Skip to content

Commit 9965f6c

Browse files
committed
opal/accelerator: allow 0 size copies
it looks like zero size messages with valid buffer pointers can occur for send-to-self operations and with persistent request. The current accelerator components return however an error for size 0 making those tests fail in our testsuite. This commit allows size 0 messages, and returns immediatly. Signed-off-by: Edgar Gabriel <Edgar.Gabriel@amd.com>
1 parent 5fa32f7 commit 9965f6c

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

opal/mca/accelerator/cuda/accelerator_cuda.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,12 @@ static int accelerator_cuda_memcpy_async(int dest_dev_id, int src_dev_id, void *
399399
}
400400

401401
if ((MCA_ACCELERATOR_STREAM_DEFAULT != stream && NULL == stream) ||
402-
NULL == dest || NULL == src || size <= 0) {
402+
NULL == dest || NULL == src || size < 0) {
403403
return OPAL_ERR_BAD_PARAM;
404404
}
405+
if (0 == size) {
406+
return OPAL_SUCCESS;
407+
}
405408

406409
result = cuMemcpyAsync((CUdeviceptr) dest, (CUdeviceptr) src, size, GET_STREAM(stream));
407410
if (OPAL_UNLIKELY(CUDA_SUCCESS != result)) {
@@ -422,9 +425,12 @@ static int accelerator_cuda_memcpy(int dest_dev_id, int src_dev_id, void *dest,
422425
return delayed_init;
423426
}
424427

425-
if (NULL == dest || NULL == src || size <= 0) {
428+
if (NULL == dest || NULL == src || size < 0) {
426429
return OPAL_ERR_BAD_PARAM;
427430
}
431+
if (0 == size) {
432+
return OPAL_SUCCESS;
433+
}
428434

429435
/* Async copy then synchronize is the default behavior as some applications
430436
* cannot utilize synchronous copies. In addition, host memory does not need

opal/mca/accelerator/rocm/accelerator_rocm_module.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,12 @@ static int mca_accelerator_rocm_memcpy_async(int dest_dev_id, int src_dev_id, vo
303303
{
304304
if ((MCA_ACCELERATOR_STREAM_DEFAULT != stream &&
305305
(NULL == stream || NULL == stream->stream)) ||
306-
NULL == src || NULL == dest || size <= 0) {
306+
NULL == src || NULL == dest || size < 0) {
307307
return OPAL_ERR_BAD_PARAM;
308308
}
309+
if (0 == size) {
310+
return OPAL_SUCCESS;
311+
}
309312

310313
hipError_t err = hipMemcpyAsync(dest, src, size, hipMemcpyDefault,
311314
GET_STREAM(stream));
@@ -324,9 +327,12 @@ static int mca_accelerator_rocm_memcpy(int dest_dev_id, int src_dev_id, void *de
324327
{
325328
hipError_t err;
326329

327-
if (NULL == src || NULL == dest || size <=0) {
330+
if (NULL == src || NULL == dest || size < 0) {
328331
return OPAL_ERR_BAD_PARAM;
329332
}
333+
if (0 == size) {
334+
return OPAL_SUCCESS;
335+
}
330336

331337
if (type == MCA_ACCELERATOR_TRANSFER_DTOH && size <= opal_accelerator_rocm_memcpyD2H_limit) {
332338
memcpy(dest, src, size);

opal/mca/accelerator/ze/accelerator_ze_module.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,14 @@ static int mca_accelerator_ze_memcpy_async(int dest_dev_id, int src_dev_id, void
403403
opal_accelerator_ze_stream_t *ze_stream = NULL;
404404

405405
if (NULL == stream || NULL == src ||
406-
NULL == dest || size <= 0) {
406+
NULL == dest || size < 0) {
407407
return OPAL_ERR_BAD_PARAM;
408408
}
409+
if (0 == size) {
410+
return OPAL_SUCCESS;
411+
}
409412

410-
ze_stream = (opal_accelerator_ze_stream_t *)stream->stream;
413+
ze_stream = (opal_accelerator_ze_stream_t *)stream->stream;
411414
assert(NULL != ze_stream);
412415

413416
zret = zeCommandListAppendMemoryCopy(ze_stream->hCommandList,
@@ -435,9 +438,12 @@ static int mca_accelerator_ze_memcpy(int dest_dev_id, int src_dev_id, void *dest
435438

436439
opal_accelerator_ze_stream_t *ze_stream = NULL;
437440

438-
if (NULL == src || NULL == dest || size <=0) {
441+
if (NULL == src || NULL == dest || size <0) {
439442
return OPAL_ERR_BAD_PARAM;
440443
}
444+
if (0 == size) {
445+
return OPAL_SUCCESS;
446+
}
441447

442448
if (MCA_ACCELERATOR_NO_DEVICE_ID == src_dev_id) {
443449
dev_id = 0;

0 commit comments

Comments
 (0)