Skip to content

Commit

Permalink
docs: Document how to use rules_cuda with Bzlmod (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vertexwahn authored Jun 11, 2024
1 parent ec375a2 commit 1fad6ba
Showing 1 changed file with 28 additions and 2 deletions.
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

0 comments on commit 1fad6ba

Please sign in to comment.