Skip to content

Commit a85c67b

Browse files
committed
cmake: select precision(s) to build
1 parent 1804c1c commit a85c67b

File tree

22 files changed

+680
-773
lines changed

22 files changed

+680
-773
lines changed

BLACS/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
add_subdirectory(SRC)
2-
if(${SCALAPACK_BUILD_TESTS})
2+
3+
if(SCALAPACK_BUILD_TESTS)
34
add_subdirectory(TESTING)
45
endif()

BLACS/SRC/CMakeLists.txt

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
# --------------------------
22
# The communication routines
33
# --------------------------
4-
set (comm
5-
igesd2d_.c sgesd2d_.c dgesd2d_.c cgesd2d_.c zgesd2d_.c
6-
itrsd2d_.c strsd2d_.c dtrsd2d_.c ctrsd2d_.c ztrsd2d_.c
7-
igerv2d_.c sgerv2d_.c dgerv2d_.c cgerv2d_.c zgerv2d_.c
8-
itrrv2d_.c strrv2d_.c dtrrv2d_.c ctrrv2d_.c ztrrv2d_.c
9-
igebs2d_.c sgebs2d_.c dgebs2d_.c cgebs2d_.c zgebs2d_.c
10-
igebr2d_.c sgebr2d_.c dgebr2d_.c cgebr2d_.c zgebr2d_.c
11-
itrbs2d_.c strbs2d_.c dtrbs2d_.c ctrbs2d_.c ztrbs2d_.c
12-
itrbr2d_.c strbr2d_.c dtrbr2d_.c ctrbr2d_.c ztrbr2d_.c
13-
igsum2d_.c sgsum2d_.c dgsum2d_.c cgsum2d_.c zgsum2d_.c
14-
igamx2d_.c sgamx2d_.c dgamx2d_.c cgamx2d_.c zgamx2d_.c
15-
igamn2d_.c sgamn2d_.c dgamn2d_.c cgamn2d_.c zgamn2d_.c)
4+
set(comm
5+
igesd2d_.c itrsd2d_.c igerv2d_.c itrrv2d_.c igebs2d_.c igebr2d_.c itrbs2d_.c itrbr2d_.c igsum2d_.c igamx2d_.c igamn2d_.c
6+
dgsum2d_.c dgamx2d_.c dgamn2d_.c
7+
)
8+
if(BUILD_SINGLE)
9+
list(APPEND comm sgesd2d_.c strsd2d_.c sgerv2d_.c strrv2d_.c sgebs2d_.c sgebr2d_.c strbs2d_.c strbr2d_.c sgsum2d_.c sgamx2d_.c sgamn2d_.c)
10+
endif()
11+
if(BUILD_DOUBLE)
12+
list(APPEND comm dgesd2d_.c dtrsd2d_.c dgerv2d_.c dtrrv2d_.c dgebs2d_.c dgebr2d_.c dtrbs2d_.c dtrbr2d_.c dgamx2d_.c)
13+
endif()
14+
if(BUILD_COMPLEX)
15+
list(APPEND comm cgesd2d_.c ctrsd2d_.c cgerv2d_.c ctrrv2d_.c cgebs2d_.c cgebr2d_.c ctrbs2d_.c ctrbr2d_.c cgsum2d_.c cgamx2d_.c cgamn2d_.c)
16+
endif()
17+
if(BUILD_COMPLEX16)
18+
list(APPEND comm zgesd2d_.c ztrsd2d_.c zgerv2d_.c ztrrv2d_.c zgebs2d_.c zgebr2d_.c ztrbs2d_.c ztrbr2d_.c zgsum2d_.c zgamx2d_.c zgamn2d_.c)
19+
endif()
1620

