Merge "search path logic updated for extractkernel SWDEV-230929" into amd-master-next
This commit is contained in:
+20
-11
@@ -34,26 +34,35 @@ defined $options{i} || die("input not specified");
|
|||||||
$input_file = $options{i};
|
$input_file = $options{i};
|
||||||
(-f $input_file) || die("can't find $input_file");
|
(-f $input_file) || die("can't find $input_file");
|
||||||
|
|
||||||
|
# derive HIP_PATH via env var or use parent directory of extractkernel
|
||||||
|
my $HIP_PATH=$ENV{'HIP_PATH'} // dirname(Cwd::abs_path("$0/../"));
|
||||||
|
my $HIP_COMPILER = `$HIP_PATH/bin/hipconfig --compiler`;
|
||||||
|
my $ROCM_PATH = `$HIP_PATH/bin/hipconfig --rocmpath`;
|
||||||
|
my $HIP_CLANG_PATH = `$HIP_PATH/bin/hipconfig --hipclangpath`;
|
||||||
|
|
||||||
# look for llvm-objdump and clang-offload-bundler
|
# look for llvm-objdump and clang-offload-bundler
|
||||||
my $tools_path_prefix;
|
my $tools_path_prefix;
|
||||||
my $llvm_objdump;
|
my $llvm_objdump;
|
||||||
my $clang_offload_bundler;
|
my $clang_offload_bundler;
|
||||||
|
|
||||||
if (defined $ENV{'HCC_HOME'}) {
|
if (defined $HIP_COMPILER and $HIP_COMPILER eq "clang"){
|
||||||
$tools_path_prefix = File::Spec->catfile($ENV{'HCC_HOME'}, "bin");
|
# Search the path with respect to HIP_CLANG_PATH
|
||||||
$llvm_objdump = File::Spec->catfile($tools_path_prefix, "llvm-objdump");
|
$tools_path_prefix = $HIP_CLANG_PATH;
|
||||||
$clang_offload_bundler = File::Spec->catfile($tools_path_prefix, "clang-offload-bundler");
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$tools_path_prefix = dirname(realpath($0));
|
if (defined $HIP_COMPILER and $HIP_COMPILER eq "hcc") {
|
||||||
$llvm_objdump = File::Spec->catfile($tools_path_prefix, "llvm-objdump");
|
# Search the path with respect to HCC_HOME if it is set, else search in ROCM_PATH
|
||||||
$clang_offload_bundler = File::Spec->catfile($tools_path_prefix, "clang-offload-bundler");
|
if (defined $ENV{'HCC_HOME'}) {
|
||||||
if (!(-f $llvm_objdump)) {
|
$tools_path_prefix = File::Spec->catfile($ENV{'HCC_HOME'}, "bin");
|
||||||
$tools_path_prefix = realpath($tools_path_prefix."/../../hcc/bin");
|
}
|
||||||
$llvm_objdump = File::Spec->catfile($tools_path_prefix, "llvm-objdump");
|
else {
|
||||||
$clang_offload_bundler = File::Spec->catfile($tools_path_prefix, "clang-offload-bundler");
|
$tools_path_prefix = realpath($ROCM_PATH."/hcc/bin");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
# Find llvm-objdump and clang-offload-bundler in the path set above
|
||||||
|
$llvm_objdump = File::Spec->catfile($tools_path_prefix, "llvm-objdump");
|
||||||
|
$clang_offload_bundler = File::Spec->catfile($tools_path_prefix, "clang-offload-bundler");
|
||||||
|
|
||||||
if (!(-f $llvm_objdump)) {
|
if (!(-f $llvm_objdump)) {
|
||||||
$llvm_objdump = which("llvm-objdump");
|
$llvm_objdump = which("llvm-objdump");
|
||||||
|
|||||||
+33
-1
@@ -17,9 +17,11 @@ Getopt::Long::Configure ( qw{bundling no_ignore_case});
|
|||||||
GetOptions(
|
GetOptions(
|
||||||
"help|h" => \$p_help
|
"help|h" => \$p_help
|
||||||
,"path|p" => \$p_path
|
,"path|p" => \$p_path
|
||||||
|
,"rocmpath|R" => \$p_rocmpath
|
||||||
,"compiler|c" => \$p_compiler
|
,"compiler|c" => \$p_compiler
|
||||||
,"platform|P" => \$p_platform
|
,"platform|P" => \$p_platform
|
||||||
,"runtime|r" => \$p_runtime
|
,"runtime|r" => \$p_runtime
|
||||||
|
,"hipclangpath|l" => \$p_hipclangpath
|
||||||
,"cpp_config|cxx_config|C" => \$p_cpp_config
|
,"cpp_config|cxx_config|C" => \$p_cpp_config
|
||||||
,"full|f|info" => \$p_full,
|
,"full|f|info" => \$p_full,
|
||||||
,"version|v" => \$p_version,
|
,"version|v" => \$p_version,
|
||||||
@@ -30,10 +32,12 @@ GetOptions(
|
|||||||
if ($p_help) {
|
if ($p_help) {
|
||||||
print "usage: hipconfig [OPTIONS]\n";
|
print "usage: hipconfig [OPTIONS]\n";
|
||||||
print " --path, -p : print HIP_PATH (use env var if set, else determine from hipconfig path)\n";
|
print " --path, -p : print HIP_PATH (use env var if set, else determine from hipconfig path)\n";
|
||||||
|
print " --rocmpath, -R : print ROCM_PATH (use env var if set, else determine from hip path or /opt/rocm)\n";
|
||||||
print " --cpp_config, -C : print C++ compiler options\n";
|
print " --cpp_config, -C : print C++ compiler options\n";
|
||||||
print " --compiler, -c : print compiler (hcc or clang or nvcc)\n";
|
print " --compiler, -c : print compiler (hcc or clang or nvcc)\n";
|
||||||
print " --platform, -P : print platform (hcc or nvcc)\n";
|
print " --platform, -P : print platform (hcc or nvcc)\n";
|
||||||
print " --runtime, -r : print runtime (HCC or ROCclr)\n";
|
print " --runtime, -r : print runtime (HCC or ROCclr)\n";
|
||||||
|
print " --hipclangpath, -l : print HIP_CLANG_PATH\n";
|
||||||
print " --full, -f : print full config\n";
|
print " --full, -f : print full config\n";
|
||||||
print " --version, -v : print hip version\n";
|
print " --version, -v : print hip version\n";
|
||||||
print " --check : check configuration\n";
|
print " --check : check configuration\n";
|
||||||
@@ -88,16 +92,31 @@ $HIP_CLANG_PATH=$ENV{'HIP_CLANG_PATH'} // "$ROCM_PATH/llvm/bin";
|
|||||||
# HIP_ROCclr_HOME is used by Windows builds
|
# HIP_ROCclr_HOME is used by Windows builds
|
||||||
$HIP_ROCclr_HOME=$ENV{'HIP_ROCclr_HOME'};
|
$HIP_ROCclr_HOME=$ENV{'HIP_ROCclr_HOME'};
|
||||||
|
|
||||||
|
if (defined $HIP_ROCclr_HOME) {
|
||||||
|
$HIP_INFO_PATH= "$HIP_ROCclr_HOME/lib/.hipInfo";
|
||||||
|
} else {
|
||||||
|
$HIP_INFO_PATH= "$HIP_PATH/lib/.hipInfo"; # use actual file
|
||||||
|
}
|
||||||
#---
|
#---
|
||||||
#HIP_PLATFORM controls whether to use NVCC or HCC for compilation:
|
#HIP_PLATFORM controls whether to use NVCC or HCC for compilation:
|
||||||
$HIP_PLATFORM=$ENV{'HIP_PLATFORM'};
|
$HIP_PLATFORM=$ENV{'HIP_PLATFORM'};
|
||||||
# Read .hipInfo
|
# Read .hipInfo
|
||||||
my %hipInfo = ();
|
my %hipInfo = ();
|
||||||
parse_config_file("$HIP_PATH/lib/.hipInfo", \%hipInfo);
|
parse_config_file("$HIP_INFO_PATH", \%hipInfo);
|
||||||
# Prioritize Env first, otherwise use the hipInfo config file
|
# Prioritize Env first, otherwise use the hipInfo config file
|
||||||
$HIP_COMPILER = $ENV{'HIP_COMPILER'} // $hipInfo{'HIP_COMPILER'} // "hcc";
|
$HIP_COMPILER = $ENV{'HIP_COMPILER'} // $hipInfo{'HIP_COMPILER'} // "hcc";
|
||||||
$HIP_RUNTIME = $ENV{'HIP_RUNTIME'} // $hipInfo{'HIP_RUNTIME'} // "HCC";
|
$HIP_RUNTIME = $ENV{'HIP_RUNTIME'} // $hipInfo{'HIP_RUNTIME'} // "HCC";
|
||||||
|
|
||||||
|
# If using ROCclr runtime, need to find HIP_ROCclr_HOME
|
||||||
|
if (defined $HIP_RUNTIME and $HIP_RUNTIME eq "ROCclr" and !defined $HIP_ROCclr_HOME) {
|
||||||
|
my $hipconfig_dir = dirname($0);
|
||||||
|
if (-e "$hipconfig_dir/../lib/bitcode") {
|
||||||
|
$HIP_ROCclr_HOME = abs_path($hipconfig_dir . "/..");
|
||||||
|
} else {
|
||||||
|
$HIP_ROCclr_HOME = $HIP_PATH; # use HIP_PATH
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (not defined $HIP_PLATFORM) {
|
if (not defined $HIP_PLATFORM) {
|
||||||
if (can_run("$HCC_HOME/bin/hcc") or can_run("hcc")) {
|
if (can_run("$HCC_HOME/bin/hcc") or can_run("hcc")) {
|
||||||
$HIP_PLATFORM = "hcc";
|
$HIP_PLATFORM = "hcc";
|
||||||
@@ -146,6 +165,11 @@ if ($p_path) {
|
|||||||
$printed = 1;
|
$printed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($p_rocmpath) {
|
||||||
|
print "$ROCM_PATH";
|
||||||
|
$printed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if ($p_cpp_config) {
|
if ($p_cpp_config) {
|
||||||
print $CPP_CONFIG;
|
print $CPP_CONFIG;
|
||||||
$printed = 1;
|
$printed = 1;
|
||||||
@@ -166,6 +190,13 @@ if ($p_runtime) {
|
|||||||
$printed = 1;
|
$printed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($p_hipclangpath) {
|
||||||
|
if (defined $HIP_CLANG_PATH) {
|
||||||
|
print $HIP_CLANG_PATH;
|
||||||
|
}
|
||||||
|
$printed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if ($p_version) {
|
if ($p_version) {
|
||||||
print $HIP_VERSION;
|
print $HIP_VERSION;
|
||||||
$printed = 1;
|
$printed = 1;
|
||||||
@@ -175,6 +206,7 @@ if (!$printed or $p_full) {
|
|||||||
print "HIP version : ", $HIP_VERSION, "\n\n";
|
print "HIP version : ", $HIP_VERSION, "\n\n";
|
||||||
print "== hipconfig\n";
|
print "== hipconfig\n";
|
||||||
print "HIP_PATH : ", $HIP_PATH, "\n";
|
print "HIP_PATH : ", $HIP_PATH, "\n";
|
||||||
|
print "ROCM_PATH : ", $ROCM_PATH, "\n";
|
||||||
print "HIP_COMPILER : ", $HIP_COMPILER, "\n";
|
print "HIP_COMPILER : ", $HIP_COMPILER, "\n";
|
||||||
print "HIP_PLATFORM : ", $HIP_PLATFORM, "\n";
|
print "HIP_PLATFORM : ", $HIP_PLATFORM, "\n";
|
||||||
print "HIP_RUNTIME : ", $HIP_RUNTIME, "\n";
|
print "HIP_RUNTIME : ", $HIP_RUNTIME, "\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user