Mentions légales du service

Skip to content
Snippets Groups Projects
Commit f08ed1d4 authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

cmake/gpucublas: Move the cuda toolkit detection to better select the inclusion of extra kernels

parent 806a2160
No related branches found
No related tags found
1 merge request!470Issue #127: Fix the protection of half precision kernels with cuda
......@@ -26,6 +26,48 @@
#
###
# Add CUDA kernel if compiler and toolkit are available
# -----------------------------------------------------
include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
enable_language(CUDA)
find_package(CUDAToolkit)
else()
message(STATUS "CUDA language is not supported")
endif()
if (CUDAToolkit_FOUND)
set(GPUCUBLAS_HAVE_CUDA_TOOLKIT ON CACHE INTERNAL "Indicate if cuda kernels are enabled or not" FORCE)
include(SetCMakeCudaArchitectures)
if (CUDAToolkit_VERSION VERSION_GREATER_EQUAL "7.5")
set(GPUCUBLAS_HAVE_CUDA_HALF ON CACHE INTERNAL "Indicate if half precision support is enabled or not" FORCE)
else()
set(GPUCUBLAS_HAVE_CUDA_HALF OFF CACHE INTERNAL "Indicate if half precision support is enabled or not" FORCE)
endif()
else()
set(GPUCUBLAS_HAVE_CUDA_TOOLKIT OFF CACHE INTERNAL "Indicate if cuda kernels are enabled or not" FORCE)
set(GPUCUBLAS_HAVE_CUDA_HALF OFF CACHE INTERNAL "Indicate if half precision support is enabled or not" FORCE)
endif()
if ( GPUCUBLAS_HAVE_CUDA_HALF )
##morse_cmake_required_set( CUBLAS )
set(CMAKE_REQUIRED_LIBRARIES CUDA::CUBLAS)
check_function_exists(cublasHgemm GPUCUBLAS_HAVE_CUBLASHGEMM)
if ( GPUCUBLAS_HAVE_CUBLASHGEMM )
message("-- ${Blue}Add definition HAVE_CUBLASHGEMM${ColourReset}")
endif()
check_function_exists(cublasGemmEx GPUCUBLAS_HAVE_CUBLASGEMMEX)
if ( GPUCUBLAS_HAVE_CUBLASGEMMEX )
message("-- ${Blue}Add definition HAVE_CUBLASGEMMEX${ColourReset}")
endif()
morse_cmake_required_unset()
endif()
add_subdirectory(include)
add_subdirectory(compute)
add_subdirectory(eztrace_module)
......
......@@ -56,24 +56,15 @@ set(ZSRC
cuda_zunmqrt.c
)
# Add CUDA kernel if compiler and toolkit are available
# -----------------------------------------------------
include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
enable_language(CUDA)
find_package(CUDAToolkit)
else()
message(STATUS "CUDA language is not supported")
endif()
if (CUDAToolkit_FOUND)
include(SetCMakeCudaArchitectures)
if ( GPUCUBLAS_HAVE_CUDA_TOOLKIT )
set(ZSRC
${ZSRC}
cuda_zlag2c.cu
)
endif()
if ( GPUCUBLAS_HAVE_CUDA_HALF )
set(ZSRC
${ZSRC}
cuda_dlag2h.cu
)
endif()
......@@ -102,13 +93,24 @@ precisions_rules_py(
set(GPUCUBLAS_SRCS
${GPUCUBLAS_SRCS_GENERATED}
cuda_hgemm.c
cuda_gemmex.c
cudaglobal.c
)
if (GPUCUBLAS_HAVE_CUBLASHGEMM)
set(GPUCUBLAS_SRCS
${GPUCUBLAS_SRCS}
cuda_hgemm.c
)
# Need to use CXX compiler to have the __half support and access to cublasHgemm()
set_source_files_properties( cuda_hgemm.c PROPERTIES LANGUAGE CXX )
endif()
# Need to use CXX compiler to have the __half support and access to cublasHgemm()
set_source_files_properties( cuda_hgemm.c PROPERTIES LANGUAGE CXX )
if (GPUCUBLAS_HAVE_CUBLASGEMMEX)
set(GPUCUBLAS_SRCS
${GPUCUBLAS_SRCS}
cuda_gemmex.c
)
endif()
# Force generation of sources
# ---------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment