Skip to content

Commit

Permalink
No need for FetchContent
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed May 28, 2024
1 parent 9555484 commit 542e34e
Show file tree
Hide file tree
Showing 19 changed files with 441 additions and 275 deletions.
26 changes: 13 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ endif()

project(SCALAPACK
LANGUAGES C Fortran
VERSION 2.2.1.7
VERSION 2.2.1.8
HOMEPAGE_URL "http://netlib.org/scalapack"
)

Expand All @@ -30,13 +30,11 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)

include(cmake/lapack.cmake)

# --- get Scalapack source
include(cmake/scalapack_src.cmake)

# --- BLACS
configure_file(blacs/src/CMakeLists.txt ${scalapack_src_SOURCE_DIR}/BLACS/SRC/ COPYONLY)
add_subdirectory(${scalapack_src_SOURCE_DIR}/BLACS/SRC ${scalapack_src_BINARY_DIR}/BLACS/SRC)
# --- Scalapack source
include(cmake/GitSubmodule.cmake)
git_submodule("${PROJECT_SOURCE_DIR}/scalapack")

include(cmake/blacs.cmake)

# == SCALAPACK
add_library(scalapack)
Expand All @@ -50,12 +48,14 @@ target_compile_definitions(scalapack PRIVATE ${cargs})
add_library(SCALAPACK::SCALAPACK INTERFACE IMPORTED GLOBAL)
target_link_libraries(SCALAPACK::SCALAPACK INTERFACE scalapack)

foreach(d IN ITEMS src/ pblas/src/ pblas/src/pbblas/ pblas/src/ptools/ pblas/src/ptzblas/ redist/src/ tools/ tools/lapack/)
string(TOUPPER ${d} D)

configure_file(${d}CMakeLists.txt ${scalapack_src_SOURCE_DIR}/${D} COPYONLY)
add_subdirectory(${scalapack_src_SOURCE_DIR}/${D} ${scalapack_src_BINARY_DIR}/${D})
endforeach()
include(cmake/src.cmake)
include(cmake/pblas.cmake)
include(cmake/pbblas.cmake)
include(cmake/ptools.cmake)
include(cmake/ptzblas.cmake)
include(cmake/redist.cmake)
include(cmake/tools.cmake)
include(cmake/tools_lapack.cmake)

if(${PROJECT_NAME}_BUILD_TESTING)
add_subdirectory(test)
Expand Down
54 changes: 0 additions & 54 deletions blacs/src/CMakeLists.txt

This file was deleted.

97 changes: 97 additions & 0 deletions cmake/blacs.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
set(_p ${PROJECT_SOURCE_DIR}/scalapack/BLACS/SRC/)

# The communication routines
set(comm)
foreach(i IN ITEMS igesd2d_.c itrsd2d_.c igerv2d_.c itrrv2d_.c igebs2d_.c igebr2d_.c itrbs2d_.c itrbr2d_.c igsum2d_.c igamx2d_.c igamn2d_.c dgsum2d_.c dgamx2d_.c dgamn2d_.c)
list(APPEND comm ${_p}${i})
endforeach()

if(BUILD_SINGLE)
foreach(i IN ITEMS sgesd2d_.c strsd2d_.c sgerv2d_.c strrv2d_.c sgebs2d_.c sgebr2d_.c strbs2d_.c strbr2d_.c sgsum2d_.c sgamx2d_.c sgamn2d_.c)
list(APPEND comm ${_p}${i})
endforeach()
endif()

if(BUILD_DOUBLE)
foreach(i IN ITEMS dgesd2d_.c dtrsd2d_.c dgerv2d_.c dtrrv2d_.c dgebs2d_.c dgebr2d_.c dtrbs2d_.c dtrbr2d_.c dgamx2d_.c)
list(APPEND comm ${_p}${i})
endforeach()
endif()

if(BUILD_COMPLEX)
foreach(i IN ITEMS cgesd2d_.c ctrsd2d_.c cgerv2d_.c ctrrv2d_.c cgebs2d_.c cgebr2d_.c ctrbs2d_.c ctrbr2d_.c cgsum2d_.c cgamx2d_.c cgamn2d_.c)
list(APPEND comm ${_p}${i})
endforeach()
endif()

if(BUILD_COMPLEX16)
foreach(i IN ITEMS zgesd2d_.c ztrsd2d_.c zgerv2d_.c ztrrv2d_.c zgebs2d_.c zgebr2d_.c ztrbs2d_.c ztrbr2d_.c zgsum2d_.c zgamx2d_.c zgamn2d_.c)
list(APPEND comm ${_p}${i})
endforeach()
endif()

