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
이 커밋은 다음에 포함됨:
foreman
2017-11-10 16:21:49 -05:00
부모 d779c69dfa
커밋 88ba77a1b4
16개의 변경된 파일1010개의 추가작업 그리고 1134개의 파일을 삭제
+16 -21
파일 보기
@@ -498,7 +498,7 @@ static inline cl_kernel_arg_type_qualifier GetOclTypeQual(const aclArgData* argI
return rv;
}
void Kernel::initArguments(const aclArgData* aclArg) {
void HSAILKernel::initArguments(const aclArgData* aclArg) {
device::Kernel::parameters_t params;
// Iterate through the arguments and insert into parameterList
@@ -562,7 +562,7 @@ void Kernel::initArguments(const aclArgData* aclArg) {
}
#if defined(WITH_LIGHTNING_COMPILER)
void Kernel::initArguments_LC(const KernelMD& kernelMD) {
void LightningKernel::initArguments(const KernelMD& kernelMD) {
device::Kernel::parameters_t params;
size_t offset = 0;
@@ -632,7 +632,7 @@ void Kernel::initArguments_LC(const KernelMD& kernelMD) {
}
#endif // defined(WITH_LIGHTNING_COMPILER)
Kernel::Kernel(std::string name, HSAILProgram* prog, const uint64_t& kernelCodeHandle,
Kernel::Kernel(std::string name, Program* prog, const uint64_t& kernelCodeHandle,
const uint32_t workgroupGroupSegmentByteSize,
const uint32_t workitemPrivateSegmentByteSize, const uint32_t kernargSegmentByteSize,
const uint32_t kernargSegmentAlignment)
@@ -645,7 +645,6 @@ Kernel::Kernel(std::string name, HSAILProgram* prog, const uint64_t& kernelCodeH
kernargSegmentAlignment_(kernargSegmentAlignment) {}
#if defined(WITH_LIGHTNING_COMPILER)
static const KernelMD* FindKernelMetadata(const CodeObjectMD* programMD, const std::string& name) {
for (const KernelMD& kernelMD : programMD->mKernels) {
if (kernelMD.mName == name) {
@@ -655,18 +654,18 @@ static const KernelMD* FindKernelMetadata(const CodeObjectMD* programMD, const s
return nullptr;
}
bool Kernel::init_LC() {
bool LightningKernel::init() {
hsa_agent_t hsaDevice = program_->hsaDevice();
// Pull out metadata from the ELF
const CodeObjectMD* programMD = program_->metadata();
const CodeObjectMD* programMD = static_cast<LightningProgram*>(program_)->metadata();
assert(programMD != nullptr);
const KernelMD* kernelMD = FindKernelMetadata(programMD, name());
if (kernelMD == nullptr) {
return false;
}
initArguments_LC(*kernelMD);
initArguments(*kernelMD);
// Set the workgroup information for the kernel
workGroupInfo_.availableLDSSize_ = program_->dev().info().localMemSizePerCU_;
@@ -721,16 +720,13 @@ bool Kernel::init_LC() {
return false;
}
initPrintf_LC(programMD->mPrintf);
initPrintf(programMD->mPrintf);
return true;
}
#endif // defined(WITH_LIGHTNING_COMPILER)
bool Kernel::init() {
#if defined(WITH_LIGHTNING_COMPILER)
return init_LC();
#else // !defined(WITH_LIGHTNING_COMPILER)
bool HSAILKernel::init() {
acl_error errorCode;
// compile kernel down to ISA
hsa_agent_t hsaDevice = program_->hsaDevice();
@@ -738,13 +734,13 @@ bool Kernel::init() {
size_t sizeOfArgList;
aclCompiler* compileHandle = program_->dev().compiler();
std::string openClKernelName("&__OpenCL_" + name() + "_kernel");
errorCode = g_complibApi._aclQueryInfo(compileHandle, program_->binaryElf(), RT_ARGUMENT_ARRAY,
errorCode = aclQueryInfo(compileHandle, program_->binaryElf(), RT_ARGUMENT_ARRAY,
openClKernelName.c_str(), nullptr, &sizeOfArgList);
if (errorCode != ACL_SUCCESS) {
return false;
}
std::unique_ptr<char[]> argList(new char[sizeOfArgList]);
errorCode = g_complibApi._aclQueryInfo(compileHandle, program_->binaryElf(), RT_ARGUMENT_ARRAY,
errorCode = aclQueryInfo(compileHandle, program_->binaryElf(), RT_ARGUMENT_ARRAY,
openClKernelName.c_str(), argList.get(), &sizeOfArgList);
if (errorCode != ACL_SUCCESS) {
return false;
@@ -760,12 +756,12 @@ bool Kernel::init() {
workGroupInfo_.availableSGPRs_ = 104;
workGroupInfo_.availableVGPRs_ = 256;
size_t sizeOfWorkGroupSize;
errorCode = g_complibApi._aclQueryInfo(compileHandle, program_->binaryElf(), RT_WORK_GROUP_SIZE,
errorCode = aclQueryInfo(compileHandle, program_->binaryElf(), RT_WORK_GROUP_SIZE,
openClKernelName.c_str(), nullptr, &sizeOfWorkGroupSize);
if (errorCode != ACL_SUCCESS) {
return false;
}
errorCode = g_complibApi._aclQueryInfo(compileHandle, program_->binaryElf(), RT_WORK_GROUP_SIZE,
errorCode = aclQueryInfo(compileHandle, program_->binaryElf(), RT_WORK_GROUP_SIZE,
openClKernelName.c_str(), workGroupInfo_.compileSize_,
&sizeOfWorkGroupSize);
if (errorCode != ACL_SUCCESS) {
@@ -810,7 +806,7 @@ bool Kernel::init() {
// Pull out printf metadata from the ELF
size_t sizeOfPrintfList;
errorCode = g_complibApi._aclQueryInfo(compileHandle, program_->binaryElf(), RT_GPU_PRINTF_ARRAY,
errorCode = aclQueryInfo(compileHandle, program_->binaryElf(), RT_GPU_PRINTF_ARRAY,
openClKernelName.c_str(), nullptr, &sizeOfPrintfList);
if (errorCode != ACL_SUCCESS) {
return false;
@@ -822,7 +818,7 @@ bool Kernel::init() {
if (!aclPrintfList) {
return false;
}
errorCode = g_complibApi._aclQueryInfo(compileHandle, program_->binaryElf(),
errorCode = aclQueryInfo(compileHandle, program_->binaryElf(),
RT_GPU_PRINTF_ARRAY, openClKernelName.c_str(),
aclPrintfList.get(), &sizeOfPrintfList);
if (errorCode != ACL_SUCCESS) {
@@ -833,11 +829,10 @@ bool Kernel::init() {
initPrintf(reinterpret_cast<aclPrintfFmt*>(aclPrintfList.get()));
}
return true;
#endif // !defined(WITH_LIGHTNING_COMPILER)
}
#if defined(WITH_LIGHTNING_COMPILER)
void Kernel::initPrintf_LC(const std::vector<std::string>& printfInfoStrings) {
void LightningKernel::initPrintf(const std::vector<std::string>& printfInfoStrings) {
for (auto str : printfInfoStrings) {
std::vector<std::string> tokens;
@@ -928,7 +923,7 @@ void Kernel::initPrintf_LC(const std::vector<std::string>& printfInfoStrings) {
}
#endif // defined(WITH_LIGHTNING_COMPILER)
void Kernel::initPrintf(const aclPrintfFmt* aclPrintf) {
void HSAILKernel::initPrintf(const aclPrintfFmt* aclPrintf) {
PrintfInfo info;
uint index = 0;
for (; aclPrintf->struct_size != 0; aclPrintf++) {