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

Document how to use rules_cuda with Bzlmod #252

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ These rules provide some macros and rules that make it easier to build CUDA with

## Getting Started

### Traditional WORKSPACE approach

Add the following to your `WORKSPACE` file and replace the placeholders with actual values.

```starlark
Expand All @@ -29,11 +31,35 @@ ensure the host compiler is available. On Windows, this means that you will also
and [`detect_clang`](https://github.com/bazel-contrib/rules_cuda/blob/5633f0c0f7/cuda/private/repositories.bzl#L143-L166)
determains how the toolchains are detected.

### Bzlmod

Add the following to your `MODULE.bazel` file and replace the placeholders with actual values.

```starlark
bazel_dep(name = "rules_cuda", version = "0.2.1")

# pick a specific version (this is optional an can be skipped)
archive_override(
module_name = "rules_cuda",
integrity = "{sha256_to_replace}",
urls = "https://github.com/bazel-contrib/rules_cuda/archive/{git_commit_hash}.tar.gz",
strip_prefix = "rules_cuda-{git_commit_hash}",
)

cuda = use_extension("@rules_cuda//cuda:extensions.bzl", "toolchain")
cuda.local_toolchain(
name = "local_cuda",
toolkit_path = "",
)
use_repo(cuda, "local_cuda")
```

### Rules

- `cuda_library`: Can be used to compile and create static library for CUDA kernel code. The resulting targets can be
consumed by [C/C++ Rules](https://bazel.build/reference/be/c-cpp#rules).
- `cuda_objects`: If you don't understand what _device link_ means, you must never use it. This rule produces incomplete object files that can only be consumed by `cuda_library`. It is created for relocatable device code and device link
- `cuda_objects`: If you don't understand what _device link_ means, you must never use it. This rule produces incomplete
object files that can only be consumed by `cuda_library`. It is created for relocatable device code and device link
time optimization source files.

### Flags
Expand Down Expand Up @@ -96,7 +122,7 @@ Checkout the examples to see if it fits your needs.

See [examples](./examples) for basic usage.

See [rules_cuda_examples](https://github.com/cloudhan/rules_cuda_examples) for extended real world projects.
See [rules_cuda_examples](https://github.com/cloudhan/rules_cuda_examples) for extended real-world projects.

## Known issue

Expand Down