diff --git a/rocclr/runtime/device/device.cpp b/rocclr/runtime/device/device.cpp index 4e7b26fdfc..b05b09691c 100644 --- a/rocclr/runtime/device/device.cpp +++ b/rocclr/runtime/device/device.cpp @@ -628,6 +628,8 @@ Settings::Settings() waitCommand_ = AMD_OCL_WAIT_COMMAND; supportDepthsRGB_ = false; enableHwDebug_ = false; + commandQueues_ = 200; //!< Field value set to maximum number + //!< concurrent Virtual GPUs for default } bool diff --git a/rocclr/runtime/device/device.hpp b/rocclr/runtime/device/device.hpp index 4f322f3479..a31d7672b7 100644 --- a/rocclr/runtime/device/device.hpp +++ b/rocclr/runtime/device/device.hpp @@ -594,6 +594,8 @@ public: uint value_; }; + uint commandQueues_; //!< Field value for maximum number + //!< concurrent Virtual GPUs for each backend //! Default constructor Settings(); diff --git a/rocclr/runtime/device/rocm/rocdevice.cpp b/rocclr/runtime/device/rocm/rocdevice.cpp index 208c63d22a..7d097a042f 100644 --- a/rocclr/runtime/device/rocm/rocdevice.cpp +++ b/rocclr/runtime/device/rocm/rocdevice.cpp @@ -186,6 +186,7 @@ Device::Device(hsa_agent_t bkendDevice) , alloc_granularity_(0) , context_(nullptr) , xferQueue_(nullptr) + , numOfVgpus_(0) { group_segment_.handle = 0; system_segment_.handle = 0; diff --git a/rocclr/runtime/device/rocm/rocdevice.hpp b/rocclr/runtime/device/rocm/rocdevice.hpp index 3aff6e1458..560ba509dc 100644 --- a/rocclr/runtime/device/rocm/rocdevice.hpp +++ b/rocclr/runtime/device/rocm/rocdevice.hpp @@ -221,6 +221,8 @@ public: static bool loadHsaModules(); + amd::Atomic numOfVgpus_; //!< Virtual gpu unique index + bool create(); //! Construct a new physical HSA device diff --git a/rocclr/runtime/device/rocm/rocsettings.cpp b/rocclr/runtime/device/rocm/rocsettings.cpp index 133b2cd90c..a491a81022 100644 --- a/rocclr/runtime/device/rocm/rocsettings.cpp +++ b/rocclr/runtime/device/rocm/rocsettings.cpp @@ -52,6 +52,8 @@ Settings::Settings() partialDispatch = getenv("OPENCL_DISABLE_PARTIAL_DISPATCH"); enablePartialDispatch_ = (partialDispatch) ? false : true; partialDispatch_ = (partialDispatch) ? false : true; + commandQueues_ = 100 //!< Field value set to maximum number + //!< concurrent Virtual GPUs for ROCm backend } bool @@ -97,6 +99,11 @@ Settings::create(bool doublePrecision) void Settings::override() { + if (!flagIsDefault(GPU_MAX_COMMAND_QUEUES)) { + commandQueues_ = GPU_MAX_COMMAND_QUEUES; + } +} + } } // namespace roc diff --git a/rocclr/runtime/device/rocm/rocvirtual.cpp b/rocclr/runtime/device/rocm/rocvirtual.cpp index 663ea208f8..4a8bd1bd9a 100644 --- a/rocclr/runtime/device/rocm/rocvirtual.cpp +++ b/rocclr/runtime/device/rocm/rocvirtual.cpp @@ -450,6 +450,8 @@ bool VirtualGPU::releaseGpuMemoryFence() { VirtualGPU::VirtualGPU(Device &device) : device::VirtualDevice(device) , roc_device_(device) + , index_(device_.numOfVgpus_++) // Virtual gpu unique index incrementing + , gpuDevice_(device) { gpu_device_ = device.getBackendDevice(); // Initialize the last signal and dispatch flags @@ -477,6 +479,7 @@ VirtualGPU::~VirtualGPU() } tools_lib_ = NULL; + --gpuDevice_.numOfVgpus_; // Virtual gpu unique index decrementing } bool @@ -494,6 +497,11 @@ VirtualGPU::create(bool profilingEna) tools_lib_ = amd::Os::loadLibrary(tools_lib_name); } + // Checking Virtual gpu unique index for ROCm backend + if (index() > device().settings().commandQueues_) { + return false; + } + uint32_t queue_max_packets = 0; if (HSA_STATUS_SUCCESS != hsa_agent_get_info( diff --git a/rocclr/runtime/device/rocm/rocvirtual.hpp b/rocclr/runtime/device/rocm/rocvirtual.hpp index 6c3e881825..254ea6a911 100644 --- a/rocclr/runtime/device/rocm/rocvirtual.hpp +++ b/rocclr/runtime/device/rocm/rocvirtual.hpp @@ -193,7 +193,10 @@ public: bool processMemObjects( const amd::Kernel& kernel, //!< AMD kernel object for execution const_address params //!< Pointer to the param's store - ); + ); + //Retun the virtual gpu unique index + uint index() const { return index_; } + // } roc OpenCL integration private: @@ -244,7 +247,8 @@ private: uint kernarg_pool_cur_offset_; std::vector signal_pool_; //!< Pool of signals for profiling - + Device& gpuDevice_; //!< Roc device obj + const uint index_; //!< Virtual gpu unique index friend class Timestamp; }; }