CMakeLists.txt 4.14 KB
Newer Older
incardon's avatar
incardon committed
1
if(CUDA_FOUND OR CUDA_ON_CPU)
incardon's avatar
incardon committed
2
	set(CUDA_SOURCES memory/CudaMemory.cu)
incardon's avatar
incardon committed
3
4
5
6
else()
	set(CUDA_SOURCES )
endif()

incardon's avatar
incardon committed
7
8
9
if (CUDA_ON_CPU)
	add_definitions(-DCUDA_ON_CPU)
        set_source_files_properties(${CUDA_SOURCES} PROPERTIES LANGUAGE CXX)
incardon's avatar
incardon committed
10
	set_source_files_properties(${CUDA_SOURCES} PROPERTIES COMPILE_FLAGS "-D__NVCC__ -DCUDART_VERSION=11000")
incardon's avatar
incardon committed
11
       	if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
incardon's avatar
incardon committed
12
13
14
        	add_definitions("-x c++")
        endif()
endif()
incardon's avatar
incardon committed
15

incardon's avatar
incardon committed
16
add_executable(mem main.cpp memory/HeapMemory.cpp util/cudify/cudify_vars.cpp util/cudify/cudify_unit_test.cu memory/mem_conf.cpp  ${CUDA_SOURCES})
incardon's avatar
incardon committed
17

incardon's avatar
incardon committed
18
19
add_library(ofpmmemory STATIC memory/HeapMemory.cpp util/cudify/cudify_vars.cpp memory/PtrMemory.cpp memory/mem_conf.cpp  ${CUDA_SOURCES})
add_library(ofpmmemory_dl SHARED memory/HeapMemory.cpp util/cudify/cudify_vars.cpp memory/PtrMemory.cpp memory/mem_conf.cpp  ${CUDA_SOURCES})
incardon's avatar
incardon committed
20

21
if ( CMAKE_COMPILER_IS_GNUCC )
22
    target_compile_options(mem PRIVATE "-Wno-deprecated-declarations")
23
    if (TEST_COVERAGE)
24
        target_compile_options(mem PRIVATE $<$<COMPILE_LANGUAGE:CXX>: -fprofile-arcs -ftest-coverage>)
25
26
27
28
    endif()
endif()


incardon's avatar
incardon committed
29
30
if (CUDA_FOUND)
	target_compile_options(mem PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:-Xcudafe "--display_error_number --diag_suppress=2885 --diag_suppress=2887  --diag_suppress=2888 --diag_suppress=186 --diag_suppress=111" --expt-extended-lambda>)
incardon's avatar
incardon committed
31
	if (TEST_COVERAGE)
incardon's avatar
incardon committed
32
                target_compile_options(mem PRIVATE $<$<COMPILE_LANGUAGE:CUDA>: -Xcompiler "-fprofile-arcs -ftest-coverage" >)
incardon's avatar
incardon committed
33
34
35
36
37
    endif()

    if (NOT CUDA_ON_CPU)
        set_source_files_properties(memory/mem_conf.cpp PROPERTIES LANGUAGE CUDA)
    endif()
incardon's avatar
incardon committed
38

incardon's avatar
incardon committed
39
endif()
incardon's avatar
incardon committed
40

incardon's avatar
incardon committed
41
target_include_directories (mem PUBLIC ${CUDA_INCLUDE_DIRS})
incardon's avatar
incardon committed
42
43
target_include_directories (mem PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories (mem PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/config)
incardon's avatar
incardon committed
44
target_include_directories (mem PUBLIC ${Boost_INCLUDE_DIRS})
incardon's avatar
incardon committed
45
46
47
if (ALPAKA_ROOT)
	target_include_directories (mem PUBLIC ${ALPAKA_ROOT}/include)
endif()
incardon's avatar
incardon committed
48
49
50
if (CUDA_FOUND)
	target_include_directories (mem PUBLIC ${CUDA_INCLUDE_DIRS})
endif()
incardon's avatar
incardon committed
51
52
53

target_include_directories (ofpmmemory PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories (ofpmmemory PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/config)
incardon's avatar
incardon committed
54
target_include_directories (ofpmmemory PUBLIC ${ALPAKA_ROOT}/include)
incardon's avatar
incardon committed
55
target_include_directories (ofpmmemory PUBLIC ${Boost_INCLUDE_DIRS})
incardon's avatar
incardon committed
56

incardon's avatar
incardon committed
57
58
target_include_directories (ofpmmemory_dl PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories (ofpmmemory_dl PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/config)
incardon's avatar
incardon committed
59
target_include_directories (ofpmmemory_dl PUBLIC ${ALPAKA_ROOT}/include)
incardon's avatar
incardon committed
60
target_include_directories (ofpmmemory_dl PUBLIC ${Boost_INCLUDE_DIRS})
incardon's avatar
incardon committed
61
target_link_libraries(mem ${Boost_LIBRARIES_BCK})
incardon's avatar
incardon committed
62
63
target_link_libraries(ofpmmemory ${Boost_LIBRARIES_BCK})
target_link_libraries(ofpmmemory_dl ${Boost_LIBRARIES_BCK})
incardon's avatar
incardon committed
64

65
if (TEST_COVERAGE)
66
    target_link_libraries(mem -lgcov)
67
68
endif()

incardon's avatar
incardon committed
69
70
71
install(TARGETS ofpmmemory ofpmmemory_dl
	DESTINATION openfpm_devices/lib )

incardon's avatar
incardon committed
72
73
74
75
76
77
install(FILES memory/ExtPreAlloc.hpp 
	      memory/BHeapMemory.hpp  
	      memory/HeapMemory.hpp 
	      memory/memory.hpp 
	      memory/PtrMemory.hpp
	      memory/CudaMemory.cuh
incardon's avatar
incardon committed
78
	      util/util_unit_tests.hpp
incardon's avatar
incardon committed
79
80
	      DESTINATION openfpm_devices/include/memory)

incardon's avatar
incardon committed
81
82
83
84
85
86
87
88
89
install(FILES memory/ExtPreAlloc.hpp
              memory/BHeapMemory.hpp
              memory/HeapMemory.hpp
              memory/memory.hpp
              memory/PtrMemory.hpp
              memory/CudaMemory.cuh
              util/util_unit_tests.hpp
              DESTINATION openfpm_devices/include/memory)

incardon's avatar
incardon committed
90
install(FILES util/print_stack.hpp
incardon's avatar
incardon committed
91
92
93
94
	      util/cuda_launch.hpp
	      util/se_util.hpp
	      util/cuda_util.hpp
	      util/cuda_kernel_error_checker.hpp
incardon's avatar
incardon committed
95
96
	DESTINATION openfpm_devices/include/util)

incardon's avatar
incardon committed
97
98
99
100
101
102
install(FILES util/cudify/cudify_alpaka.hpp
              util/cudify/cudify_hardware_alpaka.hpp
              util/cudify/cudify_hardware_common.hpp
              util/cudify/cudify_sequencial.hpp
              util/cudify/cudify.hpp
        DESTINATION openfpm_devices/include/util/cudify)
incardon's avatar
incardon committed
103
104
105
106
107

install(FILES ptr_info.hpp
	DESTINATION openfpm_devices/include)