diff --git a/hipamd/src/hip_memory.cpp b/hipamd/src/hip_memory.cpp index f3c01491e5..10eb317f26 100644 --- a/hipamd/src/hip_memory.cpp +++ b/hipamd/src/hip_memory.cpp @@ -1160,12 +1160,17 @@ hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) { HIP_INIT_SPECIAL_API(hipMemcpyHtoD, (TRACE_MCMD), dst, src, sizeBytes); + hipError_t e = hipSuccess; + if (sizeBytes == 0) return ihipLogStatus(e); + + if(dst==NULL || src==NULL){ + return ihipLogStatus(hipErrorInvalidValue); + } + hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); hc::completion_future marker; - hipError_t e = hipSuccess; - try { stream->locked_copySync((void*)dst, (void*)src, sizeBytes, hipMemcpyHostToDevice, false); } catch (ihipException& ex) { @@ -1179,12 +1184,17 @@ hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) { hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) { HIP_INIT_SPECIAL_API(hipMemcpyDtoH, (TRACE_MCMD), dst, src, sizeBytes); + hipError_t e = hipSuccess; + if (sizeBytes == 0) return ihipLogStatus(e); + + if(dst==NULL || src==NULL){ + return ihipLogStatus(hipErrorInvalidValue); + } + hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); hc::completion_future marker; - hipError_t e = hipSuccess; - try { stream->locked_copySync((void*)dst, (void*)src, sizeBytes, hipMemcpyDeviceToHost, false); } catch (ihipException& ex) { @@ -1198,12 +1208,17 @@ hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) { hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes) { HIP_INIT_SPECIAL_API(hipMemcpyDtoD, (TRACE_MCMD), dst, src, sizeBytes); + hipError_t e = hipSuccess; + if (sizeBytes == 0) return ihipLogStatus(e); + + if(dst==NULL || src==NULL){ + return ihipLogStatus(hipErrorInvalidValue); + } + hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); hc::completion_future marker; - hipError_t e = hipSuccess; - try { stream->locked_copySync((void*)dst, (void*)src, sizeBytes, hipMemcpyDeviceToDevice, false); } catch (ihipException& ex) { @@ -1216,12 +1231,17 @@ hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeByte hipError_t hipMemcpyHtoH(void* dst, void* src, size_t sizeBytes) { HIP_INIT_SPECIAL_API(hipMemcpyHtoH, (TRACE_MCMD), dst, src, sizeBytes); + hipError_t e = hipSuccess; + if (sizeBytes == 0) return ihipLogStatus(e); + + if(dst==NULL || src==NULL){ + return ihipLogStatus(hipErrorInvalidValue); + } + hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); hc::completion_future marker; - hipError_t e = hipSuccess; - try { stream->locked_copySync((void*)dst, (void*)src, sizeBytes, hipMemcpyHostToHost, false); } catch (ihipException& ex) {