Arquivos
rocm-systems/bin/hipconfig
T

201 linhas
5.4 KiB
Perl
Original Visão Normal Histórico

2016-01-26 20:14:33 -06:00
#!/usr/bin/perl -w
2016-07-11 16:38:41 +05:30
# Need perl > 5.10 to use logic-defined or
use 5.006; use v5.10.1;
2016-01-26 20:14:33 -06:00
use Getopt::Long;
use Cwd;
2020-11-27 20:13:14 -05:00
# Return name of HIP compiler - either 'clang' or 'nvcc'
2016-01-26 20:14:33 -06:00
#
use Getopt::Long;
use File::Basename;
my $base_dir;
BEGIN {
2021-01-08 17:53:32 -05:00
$base_dir = dirname( Cwd::realpath(__FILE__) );
}
use lib "$base_dir/";
use hipvars;
$HIP_RUNTIME = $hipvars::HIP_RUNTIME;
$HIP_PLATFORM = $hipvars::HIP_PLATFORM;
$HIP_COMPILER = $hipvars::HIP_COMPILER;
$HIP_CLANG_PATH = $hipvars::HIP_CLANG_PATH;
$CUDA_PATH = $hipvars::CUDA_PATH;
$HIP_PATH = $hipvars::HIP_PATH;
$ROCM_PATH = $hipvars::ROCM_PATH;
$HIP_VERSION = $hipvars::HIP_VERSION;
$HSA_PATH = $hipvars::HSA_PATH;
2016-01-26 20:14:33 -06:00
Getopt::Long::Configure ( qw{bundling no_ignore_case});
GetOptions(
"help|h" => \$p_help
,"path|p" => \$p_path
,"rocmpath|R" => \$p_rocmpath
2016-01-26 20:14:33 -06:00
,"compiler|c" => \$p_compiler
,"platform|P" => \$p_platform
2020-04-24 15:59:33 +00:00
,"runtime|r" => \$p_runtime
,"hipclangpath|l" => \$p_hipclangpath
2016-01-26 20:14:33 -06:00
,"cpp_config|cxx_config|C" => \$p_cpp_config
2016-02-25 23:07:18 -06:00
,"full|f|info" => \$p_full,
2016-07-11 16:38:41 +05:30
,"version|v" => \$p_version,
2016-02-27 21:26:40 -06:00
,"check" => \$p_check,
2016-01-26 20:14:33 -06:00
,"newline|n" => \$p_newline
);
if ($HIP_COMPILER eq "clang") {
$HIP_CLANG_VERSION = `$HIP_CLANG_PATH/clang++ --version`;
$HIP_CLANG_VERSION=~/.*clang version (\S+).*/;
$HIP_CLANG_VERSION=$1;
2021-01-13 11:46:42 -05:00
$CPP_CONFIG = " -D__HIP_PLATFORM_HCC__= -D__HIP_PLATFORM_AMD__= -I$HIP_PATH/include -I$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION -I$HSA_PATH/include";
}
2021-01-04 19:58:20 -05:00
if ($HIP_PLATFORM eq "nvidia") {
2021-01-13 11:46:42 -05:00
$CPP_CONFIG = " -D__HIP_PLATFORM_NVCC__= -D__HIP_PLATFORM_NVIDIA__= -I$HIP_PATH/include -I$CUDA_PATH/include";
};
2016-01-26 20:14:33 -06:00
if ($p_help) {
2016-02-09 11:51:26 +05:30
print "usage: hipconfig [OPTIONS]\n";
2016-01-26 20:14:33 -06:00
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";
2016-01-26 20:14:33 -06:00
print " --cpp_config, -C : print C++ compiler options\n";
2020-11-27 20:13:14 -05:00
print " --compiler, -c : print compiler (clang or nvcc)\n";
print " --platform, -P : print platform (amd or nvidia)\n";
2020-11-27 20:13:14 -05:00
print " --runtime, -r : print runtime (rocclr or cuda)\n";
print " --hipclangpath, -l : print HIP_CLANG_PATH\n";
2016-01-28 20:16:43 -06:00
print " --full, -f : print full config\n";
2016-07-11 16:38:41 +05:30
print " --version, -v : print hip version\n";
2016-02-27 21:26:40 -06:00
print " --check : check configuration\n";
2016-01-26 20:14:33 -06:00
print " --newline, -n : print newline\n";
print " --help, -h : print help message\n";
exit();
}
if ($p_path) {
print "$HIP_PATH";
$printed = 1;
}
2016-08-12 23:21:37 +05:30
if ($p_rocmpath) {
print "$ROCM_PATH";
$printed = 1;
}
2016-01-26 20:14:33 -06:00
if ($p_cpp_config) {
2016-01-28 20:16:43 -06:00
print $CPP_CONFIG;
2016-01-26 20:14:33 -06:00
$printed = 1;
}
2020-04-24 15:59:33 +00:00
if ($p_compiler) {
print $HIP_COMPILER;
$printed = 1;
}
2016-02-27 20:34:33 -06:00
2020-04-24 15:59:33 +00:00
if ($p_platform) {
2016-02-27 20:34:33 -06:00
print $HIP_PLATFORM;
$printed = 1;
}
2020-04-24 15:59:33 +00:00
if ($p_runtime) {
print $HIP_RUNTIME;
$printed = 1;
}
if ($p_hipclangpath) {
if (defined $HIP_CLANG_PATH) {
print $HIP_CLANG_PATH;
}
$printed = 1;
}
2016-07-11 16:38:41 +05:30
if ($p_version) {
print $HIP_VERSION;
$printed = 1;
}
2016-02-27 21:26:40 -06:00
2016-02-27 20:34:33 -06:00
if (!$printed or $p_full) {
2016-07-11 16:38:41 +05:30
print "HIP version : ", $HIP_VERSION, "\n\n";
2016-01-28 20:16:43 -06:00
print "== hipconfig\n";
print "HIP_PATH : ", $HIP_PATH, "\n";
print "ROCM_PATH : ", $ROCM_PATH, "\n";
2020-04-24 15:59:33 +00:00
print "HIP_COMPILER : ", $HIP_COMPILER, "\n";
2016-01-28 20:16:43 -06:00
print "HIP_PLATFORM : ", $HIP_PLATFORM, "\n";
2020-04-24 15:59:33 +00:00
print "HIP_RUNTIME : ", $HIP_RUNTIME, "\n";
2016-01-28 20:16:43 -06:00
print "CPP_CONFIG : ", $CPP_CONFIG, "\n";
if ($HIP_PLATFORM eq "amd")
2016-01-28 20:16:43 -06:00
{
print "\n" ;
2020-04-24 15:59:33 +00:00
if ($HIP_COMPILER eq "clang")
{
print "== hip-clang\n";
print ("HSA_PATH : $HSA_PATH\n");
print ("HIP_CLANG_PATH : $HIP_CLANG_PATH\n");
system("$HIP_CLANG_PATH/clang++ --version");
system("$HIP_CLANG_PATH/llc --version");
print ("hip-clang-cxxflags : ");
system("$HIP_PATH/bin/hipcc --cxxflags");
printf("\n");
print ("hip-clang-ldflags : ");
system("$HIP_PATH/bin/hipcc --ldflags");
printf("\n");
2020-11-27 20:13:14 -05:00
} else {
print ("Unexpected HIP_COMPILER: $HIP_COMPILER\n");
2020-04-24 15:59:33 +00:00
}
2016-01-28 20:16:43 -06:00
}
if ($HIP_PLATFORM eq "nvidia") {
2016-01-28 20:16:43 -06:00
print "\n" ;
print "== nvcc\n";
#print "CUDA_PATH :", $CUDA_PATH";
system("nvcc --version");
}
print "\n" ;
print "=== Environment Variables\n";
2016-02-25 23:07:18 -06:00
system("echo PATH=\$PATH");
2020-11-27 20:13:14 -05:00
system("env | egrep '^HIP|^HSA|^CUDA|^LD_LIBRARY_PATH'");
2016-02-25 23:07:18 -06:00
2016-01-28 20:16:43 -06:00
print "\n" ;
print "== Linux Kernel\n";
2016-04-25 15:13:23 -05:00
print "Hostname : "; system ("hostname");
2016-01-28 20:16:43 -06:00
system ("uname -a");
2016-02-17 21:22:31 -06:00
2016-03-24 22:12:41 -05:00
if (-e "/usr/bin/lsb_release") {
system ("/usr/bin/lsb_release -a");
}
2016-02-17 21:22:31 -06:00
print "\n" ;
2016-01-28 20:16:43 -06:00
$printed = 1;
}
2016-01-26 20:14:33 -06:00
2016-02-27 21:26:40 -06:00
if ($p_check) {
print "\nCheck system installation:\n";
printf ("%-70s", "check hipconfig in PATH...");
# Safer to use which hipconfig instead of invoking hipconfig
if (system ("which hipconfig > /dev/null 2>&1") != 0) {
2016-02-27 21:26:40 -06:00
print "FAIL\n";
} else {
printf "good\n";
}
if ($HIP_PLATFORM eq "amd") {
2016-02-27 21:26:40 -06:00
$LD_LIBRARY_PATH=$ENV{'LD_LIBRARY_PATH'};
printf("%-70s", "check LD_LIBRARY_PATH ($LD_LIBRARY_PATH) contains HSA_PATH ($HSA_PATH)...");
if (index($LD_LIBRARY_PATH, $HSA_PATH) == -1) {
print "FAIL\n";
} else {
printf "good\n";
}
# TODO - check hipcc / nvcc found and executable.
}
}
2016-01-26 20:14:33 -06:00
if ($p_newline) {
print "\n";
}