Skip to content

Commit a329ce8

Browse files
committed
Porting ScaLAPACK on CMAKE.
What I can say is that it is working on my Mac, that's a start. Need further tests.
1 parent fb52302 commit a329ce8

34 files changed

+1636
-9
lines changed

BLACS/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
add_subdirectory(SRC)
2+
if(BUILD_TESTING)
3+
add_subdirectory(TESTING)
4+
endif(BUILD_TESTING)

BLACS/INSTALL/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cmake_minimum_required(VERSION 2.6)
2+
project(INSTALL C Fortran)
3+
4+
add_executable(xintface Fintface.f Cintface.c)

BLACS/INSTALL/Cintface.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
void c_intface_(int *i)
44
{
5-
fprintf(stderr, "For this platform, set INTFACE = -DAdd_\n");
5+
fprintf(stdout, "Add_\n");
66
}
77

88
void c_intface(int *i)
99
{
10-
fprintf(stderr, "For this platform, set INTFACE = -DNoChange\n");
10+
fprintf(stdout, "NoChange\n");
1111
}
1212

1313
void c_intface__(int *i)
1414
{
15-
fprintf(stderr, "For this platform, set INTFACE = -Df77IsF2C\n");
15+
fprintf(stdout, "f77IsF2C\n");
1616
}
1717

1818
void C_INTFACE(int *i)
1919
{
20-
fprintf(stderr, "For this platform, set INTFACE = -DUpCase\n");
20+
fprintf(stdout, "UpCase\n");
2121
}

