Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ set(METIS_PATCHES_DIR "${PROJECT_SOURCE_DIR}/metis/metis_patches")
if(NOT DEFINED TPL_ENABLE_METISLIB)
set(TPL_ENABLE_METISLIB ON CACHE BOOL "Enable METIS for SuperLU")
endif()

if(TPL_ENABLE_METISLIB)
if(NOT EXISTS "${GKLIB_DIR}/CMakeLists.txt")
message(FATAL_ERROR "The GKlib submodule was not downloaded.")
endif()

if(NOT EXISTS "${METIS_DIR}/CMakeLists.txt")
message(FATAL_ERROR "The METIS submodule was not downloaded.")
endif()
Expand Down Expand Up @@ -199,6 +201,15 @@ if(USE_SUPERLU_MT)

include_directories("${SUPERLU_MT_DIR}/SRC")
add_subdirectory(${SUPERLU_MT_DIR})

if(TPL_ENABLE_METISLIB)
if(PLAT STREQUAL "_PTHREAD")
add_dependencies(superlu_mt_PTHREAD metis GKlib)
elseif(PLAT STREQUAL "_OPENMP")
add_dependencies(superlu_mt_OPENMP metis GKlib)
endif()
endif()

set(SLU_DRIVER "${SUPERLU_MT_DIR}/SRC/c_fortran_pdgssv.c")
else()
message(STATUS "Will link against regular SuperLU.")
Expand All @@ -212,9 +223,11 @@ else()

include_directories("${SUPERLU_DIR}/SRC")
add_subdirectory(${SUPERLU_DIR})

if(TPL_ENABLE_METISLIB)
add_dependencies(superlu metis GKlib)
endif()

set(SLU_DRIVER "${SUPERLU_DIR}/FORTRAN/c_fortran_dgssv.c")
endif()

Expand Down Expand Up @@ -384,6 +397,10 @@ if(USE_SUPERLU_MT)
endif()

target_compile_definitions(mystran PRIVATE USE_SUPERLU_MT)

if(TPL_ENABLE_METISLIB)
target_compile_definitions(mystran PRIVATE HAVE_METIS)
endif()
else()
target_link_libraries(mystran superlu f2c)
endif()
Expand Down
6 changes: 3 additions & 3 deletions Source/Modules/PARAMS.f90
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,9 @@ MODULE PARAMS
INTEGER(LONG) :: F06_COL_START = 0 ! 1st col in F06 file for output data to begin. If it is not > 2, then
! output will be written with each main header centered on one another

INTEGER(LONG) :: SPIENV6 = 100 ! Memory growth factor for SuperLU_MT -- corresponds to -sp_ienv(6)
INTEGER(LONG) :: SPIENV7 = 100 ! Memory growth factor for SuperLU_MT -- corresponds to -sp_ienv(7)
INTEGER(LONG) :: SPIENV8 = 50 ! Memory growth factor for SuperLU_MT -- corresponds to -sp_ienv(8)
INTEGER(LONG) :: SPIENV6 = 50 ! Memory growth factor for SuperLU_MT -- corresponds to -sp_ienv(6)
INTEGER(LONG) :: SPIENV7 = 50 ! Memory growth factor for SuperLU_MT -- corresponds to -sp_ienv(7)
INTEGER(LONG) :: SPIENV8 = 30 ! Memory growth factor for SuperLU_MT -- corresponds to -sp_ienv(8)

INTEGER(LONG) :: SLU_NTHR = 0 ! Number of threads for SuperLU_MT.
! Using 0 will use as many threads as the system has.
Expand Down
37 changes: 20 additions & 17 deletions metis/metis_patches/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.10)
project(METIS C)
set(CMAKE_C_STANDARD 99)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(SHARED FALSE CACHE BOOL "build a shared library")
Expand All @@ -21,27 +22,28 @@ endif(SHARED)
include(./conf/gkbuild.cmake)

