P4 to Git Change 1481396 by lmoriche@lmoriche_opencl_dev2 on 2017/11/10 16:12:29

SWDEV-118564 - [OCL-LC-ROCm] Refactor the Lightning Compiler program manager to allow the compiler library API and the ROCm-OpenCL-Driver to coexist in the same platform.
	- Default compiler is the Lightning Compiler
	- Fall back to the HSAIL compiler if the amdoclcl compiler library is in the PATH and the -legacy option is specified (or app-detect)

Affected files ...

... //depot/stg/opencl/drivers/opencl/Makefile#59 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/build/Makefile.api#168 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/api/v0_8/acl.cpp#44 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/api/v0_8/aclLoaders.cpp#14 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/api/v0_8/aclValidation.cpp#7 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/build/Makefile.complib#98 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/loaders/elf/elf.hpp#26 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/OPTIONS.def#137 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/build/Makefile.utils#19 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/cpu/cpuprogram.cpp#71 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#213 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#292 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#235 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.cpp#49 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/build/Makefile.oclrocm#20 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompiler.cpp#38 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompilerlib.cpp#8 delete
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompilerlib.hpp#6 delete
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#75 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.cpp#30 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.hpp#17 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#75 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.hpp#30 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/program.cpp#88 edit
Tento commit je obsažen v:
foreman
2017-11-10 16:21:49 -05:00
rodič d779c69dfa
revize 88ba77a1b4
16 změnil soubory, kde provedl 1010 přidání a 1134 odebrání
+19 -25
Zobrazit soubor
@@ -9,6 +9,7 @@
#include "os/os.hpp"
#include "utils/debug.hpp"
#include "utils/flags.hpp"
#include "utils/options.hpp"
#include "utils/versions.hpp"
#include "thread/monitor.hpp"
#include "CL/cl_ext.h"
@@ -20,9 +21,7 @@
#include "device/rocm/rocprogram.hpp"
#if defined(WITH_LIGHTNING_COMPILER)
#include "driver/AmdCompiler.h"
#else // !defined(WITH_LIGHTNING_COMPILER)
#include "device/rocm/roccompilerlib.hpp"
#endif // !defined(WITH_LIGHTNING_COMPILER)
#endif // defined(WITH_LIGHTNING_COMPILER)
#include "device/rocm/rocmemory.hpp"
#include "device/rocm/rocglinterop.hpp"
#ifdef WITH_AMDGPU_PRO
@@ -191,46 +190,34 @@ Device::~Device() {
}
}
bool NullDevice::initCompiler(bool isOffline) {
#if !defined(WITH_LIGHTNING_COMPILER)
// Initializes g_complibModule and g_complibApi if they were not initialized
if (g_complibModule == nullptr) {
if (!LoadCompLib(isOffline)) {
if (!isOffline) {
LogError("Error - could not find the compiler library");
}
return false;
}
}
// Initialize the compiler handle if has already not been initialized
// This is destroyed in Device::teardown
acl_error error;
if (!compilerHandle_) {
compilerHandle_ = g_complibApi._aclCompilerInit(nullptr, &error);
aclCompilerOptions opts = {
sizeof(aclCompilerOptions_0_8),
IF(IS_LIGHTNING, "libamdoclcl64.so", NULL),
NULL, NULL, NULL, NULL, NULL, NULL
};
compilerHandle_ = aclCompilerInit(&opts, &error);
if (error != ACL_SUCCESS) {
#if !defined(WITH_LIGHTNING_COMPILER)
LogError("Error initializing the compiler handle");
return false;
#endif // !defined(WITH_LIGHTNING_COMPILER)
}
}
#endif // !defined(WITH_LIGHTNING_COMPILER)
return true;
}
bool NullDevice::destroyCompiler() {
#if defined(WITH_LIGHTNING_COMPILER)
delete compilerHandle_;
compilerHandle_ = nullptr;
#else // !defined(WITH_LIGHTNING_COMPILER)
if (compilerHandle_ != nullptr) {
acl_error error = g_complibApi._aclCompilerFini(compilerHandle_);
acl_error error = aclCompilerFini(compilerHandle_);
if (error != ACL_SUCCESS) {
LogError("Error closing the compiler");
return false;
}
}
if (g_complibModule != nullptr) {
UnloadCompLib();
}
#endif // !defined(WITH_LIGHTNING_COMPILER)
return true;
}
@@ -682,6 +669,11 @@ device::Program* NullDevice::createProgram(amd::option::Options* options) {
}
device::Program* Device::createProgram(amd::option::Options* options) {
#if defined(WITH_LIGHTNING_COMPILER)
if (!compilerHandle_ || !options->oVariables->Legacy) {
return new roc::LightningProgram(*this);
}
#endif // defined(WITH_LIGHTNING_COMPILER)
return new roc::HSAILProgram(*this);
}
@@ -965,7 +957,9 @@ bool Device::populateOCLDeviceConstants() {
return false;
}
std::stringstream ss;
ss << AMD_BUILD_STRING " (HSA" << major << "." << minor << "," IF(IS_LIGHTNING, "LC", "HSAIL") ")";
ss << AMD_BUILD_STRING " (HSA" << major << "." << minor << "," IF(IS_LIGHTNING, "LC", "HSAIL");
if (IS_LIGHTNING && compilerHandle_) ss << "*,HSAIL";
ss << ")";
strcpy(info_.driverVersion_, ss.str().c_str());
info_.version_ = "OpenCL " /*OPENCL_VERSION_STR*/"1.2" " ";