Skip to content

Commit

Permalink
Revert "Enable function call support by default."
Browse files Browse the repository at this point in the history
This reverts commit 95e8b61.
  • Loading branch information
scchan committed Oct 30, 2019
1 parent 922f94a commit 53a616a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
15 changes: 11 additions & 4 deletions lib/clamp-device.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ KMTHINLTO="${KMTHINLTO:=0}"
# flag for early finalization
AMDGPU_OBJ_CODEGEN="0"

# flag for function calls enabled
AMDGPU_FUNC_CALLS="0"

# flag for COV3
HCC_COV3="0"

Expand Down Expand Up @@ -113,6 +116,10 @@ do
KMTHINLTO="0"
continue
;;
--amdgpu-func-calls)
AMDGPU_FUNC_CALLS="1"
continue
;;
--hcc-cov3)
HCC_COV3="1"
continue
Expand Down Expand Up @@ -211,7 +218,7 @@ fi
$OPT $HCC_OPT -mtriple amdgcn-amd-amdhsa -mcpu=$AMDGPU_TARGET \
-load $LIB/LLVMSelectAcceleratorCode@CMAKE_SHARED_LIBRARY_SUFFIX@ \
-load $LIB/LLVMPromotePointerKernArgsToGlobal@CMAKE_SHARED_LIBRARY_SUFFIX@ \
-select-accelerator-code \
-select-accelerator-code -sac-enable-function-calls=$AMDGPU_FUNC_CALLS \
-promote-pointer-kernargs-to-global \
-infer-address-spaces \
-verify < $2.linked.bc -o $2.opt.bc
Expand Down Expand Up @@ -245,10 +252,10 @@ if [ $HCC_COV3 == "1" ]; then
fi
if [ $KMTHINLTO == "1" ]; then
$LLC -mtriple amdgcn-amd-amdhsa -mcpu=$AMDGPU_TARGET $CODE_OBJECT_FORMAT \
$HCC_OPT $KMOPTLLC -filetype=obj -o $2 $2.opt.bc
$HCC_OPT $KMOPTLLC -amdgpu-function-calls=$AMDGPU_FUNC_CALLS -filetype=obj -o $2 $2.opt.bc
else
$LLC -mtriple amdgcn-amd-amdhsa -mcpu=$AMDGPU_TARGET $CODE_OBJECT_FORMAT \
$HCC_OPT $KMOPTLLC -filetype=obj -o $2.isabin $2.opt.bc
$HCC_OPT $KMOPTLLC -amdgpu-function-calls=$AMDGPU_FUNC_CALLS -filetype=obj -o $2.isabin $2.opt.bc
fi

# error handling for llc
Expand All @@ -265,7 +272,7 @@ if [ $KMDUMPISA == "1" ]; then
cp $2.isabin ${KMDUMPDIR}/dump-$AMDGPU_TARGET.isabin
fi
$LLC -mtriple amdgcn-amd-amdhsa -mcpu=$AMDGPU_TARGET $CODE_OBJECT_FORMAT \
$HCC_OPT $KMOPTLLC -filetype=asm -o $2.isa $2.opt.bc
$HCC_OPT $KMOPTLLC -amdgpu-function-calls=$AMDGPU_FUNC_CALLS -filetype=asm -o $2.isa $2.opt.bc
mv $2.isa ${KMDUMPDIR}/dump-$AMDGPU_TARGET.isa
fi

Expand Down
19 changes: 17 additions & 2 deletions lib/clamp-link.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ fi
# enable bundle dumping
KMDUMPBUNDLE="${KMDUMPBUNDLE:=0}"

# flag for function calls enabled
AMDGPU_FUNC_CALLS="0"

# flag for COV3
HCC_COV3="0"