# METIS' custom options
#option(IDX64 "enable 64 bit ints" OFF)
#option(REAL64 "enable 64 bit floats (i.e., double)" OFF)
#if(IDX64)
# set(METIS_COPTIONS "${METIS_COPTIONS} -DIDXTYPEWIDTH=64")
#else()
# set(METIS_COPTIONS "${METIS_COPTIONS} -DIDXTYPEWIDTH=32")
#endif(IDX64)
#if(REAL64)
# set(METIS_COPTIONS "${METIS_COPTIONS} -DREALTYPEWIDTH=64")
#else()
# set(METIS_COPTIONS "${METIS_COPTIONS} -DREALTYPEWIDTH=32")
#endif(REAL64)
#
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${METIS_COPTIONS}")
option(IDX64 "enable 64 bit ints" OFF)
option(REAL64 "enable 64 bit floats (i.e., double)" ON)

if(IDX64)
set(_metis_idxwidth 64)
else()
set(_metis_idxwidth 32)
endif()

if(REAL64)
set(_metis_realwidth 64)
else()
set(_metis_realwidth 32)
endif()

# Generate a metis.h in the build tree that prepends the width defines.
# Read the source header FIRST so an in-source build cannot corrupt the original.
set(METIS_GENERATED_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/include")
file(MAKE_DIRECTORY "${METIS_GENERATED_INCLUDE_DIR}")
file(WRITE "${METIS_GENERATED_INCLUDE_DIR}/metis.h" "#define IDXTYPEWIDTH 32\n#define REALTYPEWIDTH 32\n")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/include/metis.h" METIS_PUBLIC_HEADER)
file(APPEND "${METIS_GENERATED_INCLUDE_DIR}/metis.h" "${METIS_PUBLIC_HEADER}")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/include/metis.h" _metis_public_header)
file(WRITE "${METIS_GENERATED_INCLUDE_DIR}/metis.h"
"#define IDXTYPEWIDTH ${_metis_idxwidth}\n#define REALTYPEWIDTH ${_metis_realwidth}\n${_metis_public_header}")

# Add include directories.
# i.e., the -I equivalent
Expand All @@ -56,6 +58,7 @@ link_directories(${CMAKE_INSTALL_PREFIX}/lib)

# Recursively look for CMakeLists.txt in subdirs.
add_subdirectory("libmetis")

if(METIS_BUILD_PROGRAMS)
add_subdirectory("programs")
endif()
136 changes: 92 additions & 44 deletions superlu_mt_patches/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.13)
cmake_minimum_required(VERSION 3.13)

# Project Version
project(SuperLU_MT C)
Expand All @@ -12,8 +12,8 @@ set(PROJECT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BugFix})
set(USE_XSDK_DEFAULTS TRUE)

# The XSDK standard does not allow using internally built BLAS
if (NOT "${enable_internal_blaslib}" STREQUAL "")
if (USE_XSDK_DEFAULTS)
if(NOT "${enable_internal_blaslib}" STREQUAL "")
if(USE_XSDK_DEFAULTS)
set(enable_blaslib_xSDK OFF)
else()
set(enable_blaslib_xSDK ON)
Expand All @@ -22,8 +22,8 @@ else()
set(enable_blaslib_xSDK ${enable_internal_blaslib})
endif()

if (NOT "${enable_fortran}" STREQUAL "")
if (XSDK_ENABLE_Fortran)
if(NOT "${enable_fortran}" STREQUAL "")
if(XSDK_ENABLE_Fortran)
set(enable_fortran_xSDK ON)
else()
set(enable_fortran_xSDK OFF)
Expand All @@ -32,42 +32,43 @@ else()
set(enable_fortran_xSDK ${enable_fortran})
endif()

set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type")

# set up options
option(enable_internal_blaslib "Build the CBLAS library" ${enable_blaslib_xSDK})
option(enable_single "Enable single precision library" ON)
option(enable_double "Enable double precision library" ON)
option(enable_complex "Enable complex precision library" ON)
option(enable_internal_blaslib "Build the CBLAS library" ${enable_blaslib_xSDK})
option(enable_single "Enable single precision library" ON)
option(enable_double "Enable double precision library" ON)
option(enable_complex "Enable complex precision library" ON)
option(enable_complex16 "Enable complex16 precision library" ON)
option(enable_matlabmex "Build the Matlab mex library" OFF)
option(enable_doc "Add target 'doc' to build Doxygen documentation" OFF)
option(enable_examples "Build examples" ON)
option(enable_fortran "Build Fortran interface" ${enable_fortran_xSDK})
option(enable_tests "Build tests" ON)
option (BUILD_SHARED_LIBS "shared/static" OFF)

