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

Support Volta+ arch in custatevec backend #696

Merged
merged 2 commits into from
Sep 27, 2023
Merged
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
42 changes: 17 additions & 25 deletions .github/workflows/publishing.yml
1tnguyen marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -583,31 +583,23 @@ jobs:
if [ -n "$(cat $file | grep "GPU_REQUIREMENTS")" ]; then
target=`basename $file | cut -d "." -f 1`
echo "## Execute on $target target" >> $GITHUB_STEP_SUMMARY
for file in `find /home/cudaq/examples -name '*.cpp' -not -path '*/providers/*'`; do
case $file in
/home/cudaq/examples/cpp/other/gradients.cpp)
echo ":white_flag: Issue: https://github.com/NVIDIA/cuda-quantum/issues/622. Test skipped." >> $GITHUB_STEP_SUMMARY ;;
/home/cudaq/examples/cpp/algorithms/qaoa_maxcut.cpp)
echo ":white_flag: Issue: https://github.com/NVIDIA/cuda-quantum/issues/623. Test skipped." >> $GITHUB_STEP_SUMMARY ;;
*)
ex=$(basename -- "$file")
echo "Validating $ex:"
nvq++ $file --target $target
status=$?
if [ $status -eq 0 ]; then
./a.out
status=$?
if [ $status -eq 0 ]; then
echo ":white_check_mark: Successfully ran $ex." >> $GITHUB_STEP_SUMMARY
else
echo ":x: Failed to execute $ex." >> $GITHUB_STEP_SUMMARY
status_sum=$((status_sum+1))
fi
else
echo ":x: Compilation failed for $ex." >> $GITHUB_STEP_SUMMARY
status_sum=$((status_sum+1))
fi ;;
esac
for ex in `find /home/cudaq/examples -name '*.cpp' -not -path '*/providers/*'`; do
filename=$(basename -- "$ex")
nvq++ $ex --target $target
status=$?
if [ $status -eq 0 ]; then
./a.out
status=$?
if [ $status -eq 0 ]; then
echo ":white_check_mark: Successfully ran $filename." >> $GITHUB_STEP_SUMMARY
else
echo ":x: Failed to execute $filename." >> $GITHUB_STEP_SUMMARY
status_sum=$((status_sum+1))
fi
else
echo ":x: Compilation failed for $filename." >> $GITHUB_STEP_SUMMARY
status_sum=$((status_sum+1))
fi
done
fi
done
Expand Down
26 changes: 23 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,31 @@ target_compile_options(spdlog PRIVATE -Wno-covered-switch-default)
include(CheckLanguage)
check_language(CUDA)
set(CUDA_FOUND FALSE)
# Generate -gencode arch=compute_XX,code=sm_XX for list of supported
# arch values.
# List should be sorted in increasing order.
function(CUDA_get_gencode_args out_args_string arch_values)
# allow the user to pass the list like a normal variable
set(arch_list ${arch_values} ${ARGN})
set(out "")
foreach(arch IN LISTS arch_list)
set(out "${out} -gencode arch=compute_${arch},code=sm_${arch}")
endforeach(arch)

# Repeat the last one as to ensure the generation of PTX for most
# recent virtual architecture for forward compatibility
list(GET arch_list -1 last_arch)
set(out "${out} -gencode arch=compute_${last_arch},code=compute_${last_arch}")
set(${out_args_string} ${out} PARENT_SCOPE)
endfunction()

if(CMAKE_CUDA_COMPILER)
if (NOT CUDA_ARCH_BIN)
set(CUDA_ARCH_BIN 80)
if (NOT CUDA_TARGET_ARCHS)
# Volta, Ampere, Hopper
set(CUDA_TARGET_ARCHS "70;80;90")
endif()
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -shared -std=c++17 -gencode arch=compute_${CUDA_ARCH_BIN},code=sm_${CUDA_ARCH_BIN} --compiler-options -fPIC")
CUDA_get_gencode_args(CUDA_gencode_flags ${CUDA_TARGET_ARCHS})
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -shared -std=c++17 ${CUDA_gencode_flags} --compiler-options -fPIC")

enable_language(CUDA)
set(CUDA_FOUND TRUE)
Expand Down
Loading