clr: Minor fixes for error return (#2153)
Bu işleme şunda yer alıyor:
@@ -297,14 +297,14 @@ hipError_t ihipEventCreateWithFlags(hipEvent_t* event, unsigned flags) {
|
||||
e = new hip::Event(flags);
|
||||
}
|
||||
}
|
||||
if (e == nullptr) {
|
||||
return hipErrorOutOfMemory;
|
||||
}
|
||||
// App might have used combination of flags i.e. hipEventInterprocess|hipEventDisableTiming
|
||||
// However based on hipEventInterprocess flag, IPCEvent creates even with
|
||||
// JUST hipEventInterprocess and hence, Actual hipEventInterprocess|hipEventDisableTiming
|
||||
// flag is getting supressed with hipEventInterprocess
|
||||
e->flags_ = flags;
|
||||
if (e == nullptr) {
|
||||
return hipErrorOutOfMemory;
|
||||
}
|
||||
*event = reinterpret_cast<hipEvent_t>(e);
|
||||
std::unique_lock lock(hip::eventSetLock);
|
||||
hip::eventSet.insert(*event);
|
||||
@@ -346,7 +346,7 @@ hipError_t hipEventDestroy(hipEvent_t event) {
|
||||
|
||||
std::unique_lock lock(hip::eventSetLock);
|
||||
if (hip::eventSet.erase(event) == 0) {
|
||||
return hipErrorContextIsDestroyed;
|
||||
HIP_RETURN(hipErrorContextIsDestroyed);
|
||||
}
|
||||
|
||||
hip::Event* e = reinterpret_cast<hip::Event*>(event);
|
||||
|
||||
@@ -80,7 +80,6 @@ amd::Memory* getMemoryObjectWithOffset(const void* ptr, const size_t size) {
|
||||
}
|
||||
memObj = new (memObj->getContext()) amd::Buffer(*memObj, memObj->getMemFlags(), offset, size);
|
||||
if (memObj == nullptr) {
|
||||
;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -272,7 +271,7 @@ hipError_t hipSignalExternalSemaphoresAsync(const hipExternalSemaphore_t* extSem
|
||||
*hip_stream, extSemArray[i], paramsArray[i].params.fence.value,
|
||||
amd::ExternalSemaphoreCmd::COMMAND_SIGNAL_EXTSEMAPHORE);
|
||||
if (command == nullptr) {
|
||||
return hipErrorOutOfMemory;
|
||||
HIP_RETURN(hipErrorOutOfMemory);
|
||||
}
|
||||
command->enqueue();
|
||||
command->release();
|
||||
@@ -310,7 +309,7 @@ hipError_t hipWaitExternalSemaphoresAsync(const hipExternalSemaphore_t* extSemAr
|
||||
*hip_stream, extSemArray[i], paramsArray[i].params.fence.value,
|
||||
amd::ExternalSemaphoreCmd::COMMAND_WAIT_EXTSEMAPHORE);
|
||||
if (command == nullptr) {
|
||||
return hipErrorOutOfMemory;
|
||||
HIP_RETURN(hipErrorOutOfMemory);
|
||||
}
|
||||
command->enqueue();
|
||||
command->release();
|
||||
@@ -847,6 +846,10 @@ hipError_t hipMemcpyWithStream(void* dst, const void* src, size_t sizeBytes, hip
|
||||
hipError_t hipMemPtrGetInfo(void* ptr, size_t* size) {
|
||||
HIP_INIT_API(hipMemPtrGetInfo, ptr, size);
|
||||
|
||||
if (size == nullptr) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
if (ptr == nullptr) {
|
||||
*size = 0;
|
||||
HIP_RETURN(hipSuccess);
|
||||
@@ -912,6 +915,10 @@ hipError_t hipFreeArray(hipArray_t array) {
|
||||
hipError_t hipMemGetAddressRange(hipDeviceptr_t* pbase, size_t* psize, hipDeviceptr_t dptr) {
|
||||
HIP_INIT_API(hipMemGetAddressRange, pbase, psize, dptr);
|
||||
|
||||
if (pbase == nullptr || psize == nullptr) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
// Since we are using SVM buffer DevicePtr and HostPtr is the same
|
||||
void* ptr = dptr;
|
||||
size_t offset = 0;
|
||||
@@ -1217,7 +1224,7 @@ hipError_t ihipArrayCreate(hipArray_t* array, const HIP_ARRAY3D_DESCRIPTOR* pAll
|
||||
hipError_t hipArrayCreate(hipArray_t* array, const HIP_ARRAY_DESCRIPTOR* pAllocateArray) {
|
||||
HIP_INIT_API(hipArrayCreate, array, pAllocateArray);
|
||||
if (pAllocateArray == nullptr) {
|
||||
return hipErrorInvalidValue;
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
CHECK_STREAM_CAPTURE_SUPPORTED();
|
||||
HIP_ARRAY3D_DESCRIPTOR desc = {
|
||||
@@ -1632,10 +1639,10 @@ hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dstDevice, const void* srcHost, siz
|
||||
hipMemcpyKind kind = hipMemcpyHostToDevice;
|
||||
STREAM_CAPTURE(hipMemcpyHtoDAsync, stream, dstDevice, srcHost, ByteCount, kind);
|
||||
if (static_cast<uint32_t>(kind) > hipMemcpyDefault && kind != hipMemcpyDeviceToDeviceNoCU) {
|
||||
return hipErrorInvalidMemcpyDirection;
|
||||
HIP_RETURN(hipErrorInvalidMemcpyDirection);
|
||||
}
|
||||
if (!hip::isValid(stream)) {
|
||||
return hipErrorContextIsDestroyed;
|
||||
HIP_RETURN(hipErrorContextIsDestroyed);
|
||||
}
|
||||
hip::Stream* hip_stream = hip::getStream(stream);
|
||||
if (hip_stream == nullptr) {
|
||||
@@ -1650,10 +1657,10 @@ hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dstDevice, hipDeviceptr_t srcDevice
|
||||
hipMemcpyKind kind = hipMemcpyDeviceToDevice;
|
||||
STREAM_CAPTURE(hipMemcpyDtoDAsync, stream, dstDevice, srcDevice, ByteCount, kind);
|
||||
if (static_cast<uint32_t>(kind) > hipMemcpyDefault && kind != hipMemcpyDeviceToDeviceNoCU) {
|
||||
return hipErrorInvalidMemcpyDirection;
|
||||
HIP_RETURN(hipErrorInvalidMemcpyDirection);
|
||||
}
|
||||
if (!hip::isValid(stream)) {
|
||||
return hipErrorContextIsDestroyed;
|
||||
HIP_RETURN(hipErrorContextIsDestroyed);
|
||||
}
|
||||
hip::Stream* hip_stream = hip::getStream(stream);
|
||||
if (hip_stream == nullptr) {
|
||||
@@ -1668,10 +1675,10 @@ hipError_t hipMemcpyDtoHAsync(void* dstHost, hipDeviceptr_t srcDevice, size_t By
|
||||
hipMemcpyKind kind = hipMemcpyDeviceToHost;
|
||||
STREAM_CAPTURE(hipMemcpyDtoHAsync, stream, dstHost, srcDevice, ByteCount, kind);
|
||||
if (static_cast<uint32_t>(kind) > hipMemcpyDefault && kind != hipMemcpyDeviceToDeviceNoCU) {
|
||||
return hipErrorInvalidMemcpyDirection;
|
||||
HIP_RETURN(hipErrorInvalidMemcpyDirection);
|
||||
}
|
||||
if (!hip::isValid(stream)) {
|
||||
return hipErrorContextIsDestroyed;
|
||||
HIP_RETURN(hipErrorContextIsDestroyed);
|
||||
}
|
||||
hip::Stream* hip_stream = hip::getStream(stream);
|
||||
if (hip_stream == nullptr) {
|
||||
|
||||
@@ -331,13 +331,17 @@ hipError_t hipDeviceGetStreamPriorityRange(int* leastPriority, int* greatestPrio
|
||||
|
||||
// ================================================================================================
|
||||
hipError_t hipStreamGetFlags_common(hipStream_t stream, unsigned int* flags) {
|
||||
if ((flags != nullptr) && (stream != nullptr)) {
|
||||
getStreamPerThread(stream);
|
||||
*flags = reinterpret_cast<hip::Stream*>(stream)->Flags();
|
||||
} else {
|
||||
if (flags == nullptr || stream == nullptr) {
|
||||
return hipErrorInvalidValue;
|
||||
}
|
||||
|
||||
getStreamPerThread(stream);
|
||||
|
||||
if (!hip::isValid(stream)) {
|
||||
return hipErrorInvalidResourceHandle;
|
||||
}
|
||||
|
||||
*flags = reinterpret_cast<hip::Stream*>(stream)->Flags();
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
@@ -729,18 +733,22 @@ hipError_t hipExtStreamCreateWithCUMask(hipStream_t* stream, uint32_t cuMaskSize
|
||||
|
||||
// ================================================================================================
|
||||
hipError_t hipStreamGetPriority_common(hipStream_t stream, int* priority) {
|
||||
if ((priority != nullptr) && (stream == nullptr)) {
|
||||
if (priority == nullptr) {
|
||||
return hipErrorInvalidValue;
|
||||
}
|
||||
|
||||
if (stream == nullptr) {
|
||||
*priority = 0;
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
if ((priority != nullptr) && (stream != nullptr)) {
|
||||
getStreamPerThread(stream);
|
||||
*priority = static_cast<int>(reinterpret_cast<hip::Stream*>(stream)->GetPriority());
|
||||
} else {
|
||||
return hipErrorInvalidValue;
|
||||
getStreamPerThread(stream);
|
||||
|
||||
if (!hip::isValid(stream)) {
|
||||
return hipErrorInvalidResourceHandle;
|
||||
}
|
||||
|
||||
*priority = static_cast<int>(reinterpret_cast<hip::Stream*>(stream)->GetPriority());
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
@@ -784,14 +792,13 @@ hipError_t hipExtStreamGetCUMask(hipStream_t stream, uint32_t cuMaskSize, uint32
|
||||
uint32_t temp = 0;
|
||||
uint32_t bit_index = 0;
|
||||
for (uint32_t i = 0; i < info.maxComputeUnits_; i++) {
|
||||
temp |= 1UL << bit_index;
|
||||
temp |= 1U << bit_index;
|
||||
bit_index += 1;
|
||||
if (bit_index >= 32) {
|
||||
defaultCUMask.push_back(temp);
|
||||
temp = 0;
|
||||
bit_index = 0;
|
||||
temp |= 1UL << bit_index;
|
||||
}
|
||||
bit_index += 1;
|
||||
}
|
||||
if (bit_index != 0) {
|
||||
defaultCUMask.push_back(temp);
|
||||
@@ -909,7 +916,7 @@ hipError_t hipStreamGetAttribute(hipStream_t stream, hipStreamAttrID attr,
|
||||
HIP_INIT_API(hipStreamGetAttribute, stream, attr, value_out);
|
||||
|
||||
if (value_out == nullptr) {
|
||||
return hipErrorInvalidValue;
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
if (!hip::isValid(stream)) {
|
||||
|
||||
Yeni konuda referans
Bir kullanıcı engelle