From aee10912e0f89baedafa5eef3da96016c8d15bd9 Mon Sep 17 00:00:00 2001 From: Vladana Stojiljkovic Date: Tue, 22 Oct 2024 17:31:37 +0200 Subject: [PATCH] SWDEV-491257 - Create stream capture tests with Event APIs Change-Id: I9803a78c3513845f7bf91333a0db0d43bed5b346 [ROCm/hip-tests commit: fd92c47fea44e199a5cd9aee9e777a757fdaca9e] --- .../unit/event/Unit_hipEventElapsedTime.cc | 26 ++++++++++++++ .../catch/unit/event/hipEventCreate.cc | 29 ++++++++++++++++ .../unit/event/hipEventCreateWithFlags.cc | 34 ++++++++++++++++++- .../catch/unit/event/hipEventDestroy.cc | 18 ++++++++++ 4 files changed, 106 insertions(+), 1 deletion(-) diff --git a/projects/hip-tests/catch/unit/event/Unit_hipEventElapsedTime.cc b/projects/hip-tests/catch/unit/event/Unit_hipEventElapsedTime.cc index 21e66f97a6..9de5349843 100644 --- a/projects/hip-tests/catch/unit/event/Unit_hipEventElapsedTime.cc +++ b/projects/hip-tests/catch/unit/event/Unit_hipEventElapsedTime.cc @@ -209,6 +209,32 @@ TEST_CASE("Unit_hipEventElapsedTime") { HIP_CHECK(hipEventDestroy(stop)); } +TEST_CASE("Unit_hipEventElapsedTime_Verify_Capture") { + hipEvent_t start, stop; + + HIP_CHECK(hipEventCreate(&start)); + HIP_CHECK(hipEventCreate(&stop)); + HIP_CHECK(hipEventRecord(start, nullptr)); + HIP_CHECK(hipEventSynchronize(start)); + HIP_CHECK(hipEventRecord(stop, nullptr)); + HIP_CHECK(hipEventSynchronize(stop)); + + hipStream_t stream; + HIP_CHECK(hipStreamCreate(&stream)); + hipStreamCaptureMode mode = GENERATE(hipStreamCaptureModeGlobal, hipStreamCaptureModeThreadLocal, + hipStreamCaptureModeRelaxed); + HIP_CHECK(hipStreamBeginCapture(stream, mode)); + float tElapsed = 1.0f; + HIP_CHECK(hipEventElapsedTime(&tElapsed, start, stop)); + hipGraph_t graph; + HIP_CHECK(hipStreamEndCapture(stream, &graph)); + + HIP_CHECK(hipGraphDestroy(graph)); + HIP_CHECK(hipStreamDestroy(stream)); + HIP_CHECK(hipEventDestroy(start)); + HIP_CHECK(hipEventDestroy(stop)); +} + /** * End doxygen group EventTest. * @} diff --git a/projects/hip-tests/catch/unit/event/hipEventCreate.cc b/projects/hip-tests/catch/unit/event/hipEventCreate.cc index 99354f1797..78414c5a02 100644 --- a/projects/hip-tests/catch/unit/event/hipEventCreate.cc +++ b/projects/hip-tests/catch/unit/event/hipEventCreate.cc @@ -52,6 +52,35 @@ TEST_CASE("Unit_hipEventCreate_Positive") { HIP_CHECK(hipEventDestroy(event)); } +/** + * Test Description + * ------------------------ + * - Test event creation while stream is capturing. + * Test source + * ------------------------ + * - unit/event/hipEventCreate.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ +TEST_CASE("Unit_hipEventCreate_Verify_Capture") { + hipStream_t stream; + HIP_CHECK(hipStreamCreate(&stream)); + + hipStreamCaptureMode mode = GENERATE(hipStreamCaptureModeGlobal, hipStreamCaptureModeThreadLocal, + hipStreamCaptureModeRelaxed); + HIP_CHECK(hipStreamBeginCapture(stream, mode)); + hipEvent_t event; + HIP_CHECK(hipEventCreate(&event)); + REQUIRE(event != nullptr); + hipGraph_t graph; + HIP_CHECK(hipStreamEndCapture(stream, &graph)); + + HIP_CHECK(hipGraphDestroy(graph)); + HIP_CHECK(hipEventDestroy(event)); + HIP_CHECK(hipStreamDestroy(stream)); +} + /** * End doxygen group hipEventCreate. * @} diff --git a/projects/hip-tests/catch/unit/event/hipEventCreateWithFlags.cc b/projects/hip-tests/catch/unit/event/hipEventCreateWithFlags.cc index 1049026862..e9625d6fe2 100644 --- a/projects/hip-tests/catch/unit/event/hipEventCreateWithFlags.cc +++ b/projects/hip-tests/catch/unit/event/hipEventCreateWithFlags.cc @@ -347,10 +347,42 @@ TEST_CASE("Unit_hipEventCreateWithFlags_DefaultFlg_CohHstMem") { eMemoryToTest::eCoherentHostMemory, hipEventDefault); } } +#endif + +/** + * Test Description + * ------------------------ + * - Test event creation with hipEventCreateWithFlags while stream is capturing + * Test source + * ------------------------ + * - catch\unit\event\hipEventCreateWithFlags.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.2 + */ +TEST_CASE("Unit_hipEventCreateWithFlags_Verify_Capture") { + hipStream_t stream; + HIP_CHECK(hipStreamCreate(&stream)); + + hipStreamCaptureMode mode = GENERATE(hipStreamCaptureModeGlobal, hipStreamCaptureModeThreadLocal, + hipStreamCaptureModeRelaxed); + HIP_CHECK(hipStreamBeginCapture(stream, mode)); + + const unsigned int flags = GENERATE(hipEventDefault, hipEventBlockingSync, hipEventDisableTiming, + hipEventInterprocess | hipEventDisableTiming); + hipEvent_t event; + HIP_CHECK(hipEventCreateWithFlags(&event, flags)); + REQUIRE(event != nullptr); + hipGraph_t graph; + HIP_CHECK(hipStreamEndCapture(stream, &graph)); + + HIP_CHECK(hipGraphDestroy(graph)); + HIP_CHECK(hipEventDestroy(event)); + HIP_CHECK(hipStreamDestroy(stream)); +} /** * End doxygen group hipEventCreateWithFlags. * @} */ -#endif diff --git a/projects/hip-tests/catch/unit/event/hipEventDestroy.cc b/projects/hip-tests/catch/unit/event/hipEventDestroy.cc index e81b73d89f..0a8d7b5068 100644 --- a/projects/hip-tests/catch/unit/event/hipEventDestroy.cc +++ b/projects/hip-tests/catch/unit/event/hipEventDestroy.cc @@ -151,6 +151,24 @@ TEST_CASE("Unit_hipEventDestroy_Negative") { } #endif +TEST_CASE("Unit_hipEventDestroy_Verify_Capture") { + hipEvent_t event; + HIP_CHECK(hipEventCreate(&event)); + REQUIRE(event != nullptr); + + hipStream_t stream; + HIP_CHECK(hipStreamCreate(&stream)); + hipStreamCaptureMode mode = GENERATE(hipStreamCaptureModeGlobal, hipStreamCaptureModeThreadLocal, + hipStreamCaptureModeRelaxed); + HIP_CHECK(hipStreamBeginCapture(stream, mode)); + HIP_CHECK(hipEventDestroy(event)); + hipGraph_t graph; + HIP_CHECK(hipStreamEndCapture(stream, &graph)); + + HIP_CHECK(hipGraphDestroy(graph)); + HIP_CHECK(hipStreamDestroy(stream)); +} + /** * End doxygen group EventTest. * @}