P4 to Git Change 1917620 by yaxunl@yaxunl-lc10 on 2019/06/28 07:57:46

SWDEV-145570 - Fix device name mismatch.

	Not only gfx906 can have device name with +xnack etc.
	Other devices e.g. gfx900 could have that too.
	Make the previous fix more generic.

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/hip/hip_platform.cpp#33 edit


[ROCm/hip commit: 97a079826e]
This commit is contained in:
foreman
2019-06-28 08:06:23 -04:00
förälder 9176cd6664
incheckning e07ddab2d9
+11 -6
Visa fil
@@ -66,12 +66,17 @@ hipError_t ihipCreateGlobalVarObj(const char* name, hipModule_t hmod, amd::Memor
static bool isCompatibleCodeObject(const std::string& codeobj_target_id,
const char* device_name) {
// Workaround for gfx906 device name mismatch.
// If bundle target id starts with gfx906 and device name starts with
// gfx906, treat them as match.
return codeobj_target_id.compare(device_name) == 0 ||
(codeobj_target_id.find("gfx906") == 0 &&
std::string(device_name).find("gfx906") == 0);
// Workaround for device name mismatch.
// Device name may contain feature strings delimited by '+', e.g.
// gfx900+xnack. Currently HIP-Clang does not include feature strings
// in code object target id in fat binary. Therefore drop the feature
// strings from device name before comparing it with code object target id.
std::string short_name(device_name);
auto feature_loc = short_name.find('+');
if (feature_loc != std::string::npos) {
short_name.erase(feature_loc);
}
return codeobj_target_id == short_name;
}
// Extracts code objects from fat binary in data for device names given in devices.