52
52
53
53
# retrieve --rocm-path hipcc option from command line.
54
54
# We need to respect this over the env var ROCM_PATH for this compilation.
55
- sub get_rocm_path_option {
55
+ sub get_path_options {
56
56
my $rocm_path =" " ;
57
+ my $hip_path =" " ;
57
58
my @CLArgs = @ARGV ;
58
59
foreach $arg (@CLArgs ) {
59
60
if (index ($arg ," --rocm-path=" ) != -1) {
60
61
($rocm_path ) = $arg =~ / =\s *(.*)\s *$ / ;
62
+ next ;
63
+ }
64
+ if (index ($arg ," --hip-path=" ) != -1) {
65
+ ($hip_path ) = $arg =~ / =\s *(.*)\s *$ / ;
66
+ next ;
61
67
}
62
68
}
63
- return $rocm_path ;
69
+ return ( $rocm_path , $hip_path ) ;
64
70
}
65
71
66
72
$verbose = $ENV {' HIPCC_VERBOSE' } // 0;
@@ -99,13 +105,16 @@ sub delete_temp_dirs {
99
105
}
100
106
101
107
my $base_dir ;
102
- my $rocmPath ;
103
108
BEGIN {
104
109
$base_dir = dirname(Cwd::realpath(__FILE__ ) );
105
- $rocmPath = get_rocm_path_option();
106
- if ($rocmPath ne ' ' ) {
110
+ my ($rocm_path , $hip_path ) = get_path_options();
111
+ if ($rocm_path ne ' ' ) {
112
+ # --rocm-path takes precedence over ENV{ROCM_PATH}
113
+ $ENV {ROCM_PATH }=$rocm_path ;
114
+ }
115
+ if ($hip_path ne ' ' ) {
107
116
# --rocm-path takes precedence over ENV{ROCM_PATH}
108
- $ENV {ROCM_PATH }=$rocmPath ;
117
+ $ENV {HIP_PATH }=$hip_path ;
109
118
}
110
119
}
111
120
use lib " $base_dir /" ;
@@ -123,25 +132,10 @@ BEGIN
123
132
$HIP_ROCCLR_HOME = $hipvars::HIP_ROCCLR_HOME ;
124
133
125
134
if ($HIP_PLATFORM eq " amd" ) {
126
- # If using ROCclr runtime, need to find HIP_ROCCLR_HOME
127
- if (!defined $DEVICE_LIB_PATH and -e " $HIP_ROCCLR_HOME /lib/bitcode" ) {
128
- $DEVICE_LIB_PATH = " $HIP_ROCCLR_HOME /lib/bitcode" ;
129
- }
130
135
$HIP_INCLUDE_PATH = " $HIP_ROCCLR_HOME /include" ;
131
136
if (!defined $HIP_LIB_PATH ) {
132
137
$HIP_LIB_PATH = " $HIP_ROCCLR_HOME /lib" ;
133
138
}
134
-
135
- if (!defined $DEVICE_LIB_PATH ) {
136
- if (-e " $ROCM_PATH /amdgcn/bitcode" ) {
137
- $DEVICE_LIB_PATH = " $ROCM_PATH /amdgcn/bitcode" ;
138
- }
139
- else {
140
- # This path is to support an older build of the device library
141
- # TODO: To be removed in the future.
142
- $DEVICE_LIB_PATH = " $ROCM_PATH /lib" ;
143
- }
144
- }
145
139
}
146
140
147
141
if ($verbose & 0x2) {
@@ -259,7 +253,12 @@ BEGIN
259
253
if ($ARGV [0] eq " --genco" ){
260
254
foreach $isaarg (@ARGV [1..$#ARGV ]){
261
255
$ISACMD .= " " ;
262
- $ISACMD .= $isaarg ;
256
+ # ignore --rocm-path=xxxx on nvcc nvidia platform
257
+ if ($isaarg !~ / --rocm-path/ ) {
258
+ $ISACMD .= $isaarg ;
259
+ } else {
260
+ print " Ignoring --rocm-path= on nvidia nvcc platform.\n " ;
261
+ }
263
262
}
264
263
if ($verbose & 0x1) {
265
264
print " hipcc-cmd: " , $ISACMD , " \n " ;
@@ -566,8 +565,15 @@ BEGIN
566
565
}
567
566
}
568
567
568
+ # If the HIP_PATH env var is defined, pass that path to Clang
569
+ if ($ENV {' HIP_PATH' }) {
570
+ my $hip_path_flag = " --hip-path=\" $HIP_PATH \" " ;
571
+ $HIPCXXFLAGS .= $hip_path_flag ;
572
+ $HIPLDFLAGS .= $hip_path_flag ;
573
+ }
574
+
569
575
if ($hasHIP ) {
570
- if ($DEVICE_LIB_PATH ne " $ROCM_PATH /amdgcn/bitcode " ) {
576
+ if (defined $DEVICE_LIB_PATH ) {
571
577
$HIPCXXFLAGS .= " --hip-device-lib-path=\" $DEVICE_LIB_PATH \" " ;
572
578
}
573
579
}
0 commit comments