SWDEV-323472 - Fix hipThreadExchangeStreamCaptureMode

Matching CUDA's described behavior: Threads have their own mode.

Change-Id: I3ea15826305a607bff73eb317c4ef62728ed5dc8
Этот коммит содержится в:
Christophe Paquot
2022-03-11 17:30:07 -08:00
коммит произвёл Christophe Paquot
родитель 3cc0a3fcaf
Коммит 925c742d42
2 изменённых файлов: 42 добавлений и 21 удалений
+16 -5
Просмотреть файл
@@ -153,13 +153,19 @@ static amd::Monitor g_hipInitlock{"hipInit lock"};
} \
} while (0);
extern thread_local std::vector<hipStream_t> g_captureStreams;
#define CHECK_STREAM_CAPTURE_SUPPORTED() \
for (auto stream : g_captureStreams) { \
if (reinterpret_cast<hip::Stream*>(stream)->GetCaptureMode() != hipStreamCaptureModeRelaxed) { \
if (l_streamCaptureMode == hipStreamCaptureModeThreadLocal) { \
if (l_captureStreams.size() != 0) { \
HIP_RETURN(hipErrorStreamCaptureUnsupported); \
} \
} else if (l_streamCaptureMode == hipStreamCaptureModeGlobal) { \
if (l_captureStreams.size() != 0) { \
HIP_RETURN(hipErrorStreamCaptureUnsupported); \
} \
amd::ScopedLock lock(g_captureStreamsLock); \
if (g_captureStreams.size() != 0) { \
HIP_RETURN(hipErrorStreamCaptureUnsupported); \
} \
}
// Sync APIs cannot be called when stream capture is active
@@ -210,7 +216,7 @@ namespace hip {
hipGraph_t pCaptureGraph_;
/// Based on mode stream capture places restrictions on API calls that can be made within or
/// concurrently
hipStreamCaptureMode captureMode_;
hipStreamCaptureMode captureMode_{hipStreamCaptureModeGlobal};
bool originStream_;
/// Origin sream has no parent. Parent stream for the derived captured streams with event
/// dependencies
@@ -451,4 +457,9 @@ constexpr bool kNewDevProg = false;
constexpr bool kMarkerDisableFlush = true; //!< Avoids command batch flush in ROCclr
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