Skip to content

Commit 227122c

Browse files
mivertowskiclaude
andcommitted
fix(accnet,procint): migrate from cudarc 0.11 API to 0.19.3
Pre-existing bug: accnet and procint used old cudarc 0.11 API (CudaDevice, load_ptx, htod_copy, get_func, LaunchAsync) which only compiled when cuda feature was disabled. Now fixed: - CudaDevice -> CudaContext - load_ptx() -> load_module() + load_function() - htod_copy() -> stream.clone_htod() - get_func() + func.launch() -> stream.launch_builder().arg().launch() - dtoh_sync_copy() -> stream.clone_dtoh() - device.synchronize() -> context.synchronize() Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 257e5f9 commit 227122c

3 files changed

Lines changed: 266 additions & 268 deletions

File tree

crates/ringkernel-accnet/src/actors/runtime.rs

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub struct GpuActorRuntime {
117117
messages_processed: u64,
118118
/// CUDA device handle (when feature enabled).
119119
#[cfg(feature = "cuda")]
120-
cuda_device: Option<Arc<cudarc::driver::CudaDevice>>,
120+
cuda_device: Option<Arc<cudarc::driver::CudaContext>>,
121121
/// Compiled PTX modules (reserved for future multi-kernel support).
122122
#[cfg(feature = "cuda")]
123123
#[allow(dead_code)]
@@ -168,17 +168,14 @@ impl GpuActorRuntime {
168168
fn init_gpu() -> (bool, Option<String>, Option<(u32, u32)>) {
169169
#[cfg(feature = "cuda")]
170170
{
171-
match cudarc::driver::CudaDevice::new(0) {
172-
Ok(device) => {
173-
let name = device.name().unwrap_or_else(|_| "Unknown GPU".to_string());
171+
match cudarc::driver::CudaContext::new(0) {
172+
Ok(context) => {
173+
let name = context.name().unwrap_or_else(|_| "Unknown GPU".to_string());
174174
// Get compute capability
175-
let cc = device.attribute(
176-
cudarc::driver::sys::CUdevice_attribute::CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR
177-
).ok().and_then(|major| {
178-
device.attribute(
179-
cudarc::driver::sys::CUdevice_attribute::CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR
180-
).ok().map(|minor| (major as u32, minor as u32))
181-
});
175+
let cc = context
176+
.compute_capability()
177+
.ok()
178+
.map(|(major, minor)| (major as u32, minor as u32));
182179
log::info!("GPU initialized: {} (CC {:?})", name, cc);
183180
(true, Some(name), cc)
184181
}
@@ -270,12 +267,11 @@ impl GpuActorRuntime {
270267
network: &AccountingNetwork,
271268
result: &mut GpuAnalyticsResult,
272269
) -> crate::Result<()> {
273-
use cudarc::driver::*;
274-
275270
let device = match &self.cuda_device {
276271
Some(d) => d.clone(),
277272
None => {
278-
let d = CudaDevice::new(0).map_err(|e| AccNetError::DeviceCreation(e.to_string()))?;
273+
let d = cudarc::driver::CudaContext::new(0)
274+
.map_err(|e| AccNetError::DeviceCreation(e.to_string()))?;
279275
self.cuda_device = Some(d.clone());
280276
d
281277
}
@@ -325,7 +321,7 @@ impl GpuActorRuntime {
325321
#[cfg(feature = "cuda")]
326322
fn compute_pagerank_gpu(
327323
&self,
328-
_device: &Arc<cudarc::driver::CudaDevice>,
324+
_device: &Arc<cudarc::driver::CudaContext>,
329325
network: &AccountingNetwork,
330326
) -> crate::Result<Vec<f64>> {
331327
// For now, use CPU implementation until ring kernel infrastructure is ready
@@ -339,7 +335,7 @@ impl GpuActorRuntime {
339335
#[cfg(feature = "cuda")]
340336
fn detect_fraud_gpu(
341337
&self,
342-
_device: &Arc<cudarc::driver::CudaDevice>,
338+
_device: &Arc<cudarc::driver::CudaContext>,
343339
network: &AccountingNetwork,
344340
) -> crate::Result<(u32, Vec<u32>)> {
345341
let n_flows = network.flows.len();
@@ -378,7 +374,7 @@ impl GpuActorRuntime {
378374
#[cfg(feature = "cuda")]
379375
fn validate_gaap_gpu(
380376
&self,
381-
_device: &Arc<cudarc::driver::CudaDevice>,
377+
_device: &Arc<cudarc::driver::CudaContext>,
382378
network: &AccountingNetwork,
383379
) -> crate::Result<(u32, Vec<u32>)> {
384380
let n_flows = network.flows.len();
@@ -415,7 +411,7 @@ impl GpuActorRuntime {
415411
#[cfg(feature = "cuda")]
416412
fn analyze_benford_gpu(
417413
&self,
418-
_device: &Arc<cudarc::driver::CudaDevice>,
414+
_device: &Arc<cudarc::driver::CudaContext>,
419415
network: &AccountingNetwork,
420416
) -> crate::Result<([u32; 9], f32, bool)> {
421417
let mut counts = [0u32; 9];
@@ -457,7 +453,7 @@ impl GpuActorRuntime {
457453
#[cfg(feature = "cuda")]
458454
fn detect_suspense_gpu(
459455
&self,
460-
_device: &Arc<cudarc::driver::CudaDevice>,
456+
_device: &Arc<cudarc::driver::CudaContext>,
461457
network: &AccountingNetwork,
462458
) -> crate::Result<(u32, Vec<f32>)> {
463459
let n_accounts = network.accounts.len();

0 commit comments

Comments
 (0)