diff --git a/projects/clr/rocclr/runtime/device/cpu/cpusettings.cpp b/projects/clr/rocclr/runtime/device/cpu/cpusettings.cpp index e654d32b63..2c407d1dad 100644 --- a/projects/clr/rocclr/runtime/device/cpu/cpusettings.cpp +++ b/projects/clr/rocclr/runtime/device/cpu/cpusettings.cpp @@ -54,7 +54,6 @@ Settings::create() enableExtension(ClKhrSubGroups); supportDepthsRGB_ = true; enableExtension(ClKhrDepthImages); - customSvmAllocator_ = true; } // Map CPUID feature bits to our own feature bits diff --git a/projects/clr/rocclr/runtime/device/device.cpp b/projects/clr/rocclr/runtime/device/device.cpp index aa010a50de..1cd452828e 100644 --- a/projects/clr/rocclr/runtime/device/device.cpp +++ b/projects/clr/rocclr/runtime/device/device.cpp @@ -518,7 +518,6 @@ Settings::Settings() supportRA_ = true; largeHostMemAlloc_ = false; customHostAllocator_ = false; - customSvmAllocator_ = false; waitCommand_ = AMD_OCL_WAIT_COMMAND; supportDepthsRGB_ = false; assumeAliases_ = false; diff --git a/projects/clr/rocclr/runtime/device/device.hpp b/projects/clr/rocclr/runtime/device/device.hpp index 1b3f6e0a71..a7f0eb4965 100644 --- a/projects/clr/rocclr/runtime/device/device.hpp +++ b/projects/clr/rocclr/runtime/device/device.hpp @@ -586,10 +586,9 @@ public: uint waitCommand_: 1; //!< Enables a wait for every submitted command uint customHostAllocator_: 1;//!< True if device has custom host allocator // that replaces generic OS allocation routines - uint customSvmAllocator_: 1; //!< True if device has custom SVM allocator uint supportDepthsRGB_: 1; //!< Support DEPTH and sRGB channel order format uint assumeAliases_: 1; //!< Assume aliases in the compilation process - uint reserved_: 24; + uint reserved_: 25; }; uint value_; }; @@ -1515,6 +1514,14 @@ public: const device::Info& info() const { return info_; } + //! Return svm support capability. + bool svmSupport() const { + return (info().svmCapabilities_ & + (CL_DEVICE_SVM_COARSE_GRAIN_BUFFER | + CL_DEVICE_SVM_FINE_GRAIN_BUFFER | + CL_DEVICE_SVM_FINE_GRAIN_SYSTEM)) != 0 ? true : false; + } + //! Return this device's type. cl_device_type type() const { return info().type_ & ~(CL_DEVICE_TYPE_DEFAULT | CL_HSA_ENABLED_AMD @@ -1614,13 +1621,6 @@ public: ShouldNotCallThis(); } - /** - * @return True if the device has its own custom SVM allocator - */ - bool customSvmAllocator() const { - return settings().customSvmAllocator_ == 1; - } - /** * @copydoc amd::Context::svmAlloc */ diff --git a/projects/clr/rocclr/runtime/device/gpu/gpusettings.cpp b/projects/clr/rocclr/runtime/device/gpu/gpusettings.cpp index 629edcf773..2641c80e59 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpusettings.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpusettings.cpp @@ -318,7 +318,6 @@ Settings::create( if (oclVersion_ >= OpenCL20) { supportDepthsRGB_ = true; - customSvmAllocator_ = true; } if (use64BitPtr_) { if (GPU_ENABLE_LARGE_ALLOCATION) { diff --git a/projects/clr/rocclr/runtime/device/hsa/hsasettings.cpp b/projects/clr/rocclr/runtime/device/hsa/hsasettings.cpp index fc4db222a7..a2cfe55a89 100644 --- a/projects/clr/rocclr/runtime/device/hsa/hsasettings.cpp +++ b/projects/clr/rocclr/runtime/device/hsa/hsasettings.cpp @@ -36,7 +36,6 @@ Settings::create(bool doublePrecision) { largeHostMemAlloc_ = true; customHostAllocator_ = true; - customSvmAllocator_ = true; // Enable extensions enableExtension(ClKhrByteAddressableStore); diff --git a/projects/clr/rocclr/runtime/platform/context.cpp b/projects/clr/rocclr/runtime/platform/context.cpp index 189b23603e..25124ab443 100644 --- a/projects/clr/rocclr/runtime/platform/context.cpp +++ b/projects/clr/rocclr/runtime/platform/context.cpp @@ -36,14 +36,14 @@ Context::Context( "is allowed per context"); customHostAllocDevice_ = device; } - if (device->customSvmAllocator()) { - customSvmAllocDevice_.push_back(device); + if (device->svmSupport()) { + svmAllocDevice_.push_back(device); } } //make sure the first device is GPU - if ((customSvmAllocDevice_.size() > 1) - && (customSvmAllocDevice_.front()->type() == CL_DEVICE_TYPE_CPU)) { - std::swap(customSvmAllocDevice_.front(), customSvmAllocDevice_.back()); + if ((svmAllocDevice_.size() > 1) + && (svmAllocDevice_.front()->type() == CL_DEVICE_TYPE_CPU)) { + std::swap(svmAllocDevice_.front(), svmAllocDevice_.back()); } } @@ -293,22 +293,22 @@ Context::hostFree(void* ptr) const void* Context::svmAlloc(size_t size, size_t alignment, cl_svm_mem_flags flags) { - unsigned int numSVMDev = customSvmAllocDevice_.size(); + unsigned int numSVMDev = svmAllocDevice_.size(); if (numSVMDev < 1) { return NULL; } - if (customSvmAllocDevice_.front()->type() == CL_DEVICE_TYPE_CPU) { + if (svmAllocDevice_.front()->type() == CL_DEVICE_TYPE_CPU) { return AlignedMemory::allocate(size, alignment); } else { void* svmPtrAlloced = NULL; void* tempPtr = NULL; - for (const auto& dev : customSvmAllocDevice_) { + for (const auto& dev : svmAllocDevice_) { if (dev->type() == CL_DEVICE_TYPE_GPU) { tempPtr = dev->svmAlloc(*this, size, alignment, flags); - if (dev == customSvmAllocDevice_.front()) { + if (dev == svmAllocDevice_.front()) { svmPtrAlloced = tempPtr; } if ((svmPtrAlloced != tempPtr) || (NULL == tempPtr)) { @@ -323,12 +323,12 @@ Context::svmAlloc(size_t size, size_t alignment, cl_svm_mem_flags flags) void Context::svmFree(void* ptr) const { - if (customSvmAllocDevice_.front()->type() == CL_DEVICE_TYPE_CPU) { + if (svmAllocDevice_.front()->type() == CL_DEVICE_TYPE_CPU) { AlignedMemory::deallocate(ptr); return; } - for (const auto& dev : customSvmAllocDevice_) { + for (const auto& dev : svmAllocDevice_) { if (dev->type() == CL_DEVICE_TYPE_GPU) { dev->svmFree(ptr); } diff --git a/projects/clr/rocclr/runtime/platform/context.hpp b/projects/clr/rocclr/runtime/platform/context.hpp index bfbc4bdf3f..64e5568757 100644 --- a/projects/clr/rocclr/runtime/platform/context.hpp +++ b/projects/clr/rocclr/runtime/platform/context.hpp @@ -143,7 +143,7 @@ public: const std::vector& devices() const { return devices_; } //! Return the SVM capable devices associated with this context. - const std::vector& svmDevices() const { return customSvmAllocDevice_; } + const std::vector& svmDevices() const { return svmAllocDevice_; } //! Returns true if the given device is associated with this context. bool containsDevice(const Device* device) const; @@ -187,7 +187,7 @@ private: cl_context_properties* properties_; //!< Original properties GLFunctions* glenv_; //!< OpenGL context Device* customHostAllocDevice_; //!< Device responsible for host allocations - std::vector customSvmAllocDevice_; //!< Devices can support SVM allocations + std::vector svmAllocDevice_; //!< Devices can support SVM allocations std::map deviceQueues_; //!< Device queues mapping Monitor ctxLock_; //!< Lock for the context access };