Expand Down Expand Up @@ -166,14 +169,18 @@ _thinlto_path() {
fi

# Perform clamp-device's opt and llc on each kernel individually in parallel
FUNC_CALLS=""
if [ $AMDGPU_FUNC_CALLS == "1" ]; then
FUNC_CALLS="--amdgpu-func-calls"
fi
CODE_OBJECT=""
if [ $HCC_COV3 == "1" ]; then
CODE_OBJECT="--hcc-cov3"
fi
i=0
for AMDGPU_TARGET in ${AMDGPU_TARGET_ARRAY[@]}
do
$CLAMP_DEVICE $KERNEL.thinlto.imported.bc $KERNEL-$AMDGPU_TARGET.isabin --amdgpu-target=$AMDGPU_TARGET $CODE_OBJECT $HCC_OPT
$CLAMP_DEVICE $KERNEL.thinlto.imported.bc $KERNEL-$AMDGPU_TARGET.isabin --amdgpu-target=$AMDGPU_TARGET $FUNC_CALLS $CODE_OBJECT $HCC_OPT

# error handling
pids=("${pids[@]}" "$!")
Expand Down Expand Up @@ -241,12 +248,16 @@ _default_path() {

declare -a pids
# for each GPU target, lower to GCN ISA in HSACO format
FUNC_CALLS=""
if [ $AMDGPU_FUNC_CALLS == "1" ]; then
FUNC_CALLS="--amdgpu-func-calls"
fi
CODE_OBJECT=""
if [ $HCC_COV3 == "1" ]; then
CODE_OBJECT="--hcc-cov3"
fi
for AMDGPU_TARGET in ${AMDGPU_TARGET_ARRAY[@]}; do
$CLAMP_DEVICE $TEMP_DIR/kernel.bc $TEMP_DIR/kernel-$AMDGPU_TARGET.hsaco --amdgpu-target=$AMDGPU_TARGET $CODE_OBJECT $HCC_OPT
$CLAMP_DEVICE $TEMP_DIR/kernel.bc $TEMP_DIR/kernel-$AMDGPU_TARGET.hsaco --amdgpu-target=$AMDGPU_TARGET $FUNC_CALLS $CODE_OBJECT $HCC_OPT
# error handling
pids+=("${pids[@]}" "$!")

Expand Down Expand Up @@ -329,6 +340,10 @@ do
AMDGPU_TARGET_ARRAY+=("${ARG#*=}")
continue
;;
--amdgpu-func-calls)
AMDGPU_FUNC_CALLS="1"
continue
;;
--hcc-cov3)
HCC_COV3="1"
continue
Expand Down
13 changes: 12 additions & 1 deletion lib/hc-kernel-assemble.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ KMDUMPLLVM="${KMDUMPLLVM:=0}"

AMDGPU_OBJ_CODEGEN="${AMDGPU_OBJ_CODEGEN:=0}"

# flag for function calls enabled
AMDGPU_FUNC_CALLS="0"

# flag for COV3
HCC_COV3="0"

Expand Down Expand Up @@ -71,6 +74,10 @@ do
AMDGPU_OBJ_CODEGEN=1
continue
;;
--amdgpu-func-calls)
AMDGPU_FUNC_CALLS="1"
continue
;;
--hcc-cov3)
HCC_COV3="1"
continue
Expand Down Expand Up @@ -131,12 +138,16 @@ if [ $AMDGPU_OBJ_CODEGEN == 1 ]; then

declare -a pids
# for each GPU target, lower to GCN ISA in HSACO format
FUNC_CALLS=""
if [ $AMDGPU_FUNC_CALLS == "1" ]; then
FUNC_CALLS="--amdgpu-func-calls"
fi
CODE_OBJECT=""
if [ $HCC_COV3 == "1" ]; then
CODE_OBJECT="--hcc-cov3"
fi
for AMDGPU_TARGET in ${AMDGPU_TARGET_ARRAY[@]}; do
$CLAMP_DEVICE "$KERNEL_INPUT" "$TEMP_DIR/kernel-$AMDGPU_TARGET.hsaco" --amdgpu-target=$AMDGPU_TARGET --early-finalize $CODE_OBJECT $HCC_OPT
$CLAMP_DEVICE "$KERNEL_INPUT" "$TEMP_DIR/kernel-$AMDGPU_TARGET.hsaco" --amdgpu-target=$AMDGPU_TARGET --early-finalize $FUNC_CALLS $CODE_OBJECT $HCC_OPT
# error handling
pids+=("${pids[@]}" "$!")

Expand Down
2 changes: 1 addition & 1 deletion llvm-project
2 changes: 1 addition & 1 deletion tests/Unit/FunctionCall/fcs_saxpy.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %hc -hc %s -o %t.out && %t.out
// RUN: %hc -hc -hc-function-calls %s -o %t.out && %t.out

#include <random>
#include <algorithm>
Expand Down

0 comments on commit 53a616a

Please sign in to comment.