# The support routines
set(supp)

foreach(i IN ITEMS blacs_setup_.c blacs_set_.c blacs_get_.c blacs_abort_.c blacs_exit_.c blacs_pnum_.c
blacs_pcoord_.c ksendid_.c krecvid_.c kbsid_.c kbrid_.c dcputime00_.c dwalltime00_.c
blacs_pinfo_.c blacs_init_.c blacs_map_.c blacs_free_.c blacs_grid_.c blacs_info_.c
blacs_barr_.c sys2blacs_.c blacs2sys_.c free_handle_.c)
list(APPEND supp ${_p}${i})
endforeach()

# The internal routines
set(blacsInternal)

foreach(i IN ITEMS BI_HypBS.c BI_HypBR.c BI_IdringBS.c BI_IdringBR.c BI_MpathBS.c BI_MpathBR.c BI_SringBS.c
BI_SringBR.c BI_TreeBS.c BI_TreeBR.c BI_Ssend.c BI_Rsend.c BI_Srecv.c BI_Asend.c BI_Arecv.c
BI_TreeComb.c BI_BeComb.c BI_MringComb.c BI_ArgCheck.c BI_TransDist.c BI_GetBuff.c
BI_UpdateBuffs.c BI_EmergencyBuff.c BI_BlacsErr.c BI_BlacsWarn.c BI_BlacsAbort.c BI_BuffIsFree.c
BI_imvcopy.c BI_ivmcopy.c
BI_Pack.c BI_Unpack.c BI_GetMpiGeType.c BI_GetMpiTrType.c
BI_ivvsum.c BI_ivvamx.c BI_ivvamx2.c BI_ivvamn.c BI_ivvamn2.c
BI_iMPI_amx.c BI_iMPI_amx2.c BI_iMPI_amn.c BI_iMPI_amn2.c
BI_ContxtNum.c BI_GlobalVars.c BI_TransUserComm.c
BI_dvvsum.c BI_dvvamx.c BI_dvvamx2.c BI_dvvamn.c BI_dvvamn2.c BI_dMPI_amx.c BI_dMPI_amx2.c BI_dMPI_amn.c BI_dMPI_amn2.c
BI_dmvcopy.c BI_dvmcopy.c)
list(APPEND blacsInternal ${_p}${i})
endforeach()

if(BUILD_SINGLE)
foreach(i IN ITEMS BI_svvsum.c BI_svvamx.c BI_svvamx2.c BI_svvamn.c BI_svvamn2.c BI_sMPI_amx.c BI_sMPI_amx2.c BI_sMPI_amn.c BI_sMPI_amn2.c
BI_smvcopy.c BI_svmcopy.c)
list(APPEND blacsInternal ${_p}${i})
endforeach()
endif()

if(BUILD_COMPLEX)
foreach(i IN ITEMS BI_cvvsum.c BI_cvvamx.c BI_cvvamx2.c BI_cvvamn.c BI_cvvamn2.c BI_cMPI_amx.c BI_cMPI_amx2.c BI_cMPI_amn.c BI_cMPI_amn2.c BI_cMPI_sum.c)
list(APPEND blacsInternal ${_p}${i})
endforeach()
endif()

if(BUILD_COMPLEX16)
foreach(i IN ITEMS BI_zvvsum.c BI_zvvamx.c BI_zvvamx2.c BI_zvvamn.c BI_zvvamn2.c BI_zMPI_amx.c BI_zMPI_amx2.c BI_zMPI_amn.c BI_zMPI_amn2.c BI_zMPI_sum.c)
list(APPEND blacsInternal ${_p}${i})
endforeach()
endif()

add_library(blacsCinit OBJECT ${comm} ${supp})
target_compile_definitions(blacsCinit PRIVATE -DCallFromC ${cargs})
target_link_libraries(blacsCinit PRIVATE MPI::MPI_C)

add_library(blacsF77init OBJECT ${comm} ${supp})
target_compile_definitions(blacsF77init PRIVATE ${cargs}) # NOT CallFromC!
target_link_libraries(blacsF77init PRIVATE MPI::MPI_C)

