From d22d725e8c88ea5a3d9a213d1b35fdc0eaad4cc2 Mon Sep 17 00:00:00 2001 From: Peter Jin Date: Mon, 10 Dec 2018 12:18:09 -0800 Subject: [PATCH] Add Cargo features for selecting installed CUDA version. Use the features to gate on the API version and a (currently empty) binding to the FP16 API. Fix for stable rustc. --- Cargo.toml | 21 +++++++++++++++++++++ src/cuda_fp16.rs | 0 src/lib.rs | 9 +++++++++ 3 files changed, 30 insertions(+) create mode 100644 src/cuda_fp16.rs diff --git a/Cargo.toml b/Cargo.toml index 6a3ef37..b60a71f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/cuda_fp16.rs b/src/cuda_fp16.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/lib.rs b/src/lib.rs index 68a42f1..e821a2e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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;