@@ -46,25 +46,25 @@ pub fn is_cuda_available() -> bool {
4646fn check_cuda_available ( ) -> bool {
4747 unsafe {
4848 // Try to initialize CUDA
49- let result = cuda_sys :: cuInit ( 0 ) ;
49+ let result = rdmaxcel_sys :: rdmaxcel_cuInit ( 0 ) ;
5050
51- if result != cuda_sys :: CUresult :: CUDA_SUCCESS {
51+ if result != rdmaxcel_sys :: CUDA_SUCCESS {
5252 return false ;
5353 }
5454
5555 // Check if there are any CUDA devices
5656 let mut device_count: i32 = 0 ;
57- let count_result = cuda_sys :: cuDeviceGetCount ( & mut device_count) ;
57+ let count_result = rdmaxcel_sys :: rdmaxcel_cuDeviceGetCount ( & mut device_count) ;
5858
59- if count_result != cuda_sys :: CUresult :: CUDA_SUCCESS || device_count <= 0 {
59+ if count_result != rdmaxcel_sys :: CUDA_SUCCESS || device_count <= 0 {
6060 return false ;
6161 }
6262
6363 // Try to get the first device to verify it's actually accessible
64- let mut device: cuda_sys :: CUdevice = std:: mem:: zeroed ( ) ;
65- let device_result = cuda_sys :: cuDeviceGet ( & mut device, 0 ) ;
64+ let mut device: rdmaxcel_sys :: CUdevice = std:: mem:: zeroed ( ) ;
65+ let device_result = rdmaxcel_sys :: rdmaxcel_cuDeviceGet ( & mut device, 0 ) ;
6666
67- if device_result != cuda_sys :: CUresult :: CUDA_SUCCESS {
67+ if device_result != rdmaxcel_sys :: CUDA_SUCCESS {
6868 return false ;
6969 }
7070
@@ -270,8 +270,8 @@ pub mod test_utils {
270270 pub actor_2 : ActorRef < RdmaManagerActor > ,
271271 pub rdma_handle_1 : RdmaBuffer ,
272272 pub rdma_handle_2 : RdmaBuffer ,
273- cuda_context_1 : Option < cuda_sys :: CUcontext > ,
274- cuda_context_2 : Option < cuda_sys :: CUcontext > ,
273+ cuda_context_1 : Option < rdmaxcel_sys :: CUcontext > ,
274+ cuda_context_2 : Option < rdmaxcel_sys :: CUcontext > ,
275275 }
276276
277277 #[ derive( Debug , Clone ) ]
@@ -375,46 +375,53 @@ pub mod test_utils {
375375 }
376376 // CUDA case
377377 unsafe {
378- cu_check ! ( cuda_sys :: cuInit ( 0 ) ) ;
378+ cu_check ! ( rdmaxcel_sys :: rdmaxcel_cuInit ( 0 ) ) ;
379379
380- let mut dptr: cuda_sys :: CUdeviceptr = std:: mem:: zeroed ( ) ;
381- let mut handle: cuda_sys :: CUmemGenericAllocationHandle = std:: mem:: zeroed ( ) ;
380+ let mut dptr: rdmaxcel_sys :: CUdeviceptr = std:: mem:: zeroed ( ) ;
381+ let mut handle: rdmaxcel_sys :: CUmemGenericAllocationHandle = std:: mem:: zeroed ( ) ;
382382
383- let mut device: cuda_sys:: CUdevice = std:: mem:: zeroed ( ) ;
384- cu_check ! ( cuda_sys:: cuDeviceGet( & mut device, accel. 1 as i32 ) ) ;
383+ let mut device: rdmaxcel_sys:: CUdevice = std:: mem:: zeroed ( ) ;
384+ cu_check ! ( rdmaxcel_sys:: rdmaxcel_cuDeviceGet(
385+ & mut device,
386+ accel. 1 as i32
387+ ) ) ;
385388
386- let mut context: cuda_sys:: CUcontext = std:: mem:: zeroed ( ) ;
387- cu_check ! ( cuda_sys:: cuCtxCreate_v2( & mut context, 0 , accel. 1 as i32 ) ) ;
388- cu_check ! ( cuda_sys:: cuCtxSetCurrent( context) ) ;
389+ let mut context: rdmaxcel_sys:: CUcontext = std:: mem:: zeroed ( ) ;
390+ cu_check ! ( rdmaxcel_sys:: rdmaxcel_cuCtxCreate_v2(
391+ & mut context,
392+ 0 ,
393+ accel. 1 as i32
394+ ) ) ;
395+ cu_check ! ( rdmaxcel_sys:: rdmaxcel_cuCtxSetCurrent( context) ) ;
389396
390397 let mut granularity: usize = 0 ;
391- let mut prop: cuda_sys :: CUmemAllocationProp = std:: mem:: zeroed ( ) ;
392- prop. type_ = cuda_sys :: CUmemAllocationType :: CU_MEM_ALLOCATION_TYPE_PINNED ;
393- prop. location . type_ = cuda_sys :: CUmemLocationType :: CU_MEM_LOCATION_TYPE_DEVICE ;
398+ let mut prop: rdmaxcel_sys :: CUmemAllocationProp = std:: mem:: zeroed ( ) ;
399+ prop. type_ = rdmaxcel_sys :: CU_MEM_ALLOCATION_TYPE_PINNED ;
400+ prop. location . type_ = rdmaxcel_sys :: CU_MEM_LOCATION_TYPE_DEVICE ;
394401 prop. location . id = device;
395402 prop. allocFlags . gpuDirectRDMACapable = 1 ;
396403 prop. requestedHandleTypes =
397- cuda_sys :: CUmemAllocationHandleType :: CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR ;
404+ rdmaxcel_sys :: CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR ;
398405
399- cu_check ! ( cuda_sys :: cuMemGetAllocationGranularity (
406+ cu_check ! ( rdmaxcel_sys :: rdmaxcel_cuMemGetAllocationGranularity (
400407 & mut granularity as * mut usize ,
401408 & prop,
402- cuda_sys :: CUmemAllocationGranularity_flags :: CU_MEM_ALLOC_GRANULARITY_MINIMUM ,
409+ rdmaxcel_sys :: CU_MEM_ALLOC_GRANULARITY_MINIMUM ,
403410 ) ) ;
404411
405412 // ensure our size is aligned
406413 let /*mut*/ padded_size: usize = ( ( buffer_size - 1 ) / granularity + 1 ) * granularity;
407414 assert ! ( padded_size == buffer_size) ;
408415
409- cu_check ! ( cuda_sys :: cuMemCreate (
410- & mut handle as * mut cuda_sys :: CUmemGenericAllocationHandle ,
416+ cu_check ! ( rdmaxcel_sys :: rdmaxcel_cuMemCreate (
417+ & mut handle as * mut rdmaxcel_sys :: CUmemGenericAllocationHandle ,
411418 padded_size,
412419 & prop,
413420 0
414421 ) ) ;
415422 // reserve and map the memory
416- cu_check ! ( cuda_sys :: cuMemAddressReserve (
417- & mut dptr as * mut cuda_sys :: CUdeviceptr ,
423+ cu_check ! ( rdmaxcel_sys :: rdmaxcel_cuMemAddressReserve (
424+ & mut dptr as * mut rdmaxcel_sys :: CUdeviceptr ,
418425 padded_size,
419426 0 ,
420427 0 ,
@@ -424,25 +431,28 @@ pub mod test_utils {
424431 assert ! ( padded_size. is_multiple_of( granularity) ) ;
425432
426433 // fails if a add cu_check macro; but passes if we don't
427- let err = cuda_sys :: cuMemMap (
428- dptr as cuda_sys :: CUdeviceptr ,
434+ let err = rdmaxcel_sys :: rdmaxcel_cuMemMap (
435+ dptr as rdmaxcel_sys :: CUdeviceptr ,
429436 padded_size,
430437 0 ,
431- handle as cuda_sys :: CUmemGenericAllocationHandle ,
438+ handle as rdmaxcel_sys :: CUmemGenericAllocationHandle ,
432439 0 ,
433440 ) ;
434- if err != cuda_sys :: CUresult :: CUDA_SUCCESS {
441+ if err != rdmaxcel_sys :: CUDA_SUCCESS {
435442 panic ! ( "failed reserving and mapping memory {:?}" , err) ;
436443 }
437444
438445 // set access
439- let mut access_desc: cuda_sys:: CUmemAccessDesc = std:: mem:: zeroed ( ) ;
440- access_desc. location . type_ =
441- cuda_sys:: CUmemLocationType :: CU_MEM_LOCATION_TYPE_DEVICE ;
446+ let mut access_desc: rdmaxcel_sys:: CUmemAccessDesc = std:: mem:: zeroed ( ) ;
447+ access_desc. location . type_ = rdmaxcel_sys:: CU_MEM_LOCATION_TYPE_DEVICE ;
442448 access_desc. location . id = device;
443- access_desc. flags =
444- cuda_sys:: CUmemAccess_flags :: CU_MEM_ACCESS_FLAGS_PROT_READWRITE ;
445- cu_check ! ( cuda_sys:: cuMemSetAccess( dptr, padded_size, & access_desc, 1 ) ) ;
449+ access_desc. flags = rdmaxcel_sys:: CU_MEM_ACCESS_FLAGS_PROT_READWRITE ;
450+ cu_check ! ( rdmaxcel_sys:: rdmaxcel_cuMemSetAccess(
451+ dptr,
452+ padded_size,
453+ & access_desc,
454+ 1
455+ ) ) ;
446456 buf_vec. push ( Buffer {
447457 ptr : dptr,
448458 len : padded_size,
@@ -460,11 +470,11 @@ pub mod test_utils {
460470 }
461471 unsafe {
462472 // Use the CUDA context that was created for the first buffer
463- cu_check ! ( cuda_sys :: cuCtxSetCurrent (
473+ cu_check ! ( rdmaxcel_sys :: rdmaxcel_cuCtxSetCurrent (
464474 cuda_contexts[ 0 ] . expect( "No CUDA context found" )
465475 ) ) ;
466476
467- cu_check ! ( cuda_sys :: cuMemcpyHtoD_v2 (
477+ cu_check ! ( rdmaxcel_sys :: rdmaxcel_cuMemcpyHtoD_v2 (
468478 buf_vec[ 0 ] . ptr,
469479 temp_buffer. as_ptr( ) as * const std:: ffi:: c_void,
470480 temp_buffer. len( )
@@ -514,30 +524,30 @@ pub mod test_utils {
514524 . await ?;
515525 if self . cuda_context_1 . is_some ( ) {
516526 unsafe {
517- cu_check ! ( cuda_sys :: cuCtxSetCurrent (
527+ cu_check ! ( rdmaxcel_sys :: rdmaxcel_cuCtxSetCurrent (
518528 self . cuda_context_1. expect( "No CUDA context found" )
519529 ) ) ;
520- cu_check ! ( cuda_sys :: cuMemUnmap (
521- self . buffer_1. ptr as cuda_sys :: CUdeviceptr ,
530+ cu_check ! ( rdmaxcel_sys :: rdmaxcel_cuMemUnmap (
531+ self . buffer_1. ptr as rdmaxcel_sys :: CUdeviceptr ,
522532 self . buffer_1. len
523533 ) ) ;
524- cu_check ! ( cuda_sys :: cuMemAddressFree (
525- self . buffer_1. ptr as cuda_sys :: CUdeviceptr ,
534+ cu_check ! ( rdmaxcel_sys :: rdmaxcel_cuMemAddressFree (
535+ self . buffer_1. ptr as rdmaxcel_sys :: CUdeviceptr ,
526536 self . buffer_1. len
527537 ) ) ;
528538 }
529539 }
530540 if self . cuda_context_2 . is_some ( ) {
531541 unsafe {
532- cu_check ! ( cuda_sys :: cuCtxSetCurrent (
542+ cu_check ! ( rdmaxcel_sys :: rdmaxcel_cuCtxSetCurrent (
533543 self . cuda_context_2. expect( "No CUDA context found" )
534544 ) ) ;
535- cu_check ! ( cuda_sys :: cuMemUnmap (
536- self . buffer_2. ptr as cuda_sys :: CUdeviceptr ,
545+ cu_check ! ( rdmaxcel_sys :: rdmaxcel_cuMemUnmap (
546+ self . buffer_2. ptr as rdmaxcel_sys :: CUdeviceptr ,
537547 self . buffer_2. len
538548 ) ) ;
539- cu_check ! ( cuda_sys :: cuMemAddressFree (
540- self . buffer_2. ptr as cuda_sys :: CUdeviceptr ,
549+ cu_check ! ( rdmaxcel_sys :: rdmaxcel_cuMemAddressFree (
550+ self . buffer_2. ptr as rdmaxcel_sys :: CUdeviceptr ,
541551 self . buffer_2. len
542552 ) ) ;
543553 }
@@ -579,12 +589,12 @@ pub mod test_utils {
579589 let mut temp_buffer = vec ! [ 0u8 ; size] . into_boxed_slice ( ) ;
580590 // SAFETY: The buffer is allocated with the correct size and the pointer is valid.
581591 unsafe {
582- cu_check ! ( cuda_sys :: cuCtxSetCurrent (
592+ cu_check ! ( rdmaxcel_sys :: rdmaxcel_cuCtxSetCurrent (
583593 cuda_context. expect( "No CUDA context found" )
584594 ) ) ;
585- cu_check ! ( cuda_sys :: cuMemcpyDtoH_v2 (
595+ cu_check ! ( rdmaxcel_sys :: rdmaxcel_cuMemcpyDtoH_v2 (
586596 temp_buffer. as_mut_ptr( ) as * mut std:: ffi:: c_void,
587- virtual_addr as cuda_sys :: CUdeviceptr ,
597+ virtual_addr as rdmaxcel_sys :: CUdeviceptr ,
588598 size
589599 ) ) ;
590600 }
0 commit comments