Skip to content

Commit ef40f8f

Browse files
committed
SWDEV-322039 - remove unknown device warning and fix knownFeatures check
Change-Id: Ife7f4beebaf7ce3c200fb7e9f89b151099ae1fe3
1 parent 91477d8 commit ef40f8f

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed

amd/hipcc/src/hipBin_amd.h

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,17 @@ THE SOFTWARE.
2727
#include "hipBin_util.h"
2828
#include <vector>
2929
#include <string>
30+
#include <unordered_set>
31+
#include <cassert>
3032

3133

32-
// Known HIP target names.
33-
vector<string> knownTargets = { "gfx700", "gfx701", "gfx702", "gfx703",
34-
"gfx704", "gfx705", "gfx801", "gfx802",
35-
"gfx803", "gfx805", "gfx810", "gfx900",
36-
"gfx902", "gfx904", "gfx906", "gfx908",
37-
"gfx909", "gfx90a", "gfx1010", "gfx1011",
38-
"gfx1012", "gfx1030", "gfx1031", "gfx1032" };
39-
34+
// Use (void) to silent unused warnings.
35+
#define assertm(exp, msg) assert(((void)msg, exp))
4036

4137
// Known Features
42-
vector<string> knownFeatures = { "sramecc - " , "sramecc + ",
43-
"xnack - ", "xnack + " };
44-
38+
std::unordered_set
39+
<std::string> knownFeatures = { "sramecc-" , "sramecc+",
40+
"xnack-", "xnack+" };
4541

4642
class HipBinAmd : public HipBinBase {
4743
private:
@@ -1015,25 +1011,21 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
10151011
vector<string> targets = hipBinUtilPtr_->splitStr(targetsStr, ',');
10161012
string GPU_ARCH_OPT = " --offload-arch=";
10171013

1018-
for (unsigned int count = 0; count < targets.size(); count++) {
1019-
string val = targets.at(count);
1014+
for (auto &val : targets) {
10201015
// Ignore 'gfx000' target reported by rocm_agent_enumerator.
10211016
if (val != "gfx000") {
10221017
vector<string> procAndFeatures = hipBinUtilPtr_->splitStr(val, ':');
1023-
int len = static_cast<int>(procAndFeatures.size());
1024-
string procName;
1025-
if (len >= 1 && len <= 3) { //# proc and features
1026-
procName = procAndFeatures.at(0);
1027-
for (int i = 1; i< len; i++) {
1028-
for (unsigned int j = 0; j <knownFeatures.size(); j++) {
1029-
if (procAndFeatures.at(i) == knownFeatures.at(j)) {
1018+
size_t len = procAndFeatures.size();
1019+
// proc and features
1020+
assertm(procAndFeatures.size() >= 1, "Pass the correct device/feature");
1021+
for (size_t i = 1; i < len; i++) {
1022+
// fixme: currently it checks only for validity of the feature string.
1023+
// does not check if the device supports the feature or not
1024+
// e.g. vega10 does not support sramecc
1025+
if (knownFeatures.find(procAndFeatures.at(i)) == knownFeatures.end()) {
10301026
cout << "Warning: The Feature: "<< procAndFeatures.at(i) <<
1031-
"is unknown. Correct compilation is not guaranteed.\n";
1032-
}
1027+
" is unknown. Correct compilation is not guaranteed.\n";
10331028
}
1034-
}
1035-
} else {
1036-
procName = val;
10371029
}
10381030
string GPU_ARCH_ARG;
10391031
GPU_ARCH_ARG = GPU_ARCH_OPT + val;

0 commit comments

Comments
 (0)