EXSWHTEC-15 - Implement additional HipEventElapsedTime tests (#2903)
- Fix minor bug in helper test function in Unit_hipEvent.cc - Move negative test from Unit_hipEventElapsedTime_DifferentDevices to Unit_hipEventRecord_Negative - Add Unit_hipEventElapsedTime_NotReady_Negative test when function is called on event that has not been completed
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
51a22bb085
Коммит
f72a34b807
@@ -114,7 +114,8 @@ void test(unsigned testMask, int* C_d, int* C_h, int64_t numElements, hipStream_
|
||||
if (e == hipSuccess) assert(t == 0.0f);
|
||||
|
||||
// stop usually ready unless we skipped the synchronization (syncNone)
|
||||
HIP_ASSERT(hipEventElapsedTime(&t, stop, stop) == expectedStopError);
|
||||
e = hipEventElapsedTime(&t, stop, stop);
|
||||
HIP_ASSERT(e == expectedStopError);
|
||||
if (e == hipSuccess) assert(t == 0.0f);
|
||||
|
||||
e = hipEventElapsedTime(&t, start, stop);
|
||||
|
||||
@@ -19,8 +19,19 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
/*
|
||||
Testcase Scenarios :
|
||||
Unit_hipEventElapsedTime_NullCheck - Test unsuccessful hipEventElapsedTime when either event passed as nullptr
|
||||
Unit_hipEventElapsedTime_DisableTiming - Test unsuccessful hipEventElapsedTime when events are created with hipEventDisableTiming flag
|
||||
Unit_hipEventElapsedTime_DifferentDevices - Test unsuccessful hipEventElapsedTime when events are recorded on different devices
|
||||
Unit_hipEventElapsedTime_NotReady_Negative - Test unsuccessful hipEventElapsedTime when an event has not been completed
|
||||
Unit_hipEventElapsedTime - Test time elapsed between two recorded events with hipEventElapsedTime api
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
#include <hip_test_checkers.hh>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
TEST_CASE("Unit_hipEventElapsedTime_NullCheck") {
|
||||
@@ -51,9 +62,7 @@ TEST_CASE("Unit_hipEventElapsedTime_DifferentDevices") {
|
||||
// create event on dev=0
|
||||
HIP_CHECK(hipSetDevice(0));
|
||||
hipEvent_t start;
|
||||
hipEvent_t start1;
|
||||
HIP_CHECK(hipEventCreate(&start));
|
||||
HIP_CHECK(hipEventCreate(&start1));
|
||||
|
||||
HIP_CHECK(hipEventRecord(start, nullptr));
|
||||
HIP_CHECK(hipEventSynchronize(start));
|
||||
@@ -63,9 +72,6 @@ TEST_CASE("Unit_hipEventElapsedTime_DifferentDevices") {
|
||||
hipEvent_t stop;
|
||||
HIP_CHECK(hipEventCreate(&stop));
|
||||
|
||||
// start1 on device 0 but null stream on device 1
|
||||
HIP_ASSERT(hipEventRecord(start1, nullptr) == hipErrorInvalidHandle);
|
||||
|
||||
HIP_CHECK(hipEventRecord(stop, nullptr));
|
||||
HIP_CHECK(hipEventSynchronize(stop));
|
||||
|
||||
@@ -74,11 +80,37 @@ TEST_CASE("Unit_hipEventElapsedTime_DifferentDevices") {
|
||||
HIP_ASSERT(hipEventElapsedTime(&tElapsed,start,stop) == hipErrorInvalidHandle);
|
||||
|
||||
HIP_CHECK(hipEventDestroy(start));
|
||||
HIP_CHECK(hipEventDestroy(start1));
|
||||
HIP_CHECK(hipEventDestroy(stop));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if HT_AMD /* Disabled because frequency based wait is timing out on nvidia platforms */
|
||||
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));
|
||||
|
||||
HipTest::runKernelForDuration(std::chrono::milliseconds(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(hipEventDestroy(start));
|
||||
HIP_CHECK(hipEventDestroy(stop));
|
||||
}
|
||||
#endif // HT_AMD
|
||||
|
||||
TEST_CASE("Unit_hipEventElapsedTime") {
|
||||
hipEvent_t start;
|
||||
HIP_CHECK(hipEventCreate(&start));
|
||||
|
||||
@@ -19,8 +19,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// Test hipEventRecord serialization behavior.
|
||||
/*
|
||||
Testcase Scenarios :
|
||||
Unit_hipEventRecord- Test hipEventRecord serialization behavior
|
||||
Unit_hipEventRecord_Negative - Test unsuccessful hipEventRecord when event is passed as nullptr
|
||||
- Test unsuccessful hipEventRecord when event is created/recorded on different devices
|
||||
*/
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
@@ -117,4 +121,21 @@ TEST_CASE("Unit_hipEventRecord_Negative") {
|
||||
SECTION("Nullptr event") {
|
||||
HIP_CHECK_ERROR(hipEventRecord(nullptr, nullptr), hipErrorInvalidResourceHandle);
|
||||
}
|
||||
|
||||
SECTION("Different devices") {
|
||||
int devCount = 0;
|
||||
HIP_CHECK(hipGetDeviceCount(&devCount));
|
||||
if (devCount > 1) {
|
||||
// create event on dev=0
|
||||
HIP_CHECK(hipSetDevice(0));
|
||||
hipEvent_t start;
|
||||
HIP_CHECK(hipEventCreate(&start));
|
||||
|
||||
// start on device 0 but null stream on device 1
|
||||
HIP_CHECK(hipSetDevice(1));
|
||||
HIP_CHECK_ERROR(hipEventRecord(start, nullptr), hipErrorInvalidHandle)
|
||||
|
||||
HIP_CHECK(hipEventDestroy(start));
|
||||
}
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user