# LINK_INTERFACE_MULTIPLICITY did not help
# there are cyclical references between {blacs,blacsF77init,blacsCinit}, which Meson handles by -Wl,start-group
# we opted to use objects instead
add_library(blacs ${blacsInternal} $<TARGET_OBJECTS:blacsF77init> $<TARGET_OBJECTS:blacsCinit>)
target_link_libraries(blacs PRIVATE MPI::MPI_C)
set_property(TARGET blacs PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set_property(TARGET blacs PROPERTY LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set_property(TARGET blacs PROPERTY VERSION ${SCALAPACK_VERSION})
set_property(TARGET blacs PROPERTY EXPORT_NAME BLACS)

install(TARGETS blacs EXPORT ${PROJECT_NAME}-targets)
30 changes: 30 additions & 0 deletions cmake/pbblas.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
set(_p ${PROJECT_SOURCE_DIR}/scalapack/pblas/src/pbblas/)

set(pbblas)

if(BUILD_SINGLE)
foreach(i IN ITEMS pbstran.f pbsmatadd.f pbstrsrt.f pbstrget.f pbstrnv.f pbsvecadd.f pbstrst1.f)
list(APPEND pbblas ${_p}${i})
endforeach()
endif()

if(BUILD_COMPLEX)
foreach(i IN ITEMS pbctran.f pbcmatadd.f pbctrsrt.f pbctrget.f pbctrnv.f pbcvecadd.f pbctrst1.f)
list(APPEND pbblas ${_p}${i})
endforeach()
endif()

if(BUILD_DOUBLE)
foreach(i IN ITEMS pbdtran.f pbdmatadd.f pbdtrsrt.f pbdtrget.f pbdtrnv.f pbdvecadd.f pbdtrst1.f)
list(APPEND pbblas ${_p}${i})
endforeach()
endif()

if(BUILD_COMPLEX16)
foreach(i IN ITEMS pbztran.f pbzmatadd.f pbztrsrt.f pbztrget.f pbztrnv.f pbzvecadd.f pbztrst1.f)
list(APPEND pbblas ${_p}${i})
endforeach()
endif()


target_sources(scalapack PRIVATE ${pbblas})
97 changes: 97 additions & 0 deletions cmake/pblas.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
set(_p ${PROJECT_SOURCE_DIR}/scalapack/PBLAS/SRC/)

add_library(appblas OBJECT ${_p}pilaenv.f)
#---------------------------------------------------------------------------
# Level 1 PBLAS.
#---------------------------------------------------------------------------
set(piblas1 ${_p}picopy_.c)

set(blas1)

if(BUILD_SINGLE)
foreach(i IN ITEMS psswap_.c psscal_.c pscopy_.c psaxpy_.c psdot_.c psnrm2_.c psasum_.c psamax_.c)
list(APPEND blas1 ${_p}${i})
endforeach()
endif()

if(BUILD_DOUBLE)
foreach(i IN ITEMS pdswap_.c pdscal_.c pdcopy_.c pdaxpy_.c pddot_.c pdnrm2_.c pdasum_.c pdamax_.c)
list(APPEND blas1 ${_p}${i})
endforeach()
endif()

if(BUILD_COMPLEX)
foreach(i IN ITEMS pcswap_.c pcscal_.c pcsscal_.c pccopy_.c pcaxpy_.c pcdotu_.c pcdotc_.c pscnrm2_.c pscasum_.c pcamax_.c)
list(APPEND blas1 ${_p}${i})
endforeach()
endif()

if(BUILD_COMPLEX16)
foreach(i IN ITEMS pzswap_.c pzscal_.c pzdscal_.c pzcopy_.c pzaxpy_.c pzdotu_.c pzdotc_.c pdznrm2_.c pdzasum_.c pzamax_.c)
list(APPEND blas1 ${_p}${i})
endforeach()
endif()
#---------------------------------------------------------------------------
# Level 2 PBLAS.
#---------------------------------------------------------------------------

set(blas2)

if(BUILD_SINGLE)
foreach(i IN ITEMS psgemv_.c psger_.c pssymv_.c pssyr_.c pssyr2_.c pstrmv_.c pstrsv_.c psagemv_.c psasymv_.c psatrmv_.c)
list(APPEND blas2 ${_p}${i})
endforeach()
endif()

if(BUILD_COMPLEX)
foreach(i IN ITEMS pcgemv_.c pcgerc_.c pcgeru_.c pchemv_.c pcher_.c pcher2_.c pctrmv_.c pctrsv_.c pcagemv_.c pcahemv_.c pcatrmv_.c)
list(APPEND blas2 ${_p}${i})
endforeach()
endif()

if(BUILD_DOUBLE)
foreach(i IN ITEMS pdgemv_.c pdger_.c pdsymv_.c pdsyr_.c pdsyr2_.c pdtrmv_.c pdtrsv_.c pdagemv_.c pdasymv_.c pdatrmv_.c)
list(APPEND blas2 ${_p}${i})
endforeach()
endif()

if(BUILD_COMPLEX16)
foreach(i IN ITEMS pzgemv_.c pzgerc_.c pzgeru_.c pzhemv_.c pzher_.c pzher2_.c pztrmv_.c pztrsv_.c pzagemv_.c pzahemv_.c pzatrmv_.c)
list(APPEND blas2 ${_p}${i})
endforeach()
endif()

#---------------------------------------------------------------------------
# Level 3 PBLAS.
#---------------------------------------------------------------------------
set(blas3)


if(BUILD_SINGLE)
foreach(i IN ITEMS psgeadd_.c psgemm_.c pssymm_.c pssyr2k_.c pssyrk_.c pstradd_.c pstran_.c pstrmm_.c pstrsm_.c)
list(APPEND blas3 ${_p}${i})
endforeach()
endif()

if(BUILD_COMPLEX)
foreach(i IN ITEMS pcgeadd_.c pcgemm_.c pchemm_.c pcher2k_.c pcherk_.c pcsymm_.c pcsyr2k_.c pcsyrk_.c pctradd_.c pctranc_.c pctranu_.c pctrmm_.c pctrsm_.c)
list(APPEND blas3 ${_p}${i})
endforeach()
endif()

if(BUILD_DOUBLE)
foreach(i IN ITEMS pdgeadd_.c pdgemm_.c pdsymm_.c pdsyr2k_.c pdsyrk_.c pdtradd_.c pdtran_.c pdtrmm_.c pdtrsm_.c)
list(APPEND blas3 ${_p}${i})
endforeach()
endif()

if(BUILD_COMPLEX16)
foreach(i IN ITEMS pzgeadd_.c pzgemm_.c pzhemm_.c pzher2k_.c pzherk_.c pzsymm_.c pzsyr2k_.c pzsyrk_.c pztradd_.c pztranc_.c pztranu_.c pztrmm_.c pztrsm_.c)
list(APPEND blas3 ${_p}${i})
endforeach()
endif()


add_library(scalapack_blas OBJECT ${piblas1} ${blas1} ${blas2} ${blas3})

target_sources(scalapack PRIVATE $<TARGET_OBJECTS:appblas> $<TARGET_OBJECTS:scalapack_blas>)
31 changes: 24 additions & 7 deletions pblas/src/ptools/CMakeLists.txt → cmake/ptools.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
set(ALLCTOOLS
set(_p ${PROJECT_SOURCE_DIR}/scalapack/pblas/src/ptools/)

set(ALLCTOOLS)

foreach(i IN ITEMS
PB_CGatherV.c PB_CInV.c PB_CInV2.c PB_CInOutV.c
PB_CInOutV2.c PB_COutV.c PB_CScatterV.c PB_CVMinit.c
PB_CVMloc.c PB_CVMnpq.c PB_CVMpack.c PB_CVMswp.c
Expand All @@ -25,13 +29,26 @@ set(ALLCTOOLS
PB_Cdescset.c PB_Cdescribe.c PB_CargFtoC.c PB_Cfirstnb.c
PB_Clastnb.c PB_Cspan.c
)
list(APPEND ALLCTOOLS ${_p}${i})
endforeach()

set(pctools
$<$<BOOL:${BUILD_SINGLE}>:PB_Cstypeset.c>
$<$<BOOL:${BUILD_DOUBLE}>:PB_Cdtypeset.c>
$<$<BOOL:${BUILD_COMPLEX}>:PB_Cctypeset.c>
$<$<BOOL:${BUILD_COMPLEX16}>:PB_Cztypeset.c>
)
set(pctools)

if(BUILD_SINGLE)
list(APPEND pctools ${_p}PB_Cstypeset.c)
endif()

if(BUILD_DOUBLE)
list(APPEND pctools ${_p}PB_Cdtypeset.c)
endif()

if(BUILD_COMPLEX)
list(APPEND pctools ${_p}PB_Cctypeset.c)
endif()

if(BUILD_COMPLEX16)
list(APPEND pctools ${_p}PB_Cztypeset.c)
endif()

add_library(scalapack_pctools OBJECT ${ALLCTOOLS} ${pctools})

Expand Down
Loading

0 comments on commit 542e34e

Please sign in to comment.