1721
# --------------------
1822
# The support routines
@@ -39,18 +43,32 @@ set (internal
3943
BI_BuffIsFree.c BI_imvcopy.c BI_smvcopy.c BI_dmvcopy.c
4044
BI_ivmcopy.c BI_svmcopy.c BI_dvmcopy.c
4145
BI_Pack.c BI_Unpack.c BI_GetMpiGeType.c BI_GetMpiTrType.c
42-
BI_ivvsum.c BI_svvsum.c BI_dvvsum.c BI_cvvsum.c BI_zvvsum.c
43-
BI_ivvamx.c BI_svvamx.c BI_dvvamx.c BI_cvvamx.c BI_zvvamx.c
44-
BI_ivvamx2.c BI_svvamx2.c BI_dvvamx2.c BI_cvvamx2.c BI_zvvamx2.c
45-
BI_ivvamn.c BI_svvamn.c BI_dvvamn.c BI_cvvamn.c BI_zvvamn.c
46-
BI_ivvamn2.c BI_svvamn2.c BI_dvvamn2.c BI_cvvamn2.c BI_zvvamn2.c
47-
BI_iMPI_amx.c BI_sMPI_amx.c BI_dMPI_amx.c BI_cMPI_amx.c
48-
BI_zMPI_amx.c BI_iMPI_amx2.c BI_sMPI_amx2.c BI_dMPI_amx2.c
49-
BI_cMPI_amx2.c BI_zMPI_amx2.c BI_iMPI_amn.c BI_sMPI_amn.c
50-
BI_dMPI_amn.c BI_cMPI_amn.c BI_zMPI_amn.c BI_iMPI_amn2.c
51-
BI_sMPI_amn2.c BI_dMPI_amn2.c BI_cMPI_amn2.c BI_zMPI_amn2.c
52-
BI_cMPI_sum.c BI_zMPI_sum.c BI_ContxtNum.c BI_GlobalVars.c
53-
BI_TransUserComm.c )
46+
BI_ivvsum.c BI_ivvamx.c BI_ivvamx2.c BI_ivvamn.c BI_ivvamn2.c
47+
BI_iMPI_amx.c BI_iMPI_amx2.c BI_iMPI_amn.c BI_iMPI_amn2.c
48+
BI_ContxtNum.c BI_GlobalVars.c BI_TransUserComm.c
49+
BI_dvvsum.c BI_dvvamx.c BI_dvvamx2.c BI_dvvamn.c BI_dvvamn2.c
50+
BI_dMPI_amx.c BI_dMPI_amx2.c BI_dMPI_amn.c BI_dMPI_amn2.c
51+
BI_dmvcopy.c BI_dvmcopy.c
52+
)
53+
if(BUILD_SINGLE)
54+
list(APPEND internal
55+
BI_svvsum.c BI_svvamx.c BI_svvamx2.c BI_svvamn.c BI_svvamn2.c
56+
BI_sMPI_amx.c BI_sMPI_amx2.c BI_sMPI_amn.c BI_sMPI_amn2.c
57+
BI_smvcopy.c BI_svmcopy.c
58+
)
59+
endif()
60+
if(BUILD_COMPLEX)
61+
list(APPEND internal
62+
BI_cvvsum.c BI_cvvamx.c BI_cvvamx2.c BI_cvvamn.c BI_cvvamn2.c
63+
BI_cMPI_amx.c BI_cMPI_amx2.c BI_cMPI_amn.c BI_cMPI_amn2.c BI_cMPI_sum.c
64+
)
65+
endif()
66+
if(BUILD_COMPLEX16)
67+
list(APPEND internal
68+
BI_zvvsum.c BI_zvvamx.c BI_zvvamx2.c BI_zvvamn.c BI_zvvamn2.c
69+
BI_zMPI_amx.c BI_zMPI_amx2.c BI_zMPI_amn.c BI_zMPI_amn2.c BI_zMPI_sum.c
70+
)
71+
endif()
5472

5573

5674
#
@@ -81,4 +99,3 @@ endforeach()
8199
set(blacs ${srcs} ${srcs_C} ${internal})
82100
#add_library(scalapack ${srcs} ${srcs_C} ${internal})
83101
#scalapack_install_library(scalapack)
84-

BLACS/TESTING/CMakeLists.txt

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
if(NOT (BUILD_SINGLE AND BUILD_DOUBLE AND BUILD_COMPLEX AND BUILD_COMPLEX16))
2+
return()
3+
endif()
4+
5+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
6+
17
set(FTestObj
28
blacstest.f btprim.f tools.f)
39

4-
if ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
5-
set_source_files_properties(blacstest.f PROPERTIES COMPILE_FLAGS "-std=legacy")
10+
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
11+
set_source_files_properties(blacstest.f PROPERTIES COMPILE_FLAGS "-std=legacy")
612
endif()
713

814
add_executable(xFbtest ${FTestObj})
9-
target_link_libraries(xFbtest scalapack MPI::MPI_Fortran)
15+
target_link_libraries(xFbtest PRIVATE scalapack MPI::MPI_Fortran)
1016

1117
set(CTestObj
1218
Cbt.c)
@@ -17,39 +23,30 @@ set_property(
1723
)
1824

