@@ -27,21 +27,17 @@ THE SOFTWARE.
27
27
#include " hipBin_util.h"
28
28
#include < vector>
29
29
#include < string>
30
+ #include < unordered_set>
31
+ #include < cassert>
30
32
31
33
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))
40
36
41
37
// 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+ " };
45
41
46
42
class HipBinAmd : public HipBinBase {
47
43
private:
@@ -1015,25 +1011,21 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
1015
1011
vector<string> targets = hipBinUtilPtr_->splitStr (targetsStr, ' ,' );
1016
1012
string GPU_ARCH_OPT = " --offload-arch=" ;
1017
1013
1018
- for (unsigned int count = 0 ; count < targets.size (); count++) {
1019
- string val = targets.at (count);
1014
+ for (auto &val : targets) {
1020
1015
// Ignore 'gfx000' target reported by rocm_agent_enumerator.
1021
1016
if (val != " gfx000" ) {
1022
1017
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 ()) {
1030
1026
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 " ;
1033
1028
}
1034
- }
1035
- } else {
1036
- procName = val;
1037
1029
}
1038
1030
string GPU_ARCH_ARG;
1039
1031
GPU_ARCH_ARG = GPU_ARCH_OPT + val;
@@ -1042,14 +1034,6 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
1042
1034
if (hasHIP) {
1043
1035
HIPCXXFLAGS += GPU_ARCH_ARG;
1044
1036
}
1045
- for (unsigned int j= 0 ; j < knownTargets.size (); j++) {
1046
- // If the specified target is not
1047
- // in the list of known target names, emit a warning.
1048
- if (procName == knownTargets.at (j)) {
1049
- cout << " Warning: The specified HIP target: " << val <<
1050
- " is unknown. Correct compilation is not guaranteed.\n " ;
1051
- }
1052
- }
1053
1037
} // end of val != "gfx000"
1054
1038
} // end of targets for loop
1055
1039
string HCC_EXTRA_LIBRARIES;
0 commit comments