forked from weft/warp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
237 lines (198 loc) · 7.47 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#set project name
project(WARP)
#define cmake commands/policies
#need >= v2.8.10, see http://redmine.gromacs.org/issues/1051
cmake_minimum_required(VERSION 2.8.10)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} LD_LIBRARY_PATH)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
include_directories(${CMAKE_SOURCE_DIR})
#find CUDA; we need that
find_package(CUDA QUIET REQUIRED)
include_directories("${CUDA_TOOLKIT_INCLUDE}")
include_directories("${CUDA_INCLUDE_DIRS}")
set(OptiX_ROOT_DIR CACHE PATH "Root directory of OptiX")
find_path(OptiX_INCLUDE_DIR optix.h
${OptiX_ROOT_DIR}/include
)
find_library(OptiX_LIBRARY
NAMES optix optix${CMAKE_SIZEOF_VOID_P}
PATHS
${OptiX_ROOT_DIR}/lib64
)
if(OptiX_LIBRARY)
if (OptiX_INCLUDE_DIR)
# OK, found all we need
set(OptiX_FOUND TRUE)
get_filename_component(OptiX_LINK_DIRECTORIES ${OptiX_LIBRARY} PATH)
else (OptiX_INCLUDE_DIR)
message("OptiX include dir not found. Set OptiX_ROOT_DIR to find it.")
endif(OptiX_INCLUDE_DIR)
else(OptiX_LIBRARY)
message("OptiX lib not found. Set OptiX_ROOT_DIR to find it.")
endif(OptiX_LIBRARY)
mark_as_advanced(
OptiX_INCLUDE_DIR
OptiX_LIBRARY
OptiX_LINK_DIRECTORIES
)
include_directories(${OptiX_INCLUDE_DIR})
set(CUDA_64_BIT_DEVICE_CODE ON)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -arch=sm_30; --use_fast_math; --compiler-options '-fPIC')
set (CUDPP_ROOT_DIR CACHE PATH "Root directory for CUDPP")
#http://suren.me/webbzr/normxcorr/trunk/annotate/27/dict_hw/cmake/FindCUDPP.cmake?remember=7
find_path(CUDPP_INCLUDE_DIR cudpp.h
${CUDPP_ROOT_DIR}/cudpp/include
${CUDPP_ROOT_DIR}/include
)
find_library(CUDPP_LIBRARY
NAMES cudpp cudpp${CMAKE_SIZEOF_VOID_P}
PATHS
${CUDPP_ROOT_DIR}/lib
)
if(CUDPP_LIBRARY)
if (CUDPP_INCLUDE_DIR)
# OK, found all we need
set(CUDPP_FOUND TRUE)
get_filename_component(CUDPP_LINK_DIRECTORIES ${CUDPP_LIBRARY} PATH)
else (CUDPP_INCLUDE_DIR)
message("CUDPP include dir not found. Set CUDPP_ROOT_DIR to find it.")
endif(CUDPP_INCLUDE_DIR)
else(CUDPP_LIBRARY)
message("CUDPP lib not found. Set CUDPP_ROOT_DIR to find it.")
endif(CUDPP_LIBRARY)
mark_as_advanced(
CUDPP_INCLUDE_DIR
CUDPP_LIBRARY
CUDPP_LINK_DIRECTORIES
)
# find numpy and include the numpy headers
find_package(Numpy REQUIRED)
include_directories("${NUMPY_INCLUDE_DIR}")
set(libs ${libs} ${CUDPP_LIBRARY})
set(libs ${libs} ${OptiX_LIBRARY})
set(libs ${libs} ${CUDA_LIBRARIES})
set(libs ${libs} ${CUDA_CUDART_LIBRARY})
set(libs ${libs} ${CUDA_CUBLAS_LIBRARY})
set(libs ${libs} ${CUDA_curand_LIBRARY})
include_directories(${CUDPP_INCLUDE_DIR})
#http://stackoverflow.com/questions/11041299/python-h-no-such-file-or-directory
find_package(PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
set(libs ${libs} ${PYTHON_LIBRARIES})
find_package(PNG REQUIRED)
set(libs ${libs} ${PNG_LIBRARY})
#mac stuff
if(APPLE)
set(CMAKE_OSX_VERSION "10.11" CACHE STRING "OSX Version number")
include_directories("/usr/local/include")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=${CMAKE_OSX_VERSION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=${CMAKE_OSX_VERSION}")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} --compiler-options '-mmacosx-version-min=${CMAKE_OSX_VERSION}'")
endif(APPLE)
include( UseCython )
execute_process(COMMAND "${CYTHON_EXECUTABLE}" "-V"
ERROR_VARIABLE CYTHON_VERSION
ERROR_STRIP_TRAILING_WHITESPACE)
message( STATUS "Cython Version: " ${CYTHON_VERSION} )
cuda_compile_ptx(camera camera.cu)
cuda_compile_ptx(miss miss.cu)
cuda_compile_ptx(hits_mesh hits_mesh.cu)
cuda_compile_ptx(box_mesh box_mesh.cu)
cuda_compile_ptx(cylinder_mesh cylinder_mesh.cu)
cuda_compile_ptx(hex_mesh hex_mesh.cu)
cuda_compile_ptx(sphere_mesh sphere_mesh.cu)
#http://stackoverflow.com/questions/26198294/nvcc-compile-to-ptx-using-cmakes-cuda-compile-ptx
add_custom_command(OUTPUT camera.ptx COMMAND ${CMAKE_COMMAND} -E rename ${camera} camera.ptx DEPENDS ${camera})
add_custom_command(OUTPUT miss.ptx COMMAND ${CMAKE_COMMAND} -E rename ${miss} miss.ptx DEPENDS ${miss})
add_custom_command(OUTPUT hits_mesh.ptx COMMAND ${CMAKE_COMMAND} -E rename ${hits_mesh} hits_mesh.ptx DEPENDS ${hits_mesh})
add_custom_command(OUTPUT box_mesh.ptx COMMAND ${CMAKE_COMMAND} -E rename ${box_mesh} box_mesh.ptx DEPENDS ${box_mesh})
add_custom_command(OUTPUT cylinder_mesh.ptx COMMAND ${CMAKE_COMMAND} -E rename ${cylinder_mesh} cylinder_mesh.ptx DEPENDS ${cylinder_mesh})
add_custom_command(OUTPUT hex_mesh.ptx COMMAND ${CMAKE_COMMAND} -E rename ${hex_mesh} hex_mesh.ptx DEPENDS ${hex_mesh})
add_custom_command(OUTPUT sphere_mesh.ptx COMMAND ${CMAKE_COMMAND} -E rename ${sphere_mesh} sphere_mesh.ptx DEPENDS ${sphere_mesh})
add_custom_target(camera ALL
DEPENDS camera.ptx camera.cu
SOURCES camera.cu)
add_custom_target(miss ALL
DEPENDS miss.ptx miss.cu
SOURCES miss.cu)
add_custom_target(hits_mesh ALL
DEPENDS hits_mesh.ptx hits_mesh.cu
SOURCES hits_mesh.cu)
add_custom_target(box_mesh ALL
DEPENDS box_mesh.ptx box_mesh.cu
SOURCES box_mesh.cu)
add_custom_target(cylinder_mesh ALL
DEPENDS cylinder_mesh.ptx cylinder_mesh.cu
SOURCES cylinder_mesh.cu)
add_custom_target(hex_mesh ALL
DEPENDS hex_mesh.ptx hex_mesh.cu
SOURCES hex_mesh.cu)
add_custom_target(sphere_mesh ALL
DEPENDS sphere_mesh.ptx sphere_mesh.cu
SOURCES sphere_mesh.cu)
#build CUDA executables
cuda_compile(set_positions_rand set_positions_rand.cu)
cuda_compile(find_E_grid_index find_E_grid_index.cu)
cuda_compile(sample_fissile_energy sample_fissile_energy.cu)
cuda_compile(macro_micro macro_micro.cu)
cuda_compile(copy_points copy_points.cu)
cuda_compile(scatter_level scatter_level.cu)
cuda_compile(scatter_conti scatter_conti.cu)
cuda_compile(scatter_multi scatter_multi.cu)
cuda_compile(fission fission.cu)
cuda_compile(pop_fission pop_fission.cu)
cuda_compile(rebase_yield rebase_yield.cu)
cuda_compile(reaction_edges3 reaction_edges3.cu)
cuda_compile(write_to_file write_to_file.cu)
cuda_compile(safety_check safety_check.cu)
cuda_compile(check_pointers check_pointers.cu)
# Sources:
set(warp_executable_srcs
wprimitive.cpp
mt19937ar.cpp
optix_stuff.cpp
whistory.cpp
wgeometry.cpp
)
set(warp_cuda_srcs
${set_positions_rand}
${find_E_grid_index}
${sample_fissile_energy}
${macro_micro}
${copy_points}
${scatter_level}
${scatter_conti}
${scatter_multi}
${fission}
${pop_fission}
${rebase_yield}
${reaction_edges3}
${write_to_file}
${safety_check}
${check_pointers}
)
ADD_LIBRARY(warp SHARED ${warp_executable_srcs} ${warp_cuda_srcs})
# link libs
TARGET_LINK_LIBRARIES(warp ${libs})
# actual target:
add_executable(dissertation ${warp_executable_srcs} ${warp_cuda_srcs} main.cpp)
add_executable(benchmarks ${warp_executable_srcs} ${warp_cuda_srcs} benchmarks.cpp)
# standalone ace
set_source_files_properties("${PROJECT_SOURCE_DIR}/ace.pyx"
PROPERTIES CYTHON_IS_CXX TRUE)
cython_add_module(ace ace.pyx)
#target_link_libraries(ace pyne)
# link libs
target_link_libraries(dissertation ${libs})
target_link_libraries(benchmarks ${libs})
#enable_testing()
#find_package(GTest REQUIRED)
#add_subdirectory(test)
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
include_directories(${PYTHON_INCLUDE_PATH})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set_source_files_properties(warp.i PROPERTIES CPLUSPLUS ON)
set_source_files_properties(warp.i PROPERTIES SWIG_FLAGS "-c++")
swig_add_module(warp python warp.i)
swig_link_libraries(warp warp ${PYTHON_LIBRARIES})