Commit d36b1758 authored by BRAMAS Berenger's avatar BRAMAS Berenger

Enable compilation with CUDA (when we generate the library)

parent b5991826
......@@ -289,8 +289,28 @@ if( ScalFMM_USE_STARPU )
MESSAGE(STATUS " STARPU_LIBRARIES = ${STARPU_LIBRARIES}")
MESSAGE(STATUS " STARPU_INCLUDES = ${STARPU_INCLUDES}")
OPTION( ScalFMM_USE_CUDA "Set to ON to use CUDA with StarPU" OFF )
if(ScalFMM_USE_CUDA)
execute_process(COMMAND nvcc --version ERROR_VARIABLE cuda_error_output OUTPUT_QUIET)
if(cuda_error_output)
message( FATAL_ERROR "nvcc is needed with CUDA." )
endif()
if(NOT DEFINED CUSTOM_CUDA_FLAGS)
SET( CUSTOM_CUDA_FLAGS "-std=c++11;-arch=sm_20" CACHE STRING "Set your CUDA flags, for example : -arch=sm_20;-ptxas-options=-v;-use_fast_math")
endif()
# This is needed to remove backslash after space in ADD_CUSTOM_COMMAND
SEPARATE_ARGUMENTS(CUSTOM_CUDA_FLAGS)
MESSAGE( STATUS "CUSTOM_CUDA_FLAGS = ${CUSTOM_CUDA_FLAGS}" )
# Add libcudart and cuda.h
# link_directories($ENV{CUDA_LIB})
include_directories(${$ENV{CUDA_INC}})
SET(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}; -L$ENV{CUDA_LIB}; -lcudart")
endif()
endif(ScalFMM_USE_STARPU)
list(APPEND FUSE_LIST "STARPU")
list(APPEND FUSE_LIST "CUDA")
#
##################################################################
# Use SSE #
......
......@@ -17,11 +17,35 @@ file(
./*.cpp
)
# Add CUDA files once they are compiled from cu to .o
if(ScalFMM_USE_CUDA)
# Find all the CU files in my project
file(GLOB_RECURSE source_cu_files ./*.cu)
# Iterate and add builind command for each file
set( SCALFMM_CUDA_SOURCES "" )
FOREACH (_file ${source_cu_files})
GET_FILENAME_COMPONENT (_filewe ${_file} NAME_WE)
SET (_filehpp_output ${CMAKE_CURRENT_BINARY_DIR}/${_filewe}.o)
ADD_CUSTOM_COMMAND(OUTPUT ${_filehpp_output}
DEPENDS ${_file}
COMMAND echo ARGS Compiling ${_filewe}
COMMAND nvcc ARGS -c ${_file} -o ${_filehpp_output} ${CUSTOM_CUDA_FLAGS})
LIST (APPEND SCALFMM_CUDA_SOURCES ${_filehpp_output})
ENDFOREACH ()
MESSAGE( STATUS "SCALFMM_CUDA_SOURCES = ${SCALFMM_CUDA_SOURCES}" )
endif()
# Adding cpp files to project
add_library(
scalfmm
STATIC
${source_lib_files}
${SCALFMM_CUDA_SOURCES}
)
# Add blas library (even if it is set to off)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment