Skip to content

Commit 270e549

Browse files
committed
Relocate files
1 parent 596e9d3 commit 270e549

File tree

2 files changed

+382
-384
lines changed

2 files changed

+382
-384
lines changed

CMakeLists.txt

+382-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,388 @@ endif ()
3535
# make sure changes to revision.h is not logged
3636
execute_process(COMMAND git update-index --assume-unchanged Toolbox/revision.h WORKING_DIRECTORY ${ROOT})
3737

38-
include(${ROOT}/Option.cmake)
38+
include_directories(${ROOT})
39+
include_directories(Include)
40+
include_directories(Include/metis)
41+
include_directories(Include/fmt/include)
42+
43+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Debug Release RelWithDebInfo MinSizeRel")
44+
45+
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
46+
47+
set(BUILD_PACKAGE "" CACHE STRING "DEB OR RPM")
48+
49+
option(BUILD_SHARED_LIBS "Build all libraries as shared ones." OFF)
50+
option(BUILD_DLL_EXAMPLE "Build dynamic linked library examples." OFF)
51+
option(BUILD_MULTITHREAD "Build with multi-threaded support via TBB." OFF)
52+
option(USE_SUPERLUMT "Use multi-threaded SuperLU. Note the performance may not be better than the sequential version." OFF)
53+
option(USE_VTK "Enable visualisation via VTK. Note external VTK libraries need to be compiled in advance." OFF)
54+
option(USE_HDF5 "Enable recording results in HDF5 format." ON)
55+
option(USE_AVX "Enable AVX support." OFF)
56+
option(USE_AVX2 "Enable AVX2 support." ON)
57+
option(USE_AVX512 "Enable AVX512 support." OFF)
58+
option(USE_MKL "Use Intel MKL instead of OpenBLAS." OFF)
59+
if (LINUX AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
60+
option(USE_AOCL "Use AMD Optimizing CPU Libraries instead of OpenBLAS." OFF)
61+
endif ()
62+
option(USE_MIMALLOC "Use mimalloc instead of default memory allocator." OFF)
63+
option(USE_SYS_LIB "Use libraries installed on the system instead of the bundled ones." OFF)
64+
if (USE_MKL)
65+
option(USE_INTEL_OPENMP "Use Intel OpenMP implementation on Linux and macOS" ON)
66+
option(LINK_DYNAMIC_MKL "Link dynamic Intel MKL libraries." ON)
67+
option(USE_MPI "Enable MPI based global solvers." OFF)
68+
else ()
69+
set(USE_MPI OFF CACHE BOOL "" FORCE)
70+
set(CUSTOM_OPENBLAS "" CACHE PATH "The path that contains the custom OpenBLAS library. If not set, the bundled OpenBLAS will be used.")
71+
endif ()
72+
if (USE_AOCL)
73+
set(AOCL_BLIS_PATH "${CMAKE_SOURCE_DIR}/Libs/linux/libblis-mt.a" CACHE FILEPATH "AOCL libblis path.")
74+
set(AOCL_FLAME_PATH "${CMAKE_SOURCE_DIR}/Libs/linux/libflame.a" CACHE FILEPATH "AOCL libflame path.")
75+
set(AOCL_UTILS_PATH "${CMAKE_SOURCE_DIR}/Libs/linux/libaoclutils.a" CACHE FILEPATH "AOCL libaoclutils path.")
76+
add_compile_definitions(SUANPAN_AOCL)
77+
endif ()
78+
79+
set(COMPILER_IDENTIFIER "unknown")
80+
set(SP_EXTERNAL_LIB_PATH "unknown")
81+
if (CMAKE_SYSTEM_NAME MATCHES "Windows") # WINDOWS PLATFORM
82+
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") # GNU GCC COMPILER
83+
set(COMPILER_IDENTIFIER "gcc-win")
84+
set(SP_EXTERNAL_LIB_PATH "win")
85+
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") # MSVC COMPILER
86+
set(COMPILER_IDENTIFIER "vs")
87+
set(SP_EXTERNAL_LIB_PATH "vs")
88+
add_compile_definitions(_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING)
89+
if (FORTRAN_STATUS)
90+
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
91+
endif ()
92+
option(USE_CUDA "Enable GPU based global solvers via CUDA." OFF)
93+
endif ()
94+
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux") # LINUX PLATFORM
95+
set(SP_EXTERNAL_LIB_PATH "linux")
96+
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") # GNU GCC COMPILER
97+
set(COMPILER_IDENTIFIER "gcc-linux")
98+
elseif (CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM") # Intel COMPILER icpx
99+
set(COMPILER_IDENTIFIER "clang-linux")
100+
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel") # Intel COMPILER Classic icc
101+
set(COMPILER_IDENTIFIER "gcc-linux")
102+
message(STATUS "Classic Intel compiler icc has incomplete CPP20 support, if it fails to compile please use another compiler.")
103+
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Clang COMPILER
104+
set(COMPILER_IDENTIFIER "clang-linux")
105+
endif ()
106+
option(USE_CUDA "Enable GPU based global solvers via CUDA." OFF)
107+
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") # MAC PLATFORM
108+
set(SP_EXTERNAL_LIB_PATH "mac")
109+
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") # GNU GCC COMPILER
110+
set(COMPILER_IDENTIFIER "gcc-mac")
111+
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
112+
set(COMPILER_IDENTIFIER "clang-mac")
113+
link_directories(/usr/local/opt/libomp/lib/)
114+
message(STATUS "On macOS, make sure llvm and libomp are installed.")
115+
message(STATUS "brew install llvm libomp")
116+
endif ()
117+
endif ()
118+
119+
if (COMPILER_IDENTIFIER MATCHES "unknown")
120+
message(FATAL_ERROR "Cannot identify the compiler available, please use GCC or MSVC or Intel.")
121+
endif ()
122+
123+
if (USE_MKL AND USE_CUDA)
124+
option(USE_MAGMA "Enable GPU based global solvers via MAGMA." OFF)
125+
endif ()
126+
127+
if (NOT CUSTOM_OPENBLAS STREQUAL "")
128+
link_directories(${CUSTOM_OPENBLAS})
129+
elseif (USE_SYS_LIB)
130+
find_package(OpenBLAS REQUIRED)
131+
endif ()
132+
133+
if (NOT USE_SYS_LIB)
134+
link_directories(Libs/${SP_EXTERNAL_LIB_PATH})
135+
endif ()
136+
137+
if (USE_SUPERLUMT)
138+
message(WARNING "Current SuperLU MT library may contain bugs. Disabling it.")
139+
set(USE_SUPERLUMT OFF CACHE BOOL "" FORCE)
140+
# add_compile_definitions(SUANPAN_SUPERLUMT)
141+
endif ()
142+
143+
if (USE_MPI)
144+
find_package(MPI REQUIRED)
145+
# add_compile_definitions(SUANPAN_MPI)
146+
endif ()
147+
148+
if (USE_MKL)
149+
set(MKLROOT "" CACHE PATH "MKL library path which contains /include and /lib folders.")
150+
find_file(MKL_HEADER NAMES mkl.h PATHS ${MKLROOT}/include)
151+
if (MKL_HEADER MATCHES "MKL_HEADER-NOTFOUND")
152+
message(FATAL_ERROR "The <mkl.h> is not found under the path: ${MKLROOT}/include.")
153+
endif ()
154+
if (COMPILER_IDENTIFIER MATCHES "IntelLLVM")
155+
set(USE_INTEL_OPENMP ON CACHE BOOL "" FORCE)
156+
endif ()
157+
set(MKL_ROOT ${MKLROOT})
158+
if (NOT LINK_DYNAMIC_MKL)
159+
set(MKL_LINK static)
160+
endif ()
161+
if (NOT USE_INTEL_OPENMP)
162+
set(MKL_THREADING gnu_thread)
163+
endif ()
164+
set(MKL_INTERFACE lp64)
165+
find_package(MKL REQUIRED)
166+
add_compile_definitions(SUANPAN_MKL)
167+
# add_compile_definitions(ARMA_USE_MKL_ALLOC)
168+
elseif (FORTRAN_STATUS AND CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
169+
message(WARNING "Since Intel compilers are used, why not enabling MKL?")
170+
elseif (USE_AOCL)
171+
if (NOT AOCL_BLIS_PATH MATCHES "blis")
172+
message(FATAL_ERROR "Please point AOCL_BLIS_PATH to the library file of BLIS.")
173+
endif ()
174+
if (NOT AOCL_FLAME_PATH MATCHES "flame")
175+
message(FATAL_ERROR "Please point AOCL_FLAME_PATH to the library file of FLAME.")
176+
endif ()
177+
if (NOT AOCL_UTILS_PATH MATCHES "aoclutils")
178+
message(FATAL_ERROR "Please point AOCL_UTILS_PATH to the library file of AOCL Utils.")
179+
endif ()
180+
endif ()
181+
182+
if (USE_CUDA)
183+
if (POLICY CMP0146)
184+
cmake_policy(SET CMP0146 OLD)
185+
endif ()
186+
find_package(CUDA)
187+
if (NOT CUDA_FOUND)
188+
set(CUDA_PATH "" CACHE PATH "CUDA library path which contains /include folder.")
189+
find_package(CUDA PATHS ${CUDA_PATH})
190+
if (NOT CUDA_FOUND)
191+
message(FATAL_ERROR "CUDA library is not found, please indicate its path.")
192+
endif ()
193+
endif ()
194+
add_compile_definitions(SUANPAN_CUDA)
195+
include_directories(${CUDA_INCLUDE_DIRS})
196+
link_libraries(${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_cusolver_LIBRARY} ${CUDA_cusparse_LIBRARY})
197+
if (CUDA_VERSION VERSION_GREATER_EQUAL "12.3")
198+
if (COMPILER_IDENTIFIER MATCHES "vs")
199+
add_compile_options(/wd4996)
200+
endif ()
201+
endif ()
202+
endif ()
203+
204+
if (USE_MAGMA)
205+
set(MAGMAROOT "" CACHE PATH "Magma library path which contains /include and /lib folders.")
206+
find_file(MAGMA_HEADER NAMES magma.h PATHS ${MAGMAROOT}/include)
207+
if (MAGMA_HEADER MATCHES "MAGMA_HEADER-NOTFOUND")
208+
message(FATAL_ERROR "The <magma.h> is not found under the path: ${MAGMAROOT}/include.")
209+
endif ()
210+
include_directories(${MAGMAROOT}/include)
211+
link_directories(${MAGMAROOT}/lib)
212+
link_libraries(magma magma_sparse)
213+
add_compile_definitions(SUANPAN_MAGMA)
214+
endif ()
215+
216+
set(HAVE_VTK FALSE CACHE INTERNAL "")
217+
if (USE_VTK)
218+
if (VTK_PATH MATCHES "")
219+
find_package(VTK)
220+
else ()
221+
find_package(VTK PATHS ${VTK_PATH})
222+
endif ()
223+
if (VTK_FOUND)
224+
add_compile_definitions(SUANPAN_VTK)
225+
set(HAVE_VTK TRUE CACHE INTERNAL "")
226+
else ()
227+
set(VTK_PATH "" CACHE PATH "VTK library path which contains /include folder.")
228+
find_package(VTK PATHS ${VTK_PATH})
229+
if (NOT VTK_FOUND)
230+
message(FATAL_ERROR "VTK library is not found, please indicate its path.")
231+
endif ()
232+
endif ()
233+
endif ()
234+
235+
if (USE_HDF5)
236+
add_compile_definitions(SUANPAN_HDF5)
237+
if (HAVE_VTK)
238+
string(REGEX REPLACE "/lib6?4?/cmake/vtk" "/include/vtk" VTK_INCLUDE ${VTK_DIR}) # on linux
239+
string(REGEX REPLACE "\\\\lib6?4?\\\\cmake\\\\vtk" "\\\\include\\\\vtk" VTK_INCLUDE ${VTK_INCLUDE}) # on windows
240+
include_directories(${VTK_INCLUDE}/vtkhdf5)
241+
include_directories(${VTK_INCLUDE}/vtkhdf5/src)
242+
include_directories(${VTK_INCLUDE}/vtkhdf5/hl/src)
243+
find_file(HDF5_HEADER NAMES hdf5.h PATHS ${VTK_INCLUDE}/vtkhdf5/src)
244+
if (HDF5_HEADER MATCHES "HDF5_HEADER-NOTFOUND")
245+
message(FATAL_ERROR "The <hdf5.h> is not found in the include directories.")
246+
else ()
247+
message(STATUS "Found HDF5 header: ${HDF5_HEADER}")
248+
endif ()
249+
else ()
250+
if (USE_SYS_LIB)
251+
find_package(HDF5 REQUIRED COMPONENTS C HL)
252+
include_directories(${HDF5_INCLUDE_DIRS})
253+
link_libraries(${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES})
254+
else ()
255+
include_directories(Include/hdf5)
256+
include_directories(Include/hdf5-${SP_EXTERNAL_LIB_PATH})
257+
if (COMPILER_IDENTIFIER MATCHES "vs")
258+
link_libraries(libhdf5_hl libhdf5 shlwapi)
259+
else ()
260+
link_libraries(hdf5_hl hdf5)
261+
endif ()
262+
endif ()
263+
endif ()
264+
else ()
265+
add_compile_definitions(ARMA_DONT_USE_HDF5)
266+
endif ()
267+
268+
if (USE_MIMALLOC)
269+
message(STATUS "USING MIMALLOC LIBRARY")
270+
include(FetchContent)
271+
FetchContent_Declare(mimalloc
272+
GIT_REPOSITORY https://github.com/microsoft/mimalloc
273+
GIT_TAG v2.1.2)
274+
FetchContent_MakeAvailable(mimalloc)
275+
endif ()
276+
277+
if (BUILD_MULTITHREAD)
278+
message(STATUS "USING TBB LIBRARY")
279+
add_compile_definitions(SUANPAN_MT)
280+
if (USE_SYS_LIB)
281+
find_package(TBB REQUIRED)
282+
include_directories(${TBB_INCLUDE_DIRS})
283+
link_libraries(TBB::tbb TBB::tbbmalloc TBB::tbbmalloc_proxy)
284+
else ()
285+
if (COMPILER_IDENTIFIER MATCHES "gcc-win")
286+
link_libraries(tbb12)
287+
else ()
288+
link_libraries(tbb)
289+
endif ()
290+
option(USE_TBB_ALLOC "Use tbb memory allocator. Enable if no other allocators will be used." OFF)
291+
if (USE_TBB_ALLOC)
292+
# for armadillo to use tbb allocator
293+
add_compile_definitions(ARMA_USE_TBB_ALLOC)
294+
include_directories(Include/oneapi) # because armadillo assumes oneapi be in the include path
295+
link_libraries(tbbmalloc tbbmalloc_proxy)
296+
endif ()
297+
endif ()
298+
endif ()
299+
300+
if (BUILD_SHARED_LIBS)
301+
message(STATUS "BUILD SHARED LIBRARY")
302+
else ()
303+
message(STATUS "BUILD STATIC LIBRARY")
304+
endif ()
305+
306+
if (USE_AVX512)
307+
add_compile_definitions(SUANPAN_AVX512)
308+
elseif (USE_AVX2)
309+
add_compile_definitions(SUANPAN_AVX2)
310+
elseif (USE_AVX)
311+
add_compile_definitions(SUANPAN_AVX)
312+
endif ()
313+
314+
if (COMPILER_IDENTIFIER MATCHES "vs")
315+
unset(TEST_COVERAGE CACHE)
316+
317+
link_directories(Libs/win)
318+
319+
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
320+
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
321+
322+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP /openmp")
323+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /openmp /EHsc")
324+
325+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /nowarn /MP /Qopenmp /Qparallel /fpp /names:lowercase /assume:underscore /libs:dll /threads")
326+
327+
if (USE_AVX512)
328+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX512")
329+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX512")
330+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /arch:AVX2")
331+
elseif (USE_AVX2)
332+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX2")
333+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")
334+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /arch:AVX2")
335+
elseif (USE_AVX)
336+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX")
337+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX")
338+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /arch:AVX")
339+
endif ()
340+
else ()
341+
if (BUILD_SHARED_LIBS)
342+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
343+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
344+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fPIC")
345+
endif ()
346+
347+
link_libraries(dl pthread gfortran)
348+
349+
find_library(HAS_QUADMATH quadmath)
350+
if (HAS_QUADMATH)
351+
link_libraries(quadmath)
352+
endif ()
353+
354+
if (CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM")
355+
link_libraries(stdc++)
356+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffp-model=precise -fexceptions -fiopenmp")
357+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-model=precise -fexceptions -fiopenmp")
358+
elseif (COMPILER_IDENTIFIER MATCHES "clang-mac")
359+
include_directories("/usr/local/include" "/usr/local/opt/llvm/include")
360+
link_directories("/usr/local/lib" "/usr/local/opt/llvm/lib")
361+
link_libraries(omp)
362+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions -Xpreprocessor -fopenmp")
363+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -Xpreprocessor -fopenmp")
364+
else ()
365+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions -fopenmp")
366+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -fopenmp")
367+
endif ()
368+
369+
if (USE_AVX512)
370+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx512f")
371+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx512f")
372+
elseif (USE_AVX2)
373+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
374+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2")
375+
elseif (USE_AVX)
376+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
377+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
378+
endif ()
379+
380+
option(TEST_COVERAGE "TEST CODE COVERAGE USING GCOV" OFF)
381+
382+
if (TEST_COVERAGE AND COMPILER_IDENTIFIER MATCHES "gcc") # only report coverage with gcc
383+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
384+
link_libraries(gcov)
385+
endif ()
386+
387+
if (CMAKE_BUILD_TYPE MATCHES "Debug")
388+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
389+
option(USE_ASAN "USE ADDRESS SANITIZER" OFF)
390+
if (USE_ASAN)
391+
message(STATUS "Using the address sanitizer with flags: -fsanitize=address,leak,undefined")
392+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,leak,undefined")
393+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address,leak,undefined")
394+
endif ()
395+
endif ()
396+
397+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w -fallow-argument-mismatch")
398+
if (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
399+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpp -qopenmp")
400+
401+
if (USE_AVX512)
402+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -arch AVX2")
403+
elseif (USE_AVX2)
404+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -arch AVX2")
405+
elseif (USE_AVX)
406+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -arch AVX")
407+
endif ()
408+
else ()
409+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -cpp -fopenmp")
410+
411+
if (USE_AVX512)
412+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mavx512f")
413+
elseif (USE_AVX2)
414+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mavx2")
415+
elseif (USE_AVX)
416+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mavx")
417+
endif ()
418+
endif ()
419+
endif ()
39420

40421
if (USE_MKL)
41422
if (COMPILER_IDENTIFIER MATCHES "win")

0 commit comments

Comments
 (0)