1925
add_executable(xCbtest ${CTestObj} ${FTestObj})
20-
target_link_libraries(xCbtest scalapack MPI::MPI_Fortran)
21-
22-
file(COPY bsbr.dat DESTINATION ${SCALAPACK_BINARY_DIR}/BLACS/TESTING)
23-
file(COPY bt.dat DESTINATION ${SCALAPACK_BINARY_DIR}/BLACS/TESTING)
24-
file(COPY comb.dat DESTINATION ${SCALAPACK_BINARY_DIR}/BLACS/TESTING)
25-
file(COPY sdrv.dat DESTINATION ${SCALAPACK_BINARY_DIR}/BLACS/TESTING)
26+
target_link_libraries(xCbtest PRIVATE scalapack MPI::MPI_Fortran)
2627

2728
# We could run the BLACS TESTING the following way
2829
# But BLACS TESTING are TESTING anormal exit so even if they pass,
2930
# CTest will determine they fail
3031
#add_test(xFbtest0 ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ${MPIEXEC_PREFLAGS} ./xFbtest)
3132
#add_test(xCbtest0 ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ${MPIEXEC_PREFLAGS} ./xCbtest)
3233

33-
add_test(xCbtest
34-
${CMAKE_COMMAND}
35-
-DMPIEXEC=${MPIEXEC}
34+
add_test(NAME xCbtest
35+
COMMAND ${CMAKE_COMMAND}
36+
-DMPIEXEC_EXECUTABLE=${MPIEXEC_EXECUTABLE}
3637
-DMPIEXEC_NUMPROC_FLAG=${MPIEXEC_NUMPROC_FLAG}
3738
-DMPIEXEC_PREFLAGS=${MPIEXEC_PREFLAGS}
38-
-DTEST_PROG=xCbtest
39-
-DOUTPUTDIR=${SCALAPACK_BINARY_DIR}/BLACS/TESTING
40-
-DRUNTIMEDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
41-
-DSOURCEDIR=${CMAKE_CURRENT_SOURCE_DIR}
39+
-DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
40+
-DEXE=$<TARGET_FILE:xCbtest>
4241
-P ${CMAKE_CURRENT_SOURCE_DIR}/runtest.cmake
4342
)
4443

45-
add_test(xFbtest
46-
${CMAKE_COMMAND}
47-
-DMPIEXEC=${MPIEXEC}
44+
add_test(NAME xFbtest
45+
COMMAND ${CMAKE_COMMAND}
46+
-DMPIEXEC_EXECUTABLE=${MPIEXEC_EXECUTABLE}
4847
-DMPIEXEC_NUMPROC_FLAG=${MPIEXEC_NUMPROC_FLAG}
4948
-DMPIEXEC_PREFLAGS=${MPIEXEC_PREFLAGS}
50-
-DTEST_PROG=xFbtest
51-
-DOUTPUTDIR=${SCALAPACK_BINARY_DIR}/BLACS/TESTING
52-
-DRUNTIMEDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
53-
-DSOURCEDIR=${CMAKE_CURRENT_SOURCE_DIR}
49+
-DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
50+
-DEXE=$<TARGET_FILE:xFbtest>
5451
-P ${CMAKE_CURRENT_SOURCE_DIR}/runtest.cmake
5552
)

BLACS/TESTING/runtest.cmake

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
message("Running BLACS TESTS")
2-
message(STATUS "${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ${MPIEXEC_PREFLAGS} ./${TEST_PROG}")
3-
message(STATUS "Output out_${TEST_PROG}.txt")
4-
file(COPY ${RUNTIMEDIR}/${TEST_PROG} DESTINATION ${OUTPUTDIR})
1+
get_filename_component(OUTPUTDIR ${EXE} DIRECTORY)
2+
get_filename_component(name ${EXE} NAME_WE)
53

6-
execute_process(COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ${MPIEXEC_PREFLAGS} ./${TEST_PROG}
7-
OUTPUT_FILE "out_${TEST_PROG}.txt"
8-
ERROR_FILE "error_${TEST_PROG}.txt"
9-
RESULT_VARIABLE HAD_ERROR)
4+
set(cmd ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 4 ${MPIEXEC_PREFLAGS} ${EXE})
5+
set(outfile ${OUTPUTDIR}/out_${name}.txt)
6+
set(errfile ${OUTPUTDIR}/err_${name}.txt)
7+
message(STATUS "Output/Error log files: ${outfile} ${errfile}")
8+
set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDOUT)
109

11-
if(HAD_ERROR)
10+
execute_process(COMMAND ${cmd}
11+
OUTPUT_FILE ${outfile}
12+
ERROR_FILE ${errfile}
13+
RESULT_VARIABLE HAD_ERROR
14+
WORKING_DIRECTORY ${SOURCE_DIR}
15+
)
16+
17+
if(NOT HAD_ERROR EQUAL 0)
1218
# This is normal to exit in Error (good behaviour)
1319
# So we are going to check that the output have the last line of the testing : DONE BLACS_GRIDEXIT
14-
file(READ "out_${TEST_PROG}.txt" TESTSTRING)
20+
file(READ ${outfile} TESTSTRING)
1521

16-
STRING(REPLACE "DONE BLACS_GRIDEXIT" "BLACS OK" tmp ${TESTSTRING})
22+
STRING(REPLACE "DONE BLACS_GRIDEXIT" "BLACS OK" tmp "${TESTSTRING}")
1723

1824
if("${tmp}" STREQUAL "${TESTSTRING}")
19-
message( STATUS "Error in error_${TEST_PROG}.txt")
25+
message( STATUS "Error in ${errfile}")
2026
message(FATAL_ERROR "Test failed - Test did not reach DONE BLACS_GRIDEXIT")
2127
else()
2228
message( STATUS "Test Passed")

CMAKE/CheckBLACSCompilerFlags.cmake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# This module checks against various known compilers and thier respective
22
# flags to determine any specific flags needing to be set.
3-
#
3+
#
44
# 1. If FPE traps are enabled either abort or disable them
55
# 2. Specify fixed form if needed
66
# 3. Ensure that Release builds use O2 instead of O3
7-
#
7+
#
88
#=============================================================================
99
# Author: Chuck Atkins
1010
# Copyright 2011
@@ -16,7 +16,7 @@ set( FPE_EXIT FALSE )
1616

1717
# GNU Fortran
1818
if( CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" )
19-
if( "${CMAKE_Fortran_FLAGS}" MATCHES "-ffpe-trap=[izoupd]")
19+
if( "${CMAKE_Fortran_FLAGS}" MATCHES "-ffpe-trap=[izoupd]")
2020
set( FPE_EXIT TRUE )
2121
endif()
2222

@@ -55,12 +55,12 @@ elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "HP" )
5555
if( "${CMAKE_Fortran_FLAGS}" MATCHES "\\+fp_exception" )
5656
set( FPE_EXIT TRUE )
5757
endif()
58-
58+
5959
if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "\\+fltconst_strict") )
6060
message( STATUS "Enabling strict float conversion with +fltconst_strict" )
6161
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} +fltconst_strict"
6262
CACHE STRING "Flags for Fortran compiler." FORCE )
63-
endif()
63+
endif()
6464

