P4 to Git Change 1208929 by emankov@em-hsa-amd on 2015/11/09 10:49:06
SWDEV-77584 - ORCA RT: Preparations for enabling HSAIL on OpenCL 1.2 by default. Integrate new algorithm for device program choice. [Reasons] 1. Make the switching change as less as possible. 2. Give a chance to test HSA_foundation device work on OCL 1.2 beforehand (asked by Nikolay). Almost already reviewed: http://ocltc.amd.com/reviews/r/8850/ Additionally: 1. Linking logic was changed: if the target of one of the binaries is hsail-(64) linking goes through HSAIL, otherwise - through AMDIL. Previously -cl-std=CL2.0 in any of the linking binaries was a criterion for HSAIL, what will be wrong for HSAIL 1.2 after switching. -clang & -edg options are set now to distinguish the path while linking. 2. -cl-std=CL2.0 as a criterion for HSAIL was returned back in isHSAILProgram() method; -clang & -edg options were also added as a criterion. [ToDo] After enabling HSAIL by default remove -cl-std, -clang & -edg checks from the code. [Testing] Pre-checkin http://ocltc.amd.com:8111/viewModification.html?modId=61929&personal=true&buildTypeId=&tab=vcsModificationBuilds&show_all_builds=true [Reviewers] German Andryeyev, Nikolay Haustov Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_program.cpp#39 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/cpu/cpudevice.cpp#279 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/cpu/cpudevice.hpp#93 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#261 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#534 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.hpp#154 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadevice.cpp#47 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadevice.hpp#22 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/program.cpp#76 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/program.hpp#38 edit
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "device/gpu/gpudevice.hpp"
|
||||
#include "utils/flags.hpp"
|
||||
#include "utils/versions.hpp"
|
||||
#include "utils/options.hpp"
|
||||
#include "thread/monitor.hpp"
|
||||
#include "device/gpu/gpuprogram.hpp"
|
||||
#include "device/gpu/gpubinary.hpp"
|
||||
@@ -204,21 +205,79 @@ NullDevice::create(CALtarget target)
|
||||
return true;
|
||||
}
|
||||
|
||||
device::Program*
|
||||
NullDevice::createProgram(bool hsail)
|
||||
{
|
||||
device::Program* nullProgram;
|
||||
if (settings().hsail_ || hsail) {
|
||||
nullProgram = new HSAILProgram(*this);
|
||||
bool
|
||||
NullDevice::isHsailProgram(amd::option::Options* options) {
|
||||
bool isCIPlus = settings().ciPlus_;
|
||||
bool isHSAILcapable = settings().hsail_;
|
||||
bool isBlit = false;
|
||||
bool isSPIRV = false;
|
||||
bool isLangExt = false;
|
||||
bool isClang = false;
|
||||
bool isEDG = false;
|
||||
bool isLegacy = false;
|
||||
bool isOCL20 = false;
|
||||
std::vector<amd::option::Options*> optvec;
|
||||
bool isInputOptions = false;
|
||||
if (options != NULL) {
|
||||
optvec.push_back(options);
|
||||
isInputOptions = true;
|
||||
}
|
||||
else {
|
||||
nullProgram = new NullProgram(*this);
|
||||
amd::option::Options parsedOptions;
|
||||
if (!amd::Program::ParseAllOptions("", parsedOptions)) {
|
||||
return NULL;
|
||||
}
|
||||
if (nullProgram == NULL) {
|
||||
LogError("Memory allocation has failed!");
|
||||
optvec.push_back(&parsedOptions);
|
||||
for (auto const op : optvec) {
|
||||
if (op->oVariables->clInternalKernel) {
|
||||
isBlit = true;
|
||||
continue;
|
||||
}
|
||||
if (!isLegacy) {
|
||||
isLegacy = op->oVariables->Legacy;
|
||||
}
|
||||
if (!isLangExt) {
|
||||
isLangExt = op->isCStrOptionsEqual(op->oVariables->XLang, "clc++") ||
|
||||
op->isCStrOptionsEqual(op->oVariables->XLang, "spir");
|
||||
}
|
||||
// Checks Frontend option only from input *options, not from Env,
|
||||
// because they might be only calculated by RT based on the binaries to link.
|
||||
// -frontend is being queried now instead of -cl-std=CL2.0, because the last one
|
||||
// is not an indicator for HSAIL path anymore.
|
||||
// TODO: Revise these binary's target checks
|
||||
// and possibly remove them after switching to HSAIL by default.
|
||||
if (isInputOptions) {
|
||||
if (!isClang) {
|
||||
isClang = op->isCStrOptionsEqual(op->oVariables->Frontend, "clang");
|
||||
}
|
||||
if (!isEDG) {
|
||||
isEDG = op->isCStrOptionsEqual(op->oVariables->Frontend, "edg");
|
||||
}
|
||||
}
|
||||
if (!isSPIRV) {
|
||||
isSPIRV = op->oVariables->BinaryIsSpirv;
|
||||
}
|
||||
// TODO: Remove isOCL20 related code from this function along with switching HSAIL by default
|
||||
if (isCIPlus && amd::Program::GetOclCVersion(op->oVariables->CLStd) >= 20) {
|
||||
isOCL20 = true;
|
||||
}
|
||||
isInputOptions = false;
|
||||
}
|
||||
if (isSPIRV || (isBlit && isCIPlus) || isClang || isOCL20) {
|
||||
return true;
|
||||
}
|
||||
if (isLegacy || !isHSAILcapable || isEDG || isLangExt) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return nullProgram;
|
||||
device::Program*
|
||||
NullDevice::createProgram(amd::option::Options* options)
|
||||
{
|
||||
if (isHsailProgram(options)) {
|
||||
return new HSAILProgram(*this);
|
||||
}
|
||||
return new NullProgram(*this);
|
||||
}
|
||||
|
||||
void NullDevice::fillDeviceInfo(
|
||||
@@ -985,17 +1044,17 @@ Device::initializeHeapResources()
|
||||
}
|
||||
|
||||
// Delay compilation due to brig_loader memory allocation
|
||||
if (settings().hsail_ || (settings().oclVersion_ == OpenCL20)) {
|
||||
const char* scheduler = NULL;
|
||||
if (settings().ciPlus_) {
|
||||
const char* CL20extraBlits = NULL;
|
||||
const char* ocl20 = NULL;
|
||||
if (settings().oclVersion_ == OpenCL20) {
|
||||
scheduler = SchedulerSourceCode;
|
||||
CL20extraBlits = SchedulerSourceCode;
|
||||
ocl20 = "-cl-std=CL2.0";
|
||||
}
|
||||
blitProgram_ = new BlitProgram(context_);
|
||||
// Create blit programs
|
||||
if (blitProgram_ == NULL ||
|
||||
!blitProgram_->create(this, scheduler, ocl20)) {
|
||||
!blitProgram_->create(this, CL20extraBlits, ocl20)) {
|
||||
delete blitProgram_;
|
||||
blitProgram_ = NULL;
|
||||
LogError("Couldn't create blit kernels!");
|
||||
@@ -1066,20 +1125,12 @@ Device::createVirtualDevice(
|
||||
}
|
||||
|
||||
device::Program*
|
||||
Device::createProgram(bool hsail)
|
||||
Device::createProgram(amd::option::Options* options)
|
||||
{
|
||||
device::Program* gpuProgram;
|
||||
if (settings().hsail_ || hsail) {
|
||||
gpuProgram = new HSAILProgram(*this);
|
||||
if (isHsailProgram(options)) {
|
||||
return new HSAILProgram(*this);
|
||||
}
|
||||
else {
|
||||
gpuProgram = new Program(*this);
|
||||
}
|
||||
if (gpuProgram == NULL) {
|
||||
LogError("We failed memory allocation for program!");
|
||||
}
|
||||
|
||||
return gpuProgram;
|
||||
return new Program(*this);
|
||||
}
|
||||
|
||||
//! Requested devices list as configured by the GPU_DEVICE_ORDINAL
|
||||
|
||||
@@ -66,8 +66,8 @@ public:
|
||||
amd::CommandQueue* queue = NULL
|
||||
) { return NULL; }
|
||||
|
||||
//! Compile the given source code.
|
||||
virtual device::Program* createProgram(bool hsail = false);
|
||||
//! Create the device program.
|
||||
virtual device::Program* createProgram(amd::option::Options* options = NULL);
|
||||
|
||||
//! Just returns NULL for the dummy device
|
||||
virtual device::Memory* createMemory(amd::Memory& owner) const { return NULL; }
|
||||
@@ -120,6 +120,10 @@ protected:
|
||||
CALtarget calTarget_; //!< GPU device identifier
|
||||
const AMDDeviceInfo* hwInfo_; //!< Device HW info structure
|
||||
|
||||
//! Answer the question: "Should HSAIL Program be created?",
|
||||
//! based on the given options.
|
||||
bool isHsailProgram(amd::option::Options* options = NULL);
|
||||
|
||||
//! Fills OpenCL device info structure
|
||||
void fillDeviceInfo(
|
||||
const CALdeviceattribs& calAttr, //!< CAL device attributes info
|
||||
@@ -430,7 +434,7 @@ public:
|
||||
) const;
|
||||
|
||||
//! Create the device program.
|
||||
virtual device::Program* createProgram(bool hsail = false);
|
||||
virtual device::Program* createProgram(amd::option::Options* options = NULL);
|
||||
|
||||
//! Attempt to bind with external graphics API's device/context
|
||||
virtual bool bindExternalDevice(
|
||||
|
||||
مرجع در شماره جدید
Block a user