Skip to content

Commit dbcf5e7

Browse files
committed
Bring hipcc and hipconfig scripts in sync with HIP repo
1 parent eab4ba1 commit dbcf5e7

File tree

4 files changed

+30
-24
lines changed

4 files changed

+30
-24
lines changed

amd/hipcc/bin/hipcc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ if ($USE_PERL_SCRIPT) {
5454
#Invoke hipcc.bin
5555
system($HIPCC_BIN, @ARGV);
5656
} else {
57-
print "hipcc.bin not present; Install HIPCC binaries before proceeding";
57+
print "hipcc.bin not present; install HIPCC binaries before proceeding\n";
5858
exit(-1);
5959
}
6060
}

amd/hipcc/bin/hipcc.bat

100755100644
File mode changed.

amd/hipcc/bin/hipcc.pl

100755100644
Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,21 @@
5252

5353
# retrieve --rocm-path hipcc option from command line.
5454
# 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 {
5656
my $rocm_path="";
57+
my $hip_path="";
5758
my @CLArgs = @ARGV;
5859
foreach $arg (@CLArgs) {
5960
if (index($arg,"--rocm-path=") != -1) {
6061
($rocm_path) = $arg=~ /=\s*(.*)\s*$/;
62+
next;
63+
}
64+
if (index($arg,"--hip-path=") != -1) {
65+
($hip_path) = $arg=~ /=\s*(.*)\s*$/;
66+
next;
6167
}
6268
}
63-
return $rocm_path;
69+
return ($rocm_path, $hip_path);
6470
}
6571

6672
$verbose = $ENV{'HIPCC_VERBOSE'} // 0;
@@ -99,13 +105,16 @@ sub delete_temp_dirs {
99105
}
100106

101107
my $base_dir;
102-
my $rocmPath;
103108
BEGIN {
104109
$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 '') {
107116
# --rocm-path takes precedence over ENV{ROCM_PATH}
108-
$ENV{ROCM_PATH}=$rocmPath;
117+
$ENV{HIP_PATH}=$hip_path;
109118
}
110119
}
111120
use lib "$base_dir/";
@@ -123,25 +132,10 @@ BEGIN
123132
$HIP_ROCCLR_HOME = $hipvars::HIP_ROCCLR_HOME;
124133

125134
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-
}
130135
$HIP_INCLUDE_PATH = "$HIP_ROCCLR_HOME/include";
131136
if (!defined $HIP_LIB_PATH) {
132137
$HIP_LIB_PATH = "$HIP_ROCCLR_HOME/lib";
133138
}
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-
}
145139
}
146140

147141
if ($verbose & 0x2) {
@@ -259,7 +253,12 @@ BEGIN
259253
if($ARGV[0] eq "--genco"){
260254
foreach $isaarg (@ARGV[1..$#ARGV]){
261255
$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+
}
263262
}
264263
if ($verbose & 0x1) {
265264
print "hipcc-cmd: ", $ISACMD, "\n";
@@ -566,8 +565,15 @@ BEGIN
566565
}
567566
}
568567

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+
569575
if ($hasHIP) {
570-
if ($DEVICE_LIB_PATH ne "$ROCM_PATH/amdgcn/bitcode") {
576+
if (defined $DEVICE_LIB_PATH) {
571577
$HIPCXXFLAGS .= " --hip-device-lib-path=\"$DEVICE_LIB_PATH\"";
572578
}
573579
}

amd/hipcc/bin/hipconfig.bat

100755100644
File mode changed.

0 commit comments

Comments
 (0)