- 
                Notifications
    
You must be signed in to change notification settings  - Fork 74
 
[XPU][TritonGEN] Revamp SIMD block memory access operations #2756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            victor-eds
  merged 4 commits into
  intel:main
from
victor-eds:triton-gen-sub-group-block-memaccess
  
      
      
   
  Nov 20, 2024 
      
    
  
     Merged
                    Changes from 2 commits
      Commits
    
    
            Show all changes
          
          
            4 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      a0ea9f6
              
                [XPU][TritonGEN] Revamp SIMD block memory access operations
              
              
                victor-eds b184e9c
              
                Merge branch 'main' into triton-gen-sub-group-block-memaccess
              
              
                victor-eds ea25db5
              
                Drop tabs
              
              
                victor-eds 27df208
              
                Merge branch 'main' into triton-gen-sub-group-block-memaccess
              
              
                victor-eds File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -314,46 +314,97 @@ def TritonGEN_Matrix2DBlockPrefetchOp : TritonGEN_Op<"2Dblockprefetch">, | |
| let hasVerifier = 1; | ||
| } | ||
| 
     | 
||
| def TritonGEN_SIMDBlockReadOp: TritonGEN_Op<"simdblockread">, | ||
| Results<(outs FixedVectorOf<[AnyTypeOf<[AnyI8, AnyI16, AnyI32, AnyI64]>]>:$res)>, | ||
| Arguments<(ins | ||
| Arg<LLVM_AnyPointer, "", [MemRead]>:$ptr | ||
| )> { | ||
| 
     | 
||
| let summary = "simd block read"; | ||
| def TritonGEN_SubGroupBlockMemoryAccessElementType | ||
| : AnyTypeOf<[I8, I16, I32, I64], | ||
| "Valid sub-group block memory access element type">; | ||
| 
     | 
||
| def TritonGEN_SubGroupBlockMemoryAccessType | ||
| : AnyTypeOf<[TritonGEN_SubGroupBlockMemoryAccessElementType, | ||
| FixedVectorOfLengthAndType< | ||
| [2, 4, 8], | ||
| [TritonGEN_SubGroupBlockMemoryAccessElementType]>, | ||
| // Vectors of length 16 only allowed for i8 for now. | ||
| FixedVectorOfLengthAndType<[16], [I8]>], | ||
| "Valid sub-group block memory access type">; | ||
| 
     | 
||
| def TritonGEN_SubGroupBlockMemoryAccessPointerType | ||
| : Type<And<[LLVM_AnyPointer.predicate, | ||
| Or<[CPred<"::llvm::cast<::mlir::LLVM::LLVMPointerType>($_self)" # | ||
| ".getAddressSpace() == " # | ||
| "static_cast<unsigned>(kCrossWorkgroup)">, | ||
| CPred<"::llvm::cast<::mlir::LLVM::LLVMPointerType>($_self)" # | ||
| ".getAddressSpace() == " # | ||
| "static_cast<unsigned>(kWorkgroup)">]>]>, | ||
| "LLVM pointer in local or global OpenCL address space", | ||
| "::mlir::LLVM::LLVMPointerType">; | ||
| 
     | 
||
| def TritonGEN_SubGroupBlockReadOp: TritonGEN_Op<"sub_group_block_read"> { | ||
| let summary = "Sub-group block read."; | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder before merge: use spaces instead of tabs for indentation.  | 
||
| 
     | 
||
| let description = [{ | ||
| The `triton_gen.simdblockread` operation performs simd block read from | ||
| a start address without laneId offset. The parameters are: | ||
| $ptr - the base address to read data | ||
| The `triton_gen.sub_group_block_read` reads a scalar or vector for each | ||
| work-item in the sub-group from pointer `ptr` as a block operation. | ||
| The data is read strided, so the first value is read from: | ||
| ``` | ||
| ptr[sub_group_local_id] | ||
| ``` | ||
| and the second one is: | ||
| ``` | ||
| ptr[sub_group_local_id + sub_group_size] | ||
| ``` | ||
| etc. | ||
| 
     | 
||
| `ptr` must be aligned to the size of the element type of `res`. | ||
| 
     | 
||
| Example: | ||
| ```mlir | ||
| %0 = triton_gen.sub_group_block_read %ptr : !llvm.ptr<1> -> vector<4xi32> | ||
| ``` | ||
| }]; | ||
| 
     | 
||
| let arguments = (ins | ||
| Arg<TritonGEN_SubGroupBlockMemoryAccessPointerType, "", [MemRead]>:$ptr); | ||
| 
     | 
||
| let results = (outs TritonGEN_SubGroupBlockMemoryAccessType:$res); | ||
| 
     | 
||
| let assemblyFormat = [{ | ||
| operands ` ` attr-dict `:` functional-type(operands, results) | ||
| $ptr attr-dict `:` qualified(type($ptr)) `->` type($res) | ||
| }]; | ||
| 
     | 
||
| let hasVerifier = 1; | ||
| } | ||
| 
     | 
||
| def TritonGEN_SIMDBlockWriteOp : TritonGEN_Op<"simdblockwrite">, | ||
| Arguments<(ins | ||
| Arg<LLVM_AnyPointer, "", [MemWrite]>:$ptr, | ||
| FixedVectorOf<[AnyTypeOf<[AnyI8, AnyI16, AnyI32, AnyI64]>]>:$val | ||
| )> { | ||
| 
     | 
||
| def TritonGEN_SubGroupBlockWriteOp : TritonGEN_Op<"sub_group_block_write"> { | ||
| let summary = "simd block write"; | ||
| 
     | 
||
| let description = [{ | ||
| The `triton_gen.simdblockwrite` operation performs simd block write to | ||
| a start address without laneId offset. The parameters are: | ||
| $ptr - the base address to be written | ||
| $val - the value vector to write | ||
| The `triton_gen.sub_group_block_write` writes a scalar or vector for each | ||
| work-item in the sub-group from pointer `ptr` as a block operation. | ||
| The data is read strided, so the first value is written to: | ||
| ``` | ||
| ptr[sub_group_local_id] | ||
| ``` | ||
| and the second one is: | ||
| ``` | ||
| ptr[sub_group_local_id + sub_group_size] | ||
| ``` | ||
| etc. | ||
| 
     | 
||
| `ptr` must be aligned to the size of the element type of `res`. | ||
| 
     | 
||
| Example: | ||
| ```mlir | ||
| %0 = triton_gen.sub_group_block_write %ptr, %val : !llvm.ptr<1>, vector<4xi32> | ||
                
      
                  victor-eds marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| ``` | ||
| }]; | ||
| 
     | 
||
| let arguments = (ins | ||
| Arg<TritonGEN_SubGroupBlockMemoryAccessPointerType, "", [MemRead]>:$ptr, | ||
| TritonGEN_SubGroupBlockMemoryAccessType:$val); | ||
| 
     | 
||
| let results = (outs); | ||
| 
     | 
||
| let assemblyFormat = [{ | ||
| operands ` ` attr-dict `:` `(` type(operands) `)` | ||
| $ptr `,` $val attr-dict `:` qualified(type($ptr)) `,` type($val) | ||
| }]; | ||
| 
     | 
||
| let hasVerifier = 1; | ||
| } | ||
| 
     | 
||
| #endif // TRITONGEN_OPS | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.