Commit 5f1d3ef0 authored by Michel Henry's avatar Michel Henry
Browse files

Merge branch 'master' into simon_yans

parents accd4f8c 9b980cb4
Pipeline #9859 passed with stages
in 49 minutes and 24 seconds
......@@ -34,6 +34,8 @@ set(CMAKE_C_STANDARD 99)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(MUMPS_PACH_COMMAND "")
if(${CMAKE_VERSION} VERSION_LESS "3.20.0")
set(MUMPS_PATCH_COMMAND patch -p1 < ${PROJECT_SOURCE_DIR}/cmake/CMakeMumpsPre3.20.diff)
else()
set(MUMPS_PATCH_COMMAND patch -p1 < ${PROJECT_SOURCE_DIR}/cmake/CMakeMumps.diff)
endif()
if(BUILD_MUMPS)
......
diff -ruN mumps/CMakeLists.txt mumps-ok/CMakeLists.txt
--- mumps/CMakeLists.txt 2021-10-04 14:31:04.000000000 +0000
+++ mumps-ok/CMakeLists.txt 2021-10-08 14:38:20.823214013 +0000
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.20...3.21)
+cmake_minimum_required(VERSION 3.0...3.21)
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION PROJECT_VERSION
REGEX "^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)" LIMIT_INPUT 16 LENGTH_MAXIMUM 16 LIMIT_COUNT 1)
diff -ruN mumps/cmake/Modules/CheckSourceCompiles.cmake mumps-ok/cmake/Modules/CheckSourceCompiles.cmake
--- mumps/cmake/Modules/CheckSourceCompiles.cmake 1970-01-01 00:00:00.000000000 +0000
+++ mumps-ok/cmake/Modules/CheckSourceCompiles.cmake 2021-10-08 14:38:20.823214013 +0000
@@ -0,0 +1,134 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+include_guard(GLOBAL)
+
+cmake_policy(PUSH)
+cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced
+cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST
+
+function(CMAKE_CHECK_SOURCE_COMPILES _lang _source _var)
+ if(NOT DEFINED "${_var}")
+
+ if(_lang STREQUAL "C")
+ set(_lang_textual "C")
+ set(_lang_ext "c")
+ elseif(_lang STREQUAL "CXX")
+ set(_lang_textual "C++")
+ set(_lang_ext "cxx")
+ elseif(_lang STREQUAL "CUDA")
+ set(_lang_textual "CUDA")
+ set(_lang_ext "cu")
+ elseif(_lang STREQUAL "Fortran")
+ set(_lang_textual "Fortran")
+ set(_lang_ext "F90")
+ elseif(_lang STREQUAL "HIP")
+ set(_lang_textual "HIP")
+ set(_lang_ext "hip")
+ elseif(_lang STREQUAL "ISPC")
+ set(_lang_textual "ISPC")
+ set(_lang_ext "ispc")
+ elseif(_lang STREQUAL "OBJC")
+ set(_lang_textual "Objective-C")
+ set(_lang_ext "m")
+ elseif(_lang STREQUAL "OBJCXX")
+ set(_lang_textual "Objective-C++")
+ set(_lang_ext "mm")
+ else()
+ message (SEND_ERROR "check_source_compiles: ${_lang}: unknown language.")
+ return()
+ endif()
+
+ get_property (_supported_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
+ if (NOT _lang IN_LIST _supported_languages)
+ message (SEND_ERROR "check_source_compiles: ${_lang}: needs to be enabled before use.")
+ return()
+ endif()
+
+ set(_FAIL_REGEX)
+ set(_SRC_EXT)
+ set(_key)
+ foreach(arg ${ARGN})
+ if("${arg}" MATCHES "^(FAIL_REGEX|SRC_EXT)$")
+ set(_key "${arg}")
+ elseif(_key STREQUAL "FAIL_REGEX")
+ list(APPEND _FAIL_REGEX "${arg}")
+ elseif(_key STREQUAL "SRC_EXT")
+ set(_SRC_EXT "${arg}")
+ set(_key "")
+ else()
+ message(FATAL_ERROR "Unknown argument:\n ${arg}\n")
+ endif()
+ endforeach()
+
+ if(NOT _SRC_EXT)
+ set(_SRC_EXT ${_lang_ext})
+ endif()
+
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_${LANG}_SOURCE_COMPILES_ADD_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_${LANG}_SOURCE_COMPILES_ADD_LINK_OPTIONS)
+ endif()
+ if(CMAKE_REQUIRED_LIBRARIES)
+ set(CHECK_${LANG}_SOURCE_COMPILES_ADD_LIBRARIES
+ LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ else()
+ set(CHECK_${LANG}_SOURCE_COMPILES_ADD_LIBRARIES)
+ endif()
+ if(CMAKE_REQUIRED_INCLUDES)
+ set(CHECK_${LANG}_SOURCE_COMPILES_ADD_INCLUDES
+ "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
+ else()
+ set(CHECK_${LANG}_SOURCE_COMPILES_ADD_INCLUDES)
+ endif()
+ file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}"
+ "${_source}\n")
+
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(CHECK_START "Performing Test ${_var}")
+ endif()
+ try_compile(${_var}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}
+ COMPILE_DEFINITIONS -D${_var} ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_${LANG}_SOURCE_COMPILES_ADD_LINK_OPTIONS}
+ ${CHECK_${LANG}_SOURCE_COMPILES_ADD_LIBRARIES}
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS}
+ "${CHECK_${LANG}_SOURCE_COMPILES_ADD_INCLUDES}"
+ OUTPUT_VARIABLE OUTPUT)
+
+ foreach(_regex ${_FAIL_REGEX})
+ if("${OUTPUT}" MATCHES "${_regex}")
+ set(${_var} 0)
+ endif()
+ endforeach()
+
+ if(${_var})
+ set(${_var} 1 CACHE INTERNAL "Test ${_var}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(CHECK_PASS "Success")
+ endif()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Performing ${_lang_textual} SOURCE FILE Test ${_var} succeeded with the following output:\n"
+ "${OUTPUT}\n"
+ "Source file was:\n${_source}\n")
+ else()
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(CHECK_FAIL "Failed")
+ endif()
+ set(${_var} "" CACHE INTERNAL "Test ${_var}")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Performing ${_lang_textual} SOURCE FILE Test ${_var} failed with the following output:\n"
+ "${OUTPUT}\n"
+ "Source file was:\n${_source}\n")
+ endif()
@@ -47,6 +47,10 @@
configure_file(libseq/CMakeLists.txt ${mumps_SOURCE_DIR}/libseq/ COPYONLY)
add_subdirectory(${mumps_SOURCE_DIR}/libseq ${mumps_BINARY_DIR}/libseq)
set(NUMERIC_LIBS mpiseq)
+ if(openmp)
+ find_package(OpenMP COMPONENTS C Fortran REQUIRED)
+ list(APPEND NUMERIC_LIBS OpenMP::OpenMP_Fortran OpenMP::OpenMP_C)
+ endif()
+endfunction()
+
+cmake_policy(POP)
+function(CHECK_SOURCE_COMPILES _lang _source _var)
+ cmake_check_source_compiles(${_lang} "${_source}" ${_var} ${ARGN})
+endfunction()
+
diff -ruN mumps/cmake/get_mumps.cmake mumps-ok/cmake/get_mumps.cmake
--- mumps/cmake/get_mumps.cmake 2021-10-04 14:31:04.000000000 +0000
+++ mumps-ok/cmake/get_mumps.cmake 2021-10-08 14:38:20.823214013 +0000
@@ -2,16 +2,18 @@
file(READ ${CMAKE_CURRENT_LIST_DIR}/libraries.json json)
+string(REGEX MATCH "\"mumps\": {.*\"${MUMPS_UPSTREAM_VERSION}\": {([^}]*)}" _ ${json})
+set(info ${CMAKE_MATCH_1})
+string(REGEX MATCH "\"sha256\": \"([^\"]*)\"" _ ${info})
+set(mumps_sha256 ${CMAKE_MATCH_1})
+string(REGEX MATCH "\"urls\": [\[]([^\]]*)" _ ${info})
+string(REGEX MATCHALL "\"([^\"]*)\"" urllist ${CMAKE_MATCH_1})
set(mumps_urls)
-string(JSON N LENGTH ${json} mumps ${MUMPS_UPSTREAM_VERSION} urls)
-math(EXPR N "${N}-1")
-foreach(i RANGE ${N})
- string(JSON _u GET ${json} mumps ${MUMPS_UPSTREAM_VERSION} urls ${i})
- list(APPEND mumps_urls ${_u})
+foreach(url ${urllist})
+ string(REPLACE "\"" "" urlstrip ${url})
+ list(APPEND mumps_urls ${urlstrip})
endforeach()
-string(JSON mumps_sha256 GET ${json} mumps ${MUMPS_UPSTREAM_VERSION} sha256)
-
FetchContent_Declare(mumps
URL ${mumps_urls}
URL_HASH SHA256=${mumps_sha256}
diff -ruN mumps/cmake/libraries.cmake mumps-ok/cmake/libraries.cmake
--- mumps/cmake/libraries.cmake 2021-10-04 14:31:04.000000000 +0000
+++ mumps-ok/cmake/libraries.cmake 2021-10-08 14:38:20.823214013 +0000
@@ -1,12 +1,13 @@
set(names lapack scalapack)
-file(READ ${CMAKE_CURRENT_LIST_DIR}/libraries.json _libj)
+file(READ ${CMAKE_CURRENT_LIST_DIR}/libraries.json json)
foreach(n ${names})
- foreach(t git tag)
- string(JSON m ERROR_VARIABLE e GET ${_libj} ${n} ${t})
- if(m)
- set(${n}_${t} ${m})
- endif()
+ string(REGEX MATCH "\"${n}\": {([^\}]*)}" _ ${json})
+ string(REGEX MATCHALL "\"[^\"]*\": \"[^\"]*" info_list ${CMAKE_MATCH_1})
+ foreach(info ${info_list})
+ string(REGEX MATCH "\"([^\"]*)\": \"([^\"]*)" INFO_LIST ${info})
+ set(${n}_${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
+ message("${n}_${CMAKE_MATCH_1} ${CMAKE_MATCH_2}")
endforeach()
endforeach()
diff -ruN mumps/cmake/mumps_patch.cmake mumps-ok/cmake/mumps_patch.cmake
--- mumps/cmake/mumps_patch.cmake 2021-10-04 14:31:04.000000000 +0000
+++ mumps-ok/cmake/mumps_patch.cmake 2021-10-08 14:38:20.823214013 +0000
@@ -13,26 +13,22 @@
execute_process(COMMAND ${WSL} wslpath ${mumps_orig}
TIMEOUT 5
OUTPUT_VARIABLE mumps_orig_path
- COMMAND_ERROR_IS_FATAL ANY
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(COMMAND ${WSL} wslpath ${mumps_patch}
TIMEOUT 5
OUTPUT_VARIABLE mumps_patch_path
- COMMAND_ERROR_IS_FATAL ANY
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(COMMAND ${WSL} patch ${mumps_orig_path} ${mumps_patch_path}
TIMEOUT 10
- COMMAND_ERROR_IS_FATAL ANY
)
else()
find_program(PATCH NAMES patch REQUIRED)
execute_process(COMMAND ${PATCH} ${mumps_orig} ${mumps_patch}
TIMEOUT 10
- COMMAND_ERROR_IS_FATAL ANY
)
endif()
endif(parallel)
list(APPEND NUMERIC_LIBS LAPACK::LAPACK ${CMAKE_THREAD_LIBS_INIT})
diff -ruN mumps/CMakeLists.txt mumps-ok/CMakeLists.txt
--- mumps/CMakeLists.txt 2021-10-04 14:31:04.000000000 +0000
+++ mumps-ok/CMakeLists.txt 2021-10-08 14:38:20.823214013 +0000
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.20...3.21)
+cmake_minimum_required(VERSION 3.0...3.21)
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION PROJECT_VERSION
REGEX "^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)" LIMIT_INPUT 16 LENGTH_MAXIMUM 16 LIMIT_COUNT 1)
@@ -47,6 +47,10 @@
configure_file(libseq/CMakeLists.txt ${mumps_SOURCE_DIR}/libseq/ COPYONLY)
add_subdirectory(${mumps_SOURCE_DIR}/libseq ${mumps_BINARY_DIR}/libseq)
set(NUMERIC_LIBS mpiseq)
+ if(openmp)
+ find_package(OpenMP COMPONENTS C Fortran REQUIRED)
+ list(APPEND NUMERIC_LIBS OpenMP::OpenMP_Fortran OpenMP::OpenMP_C)
+ endif()
endif(parallel)
list(APPEND NUMERIC_LIBS LAPACK::LAPACK ${CMAKE_THREAD_LIBS_INIT})
diff -ruN mumps/cmake/Modules/CheckSourceCompiles.cmake mumps-ok/cmake/Modules/CheckSourceCompiles.cmake
--- mumps/cmake/Modules/CheckSourceCompiles.cmake 1970-01-01 00:00:00.000000000 +0000
+++ mumps-ok/cmake/Modules/CheckSourceCompiles.cmake 2021-10-08 14:38:20.823214013 +0000
@@ -0,0 +1,134 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+include_guard(GLOBAL)
+
+cmake_policy(PUSH)
+cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced
+cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST
+
+function(CMAKE_CHECK_SOURCE_COMPILES _lang _source _var)
+ if(NOT DEFINED "${_var}")
+
+ if(_lang STREQUAL "C")
+ set(_lang_textual "C")
+ set(_lang_ext "c")
+ elseif(_lang STREQUAL "CXX")
+ set(_lang_textual "C++")
+ set(_lang_ext "cxx")
+ elseif(_lang STREQUAL "CUDA")
+ set(_lang_textual "CUDA")
+ set(_lang_ext "cu")
+ elseif(_lang STREQUAL "Fortran")
+ set(_lang_textual "Fortran")
+ set(_lang_ext "F90")
+ elseif(_lang STREQUAL "HIP")
+ set(_lang_textual "HIP")
+ set(_lang_ext "hip")
+ elseif(_lang STREQUAL "ISPC")
+ set(_lang_textual "ISPC")
+ set(_lang_ext "ispc")
+ elseif(_lang STREQUAL "OBJC")
+ set(_lang_textual "Objective-C")
+ set(_lang_ext "m")
+ elseif(_lang STREQUAL "OBJCXX")
+ set(_lang_textual "Objective-C++")
+ set(_lang_ext "mm")
+ else()
+ message (SEND_ERROR "check_source_compiles: ${_lang}: unknown language.")
+ return()
+ endif()
+
+ get_property (_supported_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
+ if (NOT _lang IN_LIST _supported_languages)
+ message (SEND_ERROR "check_source_compiles: ${_lang}: needs to be enabled before use.")
+ return()
+ endif()
+
+ set(_FAIL_REGEX)
+ set(_SRC_EXT)
+ set(_key)
+ foreach(arg ${ARGN})
+ if("${arg}" MATCHES "^(FAIL_REGEX|SRC_EXT)$")
+ set(_key "${arg}")
+ elseif(_key STREQUAL "FAIL_REGEX")
+ list(APPEND _FAIL_REGEX "${arg}")
+ elseif(_key STREQUAL "SRC_EXT")
+ set(_SRC_EXT "${arg}")
+ set(_key "")
+ else()
+ message(FATAL_ERROR "Unknown argument:\n ${arg}\n")
+ endif()
+ endforeach()
+
+ if(NOT _SRC_EXT)
+ set(_SRC_EXT ${_lang_ext})
+ endif()
+
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_${LANG}_SOURCE_COMPILES_ADD_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_${LANG}_SOURCE_COMPILES_ADD_LINK_OPTIONS)
+ endif()
+ if(CMAKE_REQUIRED_LIBRARIES)
+ set(CHECK_${LANG}_SOURCE_COMPILES_ADD_LIBRARIES
+ LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ else()
+ set(CHECK_${LANG}_SOURCE_COMPILES_ADD_LIBRARIES)
+ endif()
+ if(CMAKE_REQUIRED_INCLUDES)
+ set(CHECK_${LANG}_SOURCE_COMPILES_ADD_INCLUDES
+ "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
+ else()
+ set(CHECK_${LANG}_SOURCE_COMPILES_ADD_INCLUDES)
+ endif()
+ file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}"
+ "${_source}\n")
+
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(CHECK_START "Performing Test ${_var}")
+ endif()
+ try_compile(${_var}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}
+ COMPILE_DEFINITIONS -D${_var} ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_${LANG}_SOURCE_COMPILES_ADD_LINK_OPTIONS}
+ ${CHECK_${LANG}_SOURCE_COMPILES_ADD_LIBRARIES}
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS}
+ "${CHECK_${LANG}_SOURCE_COMPILES_ADD_INCLUDES}"
+ OUTPUT_VARIABLE OUTPUT)
+
+ foreach(_regex ${_FAIL_REGEX})
+ if("${OUTPUT}" MATCHES "${_regex}")
+ set(${_var} 0)
+ endif()
+ endforeach()
+
+ if(${_var})
+ set(${_var} 1 CACHE INTERNAL "Test ${_var}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(CHECK_PASS "Success")
+ endif()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Performing ${_lang_textual} SOURCE FILE Test ${_var} succeeded with the following output:\n"
+ "${OUTPUT}\n"
+ "Source file was:\n${_source}\n")
+ else()
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(CHECK_FAIL "Failed")
+ endif()
+ set(${_var} "" CACHE INTERNAL "Test ${_var}")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Performing ${_lang_textual} SOURCE FILE Test ${_var} failed with the following output:\n"
+ "${OUTPUT}\n"
+ "Source file was:\n${_source}\n")
+ endif()
+ endif()
+endfunction()
+
+cmake_policy(POP)
+function(CHECK_SOURCE_COMPILES _lang _source _var)
+ cmake_check_source_compiles(${_lang} "${_source}" ${_var} ${ARGN})
+endfunction()
+
diff -ruN mumps/cmake/get_mumps.cmake mumps-ok/cmake/get_mumps.cmake
--- mumps/cmake/get_mumps.cmake 2021-10-04 14:31:04.000000000 +0000
+++ mumps-ok/cmake/get_mumps.cmake 2021-10-08 14:38:20.823214013 +0000
@@ -2,16 +2,18 @@
file(READ ${CMAKE_CURRENT_LIST_DIR}/libraries.json json)
+string(REGEX MATCH "\"mumps\": {.*\"${MUMPS_UPSTREAM_VERSION}\": {([^}]*)}" _ ${json})
+set(info ${CMAKE_MATCH_1})
+string(REGEX MATCH "\"sha256\": \"([^\"]*)\"" _ ${info})
+set(mumps_sha256 ${CMAKE_MATCH_1})
+string(REGEX MATCH "\"urls\": [\[]([^\]]*)" _ ${info})
+string(REGEX MATCHALL "\"([^\"]*)\"" urllist ${CMAKE_MATCH_1})
set(mumps_urls)
-string(JSON N LENGTH ${json} mumps ${MUMPS_UPSTREAM_VERSION} urls)
-math(EXPR N "${N}-1")
-foreach(i RANGE ${N})
- string(JSON _u GET ${json} mumps ${MUMPS_UPSTREAM_VERSION} urls ${i})
- list(APPEND mumps_urls ${_u})
+foreach(url ${urllist})
+ string(REPLACE "\"" "" urlstrip ${url})
+ list(APPEND mumps_urls ${urlstrip})
endforeach()
-string(JSON mumps_sha256 GET ${json} mumps ${MUMPS_UPSTREAM_VERSION} sha256)
-
FetchContent_Declare(mumps
URL ${mumps_urls}
URL_HASH SHA256=${mumps_sha256}
diff -ruN mumps/cmake/libraries.cmake mumps-ok/cmake/libraries.cmake
--- mumps/cmake/libraries.cmake 2021-10-04 14:31:04.000000000 +0000
+++ mumps-ok/cmake/libraries.cmake 2021-10-08 14:38:20.823214013 +0000
@@ -1,12 +1,13 @@
set(names lapack scalapack)
-file(READ ${CMAKE_CURRENT_LIST_DIR}/libraries.json _libj)
+file(READ ${CMAKE_CURRENT_LIST_DIR}/libraries.json json)
foreach(n ${names})
- foreach(t git tag)
- string(JSON m ERROR_VARIABLE e GET ${_libj} ${n} ${t})
- if(m)
- set(${n}_${t} ${m})
- endif()
+ string(REGEX MATCH "\"${n}\": {([^\}]*)}" _ ${json})
+ string(REGEX MATCHALL "\"[^\"]*\": \"[^\"]*" info_list ${CMAKE_MATCH_1})
+ foreach(info ${info_list})
+ string(REGEX MATCH "\"([^\"]*)\": \"([^\"]*)" INFO_LIST ${info})
+ set(${n}_${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
+ message("${n}_${CMAKE_MATCH_1} ${CMAKE_MATCH_2}")
endforeach()
endforeach()
diff -ruN mumps/cmake/mumps_patch.cmake mumps-ok/cmake/mumps_patch.cmake
--- mumps/cmake/mumps_patch.cmake 2021-10-04 14:31:04.000000000 +0000
+++ mumps-ok/cmake/mumps_patch.cmake 2021-10-08 14:38:20.823214013 +0000
@@ -13,26 +13,22 @@
execute_process(COMMAND ${WSL} wslpath ${mumps_orig}
TIMEOUT 5
OUTPUT_VARIABLE mumps_orig_path
- COMMAND_ERROR_IS_FATAL ANY
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(COMMAND ${WSL} wslpath ${mumps_patch}
TIMEOUT 5
OUTPUT_VARIABLE mumps_patch_path
- COMMAND_ERROR_IS_FATAL ANY
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(COMMAND ${WSL} patch ${mumps_orig_path} ${mumps_patch_path}
TIMEOUT 10
- COMMAND_ERROR_IS_FATAL ANY
)
else()
find_program(PATCH NAMES patch REQUIRED)
execute_process(COMMAND ${PATCH} ${mumps_orig} ${mumps_patch}
TIMEOUT 10
- COMMAND_ERROR_IS_FATAL ANY
)
endif()
......@@ -15,57 +15,6 @@ void mumps_set_options(DMUMPS_STRUC_C *id, int *options, int n){
}
}
DMUMPS_STRUC_C *mumps_new(int n, int nnz, int *row, int *col) {
DMUMPS_STRUC_C *id = malloc(sizeof(DMUMPS_STRUC_C));
int myid, ierr;
ierr = MPI_Init(NULL, NULL);
//ierr = MPI_Comm_rank(MPI_COMM_WORLD, &myid);
/*Initialize a MUMPS instance. Use MPI_COMM_WORLD.*/
id->job=JOB_INIT;
id->par=1;
id->sym=0;
id->comm_fortran=USE_COMM_WORLD;
dmumps_c(id);
/*Define the problem on the host*/
id->n = n;
id->nz = nnz;
id->irn = malloc(nnz*sizeof(int));
memcpy(id->irn, row, sizeof(int)*nnz);
id->jcn = malloc(nnz*sizeof(int));
memcpy(id->jcn, col, sizeof(int)*nnz);
/*No outputs*/
/*id->ICNTL(1)=-1;
id->ICNTL(2)=-1;
id->ICNTL(3)=-1;*/
/* output level */
id->ICNTL(4)=-1;
/* element format */
id->ICNTL(5)=0;
/* permutes the matrix to a zero-free diagonal */
id->ICNTL(6)=2;
/* reordering metis */
id->ICNTL(7)=5;
/* transpose matrix (local matrices c->f) */
id->ICNTL(9)=1;
/* no scaling */
id->ICNTL(8)=0;
/* When significant extra fill-in is caused by numerical pivoting, increasing ICNTL(14) may help */
/* 50 makes all the validation functional */
id->ICNTL(14)=50;
/* num of openmp threads */
id->ICNTL(16)=4;
return id;
}
void mumps_solve(DMUMPS_STRUC_C *id, double *a, double *rhs) {
int init = id->a == NULL;
id->a = a;
id->rhs = rhs;
id->job = (init ? 6 : 5);
dmumps_c(id);
}
DMUMPS_STRUC_C *mumps_element_new(int n, int nelt, int *eltptr, int *eltvar, double *a_elt, double *rhs) {
DMUMPS_STRUC_C *id = malloc(sizeof(DMUMPS_STRUC_C));
int myid, ierr;
......@@ -107,7 +56,7 @@ DMUMPS_STRUC_C *mumps_element_new(int n, int nelt, int *eltptr, int *eltvar, dou
/* 50 makes all the validation functional */
id->ICNTL(14)=50;
/* num of openmp threads */
id->ICNTL(16)=4;
id->ICNTL(16)=0;
return id;
}
......
......@@ -2,6 +2,8 @@ import time
import atexit
import gmsh
import signal
import numpy as np
import ctypes
gmsh.initialize()
gmsh.option.setNumber("General.Terminal",1)
......@@ -10,6 +12,12 @@ signal.signal(signal.SIGINT, signal.SIG_DFL)
timers = {}
def _np2c(a,dtype=float,order="C") :
tmp = np.require(a,dtype,order)
r = ctypes.c_void_p(tmp.ctypes.data)
r.tmp = tmp
return r
def timeit(func):
def wrapper(*args, **kwargs):
self = args[0]
......@@ -50,7 +58,7 @@ except :
def get_linear_system_package(choices=None):
if choices is None:
choices = ["mumps","petsc","scipy"]
choices = ["mumps","petsc","petsc4py","scipy"]
if isinstance(choices, str):
choices = [choices]
for choice in choices:
......
import numpy as np
import time
class CSR :
def __init__(self, idx, rhsidx,constraints):
pairs = np.ndarray([idx.shape[0],idx.shape[1],idx.shape[1]],dtype=([('i0',np.int32),('i1',np.int32)]))
pairs['i0'][:,:,:] = idx[:,:,None]
pairs['i1'][:,:,:] = idx[:,None,:]
pairs = pairs.reshape([-1])
allpairs = [pairs.reshape([-1])]
shift = 2**32
num = np.max(idx)
self.ndof = num+1
idx = idx.astype('uint64')
pairs = (idx[:,:,None]*shift+idx[:,None,:]).flatten()
allpairs = [pairs]
self.constraints = constraints
for c in constraints :
num += 1
pairs = np.ndarray([c.size*2+1],dtype=([('i0',np.int32),('i1',np.int32)]))
pairs['i0'][:c.size] = c
pairs['i1'][:c.size] = num
pairs['i0'][c.size:c.size*2] = num
pairs['i1'][c.size:c.size*2] = c
pairs['i0'][c.size*2] = num
pairs['i1'][c.size*2] = num
pairs = np.ndarray([c.size*2+1],np.uint64)
pairs[:c.size] = c*shift+num
pairs[c.size:c.size*2] = num*shift+c
pairs[c.size*2] = num*shift+num
allpairs.append(pairs)
pairs = np.concatenate(allpairs)
pairs, pmap = np.unique(pairs,return_inverse=True)
......@@ -28,9 +25,9 @@ class CSR :
self.map.append(pmap[count:count+p.size])
count += p.size
self.row = np.hstack([np.array([0],dtype=np.int32),
np.cumsum(np.bincount(pairs["i0"]),
np.cumsum(np.bincount((pairs//shift).astype(np.int32)),
dtype=np.int32)])
self.col = pairs['i1'].copy()
self.col = (pairs%shift).astype(np.int32)
self.size = self.row.size-1
self.rhsidx = rhsidx
......