6565
# Most versions of cmake don't have good default options for the HP compiler
6666
set( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -g"
@@ -76,13 +76,13 @@ endif()
7676

7777
if( "${CMAKE_Fortran_FLAGS_RELEASE}" MATCHES "O[3-9]" )
7878
message( STATUS "Reducing RELEASE optimization level to O2" )
79-
string( REGEX REPLACE "O[3-9]" "O2" CMAKE_Fortran_FLAGS_RELEASE
79+
string( REGEX REPLACE "O[3-9]" "O2" CMAKE_Fortran_FLAGS_RELEASE
8080
"${CMAKE_Fortran_FLAGS_RELEASE}" )
8181
set( CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}"
8282
CACHE STRING "Flags used by the compiler during release builds" FORCE )
8383
elseif ( "${CMAKE_Fortran_FLAGS_RELEASE}" MATCHES "Ofast" )
8484
message( STATUS "Reducing RELEASE optimization level to O2" )
85-
string( REGEX REPLACE "Ofast" "O2" CMAKE_Fortran_FLAGS_RELEASE
85+
string( REGEX REPLACE "Ofast" "O2" CMAKE_Fortran_FLAGS_RELEASE
8686
"${CMAKE_Fortran_FLAGS_RELEASE}" )
8787
set( CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}"
8888
CACHE STRING "Flags used by the compiler during release builds" FORCE )

CMakeLists.txt

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ cmake_minimum_required(VERSION 3.9)
22

33
project(SCALAPACK VERSION 2.2.1 LANGUAGES C Fortran)
44

5+
# --------------------------------------------------
6+
# Precision to build
7+
# By default all precisions are generated
8+
option(BUILD_SINGLE "Build single precision real" ON)
9+
option(BUILD_DOUBLE "Build double precision real" ON)
10+
option(BUILD_COMPLEX "Build single precision complex" ON)
11+
option(BUILD_COMPLEX16 "Build double precision complex" ON)
12+
if(BUILD_COMPLEX)
13+
set(BUILD_SINGLE true)
14+
endif()
15+
if(BUILD_COMPLEX16)
16+
set(BUILD_DOUBLE true)
17+
endif()
18+
519
# Configure the warning and code coverage suppression file
620
configure_file(
721
"${SCALAPACK_SOURCE_DIR}/CMAKE/CTestCustom.cmake.in"
@@ -26,7 +40,7 @@ set(CMAKE_PREFIX_PATH "${MPI_BASE_DIR};${CMAKE_PREFIX_PATH}")
2640
find_package(MPI)
2741
if (MPI_FOUND)
2842
message(STATUS "Found MPI_LIBRARY : ${MPI_FOUND} ")
29-
43+
3044
find_program(MPI_C_COMPILER
3145
NAMES mpicc
3246
HINTS "${MPI_BASE_DIR}"
@@ -89,9 +103,7 @@ endmacro()
89103
# Testing
90104
SET(DART_TESTING_TIMEOUT 600)
91105

92-
enable_testing()
93106
include(CTest)
94-
enable_testing()
95107
# --------------------------------------------------
96108

97109
# Organize output files. On Windows this also keeps .dll files next
@@ -171,9 +183,15 @@ else(LAPACK_FOUND)
171183
include(ExternalProject)
172184
ExternalProject_Add(
173185
lapack
174-
URL http://www.netlib.org/lapack/lapack.tgz
175-
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${SCALAPACK_BINARY_DIR}
186+
URL https://www.netlib.org/lapack/lapack.tgz
187+
CMAKE_ARGS
188+
-DCMAKE_INSTALL_PREFIX:PATH=${SCALAPACK_BINARY_DIR}
189+
-DBUILD_SINGLE:BOOL=${BUILD_SINGLE}
190+
-DBUILD_DOUBLE:BOOL=${BUILD_DOUBLE}
191+
-DBUILD_COMPLEX:BOOL=${BUILD_COMPLEX}
192+
-DBUILD_COMPLEX16:BOOL=${BUILD_COMPLEX16}
176193
PREFIX ${SCALAPACK_BINARY_DIR}/dependencies
194+
TLS_VERIFY true
177195
)
178196
if (NOT MSVC)
179197
SET(LAPACK_LIBRARIES ${SCALAPACK_BINARY_DIR}/lib/liblapack.a CACHE STRING "LAPACK library" FORCE)
@@ -266,7 +284,7 @@ if(TARGET lapack)
266284
endif()
267285

268286
option(SCALAPACK_BUILD_TESTS "Build all tests of the ScaLAPACK library" ON)
269-
if(${SCALAPACK_BUILD_TESTS})
287+
if(SCALAPACK_BUILD_TESTS)
270288
add_subdirectory(TESTING)
271289
endif()
272290

@@ -332,3 +350,15 @@ install(FILES
332350

333351
install(EXPORT scalapack-targets
334352
DESTINATION lib/cmake/scalapack-${SCALAPACK_VERSION})
353+
354+
355+
include(FeatureSummary)
356+
357+
add_feature_info(real32 ${BUILD_SINGLE} "Build with single precision")
358+
add_feature_info(real64 ${BUILD_DOUBLE} "Build with double precision")
359+
add_feature_info(complex32 ${BUILD_COMPLEX} "Build with complex precision")
360+
add_feature_info(complex64 ${BUILD_COMPLEX16} "Build with complex16 precision")
361+
add_feature_info(tests ${SCALAPACK_BUILD_TESTS} "Build tests")
362+
add_feature_info(shared ${BUILD_SHARED_LIBS} "Build shared libraries")
363+
message(STATUS "${PROJECT_NAME} features enabled:")
364+
feature_summary(WHAT ENABLED_FEATURES)

PBLAS/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
add_subdirectory(SRC)
2-
if(${SCALAPACK_BUILD_TESTS})
2+
3+
if(SCALAPACK_BUILD_TESTS)
34
add_subdirectory(TESTING)
45
add_subdirectory(TIMING)
56
endif()

0 commit comments

Comments
 (0)