@@ -81,8 +81,8 @@ static int accelerator_cuda_sync_stream(opal_accelerator_stream_t *stream);
8181static int accelerator_cuda_get_num_devices (int * num_devices );
8282static int accelerator_cuda_get_mem_bw (int device , float * bw );
8383
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))
8686
8787opal_accelerator_base_module_t opal_accelerator_cuda_module =
8888{
@@ -128,7 +128,7 @@ opal_accelerator_base_module_t opal_accelerator_cuda_module =
128128 accelerator_cuda_get_mem_bw
129129};
130130
131- static inline opal_accelerator_cuda_delayed_init_check (void )
131+ static inline int opal_accelerator_cuda_delayed_init_check (void )
132132{
133133 if (OPAL_UNLIKELY (true != mca_accelerator_cuda_init_complete )) {
134134 return opal_accelerator_cuda_delayed_init ();
@@ -314,7 +314,7 @@ static int accelerator_cuda_create_stream(int dev_id, opal_accelerator_stream_t
314314 }
315315
316316 result = cuStreamCreate ((* stream )-> stream , 0 );
317- if (OPAL_UNLIKELY (result != CUDA_SUCCESS )) {
317+ if (OPAL_UNLIKELY (CUDA_SUCCESS != result )) {
318318 opal_show_help ("help-accelerator-cuda.txt" , "cuStreamCreate failed" , true,
319319 OPAL_PROC_MY_HOSTNAME , result );
320320 free ((* stream )-> stream );
@@ -498,13 +498,14 @@ static int accelerator_cuda_memcpy(int dest_dev_id, int src_dev_id, void *dest,
498498 * Additionally, cuMemcpy is not necessarily always synchronous. See:
499499 * https://docs.nvidia.com/cuda/cuda-driver-api/api-sync-behavior.html
500500 * 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 );
502503 if (OPAL_UNLIKELY (CUDA_SUCCESS != result )) {
503504 opal_show_help ("help-accelerator-cuda.txt" , "cuMemcpyAsync failed" , true, dest , src ,
504505 size , result );
505506 return OPAL_ERROR ;
506507 }
507- result = cuStreamSynchronize (GET_STREAM ( opal_accelerator_cuda_memcpy_stream .super ) );
508+ result = cuStreamSynchronize (( CUstream * ) opal_accelerator_cuda_memcpy_stream .base . stream );
508509 if (OPAL_UNLIKELY (CUDA_SUCCESS != result )) {
509510 opal_show_help ("help-accelerator-cuda.txt" , "cuStreamSynchronize failed" , true,
510511 OPAL_PROC_MY_HOSTNAME , result );
@@ -532,7 +533,7 @@ static int accelerator_cuda_memmove_async(int dest_dev_id, int src_dev_id, void
532533 }
533534
534535 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 )) {
536537 return OPAL_ERROR ;
537538 }
538539 tmp = (CUdeviceptr )ptr ;
@@ -561,9 +562,9 @@ static int accelerator_cuda_memmove(int dest_dev_id, int src_dev_id, void *dest,
561562 return OPAL_ERROR ;
562563 }
563564 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 )) {
565566 opal_show_help ("help-accelerator-cuda.txt" , "cuStreamSynchronize failed" , true,
566- OPAL_PROC_MY_HOSTNAME , result );
567+ OPAL_PROC_MY_HOSTNAME , ret );
567568 return OPAL_ERROR ;
568569 }
569570 return OPAL_SUCCESS ;
@@ -982,7 +983,7 @@ static int accelerator_cuda_get_buffer_id(int dev_id, const void *addr, opal_acc
982983 }
983984
984985 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 )) {
986987 opal_show_help ("help-accelerator-cuda.txt" , "bufferID failed" , true, OPAL_PROC_MY_HOSTNAME ,
987988 result );
988989 return OPAL_ERROR ;
0 commit comments