CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
227 lines
6.7 KiB
C++
227 lines
6.7 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include <hip_test_common.hh>
|
|
#include <hip_test_checkers.hh>
|
|
#include <iostream>
|
|
#include <utils.hh>
|
|
/**
|
|
* @addtogroup hipEventElapsedTime hipEventElapsedTime
|
|
* @{
|
|
* @ingroup EventTest
|
|
* `hipEventElapsedTime(float* ms, hipEvent_t start, hipEvent_t stop)` -
|
|
* Return the elapsed time between two events.
|
|
* ________________________
|
|
* Test cases from other modules:
|
|
* - @ref Unit_hipEvent
|
|
* - @ref Unit_hipEventIpc
|
|
* - @ref Unit_hipEventMGpuMThreads_1
|
|
* - @ref Unit_hipEventMGpuMThreads_2
|
|
* - @ref Unit_hipEventMGpuMThreads_3
|
|
*/
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Validates handling of invalid arguments:
|
|
* -# When output parameter for time is `nullptr`
|
|
* - Expected output: return `hipErrorInvalidValue`
|
|
* -# When first event is `nullptr`
|
|
* - Expected output: return `hipErrorInvalidHandle`
|
|
* -# When second event is `nullptr`
|
|
* - Expected output: return `hipErrorInvalidHandle`
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/event/Unit_hipEventElapsedTime.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_hipEventElapsedTime_NullCheck) {
|
|
hipEvent_t start, end;
|
|
HIP_CHECK(hipEventCreate(&start));
|
|
HIP_CHECK(hipEventCreate(&end));
|
|
|
|
float tms = 1.0f;
|
|
HIP_ASSERT(hipEventElapsedTime(nullptr, start, end) == hipErrorInvalidValue);
|
|
#ifndef __HIP_PLATFORM_NVIDIA__
|
|
// On NVCC platform API throws seg fault hence skipping
|
|
HIP_ASSERT(hipEventElapsedTime(&tms, nullptr, end) == hipErrorInvalidHandle);
|
|
HIP_ASSERT(hipEventElapsedTime(&tms, start, nullptr) == hipErrorInvalidHandle);
|
|
#endif
|
|
HIP_CHECK(hipEventDestroy(start));
|
|
HIP_CHECK(hipEventDestroy(end));
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Calculates elapsed time when events are created with disable timing flag
|
|
* -# When flag is set to disable timing
|
|
* - Expected output: return `hipErrorInvalidHandle`
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/event/Unit_hipEventElapsedTime.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_hipEventElapsedTime_DisableTiming) {
|
|
float timeElapsed = 1.0f;
|
|
hipEvent_t start, stop;
|
|
HIP_CHECK(hipEventCreateWithFlags(&start, hipEventDisableTiming));
|
|
HIP_CHECK(hipEventCreateWithFlags(&stop, hipEventDisableTiming));
|
|
HIP_ASSERT(hipEventElapsedTime(&timeElapsed, start, stop) == hipErrorInvalidHandle);
|
|
HIP_CHECK(hipEventDestroy(start));
|
|
HIP_CHECK(hipEventDestroy(stop));
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Calculates elapsed time when events are recorded on different devices
|
|
* -# When start and stop events are recorded on different devices
|
|
* - Expected output: return `hipErrorInvalidHandle`
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/event/Unit_hipEventElapsedTime.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_hipEventElapsedTime_DifferentDevices) {
|
|
const auto device_count = HipTest::getDeviceCount();
|
|
if (device_count < 2) {
|
|
HIP_SKIP_TEST(HipTest::SkipReason::kFewerThanTwoGpus);
|
|
}
|
|
|
|
// create event on dev=0
|
|
HIP_CHECK(hipSetDevice(0));
|
|
hipEvent_t start;
|
|
HIP_CHECK(hipEventCreate(&start));
|
|
|
|
HIP_CHECK(hipEventRecord(start, nullptr));
|
|
HIP_CHECK(hipEventSynchronize(start));
|
|
|
|
// create event on dev=1
|
|
HIP_CHECK(hipSetDevice(1));
|
|
hipEvent_t stop;
|
|
HIP_CHECK(hipEventCreate(&stop));
|
|
|
|
HIP_CHECK(hipEventRecord(stop, nullptr));
|
|
HIP_CHECK(hipEventSynchronize(stop));
|
|
|
|
float tElapsed = 1.0f;
|
|
// start on device 0 but stop on device 1
|
|
HIP_ASSERT(hipEventElapsedTime(&tElapsed, start, stop) == hipErrorInvalidHandle);
|
|
|
|
HIP_CHECK(hipEventDestroy(start));
|
|
HIP_CHECK(hipEventDestroy(stop));
|
|
}
|
|
|
|
|
|
#if HT_AMD /* Disabled because frequency based wait is timing out on nvidia platforms */
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Calculates elapsed time when an event has not been completed.
|
|
* -# When the stop event has not finished yet
|
|
* - Expected output: return `hipErrorNotReady`
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/event/Unit_hipEventElapsedTime.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - Platform specific (AMD)
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_hipEventElapsedTime_NotReady_Negative) {
|
|
hipEvent_t start;
|
|
HIP_CHECK(hipEventCreate(&start));
|
|
|
|
hipEvent_t stop;
|
|
HIP_CHECK(hipEventCreate(&stop));
|
|
|
|
// Record start event
|
|
HIP_CHECK(hipEventRecord(start, nullptr));
|
|
|
|
LaunchDelayKernel(std::chrono::milliseconds(isQuickLevel() ? 100 : 1000));
|
|
// Record stop event
|
|
HIP_CHECK(hipEventRecord(stop, nullptr));
|
|
|
|
// stop event has not been completed
|
|
float tElapsed = 1.0f;
|
|
HIP_CHECK_ERROR(hipEventQuery(stop), hipErrorNotReady);
|
|
HIP_ASSERT(hipEventElapsedTime(&tElapsed, start, stop) == hipErrorNotReady);
|
|
|
|
HIP_CHECK(hipStreamSynchronize(nullptr));
|
|
HIP_CHECK(hipEventDestroy(start));
|
|
HIP_CHECK(hipEventDestroy(stop));
|
|
}
|
|
#endif // HT_AMD
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Calculates elapsed time between two successfully created and recorded events.
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/event/Unit_hipEventElapsedTime.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_hipEventElapsedTime) {
|
|
hipEvent_t start;
|
|
HIP_CHECK(hipEventCreate(&start));
|
|
|
|
hipEvent_t stop;
|
|
HIP_CHECK(hipEventCreate(&stop));
|
|
|
|
HIP_CHECK(hipEventRecord(start, nullptr));
|
|
HIP_CHECK(hipEventSynchronize(start));
|
|
|
|
HIP_CHECK(hipEventRecord(stop, nullptr));
|
|
HIP_CHECK(hipEventSynchronize(stop));
|
|
|
|
float tElapsed = 1.0f;
|
|
HIP_CHECK(hipEventElapsedTime(&tElapsed, start, stop));
|
|
|
|
HIP_CHECK(hipEventDestroy(start));
|
|
HIP_CHECK(hipEventDestroy(stop));
|
|
}
|
|
|
|
HIP_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.
|
|
* @}
|
|
*/
|