From a7adace36e951d96d70de3738cb5f553e35c7070 Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Fri, 6 Nov 2020 17:36:49 -0500 Subject: [PATCH] Add direct dispatch simple hack for testing The hack dosn't really track the commands status. It may be not necessary for HIP, but will cause early resource release. Change-Id: I791ad36dd8abd3b6b3d2c9b16a210a555c08ca64 [ROCm/clr commit: 532f0ae95128151af286a28b601e774f354a123f] --- projects/clr/rocclr/platform/command.cpp | 18 ++++++++++++++++-- projects/clr/rocclr/utils/flags.hpp | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/projects/clr/rocclr/platform/command.cpp b/projects/clr/rocclr/platform/command.cpp index 76fe6d140a..9f8751401a 100644 --- a/projects/clr/rocclr/platform/command.cpp +++ b/projects/clr/rocclr/platform/command.cpp @@ -258,8 +258,22 @@ void Command::enqueue() { } ClPrint(LOG_DEBUG, LOG_CMD, "command is enqueued: %p", this); - queue_->append(*this); - queue_->flush(); + if (AMD_DIRECT_DISPATCH) { + if (type() == CL_COMMAND_MARKER || type() == 0) { + setStatus(CL_SUBMITTED); + queue_->vdev()->flush(); + retain(); + setStatus(CL_COMPLETE); + } else { + setStatus(CL_SUBMITTED); + submit(*queue_->vdev()); + retain(); + setStatus(CL_COMPLETE); + } + } else { + queue_->append(*this); + queue_->flush(); + } if ((queue_->device().settings().waitCommand_ && (type_ != 0)) || ((commandWaitBits_ & 0x2) != 0)) { awaitCompletion(); diff --git a/projects/clr/rocclr/utils/flags.hpp b/projects/clr/rocclr/utils/flags.hpp index da9fae9f30..53852b2d98 100644 --- a/projects/clr/rocclr/utils/flags.hpp +++ b/projects/clr/rocclr/utils/flags.hpp @@ -231,6 +231,8 @@ release(uint, HIP_HOST_COHERENT, 0, \ release(uint, AMD_OPT_FLUSH, 1, \ "Kernel flush option , 0x0 = Use system-scope fence operations." \ "0x1 = Use device-scope fence operations when possible.") \ +release(bool, AMD_DIRECT_DISPATCH, false, \ + "Enable direct kernel dispatch.") \ release(uint, HIP_HIDDEN_FREE_MEM, 0, \ "Reserve free mem reporting in Mb" \ "0 = Disable") \