@@ -81,8 +81,8 @@ static int accelerator_cuda_sync_stream(opal_accelerator_stream_t *stream);
81
81
static int accelerator_cuda_get_num_devices (int * num_devices );
82
82
static int accelerator_cuda_get_mem_bw (int device , float * bw );
83
83
84
-
85
- #define GET_STREAM ( _stream ) (_stream == MCA_ACCELERATOR_STREAM_DEFAULT ? 0 : *((CUstream *)_stream->stream))
84
+ #define GET_STREAM ( _stream ) \
85
+ (( _stream) == MCA_ACCELERATOR_STREAM_DEFAULT ? 0 : *((CUstream *) ( _stream) ->stream))
86
86
87
87
opal_accelerator_base_module_t opal_accelerator_cuda_module =
88
88
{
@@ -128,7 +128,7 @@ opal_accelerator_base_module_t opal_accelerator_cuda_module =
128
128
accelerator_cuda_get_mem_bw
129
129
};
130
130
131
- static inline opal_accelerator_cuda_delayed_init_check (void )
131
+ static inline int opal_accelerator_cuda_delayed_init_check (void )
132
132
{
133
133
if (OPAL_UNLIKELY (true != mca_accelerator_cuda_init_complete )) {
134
134
return opal_accelerator_cuda_delayed_init ();
@@ -314,7 +314,7 @@ static int accelerator_cuda_create_stream(int dev_id, opal_accelerator_stream_t
314
314
}
315
315
316
316
result = cuStreamCreate ((* stream )-> stream , 0 );
317
- if (OPAL_UNLIKELY (result != CUDA_SUCCESS )) {
317
+ if (OPAL_UNLIKELY (CUDA_SUCCESS != result )) {
318
318
opal_show_help ("help-accelerator-cuda.txt" , "cuStreamCreate failed" , true,
319
319
OPAL_PROC_MY_HOSTNAME , result );
320
320
free ((* stream )-> stream );
@@ -498,13 +498,14 @@ static int accelerator_cuda_memcpy(int dest_dev_id, int src_dev_id, void *dest,
498
498
* Additionally, cuMemcpy is not necessarily always synchronous. See:
499
499
* https://docs.nvidia.com/cuda/cuda-driver-api/api-sync-behavior.html
500
500
* TODO: Add optimizations for type field */
501
- result = cuMemcpyAsync ((CUdeviceptr ) dest , (CUdeviceptr ) src , size , GET_STREAM (opal_accelerator_cuda_memcpy_stream .super ));
501
+ result = cuMemcpyAsync ((CUdeviceptr ) dest , (CUdeviceptr ) src , size ,
502
+ (CUstream * ) opal_accelerator_cuda_memcpy_stream .base .stream );
502
503
if (OPAL_UNLIKELY (CUDA_SUCCESS != result )) {
503
504
opal_show_help ("help-accelerator-cuda.txt" , "cuMemcpyAsync failed" , true, dest , src ,
504
505
size , result );
505
506
return OPAL_ERROR ;
506
507
}
507
- result = cuStreamSynchronize (GET_STREAM ( opal_accelerator_cuda_memcpy_stream .super ) );
508
+ result = cuStreamSynchronize (( CUstream * ) opal_accelerator_cuda_memcpy_stream .base . stream );
508
509
if (OPAL_UNLIKELY (CUDA_SUCCESS != result )) {
509
510
opal_show_help ("help-accelerator-cuda.txt" , "cuStreamSynchronize failed" , true,
510
511
OPAL_PROC_MY_HOSTNAME , result );
@@ -532,7 +533,7 @@ static int accelerator_cuda_memmove_async(int dest_dev_id, int src_dev_id, void
532
533
}
533
534
534
535
result = accelerator_cuda_mem_alloc_stream (src_dev_id , & ptr , size , stream );
535
- if (OPAL_UNLIKELY (OPAL_SUCCESS != result )) {
536
+ if (OPAL_UNLIKELY (CUDA_SUCCESS != result )) {
536
537
return OPAL_ERROR ;
537
538
}
538
539
tmp = (CUdeviceptr )ptr ;
@@ -561,9 +562,9 @@ static int accelerator_cuda_memmove(int dest_dev_id, int src_dev_id, void *dest,
561
562
return OPAL_ERROR ;
562
563
}
563
564
ret = accelerator_cuda_sync_stream (& opal_accelerator_cuda_memcpy_stream .base );
564
- if (OPAL_UNLIKELY (OPAL_SUCCESS != result )) {
565
+ if (OPAL_UNLIKELY (OPAL_SUCCESS != ret )) {
565
566
opal_show_help ("help-accelerator-cuda.txt" , "cuStreamSynchronize failed" , true,
566
- OPAL_PROC_MY_HOSTNAME , result );
567
+ OPAL_PROC_MY_HOSTNAME , ret );
567
568
return OPAL_ERROR ;
568
569
}
569
570
return OPAL_SUCCESS ;
@@ -982,7 +983,7 @@ static int accelerator_cuda_get_buffer_id(int dev_id, const void *addr, opal_acc
982
983
}
983
984
984
985
result = cuPointerGetAttribute ((unsigned long long * )buf_id , CU_POINTER_ATTRIBUTE_BUFFER_ID , (CUdeviceptr ) addr );
985
- if (OPAL_UNLIKELY (result != CUDA_SUCCESS )) {
986
+ if (OPAL_UNLIKELY (CUDA_SUCCESS != result )) {
986
987
opal_show_help ("help-accelerator-cuda.txt" , "bufferID failed" , true, OPAL_PROC_MY_HOSTNAME ,
987
988
result );
988
989
return OPAL_ERROR ;
0 commit comments