P4 to Git Change 1365943 by lmoriche@lmoriche_opencl_dev on 2017/01/25 11:37:20

SWDEV-102726 - [OCL-LC-ROCm] Open source OpenCL Runtime
	- Cleanups: Remove CL_HSA_ENABLED/DISABLED_AMD.

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_context.cpp#52 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_device.cpp#60 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_ext.h#13 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_ext.h#28 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_ext.h#6 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/appprofile.cpp#15 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/appprofile.hpp#10 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#208 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#283 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocappprofile.cpp#4 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#36 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.hpp#14 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#53 edit
This commit is contained in:
foreman
2017-01-25 11:44:06 -05:00
parent c3b34aeaa7
commit aae258198d
8 changed files with 24 additions and 192 deletions
+1 -26
View File
@@ -131,9 +131,7 @@ bool ADL::init()
#endif //BRAHMA
AppProfile::AppProfile(): hsaDeviceHint_(0),
gpuvmHighAddr_(false),
noHsaInit_(false),
AppProfile::AppProfile(): gpuvmHighAddr_(false),
profileOverridesAllSettings_(false)
{
appFileName_ = amd::Os::getAppFileName();
@@ -171,29 +169,6 @@ bool AppProfile::init()
return true;
}
cl_device_type AppProfile::ApplyHsaDeviceHintFlag(const cl_device_type& type)
{
cl_device_type ret_type = type;
bool isHsaHintSpecified = (type & (CL_HSA_ENABLED_AMD|CL_HSA_DISABLED_AMD))
!= 0;
// Apply app profile hsa device hint only if
// HSA_RUNTIME is not set/defined *and*
// no hsa hint flag already specified.
// OR
// Profile overridess all other settings (HSA_RUNTIME and hint flags).
if ( profileOverridesAllSettings_
|| (flagIsDefault(HSA_RUNTIME) && !isHsaHintSpecified)) {
// Clear current hsa hint.
ret_type = type & ~(CL_HSA_ENABLED_AMD | CL_HSA_DISABLED_AMD);
// Apply hsa hint from app profile.
return (ret_type | hsaDeviceHint_);
}
// Do not apply app profile hsa device hint.
return type;
}
bool AppProfile::ParseApplicationProfile()
{
ADLApplicationProfile* pProfile = NULL;
-5
View File
@@ -16,8 +16,6 @@ public:
bool init();
cl_device_type ApplyHsaDeviceHintFlag(const cl_device_type& type);
bool IsHsaInitDisabled() { return noHsaInit_; }
const std::string& GetBuildOptsAppend() const { return buildOptsAppend_; }
protected:
enum DataTypes
@@ -41,10 +39,7 @@ protected:
virtual bool ParseApplicationProfile();
cl_device_type hsaDeviceHint_; // valid values: CL_HSA_ENABLED_AMD
// or CL_HSA_DISABLED_AMD
bool gpuvmHighAddr_; // Currently not used.
bool noHsaInit_; // Do not even initialize HSA.
bool profileOverridesAllSettings_; // Overrides hint flags and env.var.
std::string buildOptsAppend_;
};
+15 -131
View File
@@ -61,14 +61,8 @@ extern const char* BlitSourceCode;
namespace amd {
std::vector<Device*> *Device::devices_ = NULL;
bool Device::isHsaDeviceAvailable_ = false;
bool Device::isGpuDeviceAvailable_ = false;
AppProfile Device::appProfile_;
#if defined(WITH_HSA_DEVICE)
AppProfile* Device::rocAppProfile_ = NULL;
#endif
amd::Monitor SvmManager::AllocatedLock_("Guards SVM allocation list");
std::map<uintptr_t, amd::Memory*> SvmManager::svmBufferMap_;
@@ -175,20 +169,17 @@ Device::init()
// GPU stack. The order of initialization is signiicant and if changed
// amd::Device::registerDevice() must be accordingly modified.
#if defined(WITH_HSA_DEVICE)
rocAppProfile_ = rocCreateAppProfile();
if (rocAppProfile_ && !rocAppProfile_->IsHsaInitDisabled()) {
// Return value of roc::Device::init()
// If returned false, error initializing HSA stack.
// If returned true, either HSA not installed or HSA stack
// successfully initialized.
if (!roc::Device::init() ) {
// abort() commentted because this is the only indication
// that KFD is not installed.
// Ignore the failure and assume KFD is not installed.
//abort();
}
ret |= roc::NullDevice::init();
// Return value of roc::Device::init()
// If returned false, error initializing HSA stack.
// If returned true, either HSA not installed or HSA stack
// successfully initialized.
if (!roc::Device::init() ) {
// abort() commentted because this is the only indication
// that KFD is not installed.
// Ignore the failure and assume KFD is not installed.
//abort();
}
ret |= roc::NullDevice::init();
#endif // WITH_HSA_DEVICE
#if defined(WITH_GPU_DEVICE)
if (GPU_ENABLE_PAL != 1) {
@@ -217,11 +208,7 @@ Device::tearDown()
delete devices_;
}
#if defined(WITH_HSA_DEVICE)
if (rocAppProfile_ && !rocAppProfile_->IsHsaInitDisabled()) {
roc::Device::tearDown();
delete rocAppProfile_;
rocAppProfile_ = NULL;
}
roc::Device::tearDown();
#endif // WITH_HSA_DEVICE
#if defined(WITH_GPU_DEVICE)
if (GPU_ENABLE_PAL != 1) {
@@ -305,54 +292,21 @@ Device::isAncestor(const Device* sub) const
return false;
}
bool Device::IsHsaCapableDevice() {
static bool init = false;
typedef std::vector<std::string> ListType;
typedef std::vector<std::string>::const_iterator ListIterType;
static ListType hsaNames;
if (!init) {
hsaNames.push_back("Spectre");
hsaNames.push_back("Spooky");
init = true;
}
for (ListIterType itr = hsaNames.begin(); itr != hsaNames.end(); itr++) {
if ((*itr) == info_.name_ // If name is in list then HSA capable.
|| (info_.type_ & CL_HSA_ENABLED_AMD)) { // HSA enabled is HSA capable.
return true;
}
}
return false;
}
void
Device::registerDevice()
{
assert(Runtime::singleThreaded() && "this is not thread-safe");
static bool nonhsaDefaultIsAssigned = false;
static bool hsaDefaultIsAssigned = false;
static bool defaultIsAssigned = false;
if (devices_ == NULL) {
devices_ = new std::vector<Device*>;
}
if (info_.available_) {
bool dvHsaEnabled = (info_.type_ & CL_HSA_ENABLED_AMD) != 0;
if (IsHsaCapableDevice()) {
if (dvHsaEnabled && !hsaDefaultIsAssigned) {
hsaDefaultIsAssigned = true;
info_.type_ |= CL_DEVICE_TYPE_DEFAULT;
isHsaDeviceAvailable_ = true;
}
}
if (!dvHsaEnabled && !nonhsaDefaultIsAssigned) {
nonhsaDefaultIsAssigned = true;
if (!defaultIsAssigned) {
defaultIsAssigned = true;
info_.type_ |= CL_DEVICE_TYPE_DEFAULT;
isGpuDeviceAvailable_ = true;
}
}
devices_->push_back(this);
@@ -415,74 +369,12 @@ Device::findMemoryFromVA(const void* ptr, size_t* offset) const
return nullptr;
}
bool IsHsaRequested(cl_device_type requestedType) {
// Depending on HSA_RUNTIME and hint flags CL_HSA_XXXXX_AMD,
// decide to use Gpu or HSA device.
if (requestedType == CL_DEVICE_TYPE_ALL) {
// hint flags are masked by ALL (0xFFFFFFFF) so HSA_RUNTIME decides.
return HSA_RUNTIME;
}
bool hsabit = (requestedType & CL_HSA_ENABLED_AMD) != 0;
bool nonhsabit = (requestedType & CL_HSA_DISABLED_AMD) != 0;
// Condition where both hsabit and nonhsabit set
// is checked in getDevices() and
// numDevices(). So that condition will never occur in this code path
if (hsabit ^ nonhsabit) {
// Eithere ENABLE or DISABLE HSA specified via hint flags.
return (requestedType & CL_HSA_ENABLED_AMD) != 0;
} else {
// Niethre ENABLE nor DISABLE HSA specified via hint flags.
return HSA_RUNTIME;
}
}
bool Device::IsTypeMatching(cl_device_type type, bool offlineDevices) {
if (!(isOnline() || offlineDevices)) {
return false;
}
cl_device_type hintAndDefaultMask = (CL_HSA_ENABLED_AMD
| CL_HSA_DISABLED_AMD | CL_DEVICE_TYPE_DEFAULT);
if ((info_.type_ & type & ~hintAndDefaultMask)
|| (info_.type_ & type & CL_DEVICE_TYPE_DEFAULT)) {
// HSA and ORCA stack will never be running side-by-side.
// Hence device selection is mute.
// Instead of removing the code just returning true always.
// To reinstate, simply remove this "return true;" statement.
return true;
bool dvHsaEnabled = (info_.type_ & CL_HSA_ENABLED_AMD) != 0;
bool isHsaReq = IsHsaRequested(type);
// If not HSA capable device then always a match.
if (!IsHsaCapableDevice()) {
return true;
}
// ASSUMPTION: In the following two if statements,
// assumption is, either HSA or GPU stacks always available
// for HSA capable devcie.
// Requested stack not available - ignore hint.
if (isHsaReq && !isHsaDeviceAvailable_) {
return isGpuDeviceAvailable_;
}
// Requested stack not available - ignore hint.
if (!isHsaReq && !isGpuDeviceAvailable_) {
return isHsaDeviceAvailable_;
}
// If HSA capable device then request type(hsa or not) must
// match device hsa enablement(HSA enabled or not).
if (!(dvHsaEnabled ^ isHsaReq)) {
return true;
}
}
return false;
return (info_.type_ & type) != 0;
}
std::vector<Device*>
@@ -494,10 +386,6 @@ Device::getDevices(cl_device_type type, bool offlineDevices)
return result;
}
#if defined(WITH_HSA_DEVICE)
type = rocAppProfile_->ApplyHsaDeviceHintFlag(type);
#endif
// Create the list of available devices
for (device_iterator it = devices_->begin(); it != devices_->end(); ++it) {
// Check if the device type is matched
@@ -518,10 +406,6 @@ Device::numDevices(cl_device_type type, bool offlineDevices)
return 0;
}
#if defined(WITH_HSA_DEVICE)
type = rocAppProfile_->ApplyHsaDeviceHintFlag(type);
#endif
for (device_iterator it = devices_->begin(); it != devices_->end(); ++it) {
// Check if the device type is matched
if ((*it)->IsTypeMatching(type, offlineDevices)) {
+1 -5
View File
@@ -1636,8 +1636,7 @@ public:
//! Return this device's type.
cl_device_type type() const {
return info().type_ & ~(CL_DEVICE_TYPE_DEFAULT | CL_HSA_ENABLED_AMD
| CL_HSA_DISABLED_AMD);
return info().type_ & ~(CL_DEVICE_TYPE_DEFAULT);
}
//! Create sub-devices according to the given partition scheme.
@@ -1812,14 +1811,11 @@ protected:
HwDebugManager* hwDebugMgr_; //!< Hardware Debug manager
private:
bool IsHsaCapableDevice();
bool IsTypeMatching(cl_device_type type, bool offlineDevices);
#if defined(WITH_HSA_DEVICE)
static AppProfile* rocAppProfile_;
#endif
static bool isHsaDeviceAvailable_;
static bool isGpuDeviceAvailable_;
typedef std::vector<Device*>::iterator device_iterator;
static std::vector<Device*>* devices_; //!< All known devices
@@ -33,26 +33,10 @@ bool AppProfile::ParseApplicationProfile()
std::transform(appFileName_.begin(), appFileName_.end(), appFileName_.begin(), ::tolower);
if (appFileName_.compare(appName) == 0 ) {
hsaDeviceHint_ = CL_HSA_DISABLED_AMD;
gpuvmHighAddr_ = false;
noHsaInit_ = true;
profileOverridesAllSettings_ = true;
}
// Setting both bits is invalid, make it niether.
if (hsaDeviceHint_ & CL_HSA_ENABLED_AMD
&& hsaDeviceHint_ & CL_HSA_DISABLED_AMD) {
hsaDeviceHint_ = 0;
}
if (noHsaInit_) {
// If no HSA initialization, then force hint flag to non-HSA device.
// Even if this is not forced, the device selection logic will endure it.
// After all hint flags are treated as hint only - depending on
// availibility.
hsaDeviceHint_ = CL_HSA_DISABLED_AMD;
}
return true;
}
+5 -5
View File
@@ -159,7 +159,7 @@ bool NullDevice::create(const AMDDeviceInfo& deviceInfo) {
online_ = false;
deviceInfo_ = deviceInfo;
// Mark the device as GPU type
info_.type_ = CL_DEVICE_TYPE_GPU | CL_HSA_ENABLED_AMD;
info_.type_ = CL_DEVICE_TYPE_GPU;
info_.vendorId_ = 0x1002;
settings_ = new Settings();
@@ -173,7 +173,7 @@ bool NullDevice::create(const AMDDeviceInfo& deviceInfo) {
info_.extensions_ = getExtensionString();
info_.maxWorkGroupSize_ = hsaSettings->maxWorkGroupSize_;
::strcpy(info_.vendor_, "Advanced Micro Devices, Inc.");
info_.oclcVersion_ = "OpenCL C " OPENCL_VERSION_STR " ";
info_.oclcVersion_ = "OpenCL C " IF(IS_LIGHTNING,OPENCL_VERSION_STR,"1.2") " ";
strcpy(info_.driverVersion_, "1.0 Provisional (hsa)");
info_.version_ = "OpenCL " OPENCL_VERSION_STR " ";
return true;
@@ -296,7 +296,7 @@ bool NullDevice::init() {
#if !defined(WITH_LIGHTNING_COMPILER)
//If there is an HSA enabled device online then skip any offline device
std::vector<Device*> devices;
devices = getDevices(CL_DEVICE_TYPE_GPU | CL_HSA_ENABLED_AMD, false);
devices = getDevices(CL_DEVICE_TYPE_GPU, false);
//Load the offline devices
//Iterate through the set of available offline devices
@@ -850,7 +850,7 @@ Device::populateOCLDeviceConstants()
info_.globalMemCacheType_ = CL_READ_WRITE_CACHE;
info_.type_ = CL_DEVICE_TYPE_GPU | CL_HSA_ENABLED_AMD;
info_.type_ = CL_DEVICE_TYPE_GPU;
uint32_t hsa_bdf_id = 0;
if (HSA_STATUS_SUCCESS !=
@@ -1010,7 +1010,7 @@ Device::populateOCLDeviceConstants()
info_.addressBits_ = LP64_SWITCH(32, 64);
info_.maxSamplers_ = 16;
info_.bufferFromImageSupport_ = CL_FALSE;
info_.oclcVersion_ = "OpenCL C " OPENCL_VERSION_STR " ";
info_.oclcVersion_ = "OpenCL C " IF(IS_LIGHTNING,OPENCL_VERSION_STR,"1.2") " ";
uint16_t major, minor;
if (hsa_agent_get_info(_bkendDevice, HSA_AGENT_INFO_VERSION_MAJOR, &major)
+1 -3
View File
@@ -32,8 +32,6 @@
#include <iostream>
#include <vector>
// extern hsa::Runtime* g_hsaruntime;
/*! \addtogroup HSA
* @{
*/
@@ -45,7 +43,7 @@ namespace roc {
* @brief List of environment variables that could be used to
* configure the behavior of Hsa Runtime
*/
#define ENVVAR_HSA_POLL_KERNEL_COMPLETION "HSA_POLL_COMPLETION"
#define ENVVAR_HSA_POLL_KERNEL_COMPLETION "HSA_POLL_COMPLETION"
//! Forward declarations
class Command;
+1 -1
View File
@@ -822,7 +822,7 @@ HSAILProgram::linkImpl_LC(amd::option::Options *options)
ret = dev().cacheCompilation()->compileAndLinkExecutable(C.get(), inputs, out_exec, params, buildLog_);
buildLog_ += C->Output();
if (!ret) {
buildLog_ += "Error: Creating the executable failed: Compiling LLVM IRs to exeutable\n";
buildLog_ += "Error: Creating the executable failed: Compiling LLVM IRs to executable\n";
return false;
}