From 03d5d4b4859f8940ef92c65ec5dae3e2a728fb00 Mon Sep 17 00:00:00 2001 From: foreman Date: Fri, 7 Dec 2018 18:30:39 -0500 Subject: [PATCH] P4 to Git Change 1717839 by gandryey@gera-w8 on 2018/12/07 17:54:13 SWDEV-162389 - Prepare the runtime code for enabling COMGR by default in the non-LC workspace - Make sure OCL runtime can dynamically switch between HSAIL and LC paths - For now use the both WITH_LIGHTNING_COMPILER and USE_COMGR_LIBRARY defines to identify LC specific code. The clean-up will come later Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#236 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#325 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/devkernel.cpp#12 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/devkernel.hpp#8 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.cpp#17 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.hpp#10 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.cpp#247 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#116 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palkernel.cpp#72 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.cpp#83 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palsettings.cpp#61 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/program.cpp#99 edit --- rocclr/runtime/device/device.cpp | 6 +- rocclr/runtime/device/device.hpp | 12 ++-- rocclr/runtime/device/devkernel.cpp | 30 ++++----- rocclr/runtime/device/devkernel.hpp | 6 +- rocclr/runtime/device/devprogram.cpp | 80 ++++++++++++----------- rocclr/runtime/device/devprogram.hpp | 8 +-- rocclr/runtime/device/gpu/gpuresource.cpp | 4 +- rocclr/runtime/device/pal/paldevice.cpp | 12 ++-- rocclr/runtime/device/pal/palkernel.cpp | 12 ++-- rocclr/runtime/device/pal/palprogram.cpp | 18 ++--- rocclr/runtime/device/pal/palsettings.cpp | 2 +- rocclr/runtime/platform/program.cpp | 2 +- 12 files changed, 97 insertions(+), 95 deletions(-) diff --git a/rocclr/runtime/device/device.cpp b/rocclr/runtime/device/device.cpp index c1e45e41d1..0a78627bfc 100644 --- a/rocclr/runtime/device/device.cpp +++ b/rocclr/runtime/device/device.cpp @@ -397,7 +397,7 @@ char* Device::getExtensionString() { return result; } -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) CacheCompilation::CacheCompilation(std::string targetStr, std::string postfix, bool enableCache, bool resetCache) : codeCache_(targetStr, 0, AMD_PLATFORM_BUILD_NUMBER, postfix), @@ -482,11 +482,13 @@ bool CacheCompilation::compileToLLVMBitcode(amd::opencl_driver::Compiler* C, StringCache::CachedData cachedData = {bc->Ptr(), bc->Size()}; bcSet.push_back(cachedData); } else if (input->Type() == DT_CL_HEADER) { +#if !defined(USE_COMGR_LIBRARY) FileReference* bcFile = reinterpret_cast(input); std::string bc; bcFile->ReadToString(bc); StringCache::CachedData cachedData = {bc.c_str(), bc.size()}; bcSet.push_back(cachedData); +#endif // !defined(USE_COMGR_LIBRARY) } else { buildLog += "Error: unsupported bitcode type for checking cache.\n"; checkCache = false; @@ -564,7 +566,7 @@ bool CacheCompilation::compileAndLinkExecutable(amd::opencl_driver::Compiler* C, return true; } -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) } // namespace amd diff --git a/rocclr/runtime/device/device.hpp b/rocclr/runtime/device/device.hpp index 51e4418753..bc0a41a3db 100644 --- a/rocclr/runtime/device/device.hpp +++ b/rocclr/runtime/device/device.hpp @@ -19,10 +19,10 @@ #include "devkernel.hpp" #include "amdocl/cl_profile_amd.h" -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #include "caching/cache.hpp" #include "driver/AmdCompiler.h" -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #include "acl.h" #include "hwdebug.hpp" @@ -1308,7 +1308,7 @@ class Device : public RuntimeObject { // P2P devices that are accessible from the current device std::vector p2pDevices_; -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) amd::CacheCompilation* cacheCompilation() const { return cacheCompilation_.get(); } #endif @@ -1322,7 +1322,7 @@ class Device : public RuntimeObject { BlitProgram* blitProgram_; //!< Blit program info static AppProfile appProfile_; //!< application profile HwDebugManager* hwDebugMgr_; //!< Hardware Debug manager -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) //! Compilation with cache support std::unique_ptr cacheCompilation_; #endif @@ -1340,7 +1340,7 @@ class Device : public RuntimeObject { std::map* vaCacheMap_; //!< VA cache map }; -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) //! Compilation process with cache support. class CacheCompilation : public amd::HeapObject { public: @@ -1377,7 +1377,7 @@ class CacheCompilation : public amd::HeapObject { StringCache codeCache_; //! Cached codes const bool isCodeCacheEnabled_; //! Code cache enable }; -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) /*! @} * @} diff --git a/rocclr/runtime/device/devkernel.cpp b/rocclr/runtime/device/devkernel.cpp index 638dfa6c3b..4d7d161c28 100644 --- a/rocclr/runtime/device/devkernel.cpp +++ b/rocclr/runtime/device/devkernel.cpp @@ -16,7 +16,7 @@ #include "acl.h" -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #include "llvm/Support/AMDGPUMetadata.h" typedef llvm::AMDGPU::HSAMD::Kernel::Arg::Metadata KernelArgMD; @@ -25,7 +25,7 @@ using llvm::AMDGPU::HSAMD::AccessQualifier; using llvm::AMDGPU::HSAMD::AddressSpaceQualifier; using llvm::AMDGPU::HSAMD::ValueKind; using llvm::AMDGPU::HSAMD::ValueType; -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) namespace device { @@ -228,7 +228,7 @@ void Kernel::FindLocalWorkSize(size_t workDim, const amd::NDRange& gblWorkSize, } } // ================================================================================================ -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) static inline uint32_t GetOclArgumentTypeOCL(const KernelArgMD& lcArg, bool* isHidden) { switch (lcArg.mValueKind) { case ValueKind::GlobalBuffer: @@ -324,7 +324,7 @@ static const clk_value_type_t ClkValueMapType[6][6] = { }; // ================================================================================================ -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) static inline clk_value_type_t GetOclTypeOCL(const KernelArgMD& lcArg, size_t size = 0) { uint sizeType; uint numElements; @@ -481,7 +481,7 @@ static inline clk_value_type_t GetOclTypeOCL(const aclArgData* argInfo, size_t s #endif // ================================================================================================ -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) static inline size_t GetArgAlignmentOCL(const KernelArgMD& lcArg) { return lcArg.mAlign; } #endif @@ -525,7 +525,7 @@ static inline size_t GetArgAlignmentOCL(const aclArgData* argInfo) { #endif // ================================================================================================ -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) static inline size_t GetArgPointeeAlignmentOCL(const KernelArgMD& lcArg) { if (lcArg.mValueKind == ValueKind::DynamicSharedPointer) { uint32_t align = lcArg.mPointeeAlign; @@ -550,7 +550,7 @@ static inline size_t GetArgPointeeAlignmentOCL(const aclArgData* argInfo) { #endif // ================================================================================================ -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) static inline bool GetReadOnlyOCL(const KernelArgMD& lcArg) { if ((lcArg.mValueKind == ValueKind::GlobalBuffer) || (lcArg.mValueKind == ValueKind::Image)) { switch (lcArg.mAccQual) { @@ -580,7 +580,7 @@ static inline bool GetReadOnlyOCL(const aclArgData* argInfo) { #endif // ================================================================================================ -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) static inline int GetArgSizeOCL(const KernelArgMD& lcArg) { return lcArg.mSize; } #endif @@ -623,7 +623,7 @@ inline static int GetArgSizeOCL(const aclArgData* argInfo) { #endif // ================================================================================================ -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) static inline cl_kernel_arg_address_qualifier GetOclAddrQualOCL(const KernelArgMD& lcArg) { if (lcArg.mValueKind == ValueKind::DynamicSharedPointer) { return CL_KERNEL_ARG_ADDRESS_LOCAL; @@ -679,7 +679,7 @@ static inline cl_kernel_arg_address_qualifier GetOclAddrQualOCL(const aclArgData #endif // ================================================================================================ -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) static inline cl_kernel_arg_access_qualifier GetOclAccessQualOCL(const KernelArgMD& lcArg) { if (lcArg.mValueKind == ValueKind::Image) { switch (lcArg.mAccQual) { @@ -714,7 +714,7 @@ static inline cl_kernel_arg_access_qualifier GetOclAccessQualOCL(const aclArgDat #endif // ================================================================================================ -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) static inline cl_kernel_arg_type_qualifier GetOclTypeQualOCL(const KernelArgMD& lcArg) { cl_kernel_arg_type_qualifier rv = CL_KERNEL_ARG_TYPE_NONE; if (lcArg.mValueKind == ValueKind::GlobalBuffer || @@ -769,7 +769,7 @@ static inline cl_kernel_arg_type_qualifier GetOclTypeQualOCL(const aclArgData* a #endif // ================================================================================================ -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #if defined(USE_COMGR_LIBRARY) bool Kernel::GetAttrCodePropMetadata(const amd_comgr_metadata_node_t programMD, const uint32_t kernargSegmentByteSize, @@ -1133,7 +1133,7 @@ void Kernel::InitParameters(const KernelMD& kernelMD, uint32_t argBufferSize) { createSignature(params, numParams, amd::KernelSignature::ABIVersion_1); } #endif // defined(USE_COMGR_LIBRARY) -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) // ================================================================================================ #if defined(WITH_COMPILER_LIB) @@ -1217,7 +1217,7 @@ void Kernel::InitParameters(const aclArgData* aclArg, uint32_t argBufferSize) { #endif // ================================================================================================ -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) void Kernel::InitPrintf(const std::vector& printfInfoStrings) { for (auto str : printfInfoStrings) { std::vector tokens; @@ -1307,7 +1307,7 @@ void Kernel::InitPrintf(const std::vector& printfInfoStrings) { // ] } } -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) // ================================================================================================ #if defined(WITH_COMPILER_LIB) diff --git a/rocclr/runtime/device/devkernel.hpp b/rocclr/runtime/device/devkernel.hpp index 3e13441afe..ca0d135fd5 100644 --- a/rocclr/runtime/device/devkernel.hpp +++ b/rocclr/runtime/device/devkernel.hpp @@ -9,7 +9,7 @@ #include "platform/memory.hpp" #include "devwavelimiter.hpp" -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) namespace llvm { namespace AMDGPU { namespace HSAMD { @@ -168,7 +168,7 @@ static const std::map CodePropFieldMap = {"NumSpilledVGPRs", CodePropField::NumSpilledVGPRs} }; #endif // defined(USE_COMGR_LIBRARY) -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) namespace amd { namespace hsa { @@ -370,7 +370,7 @@ class Kernel : public amd::HeapObject { protected: //! Initializes the abstraction layer kernel parameters -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #if defined(USE_COMGR_LIBRARY) void InitParameters(const amd_comgr_metadata_node_t kernelMD, uint32_t argBufferSize); diff --git a/rocclr/runtime/device/devprogram.cpp b/rocclr/runtime/device/devprogram.cpp index d13fd0e859..fb029074b8 100644 --- a/rocclr/runtime/device/devprogram.cpp +++ b/rocclr/runtime/device/devprogram.cpp @@ -11,12 +11,12 @@ #include "utils/bif_section_labels.hpp" #include "utils/libUtils.h" -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #include "driver/AmdCompiler.h" #include "libraries.amdgcn.inc" #include "opencl1.2-c.amdgcn.inc" #include "opencl2.0-c.amdgcn.inc" -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #include #include @@ -34,11 +34,11 @@ #include "spirv/spirvUtils.h" #include "acl.h" -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #include "llvm/Support/AMDGPUMetadata.h" typedef llvm::AMDGPU::HSAMD::Kernel::Arg::Metadata KernelArgMD; -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) namespace device { @@ -96,7 +96,7 @@ bool Program::compileImpl(const std::string& sourceCode, } // ================================================================================================ -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) static std::string llvmBin_(amd::Os::getEnvironment("LLVM_BIN")); #if defined(ATI_OS_WIN) @@ -173,10 +173,14 @@ std::unique_ptr Program::newCompilerInstance() { } #endif // defined(DEBUG) +#if !defined(USE_COMGR_LIBRARY) return std::unique_ptr( amd::opencl_driver::CompilerFactory().CreateAMDGPUCompiler(llvmBin_)); +#else + return nullptr; +#endif // !defined(USE_COMGR_LIBRARY) } -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) // ================================================================================================ @@ -606,7 +610,7 @@ bool Program::compileImplLC(const std::string& sourceCode, bool Program::compileImplLC(const std::string& sourceCode, const std::vector& headers, const char** headerIncludeNames, amd::option::Options* options) { -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) const char* xLang = options->oVariables->XLang; if (xLang != nullptr) { if (strcmp(xLang, "asm") == 0) { @@ -798,7 +802,7 @@ bool Program::compileImplLC(const std::string& sourceCode, // store the original compile options clBinary()->storeCompileOptions(compileOptions_); } -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) return true; } #endif // defined(USE_COMGR_LIBRARY) @@ -1025,7 +1029,7 @@ bool Program::linkImplLC(const std::vector& inputPrograms, #else // not using COMgr bool Program::linkImplLC(const std::vector& inputPrograms, amd::option::Options* options, bool createLibrary) { -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) using namespace amd::opencl_driver; std::unique_ptr C(newCompilerInstance()); @@ -1114,7 +1118,7 @@ bool Program::linkImplLC(const std::vector& inputPrograms, return linkImpl(options); #else return false; -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) } #endif // defined(USE_COMGR_LIBRARY) @@ -1365,7 +1369,7 @@ bool Program::linkImplLC(amd::option::Options* options) { } #else // not using COMgr bool Program::linkImplLC(amd::option::Options* options) { -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) using namespace amd::opencl_driver; internal_ = (compileOptions_.find("-cl-internal-kernel") != std::string::npos) ? true : false; @@ -1597,7 +1601,7 @@ bool Program::linkImplLC(amd::option::Options* options) { return true; #else return false; -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) } #endif // defined(USE_COMGR_LIBRARY) @@ -2051,36 +2055,34 @@ cl_int Program::build(const std::string& sourceCode, const char* origOptions, std::string Program::ProcessOptions(amd::option::Options* options) { std::string optionsStr; -#ifndef WITH_LIGHTNING_COMPILER - optionsStr.append(" -D__AMD__=1"); + if (!isLC()) { + optionsStr.append(" -D__AMD__=1"); - optionsStr.append(" -D__").append(machineTarget_).append("__=1"); - optionsStr.append(" -D__").append(machineTarget_).append("=1"); -#endif + optionsStr.append(" -D__").append(machineTarget_).append("__=1"); + optionsStr.append(" -D__").append(machineTarget_).append("=1"); + } else { + int major, minor; + ::sscanf(device().info().version_, "OpenCL %d.%d ", &major, &minor); -#ifdef WITH_LIGHTNING_COMPILER - int major, minor; - ::sscanf(device().info().version_, "OpenCL %d.%d ", &major, &minor); - - std::stringstream ss; - ss << " -D__OPENCL_VERSION__=" << (major * 100 + minor * 10); - optionsStr.append(ss.str()); -#endif + std::stringstream ss; + ss << " -D__OPENCL_VERSION__=" << (major * 100 + minor * 10); + optionsStr.append(ss.str()); + } if (device().info().imageSupport_ && options->oVariables->ImageSupport) { optionsStr.append(" -D__IMAGE_SUPPORT__=1"); } -#ifndef WITH_LIGHTNING_COMPILER - // Set options for the standard device specific options - // All our devices support these options now - if (device().settings().reportFMAF_) { - optionsStr.append(" -DFP_FAST_FMAF=1"); + if (!isLC()) { + // Set options for the standard device specific options + // All our devices support these options now + if (device().settings().reportFMAF_) { + optionsStr.append(" -DFP_FAST_FMAF=1"); + } + if (device().settings().reportFMA_) { + optionsStr.append(" -DFP_FAST_FMA=1"); + } } - if (device().settings().reportFMA_) { - optionsStr.append(" -DFP_FAST_FMA=1"); - } -#endif uint clcStd = (options->oVariables->CLStd[2] - '0') * 100 + (options->oVariables->CLStd[4] - '0') * 10; @@ -2107,7 +2109,7 @@ std::string Program::ProcessOptions(amd::option::Options* options) { std::istream_iterator sit(istrstr), end; std::vector extensions(sit, end); - if (IS_LIGHTNING && !options->oVariables->Legacy) { + if (isLC()) { // FIXME_lmoriche: opencl-c.h defines 'cl_khr_depth_images', so // remove it from the command line. Should we fix opencl-c.h? auto found = std::find(extensions.begin(), extensions.end(), "cl_khr_depth_images"); @@ -2356,7 +2358,7 @@ aclType Program::getCompilationStagesFromBinary(std::vector& completeSt bool& needOptionsCheck) { aclType from = ACL_TYPE_DEFAULT; if (isLC()) { -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) completeStages.clear(); needOptionsCheck = true; //! @todo Should we also check for ACL_TYPE_OPENCL & ACL_TYPE_LLVMIR_TEXT? @@ -2394,7 +2396,7 @@ aclType Program::getCompilationStagesFromBinary(std::vector& completeSt default: break; } -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) } else { #if defined(WITH_COMPILER_LIB) acl_error errorCode; @@ -2638,7 +2640,7 @@ aclType Program::getNextCompilationStageFromBinary(amd::option::Options* options // ================================================================================================ bool Program::FindGlobalVarSize(void* binary, size_t binSize) { -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) size_t progvarsTotalSize = 0; size_t dynamicSize = 0; size_t progvarsWriteSize = 0; @@ -2745,7 +2747,7 @@ bool Program::FindGlobalVarSize(void* binary, size_t binSize) { if (progvarsWriteSize != dynamicSize) { hasGlobalStores_ = true; } -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) return true; } } diff --git a/rocclr/runtime/device/devprogram.hpp b/rocclr/runtime/device/devprogram.hpp index 39559c233b..41a19e1183 100644 --- a/rocclr/runtime/device/devprogram.hpp +++ b/rocclr/runtime/device/devprogram.hpp @@ -12,7 +12,7 @@ #include "amd_comgr.h" #endif -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #include "driver/AmdCompiler.h" //#include "llvm/Support/AMDGPUMetadata.h" @@ -28,7 +28,7 @@ namespace llvm { typedef llvm::AMDGPU::HSAMD::Metadata CodeObjectMD; typedef llvm::AMDGPU::HSAMD::Kernel::Metadata KernelMD; //typedef llvm::AMDGPU::HSAMD::Kernel::Arg::Metadata KernelArgMD; -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #ifndef LC_METADATA typedef char CodeObjectMD; @@ -264,10 +264,10 @@ class Program : public amd::HeapObject { void setType(type_t newType) { type_ = newType; } -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) //! Return a new transient compiler instance. static std::unique_ptr newCompilerInstance(); -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) /* \brief Returns the next stage to compile from, based on sections in binary, * also returns completeStages in a vector, which contains at least ACL_TYPE_DEFAULT, diff --git a/rocclr/runtime/device/gpu/gpuresource.cpp b/rocclr/runtime/device/gpu/gpuresource.cpp index e8b7a9d283..84b2f21630 100644 --- a/rocclr/runtime/device/gpu/gpuresource.cpp +++ b/rocclr/runtime/device/gpu/gpuresource.cpp @@ -1,5 +1,6 @@ // Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. // +#include "device/device.hpp" #if defined(ATI_OS_WIN) #define WIN32_LEAN_AND_MEAN 1 @@ -8,10 +9,7 @@ #include #include "GL/glATIInternal.h" -#include "platform/program.hpp" -#include "platform/kernel.hpp" #include "os/os.hpp" -#include "device/device.hpp" #include "utils/flags.hpp" #include "thread/monitor.hpp" #include "device/gpu/gpuresource.hpp" diff --git a/rocclr/runtime/device/pal/paldevice.cpp b/rocclr/runtime/device/pal/paldevice.cpp index b73a397fba..7083e459a8 100644 --- a/rocclr/runtime/device/pal/paldevice.cpp +++ b/rocclr/runtime/device/pal/paldevice.cpp @@ -116,7 +116,7 @@ bool NullDevice::init() { id < sizeof(Gfx9PlusSubDeviceInfo)/sizeof(AMDDeviceInfo); ++id) { bool foundActive = false; bool foundDuplicate = false; - uint gfxipVersion = IS_LIGHTNING ? pal::Gfx9PlusSubDeviceInfo[id].gfxipVersionLC_ : + uint gfxipVersion = GPU_ENABLE_LC ? pal::Gfx9PlusSubDeviceInfo[id].gfxipVersionLC_ : pal::Gfx9PlusSubDeviceInfo[id].gfxipVersion_; if (pal::Gfx9PlusSubDeviceInfo[id].targetName_[0] == '\0') { @@ -127,7 +127,7 @@ bool NullDevice::init() { for (uint i = 0; i < devices.size(); ++i) { driverVersion = static_cast(devices[i])->info().driverVersion_; if (driverVersion.find("PAL") != std::string::npos) { - uint gfxIpCurrent = IS_LIGHTNING ? + uint gfxIpCurrent = GPU_ENABLE_LC ? static_cast(devices[i])->hwInfo()->gfxipVersionLC_ : static_cast(devices[i])->hwInfo()->gfxipVersion_; if (gfxIpCurrent == gfxipVersion) { @@ -272,7 +272,7 @@ bool NullDevice::create(Pal::AsicRevision asicRevision, Pal::GfxIpLevel ipLevel, info_.wavefrontWidth_ = (ipLevel >= Pal::GfxIpLevel::GfxIp10) ? 32 : 64; if (settings().useLightning_) { -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) // create compilation object with cache support int gfxipMajor = hwInfo_->gfxipVersionLC_ / 100; int gfxipMinor = hwInfo_->gfxipVersionLC_ / 10 % 10; @@ -516,7 +516,7 @@ void NullDevice::fillDeviceInfo(const Pal::DeviceProperties& palProp, const static char* bristol = "Bristol Ridge"; ::strcpy(info_.name_, bristol); } else { - if (IS_LIGHTNING && hwInfo()->xnackEnabled_) { + if (GPU_ENABLE_LC && hwInfo()->xnackEnabled_) { ::snprintf(info_.name_, sizeof(info_.name_) - 1, "%s-xnack", hwInfo()->targetName_); } else { ::strcpy(info_.name_, hwInfo()->targetName_); @@ -610,7 +610,7 @@ void NullDevice::fillDeviceInfo(const Pal::DeviceProperties& palProp, info_.globalMemChannelBankWidth_ = hwInfo()->memChannelBankWidth_; info_.localMemSizePerCU_ = hwInfo()->localMemSizePerCU_; info_.localMemBanks_ = hwInfo()->localMemBanks_; - info_.gfxipVersion_ = IS_LIGHTNING ? hwInfo()->gfxipVersionLC_ : hwInfo()->gfxipVersion_; + info_.gfxipVersion_ = GPU_ENABLE_LC ? hwInfo()->gfxipVersionLC_ : hwInfo()->gfxipVersion_; info_.timeStampFrequency_ = 1000000; info_.numAsyncQueues_ = numComputeRings; @@ -936,7 +936,7 @@ bool Device::create(Pal::IDevice* device) { } if (settings().useLightning_) { -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) // create compilation object with cache support int gfxipMajor = hwInfo()->gfxipVersionLC_ / 100; int gfxipMinor = hwInfo()->gfxipVersionLC_ / 10 % 10; diff --git a/rocclr/runtime/device/pal/palkernel.cpp b/rocclr/runtime/device/pal/palkernel.cpp index 3d4643621e..d0749c55f3 100644 --- a/rocclr/runtime/device/pal/palkernel.cpp +++ b/rocclr/runtime/device/pal/palkernel.cpp @@ -10,11 +10,11 @@ #include "utils/options.hpp" #include "acl.h" -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #include "llvm/Support/AMDGPUMetadata.h" typedef llvm::AMDGPU::HSAMD::Kernel::Metadata KernelMD; -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #include #include @@ -377,7 +377,7 @@ const LightningProgram& LightningKernel::prog() const { return reinterpret_cast(prog_); } -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) static const KernelMD* FindKernelMetadata(const CodeObjectMD* programMD, const std::string& name) { for (const KernelMD& kernelMD : programMD->mKernels) { if (kernelMD.mName == name) { @@ -386,10 +386,10 @@ static const KernelMD* FindKernelMetadata(const CodeObjectMD* programMD, const s } return nullptr; } -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) bool LightningKernel::init(amd::hsa::loader::Symbol* symbol) { -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) flags_.internalKernel_ = (compileOptions_.find("-cl-internal-kernel") != std::string::npos) ? true : false; @@ -519,7 +519,7 @@ bool LightningKernel::init(amd::hsa::loader::Symbol* symbol) { waveLimiter_.enable(); */ #endif // defined(USE_COMGR_LIBRARY) -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) return true; } diff --git a/rocclr/runtime/device/pal/palprogram.cpp b/rocclr/runtime/device/pal/palprogram.cpp index 7183080e68..790678fc6c 100644 --- a/rocclr/runtime/device/pal/palprogram.cpp +++ b/rocclr/runtime/device/pal/palprogram.cpp @@ -19,12 +19,12 @@ #include "hsa.h" #include "hsa_ext_image.h" #include "amd_hsa_loader.hpp" -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #include "llvm/Support/AMDGPUMetadata.h" #include "driver/AmdCompiler.h" #include "libraries.amdgcn.inc" #include "gelf.h" -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) namespace pal { @@ -375,7 +375,7 @@ hsa_isa_t PALHSALoaderContext::IsaFromName(const char* name) { } bool PALHSALoaderContext::IsaSupportedByAgent(hsa_agent_t agent, hsa_isa_t isa) { - uint32_t gfxipVersion = IS_LIGHTNING ? + uint32_t gfxipVersion = GPU_ENABLE_LC ? program_->dev().hwInfo()->gfxipVersionLC_ : program_->dev().hwInfo()->gfxipVersion_; uint32_t majorSrc = gfxipVersion / 10; @@ -546,7 +546,7 @@ hsa_status_t PALHSALoaderContext::SamplerDestroy(hsa_agent_t agent, return HSA_STATUS_SUCCESS; } -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) static hsa_status_t GetKernelNamesCallback(hsa_executable_t hExec, hsa_executable_symbol_t hSymbol, void* data) { @@ -575,20 +575,20 @@ static hsa_status_t GetKernelNamesCallback(hsa_executable_t hExec, hsa_executabl return HSA_STATUS_SUCCESS; } -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) bool LightningProgram::createBinary(amd::option::Options* options) { -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) if (!clBinary()->createElfBinary(options->oVariables->BinEncrypt, type())) { LogError("Failed to create ELF binary image!"); return false; } -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) return true; } bool LightningProgram::setKernels(amd::option::Options* options, void* binary, size_t binSize) { -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) hsa_agent_t agent; agent.handle = 1; @@ -654,7 +654,7 @@ bool LightningProgram::setKernels(amd::option::Options* options, void* binary, s } DestroySegmentCpuAccess(); -#endif // defined(WITH_LIGHTNING_COMPILER) +#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) return true; } diff --git a/rocclr/runtime/device/pal/palsettings.cpp b/rocclr/runtime/device/pal/palsettings.cpp index 9e8d59c2a6..0f0714385d 100644 --- a/rocclr/runtime/device/pal/palsettings.cpp +++ b/rocclr/runtime/device/pal/palsettings.cpp @@ -439,7 +439,7 @@ bool Settings::create(const Pal::DeviceProperties& palProp, #endif } -#if defined(WITH_LIGHTNING_COMPILER) +#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) switch (palProp.gfxLevel) { case Pal::GfxIpLevel::GfxIp10_1: case Pal::GfxIpLevel::GfxIp10: diff --git a/rocclr/runtime/platform/program.cpp b/rocclr/runtime/platform/program.cpp index 1ed90954aa..b0cb416f2b 100644 --- a/rocclr/runtime/platform/program.cpp +++ b/rocclr/runtime/platform/program.cpp @@ -118,7 +118,7 @@ cl_int Program::addDeviceProgram(Device& device, const void* image, size_t lengt return CL_INVALID_COMPILER_OPTIONS; } } - options->oVariables->Legacy = !IS_LIGHTNING ? + options->oVariables->Legacy = !GPU_ENABLE_LC ? isAMDILTarget(*aclutGetTargetInfo(binary)) : isHSAILTarget(*aclutGetTargetInfo(binary)); aclBinaryFini(binary);