From f97eec0d3b291d6d4efc7e96e24d83a7b73094de Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 31 Aug 2016 13:05:57 -0500 Subject: [PATCH] added kernel only compilation feature for hipcc 1. Added hipgenisa.sh file to compile kernel code to hsa code object 2. Changed hipcc to call hipgenisa.sh, making hipcc compiling the kernels Change-Id: I976459c1ebb24343e1b1fe38b4c3a203f1adffa9 [ROCm/clr commit: 2f8b2fca6b829ab3def908138ec3a81cd8980a59] --- projects/clr/hipamd/bin/hipcc | 11 +++++++++++ projects/clr/hipamd/bin/hipgenisa.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 projects/clr/hipamd/bin/hipgenisa.sh diff --git a/projects/clr/hipamd/bin/hipcc b/projects/clr/hipamd/bin/hipcc index e91993b460..b92de9e29d 100755 --- a/projects/clr/hipamd/bin/hipcc +++ b/projects/clr/hipamd/bin/hipcc @@ -157,6 +157,16 @@ if ($HIP_PLATFORM eq "hcc") { exit (-1); } +my $ISACMD="hipgenisa.sh "; +$ISACMD .= $ROCM_PATH; +if($ARGV[0] eq "--genisa"){ + foreach $isaarg (@ARGV){ + $ISACMD .= " "; + $ISACMD .= $isaarg; + } + system($ISACMD); + exit(-1); +} # Add paths to common HIP includes: $HIPCXXFLAGS .= " -I$HIP_PATH/include" ; @@ -178,6 +188,7 @@ if ($verbose & 0x4) { } my $toolArgs = ""; # arguments to pass to the hcc or nvcc tool + foreach $arg (@ARGV) { my $swallowArg = 0; diff --git a/projects/clr/hipamd/bin/hipgenisa.sh b/projects/clr/hipamd/bin/hipgenisa.sh new file mode 100755 index 0000000000..ef5417a428 --- /dev/null +++ b/projects/clr/hipamd/bin/hipgenisa.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +if [ $1 = " " ] +then +exit +fi + +ROCM_PATH=$1 +GEN_ISA=$3 +FILE_NAMES=$4 +OUT=$5 +OUTPUT_FILE=$6 +TARGET="" +if [ ${GEN_ISA:0:12} = "--target-isa" ] +then + TARGET=${GEN_ISA:13:12} +fi + +export KMDUMPISA=1 +export KMDUMPLLVM=1 +hipcc $FILE_NAMES -o /tmp/hipgenisa/a.out +mv dump.* /tmp/hipgenisa/ +${ROCM_PATH}/hcc-lc/bin/llvm-mc -arch=amdgcn -mcpu=$TARGET -filetype=obj /tmp/hipgenisa/dump.isa -o /tmp/hipgenisa/dump.o +${ROCM_PATH}/llvm/bin/clang -target amdgcn--amdhsa /tmp/hipgenisa/dump.o -o $OUTPUT_FILE +export KMDUMPISA=0 +export KMDUMPLLVM=0