Skip to content

Conversation

@AdUhTkJm
Copy link
Contributor

This is a preparation of generating registration functions in LoweringPrepare.

CUDA compilation works as follows (irrelevant arguments omitted):

# First compile for device, generating PTX assembly
clang++ test.cu -fcuda-is-device -o device.s

# Convert that into a binary file
ptxas device.s --output-file device.o
fatbin --create device.fatbin --image=profile=sm_52,file=device.o

# Pass that file as an argument to host
clang++ test.cu -fcuda-include-gpubinary device.fatbin -cuid="some unique id"

And from the name of GPU binary, we can obtain a handle for registration. So we add an attribute to ModuleOp, recording that name.

If that -fcuda-include-gpubinary is not specified (like in the test simple.cu), OG will not generate any registration function. We do the same here by not generating the attribute.

@github-actions
Copy link

github-actions bot commented Feb 20, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after fixing minor nits

@bcardosolopes bcardosolopes merged commit dda69c8 into llvm:main Feb 22, 2025
6 checks passed
lanza pushed a commit that referenced this pull request Mar 18, 2025
This is a preparation of generating registration functions in
LoweringPrepare.

CUDA compilation works as follows (irrelevant arguments omitted):
```sh
# First compile for device, generating PTX assembly
clang++ test.cu -fcuda-is-device -o device.s

# Convert that into a binary file
ptxas device.s --output-file device.o
fatbin --create device.fatbin --image=profile=sm_52,file=device.o

# Pass that file as an argument to host
clang++ test.cu -fcuda-include-gpubinary device.fatbin -cuid="some unique id"
```
And from the name of GPU binary, we can obtain a handle for
registration. So we add an attribute to ModuleOp, recording that name.

If that `-fcuda-include-gpubinary` is not specified (like in the test
`simple.cu`), OG will not generate any registration function. We do the
same here by not generating the attribute.
terapines-osc-cir pushed a commit to Terapines/clangir that referenced this pull request Sep 2, 2025
This is a preparation of generating registration functions in
LoweringPrepare.

CUDA compilation works as follows (irrelevant arguments omitted):
```sh
# First compile for device, generating PTX assembly
clang++ test.cu -fcuda-is-device -o device.s

# Convert that into a binary file
ptxas device.s --output-file device.o
fatbin --create device.fatbin --image=profile=sm_52,file=device.o

# Pass that file as an argument to host
clang++ test.cu -fcuda-include-gpubinary device.fatbin -cuid="some unique id"
```
And from the name of GPU binary, we can obtain a handle for
registration. So we add an attribute to ModuleOp, recording that name.

If that `-fcuda-include-gpubinary` is not specified (like in the test
`simple.cu`), OG will not generate any registration function. We do the
same here by not generating the attribute.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants