SWDEV-429053 - Add check for StreamLegacy
Signed-off-by: sdashmiz <shadi.dashmiz@amd.com> Change-Id: I402185a3b81935aaa1c8c4963407b8de21c72d8a
This commit is contained in:
@@ -91,7 +91,7 @@ void setCurrentDevice(unsigned int index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hip::Stream* getStream(hipStream_t stream, bool wait) {
|
hip::Stream* getStream(hipStream_t stream, bool wait) {
|
||||||
if (stream == nullptr) {
|
if (stream == nullptr || stream == hipStreamLegacy) {
|
||||||
return getNullStream(wait);
|
return getNullStream(wait);
|
||||||
} else {
|
} else {
|
||||||
hip::Stream* hip_stream = reinterpret_cast<hip::Stream*>(stream);
|
hip::Stream* hip_stream = reinterpret_cast<hip::Stream*>(stream);
|
||||||
|
|||||||
@@ -855,10 +855,11 @@ hipError_t hipStreamIsCapturing_common(hipStream_t stream, hipStreamCaptureStatu
|
|||||||
if (!hip::isValid(stream)) {
|
if (!hip::isValid(stream)) {
|
||||||
return hipErrorContextIsDestroyed;
|
return hipErrorContextIsDestroyed;
|
||||||
}
|
}
|
||||||
if (hip::Stream::StreamCaptureBlocking() == true && stream == nullptr) {
|
if (hip::Stream::StreamCaptureBlocking() == true &&
|
||||||
|
(stream == nullptr || stream == hipStreamLegacy)) {
|
||||||
return hipErrorStreamCaptureImplicit;
|
return hipErrorStreamCaptureImplicit;
|
||||||
}
|
}
|
||||||
if (stream == nullptr) {
|
if (stream == nullptr || stream == hipStreamLegacy) {
|
||||||
*pCaptureStatus = hipStreamCaptureStatusNone;
|
*pCaptureStatus = hipStreamCaptureStatusNone;
|
||||||
} else {
|
} else {
|
||||||
*pCaptureStatus = reinterpret_cast<hip::Stream*>(stream)->GetCaptureStatus();
|
*pCaptureStatus = reinterpret_cast<hip::Stream*>(stream)->GetCaptureStatus();
|
||||||
@@ -898,7 +899,7 @@ hipError_t hipStreamBeginCapture_common(hipStream_t stream, hipStreamCaptureMode
|
|||||||
return hipErrorContextIsDestroyed;
|
return hipErrorContextIsDestroyed;
|
||||||
}
|
}
|
||||||
// capture cannot be initiated on legacy stream
|
// capture cannot be initiated on legacy stream
|
||||||
if (stream == nullptr) {
|
if (stream == nullptr || stream == hipStreamLegacy) {
|
||||||
return hipErrorStreamCaptureUnsupported;
|
return hipErrorStreamCaptureUnsupported;
|
||||||
}
|
}
|
||||||
if (mode < hipStreamCaptureModeGlobal || mode > hipStreamCaptureModeRelaxed) {
|
if (mode < hipStreamCaptureModeGlobal || mode > hipStreamCaptureModeRelaxed) {
|
||||||
@@ -977,7 +978,7 @@ hipError_t hipStreamEndCapture_common(hipStream_t stream, hip::Graph** pGraph) {
|
|||||||
if (pGraph == nullptr) {
|
if (pGraph == nullptr) {
|
||||||
return hipErrorInvalidValue;
|
return hipErrorInvalidValue;
|
||||||
}
|
}
|
||||||
if (stream == nullptr) {
|
if (stream == nullptr || stream == hipStreamLegacy) {
|
||||||
return hipErrorIllegalState;
|
return hipErrorIllegalState;
|
||||||
}
|
}
|
||||||
if (!hip::isValid(stream)) {
|
if (!hip::isValid(stream)) {
|
||||||
@@ -1771,10 +1772,11 @@ hipError_t hipStreamGetCaptureInfo_common(hipStream_t stream,
|
|||||||
if (!hip::isValid(stream)) {
|
if (!hip::isValid(stream)) {
|
||||||
return hipErrorContextIsDestroyed;
|
return hipErrorContextIsDestroyed;
|
||||||
}
|
}
|
||||||
if (hip::Stream::StreamCaptureBlocking() == true && stream == nullptr) {
|
if (hip::Stream::StreamCaptureBlocking() == true &&
|
||||||
|
(stream == nullptr || stream == hipStreamLegacy)) {
|
||||||
return hipErrorStreamCaptureImplicit;
|
return hipErrorStreamCaptureImplicit;
|
||||||
}
|
}
|
||||||
if (stream == nullptr) {
|
if (stream == nullptr || stream == hipStreamLegacy) {
|
||||||
*pCaptureStatus = hipStreamCaptureStatusNone;
|
*pCaptureStatus = hipStreamCaptureStatusNone;
|
||||||
return hipSuccess;
|
return hipSuccess;
|
||||||
}
|
}
|
||||||
@@ -1807,10 +1809,11 @@ hipError_t hipStreamGetCaptureInfo_v2_common(hipStream_t stream,
|
|||||||
if (captureStatus_out == nullptr) {
|
if (captureStatus_out == nullptr) {
|
||||||
return hipErrorInvalidValue;
|
return hipErrorInvalidValue;
|
||||||
}
|
}
|
||||||
if (hip::Stream::StreamCaptureBlocking() == true && stream == nullptr) {
|
if (hip::Stream::StreamCaptureBlocking() == true &&
|
||||||
|
(stream == nullptr || stream == hipStreamLegacy)) {
|
||||||
return hipErrorStreamCaptureImplicit;
|
return hipErrorStreamCaptureImplicit;
|
||||||
}
|
}
|
||||||
if (stream == nullptr) {
|
if (stream == nullptr || stream == hipStreamLegacy) {
|
||||||
*captureStatus_out = hipStreamCaptureStatusNone;
|
*captureStatus_out = hipStreamCaptureStatusNone;
|
||||||
return hipSuccess;
|
return hipSuccess;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,10 +108,12 @@ hipError_t hipMemPrefetchAsync(const void* dev_ptr, size_t count, int device,
|
|||||||
// Pick the specified stream or Null one from the provided device
|
// Pick the specified stream or Null one from the provided device
|
||||||
if (device == hipCpuDeviceId) {
|
if (device == hipCpuDeviceId) {
|
||||||
cpu_access = true;
|
cpu_access = true;
|
||||||
hip_stream = (stream == nullptr) ? hip::getCurrentDevice()->NullStream() : hip::getStream(stream);
|
hip_stream = (stream == nullptr || stream == hipStreamLegacy) ?
|
||||||
|
hip::getCurrentDevice()->NullStream() : hip::getStream(stream);
|
||||||
} else {
|
} else {
|
||||||
dev = g_devices[device]->devices()[0];
|
dev = g_devices[device]->devices()[0];
|
||||||
hip_stream = (stream == nullptr) ? g_devices[device]->NullStream() : hip::getStream(stream);
|
hip_stream = (stream == nullptr || stream == hipStreamLegacy) ?
|
||||||
|
g_devices[device]->NullStream() : hip::getStream(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hip_stream == nullptr) {
|
if (hip_stream == nullptr) {
|
||||||
@@ -250,8 +252,8 @@ hipError_t hipStreamAttachMemAsync(hipStream_t stream, void* dev_ptr,
|
|||||||
// host-accessible region of system-allocated pageable memory.
|
// host-accessible region of system-allocated pageable memory.
|
||||||
// This type of memory may only be specified if the device associated with the
|
// This type of memory may only be specified if the device associated with the
|
||||||
// stream reports a non-zero value for the device attribute hipDevAttrPageableMemoryAccess.
|
// stream reports a non-zero value for the device attribute hipDevAttrPageableMemoryAccess.
|
||||||
hip::Stream* hip_stream = (stream == nullptr) ? hip::getCurrentDevice()->NullStream()
|
hip::Stream* hip_stream = (stream == nullptr || stream == hipStreamLegacy) ?
|
||||||
: hip::getStream(stream);
|
hip::getCurrentDevice()->NullStream() : hip::getStream(stream);
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
amd::Memory* memObj = getMemoryObject(dev_ptr, offset);
|
amd::Memory* memObj = getMemoryObject(dev_ptr, offset);
|
||||||
if (memObj == nullptr) {
|
if (memObj == nullptr) {
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ const char* ihipGetErrorName(hipError_t hip_error);
|
|||||||
|
|
||||||
#define STREAM_CAPTURE(name, stream, ...) \
|
#define STREAM_CAPTURE(name, stream, ...) \
|
||||||
hip::getStreamPerThread(stream); \
|
hip::getStreamPerThread(stream); \
|
||||||
if (stream != nullptr && \
|
if (stream != nullptr && stream != hipStreamLegacy && \
|
||||||
reinterpret_cast<hip::Stream*>(stream)->GetCaptureStatus() == \
|
reinterpret_cast<hip::Stream*>(stream)->GetCaptureStatus() == \
|
||||||
hipStreamCaptureStatusActive) { \
|
hipStreamCaptureStatusActive) { \
|
||||||
hipError_t status = hip::capture##name(stream, ##__VA_ARGS__); \
|
hipError_t status = hip::capture##name(stream, ##__VA_ARGS__); \
|
||||||
@@ -242,7 +242,7 @@ const char* ihipGetErrorName(hipError_t hip_error);
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define PER_THREAD_DEFAULT_STREAM(stream) \
|
#define PER_THREAD_DEFAULT_STREAM(stream) \
|
||||||
if (stream == nullptr) { \
|
if (stream == nullptr || stream == hipStreamLegacy) { \
|
||||||
stream = getPerThreadDefaultStream(); \
|
stream = getPerThreadDefaultStream(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -674,7 +674,7 @@ hipError_t hipMemcpy_common(void* dst, const void* src, size_t sizeBytes,
|
|||||||
CHECK_STREAM_CAPTURING();
|
CHECK_STREAM_CAPTURING();
|
||||||
hip::Stream* hip_stream = nullptr;
|
hip::Stream* hip_stream = nullptr;
|
||||||
|
|
||||||
if (stream != nullptr) {
|
if (stream != nullptr && stream != hipStreamLegacy) {
|
||||||
hip_stream = hip::getStream(stream);
|
hip_stream = hip::getStream(stream);
|
||||||
} else {
|
} else {
|
||||||
hip_stream = hip::getNullStream();
|
hip_stream = hip::getNullStream();
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ hipError_t hipMallocAsync(void** dev_ptr, size_t size, hipStream_t stream) {
|
|||||||
*dev_ptr = nullptr;
|
*dev_ptr = nullptr;
|
||||||
HIP_RETURN(hipSuccess);
|
HIP_RETURN(hipSuccess);
|
||||||
}
|
}
|
||||||
auto hip_stream = (stream == nullptr) ? hip::getCurrentDevice()->NullStream() :
|
auto hip_stream = (stream == nullptr || stream == hipStreamLegacy) ?
|
||||||
reinterpret_cast<hip::Stream*>(stream);
|
hip::getCurrentDevice()->NullStream() : reinterpret_cast<hip::Stream*>(stream);
|
||||||
auto device = hip_stream->GetDevice();
|
auto device = hip_stream->GetDevice();
|
||||||
auto mem_pool = device->GetCurrentMemoryPool();
|
auto mem_pool = device->GetCurrentMemoryPool();
|
||||||
|
|
||||||
@@ -147,8 +147,8 @@ hipError_t hipFreeAsync(void* dev_ptr, hipStream_t stream) {
|
|||||||
|
|
||||||
STREAM_CAPTURE(hipFreeAsync, stream, dev_ptr);
|
STREAM_CAPTURE(hipFreeAsync, stream, dev_ptr);
|
||||||
|
|
||||||
auto hip_stream = (stream == nullptr) ? hip::getCurrentDevice()->NullStream()
|
auto hip_stream = (stream == nullptr || stream == hipStreamLegacy) ?
|
||||||
: reinterpret_cast<hip::Stream*>(stream);
|
hip::getCurrentDevice()->NullStream(): reinterpret_cast<hip::Stream*>(stream);
|
||||||
|
|
||||||
hip::Event* event = nullptr;
|
hip::Event* event = nullptr;
|
||||||
bool graph_in_use = false;
|
bool graph_in_use = false;
|
||||||
@@ -192,7 +192,7 @@ hipError_t hipFreeAsync(void* dev_ptr, hipStream_t stream) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cmd = new FreeAsyncCommand(*hip_stream, dev_ptr, event);
|
auto cmd = new FreeAsyncCommand(*hip_stream, dev_ptr, event);
|
||||||
if (cmd == nullptr) {
|
if (cmd == nullptr) {
|
||||||
HIP_RETURN(hipErrorUnknown);
|
HIP_RETURN(hipErrorUnknown);
|
||||||
@@ -367,8 +367,8 @@ hipError_t hipMallocFromPoolAsync(
|
|||||||
STREAM_CAPTURE(hipMallocAsync, stream, mem_pool, size, dev_ptr);
|
STREAM_CAPTURE(hipMallocAsync, stream, mem_pool, size, dev_ptr);
|
||||||
|
|
||||||
auto mpool = reinterpret_cast<hip::MemoryPool*>(mem_pool);
|
auto mpool = reinterpret_cast<hip::MemoryPool*>(mem_pool);
|
||||||
auto hip_stream = (stream == nullptr) ? hip::getCurrentDevice()->NullStream() :
|
auto hip_stream = (stream == nullptr || stream == hipStreamLegacy) ?
|
||||||
reinterpret_cast<hip::Stream*>(stream);
|
hip::getCurrentDevice()->NullStream() : reinterpret_cast<hip::Stream*>(stream);
|
||||||
*dev_ptr = mpool->AllocateMemory(size, hip_stream);
|
*dev_ptr = mpool->AllocateMemory(size, hip_stream);
|
||||||
if (*dev_ptr == nullptr) {
|
if (*dev_ptr == nullptr) {
|
||||||
HIP_RETURN(hipErrorOutOfMemory);
|
HIP_RETURN(hipErrorOutOfMemory);
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ void Stream::Destroy(hip::Stream* stream) {
|
|||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
bool isValid(hipStream_t& stream) {
|
bool isValid(hipStream_t& stream) {
|
||||||
// NULL stream is always valid
|
// NULL stream is always valid
|
||||||
if (stream == nullptr) {
|
if (stream == nullptr || stream == hipStreamLegacy) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user