include (GNUInstallDirs)
include (CheckLibraryExists)
option(enable_doc "Add target 'doc' to build Doxygen documentation" OFF)
option(enable_examples "Build examples" ON)
option(enable_fortran "Build Fortran interface" ${enable_fortran_xSDK})
option(enable_tests "Build tests" ON)
option(BUILD_SHARED_LIBS "shared/static" OFF)

include(GNUInstallDirs)
include(CheckLibraryExists)
check_library_exists(m sin "" HAVE_LIB_M)

######################################################################
# #####################################################################
#
# Find packages
#
######################################################################
# #####################################################################
#
###find_package (BLAS REQUIRED)
#-- BLAS
option(TPL_ENABLE_INTERNAL_BLASLIB "Build the CBLAS library" ${enable_internal_blaslib})
# ##find_package (BLAS REQUIRED)
# -- BLAS
option(TPL_ENABLE_INTERNAL_BLASLIB "Build the CBLAS library" ${enable_internal_blaslib})
option(TPL_BLAS_LIBRARIES "List of absolute paths to blas libraries [].")

if(NOT enable_internal_blaslib)
if (TPL_BLAS_LIBRARIES)
if(TPL_BLAS_LIBRARIES)
set(BLAS_FOUND TRUE)
else()
find_package(BLAS)
if (BLAS_FOUND)

if(BLAS_FOUND)
set(TPL_BLAS_LIBRARIES "${BLAS_LIBRARIES}" CACHE FILEPATH
"Set from FindBLAS.cmake BLAS_LIBRARIES." FORCE)
endif()
Expand All @@ -78,49 +79,96 @@ if(BLAS_FOUND)
message("-- Using TPL_BLAS_LIBRARIES='${TPL_BLAS_LIBRARIES}'")
set(CMAKE_C_FLAGS "-DUSE_VENDOR_BLAS ${CMAKE_C_FLAGS}")
set(BLAS_LIB ${TPL_BLAS_LIBRARIES})

# fix up BLAS library name
string (REPLACE ";" " " BLAS_LIB_STR "${BLAS_LIB}")
string(REPLACE ";" " " BLAS_LIB_STR "${BLAS_LIB}")
set(BLAS_LIB_EXPORT ${BLAS_LIB_STR})
else()
message("-- Did not find or specify BLAS so configure to build internal CBLAS ...")
add_subdirectory(CBLAS)
set(BLAS_LIB blas)
if (BUILD_SHARED_LIBS) # export to be referenced by downstream makefile
set(BLAS_LIB_EXPORT ${CMAKE_INSTALL_PREFIX}/CBLAS/libblas.so)

if(BUILD_SHARED_LIBS) # export to be referenced by downstream makefile
set(BLAS_LIB_EXPORT ${CMAKE_INSTALL_PREFIX}/CBLAS/libblas.so)
else()
set(BLAS_LIB_EXPORT ${CMAKE_INSTALL_PREFIX}/CBLAS/libblas.a)
set(BLAS_LIB_EXPORT ${CMAKE_INSTALL_PREFIX}/CBLAS/libblas.a)
endif()
endif()

# -- METIS
option(TPL_ENABLE_METISLIB "Build the METIS library" OFF)
option(TPL_METIS_LIBRARIES "List of absolute paths to METIS link libraries [].")
option(TPL_METIS_INCLUDE_DIRS "List of absolute paths to METIS include directories [].")

# --------------------- METIS ---------------------
if(TPL_ENABLE_METISLIB) # # want to use metis
if(NOT TPL_METIS_LIBRARIES)
message(FATAL_ERROR "TPL_METIS_LIBRARIES option should be set for METIS support to be enabled.")
endif()

if(NOT TPL_METIS_INCLUDE_DIRS)
message(FATAL_ERROR "TPL_METIS_INCLUDE_DIRS option be set for METIS support to be enabled.")
endif()

foreach(dir ${TPL_METIS_INCLUDE_DIRS})
if(NOT MINGW AND NOT EXISTS ${dir})
message(FATAL_ERROR "METIS include directory not found: ${dir}")
endif()

set(CMAKE_C_FLAGS "-I${dir} ${CMAKE_C_FLAGS}")
endforeach()

message("-- Enabled support for METIS.")
set(METIS_FOUND TRUE)

