SWDEV-283213 - Fix hipMemset2D, 3D failures in Debug mode

If the width is 0, hipMemset2D or 3D APIs should return success
doing nothing
Change-Id: I97f8825d090a73ee63145e52d2b6d2cc0eddade3

Change-Id: I9d62fee70929ad0c79b947aa4cbbc8ab898fb64a
Este commit está contenido en:
Satyanvesh Dittakavi
2021-04-27 04:30:18 -07:00
cometido por Tao Sang
padre 47fe205223
commit f845041f7d
+10 -9
Ver fichero
@@ -2066,16 +2066,11 @@ hipError_t hipMemsetD32Async(hipDeviceptr_t dst, int value, size_t count,
HIP_RETURN(ihipMemset(dst, value, sizeof(int32_t), count * sizeof(int32_t), stream, true));
}
inline hipError_t ihipMemset3D_validate(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent) {
inline hipError_t ihipMemset3D_validate(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent,
size_t sizeBytes) {
size_t offset = 0;
amd::Memory* memory = getMemoryObject(pitchedDevPtr.ptr, offset);
auto sizeBytes = extent.width * extent.height * extent.depth;
if (sizeBytes == 0) {
// sizeBytes is zero hence returning early as nothing to be set
return hipSuccess;
}
if (memory == nullptr) {
return hipErrorInvalidValue;
}
@@ -2120,7 +2115,13 @@ hipError_t ihipMemset3DCommand(std::vector<amd::Command*> &commands, hipPitchedP
hipError_t ihipMemset3D(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent,
hipStream_t stream, bool isAsync = false) {
hipError_t status = ihipMemset3D_validate(pitchedDevPtr, value, extent);
auto sizeBytes = extent.width * extent.height * extent.depth;
if (sizeBytes == 0) {
// sizeBytes is zero hence returning early as nothing to be set
return hipSuccess;
}
hipError_t status = ihipMemset3D_validate(pitchedDevPtr, value, extent, sizeBytes);
if (status != hipSuccess) {
return status;
}
@@ -2128,7 +2129,7 @@ hipError_t ihipMemset3D(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent
std::vector<amd::Command*> commands;
ihipMemset3DCommand(commands, pitchedDevPtr, value, extent, queue);
for (auto& command : commands) {
command->enqueue();
command->enqueue();
if (!isAsync) {
command->awaitCompletion();
}