From 4a0c6c2d53464931e210ab6ead0e4171a43aaab3 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 --- bin/hipcc | 11 +++++++++++ bin/hipgenisa.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 bin/hipgenisa.sh diff --git a/bin/hipcc b/bin/hipcc index e91993b460..b92de9e29d 100755 --- a/bin/hipcc +++ b/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/bin/hipgenisa.sh b/bin/hipgenisa.sh new file mode 100755 index 0000000000..ef5417a428 --- /dev/null +++ b/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