Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for all ROCm supported targets. Fix triple to match AMDGPU. #840

Open
wants to merge 3 commits into
base: clang_tot_upgrade
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -411,30 +411,32 @@ if (HCC_INTEGRATE_ROCDL)
file(MAKE_DIRECTORY ${ROCDL_BUILD_DIR}/lib)
add_custom_target(rocdl_links DEPENDS ${AMDGCN_LIB_TARGETS})
add_custom_command(TARGET rocdl_links POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink ../hc/hc.amdgcn.bc hc.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../irif/irif.amdgcn.bc irif.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../opencl/opencl.amdgcn.bc opencl.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../ockl/ockl.amdgcn.bc ockl.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../hc/hc.amdgcn.bc hc.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_701.amdgcn.bc oclc_isa_version_701.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_802.amdgcn.bc oclc_isa_version_802.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_810.amdgcn.bc oclc_isa_version_810.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_finite_only_on.amdgcn.bc oclc_finite_only_on.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_900.amdgcn.bc oclc_isa_version_900.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_finite_only_off.amdgcn.bc oclc_finite_only_off.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_801.amdgcn.bc oclc_isa_version_801.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_700.amdgcn.bc oclc_isa_version_700.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_daz_opt_on.amdgcn.bc oclc_daz_opt_on.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_unsafe_math_off.amdgcn.bc oclc_unsafe_math_off.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_800.amdgcn.bc oclc_isa_version_800.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_daz_opt_off.amdgcn.bc oclc_daz_opt_off.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_unsafe_math_on.amdgcn.bc oclc_unsafe_math_on.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_correctly_rounded_sqrt_off.amdgcn.bc oclc_correctly_rounded_sqrt_off.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_803.amdgcn.bc oclc_isa_version_803.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_correctly_rounded_sqrt_on.amdgcn.bc oclc_correctly_rounded_sqrt_on.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_901.amdgcn.bc oclc_isa_version_901.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../ocml/ocml.amdgcn.bc ocml.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_700.amdgcn.bc oclc_isa_version_700.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_701.amdgcn.bc oclc_isa_version_701.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_702.amdgcn.bc oclc_isa_version_702.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_800.amdgcn.bc oclc_isa_version_800.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_801.amdgcn.bc oclc_isa_version_801.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_802.amdgcn.bc oclc_isa_version_802.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_803.amdgcn.bc oclc_isa_version_803.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_804.amdgcn.bc oclc_isa_version_804.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_810.amdgcn.bc oclc_isa_version_810.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_900.amdgcn.bc oclc_isa_version_900.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_901.amdgcn.bc oclc_isa_version_901.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_902.amdgcn.bc oclc_isa_version_902.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../oclc/oclc_isa_version_906.amdgcn.bc oclc_isa_version_906.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../ocml/ocml.amdgcn.bc ocml.amdgcn.bc
COMMAND ${CMAKE_COMMAND} -E create_symlink ../opencl/opencl.amdgcn.bc opencl.amdgcn.bc
WORKING_DIRECTORY ${ROCDL_BUILD_DIR}/lib
)
# install ROCm Device Library in hcc
Expand Down
20 changes: 14 additions & 6 deletions lib/clamp-device.in
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ if [ $AMDGPU_TARGET == "gfx700" ]; then
elif [ $AMDGPU_TARGET == "gfx701" ]; then
OCLC_ISA_VERSION_LIB="$ROCM_LIB/oclc_isa_version_701.amdgcn.bc"
HCC_EXTRA_ARCH_FILE=$HCC_EXTRA_LIBRARIES_GFX701
elif [ $AMDGPU_TARGET == "gfx702" ]; then
OCLC_ISA_VERSION_LIB="$ROCM_LIB/oclc_isa_version_702.amdgcn.bc"
HCC_EXTRA_ARCH_FILE=$HCC_EXTRA_LIBRARIES_GFX702
elif [ $AMDGPU_TARGET == "gfx801" ]; then
OCLC_ISA_VERSION_LIB="$ROCM_LIB/oclc_isa_version_801.amdgcn.bc"
HCC_EXTRA_ARCH_FILE=$HCC_EXTRA_LIBRARIES_GFX801
Expand All @@ -150,8 +153,8 @@ elif [ $AMDGPU_TARGET == "gfx803" ]; then
elif [ $AMDGPU_TARGET == "gfx900" ]; then
OCLC_ISA_VERSION_LIB="$ROCM_LIB/oclc_isa_version_900.amdgcn.bc"
HCC_EXTRA_ARCH_FILE=$HCC_EXTRA_LIBRARIES_GFX900
elif [ $AMDGPU_TARGET == "gfx901" ]; then
OCLC_ISA_VERSION_LIB="$ROCM_LIB/oclc_isa_version_901.amdgcn.bc"
elif [ $AMDGPU_TARGET == "gfx902" ]; then
OCLC_ISA_VERSION_LIB="$ROCM_LIB/oclc_isa_version_902.amdgcn.bc"
HCC_EXTRA_ARCH_FILE=$HCC_EXTRA_LIBRARIES_GFX901
elif [ $AMDGPU_TARGET == "gfx906" ]; then
OCLC_ISA_VERSION_LIB="$ROCM_LIB/oclc_isa_version_906.amdgcn.bc"
Expand Down Expand Up @@ -195,7 +198,9 @@ fi

