From d5f3e9341fc8d6f5d321df154a4f0e679a69c715 Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 30 Aug 2018 15:31:56 -0400
Subject: [PATCH] P4 to Git Change 1600140 by gandryey@gera-w8 on 2018/08/30
15:10:58
SWDEV-79445 - OCL generic changes and code clean-up
- It's not necessary to have backend specific binary objects in HSAIL or LC paths.
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#228 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#316 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpubinary.hpp#28 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#239 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.hpp#72 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palbinary.cpp#3 delete
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palbinary.hpp#4 delete
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.cpp#66 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.hpp#22 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocbinary.hpp#7 delete
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#82 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.hpp#33 edit
[ROCm/clr commit: 5c4478fa22269ff58e9d47a58117c5a9953554c3]
---
projects/clr/rocclr/runtime/device/device.cpp | 139 +++++++++++-------
projects/clr/rocclr/runtime/device/device.hpp | 8 +-
.../rocclr/runtime/device/gpu/gpubinary.hpp | 33 +----
.../rocclr/runtime/device/gpu/gpuprogram.cpp | 24 ---
.../rocclr/runtime/device/gpu/gpuprogram.hpp | 16 --
.../rocclr/runtime/device/pal/palbinary.cpp | 4 -
.../rocclr/runtime/device/pal/palbinary.hpp | 41 ------
.../rocclr/runtime/device/pal/palprogram.cpp | 17 ---
.../rocclr/runtime/device/pal/palprogram.hpp | 15 --
.../rocclr/runtime/device/rocm/rocbinary.hpp | 45 ------
.../rocclr/runtime/device/rocm/rocprogram.cpp | 19 +--
.../rocclr/runtime/device/rocm/rocprogram.hpp | 16 --
12 files changed, 89 insertions(+), 288 deletions(-)
delete mode 100644 projects/clr/rocclr/runtime/device/pal/palbinary.cpp
delete mode 100644 projects/clr/rocclr/runtime/device/pal/palbinary.hpp
delete mode 100644 projects/clr/rocclr/runtime/device/rocm/rocbinary.hpp
diff --git a/projects/clr/rocclr/runtime/device/device.cpp b/projects/clr/rocclr/runtime/device/device.cpp
index edacb8557c..13f33c29d6 100644
--- a/projects/clr/rocclr/runtime/device/device.cpp
+++ b/projects/clr/rocclr/runtime/device/device.cpp
@@ -55,7 +55,7 @@ extern const char* BlitSourceCode;
namespace amd {
-std::vector* Device::devices_ = NULL;
+std::vector* Device::devices_ = nullptr;
AppProfile Device::appProfile_;
amd::Monitor MemObjMap::AllocatedLock_("Guards SVM allocation list");
@@ -81,7 +81,7 @@ amd::Memory* MemObjMap::FindMemObj(const void* k) {
uintptr_t key = reinterpret_cast(k);
auto it = MemObjMap_.upper_bound(key);
if (it == MemObjMap_.begin()) {
- return NULL;
+ return nullptr;
}
--it;
@@ -90,13 +90,13 @@ amd::Memory* MemObjMap::FindMemObj(const void* k) {
// the k is in the range
return mem;
} else {
- return NULL;
+ return nullptr;
}
}
Device::BlitProgram::~BlitProgram() {
- if (program_ != NULL) {
+ if (program_ != nullptr) {
program_->release();
}
}
@@ -107,13 +107,13 @@ bool Device::BlitProgram::create(amd::Device* device, const char* extraKernels,
devices.push_back(device);
std::string kernels(device::BlitSourceCode);
- if (extraKernels != NULL) {
+ if (extraKernels != nullptr) {
kernels += extraKernels;
}
// Create a program with all blit kernels
program_ = new Program(*context_, kernels.c_str(), Program::OpenCL_C);
- if (program_ == NULL) {
+ if (program_ == nullptr) {
return false;
}
@@ -126,13 +126,13 @@ bool Device::BlitProgram::create(amd::Device* device, const char* extraKernels,
#endif // !defined(WITH_LIGHTNING_COMPILER)
;
- if (extraOptions != NULL) {
+ if (extraOptions != nullptr) {
opt += extraOptions;
}
if (!GPU_DUMP_BLIT_KERNELS) {
opt += " -fno-enable-dump";
}
- if (CL_SUCCESS != program_->build(devices, opt.c_str(), NULL, NULL, GPU_DUMP_BLIT_KERNELS)) {
+ if (CL_SUCCESS != program_->build(devices, opt.c_str(), nullptr, nullptr, GPU_DUMP_BLIT_KERNELS)) {
return false;
}
@@ -142,7 +142,7 @@ bool Device::BlitProgram::create(amd::Device* device, const char* extraKernels,
bool Device::init() {
assert(!Runtime::initialized() && "initialize only once");
bool ret = false;
- devices_ = NULL;
+ devices_ = nullptr;
appProfile_.init();
@@ -176,7 +176,7 @@ bool Device::init() {
}
void Device::tearDown() {
- if (devices_ != NULL) {
+ if (devices_ != nullptr) {
for (uint i = 0; i < devices_->size(); ++i) {
delete devices_->at(i);
}
@@ -199,10 +199,10 @@ void Device::tearDown() {
}
Device::Device()
- : settings_(NULL),
+ : settings_(nullptr),
online_(true),
- blitProgram_(NULL),
- hwDebugMgr_(NULL),
+ blitProgram_(nullptr),
+ hwDebugMgr_(nullptr),
vaCacheAccess_(nullptr),
vaCacheMap_(nullptr) {
memset(&info_, '\0', sizeof(info_));
@@ -215,22 +215,22 @@ Device::~Device() {
delete vaCacheAccess_;
// Destroy device settings
- if (settings_ != NULL) {
+ if (settings_ != nullptr) {
delete settings_;
}
- if (info_.extensions_ != NULL) {
+ if (info_.extensions_ != nullptr) {
delete[] info_.extensions_;
}
}
bool Device::create() {
vaCacheAccess_ = new amd::Monitor("VA Cache Ops Lock", true);
- if (NULL == vaCacheAccess_) {
+ if (nullptr == vaCacheAccess_) {
return false;
}
vaCacheMap_ = new std::map();
- if (NULL == vaCacheMap_) {
+ if (nullptr == vaCacheMap_) {
return false;
}
return true;
@@ -241,7 +241,7 @@ void Device::registerDevice() {
static bool defaultIsAssigned = false;
- if (devices_ == NULL) {
+ if (devices_ == nullptr) {
devices_ = new std::vector;
}
@@ -314,7 +314,7 @@ bool Device::IsTypeMatching(cl_device_type type, bool offlineDevices) {
std::vector Device::getDevices(cl_device_type type, bool offlineDevices) {
std::vector result;
- if (devices_ == NULL) {
+ if (devices_ == nullptr) {
return result;
}
@@ -332,7 +332,7 @@ std::vector Device::getDevices(cl_device_type type, bool offlineDevices
size_t Device::numDevices(cl_device_type type, bool offlineDevices) {
size_t result = 0;
- if (devices_ == NULL) {
+ if (devices_ == nullptr) {
return 0;
}
@@ -348,11 +348,11 @@ size_t Device::numDevices(cl_device_type type, bool offlineDevices) {
bool Device::getDeviceIDs(cl_device_type deviceType, cl_uint numEntries, cl_device_id* devices,
cl_uint* numDevices, bool offlineDevices) {
- if (numDevices != NULL && devices == NULL) {
+ if (numDevices != nullptr && devices == nullptr) {
*numDevices = (cl_uint)amd::Device::numDevices(deviceType, offlineDevices);
return (*numDevices > 0) ? true : false;
}
- assert(devices != NULL && "check the code above");
+ assert(devices != nullptr && "check the code above");
std::vector ret = amd::Device::getDevices(deviceType, offlineDevices);
if (ret.size() == 0) {
@@ -378,7 +378,7 @@ bool Device::getDeviceIDs(cl_device_type deviceType, cl_uint numEntries, cl_devi
char* Device::getExtensionString() {
std::stringstream extStream;
size_t size;
- char* result = NULL;
+ char* result = nullptr;
// Generate the extension string
for (uint i = 0; i < ClExtTotal; ++i) {
@@ -391,7 +391,7 @@ char* Device::getExtensionString() {
// Create a single string with all extensions
result = new char[size];
- if (result != NULL) {
+ if (result != nullptr) {
memcpy(result, extStream.str().data(), (size - 1));
result[size - 1] = 0;
}
@@ -619,7 +619,7 @@ void Memory::saveMapInfo(const void* mapAddress, const amd::Coord3D origin,
Program::Program(amd::Device& device)
: device_(device),
type_(TYPE_NONE),
- clBinary_(NULL),
+ clBinary_(nullptr),
llvmBinary_(),
elfSectionType_(amd::OclElf::LLVMIR),
compileOptions_(),
@@ -628,7 +628,7 @@ Program::Program(amd::Device& device)
buildStatus_(CL_BUILD_NONE),
buildError_(CL_SUCCESS),
globalVariableTotalSize_(0),
- programOptions(NULL) {}
+ programOptions(nullptr) {}
Program::~Program() { clear(); }
@@ -640,6 +640,23 @@ void Program::clear() {
kernels_.clear();
}
+bool Program::initClBinary() {
+ if (clBinary_ == nullptr) {
+ clBinary_ = new ClBinary(device());
+ if (clBinary_ == nullptr) {
+ return false;
+ }
+ }
+ return true;
+}
+
+void Program::releaseClBinary() {
+ if (clBinary_ != nullptr) {
+ delete clBinary_;
+ clBinary_ = nullptr;
+ }
+}
+
bool Program::initBuild(amd::option::Options* options) {
programOptions = options;
@@ -877,7 +894,7 @@ cl_int Program::build(const std::string& sourceCode, const char* origOptions,
// Compile the source code if any
std::vector headers;
if ((buildStatus_ == CL_BUILD_IN_PROGRESS) && !sourceCode.empty() &&
- !compileImpl(sourceCode, headers, NULL, options)) {
+ !compileImpl(sourceCode, headers, nullptr, options)) {
buildStatus_ = CL_BUILD_ERROR;
if (buildLog_.empty()) {
buildLog_ = "Internal error: Compilation failed.";
@@ -1005,7 +1022,7 @@ bool Program::initClBinary(const char* binaryIn, size_t size) {
// unencrypted
int encryptCode = 0;
- char* decryptedBin = NULL;
+ char* decryptedBin = nullptr;
#if !defined(WITH_LIGHTNING_COMPILER)
bool isSPIRV = isSPIRVMagic(binaryIn, size);
@@ -1060,7 +1077,7 @@ bool Program::initClBinary(const char* binaryIn, size_t size) {
if (!clBinary()->decryptElf(binaryIn, size, &decryptedBin, &decryptedSize, &encryptCode)) {
return false;
}
- if (decryptedBin != NULL) {
+ if (decryptedBin != nullptr) {
// It is decrypted binary.
bin = decryptedBin;
sz = decryptedSize;
@@ -1068,7 +1085,7 @@ bool Program::initClBinary(const char* binaryIn, size_t size) {
if (!isElf(bin)) {
// Invalid binary.
- if (decryptedBin != NULL) {
+ if (decryptedBin != nullptr) {
delete[] decryptedBin;
}
return false;
@@ -1077,7 +1094,7 @@ bool Program::initClBinary(const char* binaryIn, size_t size) {
clBinary()->setFlags(encryptCode);
- return clBinary()->setBinary(bin, sz, (decryptedBin != NULL));
+ return clBinary()->setBinary(bin, sz, (decryptedBin != nullptr));
}
@@ -1109,7 +1126,7 @@ bool Program::setBinary(const char* binaryIn, size_t size) {
break;
}
case ET_DYN: {
- char* sect = NULL;
+ char* sect = nullptr;
size_t sz = 0;
// FIXME: we should look for the e_machine to detect an HSACO.
if (clBinary()->elfIn()->getSection(amd::OclElf::TEXT, §, &sz) && sect && sz > 0) {
@@ -1138,7 +1155,7 @@ bool Program::setBinary(const char* binaryIn, size_t size) {
bool Program::createBIFBinary(aclBinary* bin) {
#if defined(WITH_COMPILER_LIB)
acl_error err;
- char* binaryIn = NULL;
+ char* binaryIn = nullptr;
size_t size;
err = aclWriteToMem(bin, reinterpret_cast(&binaryIn), &size);
if (err != ACL_SUCCESS) {
@@ -1155,14 +1172,14 @@ bool Program::createBIFBinary(aclBinary* bin) {
ClBinary::ClBinary(const amd::Device& dev, BinaryImageFormat bifVer)
: dev_(dev),
- binary_(NULL),
+ binary_(nullptr),
size_(0),
flags_(0),
- origBinary_(NULL),
+ origBinary_(nullptr),
origSize_(0),
encryptCode_(0),
- elfIn_(NULL),
- elfOut_(NULL),
+ elfIn_(nullptr),
+ elfOut_(nullptr),
format_(bifVer) {}
ClBinary::~ClBinary() {
@@ -1176,6 +1193,14 @@ ClBinary::~ClBinary() {
}
}
+bool ClBinary::setElfTarget() {
+ static const uint32_t Target = 21;
+ assert(((0xFFFF8000 & Target) == 0) && "ASIC target ID >= 2^15");
+ uint16_t elf_target = static_cast(0x7FFF & Target);
+ return elfOut()->setTarget(elf_target, amd::OclElf::CAL_PLATFORM);
+ return true;
+}
+
std::string ClBinary::getBIFSymbol(unsigned int symbolID) const {
size_t nSymbols = 0;
// Due to PRE & POST defines in bif_section_labels.hpp conflict with
@@ -1279,9 +1304,9 @@ bool ClBinary::isRecompilable(std::string& llvmBinary, amd::OclElf::oclElfPlatfo
}
void ClBinary::release() {
- if (isBinaryAllocated() && (binary_ != NULL)) {
+ if (isBinaryAllocated() && (binary_ != nullptr)) {
delete[] binary_;
- binary_ = NULL;
+ binary_ = nullptr;
flags_ &= ~BinaryAllocated;
}
}
@@ -1309,7 +1334,7 @@ bool ClBinary::createElfBinary(bool doencrypt, Program::type_t type) {
// Insert Version string that builds this binary into .comment section
const device::Info& devInfo = dev_.info();
std::string buildVerInfo("@(#) ");
- if (devInfo.version_ != NULL) {
+ if (devInfo.version_ != nullptr) {
buildVerInfo.append(devInfo.version_);
buildVerInfo.append(". Driver version: ");
buildVerInfo.append(devInfo.driverVersion_);
@@ -1356,7 +1381,7 @@ bool ClBinary::createElfBinary(bool doencrypt, Program::type_t type) {
// Increase the size by 64 to accomodate extra headers
int outBufSize = (int)(imageSize + 64);
char* outBuf = new char[outBufSize];
- if (outBuf == NULL) {
+ if (outBuf == nullptr) {
return false;
}
memset(outBuf, '\0', outBufSize);
@@ -1403,12 +1428,12 @@ void ClBinary::setFlags(int encryptCode) {
bool ClBinary::decryptElf(const char* binaryIn, size_t size, char** decryptBin, size_t* decryptSize,
int* encryptCode) {
- *decryptBin = NULL;
+ *decryptBin = nullptr;
#if defined(HAVE_BLOWFISH_H)
int outBufSize = 0;
if (amd::isEncryptedBIF(binaryIn, (int)size, &outBufSize)) {
char* outBuf = new (std::nothrow) char[outBufSize];
- if (outBuf == NULL) {
+ if (outBuf == nullptr) {
return false;
}
@@ -1430,14 +1455,14 @@ bool ClBinary::decryptElf(const char* binaryIn, size_t size, char** decryptBin,
bool ClBinary::setElfIn() {
if (elfIn_) return true;
- if (binary_ == NULL) {
+ if (binary_ == nullptr) {
return false;
}
- elfIn_ = new amd::OclElf(ELFCLASSNONE, binary_, size_, NULL, ELF_C_READ);
- if ((elfIn_ == NULL) || elfIn_->hasError()) {
+ elfIn_ = new amd::OclElf(ELFCLASSNONE, binary_, size_, nullptr, ELF_C_READ);
+ if ((elfIn_ == nullptr) || elfIn_->hasError()) {
if (elfIn_) {
delete elfIn_;
- elfIn_ = NULL;
+ elfIn_ = nullptr;
}
LogError("Creating input ELF object failed");
return false;
@@ -1449,16 +1474,16 @@ bool ClBinary::setElfIn() {
void ClBinary::resetElfIn() {
if (elfIn_) {
delete elfIn_;
- elfIn_ = NULL;
+ elfIn_ = nullptr;
}
}
bool ClBinary::setElfOut(unsigned char eclass, const char* outFile) {
- elfOut_ = new amd::OclElf(eclass, NULL, 0, outFile, ELF_C_WRITE);
- if ((elfOut_ == NULL) || elfOut_->hasError()) {
+ elfOut_ = new amd::OclElf(eclass, nullptr, 0, outFile, ELF_C_WRITE);
+ if ((elfOut_ == nullptr) || elfOut_->hasError()) {
if (elfOut_) {
delete elfOut_;
- elfOut_ = NULL;
+ elfOut_ = nullptr;
}
LogError("Creating ouput ELF object failed");
return false;
@@ -1470,14 +1495,14 @@ bool ClBinary::setElfOut(unsigned char eclass, const char* outFile) {
void ClBinary::resetElfOut() {
if (elfOut_) {
delete elfOut_;
- elfOut_ = NULL;
+ elfOut_ = nullptr;
}
}
bool ClBinary::loadLlvmBinary(std::string& llvmBinary,
amd::OclElf::oclElfSections& elfSectionType) const {
// Check if current binary already has LLVMIR
- char* section = NULL;
+ char* section = nullptr;
size_t sz = 0;
const amd::OclElf::oclElfSections SectionTypes[] = {amd::OclElf::LLVMIR, amd::OclElf::SPIR,
amd::OclElf::SPIRV};
@@ -1494,7 +1519,7 @@ bool ClBinary::loadLlvmBinary(std::string& llvmBinary,
}
bool ClBinary::loadCompileOptions(std::string& compileOptions) const {
- char* options = NULL;
+ char* options = nullptr;
size_t sz;
compileOptions.clear();
if (elfIn_->getSymbol(amd::OclElf::COMMENT, getBIFSymbol(symOpenclCompilerOptions).c_str(),
@@ -1508,7 +1533,7 @@ bool ClBinary::loadCompileOptions(std::string& compileOptions) const {
}
bool ClBinary::loadLinkOptions(std::string& linkOptions) const {
- char* options = NULL;
+ char* options = nullptr;
size_t sz;
linkOptions.clear();
if (elfIn_->getSymbol(amd::OclElf::COMMENT, getBIFSymbol(symOpenclLinkerOptions).c_str(),
@@ -1532,7 +1557,7 @@ void ClBinary::storeLinkOptions(const std::string& linkOptions) {
}
bool ClBinary::isSPIR() const {
- char* section = NULL;
+ char* section = nullptr;
size_t sz = 0;
if (elfIn_->getSection(amd::OclElf::LLVMIR, §ion, &sz) && section && sz > 0) return false;
@@ -1542,7 +1567,7 @@ bool ClBinary::isSPIR() const {
}
bool ClBinary::isSPIRV() const {
- char* section = NULL;
+ char* section = nullptr;
size_t sz = 0;
if (elfIn_->getSection(amd::OclElf::SPIRV, §ion, &sz) && section && sz > 0) {
diff --git a/projects/clr/rocclr/runtime/device/device.hpp b/projects/clr/rocclr/runtime/device/device.hpp
index 13b7ac451b..be0ccf00f4 100644
--- a/projects/clr/rocclr/runtime/device/device.hpp
+++ b/projects/clr/rocclr/runtime/device/device.hpp
@@ -906,10 +906,10 @@ class Program : public amd::HeapObject {
bool initClBinary(const char* binaryIn, size_t size);
//! Initialize Binary
- virtual bool initClBinary() = 0;
+ virtual bool initClBinary();
//! Release the Binary
- virtual void releaseClBinary() = 0;
+ void releaseClBinary();
//! return target info
virtual const aclTargetInfo& info(const char* str = "") = 0;
@@ -943,7 +943,7 @@ class ClBinary : public amd::HeapObject {
};
//! Constructor
- ClBinary(const amd::Device& dev, BinaryImageFormat bifVer = BIF_VERSION2);
+ ClBinary(const amd::Device& dev, BinaryImageFormat bifVer = BIF_VERSION3);
//! Destructor
virtual ~ClBinary();
@@ -963,7 +963,7 @@ class ClBinary : public amd::HeapObject {
void resetElfOut();
//! Set elf header information
- virtual bool setElfTarget() = 0;
+ virtual bool setElfTarget();
// class used in for loading images in new format
amd::OclElf* elfIn() { return elfIn_; }
diff --git a/projects/clr/rocclr/runtime/device/gpu/gpubinary.hpp b/projects/clr/rocclr/runtime/device/gpu/gpubinary.hpp
index 071d6fda98..35179d49f7 100644
--- a/projects/clr/rocclr/runtime/device/gpu/gpubinary.hpp
+++ b/projects/clr/rocclr/runtime/device/gpu/gpubinary.hpp
@@ -41,7 +41,8 @@ class ClBinary : public device::ClBinary {
#pragma pack(pop)
//! Constructor
- ClBinary(const NullDevice& dev) : device::ClBinary(dev) {}
+ ClBinary(const NullDevice& dev, BinaryImageFormat bifVer = BIF_VERSION2)
+ : device::ClBinary(dev, bifVer) {}
//! Destructor
~ClBinary() {}
@@ -91,36 +92,6 @@ class ClBinary : public device::ClBinary {
const NullDevice& dev() const { return static_cast(dev_); }
};
-class ClBinaryHsa : public device::ClBinary {
- public:
- ClBinaryHsa(const Device& dev, BinaryImageFormat bifVer = BIF_VERSION3)
- : device::ClBinary(dev, bifVer) {}
-
- //! Destructor
- ~ClBinaryHsa() {}
-
-
- protected:
- bool setElfTarget() {
- uint32_t target = static_cast(21); // dev().calTarget());
- assert(((0xFFFF8000 & target) == 0) && "ASIC target ID >= 2^15");
- uint16_t elf_target = (uint16_t)(0x7FFF & target);
- return elfOut()->setTarget(elf_target, amd::OclElf::CAL_PLATFORM);
- return true;
- }
-
- private:
- //! Disable default copy constructor
- ClBinaryHsa(const ClBinaryHsa&);
-
- //! Disable default operator=
- ClBinaryHsa& operator=(const ClBinaryHsa&);
-
- //! Returns the HSA device for this object
- const Device& dev() const { return static_cast(dev_); }
-};
-
-
} // namespace gpu
#endif // GPUBINARY_HPP_
diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp
index 8cfc98f093..59ea5d034d 100644
--- a/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp
+++ b/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp
@@ -834,13 +834,6 @@ bool NullProgram::initClBinary() {
return true;
}
-void NullProgram::releaseClBinary() {
- if (clBinary_ != NULL) {
- delete clBinary_;
- clBinary_ = NULL;
- }
-}
-
bool NullProgram::loadBinary(bool* hasRecompiled) {
if (!clBinary()->loadKernels(*this, hasRecompiled)) {
clear();
@@ -2087,23 +2080,6 @@ bool HSAILProgram::linkImpl(amd::option::Options* options) {
bool HSAILProgram::createBinary(amd::option::Options* options) { return true; }
-bool HSAILProgram::initClBinary() {
- if (clBinary_ == NULL) {
- clBinary_ = new ClBinaryHsa(static_cast(device()));
- if (clBinary_ == NULL) {
- return false;
- }
- }
- return true;
-}
-
-void HSAILProgram::releaseClBinary() {
- if (clBinary_ != NULL) {
- delete clBinary_;
- clBinary_ = NULL;
- }
-}
-
std::string HSAILProgram::hsailOptions() {
std::string hsailOptions;
// Set options for the standard device specific options
diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuprogram.hpp b/projects/clr/rocclr/runtime/device/gpu/gpuprogram.hpp
index aed46c4f52..49ae305815 100644
--- a/projects/clr/rocclr/runtime/device/gpu/gpuprogram.hpp
+++ b/projects/clr/rocclr/runtime/device/gpu/gpuprogram.hpp
@@ -114,8 +114,6 @@ class NullProgram : public device::Program {
// Initialize Binary for GPU
virtual bool initClBinary();
- // Release Binary for GPU
- virtual void releaseClBinary();
//! Returns global constant buffers
const std::vector& glbCb() const { return glbCb_; }
@@ -520,12 +518,6 @@ class HSAILProgram : public device::Program {
virtual bool createBinary(amd::option::Options* options);
- //! Initialize Binary
- virtual bool initClBinary();
-
- //! Release the Binary
- virtual void releaseClBinary();
-
virtual const aclTargetInfo& info(const char* str = "");
virtual bool isElf(const char* bin) const {
@@ -533,14 +525,6 @@ class HSAILProgram : public device::Program {
// return false;
}
- //! Returns the binary
- // This should ensure that the binary is updated with all the kernels
- // ClBinary& clBinary() { return binary_; }
- ClBinary* clBinary() { return static_cast(device::Program::clBinary()); }
- const ClBinary* clBinary() const {
- return static_cast(device::Program::clBinary());
- }
-
private:
//! Disable default copy constructor
HSAILProgram(const HSAILProgram&);
diff --git a/projects/clr/rocclr/runtime/device/pal/palbinary.cpp b/projects/clr/rocclr/runtime/device/pal/palbinary.cpp
deleted file mode 100644
index a158d4f08f..0000000000
--- a/projects/clr/rocclr/runtime/device/pal/palbinary.cpp
+++ /dev/null
@@ -1,4 +0,0 @@
-//
-// Copyright (c) 2015 Advanced Micro Devices, Inc. All rights reserved.
-//
-namespace pal {} // namespace pal
diff --git a/projects/clr/rocclr/runtime/device/pal/palbinary.hpp b/projects/clr/rocclr/runtime/device/pal/palbinary.hpp
deleted file mode 100644
index fe96637745..0000000000
--- a/projects/clr/rocclr/runtime/device/pal/palbinary.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Copyright (c) 2015 Advanced Micro Devices, Inc. All rights reserved.
-//
-#pragma once
-
-#include "top.hpp"
-#include "device/pal/paldevice.hpp"
-#include "device/pal/palkernel.hpp"
-
-namespace pal {
-
-class ClBinaryHsa : public device::ClBinary {
- public:
- ClBinaryHsa(const Device& dev, BinaryImageFormat bifVer = BIF_VERSION3)
- : device::ClBinary(dev, bifVer) {}
-
- //! Destructor
- ~ClBinaryHsa() {}
-
-
- protected:
- bool setElfTarget() {
- uint32_t target = static_cast(21); // dev().calTarget());
- assert(((0xFFFF8000 & target) == 0) && "ASIC target ID >= 2^15");
- uint16_t elf_target = (uint16_t)(0x7FFF & target);
- return elfOut()->setTarget(elf_target, amd::OclElf::CAL_PLATFORM);
- return true;
- }
-
- private:
- //! Disable default copy constructor
- ClBinaryHsa(const ClBinaryHsa&);
-
- //! Disable default operator=
- ClBinaryHsa& operator=(const ClBinaryHsa&);
-
- //! Returns the HSA device for this object
- const Device& dev() const { return static_cast(dev_); }
-};
-
-} // namespace pal
diff --git a/projects/clr/rocclr/runtime/device/pal/palprogram.cpp b/projects/clr/rocclr/runtime/device/pal/palprogram.cpp
index d72aca8412..aaee299398 100644
--- a/projects/clr/rocclr/runtime/device/pal/palprogram.cpp
+++ b/projects/clr/rocclr/runtime/device/pal/palprogram.cpp
@@ -704,23 +704,6 @@ bool HSAILProgram::linkImpl(amd::option::Options* options) {
bool HSAILProgram::createBinary(amd::option::Options* options) { return true; }
-bool HSAILProgram::initClBinary() {
- if (clBinary_ == nullptr) {
- clBinary_ = new ClBinaryHsa(static_cast(device()));
- if (clBinary_ == nullptr) {
- return false;
- }
- }
- return true;
-}
-
-void HSAILProgram::releaseClBinary() {
- if (clBinary_ != nullptr) {
- delete clBinary_;
- clBinary_ = nullptr;
- }
-}
-
std::string HSAILProgram::hsailOptions(amd::option::Options* options) {
std::string hsailOptions;
diff --git a/projects/clr/rocclr/runtime/device/pal/palprogram.hpp b/projects/clr/rocclr/runtime/device/pal/palprogram.hpp
index 0c472b2699..935a0de86f 100644
--- a/projects/clr/rocclr/runtime/device/pal/palprogram.hpp
+++ b/projects/clr/rocclr/runtime/device/pal/palprogram.hpp
@@ -4,7 +4,6 @@
#pragma once
#include "device/pal/palkernel.hpp"
-#include "device/pal/palbinary.hpp"
#include "amd_hsa_loader.hpp"
#if defined(WITH_LIGHTNING_COMPILER)
@@ -216,12 +215,6 @@ class HSAILProgram : public device::Program {
virtual bool createBinary(amd::option::Options* options);
- //! Initialize Binary
- virtual bool initClBinary();
-
- //! Release the Binary
- virtual void releaseClBinary();
-
virtual const aclTargetInfo& info(const char* str = "");
virtual bool isElf(const char* bin) const {
@@ -229,14 +222,6 @@ class HSAILProgram : public device::Program {
// return false;
}
- //! Returns the binary
- // This should ensure that the binary is updated with all the kernels
- // ClBinary& clBinary() { return binary_; }
- ClBinaryHsa* clBinary() { return static_cast(device::Program::clBinary()); }
- const ClBinaryHsa* clBinary() const {
- return static_cast(device::Program::clBinary());
- }
-
private:
//! Disable default copy constructor
HSAILProgram(const HSAILProgram&);
diff --git a/projects/clr/rocclr/runtime/device/rocm/rocbinary.hpp b/projects/clr/rocclr/runtime/device/rocm/rocbinary.hpp
deleted file mode 100644
index 4ec31d676f..0000000000
--- a/projects/clr/rocclr/runtime/device/rocm/rocbinary.hpp
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// Copyright (c) 2009 Advanced Micro Devices, Inc. All rights reserved.
-//
-#pragma once
-
-#include "top.hpp"
-#include "rocdevice.hpp"
-
-#ifndef WITHOUT_HSA_BACKEND
-
-namespace roc {
-
-typedef std::unordered_map NameKernelMap;
-
-class ClBinary : public device::ClBinary {
- public:
- ClBinary(const Device& dev, BinaryImageFormat bifVer = BIF_VERSION3)
- : device::ClBinary(dev, bifVer) {}
-
- //! Destructor
- ~ClBinary() {}
-
-
- protected:
- bool setElfTarget() {
- uint32_t target = static_cast(21); // dev().calTarget());
- assert(((0xFFFF8000 & target) == 0) && "ASIC target ID >= 2^15");
- uint16_t elf_target = (uint16_t)(0x7FFF & target);
- return elfOut()->setTarget(elf_target, amd::OclElf::CAL_PLATFORM);
- }
-
- private:
- //! Disable default copy constructor
- ClBinary(const ClBinary&);
-
- //! Disable default operator=
- ClBinary& operator=(const ClBinary&);
-
- //! Returns the HSA device for this object
- const Device& dev() const { return static_cast(dev_); }
-};
-
-} // namespace roc
-
-#endif // WITHOUT_HSA_BACKEND
diff --git a/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp b/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp
index 0cbea64166..c250fac915 100644
--- a/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp
+++ b/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp
@@ -167,23 +167,6 @@ bool Program::finiBuild(bool isBuildGood) {
return device::Program::finiBuild(isBuildGood);
}
-bool Program::initClBinary() {
- if (clBinary_ == nullptr) {
- clBinary_ = new ClBinary(static_cast(device()));
- if (clBinary_ == nullptr) {
- return false;
- }
- }
- return true;
-}
-
-void Program::releaseClBinary() {
- if (clBinary_ != nullptr) {
- delete clBinary_;
- clBinary_ = nullptr;
- }
-}
-
aclType Program::getNextCompilationStageFromBinary(amd::option::Options* options) {
aclType continueCompileFrom = ACL_TYPE_DEFAULT;
binary_t binary = this->binary();
@@ -399,7 +382,7 @@ HSAILProgram::~HSAILProgram() {
}
bool HSAILProgram::createBinary(amd::option::Options* options) {
- return false;
+ return true;
}
bool HSAILProgram::saveBinaryAndSetType(type_t type) {
diff --git a/projects/clr/rocclr/runtime/device/rocm/rocprogram.hpp b/projects/clr/rocclr/runtime/device/rocm/rocprogram.hpp
index 9feae26df8..e0c893b839 100644
--- a/projects/clr/rocclr/runtime/device/rocm/rocprogram.hpp
+++ b/projects/clr/rocclr/runtime/device/rocm/rocprogram.hpp
@@ -5,7 +5,6 @@
#ifndef WITHOUT_HSA_BACKEND
-#include "rocbinary.hpp"
#include "acl.h"
#include
#include
@@ -68,15 +67,8 @@ class Program : public device::Program {
*/
int compileBinaryToHSAIL(amd::option::Options* options //!< options for compilation
);
-
virtual bool createBinary(amd::option::Options* options) = 0;
- //! Initialize Binary
- virtual bool initClBinary();
-
- //! Release the Binary
- virtual void releaseClBinary();
-
virtual const aclTargetInfo& info(const char* str = "") { return info_; }
virtual bool isElf(const char* bin) const {
@@ -84,14 +76,6 @@ class Program : public device::Program {
// return false;
}
- //! Returns the binary
- // This should ensure that the binary is updated with all the kernels
- // ClBinary& clBinary() { return binary_; }
- ClBinary* clBinary() { return static_cast(device::Program::clBinary()); }
- const ClBinary* clBinary() const {
- return static_cast(device::Program::clBinary());
- }
-
protected:
/* \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,