forked from filecoin-project/bellperson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use Cuda cores determination from rust-gpu-tools
Determining the number of cores is generally useful, so it was moved to the rust-gpu-tools library. In order to set a custom GPU please use the `RUST_GPU_TOOLS_CUSTOM_GPU` variable instead of `BELLMAN_CUSTOM_GPU`.
- Loading branch information
Showing
5 changed files
with
77 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#![cfg(any(feature = "cuda", feature = "opencl"))] | ||
// This test is in its own file as the `RUST_GPU_TOOLS_CUSTOM_GPU` variable is checked only when | ||
// `get_core_count` is accessed for the first time. Subsequent calls will return the values it was | ||
// set to on the first call. | ||
use std::env; | ||
|
||
use bellperson::gpu::get_core_count; | ||
|
||
/// Make sure that setting the `BELLMAN_CUSTOM_GPU` env var still works. | ||
#[test] | ||
fn belllman_custom_gpu_env_var() { | ||
temp_env::with_vars( | ||
vec![ | ||
("BELLMAN_CUSTOM_GPU", Some("My custom GPU:3241")), | ||
("RUST_GPU_TOOLS_CUSTOM_GPU", None), | ||
], | ||
|| { | ||
let cores = get_core_count("My custom GPU"); | ||
let rust_gpu_tools_custom_gpu = env::var("RUST_GPU_TOOLS_CUSTOM_GPU") | ||
.expect("RUST_GPU_TOOLS_CUSTOM_GPU is set after `get_core_count` was called."); | ||
assert_eq!(rust_gpu_tools_custom_gpu, "My custom GPU:3241"); | ||
assert_eq!(cores, 3241, "Cores of custom GPU were set correctly"); | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#![cfg(any(feature = "cuda", feature = "opencl"))] | ||
// This test is in its own file as the `RUST_GPU_TOOLS_CUSTOM_GPU` variable is checked only when | ||
// `get_core_count` is accessed for the first time. Subsequent calls will return the values it was | ||
// set to on the first call. | ||
use std::env; | ||
|
||
use bellperson::gpu::get_core_count; | ||
|
||
/// Make sure that `BELLMAN_CUSTOM_GPU` env var is ignored if `RUST_GPU_TOOLS_CUSTOM_GPU` is | ||
/// set. | ||
#[test] | ||
fn belllman_custom_gpu_env_var_ignored() { | ||
temp_env::with_vars( | ||
vec![ | ||
("RUST_GPU_TOOLS_CUSTOM_GPU", Some("My custom GPU:444")), | ||
("BELLMAN_CUSTOM_GPU", Some("My custom GPU:3242")), | ||
], | ||
|| { | ||
let cores = get_core_count("My custom GPU"); | ||
env::var("RUST_GPU_TOOLS_CUSTOM_GPU") | ||
.expect("RUST_GPU_TOOLS_CUSTOM_GPU is set after `get_core_count` was called."); | ||
assert_eq!(cores, 444, "Cores of custom GPU were set correctly to the `RUST_GPU_TOOLS_CUSTOM_GPU` env var."); | ||
}, | ||
); | ||
} |