Skip to content
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

Expand basic example to have both CC library and CUDA library #170

Open
nicmcd opened this issue Sep 22, 2023 · 3 comments
Open

Expand basic example to have both CC library and CUDA library #170

nicmcd opened this issue Sep 22, 2023 · 3 comments

Comments

@nicmcd
Copy link

nicmcd commented Sep 22, 2023

Can you expand the basic example to have both CC library and CUDA library?

@cloudhan
Copy link
Collaborator

cloudhan commented Oct 2, 2023

Sorry for the delayed reply. I am not sure what you (or presumably for new users) are confusing about, could you please elaborate a bit on why that is important. Also, contributions are welcomed.

@nicmcd
Copy link
Author

nicmcd commented Jan 23, 2024

In Bazel there are now 2 types of libraries, CC and CUDA. However, in a CUDA program, there are 3 types of code: 1) code that runs on the CPU that has nothing to do with GPUs, 2) code that runs on the CPU that sets up and manages the launching of GPU kernels (which needs cuda_runtime.h, and 3) code that runs on the GPU. How do these 3 types of code get mapped to the 2 types of bazel libraries?

@cloudhan
Copy link
Collaborator

there are 3 types of code

You might misunderstanding it a little bit. There is actually 2 languages involved, cuda and cpp, and cuda is a superset of cpp, so

  1. pure cpp
  2. cpp mixed with cuda, but still cuda anyway
  3. pure cuda.

So cc rules should be used to handle cpp language and cuda rules should be used to handle cuda langauge.

For the second point, it is a purely code organization thing. I'd suggest you put the launcher (a cpp function that calls a cuda kernel with <<<>>> configuration) definition in cuda and only expose the declaration to pure cpp.

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

No branches or pull requests

2 participants