Skip to content

Commit

Permalink
Add --version argument to xtask test command
Browse files Browse the repository at this point in the history
  • Loading branch information
syl20bnr committed Dec 3, 2024
1 parent 913fa46 commit 948f91f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 13 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ env:
TYPOS_LINK: "https://github.com/crate-ci/typos/releases/download"
TYPOS_VERSION: "1.23.4"
CUBECL_ROCM_PATH: "/opt/rocm"
ROCM_VERSION_FEATURE: "rocm_624"

on:
push:
Expand Down Expand Up @@ -50,13 +49,13 @@ jobs:
- name: Lint
run: cargo xtask check lint
# --------------------------------------------------------------------------------
- name: Unit Tests
- name: Unit Tests (default ROCm version)
shell: bash
run: cargo xtask test --features ${{ env.ROCM_VERSION_FEATURE }} unit
run: cargo xtask test unit
# --------------------------------------------------------------------------------
- name: Integration Tests
- name: Integration Tests (default ROCm version)
shell: bash
run: cargo xtask test --features ${{ env.ROCM_VERSION_FEATURE }} integration
run: cargo xtask test integration
# --------------------------------------------------------------------------------
- name: Documentation Tests
shell: bash
Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,24 @@ Here is a table of the libraries covered by each crate:
|:---------------|:-----------------|
| cubecl-hip-sys | hiprtc, amdhip64 |


## Running tests

To run tests you need to first meet the expectations for both `Prerequisites` and `Usage`
sections.

Then execute the following xtask command and provide the feature that corresponds to your
ROCm installation. For instance for the version `6.2.4`:
Then execute the following xtask command. If you want to test against a different version of
ROCm than the default one, use the `-v <version>`, for instance `-v 6.2.2`:

```sh
cargo xtask test --no-default-features --features rocm_622
# test default ROCm bindings
cargo xtask test
# test a specific version
cargo xtask test -v rocm_622
```

Important: always make sure that ROCm environment variable (see Usage) points to a version that matches the
tested version.

## Generate bindings for a given version of ROCm

1) To generate the bindings you need to first meet the expectations for both `Prerequisites`
Expand All @@ -98,6 +103,11 @@ rocm_624 = []

4) Replace the default feature in the `Cargo.toml` file be the latest one, in this case `rocm_624`.

```toml
[features]
default = ["rocm_624"]
```

5) Add the generated bindings module to the file `crates/cubecl-hip-sys/src/bindings/mod.rs`
conditionally to the new feature you just declared as well as the re-exports:

Expand Down
16 changes: 13 additions & 3 deletions xtask/src/commands/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
use tracel_xtask::prelude::*;

pub(crate) fn handle_command(mut args: TestCmdArgs) -> anyhow::Result<()> {
args.no_default_features = true;
base_commands::test::handle_command(args)
#[macros::extend_command_args(TestCmdArgs, Target, TestSubCommand)]
pub struct CubeClHipTestCmdArgs {
#[arg(long, short)]
pub version: Option<String>,
}

pub(crate) fn handle_command(mut args: CubeClHipTestCmdArgs) -> anyhow::Result<()> {
if let Some(version) = args.version.clone() {
let feature_name = format!("rocm_{}", version.replace(".", ""));
args.no_default_features = true;
args.features = Some(vec![feature_name]);
}
base_commands::test::handle_command(args.try_into().unwrap())
}
4 changes: 3 additions & 1 deletion xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ extern crate log;
use std::time::Instant;
use tracel_xtask::prelude::*;

#[macros::base_commands(Build, Bump, Check, Compile, Doc, Fix, Publish, Test, Validate)]
#[macros::base_commands(Build, Bump, Check, Compile, Doc, Fix, Publish, Validate)]
enum Command {
/// Generate bindings.
Bindgen(commands::bindgen::BindgenCmdArgs),
/// Test bindings.
Test(commands::test::CubeClHipTestCmdArgs),
}

fn main() -> anyhow::Result<()> {
Expand Down

0 comments on commit 948f91f

Please sign in to comment.