@@ -116,7 +116,7 @@ use crate::device::Device;
116
116
use crate :: error:: { CudaResult , DropResult , ToResult } ;
117
117
use crate :: private:: Sealed ;
118
118
use crate :: CudaApiVersion ;
119
- use cuda_sys :: cuda :: { self , CUcontext } ;
119
+ use cuda_driver_sys :: CUcontext ;
120
120
use std:: mem;
121
121
use std:: mem:: transmute;
122
122
use std:: ptr;
@@ -262,7 +262,7 @@ impl Context {
262
262
// lifetime guarantees so we create-and-push, then pop, then the programmer has to
263
263
// push again.
264
264
let mut ctx: CUcontext = ptr:: null_mut ( ) ;
265
- cuda :: cuCtxCreate_v2 (
265
+ cuda_driver_sys :: cuCtxCreate_v2 (
266
266
& mut ctx as * mut CUcontext ,
267
267
flags. bits ( ) ,
268
268
device. into_inner ( ) ,
@@ -294,7 +294,8 @@ impl Context {
294
294
pub fn get_api_version ( & self ) -> CudaResult < CudaApiVersion > {
295
295
unsafe {
296
296
let mut api_version = 0u32 ;
297
- cuda:: cuCtxGetApiVersion ( self . inner , & mut api_version as * mut u32 ) . to_result ( ) ?;
297
+ cuda_driver_sys:: cuCtxGetApiVersion ( self . inner , & mut api_version as * mut u32 )
298
+ . to_result ( ) ?;
298
299
Ok ( CudaApiVersion {
299
300
version : api_version as i32 ,
300
301
} )
@@ -358,7 +359,7 @@ impl Context {
358
359
359
360
unsafe {
360
361
let inner = mem:: replace ( & mut ctx. inner , ptr:: null_mut ( ) ) ;
361
- match cuda :: cuCtxDestroy_v2 ( inner) . to_result ( ) {
362
+ match cuda_driver_sys :: cuCtxDestroy_v2 ( inner) . to_result ( ) {
362
363
Ok ( ( ) ) => {
363
364
mem:: forget ( ctx) ;
364
365
Ok ( ( ) )
@@ -377,7 +378,7 @@ impl Drop for Context {
377
378
unsafe {
378
379
let inner = mem:: replace ( & mut self . inner , ptr:: null_mut ( ) ) ;
379
380
// No choice but to panic here.
380
- cuda :: cuCtxDestroy_v2 ( inner)
381
+ cuda_driver_sys :: cuCtxDestroy_v2 ( inner)
381
382
. to_result ( )
382
383
. expect ( "Failed to destroy context" ) ;
383
384
}
@@ -434,7 +435,8 @@ impl UnownedContext {
434
435
pub fn get_api_version ( & self ) -> CudaResult < CudaApiVersion > {
435
436
unsafe {
436
437
let mut api_version = 0u32 ;
437
- cuda:: cuCtxGetApiVersion ( self . inner , & mut api_version as * mut u32 ) . to_result ( ) ?;
438
+ cuda_driver_sys:: cuCtxGetApiVersion ( self . inner , & mut api_version as * mut u32 )
439
+ . to_result ( ) ?;
438
440
Ok ( CudaApiVersion {
439
441
version : api_version as i32 ,
440
442
} )
@@ -468,7 +470,7 @@ impl ContextStack {
468
470
pub fn pop ( ) -> CudaResult < UnownedContext > {
469
471
unsafe {
470
472
let mut ctx: CUcontext = ptr:: null_mut ( ) ;
471
- cuda :: cuCtxPopCurrent_v2 ( & mut ctx as * mut CUcontext ) . to_result ( ) ?;
473
+ cuda_driver_sys :: cuCtxPopCurrent_v2 ( & mut ctx as * mut CUcontext ) . to_result ( ) ?;
472
474
Ok ( UnownedContext { inner : ctx } )
473
475
}
474
476
}
@@ -493,7 +495,7 @@ impl ContextStack {
493
495
/// ```
494
496
pub fn push < C : ContextHandle > ( ctx : & C ) -> CudaResult < ( ) > {
495
497
unsafe {
496
- cuda :: cuCtxPushCurrent_v2 ( ctx. get_inner ( ) ) . to_result ( ) ?;
498
+ cuda_driver_sys :: cuCtxPushCurrent_v2 ( ctx. get_inner ( ) ) . to_result ( ) ?;
497
499
Ok ( ( ) )
498
500
}
499
501
}
@@ -540,8 +542,10 @@ impl CurrentContext {
540
542
pub fn get_cache_config ( ) -> CudaResult < CacheConfig > {
541
543
unsafe {
542
544
let mut config = CacheConfig :: PreferNone ;
543
- cuda:: cuCtxGetCacheConfig ( & mut config as * mut CacheConfig as * mut cuda:: CUfunc_cache )
544
- . to_result ( ) ?;
545
+ cuda_driver_sys:: cuCtxGetCacheConfig (
546
+ & mut config as * mut CacheConfig as * mut cuda_driver_sys:: CUfunc_cache ,
547
+ )
548
+ . to_result ( ) ?;
545
549
Ok ( config)
546
550
}
547
551
}
@@ -566,7 +570,8 @@ impl CurrentContext {
566
570
pub fn get_device ( ) -> CudaResult < Device > {
567
571
unsafe {
568
572
let mut device = Device { device : 0 } ;
569
- cuda:: cuCtxGetDevice ( & mut device. device as * mut cuda:: CUdevice ) . to_result ( ) ?;
573
+ cuda_driver_sys:: cuCtxGetDevice ( & mut device. device as * mut cuda_driver_sys:: CUdevice )
574
+ . to_result ( ) ?;
570
575
Ok ( device)
571
576
}
572
577
}
@@ -591,7 +596,7 @@ impl CurrentContext {
591
596
pub fn get_flags ( ) -> CudaResult < ContextFlags > {
592
597
unsafe {
593
598
let mut flags = 0u32 ;
594
- cuda :: cuCtxGetFlags ( & mut flags as * mut u32 ) . to_result ( ) ?;
599
+ cuda_driver_sys :: cuCtxGetFlags ( & mut flags as * mut u32 ) . to_result ( ) ?;
595
600
Ok ( ContextFlags :: from_bits_truncate ( flags) )
596
601
}
597
602
}
@@ -616,7 +621,8 @@ impl CurrentContext {
616
621
pub fn get_resource_limit ( resource : ResourceLimit ) -> CudaResult < usize > {
617
622
unsafe {
618
623
let mut limit: usize = 0 ;
619
- cuda:: cuCtxGetLimit ( & mut limit as * mut usize , transmute ( resource) ) . to_result ( ) ?;
624
+ cuda_driver_sys:: cuCtxGetLimit ( & mut limit as * mut usize , transmute ( resource) )
625
+ . to_result ( ) ?;
620
626
Ok ( limit)
621
627
}
622
628
}
@@ -641,8 +647,8 @@ impl CurrentContext {
641
647
pub fn get_shared_memory_config ( ) -> CudaResult < SharedMemoryConfig > {
642
648
unsafe {
643
649
let mut cfg = SharedMemoryConfig :: DefaultBankSize ;
644
- cuda :: cuCtxGetSharedMemConfig (
645
- & mut cfg as * mut SharedMemoryConfig as * mut cuda :: CUsharedconfig ,
650
+ cuda_driver_sys :: cuCtxGetSharedMemConfig (
651
+ & mut cfg as * mut SharedMemoryConfig as * mut cuda_driver_sys :: CUsharedconfig ,
646
652
)
647
653
. to_result ( ) ?;
648
654
Ok ( cfg)
@@ -676,7 +682,7 @@ impl CurrentContext {
676
682
least : 0 ,
677
683
greatest : 0 ,
678
684
} ;
679
- cuda :: cuCtxGetStreamPriorityRange (
685
+ cuda_driver_sys :: cuCtxGetStreamPriorityRange (
680
686
& mut range. least as * mut i32 ,
681
687
& mut range. greatest as * mut i32 ,
682
688
)
@@ -711,7 +717,7 @@ impl CurrentContext {
711
717
/// # }
712
718
/// ```
713
719
pub fn set_cache_config ( cfg : CacheConfig ) -> CudaResult < ( ) > {
714
- unsafe { cuda :: cuCtxSetCacheConfig ( transmute ( cfg) ) . to_result ( ) }
720
+ unsafe { cuda_driver_sys :: cuCtxSetCacheConfig ( transmute ( cfg) ) . to_result ( ) }
715
721
}
716
722
717
723
/// Sets a requested resource limit for the current context.
@@ -756,7 +762,7 @@ impl CurrentContext {
756
762
/// ```
757
763
pub fn set_resource_limit ( resource : ResourceLimit , limit : usize ) -> CudaResult < ( ) > {
758
764
unsafe {
759
- cuda :: cuCtxSetLimit ( transmute ( resource) , limit) . to_result ( ) ?;
765
+ cuda_driver_sys :: cuCtxSetLimit ( transmute ( resource) , limit) . to_result ( ) ?;
760
766
Ok ( ( ) )
761
767
}
762
768
}
@@ -782,7 +788,7 @@ impl CurrentContext {
782
788
/// # }
783
789
/// ```
784
790
pub fn set_shared_memory_config ( cfg : SharedMemoryConfig ) -> CudaResult < ( ) > {
785
- unsafe { cuda :: cuCtxSetSharedMemConfig ( transmute ( cfg) ) . to_result ( ) }
791
+ unsafe { cuda_driver_sys :: cuCtxSetSharedMemConfig ( transmute ( cfg) ) . to_result ( ) }
786
792
}
787
793
788
794
/// Returns a non-owning handle to the current context.
@@ -805,7 +811,7 @@ impl CurrentContext {
805
811
pub fn get_current ( ) -> CudaResult < UnownedContext > {
806
812
unsafe {
807
813
let mut ctx: CUcontext = ptr:: null_mut ( ) ;
808
- cuda :: cuCtxGetCurrent ( & mut ctx as * mut CUcontext ) . to_result ( ) ?;
814
+ cuda_driver_sys :: cuCtxGetCurrent ( & mut ctx as * mut CUcontext ) . to_result ( ) ?;
809
815
Ok ( UnownedContext { inner : ctx } )
810
816
}
811
817
}
@@ -833,15 +839,15 @@ impl CurrentContext {
833
839
/// ```
834
840
pub fn set_current < C : ContextHandle > ( c : & C ) -> CudaResult < ( ) > {
835
841
unsafe {
836
- cuda :: cuCtxSetCurrent ( c. get_inner ( ) ) . to_result ( ) ?;
842
+ cuda_driver_sys :: cuCtxSetCurrent ( c. get_inner ( ) ) . to_result ( ) ?;
837
843
Ok ( ( ) )
838
844
}
839
845
}
840
846
841
847
/// Block to wait for a context's tasks to complete.
842
848
pub fn synchronize ( ) -> CudaResult < ( ) > {
843
849
unsafe {
844
- cuda :: cuCtxSynchronize ( ) . to_result ( ) ?;
850
+ cuda_driver_sys :: cuCtxSynchronize ( ) . to_result ( ) ?;
845
851
Ok ( ( ) )
846
852
}
847
853
}
0 commit comments