From 3610972765accc26e76ea590698a9a7e239c85d3 Mon Sep 17 00:00:00 2001 From: foreman Date: Thu, 6 Jun 2019 11:45:30 -0400 Subject: [PATCH] P4 to Git Change 1792742 by gandryey@gera-win10 on 2019/06/06 11:13:45 SWDEV-79445 - OCL generic changes and code clean-up - Update COMGR loader to avoid the build with device layers Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/comgrctx.cpp#3 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#244 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/devkernel.cpp#23 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/devkernel.hpp#16 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.cpp#45 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.hpp#25 edit --- rocclr/runtime/device/comgrctx.cpp | 4 +++- rocclr/runtime/device/device.cpp | 2 +- rocclr/runtime/device/devkernel.cpp | 14 ++++++++++++++ rocclr/runtime/device/devkernel.hpp | 15 +++------------ rocclr/runtime/device/devprogram.cpp | 1 + rocclr/runtime/device/devprogram.hpp | 3 ++- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/rocclr/runtime/device/comgrctx.cpp b/rocclr/runtime/device/comgrctx.cpp index 5e71bf91a3..30b2acab1b 100644 --- a/rocclr/runtime/device/comgrctx.cpp +++ b/rocclr/runtime/device/comgrctx.cpp @@ -3,6 +3,7 @@ // #if defined(USE_COMGR_LIBRARY) #include "os/os.hpp" +#include "utils/flags.hpp" #include "comgrctx.hpp" namespace amd { @@ -12,6 +13,7 @@ bool Comgr::is_ready_ = false; bool Comgr::LoadLib() { #if defined(COMGR_DYN_DLL) + LogInfo("Loading COMGR library."); static const char* ComgrLibName = LP64_SWITCH(WINDOWS_SWITCH("amdcomgr.dll", "libamdcomgr32.so"), WINDOWS_SWITCH("amdcomgr64.dll", "libamdcomgr64.so")); @@ -69,4 +71,4 @@ bool Comgr::LoadLib() { } } -#endif \ No newline at end of file +#endif diff --git a/rocclr/runtime/device/device.cpp b/rocclr/runtime/device/device.cpp index be3a95727f..951d944605 100644 --- a/rocclr/runtime/device/device.cpp +++ b/rocclr/runtime/device/device.cpp @@ -6,6 +6,7 @@ #include "thread/atomic.hpp" #include "thread/monitor.hpp" #include "utils/options.hpp" +#include "comgrctx.hpp" #if defined(WITH_HSA_DEVICE) #include "device/rocm/rocdevice.hpp" @@ -232,7 +233,6 @@ bool Device::ValidateComgr() { #if defined(USE_COMGR_LIBRARY) // Check if Lightning compiler was requested if (settings_->useLightning_) { - LogInfo("Loading COMGR library."); std::call_once(amd::Comgr::initialized, amd::Comgr::LoadLib); // Use Lightning only if it's available settings_->useLightning_ = amd::Comgr::IsReady(); diff --git a/rocclr/runtime/device/devkernel.cpp b/rocclr/runtime/device/devkernel.cpp index e10bcf2301..b7f5d5a83b 100644 --- a/rocclr/runtime/device/devkernel.cpp +++ b/rocclr/runtime/device/devkernel.cpp @@ -9,6 +9,7 @@ #include "utils/options.hpp" #include "utils/bif_section_labels.hpp" #include "utils/libUtils.h" +#include "comgrctx.hpp" #include #include @@ -30,6 +31,19 @@ using llvm::AMDGPU::HSAMD::ValueType; namespace device { #if defined(USE_COMGR_LIBRARY) +amd_comgr_status_t getMetaBuf(const amd_comgr_metadata_node_t meta, + std::string* str) { + size_t size = 0; + amd_comgr_status_t status = amd::Comgr::get_metadata_string(meta, &size, NULL); + + if (status == AMD_COMGR_STATUS_SUCCESS) { + str->resize(size-1); // minus one to discount the null character + status = amd::Comgr::get_metadata_string(meta, &size, &((*str)[0])); + } + + return status; +} + static amd_comgr_status_t populateArgs(const amd_comgr_metadata_node_t key, const amd_comgr_metadata_node_t value, void *data) { diff --git a/rocclr/runtime/device/devkernel.hpp b/rocclr/runtime/device/devkernel.hpp index acff0adcec..561dfc087d 100644 --- a/rocclr/runtime/device/devkernel.hpp +++ b/rocclr/runtime/device/devkernel.hpp @@ -26,6 +26,7 @@ struct RuntimeHandle { }; #if defined(USE_COMGR_LIBRARY) +#include "amd_comgr.h" #include "llvm/Support/AMDGPUMetadata.h" typedef llvm::AMDGPU::HSAMD::Kernel::Arg::Metadata KernelArgMD; @@ -383,6 +384,7 @@ class Kernel : public amd::HeapObject { std::string compileVecTypeHint_; //!< kernel compiled vector type hint bool uniformWorkGroupSize_; //!< uniform work group size option size_t wavesPerSimdHint_; //!< waves per simd hit + int maxOccupancyPerCu_; //!< Max occupancy per compute unit in threads }; //! Default constructor @@ -560,17 +562,6 @@ class Kernel : public amd::HeapObject { }; #if defined(USE_COMGR_LIBRARY) -static amd_comgr_status_t getMetaBuf(const amd_comgr_metadata_node_t meta, - std::string* str) { - size_t size = 0; - amd_comgr_status_t status = amd::Comgr::get_metadata_string(meta, &size, NULL); - - if (status == AMD_COMGR_STATUS_SUCCESS) { - str->resize(size-1); // minus one to discount the null character - status = amd::Comgr::get_metadata_string(meta, &size, &((*str)[0])); - } - - return status; -} +amd_comgr_status_t getMetaBuf(const amd_comgr_metadata_node_t meta, std::string* str); #endif // defined(USE_COMGR_LIBRARY) } // namespace device diff --git a/rocclr/runtime/device/devprogram.cpp b/rocclr/runtime/device/devprogram.cpp index 499bee36b3..fb3d4b202a 100644 --- a/rocclr/runtime/device/devprogram.cpp +++ b/rocclr/runtime/device/devprogram.cpp @@ -10,6 +10,7 @@ #include "utils/options.hpp" #include "utils/bif_section_labels.hpp" #include "utils/libUtils.h" +#include "comgrctx.hpp" #if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #ifndef USE_COMGR_LIBRARY diff --git a/rocclr/runtime/device/devprogram.hpp b/rocclr/runtime/device/devprogram.hpp index b35cb0771e..67af239ced 100644 --- a/rocclr/runtime/device/devprogram.hpp +++ b/rocclr/runtime/device/devprogram.hpp @@ -8,11 +8,12 @@ #include "platform/object.hpp" #include "platform/memory.hpp" #include "devwavelimiter.hpp" -#include "comgrctx.hpp" #if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #ifndef USE_COMGR_LIBRARY #include "driver/AmdCompiler.h" +#else +#include "amd_comgr.h" #endif //#include "llvm/Support/AMDGPUMetadata.h"