From 03ae7251defe00301edcdb4ea49f27904b69e61e Mon Sep 17 00:00:00 2001 From: Satyanvesh Dittakavi Date: Fri, 21 May 2021 08:55:26 -0700 Subject: [PATCH] SWDEV-286830 - Fix hipStreamACb_ThrdBehaviour on windows use sleep_for which works cross-platform for other tests as well Change-Id: I915444d620e9fad0b9eda93bcdd244f9956ab8d5 --- tests/src/runtimeApi/stream/StreamAddCallback.cpp | 5 +---- .../src/runtimeApi/stream/hipStreamACb_StrmSyncTiming.cpp | 5 +---- tests/src/runtimeApi/stream/hipStreamACb_ThrdBehaviour.cpp | 7 ++----- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/tests/src/runtimeApi/stream/StreamAddCallback.cpp b/tests/src/runtimeApi/stream/StreamAddCallback.cpp index e1fc1ffbad..225cc9245a 100644 --- a/tests/src/runtimeApi/stream/StreamAddCallback.cpp +++ b/tests/src/runtimeApi/stream/StreamAddCallback.cpp @@ -1,8 +1,5 @@ #include #include -#ifdef __linux__ -#include -#endif #include "test_common.h" #include @@ -41,7 +38,7 @@ void myCallback(hipStream_t stream, hipError_t status, void* user_data) UserData* data = reinterpret_cast(user_data); printf("Callback started\n"); - sleep(1); + std::this_thread::sleep_for (std::chrono::seconds(1)); printf("Callback ending.\n"); gData.store(ExecState::EXEC_CB_FINISHED); diff --git a/tests/src/runtimeApi/stream/hipStreamACb_StrmSyncTiming.cpp b/tests/src/runtimeApi/stream/hipStreamACb_StrmSyncTiming.cpp index a243a6b382..ac30f42a77 100644 --- a/tests/src/runtimeApi/stream/hipStreamACb_StrmSyncTiming.cpp +++ b/tests/src/runtimeApi/stream/hipStreamACb_StrmSyncTiming.cpp @@ -28,9 +28,6 @@ */ #include -#ifdef __linux__ -#include -#endif #include #include #include "hip/hip_runtime.h" @@ -80,7 +77,7 @@ static void HIPRT_CB Callback1(hipStream_t stream, hipError_t status, } // Delay the callback completion - sleep(SECONDS_TO_WAIT); + std::this_thread::sleep_for (std::chrono::seconds(SECONDS_TO_WAIT)); } bool rangedCompare(long a, long b) { diff --git a/tests/src/runtimeApi/stream/hipStreamACb_ThrdBehaviour.cpp b/tests/src/runtimeApi/stream/hipStreamACb_ThrdBehaviour.cpp index 9b52dcadcb..ca9c1cc121 100644 --- a/tests/src/runtimeApi/stream/hipStreamACb_ThrdBehaviour.cpp +++ b/tests/src/runtimeApi/stream/hipStreamACb_ThrdBehaviour.cpp @@ -27,9 +27,6 @@ * HIT_END */ -#ifdef __linux__ -#include -#endif #include #include "hip/hip_runtime.h" #include "test_common.h" @@ -41,7 +38,7 @@ bool Callback_Completed = false; void HIPRT_CB Callback1(hipStream_t stream, hipError_t status, void* userData) { - sleep(5); + std::this_thread::sleep_for (std::chrono::seconds(5)); Callback_Completed = true; } @@ -49,7 +46,7 @@ int main(int argc, char* argv[]) { hipStream_t mystream; HIPCHECK(hipStreamCreateWithFlags(&mystream, hipStreamNonBlocking)); HIPCHECK(hipStreamAddCallback(mystream, Callback1, NULL, 0)); - sleep(1); + std::this_thread::sleep_for (std::chrono::seconds(1)); // Callback_Completed is initialized to false. The same is set to true at // the end of callback and callback sleeps for 5 seconds.