Skip to content

Commit

Permalink
Merge pull request #472 from aaronenyeshi/parallel_target
Browse files Browse the repository at this point in the history
Parallelize CLAMP_DEVICE for each AMDGPU_TARGET
  • Loading branch information
whchung authored Sep 29, 2017
2 parents 9d4843e + e50632b commit 674c237
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/clamp-link.in
Original file line number Diff line number Diff line change
Expand Up @@ -404,21 +404,29 @@ if [ ${#LINK_KERNEL_ARGS[@]} != 0 ]; then
CLANG_OFFLOAD_BUNDLER_INPUTS_ARGS="-inputs=$TEMP_DIR/__empty.o"
CLANG_OFFLOAD_BUNDLER_TARGETS_ARGS="-targets=host-x86_64-unknown-linux"

declare -a pids
# for each GPU target, lower to GCN ISA in HSACO format
for AMDGPU_TARGET in ${AMDGPU_TARGET_ARRAY[@]}; do
$CLAMP_DEVICE $TEMP_DIR/kernel.bc $TEMP_DIR/kernel-$AMDGPU_TARGET.hsaco --amdgpu-target=$AMDGPU_TARGET
{ $CLAMP_DEVICE $TEMP_DIR/kernel.bc $TEMP_DIR/kernel-$AMDGPU_TARGET.hsaco --amdgpu-target=$AMDGPU_TARGET; } &

# error handling
ret=$?
if [ $ret != 0 ]; then
exit $ret
fi
pids+=("${pids[@]}" "$!")

# augment arguments to clang-offload-bundler
CLANG_OFFLOAD_BUNDLER_INPUTS_ARGS+=",$TEMP_DIR/kernel-$AMDGPU_TARGET.hsaco"
CLANG_OFFLOAD_BUNDLER_TARGETS_ARGS+=",hcc-amdgcn--amdhsa-$AMDGPU_TARGET"
done

# collect all the error codes from forked processes
# error handling
for pid in ${pids[*]}; do
wait $pid || ret=$((ret+$?))
done
if [ $ret != 0 ]; then
exit $ret
fi


# invoke clang-offload-bundler
$CLANG_OFFLOAD_BUNDLER -type=o $CLANG_OFFLOAD_BUNDLER_INPUTS_ARGS $CLANG_OFFLOAD_BUNDLER_TARGETS_ARGS -outputs=$TEMP_DIR/kernel.bundle

Expand Down

0 comments on commit 674c237

Please sign in to comment.