diff --git a/lib/clamp-link.in b/lib/clamp-link.in index 61f75d58737..59d688e76d9 100755 --- a/lib/clamp-link.in +++ b/lib/clamp-link.in @@ -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