llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Support `@llvm.nvvm.membar` intrinsic

Open vchuravy opened this issue 3 years ago • 12 comments

It looks like Nvidia added a new nvvm intrinsics as part of hopper and deprecated the old format.

https://docs.nvidia.com/cuda/nvvm-ir-spec/index.html#barrier-and-memory-fence

https://godbolt.org/z/hvqPTb5eq

cc: @maleadt

vchuravy avatar Mar 10 '23 17:03 vchuravy

@llvm/issue-subscribers-julialang

llvmbot avatar Mar 10 '23 17:03 llvmbot

General caveat: NVVM != LLVM and LLVM does not match the intrinsics provided by NVVM. Whether LLVM will end up using the same signature if/when it's implemented will depend on whether it's suitable for LLVM.

To provide more specifics for this feature request. Currently we provide a subset of membar intrinsics for cta/gl/sys variants: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/NVPTX/NVPTXIntrinsics.td#L302

NVVM has introduced a unified variant which accepts an integer constant which selects a particular instruction variant.

declare void @llvm.nvvm.membar(i32 %flags)

image

Artem-B avatar Mar 10 '23 18:03 Artem-B

Can I ask the dumb question of why these aren't spelled fence syncscope?

Keno avatar Mar 10 '23 21:03 Keno

That's an excellent question in particular due to the fact that there are also now are scoped atomics (which you currently need to implement by embedding assembly) for NVPTX.

vchuravy avatar Mar 10 '23 21:03 vchuravy

Naming is hard. Once particular name is used, it becomes pretty hard to change or undo it. The initial choices, even when they turn out to be suboptimal later, often continue to live on.

Artem-B avatar Mar 10 '23 22:03 Artem-B

@Artem-B I am looking for easy tasks to work on I am new to the backend, but I am interested in GPUs. Is this an easy one? If not, can you suggest some? and please suggest ones that don't require GPUs.

Thanks

elhewaty avatar Mar 12 '24 21:03 elhewaty

@Artem-B Ping. I got an Nvidia GPU. Is this an easy issue to start with?

elhewaty avatar Nov 16 '24 13:11 elhewaty

The first question is whether we should do this. 1:1 match with NVVM is not LLVM's goal. Doing it for the sake of doing does not make a lot of sense. If there's a specific use case where it's needed, then we can consider it. Otherwise, I'd suggest picking something else as a starter project.

@justinfargnoli -- do you have anything on your TODO list which would work as a self-contained starter project?

Artem-B avatar Nov 18 '24 18:11 Artem-B

Thanks for the ping @Artem-B.

@elhewaty, I'm happy to hear that you are interested in contributing!

I wrote down some ideas I've had in the back of my head in these two issues: #116695 and #116697.

Another simple first issue is #114339. However, that's currently assigned to @Quark-69. I'll leave it to him to update you on whether he will continue working on it or if he has put it down to focus on other things.

@durga4github or @schwarzschild-radius may know other good starter issues related to intrinsic support.

I also regularly file bugs based on improvements that @Artem-B suggests during reviews. So, if the current set of good first issues doesn't appeal, I'll continuously add more.

justinfargnoli avatar Nov 18 '24 22:11 justinfargnoli

Also, @elhewaty, is there a particular area you are interested in contributing to? I can watch for work that crops up in that area.

justinfargnoli avatar Nov 18 '24 22:11 justinfargnoli

@elhewaty i am still working on the issue it's just that sem exams are going on. I'll get back on track after 3-4 days.

SergeantCooper avatar Nov 19 '24 01:11 SergeantCooper

@justinfargnoli, thank you for your reply. Anyarea is fine but GPU compilers or backends will be great for me.

elhewaty avatar Nov 19 '24 14:11 elhewaty