set(METIS_LIB ${TPL_METIS_LIBRARIES})

# fix up METIS library names
string(REPLACE ";" " " METIS_LIB_STR "${METIS_LIB}")
set(METIS_LIB_EXPORT ${METIS_LIB_STR})
else()
message("-- Will not link with METIS.")
endif()

if(METIS_FOUND)
set(HAVE_METIS TRUE)

if(TPL_METIS_INCLUDE_DIRS)
include_directories(${TPL_METIS_INCLUDE_DIRS})
endif()
endif()

set(PLAT "_OPENMP" CACHE STRING "threading flavor _PTHREAD/_OPENMP")

set (PLAT "_OPENMP" CACHE STRING "threading flavor _PTHREAD/_OPENMP")
if (PLAT STREQUAL "_PTHREAD")
find_package (Threads REQUIRED)
elseif (PLAT STREQUAL "_OPENMP")
find_package (OpenMP REQUIRED)
else ()
message (SEND_ERROR "invalid PLAT setting")
endif ()
if(PLAT STREQUAL "_PTHREAD")
find_package(Threads REQUIRED)
elseif(PLAT STREQUAL "_OPENMP")
find_package(OpenMP REQUIRED)
else()
message(SEND_ERROR "invalid PLAT setting")
endif()

option (LONGINT "use 64-bit integers for indexing sparse matrices (default is 32-bit)" OFF)
option(LONGINT "use 64-bit integers for indexing sparse matrices (default is 32-bit)" OFF)

enable_language(C)
if (enable_fortran)

if(enable_fortran)
enable_language(Fortran)
endif()
set(SUPERLU_MT_VERSION "${PROJECT_VERSION}")

set(SUPERLU_MT_VERSION "${PROJECT_VERSION}")

set (SUPERLUMT_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/superlu_mt CACHE STRING "include dir")
set(SUPERLUMT_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/superlu_mt CACHE STRING "include dir")

add_subdirectory(SRC)

# add_subdirectory(EXAMPLE)

# if(enable_tests)
# enable_testing()
# add_subdirectory(TESTING)
# enable_testing()
# add_subdirectory(TESTING)
# endif()

# if (enable_doc)
# add_subdirectory(DOC)
# add_subdirectory(DOC)
# endif()
37 changes: 37 additions & 0 deletions superlu_mt_patches/SRC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

file(GLOB sources "*.c")
add_library(superlu_mt${PLAT} ${sources})
set_target_properties(superlu_mt${PLAT} PROPERTIES POSITION_INDEPENDENT_CODE ON)

set_property(TARGET superlu_mt${PLAT} PROPERTY C_STANDARD 99)

if(HAVE_LIB_M)
target_link_libraries(superlu_mt${PLAT} PRIVATE m)
endif()

target_link_libraries(superlu_mt${PLAT} PRIVATE ${BLAS_LIB})
target_compile_definitions(superlu_mt${PLAT} PRIVATE Add_)

if(PLAT STREQUAL "_PTHREAD")
target_compile_definitions(superlu_mt${PLAT} PUBLIC __PTHREAD)
target_link_libraries(superlu_mt${PLAT} PRIVATE ${CMAKE_THREAD_LIBS_INIT})
elseif(PLAT STREQUAL "_OPENMP")
target_compile_definitions(superlu_mt${PLAT} PUBLIC __OPENMP)
target_link_libraries(superlu_mt${PLAT} PRIVATE OpenMP::OpenMP_C)
endif()

if(LONGINT)
target_compile_definitions(superlu_mt${PLAT} PUBLIC _LONGINT)
endif()

if(HAVE_METIS)
target_compile_definitions(superlu_mt${PLAT} PRIVATE HAVE_METIS)
target_link_libraries(superlu_mt${PLAT} PRIVATE ${METIS_LIB})
endif()

target_include_directories(superlu_mt${PLAT} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(superlu_mt${PLAT} INTERFACE $<INSTALL_INTERFACE:include>)
install(TARGETS superlu_mt${PLAT} DESTINATION ${CMAKE_INSTALL_LIBDIR})

file(GLOB headers "*.h")
install(FILES ${headers} DESTINATION ${SUPERLUMT_INSTALL_INCLUDEDIR})
Loading
Loading