search path logic updated for extractkernel SWDEV-230929
Change-Id: I48d6332502774485d7ced3fee065a74f15774500
This commit is contained in:
@@ -34,26 +34,35 @@ defined $options{i} || die("input not specified");
|
||||
$input_file = $options{i};
|
||||
(-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
|
||||
my $tools_path_prefix;
|
||||
my $llvm_objdump;
|
||||
my $clang_offload_bundler;
|
||||
|
||||
if (defined $ENV{'HCC_HOME'}) {
|
||||
$tools_path_prefix = File::Spec->catfile($ENV{'HCC_HOME'}, "bin");
|
||||
$llvm_objdump = File::Spec->catfile($tools_path_prefix, "llvm-objdump");
|
||||
$clang_offload_bundler = File::Spec->catfile($tools_path_prefix, "clang-offload-bundler");
|
||||
if (defined $HIP_COMPILER and $HIP_COMPILER eq "clang"){
|
||||
# Search the path with respect to HIP_CLANG_PATH
|
||||
$tools_path_prefix = $HIP_CLANG_PATH;
|
||||
}
|
||||
else {
|
||||
$tools_path_prefix = dirname(realpath($0));
|
||||
$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)) {
|
||||
$tools_path_prefix = realpath($tools_path_prefix."/../../hcc/bin");
|
||||
$llvm_objdump = File::Spec->catfile($tools_path_prefix, "llvm-objdump");
|
||||
$clang_offload_bundler = File::Spec->catfile($tools_path_prefix, "clang-offload-bundler");
|
||||
if (defined $HIP_COMPILER and $HIP_COMPILER eq "hcc") {
|
||||
# Search the path with respect to HCC_HOME if it is set, else search in ROCM_PATH
|
||||
if (defined $ENV{'HCC_HOME'}) {
|
||||
$tools_path_prefix = File::Spec->catfile($ENV{'HCC_HOME'}, "bin");
|
||||
}
|
||||
else {
|
||||
$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)) {
|
||||
$llvm_objdump = which("llvm-objdump");
|
||||
|
||||
@@ -17,9 +17,11 @@ Getopt::Long::Configure ( qw{bundling no_ignore_case});
|
||||
GetOptions(
|
||||
"help|h" => \$p_help
|
||||
,"path|p" => \$p_path
|
||||
,"rocmpath|R" => \$p_rocmpath
|
||||
,"compiler|c" => \$p_compiler
|
||||
,"platform|P" => \$p_platform
|
||||
,"runtime|r" => \$p_runtime
|
||||
,"hipclangpath|l" => \$p_hipclangpath
|
||||
,"cpp_config|cxx_config|C" => \$p_cpp_config
|
||||
,"full|f|info" => \$p_full,
|
||||
,"version|v" => \$p_version,
|
||||
@@ -30,10 +32,12 @@ GetOptions(
|
||||
if ($p_help) {
|
||||
print "usage: hipconfig [OPTIONS]\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 " --compiler, -c : print compiler (hcc or clang or nvcc)\n";
|
||||
print " --platform, -P : print platform (hcc or nvcc)\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 " --version, -v : print hip version\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=$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=$ENV{'HIP_PLATFORM'};
|
||||
# Read .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
|
||||
$HIP_COMPILER = $ENV{'HIP_COMPILER'} // $hipInfo{'HIP_COMPILER'} // "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 (can_run("$HCC_HOME/bin/hcc") or can_run("hcc")) {
|
||||
$HIP_PLATFORM = "hcc";
|
||||
@@ -146,6 +165,11 @@ if ($p_path) {
|
||||
$printed = 1;
|
||||
}
|
||||
|
||||
if ($p_rocmpath) {
|
||||
print "$ROCM_PATH";
|
||||
$printed = 1;
|
||||
}
|
||||
|
||||
if ($p_cpp_config) {
|
||||
print $CPP_CONFIG;
|
||||
$printed = 1;
|
||||
@@ -166,6 +190,13 @@ if ($p_runtime) {
|
||||
$printed = 1;
|
||||
}
|
||||
|
||||
if ($p_hipclangpath) {
|
||||
if (defined $HIP_CLANG_PATH) {
|
||||
print $HIP_CLANG_PATH;
|
||||
}
|
||||
$printed = 1;
|
||||
}
|
||||
|
||||
if ($p_version) {
|
||||
print $HIP_VERSION;
|
||||
$printed = 1;
|
||||
@@ -175,6 +206,7 @@ if (!$printed or $p_full) {
|
||||
print "HIP version : ", $HIP_VERSION, "\n\n";
|
||||
print "== hipconfig\n";
|
||||
print "HIP_PATH : ", $HIP_PATH, "\n";
|
||||
print "ROCM_PATH : ", $ROCM_PATH, "\n";
|
||||
print "HIP_COMPILER : ", $HIP_COMPILER, "\n";
|
||||
print "HIP_PLATFORM : ", $HIP_PLATFORM, "\n";
|
||||
print "HIP_RUNTIME : ", $HIP_RUNTIME, "\n";
|
||||
|
||||
Verwijs in nieuw issue
Block a user