BLACS/INSTALL/cmake_install.cmake

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Install script for directory: /Users/julie/Documents/Boulot/scalapack-dev/scalapack/trunk/BLACS/INSTALL
2+
3+
# Set the install prefix
4+
IF(NOT DEFINED CMAKE_INSTALL_PREFIX)
5+
SET(CMAKE_INSTALL_PREFIX "/usr/local")
6+
ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX)
7+
STRING(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
8+
9+
# Set the install configuration name.
10+
IF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
11+
IF(BUILD_TYPE)
12+
STRING(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
13+
CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
14+
ELSE(BUILD_TYPE)
15+
SET(CMAKE_INSTALL_CONFIG_NAME "")
16+
ENDIF(BUILD_TYPE)
17+
MESSAGE(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
18+
ENDIF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
19+
20+
# Set the component getting installed.
21+
IF(NOT CMAKE_INSTALL_COMPONENT)
22+
IF(COMPONENT)
23+
MESSAGE(STATUS "Install component: \"${COMPONENT}\"")
24+
SET(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
25+
ELSE(COMPONENT)
26+
SET(CMAKE_INSTALL_COMPONENT)
27+
ENDIF(COMPONENT)
28+
ENDIF(NOT CMAKE_INSTALL_COMPONENT)
29+
30+
IF(CMAKE_INSTALL_COMPONENT)
31+
SET(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt")
32+
ELSE(CMAKE_INSTALL_COMPONENT)
33+
SET(CMAKE_INSTALL_MANIFEST "install_manifest.txt")
34+
ENDIF(CMAKE_INSTALL_COMPONENT)
35+
36+
FILE(WRITE "/Users/julie/Documents/Boulot/scalapack-dev/scalapack/trunk/BLACS/INSTALL/${CMAKE_INSTALL_MANIFEST}" "")
37+
FOREACH(file ${CMAKE_INSTALL_MANIFEST_FILES})
38+
FILE(APPEND "/Users/julie/Documents/Boulot/scalapack-dev/scalapack/trunk/BLACS/INSTALL/${CMAKE_INSTALL_MANIFEST}" "${file}\n")
39+
ENDFOREACH(file)

BLACS/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ clean:
66
( cd INSTALL; make clean )
77

88
tester :
9-
( cd TESTING ; make $(what) )
9+
( cd TESTING ; make )
1010

1111
lib :
12-
( cd SRC ; make $(what) )
12+
( cd SRC ; make )

BLACS/SRC/CMakeLists.txt

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# --------------------------
2+
# The communication routines
3+
# --------------------------
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)
16+
17+
# --------------------
18+
# The support routines
19+
# --------------------
20+
set (supp
21+
blacs_setup_.c blacs_set_.c blacs_get_.c
22+
blacs_abort_.c blacs_exit_.c blacs_pnum_.c blacs_pcoord_.c
23+
ksendid_.c krecvid_.c kbsid_.c kbrid_.c
24+
dcputime00_.c dwalltime00_.c blacs_pinfo_.c
25+
blacs_init_.c blacs_map_.c blacs_free_.c blacs_grid_.c blacs_info_.c
26+
blacs_barr_.c sys2blacs_.c blacs2sys_.c free_handle_.c)
27+
28+
# ---------------------
29+
# The internal routines
30+
# ---------------------
31+
set (internal
32+
BI_HypBS.c BI_HypBR.c BI_IdringBS.c BI_IdringBR.c
33+
BI_MpathBS.c BI_MpathBR.c BI_SringBS.c BI_SringBR.c
34+
BI_TreeBS.c BI_TreeBR.c
35+
BI_Ssend.c BI_Rsend.c BI_Srecv.c BI_Asend.c BI_Arecv.c
36+
BI_TreeComb.c BI_BeComb.c BI_MringComb.c
37+
BI_ArgCheck.c BI_TransDist.c BI_GetBuff.c BI_UpdateBuffs.c
38+
BI_EmergencyBuff.c BI_BlacsErr.c BI_BlacsWarn.c BI_BlacsAbort.c
39+
BI_BuffIsFree.c BI_imvcopy.c BI_smvcopy.c BI_dmvcopy.c
40+
BI_ivmcopy.c BI_svmcopy.c BI_dvmcopy.c
41+
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 )
54+
55+
56+
#
57+
# Note on CMAKE (from Brad - Kitware)
58+
#
59+
#CMake hides the intermediate object files from its interface so there is
60+
#no direct way to do this within a single target. This limitation comes
61+
#from the requirement to support generation of build systems like VS IDE
62+
#project files that do not expose object files explicitly.
63+
64+
# Solution 1 : Build separate libraries, one for each block of objects
65+
#set(blacsFint ${comm} ${supp})
66+
#add_library(blacsCint ${comm} ${supp})
67+
#set_property(TARGET blacsCint PROPERTY COMPILE_DEFINITIONS CallFromC)
68+
#add_library(scalapack ${internal} ${blacsFint})
69+
#target_link_libraries(scalapack blacsCint)
70+
71+
# Solution 2 : Create an extra source file that #include-s the original one
72+
set(srcs ${comm} ${supp})
73+
set(srcs_C)
74+
foreach(src ${srcs})
75+
# string(REPLACE ".c" "-C.c" src_C "${CMAKE_CURRENT_BINARY_DIR}/${src}")
76+
string(REPLACE ".c" "-C.c" src_C "${src}")
77+
configure_file(src-C.c.in ${src_C} @ONLY)
78+
list(APPEND srcs_C ${src_C})
79+
endforeach()
80+
81+
set(blacs ${srcs} ${srcs_C} ${internal})
82+
#add_library(scalapack ${srcs} ${srcs_C} ${internal})
83+
#scalapack_install_library(scalapack)
84+

BLACS/SRC/src-C.c.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define CallFromC
2+
#include "@CMAKE_CURRENT_SOURCE_DIR@/@src@"

BLACS/TESTING/CMakeLists.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
set(FTestObj
2+
BLACStest.f btprim.f tools.f)
3+
4+
add_executable(xFbtest ${FTestObj})
5+
target_link_libraries(xFbtest scalapack)
6+
7+
set(CTestObj
8+
Cbt.c)
9+
10+
set_property(
11+
SOURCE Cbt.c
12+
APPEND PROPERTY COMPILE_DEFINITIONS BTCINTFACE
13+
)
14+
15+
add_executable(xCbtest ${CTestObj} ${FTestObj})
16+
target_link_libraries(xCbtest scalapack)
17+
18+
file(COPY bsbr.dat DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
19+
file(COPY bt.dat DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
20+
file(COPY comb.dat DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
21+
file(COPY sdrv.dat DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
22+
23+
# We could run the BLACS TESTING the following way
24+
# But BLACS TESTING are TESTING anormal exit so even if they pass,
25+
# CTest will determine they fail
26+
#add_test(xFbtest0 ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ./xFbtest)
27+
#add_test(xCbtest0 ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ./xCbtest)
28+
29+
add_test(xCbtest
30+
${CMAKE_COMMAND}
31+
-DMPIEXEC=${MPIEXEC}
32+
-DMPIEXEC_NUMPROC_FLAG=${MPIEXEC_NUMPROC_FLAG}
33+
-DTEST_PROG=xCbtest
34+
-DOUTPUTDIR=${SCALAPACK_BINARY_DIR}/BLACS/TESTING
35+
-DRUNTIMEDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
36+
-DSOURCEDIR=${CMAKE_CURRENT_SOURCE_DIR}
37+
-P ${CMAKE_CURRENT_SOURCE_DIR}/runtest.cmake
38+
)
39+
40+
add_test(xFbtest
41+
${CMAKE_COMMAND}
42+
-DMPIEXEC=${MPIEXEC}
43+
-DMPIEXEC_NUMPROC_FLAG=${MPIEXEC_NUMPROC_FLAG}
44+
-DTEST_PROG=xFbtest
45+
-DOUTPUTDIR=${SCALAPACK_BINARY_DIR}/BLACS/TESTING
46+
-DRUNTIMEDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
47+
-DSOURCEDIR=${CMAKE_CURRENT_SOURCE_DIR}
48+
-P ${CMAKE_CURRENT_SOURCE_DIR}/runtest.cmake
49+
)

BLACS/TESTING/runtest.cmake

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
message("Running BLACS TESTS")
2+
message(STATUS "${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ./${TEST_PROG}")
3+
message(STATUS "Output out_${TEST_PROG}.txt")
4+
file(COPY ${RUNTIMEDIR}/${TEST_PROG} DESTINATION ${OUTPUTDIR})
5+
6+
execute_process(COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ./${TEST_PROG}
7+
OUTPUT_FILE "out_${TEST_PROG}.txt"
8+
ERROR_FILE "error_${TEST_PROG}.txt"
9+
RESULT_VARIABLE HAD_ERROR)
10+
11+
if(HAD_ERROR)
12+
# This is normal to exit in Error (good behaviour)
13+
# 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)
15+
16+
STRING(REPLACE "DONE BLACS_GRIDEXIT" "BLACS OK" tmp ${TESTSTRING})
17+
18+
if("${tmp}" STREQUAL "${TESTSTRING}")
19+
message( STATUS "Error in error_${TEST_PROG}.txt")
20+
message(FATAL_ERROR "Test failed - Test did not reach DONE BLACS_GRIDEXIT")
21+
else()
22+
message( STATUS "Test Passed")
23+
endif()
24+
endif()

CMAKE/CTestCustom.cmake.in

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#
2+
# For further details regarding this file,
3+
# see http://www.vtk.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest
4+
#
5+
6+
SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 0)
7+
SET(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 0)
8+
SET(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 500)
9+
SET(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 500)
10+
11+
# Files to explicitly exclude from code coverage
12+
SET(CTEST_CUSTOM_COVERAGE_EXCLUDE
13+
${CTEST_CUSTOM_COVERAGE_EXCLUDE}
14+
15+
# Exclude the testing code itself from code coverage
16+
"/TESTING/"
17+
)
18+
19+
# Warnings to explicitly ignore
20+
SET(CTEST_CUSTOM_WARNING_EXCEPTION
21+
${CTEST_CUSTOM_WARNING_EXCEPTION}
22+
23+
# Common warning when linking ATLAS built with GNU Fortran 4.1 and building
24+
# with GNU Fortran 4.4. It can be safely ignored.
25+
"libgfortran.*may conflict with libgfortran"
26+
27+
# Harmless warning often seen on IRIX
28+
"WARNING 84 : .*libm.* is not used for resolving any symbol"
29+
30+
# Warnings caused by sun compilers when building code to only run on your
31+
# native platform
32+
"xarch=native on this architecture implies -xarch=.*which generates code that does not run"
33+
34+
# Harmless warnings from the Intel compiler on Windows
35+
"ipo: warning #11010: file format not recognized for .*\\.exe\\.embed\\.manifest\\.res"
36+
"LINK : warning LNK4224: /INCREMENTAL:YES is no longer supported; ignored"
37+
38+
# Warnings caused by string truncation in the test code. The truncation is
39+
# intentional
40+
"Character string truncated to length 1 on assignment"
41+
)
42+

0 commit comments

Comments
 (0)