This is an archive of the discontinued LLVM Phabricator instance.

[mlir][nvvm] Implement `mbarrier.init`
ClosedPublic

Authored by guraypp on May 24 2023, 6:31 AM.

Details

Summary

NV GPUs provides split arrive/wait barriers that one can syncronize a subgroup of threads in CTA. It is particularly important for Hopper GPUs and allows tracking engines like TMA. See for more details:
https://docs.nvidia.com/cuda/parallel-thread-execution/#parallel-synchronization-and-communication-instructions-mbarrier

This initial implementation sets the foundation for future enhancements and additions.

Diff Detail

Event Timeline

guraypp created this revision.May 24 2023, 6:31 AM
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
guraypp requested review of this revision.May 24 2023, 6:31 AM
qcolombet added inline comments.
mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
193

I don't think it makes a difference in practice, thanks to the opaque pointers work, but the intrinsic definition in llvm has shared_i64ptr, i.e., pointed type is to i64 not i8.

Same for the generic mbarrier.init.

guraypp added inline comments.Jun 15 2023, 12:31 AM
mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
193

I used that pointer type because these types are used in this file.

We have the following definitions in the beginning of the file. Both looks i8, I can try to change them to i64 in another commit?

def LLVM_i8Ptr_global : LLVM_IntPtrBase<8, 1>;
def LLVM_i8Ptr_shared : LLVM_IntPtrBase<8, 3>;
guraypp updated this revision to Diff 531998.Jun 15 2023, 11:48 PM

Instructions are defined with i64 pointer type. I added i64 here

guraypp updated this revision to Diff 532014.Jun 16 2023, 12:36 AM

use i64 pointer

guraypp updated this revision to Diff 532024.Jun 16 2023, 1:03 AM
guraypp marked an inline comment as done.

add i64 any pointer

guraypp updated this revision to Diff 532025.Jun 16 2023, 1:05 AM

add any i64 pointer

guraypp updated this revision to Diff 532027.Jun 16 2023, 1:11 AM

add i64 any addrspace

qcolombet accepted this revision.Jun 16 2023, 4:33 AM
This revision is now accepted and ready to land.Jun 16 2023, 4:33 AM
This revision was automatically updated to reflect the committed changes.