P4 to Git Change 1753035 by wchau@wchau_OCL_Linux on 2019/03/07 15:02:39

SWDEV-182054 - Allow building OpenCL-Runtime with COMGR enabled without OpenCL-Driver being present

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/hip/build/Makefile.hip#12 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/build/Makefile.api#184 edit
... //depot/stg/opencl/drivers/opencl/compiler/Makefile#71 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#242 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#335 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.cpp#30 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.hpp#18 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#126 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.cpp#87 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#120 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.cpp#51 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#100 edit
This commit is contained in:
foreman
2019-03-07 15:48:33 -05:00
والد 2df067619f
کامیت e51a27e182
9فایلهای تغییر یافته به همراه32 افزوده شده و 23 حذف شده
@@ -148,7 +148,7 @@ bool Device::init() {
// GPU stack. The order of initialization is signiicant and if changed
// amd::Device::registerDevice() must be accordingly modified.
#if defined(WITH_HSA_DEVICE)
// @todo remove IS_LIGHTNING check when PAL-LC builds will be deprecated
// @todo remove IS_LIGHTNING check when PAL-LC builds will be deprecated
if ((GPU_ENABLE_PAL != 1) || IS_LIGHTNING) {
// Return value of roc::Device::init()
// If returned false, error initializing HSA stack.
@@ -229,6 +229,7 @@ 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();
@@ -413,7 +414,7 @@ char* Device::getExtensionString() {
return result;
}
#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#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),
@@ -498,13 +499,11 @@ 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<FileReference*>(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;
@@ -582,7 +581,7 @@ bool CacheCompilation::compileAndLinkExecutable(amd::opencl_driver::Compiler* C,
return true;
}
#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#endif // defined(WITH_LIGHTNING_COMPILER) && ! defined(USE_COMGR_LIBRARY)
} // namespace amd
@@ -19,10 +19,10 @@
#include "devkernel.hpp"
#include "amdocl/cl_profile_amd.h"
#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#if defined(WITH_LIGHTNING_COMPILER) && ! defined(USE_COMGR_LIBRARY)
#include "caching/cache.hpp"
#include "driver/AmdCompiler.h"
#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#endif // defined(WITH_LIGHTNING_COMPILER) && ! defined(USE_COMGR_LIBRARY)
#include "acl.h"
#include "hwdebug.hpp"
@@ -69,7 +69,9 @@ class SvmUnmapMemoryCommand;
class TransferBufferFileCommand;
class HwDebugManager;
class Device;
#ifndef USE_COMGR_LIBRARY
class CacheCompilation;
#endif
struct KernelParameterDescriptor;
struct Coord3D;
@@ -1328,7 +1330,7 @@ class Device : public RuntimeObject {
// P2P devices that are accessible from the current device
std::vector<cl_device_id> p2pDevices_;
#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#if defined(WITH_LIGHTNING_COMPILER) && ! defined(USE_COMGR_LIBRARY)
amd::CacheCompilation* cacheCompilation() const { return cacheCompilation_.get(); }
#endif
@@ -1354,7 +1356,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) || defined(USE_COMGR_LIBRARY)
#if defined(WITH_LIGHTNING_COMPILER) && ! defined(USE_COMGR_LIBRARY)
//! Compilation with cache support
std::unique_ptr<amd::CacheCompilation> cacheCompilation_;
#endif
@@ -1372,7 +1374,7 @@ class Device : public RuntimeObject {
std::map<uintptr_t, device::Memory*>* vaCacheMap_; //!< VA cache map
};
#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#if defined(WITH_LIGHTNING_COMPILER) && ! defined(USE_COMGR_LIBRARY)
//! Compilation process with cache support.
class CacheCompilation : public amd::HeapObject {
public:
@@ -12,7 +12,9 @@
#include "utils/libUtils.h"
#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#ifndef USE_COMGR_LIBRARY
#include "driver/AmdCompiler.h"
#endif
#include "libraries.amdgcn.inc"
#include "opencl1.2-c.amdgcn.inc"
#include "opencl2.0-c.amdgcn.inc"
@@ -161,6 +163,7 @@ static void checkLLVM_BIN() {
}
#endif // defined(ATI_OS_LINUX)
#if !defined(USE_COMGR_LIBRARY)
std::unique_ptr<amd::opencl_driver::Compiler> Program::newCompilerInstance() {
#if defined(ATI_OS_WIN)
static INIT_ONCE initOnce;
@@ -178,13 +181,10 @@ std::unique_ptr<amd::opencl_driver::Compiler> Program::newCompilerInstance() {
}
#endif // defined(DEBUG)
#if !defined(USE_COMGR_LIBRARY)
return std::unique_ptr<amd::opencl_driver::Compiler>(
amd::opencl_driver::CompilerFactory().CreateAMDGPUCompiler(llvmBin_));
#else
return std::unique_ptr<amd::opencl_driver::Compiler>(nullptr);
#endif // !defined(USE_COMGR_LIBRARY)
}
#endif // !defined(USE_COMGR_LIBRARY)
#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
// ================================================================================================
@@ -1082,8 +1082,6 @@ bool Program::linkImpl(const std::vector<device::Program*>& inputPrograms,
#if defined(USE_COMGR_LIBRARY)
bool Program::linkImplLC(const std::vector<Program*>& inputPrograms,
amd::option::Options* options, bool createLibrary) {
using namespace amd::opencl_driver;
std::unique_ptr<Compiler> C(newCompilerInstance());
amd_comgr_data_set_t inputs;
@@ -11,7 +11,9 @@
#include "comgrctx.hpp"
#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#ifndef USE_COMGR_LIBRARY
#include "driver/AmdCompiler.h"
#endif
//#include "llvm/Support/AMDGPUMetadata.h"
namespace llvm {
@@ -276,7 +278,7 @@ class Program : public amd::HeapObject {
void setType(type_t newType) { type_ = newType; }
#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#if defined(WITH_LIGHTNING_COMPILER) && !defined(USE_COMGR_LIBRARY)
//! Return a new transient compiler instance.
static std::unique_ptr<amd::opencl_driver::Compiler> newCompilerInstance();
#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
@@ -280,7 +280,7 @@ bool NullDevice::create(Pal::AsicRevision asicRevision, Pal::GfxIpLevel ipLevel,
info_.wavefrontWidth_ = settings().enableWave32Mode_ ? 32 : 64;
if (settings().useLightning_) {
#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#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;
@@ -967,7 +967,7 @@ bool Device::create(Pal::IDevice* device) {
}
if (settings().useLightning_) {
#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#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;
@@ -20,8 +20,10 @@
#include "hsa_ext_image.h"
#include "amd_hsa_loader.hpp"
#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#include "llvm/Support/AMDGPUMetadata.h"
#ifndef USE_COMGR_LIBRARY
#include "driver/AmdCompiler.h"
#endif
#include "llvm/Support/AMDGPUMetadata.h"
#include "libraries.amdgcn.inc"
#include "gelf.h"
#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
@@ -19,9 +19,9 @@
#include "device/rocm/rocblit.hpp"
#include "device/rocm/rocvirtual.hpp"
#include "device/rocm/rocprogram.hpp"
#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#if defined(WITH_LIGHTNING_COMPILER) && ! defined(USE_COMGR_LIBRARY)
#include "driver/AmdCompiler.h"
#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#endif // defined(WITH_LIGHTNING_COMPILER) && ! defined(USE_COMGR_LIBRARY)
#include "device/rocm/rocmemory.hpp"
#include "device/rocm/rocglinterop.hpp"
#ifdef WITH_AMDGPU_PRO
@@ -652,6 +652,7 @@ bool Device::create(bool sramEccEnabled) {
if (settings().useLightning_) {
scheduler = sch.c_str();
}
#ifndef USE_COMGR_LIBRARY
// create compilation object with cache support
int gfxipMajor = deviceInfo_.gfxipVersion_ / 100;
int gfxipMinor = deviceInfo_.gfxipVersion_ / 10 % 10;
@@ -676,6 +677,7 @@ bool Device::create(bool sramEccEnabled) {
}
cacheCompilation_.reset(compObj);
#endif // USE_COMGR_LIBRARY
#endif
amd::Context::Info info = {0};
@@ -10,7 +10,9 @@
#ifndef WITHOUT_HSA_BACKEND
#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#ifndef USE_COMGR_LIBRARY
#include "driver/AmdCompiler.h"
#endif
#include "llvm/Support/AMDGPUMetadata.h"
typedef llvm::AMDGPU::HSAMD::Metadata CodeObjectMD;
@@ -9,8 +9,10 @@
#include "rockernel.hpp"
#if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#include <gelf.h>
#include "driver/AmdCompiler.h"
#include "libraries.amdgcn.inc"
#ifndef USE_COMGR_LIBRARY
#include "driver/AmdCompiler.h"
#endif
#endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)
#include "utils/bif_section_labels.hpp"