Skip to content

Commit

Permalink
Add Cargo features for selecting installed CUDA version.
Browse files Browse the repository at this point in the history
Use the features to gate on the API version and a (currently empty)
binding to the FP16 API.

Fix for stable rustc.

Update CI to set the version features.

Disable default features in CI.
  • Loading branch information
peterhj committed Dec 10, 2018
1 parent 127043c commit a127dfb
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
48 changes: 47 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 2
name: Cargo build
command: |
export PATH=/root/.cargo/bin:$PATH
cargo build -vv
cargo build -vv $CRATE_CARGO_FEATURES
.job_apt_template: &job_apt
steps:
Expand Down Expand Up @@ -35,94 +35,140 @@ jobs:
docker:
- image: nvidia/cuda:latest
9.2-devel-ubuntu18.04:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_9_2
<<: *job_apt
docker:
- image: nvidia/cuda:9.2-devel-ubuntu18.04
10.0-devel-ubuntu16.04:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_10_0
<<: *job_apt
docker:
- image: nvidia/cuda:10.0-devel-ubuntu16.04
9.2-devel-ubuntu16.04:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_9_2
<<: *job_apt
docker:
- image: nvidia/cuda:9.2-devel-ubuntu16.04
9.1-devel-ubuntu16.04:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_9_1
<<: *job_apt
docker:
- image: nvidia/cuda:9.1-devel-ubuntu16.04
9.0-devel-ubuntu16.04:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_9_0
<<: *job_apt
docker:
- image: nvidia/cuda:9.0-devel-ubuntu16.04
8.0-devel-ubuntu16.04:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_8_0
<<: *job_apt
docker:
- image: nvidia/cuda:8.0-devel-ubuntu16.04
8.0-devel-ubuntu14.04:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_8_0
<<: *job_apt
docker:
- image: nvidia/cuda:8.0-devel-ubuntu14.04
7.5-devel-ubuntu14.04:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_7_5
<<: *job_apt
docker:
- image: nvidia/cuda:7.5-devel-ubuntu14.04
7.0-devel-ubuntu14.04:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_7_0
<<: *job_apt
docker:
- image: nvidia/cuda:7.0-devel-ubuntu14.04
6.5-devel-ubuntu14.04:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_6_5
<<: *job_apt
docker:
- image: nvidia/cuda:6.5-devel-ubuntu14.04
10.0-devel-centos7:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_10_0
<<: *job_yum
docker:
- image: nvidia/cuda:10.0-devel-centos7
9.2-devel-centos7:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_9_2
<<: *job_yum
docker:
- image: nvidia/cuda:9.2-devel-centos7
9.1-devel-centos7:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_9_1
<<: *job_yum
docker:
- image: nvidia/cuda:9.1-devel-centos7
9.0-devel-centos7:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_9_0
<<: *job_yum
docker:
- image: nvidia/cuda:9.0-devel-centos7
8.0-devel-centos7:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_8_0
<<: *job_yum
docker:
- image: nvidia/cuda:8.0-devel-centos7
7.5-devel-centos7:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_7_5
<<: *job_yum
docker:
- image: nvidia/cuda:7.5-devel-centos7
7.0-devel-centos7:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_7_0
<<: *job_yum
docker:
- image: nvidia/cuda:7.0-devel-centos7
10.0-devel-centos6:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_10_0
<<: *job_yum
docker:
- image: nvidia/cuda:10.0-devel-centos6
9.2-devel-centos6:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_9_2
<<: *job_yum
docker:
- image: nvidia/cuda:9.2-devel-centos6
9.1-devel-centos6:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_9_1
<<: *job_yum
docker:
- image: nvidia/cuda:9.1-devel-centos6
9.0-devel-centos6:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_9_0
<<: *job_yum
docker:
- image: nvidia/cuda:9.0-devel-centos6
8.0-devel-centos6:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_8_0
<<: *job_yum
docker:
- image: nvidia/cuda:8.0-devel-centos6
7.5-devel-centos6:
environment:
CRATE_CARGO_FEATURES: --no-default-features --features cuda_7_5
<<: *job_yum
docker:
- image: nvidia/cuda:7.5-devel-centos6
Expand Down
21 changes: 21 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,24 @@ keywords = ["GPGPU", "CUDA", "ffi"]
license = "MIT"
readme = "README.md"
categories = []

[features]
default = ["cuda_8_0"]
cuda_6_5 = []
cuda_7_0 = ["gte_cuda_7_0"]
cuda_7_5 = ["gte_cuda_7_0", "gte_cuda_7_5"]
cuda_8_0 = ["gte_cuda_7_0", "gte_cuda_7_5", "gte_cuda_8_0"]
cuda_9_0 = ["gte_cuda_7_0", "gte_cuda_7_5", "gte_cuda_8_0", "gte_cuda_9_0"]
cuda_9_1 = ["gte_cuda_7_0", "gte_cuda_7_5", "gte_cuda_8_0", "gte_cuda_9_0", "gte_cuda_9_1"]
cuda_9_2 = ["gte_cuda_7_0", "gte_cuda_7_5", "gte_cuda_8_0", "gte_cuda_9_0", "gte_cuda_9_1", "gte_cuda_9_2"]
cuda_10_0 = ["gte_cuda_7_0", "gte_cuda_7_5", "gte_cuda_8_0", "gte_cuda_9_0", "gte_cuda_9_1", "gte_cuda_9_2", "gte_cuda_10_0"]
gte_cuda_7_0 = []
gte_cuda_7_5 = []
gte_cuda_8_0 = []
gte_cuda_9_0 = []
gte_cuda_9_1 = []
gte_cuda_9_2 = []
gte_cuda_10_0 = []

[dependencies]
static_assertions = "0.3.1"
Empty file added src/cuda_fp16.rs
Empty file.
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
#[macro_use] extern crate static_assertions;

pub mod cublas;
pub mod cuda;
pub mod cudart;
#[cfg(feature = "gte_cuda_8_0")]
pub mod cuda_fp16;
pub mod vector_types;

#[cfg(feature = "cuda_8_0")]
const_assert_eq!(cuda_8_0_api_version; cuda::__CUDA_API_VERSION, 8000);
#[cfg(feature = "cuda_8_0")]
const_assert_eq!(cuda_8_0_version; cuda::CUDA_VERSION, 8000);

#[test]
fn cuda_version() {
let mut d_ver = 0;
Expand Down

0 comments on commit a127dfb

Please sign in to comment.