# Optimization notes:
# -disable-simplify-libcalls: prevents transforming loops into library calls such as memset, memcopy on GPU
$OPT -mtriple amdgcn--amdhsa-amdgiz -mcpu=$AMDGPU_TARGET -amdgpu-internalize-symbols -disable-simplify-libcalls $KMOPTOPT -verify $2.selected.bc -o $2.opt.bc
$OPT -mtriple amdgcn-amd-amdhsa -mcpu=$AMDGPU_TARGET \
-amdgpu-internalize-symbols -disable-simplify-libcalls $KMOPTOPT -verify \
$2.selected.bc -o $2.opt.bc

# error handling for opt
RETVAL=$?
Expand All @@ -218,9 +223,11 @@ if [ $KMDUMPLLVM == "1" ]; then
fi

if [ $KMTHINLTO == "1" ]; then
$LLC $KMOPTLLC -mtriple amdgcn--amdhsa-amdgiz -mcpu=$AMDGPU_TARGET -filetype=obj -o $2 $2.opt.bc
$LLC $KMOPTLLC -mtriple amdgcn-amd-amdhsa -mcpu=$AMDGPU_TARGET -filetype=obj \
-o $2 $2.opt.bc
else
$LLC $KMOPTLLC -mtriple amdgcn--amdhsa-amdgiz -mcpu=$AMDGPU_TARGET -filetype=obj -o $2.isabin $2.opt.bc
$LLC $KMOPTLLC -mtriple amdgcn-amd-amdhsa -mcpu=$AMDGPU_TARGET \
-filetype=obj -o $2.isabin $2.opt.bc
fi

# error handling for llc
Expand All @@ -236,7 +243,8 @@ if [ $KMDUMPISA == "1" ]; then
else
cp $2.isabin ./dump-$AMDGPU_TARGET.isabin
fi
$LLC $KMOPTLLC -mtriple amdgcn--amdhsa-amdgiz -mcpu=$AMDGPU_TARGET -filetype=asm -o $2.isa $2.opt.bc
$LLC $KMOPTLLC -mtriple amdgcn-amd-amdhsa -mcpu=$AMDGPU_TARGET -filetype=asm \
-o $2.isa $2.opt.bc
mv $2.isa ${KMDUMPDIR}/dump-$AMDGPU_TARGET.isa
fi

Expand Down
7 changes: 6 additions & 1 deletion lib/hsa/mcwamp_hsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2671,11 +2671,16 @@ class HSADevice final : public KalmarDevice

switch(MACH) {
case hc::EF_AMDGPU_MACH_AMDGCN_GFX701 : triple.append("701"); break;
case hc::EF_AMDGPU_MACH_AMDGCN_GFX702 : triple.append("702"); break;
case hc::EF_AMDGPU_MACH_AMDGCN_GFX801 : triple.append("801"); break;
case hc::EF_AMDGPU_MACH_AMDGCN_GFX802 : triple.append("802"); break;
case hc::EF_AMDGPU_MACH_AMDGCN_GFX803 : triple.append("803"); break;
case hc::EF_AMDGPU_MACH_AMDGCN_GFX900 : triple.append("900"); break;
case hc::EF_AMDGPU_MACH_AMDGCN_GFX902 : triple.append("902"); break;
case hc::EF_AMDGPU_MACH_AMDGCN_GFX906 : triple.append("906"); break;
}

if (reader.get_flags() & hc::EF_AMDGPU_XNACK) triple += "+xnack";

const auto isa{get_isa_name_from_triple(std::move(triple))};

hsa_isa_t co_isa{};
Expand Down