SWDEV-280473 - Support HSAIL shared library build

This change makes HSAIL usage similar to that of Comgr. By default, the
runtime will statically link against it, however if HSAIL_DYN_DLL is
defined, then the runtime will try to dynamically load HSAIL.

Currently stick to statically linking to HSAIL. In a feature patch the
dynamic loading behaviour will be enabled.

Change-Id: I6a78a4375975cf847f236b200404c8cf941d012b
Ta zmiana jest zawarta w:
%! (template.HTML=Vladislav Sytchenko)złożyło 2021-04-14 12:25:54 -04:00
1 rodzic 759cf19600
złożenie c7b50bb890
19 plików zmienionych
+662 -214

Żadne pliki nie pasują do Twojego wyszukiwania

+1 -1
Wyświetl plik
@@ -66,7 +66,7 @@ bool ClBinary::loadKernels(NullProgram& program, bool* hasRecompiled) {
if (platform == amd::Elf::COMPLIB_PLATFORM) {
// BIF 3.0
uint32_t flag;
aclTargetInfo tgtInfo = aclGetTargetInfo("amdil", nullptr, NULL);
aclTargetInfo tgtInfo = amd::Hsail::GetTargetInfo("amdil", nullptr, NULL);
if (!elfIn()->getFlags(flag)) {
LogError("The OCL binary image loading failed: incorrect format");
return false;
+22 -22
Wyświetl plik
@@ -123,16 +123,16 @@ bool NullProgram::compileImpl(const std::string& src,
binOpts.alloc = &::malloc;
binOpts.dealloc = &::free;
aclBinary* bin = aclBinaryInit(sizeof(aclBinary), &targInfo, &binOpts, &err);
aclBinary* bin = amd::Hsail::BinaryInit(sizeof(aclBinary), &targInfo, &binOpts, &err);
if (err != ACL_SUCCESS) {
LogWarning("aclBinaryInit failed");
return false;
}
if (ACL_SUCCESS !=
aclInsertSection(gpuNullDevice().amdilCompiler(), bin, sourceCode.c_str(), sourceCode.size(), aclSOURCE)) {
amd::Hsail::InsertSection(gpuNullDevice().amdilCompiler(), bin, sourceCode.c_str(), sourceCode.size(), aclSOURCE)) {
LogWarning("aclInsertSection failed");
aclBinaryFini(bin);
amd::Hsail::BinaryFini(bin);
return false;
}
@@ -206,28 +206,28 @@ bool NullProgram::compileImpl(const std::string& src,
pos = newOpt.find("-fno-bin-llvmir");
}
err = aclCompile(gpuNullDevice().amdilCompiler(), bin, newOpt.c_str(), ACL_TYPE_OPENCL, ACL_TYPE_LLVMIR_BINARY,
NULL);
err = amd::Hsail::Compile(gpuNullDevice().amdilCompiler(), bin, newOpt.c_str(), ACL_TYPE_OPENCL, ACL_TYPE_LLVMIR_BINARY,
NULL);
buildLog_ += aclGetCompilerLog(gpuNullDevice().amdilCompiler());
buildLog_ += amd::Hsail::GetCompilerLog(gpuNullDevice().amdilCompiler());
if (err != ACL_SUCCESS) {
LogWarning("aclCompile failed");
aclBinaryFini(bin);
amd::Hsail::BinaryFini(bin);
return false;
}
size_t len = 0;
const void* ir = aclExtractSection(gpuNullDevice().amdilCompiler(), bin, &len, aclLLVMIR, &err);
const void* ir = amd::Hsail::ExtractSection(gpuNullDevice().amdilCompiler(), bin, &len, aclLLVMIR, &err);
if (err != ACL_SUCCESS) {
LogWarning("aclExtractSection failed");
aclBinaryFini(bin);
amd::Hsail::BinaryFini(bin);
return false;
}
llvmBinary_.assign(reinterpret_cast<const char*>(ir), len);
elfSectionType_ = amd::Elf::LLVMIR;
aclBinaryFini(bin);
amd::Hsail::BinaryFini(bin);
for (size_t i = 0; i < headerFileNames.size(); ++i) {
amd::Os::unlink(headerFileNames[i].c_str());
@@ -263,7 +263,7 @@ int NullProgram::compileBinaryToIL(amd::option::Options* options) {
binOpts.alloc = &::malloc;
binOpts.dealloc = &::free;
aclBinary* bin = aclBinaryInit(sizeof(aclBinary), &targInfo, &binOpts, &err);
aclBinary* bin = amd::Hsail::BinaryInit(sizeof(aclBinary), &targInfo, &binOpts, &err);
if (err != ACL_SUCCESS) {
LogWarning("aclBinaryInit failed");
return CL_BUILD_PROGRAM_FAILURE;
@@ -284,9 +284,9 @@ int NullProgram::compileBinaryToIL(amd::option::Options* options) {
}
if (ACL_SUCCESS !=
aclInsertSection(gpuNullDevice().amdilCompiler(), bin, llvmBinary_.data(), llvmBinary_.size(), spirFlag)) {
amd::Hsail::InsertSection(gpuNullDevice().amdilCompiler(), bin, llvmBinary_.data(), llvmBinary_.size(), spirFlag)) {
LogWarning("aclInsertSection failed");
aclBinaryFini(bin);
amd::Hsail::BinaryFini(bin);
return CL_BUILD_PROGRAM_FAILURE;
}
@@ -308,12 +308,12 @@ int NullProgram::compileBinaryToIL(amd::option::Options* options) {
type = ACL_TYPE_ISA;
}
err = aclCompile(gpuNullDevice().amdilCompiler(), bin, optionStr.c_str(), aclTypeBinaryUsed, type, NULL);
buildLog_ += aclGetCompilerLog(gpuNullDevice().amdilCompiler());
err = amd::Hsail::Compile(gpuNullDevice().amdilCompiler(), bin, optionStr.c_str(), aclTypeBinaryUsed, type, NULL);
buildLog_ += amd::Hsail::GetCompilerLog(gpuNullDevice().amdilCompiler());
if (err != ACL_SUCCESS) {
LogWarning("aclCompile failed");
aclBinaryFini(bin);
amd::Hsail::BinaryFini(bin);
return CL_BUILD_PROGRAM_FAILURE;
}
@@ -321,26 +321,26 @@ int NullProgram::compileBinaryToIL(amd::option::Options* options) {
acl_error err;
char* binaryIn = nullptr;
size_t size;
err = aclWriteToMem(bin, reinterpret_cast<void**>(&binaryIn), &size);
err = amd::Hsail::WriteToMem(bin, reinterpret_cast<void**>(&binaryIn), &size);
if (err != ACL_SUCCESS) {
LogWarning("aclWriteToMem failed");
aclBinaryFini(bin);
amd::Hsail::BinaryFini(bin);
return CL_BUILD_PROGRAM_FAILURE;
}
clBinary()->saveBIFBinary(binaryIn, size);
aclFreeMem(bin, binaryIn);
amd::Hsail::FreeMem(bin, binaryIn);
}
size_t len = 0;
const void* amdil = aclExtractSection(gpuNullDevice().amdilCompiler(), bin, &len, aclCODEGEN, &err);
const void* amdil = amd::Hsail::ExtractSection(gpuNullDevice().amdilCompiler(), bin, &len, aclCODEGEN, &err);
if (err != ACL_SUCCESS) {
LogWarning("aclExtractSection failed");
aclBinaryFini(bin);
amd::Hsail::BinaryFini(bin);
return CL_BUILD_PROGRAM_FAILURE;
}
ilProgram_.assign(reinterpret_cast<const char*>(amdil), len);
aclBinaryFini(bin);
amd::Hsail::BinaryFini(bin);
return CL_SUCCESS;
}
+1 -1
Wyświetl plik
@@ -27,7 +27,7 @@
#include "amd_hsa_kernel_code.h"
#include "device/device.hpp"
#include "device/hwdebug.hpp"
#include "acl.h"
#include "hsailctx.hpp"
static constexpr int NumberReserveVgprs = 4;
+15 -5
Wyświetl plik
@@ -35,7 +35,7 @@
#include "device/gpu/gpublit.hpp"
#include "cz_id.h"
#include "acl.h"
#include "hsailctx.hpp"
#include "vdi_common.hpp"
#include "CL/cl_gl.h"
@@ -256,6 +256,11 @@ bool NullDevice::create(const char* calName, const amd::Isa& isa, CALtarget targ
return false;
}
if (!ValidateHsail()) {
LogPrintfError("HSAIL initialization failed for offline CAL device %s", isa.targetId());
return false;
}
gslMemInfo memInfo = {0};
// Report 512MB for all offline devices
memInfo.cardMemAvailableBytes = 512 * Mi;
@@ -274,7 +279,7 @@ bool NullDevice::create(const char* calName, const amd::Isa& isa, CALtarget targ
sizeof(aclCompilerOptions_0_8), library, NULL, NULL, NULL, NULL, NULL, AMD_OCL_SC_LIB};
// Initialize the compiler handle
acl_error error;
hsaCompiler_ = aclCompilerInit(&opts, &error);
hsaCompiler_ = amd::Hsail::CompilerInit(&opts, &error);
if (error != ACL_SUCCESS) {
LogPrintfError("Error initializing the compiler for offline CAL device %s", isa.targetId());
return false;
@@ -945,6 +950,11 @@ bool Device::create(CALuint ordinal, CALuint numOfDevices) {
return false;
}
if (!ValidateHsail()) {
LogError("Hsail initialization failed!");
return false;
}
engines_.create(m_nEngines, m_engines, settings().numComputeRings_);
amd::Context::Info info = {0};
@@ -1022,7 +1032,7 @@ bool Device::create(CALuint ordinal, CALuint numOfDevices) {
sizeof(aclCompilerOptions_0_8), library, NULL, NULL, NULL, NULL, NULL, AMD_OCL_SC_LIB};
// Initialize the compiler handle
acl_error error;
hsaCompiler_ = aclCompilerInit(&opts, &error);
hsaCompiler_ = amd::Hsail::CompilerInit(&opts, &error);
if (error != ACL_SUCCESS) {
LogError("Error initializing the compiler");
return false;
@@ -1271,9 +1281,9 @@ bool Device::init() {
void Device::tearDown() {
osExit();
gslExit();
aclCompilerFini(compiler_);
amd::Hsail::CompilerFini(compiler_);
if (hsaCompiler_ != NULL) {
aclCompilerFini(hsaCompiler_);
amd::Hsail::CompilerFini(hsaCompiler_);
}
}
+1 -1
Wyświetl plik
@@ -39,7 +39,7 @@
#include <atomic>
#include "acl.h"
#include "hsailctx.hpp"
#include "vaminterface.h"
/*! \addtogroup GPU
+44 -44
Wyświetl plik
@@ -27,7 +27,7 @@
#include "shader/ComputeProgramObject.h"
#include "utils/options.hpp"
#include "acl.h"
#include "hsailctx.hpp"
#include "SCCommon.h"
#include <string>
@@ -643,8 +643,8 @@ bool NullKernel::create(const std::string& code, const std::string& metadata,
if ((binaryCode == NULL) && (binarySize == 0) && !code.empty()) {
acl_error err;
aclTargetInfo info = aclGetTargetInfo(nullDev().settings().use64BitPtr_ ? "amdil64" : "amdil",
nullptr, &err);
aclTargetInfo info = amd::Hsail::GetTargetInfo(nullDev().settings().use64BitPtr_ ? "amdil64" : "amdil",
nullptr, &err);
if (err != ACL_SUCCESS) {
LogWarning("aclGetTargetInfo failed");
return false;
@@ -657,16 +657,16 @@ bool NullKernel::create(const std::string& code, const std::string& metadata,
binOpts.alloc = &::malloc;
binOpts.dealloc = &::free;
aclBinary* bin = aclBinaryInit(sizeof(aclBinary), &info, &binOpts, &err);
aclBinary* bin = amd::Hsail::BinaryInit(sizeof(aclBinary), &info, &binOpts, &err);
if (err != ACL_SUCCESS) {
LogWarning("aclBinaryInit failed");
return false;
}
if (ACL_SUCCESS !=
aclInsertSection(nullDev().amdilCompiler(), bin, code.data(), code.size(), aclSOURCE)) {
amd::Hsail::InsertSection(nullDev().amdilCompiler(), bin, code.data(), code.size(), aclSOURCE)) {
LogWarning("aclInsertSection failed");
aclBinaryFini(bin);
amd::Hsail::BinaryFini(bin);
return false;
}
@@ -684,37 +684,37 @@ bool NullKernel::create(const std::string& code, const std::string& metadata,
// pass kernel name to compiler
Opts->setCurrKernelName(name().c_str());
err = aclCompile(nullDev().amdilCompiler(), bin, options->origOptionStr.c_str(), ACL_TYPE_AMDIL_TEXT,
ACL_TYPE_ISA, NULL);
err = amd::Hsail::Compile(nullDev().amdilCompiler(), bin, options->origOptionStr.c_str(), ACL_TYPE_AMDIL_TEXT,
ACL_TYPE_ISA, NULL);
buildLog_ += aclGetCompilerLog(nullDev().amdilCompiler());
buildLog_ += amd::Hsail::GetCompilerLog(nullDev().amdilCompiler());
if (err != ACL_SUCCESS) {
LogWarning("aclCompile failed");
aclBinaryFini(bin);
amd::Hsail::BinaryFini(bin);
return false;
}
if (!options->oVariables->BinEXE) {
// Early exit if binary doesn't contain EXE
aclBinaryFini(bin);
amd::Hsail::BinaryFini(bin);
return true;
}
size_t len;
const void* isa = aclExtractSection(nullDev().amdilCompiler(), bin, &len, aclTEXT, &err);
const void* isa = amd::Hsail::ExtractSection(nullDev().amdilCompiler(), bin, &len, aclTEXT, &err);
if (err != ACL_SUCCESS) {
LogWarning("aclExtractSection failed");
aclBinaryFini(bin);
amd::Hsail::BinaryFini(bin);
return false;
}
uint calImageSize;
if (!createMultiBinary(&calImageSize, reinterpret_cast<void**>(&calImage), isa)) {
LogWarning("initSrcEncoding failed");
aclBinaryFini(bin);
amd::Hsail::BinaryFini(bin);
return false;
}
aclBinaryFini(bin);
amd::Hsail::BinaryFini(bin);
} else if ((binaryCode != NULL) && (binarySize != 0)) {
uint size = 0;
if (!amuABIMultiBinaryGetSize(&size, const_cast<void*>(binaryCode)) || size > binarySize) {
@@ -3083,9 +3083,9 @@ bool HSAILKernel::init(amd::hsa::loader::Symbol* sym, bool finalize) {
if (dev().settings().svmFineGrainSystem_) {
options.append(" -sc-xnack-iommu");
}
error = aclCompile(dev().hsaCompiler(), prog().binaryElf(), options.c_str(), ACL_TYPE_CG,
ACL_TYPE_ISA, NULL);
buildLog_ += aclGetCompilerLog(dev().hsaCompiler());
error = amd::Hsail::Compile(dev().hsaCompiler(), prog().binaryElf(), options.c_str(), ACL_TYPE_CG,
ACL_TYPE_ISA, NULL);
buildLog_ += amd::Hsail::GetCompilerLog(dev().hsaCompiler());
if (error != ACL_SUCCESS) {
LogError("Failed to finalize kernel");
return false;
@@ -3098,8 +3098,8 @@ bool HSAILKernel::init(amd::hsa::loader::Symbol* sym, bool finalize) {
// Pull out metadata from the ELF
size_t sizeOfArgList;
error = aclQueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_ARGUMENT_ARRAY,
openClKernelName.c_str(), NULL, &sizeOfArgList);
error = amd::Hsail::QueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_ARGUMENT_ARRAY,
openClKernelName.c_str(), NULL, &sizeOfArgList);
if (error != ACL_SUCCESS) {
return false;
}
@@ -3108,20 +3108,20 @@ bool HSAILKernel::init(amd::hsa::loader::Symbol* sym, bool finalize) {
if (NULL == aclArgList) {
return false;
}
error = aclQueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_ARGUMENT_ARRAY,
openClKernelName.c_str(), aclArgList, &sizeOfArgList);
error = amd::Hsail::QueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_ARGUMENT_ARRAY,
openClKernelName.c_str(), aclArgList, &sizeOfArgList);
if (error != ACL_SUCCESS) {
return false;
}
size_t sizeOfWorkGroupSize;
error = aclQueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_WORK_GROUP_SIZE,
openClKernelName.c_str(), NULL, &sizeOfWorkGroupSize);
error = amd::Hsail::QueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_WORK_GROUP_SIZE,
openClKernelName.c_str(), NULL, &sizeOfWorkGroupSize);
if (error != ACL_SUCCESS) {
return false;
}
error = aclQueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_WORK_GROUP_SIZE,
openClKernelName.c_str(), workGroupInfo_.compileSize_, &sizeOfWorkGroupSize);
error = amd::Hsail::QueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_WORK_GROUP_SIZE,
openClKernelName.c_str(), workGroupInfo_.compileSize_, &sizeOfWorkGroupSize);
if (error != ACL_SUCCESS) {
return false;
}
@@ -3139,8 +3139,8 @@ bool HSAILKernel::init(amd::hsa::loader::Symbol* sym, bool finalize) {
// Pull out printf metadata from the ELF
size_t sizeOfPrintfList;
error = aclQueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_GPU_PRINTF_ARRAY,
openClKernelName.c_str(), NULL, &sizeOfPrintfList);
error = amd::Hsail::QueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_GPU_PRINTF_ARRAY,
openClKernelName.c_str(), NULL, &sizeOfPrintfList);
if (error != ACL_SUCCESS) {
return false;
}
@@ -3151,8 +3151,8 @@ bool HSAILKernel::init(amd::hsa::loader::Symbol* sym, bool finalize) {
if (NULL == aclPrintfList) {
return false;
}
error = aclQueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_GPU_PRINTF_ARRAY,
openClKernelName.c_str(), aclPrintfList, &sizeOfPrintfList);
error = amd::Hsail::QueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_GPU_PRINTF_ARRAY,
openClKernelName.c_str(), aclPrintfList, &sizeOfPrintfList);
if (error != ACL_SUCCESS) {
return false;
}
@@ -3165,8 +3165,8 @@ bool HSAILKernel::init(amd::hsa::loader::Symbol* sym, bool finalize) {
aclMetadata md;
md.enqueue_kernel = false;
size_t sizeOfDeviceEnqueue = sizeof(md.enqueue_kernel);
error = aclQueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_DEVICE_ENQUEUE,
openClKernelName.c_str(), &md.enqueue_kernel, &sizeOfDeviceEnqueue);
error = amd::Hsail::QueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_DEVICE_ENQUEUE,
openClKernelName.c_str(), &md.enqueue_kernel, &sizeOfDeviceEnqueue);
if (error != ACL_SUCCESS) {
return false;
}
@@ -3174,17 +3174,17 @@ bool HSAILKernel::init(amd::hsa::loader::Symbol* sym, bool finalize) {
md.kernel_index = -1;
size_t sizeOfIndex = sizeof(md.kernel_index);
error = aclQueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_KERNEL_INDEX,
openClKernelName.c_str(), &md.kernel_index, &sizeOfIndex);
error = amd::Hsail::QueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_KERNEL_INDEX,
openClKernelName.c_str(), &md.kernel_index, &sizeOfIndex);
if (error != ACL_SUCCESS) {
return false;
}
index_ = md.kernel_index;
size_t sizeOfWavesPerSimdHint = sizeof(workGroupInfo_.wavesPerSimdHint_);
error = aclQueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_WAVES_PER_SIMD_HINT,
openClKernelName.c_str(), &workGroupInfo_.wavesPerSimdHint_,
&sizeOfWavesPerSimdHint);
error = amd::Hsail::QueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_WAVES_PER_SIMD_HINT,
openClKernelName.c_str(), &workGroupInfo_.wavesPerSimdHint_,
&sizeOfWavesPerSimdHint);
if (error != ACL_SUCCESS) {
return false;
}
@@ -3192,16 +3192,16 @@ bool HSAILKernel::init(amd::hsa::loader::Symbol* sym, bool finalize) {
waveLimiter_.enable(dev().settings().ciPlus_);
size_t sizeOfWorkGroupSizeHint = sizeof(workGroupInfo_.compileSizeHint_);
error = aclQueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_WORK_GROUP_SIZE_HINT,
openClKernelName.c_str(), workGroupInfo_.compileSizeHint_,
&sizeOfWorkGroupSizeHint);
error = amd::Hsail::QueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_WORK_GROUP_SIZE_HINT,
openClKernelName.c_str(), workGroupInfo_.compileSizeHint_,
&sizeOfWorkGroupSizeHint);
if (error != ACL_SUCCESS) {
return false;
}
size_t sizeOfVecTypeHint;
error = aclQueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_VEC_TYPE_HINT,
openClKernelName.c_str(), NULL, &sizeOfVecTypeHint);
error = amd::Hsail::QueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_VEC_TYPE_HINT,
openClKernelName.c_str(), NULL, &sizeOfVecTypeHint);
if (error != ACL_SUCCESS) {
return false;
}
@@ -3211,8 +3211,8 @@ bool HSAILKernel::init(amd::hsa::loader::Symbol* sym, bool finalize) {
if (NULL == VecTypeHint) {
return false;
}
error = aclQueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_VEC_TYPE_HINT,
openClKernelName.c_str(), VecTypeHint, &sizeOfVecTypeHint);
error = amd::Hsail::QueryInfo(dev().hsaCompiler(), prog().binaryElf(), RT_VEC_TYPE_HINT,
openClKernelName.c_str(), VecTypeHint, &sizeOfVecTypeHint);
if (error != ACL_SUCCESS) {
return false;
}
+30 -30
Wyświetl plik
@@ -43,8 +43,8 @@ namespace gpu {
const aclTargetInfo& NullProgram::info() {
acl_error err;
info_ = aclGetTargetInfo(gpuNullDevice().settings().use64BitPtr_ ? "amdil64" : "amdil",
nullptr, &err);
info_ = amd::Hsail::GetTargetInfo(gpuNullDevice().settings().use64BitPtr_ ? "amdil64" : "amdil",
nullptr, &err);
if (err != ACL_SUCCESS) {
LogWarning("aclGetTargetInfo failed");
}
@@ -473,7 +473,7 @@ bool NullProgram::linkImpl(const std::vector<device::Program*>& inputPrograms,
std::vector<aclBinary*> libs(llvmBinaries.size(), NULL);
for (size_t i = 0; i < libs.size(); ++i) {
libs[i] = aclBinaryInit(sizeof(aclBinary), &aclinfo, &binOpts, &err);
libs[i] = amd::Hsail::BinaryInit(sizeof(aclBinary), &aclinfo, &binOpts, &err);
if (err != ACL_SUCCESS) {
LogWarning("aclBinaryInit failed");
break;
@@ -487,8 +487,8 @@ bool NullProgram::linkImpl(const std::vector<device::Program*>& inputPrograms,
} else {
aclTypeUsed = aclLLVMIR;
}
err = aclInsertSection(gpuNullDevice().amdilCompiler(), libs[i], llvmBinaries[i]->data(),
llvmBinaries[i]->size(), aclTypeUsed);
err = amd::Hsail::InsertSection(gpuNullDevice().amdilCompiler(), libs[i], llvmBinaries[i]->data(),
llvmBinaries[i]->size(), aclTypeUsed);
if (err != ACL_SUCCESS) {
LogWarning("aclInsertSection failed");
break;
@@ -504,10 +504,10 @@ bool NullProgram::linkImpl(const std::vector<device::Program*>& inputPrograms,
unsigned int numLibs = libs.size() - 1;
if (numLibs > 0) {
err = aclLink(gpuNullDevice().amdilCompiler(), libs[0], numLibs, &libs[1], ACL_TYPE_LLVMIR_BINARY,
"-create-library", NULL);
err = amd::Hsail::Link(gpuNullDevice().amdilCompiler(), libs[0], numLibs, &libs[1], ACL_TYPE_LLVMIR_BINARY,
"-create-library", NULL);
buildLog_ += aclGetCompilerLog(gpuNullDevice().amdilCompiler());
buildLog_ += amd::Hsail::GetCompilerLog(gpuNullDevice().amdilCompiler());
if (err != ACL_SUCCESS) {
LogWarning("aclLink failed");
@@ -524,7 +524,7 @@ bool NullProgram::linkImpl(const std::vector<device::Program*>& inputPrograms,
} else {
aclTypeUsed = aclLLVMIR;
}
const void* llvmir = aclExtractSection(gpuNullDevice().amdilCompiler(), libs[0], &size, aclTypeUsed, &err);
const void* llvmir = amd::Hsail::ExtractSection(gpuNullDevice().amdilCompiler(), libs[0], &size, aclTypeUsed, &err);
if (err != ACL_SUCCESS) {
LogWarning("aclExtractSection failed");
break;
@@ -534,7 +534,7 @@ bool NullProgram::linkImpl(const std::vector<device::Program*>& inputPrograms,
elfSectionType_ = amd::Elf::LLVMIR;
} while (0);
std::for_each(libs.begin(), libs.end(), std::ptr_fun(aclBinaryFini));
std::for_each(libs.begin(), libs.end(), std::ptr_fun(amd::Hsail::BinaryFini));
if (err != ACL_SUCCESS) {
buildLog_ += "Error: linking llvm modules failed!";
@@ -1482,12 +1482,12 @@ HSAILProgram::~HSAILProgram() {
delete it;
}
if (rawBinary_ != NULL) {
aclFreeMem(binaryElf_, rawBinary_);
amd::Hsail::FreeMem(binaryElf_, rawBinary_);
}
acl_error error;
// Free the elf binary
if (binaryElf_ != NULL) {
error = aclBinaryFini(binaryElf_);
error = amd::Hsail::BinaryFini(binaryElf_);
if (error != ACL_SUCCESS) {
LogWarning("Error while destroying the acl binary \n");
}
@@ -1533,9 +1533,9 @@ bool HSAILProgram::linkImpl(amd::option::Options* options) {
// 1. if the program is created with binary and contains only hsail text
case ACL_TYPE_HSAIL_TEXT: {
std::string curOptions = options->origOptionStr + hsailOptions();
errorCode = aclCompile(gpuNullDevice().hsaCompiler(), binaryElf_, curOptions.c_str(),
continueCompileFrom, ACL_TYPE_CG, NULL);
buildLog_ += aclGetCompilerLog(gpuNullDevice().hsaCompiler());
errorCode = amd::Hsail::Compile(gpuNullDevice().hsaCompiler(), binaryElf_, curOptions.c_str(),
continueCompileFrom, ACL_TYPE_CG, NULL);
buildLog_ += amd::Hsail::GetCompilerLog(gpuNullDevice().hsaCompiler());
if (errorCode != ACL_SUCCESS) {
buildLog_ += "Error: BRIG code generation failed.\n";
return false;
@@ -1560,9 +1560,9 @@ bool HSAILProgram::linkImpl(amd::option::Options* options) {
if (gpuNullDevice().settings().svmFineGrainSystem_) {
fin_options.append(" -sc-xnack-iommu");
}
errorCode = aclCompile(gpuNullDevice().hsaCompiler(), binaryElf_, fin_options.c_str(), ACL_TYPE_CG,
ACL_TYPE_ISA, NULL);
buildLog_ += aclGetCompilerLog(gpuNullDevice().hsaCompiler());
errorCode = amd::Hsail::Compile(gpuNullDevice().hsaCompiler(), binaryElf_, fin_options.c_str(), ACL_TYPE_CG,
ACL_TYPE_ISA, NULL);
buildLog_ += amd::Hsail::GetCompilerLog(gpuNullDevice().hsaCompiler());
if (errorCode != ACL_SUCCESS) {
buildLog_ += "Error: BRIG finalization to ISA failed.\n";
return false;
@@ -1579,7 +1579,7 @@ bool HSAILProgram::linkImpl(amd::option::Options* options) {
size_t size = 0;
hsa_code_object_t code_object;
code_object.handle = reinterpret_cast<uint64_t>(
aclExtractSection(gpuNullDevice().hsaCompiler(), binaryElf_, &size, aclTEXT, &errorCode));
amd::Hsail::ExtractSection(gpuNullDevice().hsaCompiler(), binaryElf_, &size, aclTEXT, &errorCode));
if (errorCode != ACL_SUCCESS) {
buildLog_ += "Error: Extracting AMD HSA Code Object from binary failed.\n";
return false;
@@ -1592,15 +1592,15 @@ bool HSAILProgram::linkImpl(amd::option::Options* options) {
}
size_t kernelNamesSize = 0;
errorCode =
aclQueryInfo(gpuNullDevice().hsaCompiler(), binaryElf_, RT_KERNEL_NAMES, NULL, NULL, &kernelNamesSize);
amd::Hsail::QueryInfo(gpuNullDevice().hsaCompiler(), binaryElf_, RT_KERNEL_NAMES, NULL, NULL, &kernelNamesSize);
if (errorCode != ACL_SUCCESS) {
buildLog_ += "Error: Querying of kernel names size from the binary failed.\n";
return false;
}
if (kernelNamesSize > 0) {
char* kernelNames = new char[kernelNamesSize];
errorCode = aclQueryInfo(gpuNullDevice().hsaCompiler(), binaryElf_, RT_KERNEL_NAMES, NULL, kernelNames,
&kernelNamesSize);
errorCode = amd::Hsail::QueryInfo(gpuNullDevice().hsaCompiler(), binaryElf_, RT_KERNEL_NAMES, NULL, kernelNames,
&kernelNamesSize);
if (errorCode != ACL_SUCCESS) {
buildLog_ += "Error: Querying of kernel names from the binary failed.\n";
delete [] kernelNames;
@@ -1615,9 +1615,9 @@ bool HSAILProgram::linkImpl(amd::option::Options* options) {
for (const auto& it : vKernels) {
std::string kernelName(it);
std::string openclKernelName = Kernel::openclMangledName(kernelName);
errorCode = aclQueryInfo(gpuNullDevice().hsaCompiler(), binaryElf_, RT_NUM_KERNEL_HIDDEN_ARGS,
openclKernelName.c_str(), &md.numHiddenKernelArgs,
&sizeOfnumHiddenKernelArgs);
errorCode = amd::Hsail::QueryInfo(gpuNullDevice().hsaCompiler(), binaryElf_, RT_NUM_KERNEL_HIDDEN_ARGS,
openclKernelName.c_str(), &md.numHiddenKernelArgs,
&sizeOfnumHiddenKernelArgs);
if (errorCode != ACL_SUCCESS) {
buildLog_ += "Error: Querying of kernel '" + openclKernelName +
"' extra arguments count from AMD HSA Code Object failed. Kernel initialization "
@@ -1652,7 +1652,7 @@ bool HSAILProgram::linkImpl(amd::option::Options* options) {
}
// Save the binary in the interface class
saveBinaryAndSetType(TYPE_EXECUTABLE);
buildLog_ += aclGetCompilerLog(gpuNullDevice().hsaCompiler());
buildLog_ += amd::Hsail::GetCompilerLog(gpuNullDevice().hsaCompiler());
return true;
}
@@ -1721,8 +1721,8 @@ void HSAILProgram::fillResListWithKernels(std::vector<const Memory*>& memList) c
const aclTargetInfo& HSAILProgram::info() {
acl_error err;
info_ = aclGetTargetInfo(gpuNullDevice().settings().use64BitPtr_ ? "hsail64" : "hsail",
device().isa().hsailName(), &err);
info_ = amd::Hsail::GetTargetInfo(gpuNullDevice().settings().use64BitPtr_ ? "hsail64" : "hsail",
device().isa().hsailName(), &err);
if (err != ACL_SUCCESS) {
LogWarning("aclGetTargetInfo failed");
}
@@ -1733,11 +1733,11 @@ bool HSAILProgram::saveBinaryAndSetType(type_t type) {
// Write binary to memory
if (rawBinary_ != NULL) {
// Free memory containing rawBinary
aclFreeMem(binaryElf_, rawBinary_);
amd::Hsail::FreeMem(binaryElf_, rawBinary_);
rawBinary_ = NULL;
}
size_t size = 0;
if (aclWriteToMem(binaryElf_, &rawBinary_, &size) != ACL_SUCCESS) {
if (amd::Hsail::WriteToMem(binaryElf_, &rawBinary_, &size) != ACL_SUCCESS) {
buildLog_ += "Failed to write binary to memory \n";
return false;
}
+1 -1
Wyświetl plik
@@ -21,7 +21,7 @@
#include "device/gpu/gpudefs.hpp"
#include "device/gpu/gpuprogram.hpp"
#include "device/gpu/gpukernel.hpp"
#include "acl.h"
#include "hsailctx.hpp"
#include "SCShadersSi.h"
#include "si_ci_vi_merged_offset.h"
#include "si_ci_vi_merged_registers.h"