Skip to content

Commit b2233fd

Browse files
authored
feat: upgrade ceno-gpu (#1127)
1. upgrade: cudarc v0.17.3 (scroll-tech/ceno-gpu#96) 2. perf: batch sumcheck (scroll-tech/ceno-gpu#97) ~~3. perf: gpu evaulate~~ ~~4. perf: build tower witness~~
1 parent 69dd886 commit b2233fd

File tree

5 files changed

+12
-23
lines changed

5 files changed

+12
-23
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
8282
uint = "0.8"
8383

8484
ceno_gpu = { path = "utils/cuda_hal", package = "cuda_hal" }
85+
cudarc = { version = "0.17.3", features = ["driver", "cuda-version-from-build-system"] }
8586

8687
[profile.dev]
8788
lto = "thin"

ceno_zkvm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ceno-examples = { path = "../examples-builder" }
1515
ceno_emul = { path = "../ceno_emul" }
1616
ceno_gpu = { workspace = true, optional = true }
1717
ceno_host = { path = "../ceno_host" }
18-
cudarc = { version = "0.13.0", features = ["driver", "cuda-version-from-build-system"], optional = true }
18+
cudarc = { workspace = true, optional = true }
1919
either.workspace = true
2020
ff_ext.workspace = true
2121
gkr_iop = { path = "../gkr_iop" }

gkr_iop/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ version.workspace = true
1212
[dependencies]
1313
bincode.workspace = true
1414
ceno_gpu = { workspace = true, optional = true }
15-
cudarc = { version = "0.13.0", features = ["driver", "cuda-version-from-build-system"], optional = true }
15+
cudarc = { workspace = true, optional = true }
1616
either.workspace = true
1717
ff_ext.workspace = true
1818
itertools.workspace = true

gkr_iop/src/gpu/mod.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,44 +27,32 @@ pub mod gpu_prover {
2727
common::{
2828
basefold::utils::convert_ceno_to_gpu_basefold_commitment,
2929
buffer::BufferImpl,
30+
get_ceno_gpu_device_id,
3031
mle::{
3132
build_mle_as_ceno, ordered_sparse32_selector_gpu, rotation_next_base_mle_gpu,
3233
rotation_selector_gpu,
3334
},
3435
},
3536
};
36-
use cudarc::driver::{CudaDevice, DriverError};
37+
3738
use once_cell::sync::Lazy;
3839
use std::sync::{Arc, Mutex, MutexGuard};
3940

4041
pub type BB31Base = p3::babybear::BabyBear;
4142
pub type BB31Ext = ff_ext::BabyBearExt4;
4243

43-
pub static CUDA_DEVICE: Lazy<Result<Arc<CudaDevice>, DriverError>> =
44-
Lazy::new(|| CudaDevice::new(0));
45-
4644
#[allow(clippy::type_complexity)]
4745
pub static CUDA_HAL: Lazy<
4846
Result<Arc<Mutex<CudaHalBB31>>, Box<dyn std::error::Error + Send + Sync>>,
4947
> = Lazy::new(|| {
50-
let device = CUDA_DEVICE
51-
.as_ref()
52-
.map_err(|e| format!("Device init failed: {:?}", e))?;
53-
device.bind_to_thread()?;
54-
55-
CudaHalBB31::new()
48+
// can be overridden by env variable `CENO_GPU_DEVICE_ID`
49+
let device_id: usize = get_ceno_gpu_device_id(0);
50+
CudaHalBB31::new(device_id)
5651
.map(|hal| Arc::new(Mutex::new(hal)))
5752
.map_err(|e| Box::new(e) as Box<dyn std::error::Error + Send + Sync>)
5853
});
5954

6055
pub fn get_cuda_hal() -> Result<MutexGuard<'static, CudaHalBB31>, String> {
61-
let device = CUDA_DEVICE
62-
.as_ref()
63-
.map_err(|e| format!("Device not available: {:?}", e))?;
64-
device
65-
.bind_to_thread()
66-
.map_err(|e| format!("Failed to bind device to thread: {:?}", e))?;
67-
6856
let hal_arc = CUDA_HAL
6957
.as_ref()
7058
.map_err(|e| format!("HAL not available: {:?}", e))?;

0 commit comments

Comments
 (0)