From 9739e7b9c6404bd0afa5d080d270919d98f786f6 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Wed, 3 Aug 2016 11:32:08 +0530 Subject: [PATCH] hipcc reads .hipconfig hipcc dies if HCC_VERSION is not same as the one used to build HIP Change-Id: I180c0108812fe5cb6c5304477557c524a4a61f75 [ROCm/clr commit: 138168133599b5a3f1a3a881b335962c97a542d0] --- projects/clr/hipamd/bin/hipcc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/projects/clr/hipamd/bin/hipcc b/projects/clr/hipamd/bin/hipcc index 1758cb5dce..d1f757d0c4 100755 --- a/projects/clr/hipamd/bin/hipcc +++ b/projects/clr/hipamd/bin/hipcc @@ -52,6 +52,7 @@ if ($HIP_PLATFORM eq "hcc") { $HCC_HOME=$ENV{'HCC_HOME'}; $HCC_HOME="/opt/rocm/hcc" unless defined $HCC_HOME; + $HCC_VERSION=`${HCC_HOME}/bin/hcc --version | cut -d" " -f9 | tr -d "\n"`; $ROCM_PATH=$ENV{'ROCM_PATH'}; $ROCM_PATH="/opt/rocm" unless defined $ROCM_PATH; @@ -240,6 +241,24 @@ if ($needHipHcc) { } } +# Read .hipconfig +my %hipConfig = (); +$hipConfig{'VALID'}=0; +if (open (CONFIG, "$HIP_PATH/bin/.hipconfig")) { + while () { + my $config_line=$_; + chop ($config_line); + $config_line =~ s/^\s*//; + $config_line =~ s/\s*$//; + if (($config_line !~ /^#/) && ($config_line ne "")) { + my ($name, $value) = split (/=/, $config_line); + $hipConfig{$name} = $value; + $hipConfig{'VALID'}=1; + } + } + close(CONFIG); +} + # hipcc currrently requires separate compilation of source files, ie it is not possible to pass # CPP files combined with .O files # Reason is that NVCC uses the file extension to determine whether to compile in CUDA mode or @@ -267,5 +286,8 @@ if ($printHipVersion) { print $HIP_VERSION, "\n"; } if ($runCmd) { + if ($hipConfig{'VALID'} and $HIP_PLATFORM eq "hcc" and $HCC_VERSION ne $hipConfig{'HCC_VERSION'}) { + print ("HIP was built using $hipConfig{'HCC_VERSION'}, but you are using $HCC_VERSION. Please rebuild HIP.\n") && die (); + } system ("$CMD") and die (); }