SWDEV-336548 - Check for valid hipArray pointer in hipFreeArray
Change-Id: Icf0d47eeca7b5dd390a6a9c53b622b3680688ca4
[ROCm/clr commit: 1032581ded]
Этот коммит содержится в:
коммит произвёл
Jaydeepkumar Patel
родитель
4501fb58b5
Коммит
147485a9aa
@@ -211,7 +211,10 @@ hipError_t hipGraphicsSubResourceGetMappedArray(hipArray_t* array, hipGraphicsRe
|
||||
myarray->isDrv = 0;
|
||||
myarray->textureType = 0;
|
||||
*array = myarray;
|
||||
|
||||
{
|
||||
amd::ScopedLock lock(hip::hipArraySetLock);
|
||||
hip::hipArraySet.insert(*array);
|
||||
}
|
||||
HIP_RETURN(hipSuccess);
|
||||
}
|
||||
|
||||
|
||||
@@ -468,6 +468,8 @@ namespace hip {
|
||||
int getDeviceID(amd::Context& ctx);
|
||||
/// Check if stream is valid
|
||||
extern bool isValid(hipStream_t& stream);
|
||||
extern amd::Monitor hipArraySetLock;
|
||||
extern std::unordered_set<hipArray*> hipArraySet;
|
||||
};
|
||||
|
||||
extern void WaitThenDecrementSignal(hipStream_t stream, hipError_t status, void* user_data);
|
||||
@@ -510,5 +512,4 @@ extern std::vector<hip::Stream*> g_captureStreams;
|
||||
extern amd::Monitor g_captureStreamsLock;
|
||||
extern thread_local std::vector<hip::Stream*> l_captureStreams;
|
||||
extern thread_local hipStreamCaptureMode l_streamCaptureMode;
|
||||
|
||||
#endif // HIP_SRC_HIP_INTERNAL_H
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#include "platform/memory.hpp"
|
||||
#include "amdocl/cl_vk_amd.hpp"
|
||||
|
||||
amd::Monitor hip::hipArraySetLock{"Guards global hipArray set"};
|
||||
std::unordered_set<hipArray*> hip::hipArraySet;
|
||||
|
||||
// ================================================================================================
|
||||
amd::Memory* getMemoryObject(const void* ptr, size_t& offset, size_t size) {
|
||||
amd::Memory *memObj = amd::MemObjMap::FindMemObj(ptr);
|
||||
@@ -614,7 +617,12 @@ hipError_t ihipArrayDestroy(hipArray* array) {
|
||||
if (array == nullptr) {
|
||||
return hipErrorInvalidValue;
|
||||
}
|
||||
|
||||
{
|
||||
amd::ScopedLock lock(hip::hipArraySetLock);
|
||||
if (hip::hipArraySet.find(array) == hip::hipArraySet.end()) {
|
||||
return hipErrorContextIsDestroyed;
|
||||
}
|
||||
}
|
||||
cl_mem memObj = reinterpret_cast<cl_mem>(array->data);
|
||||
if (is_valid(memObj) == false) {
|
||||
return hipErrorInvalidValue;
|
||||
@@ -628,9 +636,11 @@ hipError_t ihipArrayDestroy(hipArray* array) {
|
||||
}
|
||||
|
||||
as_amd(memObj)->release();
|
||||
|
||||
{
|
||||
amd::ScopedLock lock(hip::hipArraySetLock);
|
||||
hip::hipArraySet.erase(array);
|
||||
}
|
||||
delete array;
|
||||
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
@@ -963,7 +973,10 @@ hipError_t ihipArrayCreate(hipArray** array,
|
||||
(*array)->depth = pAllocateArray->Depth;
|
||||
(*array)->Format = pAllocateArray->Format;
|
||||
(*array)->NumChannels = pAllocateArray->NumChannels;
|
||||
|
||||
{
|
||||
amd::ScopedLock lock(hip::hipArraySetLock);
|
||||
hip::hipArraySet.insert(*array);
|
||||
}
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user