SWDEV-487395 - Add macros for capturing async APIs

Change-Id: Id8647a05f3f483792d9224aaf8a2488c2498c0ba


[ROCm/hip-tests commit: aac7b29d78]
This commit is contained in:
Marko Arandjelovic
2024-10-01 17:24:49 +02:00
committed by Anusha Godavarthy Surya
parent eadcf7db13
commit 050d2f991f
@@ -484,3 +484,26 @@ class BlockingContext {
INFO("Texture is not support on the device. Skipped."); \
return; \
}
// Call GENERATE_CAPTURE macro at the start of the test, before using BEGIN/END_CAPTURE.
// Use BEGIN/END_CAPTURE macros to execute APIs in both stream capturing and non-capturing modes.
// Place BEGIN_CAPTURE before the API call and END_CAPTURE after the call.
#define GENERATE_CAPTURE() bool capture = GENERATE(true, false);
#define BEGIN_CAPTURE(stream) \
if (capture && stream != nullptr) { \
hipStreamCaptureMode flags = GENERATE( \
hipStreamCaptureModeGlobal, hipStreamCaptureModeThreadLocal, hipStreamCaptureModeRelaxed); \
HIP_CHECK(hipStreamBeginCapture(stream, flags)); \
}
#define END_CAPTURE(stream) \
if (capture && stream != nullptr) { \
hipGraph_t graph = nullptr; \
hipGraphExec_t graph_exec = nullptr; \
HIP_CHECK(hipStreamEndCapture(stream, &graph)); \
HIP_CHECK(hipGraphInstantiate(&graph_exec, graph, nullptr, nullptr, 0)); \
HIP_CHECK(hipGraphLaunch(graph_exec, stream)); \
HIP_CHECK(hipGraphExecDestroy(graph_exec)); \
HIP_CHECK(hipGraphDestroy(graph)); \
}