From 07d06ef15620b262762510e3a46078e0dbbb1be9 Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Sat, 2 Jun 2018 17:55:37 -0400 Subject: [PATCH 1/2] callback handler: don't need to wait for the thread to become ready [ROCm/clr commit: e21e6ed3a05521f4d062ab1f8967e3457618307b] --- projects/clr/hipamd/src/hip_stream.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/projects/clr/hipamd/src/hip_stream.cpp b/projects/clr/hipamd/src/hip_stream.cpp index d9c227b6ac..4170e33d63 100644 --- a/projects/clr/hipamd/src/hip_stream.cpp +++ b/projects/clr/hipamd/src/hip_stream.cpp @@ -201,14 +201,5 @@ hipError_t hipStreamAddCallback(hipStream_t stream, hipStreamCallback_t callback ihipStreamCallback_t* cb = new ihipStreamCallback_t(stream, callback, userData); std::thread(ihipStreamCallbackHandler, cb).detach(); - // Wait for thread to be ready - cb->_mtx.lock(); - while (cb->_ready != true) { - cb->_mtx.unlock(); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - cb->_mtx.lock(); - } - cb->_mtx.unlock(); - return ihipLogStatus(e); } From 8cfbffb82bfd091489cf91be5e192acf9f9fd7b3 Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Mon, 4 Jun 2018 17:29:04 -0400 Subject: [PATCH 2/2] remove the _ready flag in ihipStreamCallback_t and the mutex that protects it. [ROCm/clr commit: 0d719c514f2b60ab9533211e6d747a6ccf572d6d] --- projects/clr/hipamd/src/hip_hcc.cpp | 4 ---- projects/clr/hipamd/src/hip_hcc_internal.h | 3 --- 2 files changed, 7 deletions(-) diff --git a/projects/clr/hipamd/src/hip_hcc.cpp b/projects/clr/hipamd/src/hip_hcc.cpp index 9856dc1905..538a9039bf 100644 --- a/projects/clr/hipamd/src/hip_hcc.cpp +++ b/projects/clr/hipamd/src/hip_hcc.cpp @@ -1445,10 +1445,6 @@ hipError_t ihipStreamSynchronize(hipStream_t stream) { void ihipStreamCallbackHandler(ihipStreamCallback_t* cb) { hipError_t e = hipSuccess; - // Notify hipStreamAddCallback that callback handler thread is active - std::lock_guard guard(cb->_mtx); - cb->_ready = true; - // Synchronize stream tprintf(DB_SYNC, "ihipStreamCallbackHandler wait on stream %s\n", ToString(cb->_stream).c_str()); diff --git a/projects/clr/hipamd/src/hip_hcc_internal.h b/projects/clr/hipamd/src/hip_hcc_internal.h index ce8041ef63..4008df1574 100644 --- a/projects/clr/hipamd/src/hip_hcc_internal.h +++ b/projects/clr/hipamd/src/hip_hcc_internal.h @@ -620,13 +620,10 @@ class ihipStreamCallback_t { public: ihipStreamCallback_t(hipStream_t stream, hipStreamCallback_t callback, void* userData) : _stream(stream), _callback(callback), _userData(userData) { - _ready = false; }; hipStream_t _stream; hipStreamCallback_t _callback; void* _userData; - std::mutex _mtx; - bool _ready; };