diff --git a/projects/clr/hipamd/src/hip_hcc.cpp b/projects/clr/hipamd/src/hip_hcc.cpp index f76c454e2e..2b5834cabc 100644 --- a/projects/clr/hipamd/src/hip_hcc.cpp +++ b/projects/clr/hipamd/src/hip_hcc.cpp @@ -69,6 +69,7 @@ int HIP_ATP_MARKER= 0; int HIP_DB= 0; int HIP_VISIBLE_DEVICES = 0; /* Contains a comma-separated sequence of GPU identifiers */ int HIP_NUM_KERNELS_INFLIGHT = 128; +int HIP_BLOCKING_SYNC = 0; std::once_flag hip_initialized; @@ -177,7 +178,7 @@ void ihipStream_t::wait(LockedAccessor_StreamCrit_t &crit, bool assertQueueEmpty { if (! assertQueueEmpty) { tprintf (DB_SYNC, "stream %p wait for queue-empty..\n", this); - crit->_av.wait(); + crit->_av.wait(HIP_BLOCKING_SYNC ? hc::hcWaitModeBlocked : hc::hcWaitModeActive); } crit->_kernelCnt = 0; @@ -257,8 +258,8 @@ void ihipStream_t::lockclose_postKernelCommand(hc::accelerator_view *av) { if (HIP_LAUNCH_BLOCKING) { - // TODO - fix this so it goes through proper stream::wait() call. - av->wait(); // direct wait OK since we know the stream is locked. + // TODO - fix this so it goes through proper stream::wait() call.// direct wait OK since we know the stream is locked. + av->wait(hc::hcWaitModeActive); tprintf(DB_SYNC, " %s LAUNCH_BLOCKING for kernel completion\n", ToString(this).c_str()); } @@ -1008,7 +1009,9 @@ void ihipInit() READ_ENV_I(release, HIP_VISIBLE_DEVICES, CUDA_VISIBLE_DEVICES, "Only devices whose index is present in the secquence are visible to HIP applications and they are enumerated in the order of secquence" ); - READ_ENV_I(release, HIP_NUM_KERNELS_INFLIGHT, 128, "Number of kernels per stream "); + READ_ENV_I(release, HIP_BLOCKING_SYNC, 0, "Use blocking synchronization for stream waits. This may increase latency but is friendlier to other processes. If 0, spin-wait."); + + READ_ENV_I(release, HIP_NUM_KERNELS_INFLIGHT, 128, "Max number of inflight kernels per stream before active synchronization is forced."); // Some flags have both compile-time and runtime flags - generate a warning if user enables the runtime flag but the compile-time flag is disabled. if (HIP_DB && !COMPILE_HIP_DB) {