Skip to content

Commit

Permalink
scalapack: submodule if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed May 27, 2024
1 parent 8fedcf5 commit 59c21f9
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 140 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,45 @@ jobs:
if: ${{ failure() && matrix.metis }}
run: |
cat example/metis/build/CMakeFiles/CMakeConfigureLog.yaml
autobuild_scalapack:
timeout-minutes: 15

strategy:
matrix:
os: [ubuntu-24.04]

runs-on: ${{ matrix.os }}

env:
FC: gfortran-13

steps:

- name: Install prereqs (Linux)
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install --no-install-recommends libopenmpi-dev openmpi-bin liblapack-dev ninja-build
- name: Install prereqs (macOS)
if: runner.os == 'macOS'
run: brew install open-mpi ninja

- uses: actions/checkout@v4

- name: Build, test Scalpack and MUMPSS
run: cmake --workflow --preset default

- name: install package
run: cmake --install build

- name: configure example
run: cmake -S example -B example/build

- name: build example
run: cmake --build example/build

- name: test example
run: ctest --test-dir example/build -V
43 changes: 0 additions & 43 deletions .github/workflows/ci_build.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "scalapack"]
path = scalapack
url = https://github.com/scivision/scalapack.git
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# MUMPS sparse solver

[![ci](https://github.com/scivision/mumps/actions/workflows/ci.yml/badge.svg)](https://github.com/scivision/mumps/actions/workflows/ci.yml)
[![ci_build](https://github.com/scivision/mumps/actions/workflows/ci_build.yml/badge.svg)](https://github.com/scivision/mumps/actions/workflows/ci_build.yml)
[![oneapi-linux](https://github.com/scivision/mumps/actions/workflows/oneapi-linux.yml/badge.svg)](https://github.com/scivision/mumps/actions/workflows/oneapi-linux.yml)

CMake downloads the unmodified source tarfile from MUMPS developers and builds.
Expand Down
94 changes: 94 additions & 0 deletions cmake/GitSubmodule.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# else it's an offline archive
if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/.git)
find_package(Git REQUIRED)
endif()

function(git_submodule submod_dir)
# get/update Git submodule directory to CMake, assuming the
# Git submodule directory is a CMake project.

# EXISTS, do not use IS_DIRECTORY as in submodule .git is a file not a directory
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/.git)
message(DEBUG "${PROJECT_SOURCE_DIR} is not a Git repository, skipping submodule ${submod_dir}")
return()
endif()

if(EXISTS ${submod_dir}/CMakeLists.txt)
return()
endif()

execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${submod_dir}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE err)

if(NOT err EQUAL 0)
message(FATAL_ERROR "${submod_dir} Git submodule failed to retrieve.")
endif()

endfunction()


function(report_submodule submod_dir)
# get the following information for the Git submodule
# git remote -v
# git status --porcelain
# git commit hash

if(NOT EXISTS ${submod_dir}/.git)
message(VERBOSE "${submod_dir} is not a Git submodule, skipping}")
return()
endif()

set(git_remote "origin")
# Git default remote name

execute_process(COMMAND ${GIT_EXECUTABLE} -C ${submod_dir} remote get-url ${git_remote}
OUTPUT_VARIABLE r
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE ret
)

if(NOT ret EQUAL 0)
message(STATUS "Git remote failed for ${submod_dir}")
return()
endif()

if(r MATCHES "@")
# remove token from remote URL
string(REGEX REPLACE "://[^@]+@" "://" r "${r}")
endif()

execute_process(COMMAND ${GIT_EXECUTABLE} -C ${submod_dir} status --porcelain
OUTPUT_VARIABLE p
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE ret
)

if(NOT ret EQUAL 0)
message(STATUS "Git status failed for ${submod_dir}")
return()
endif()

string(LENGTH "${p}" p_len)
if(p_len EQUAL 0)
set(porcelain "clean")
else()
set(porcelain "dirty")
endif()

execute_process(COMMAND ${GIT_EXECUTABLE} -C ${submod_dir} rev-parse --short HEAD
OUTPUT_VARIABLE h
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE ret
)

if(NOT ret EQUAL 0)
message(STATUS "Git rev-parse failed for ${submod_dir}")
return()
endif()

get_filename_component(name ${submod_dir} NAME)

message(STATUS "${name} remote: ${r} ${porcelain} ${h}")

endfunction()
4 changes: 0 additions & 4 deletions cmake/libraries.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
"lapack": {
"git": "https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v3.12.0.tar.gz"
},
"scalapack": {
"git": "https://github.com/scivision/scalapack.git",
"tag": "7d2a199b91187f92c553179e22f76f42bc813728"
},
"metis": {
"git": "https://github.com/scivision/METIS.git",
"tag": "v5.1.0.3"
Expand Down
63 changes: 3 additions & 60 deletions cmake/scalapack.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
include(ExternalProject)
include(GNUInstallDirs)

if(find)

if(NOT DEFINED SCALAPACK_VENDOR)
Expand Down Expand Up @@ -31,60 +28,6 @@ if(SCALAPACK_FOUND)
return()
endif()

set(scalapack_cmake_args
-DBUILD_SINGLE:BOOL=${BUILD_SINGLE}
-DBUILD_DOUBLE:BOOL=${BUILD_DOUBLE}
-DBUILD_COMPLEX:BOOL=${BUILD_COMPLEX}
-DBUILD_COMPLEX16:BOOL=${BUILD_COMPLEX16}
-DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:PATH=${CMAKE_C_COMPILER}
-DCMAKE_Fortran_COMPILER:PATH=${CMAKE_Fortran_COMPILER}
-DBUILD_TESTING:BOOL=off
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_TLS_VERIFY:BOOL=${CMAKE_TLS_VERIFY}
)

file(READ ${CMAKE_CURRENT_LIST_DIR}/libraries.json json)

string(JSON scalapack_url GET ${json} scalapack git)
string(JSON scalapack_tag GET ${json} scalapack tag)

set(SCALAPACK_INCLUDE_DIRS ${CMAKE_INSTALL_FULL_INCLUDEDIR})
file(MAKE_DIRECTORY ${SCALAPACK_INCLUDE_DIRS})
if(NOT IS_DIRECTORY ${SCALAPACK_INCLUDE_DIRS})
message(FATAL_ERROR "Could not create directory: ${SCALAPACK_INCLUDE_DIRS}")
endif()

if(BUILD_SHARED_LIBS)
set(SCALAPACK_LIBRARIES ${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}scalapack${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}blacs${CMAKE_SHARED_LIBRARY_SUFFIX}
)
else()
set(SCALAPACK_LIBRARIES ${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}scalapack${CMAKE_STATIC_LIBRARY_SUFFIX}
${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}blacs${CMAKE_STATIC_LIBRARY_SUFFIX}
)
endif()

ExternalProject_Add(scalapack
GIT_REPOSITORY ${scalapack_url}
GIT_TAG ${scalapack_tag}
GIT_SHALLOW true
CMAKE_ARGS ${scalapack_cmake_args}
TEST_COMMAND ""
BUILD_BYPRODUCTS ${SCALAPACK_LIBRARIES}
CONFIGURE_HANDLED_BY_BUILD true
USES_TERMINAL_DOWNLOAD true
USES_TERMINAL_UPDATE true
USES_TERMINAL_PATCH true
USES_TERMINAL_CONFIGURE true
USES_TERMINAL_BUILD true
USES_TERMINAL_INSTALL true
USES_TERMINAL_TEST true
)

add_library(SCALAPACK::SCALAPACK INTERFACE IMPORTED GLOBAL)
target_include_directories(SCALAPACK::SCALAPACK INTERFACE ${SCALAPACK_INCLUDE_DIRS})
target_link_libraries(SCALAPACK::SCALAPACK INTERFACE ${SCALAPACK_LIBRARIES})

add_dependencies(SCALAPACK::SCALAPACK scalapack)
include(${CMAKE_CURRENT_LIST_DIR}/GitSubmodule.cmake)
git_submodule(${PROJECT_SOURCE_DIR}/scalapack)
add_subdirectory(${PROJECT_SOURCE_DIR}/scalapack)
1 change: 1 addition & 0 deletions scalapack
Submodule scalapack added at acf286
32 changes: 0 additions & 32 deletions scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,38 +34,6 @@ set(cmake_args
-DBUILD_TESTING:BOOL=false
)

# Lapack
set(lapack_cmake_args ${cmake_args}
-DBUILD_SINGLE:BOOL=${BUILD_SINGLE}
-DBUILD_DOUBLE:BOOL=${BUILD_DOUBLE}
-DBUILD_COMPLEX:BOOL=${BUILD_COMPLEX}
-DBUILD_COMPLEX16:BOOL=${BUILD_COMPLEX16}
)

string(JSON lapack_url GET ${json} lapack git)

ExternalProject_Add(lapack
URL ${lapack_url}
CMAKE_ARGS ${lapack_cmake_args}
CONFIGURE_HANDLED_BY_BUILD true
)

# Scalapack

set(scalapack_cmake_args ${lapack_cmake_args})

string(JSON scalapack_url GET ${json} scalapack git)
string(JSON scalapack_tag GET ${json} scalapack tag)

ExternalProject_Add(scalapack
GIT_REPOSITORY ${scalapack_url}
GIT_TAG ${scalapack_tag}
GIT_SHALLOW true
CMAKE_ARGS ${scalapack_cmake_args}
DEPENDS lapack
CONFIGURE_HANDLED_BY_BUILD true
)

# METIS

set(metis_cmake_args ${cmake_args}
Expand Down

0 comments on commit 59c21f9

Please sign in to comment.