-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
108 lines (89 loc) · 4.05 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
cmake_minimum_required(VERSION 3.26)
cmake_policy(VERSION 3.26)
project(test_cyclic VERSION 0.1.0 LANGUAGES Fortran)
enable_language(Fortran)
# pick a compiler, you might need to export FC=ifort or gfortran or nvfortran prior to running with a clean tree
#set (CMAKE_Fortran_COMPILER "ifort")
#set (CMAKE_Fortran_COMPILER "nvfortran")
set (CMAKE_Fortran_COMPILER_ID "gfortran")
# should read again how to manage compiler flags with Cmake
if(CMAKE_Fortran_COMPILER_ID MATCHES "gfortran")
set(FC "gfortran")
set(dialect "-ffree-form -std=f2008 -fexternal-blas -fno-optimize-sibling-calls") #gfortran/lapack/blas bug?
set(bounds "-Wall -Wextra -Wimplicit-interface -fcheck=all -fbacktrace -fbounds-check -g")
set(omp "-fopenmp")
set(NaN "-ffpe-trap=invalid,zero,overflow -finit-real=snan -finit-integer=-99999999")
# profiling with gprof
# set(-pg)
# src profiling with gcov -a -b xxx.f90
# set(-g -coverage)
set(optimize "-O3 -march=native -ffast-math -funroll-loops")
endif()
if(CMAKE_Fortran_COMPILER_ID MATCHES "ifort")
set(FC "ifort")
set(dialect "-stand f08 -free -implicitnone")
set(type "-shared-intel")
set(bounds "-check bounds")
set(omp "-qopenmp")
endif()
# nvfortran==pgi
if(CMAKE_Fortran_COMPILER_ID MATCHES "nvfortran")
set(FC "nvfortran")
set(dialect "-Mfreeform -Mdclchk -Mstandard -Mallocatable=03")
set(bounds "-Mbounds -g")
set(omp "-mp")
endif()
set(CMAKE_BUILD_TYPE RELEASE) # no debug or bounds check
#set(CMAKE_BUILD_TYPE DEBUG) #this include debugging with addition of bounds flags as specified below
#set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${bounds}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${dialect}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS_RELEASE} ${optimize}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${omp}")
#set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${NaN}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${type}")
#set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${FC}")
set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 0) #set to 1 to show dependencies
set (CMAKE_PREFIX_PATH "/usr/local")
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
find_package(BLAS )
if ( BLAS_FOUND )
message(STATUS "BLAS found at ${BLAS_LIBRARIES}")
else()
set(BLAS_LIBRARIES "/usr/lib/libblas.so")
endif()
find_package(LAPACK)
if ( LAPACK_FOUND )
message(STATUS "LAPACK found at ${LAPACK_LIBRARIES}")
else()
set(LAPACK_LIBRARIES "/usr/lib/liblapack.so.3")
endif()
find_package(OpenMP)
# Compile.
# Fortran Source
file(GLOB mod_source LapackInterface.f90 AB_matrix_fct.f90)
file(GLOB source dctsv.f90
dcbsv_forward.f90
dcbsv_reverse.f90
forward_loop.f90
backward_loop.f90
gauss-jordan.f90)
file(GLOB source_omp dcbsv_4x4parallel_omp.f90
dcbsv_parallel_omp.f90
dcbsv_forward.f90
dcbsv_reverse.f90
dctsv_parallel_omp.f90
forward_loop.f90
backward_loop.f90
gauss-jordan.f90
thomas.f90)
add_library( modules ${mod_source})
add_library( source_omp ${source_omp})
add_library( source ${source})
add_dependencies(source_omp modules)
add_dependencies(source modules)
set(LIBS modules ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} )
add_executable(test_cyclic_omp testme_omp.f90)
target_link_libraries(test_cyclic_omp ${LIBS} source_omp)
add_executable(test_cyclic testme.f90)
target_link_libraries(test_cyclic ${LIBS} source)