From e075998b2bf59c4e92c080d5b33f99507bc39857 Mon Sep 17 00:00:00 2001 From: foreman Date: Thu, 6 Sep 2018 15:21:28 -0400 Subject: [PATCH] P4 to Git Change 1602601 by skudchad@skudchad_test2_win_opencl on 2018/09/06 15:01:00 SWDEV-145570 - [HIP] Implement hipStreamAddCallback and hipStreamQuery ReviewBoardURL = http://ocltc.amd.com/reviews/r/15749/diff/ Affected files ... ... //depot/stg/opencl/drivers/opencl/api/hip/hip_stream.cpp#13 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/commandqueue.cpp#27 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/commandqueue.hpp#19 edit ... //depot/stg/opencl/drivers/opencl/runtime/utils/concurrent.hpp#9 edit --- hipamd/api/hip/hip_stream.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/hipamd/api/hip/hip_stream.cpp b/hipamd/api/hip/hip_stream.cpp index a7221b0249..d7cd42bb51 100644 --- a/hipamd/api/hip/hip_stream.cpp +++ b/hipamd/api/hip/hip_stream.cpp @@ -65,6 +65,15 @@ static hipError_t ihipStreamCreateWithFlags(hipStream_t *stream, unsigned int fl return hipSuccess; } + +void ihipStreamCallback(hipStream_t stream, hipStreamCallback_t callback, void* userData) { + //Stream synchronize + hipError_t status = hipStreamSynchronize(stream); + + // Call the callback function + callback(stream, status, userData); +} + hipError_t hipStreamCreateWithFlags(hipStream_t *stream, unsigned int flags) { HIP_INIT_API(stream, flags); @@ -162,18 +171,22 @@ hipError_t hipStreamWaitEvent(hipStream_t stream, hipEvent_t event, unsigned int hipError_t hipStreamQuery(hipStream_t stream) { HIP_INIT_API(stream); - assert(0 && "Unimplemented"); - - HIP_RETURN(hipErrorUnknown); + amd::HostQueue* hostQueue; + if (stream == nullptr) { + hostQueue = hip::getNullStream(); + } else { + hostQueue = as_amd(reinterpret_cast(stream))->asHostQueue(); + } + HIP_RETURN(hostQueue->isEmpty() ? hipSuccess : hipErrorNotReady); } hipError_t hipStreamAddCallback(hipStream_t stream, hipStreamCallback_t callback, void* userData, unsigned int flags) { HIP_INIT_API(stream, callback, userData, flags); - assert(0 && "Unimplemented"); + std::thread (ihipStreamCallback, stream, callback, userData).detach(); - HIP_RETURN(hipErrorUnknown); + HIP_RETURN(hipSuccess); }