Skip to content

Commit 21d673c

Browse files
author
Jack Poulson
committed
Removing submodules and switching METIS to ExternalProject_Add
1 parent 61087b9 commit 21d673c

File tree

8 files changed

+260
-122
lines changed

8 files changed

+260
-122
lines changed

.gitmodules

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +0,0 @@
1-
[submodule "external/blis"]
2-
path = external/blis
3-
url = https://github.com/flame/blis.git
4-
[submodule "external/OpenBLAS"]
5-
path = external/OpenBLAS
6-
url = https://github.com/xianyi/OpenBLAS.git
7-
[submodule "external/metis"]
8-
path = external/metis
9-
url = https://github.com/poulson/metis.git
10-
[submodule "external/kiss_fft"]
11-
path = external/kiss_fft
12-
url = https://github.com/poulson/kiss_fft.git

CMakeLists.txt

Lines changed: 13 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ endif()
7575
# and is often necessary anyway.
7676
option(EL_USE_QT5 "Attempt to use Qt5?" OFF)
7777

78-
# NOTE: This is not yet used within Elemental...
79-
#
80-
# If BUILD_KISSFFT is set to 'OFF', then an external KISSFFT can be
81-
# built by defining:
82-
# KISSFFT_INCLUDE_DIR: The directory containing kiss_fft.h
83-
# KISSFFT_LIBS: The list of KISS-FFT libraries to link
84-
option(BUILD_KISSFFT "Build KISS FFT" OFF)
85-
8678
option(EL_EXAMPLES "Build simple examples?" OFF)
8779
option(EL_TESTS "Build performance and correctness tests?" OFF)
8880
option(EL_EXPERIMENTAL "Build experimental code" OFF)
@@ -101,34 +93,15 @@ endif()
10193
option(EL_USE_CUSTOM_ALLTOALLV "Avoid MPI_Alltoallv for performance reasons" ON)
10294
option(EL_BARRIER_IN_ALLTOALLV "Barrier before posting non-blocking recvs" OFF)
10395

104-
# If the version of METIS packaged with Elemental is to be built (the default),
105-
# then no METIS-specific variables need to be specified, but if the user prefers
106-
# to use their own version, then the root path of the installation should be
107-
# passed in via the METIS_ROOT variable.
108-
option(BUILD_METIS "Build METIS" ON)
109-
110-
# ParMETIS cannot yet be legally distributed under an unrestrictive
111-
# license and is currently limited to educational and research purposes.
112-
# (recent versions of METIS can be distributed under the Apache License
113-
# Version 2).
114-
#
115-
# However, if the user is in an educational or government institution, then
116-
# it is possible to re-enable support for ParMETIS by specifying the following
117-
# variables:
118-
#
119-
# METIS_ROOT: the full path to the root of the MeTiS source tree
120-
# PARMETIS_ROOT: the full path to the root of the ParMeTiS source tree
121-
# PARMETIS_LIBS: the list of ParMETIS libraries to link to
122-
# PARMETIS_TLS_PATCH: defined iff there is a GKlib configure file
123-
# (if you have not heard of this, ignore it)
124-
# GKLIB_INCLUDE_DIR: if PARMETIS_TLS_PATCH is defined, this should point
125-
# to the directory containing gklib_tls.h
126-
#
127-
# and adding in a custom ParMETIS routine for performing nodal bisections
128-
# in parallel (which was originally part of Clique and can be easily found).
129-
# Please contact [email protected] or [email protected] for more details.
96+
# By default, a search is performed for METIS via find_package, and, if this
97+
# search fails, METIS is cloned from the git repo
98+
# https://github.com/poulson/Metis.git.
99+
# If BUILD_METIS is turned on, then no initial call to find_package is
100+
# performed.
130101
#
131-
#option(BUILD_PARMETIS "Build ParMETIS" OFF)
102+
# Should you want to manually specify a METIS installation, you can set the
103+
# variables METIS_INCLUDE_DIRS and METIS_LIBRARIES
104+
option(BUILD_METIS "Build METIS" OFF)
132105

133106
# Advanced options
134107
# ----------------
@@ -253,62 +226,8 @@ if(NOT WIN32)
253226
endforeach()
254227
endif()
255228

256-
if(BUILD_PARMETIS)
257-
message(FATAL_ERROR "ParMETIS cannot be legally distributed with Elemental under a permissive license. A version of Elemental restricted to educational purposes which contains ParMETIS will hopefully soon be available.")
258-
# add_subdirectory(external/parmetis)
259-
# set(EL_HAVE_METIS TRUE)
260-
# set(EL_HAVE_PARMETIS TRUE)
261-
#
262-
# set(PARMETIS_ROOT ${PROJECT_SOURCE_DIR}/external/parmetis)
263-
# set(METIS_ROOT ${PROJECT_SOURCE_DIR}/external/parmetis/metis)
264-
# set(GKLIB_INCLUDE_DIR ${PROJECT_BINARY_DIR}/external/parmetis/include)
265-
#
266-
# include_directories(${GKLIB_INCLUDE_DIR})
267-
# include_directories(${METIS_ROOT}/include)
268-
# include_directories(${PARMETIS_ROOT}/include)
269-
elseif(METIS_ROOT AND PARMETIS_ROOT)
270-
message(FATAL_ERROR "ParMETIS cannot be legally distributed with Elemental under a permissive license. A version of Elemental restricted to educational purposes which contains ParMETIS will hopefully soon be available.")
271-
# set(EL_HAVE_METIS TRUE)
272-
# set(EL_HAVE_PARMETIS TRUE)
273-
# if(PARMETIS_TLS_PATCH)
274-
# include_directories(${GKLIB_INCLUDE_DIR})
275-
# endif()
276-
#
277-
# include_directories(${METIS_ROOT}/include)
278-
# include_directories(${PARMETIS_ROOT}/include)
279-
# set(MANUAL_PARMETIS TRUE)
280-
elseif(BUILD_METIS)
281-
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/external/metis/CMakeLists.txt")
282-
message(FATAL_ERROR
283-
"${CMAKE_SOURCE_DIR}/external/metis is not correctly set up. If you are building from source, make sure all git submodules in the source directory are checked out, e.g. with\ncd ${CMAKE_SOURCE_DIR} && git submodule update --recursive --init")
284-
endif()
285-
add_subdirectory(external/metis)
286-
set(METIS_ROOT ${PROJECT_SOURCE_DIR}/external/metis)
287-
include_directories(${METIS_ROOT}/include)
288-
289-
set(EL_HAVE_METIS TRUE)
290-
else()
291-
if(NOT METIS_ROOT)
292-
message(FATAL_ERROR
293-
"If METIS is not to be built, then METIS_ROOT must be specified")
294-
endif()
295-
include_directories(${METIS_ROOT}/include)
296-
297-
set(EL_HAVE_METIS TRUE)
298-
set(MANUAL_METIS TRUE)
299-
endif()
300-
301-
if(BUILD_KISSFFT)
302-
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/external/kiss_fft/CMakeLists.txt")
303-
message(FATAL_ERROR
304-
"${CMAKE_SOURCE_DIR}/external/kiss_fft is not correctly set up. If you are building from source, make sure all git submodules in the source directory are checked out, e.g. with\ncd ${CMAKE_SOURCE_DIR} && git pull --recurse-submodules")
305-
endif()
306-
add_subdirectory(external/kiss_fft)
307-
include_directories(external/kiss_fft)
308-
elseif(KISSFFT_INCLUDE_DIR AND KISSFFT_LIBS)
309-
include_directories(${KISSFFT_INCLUDE_DIR})
310-
set(MANUAL_KISSFFT TRUE)
311-
endif()
229+
add_custom_target(External)
230+
include(metis)
312231

313232
if(BUILD_SHARED_LIBS AND WIN32)
314233
option(EL_DECLSPEC "Use __declspec(dllexport)?" ON)
@@ -414,23 +333,11 @@ if(EL_HAVE_QT5)
414333
set(LINK_LIBS ${LINK_LIBS} ${Qt5Widgets_LIBRARIES})
415334
endif()
416335

417-
if(BUILD_KISSFFT)
418-
set(LINK_LIBS ${LINK_LIBS} kiss_fft)
419-
elseif(MANUAL_KISSFFT)
420-
set(LINK_LIBS ${LINK_LIBS} ${KISSFFT_LIBS})
421-
endif()
422-
423-
if(BUILD_PARMETIS)
424-
set(LINK_LIBS ${LINK_LIBS} parmetis)
425-
elseif(MANUAL_PARMETIS)
426-
set(LINK_LIBS ${LINK_LIBS} ${PARMETIS_LIBS})
427-
elseif(BUILD_METIS)
428-
set(LINK_LIBS ${LINK_LIBS} metis)
429-
elseif(MANUAL_METIS)
430-
set(LINK_LIBS ${LINK_LIBS} ${METIS_LIBS})
431-
endif()
336+
# TODO: ParMETIS support
337+
set(LINK_LIBS ${LINK_LIBS} ${EXTERNAL_LIBS})
432338

433339
add_library(El ${EL_C_CPP_FILES})
340+
add_dependencies(El External)
434341
target_link_libraries(El pmrrr ${LINK_LIBS})
435342
if(MPI_LINK_FLAGS)
436343
set_target_properties(El PROPERTIES LINK_FLAGS ${MPI_LINK_FLAGS})

external/OpenBLAS

Lines changed: 0 additions & 1 deletion
This file was deleted.

external/blis

Lines changed: 0 additions & 1 deletion
This file was deleted.

external/cmake/FindMETIS.cmake

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# -*- mode: cmake -*-
2+
3+
#
4+
# METIS Find Module
5+
# Shamelessly stolen from Amanzi open source code https://software.lanl.gov/ascem/trac by way of MSTK
6+
#
7+
# Usage:
8+
# Control the search through METIS_DIR or setting environment variable
9+
# METIS_ROOT to the METIS installation prefix.
10+
#
11+
# This module does not search default paths!
12+
#
13+
# Following variables are set:
14+
# METIS_FOUND (BOOL) Flag indicating if METIS was found
15+
# METIS_INCLUDE_DIR (PATH) Path to the METIS include file
16+
# METIS_INCLUDE_DIRS (LIST) List of all required include files
17+
# METIS_LIBRARY_DIR (PATH) Path to the METIS library
18+
# METIS_LIBRARY (FILE) METIS library
19+
# METIS_LIBRARIES (LIST) List of all required METIS libraries
20+
#
21+
# #############################################################################
22+
23+
# Standard CMake modules see CMAKE_ROOT/Modules
24+
include(FindPackageHandleStandardArgs)
25+
26+
if ( METIS_LIBRARIES AND METIS_INCLUDE_DIRS )
27+
28+
# Do nothing. Variables are set. No need to search again
29+
30+
else(METIS_LIBRARIES AND METIS_INCLUDE_DIRS)
31+
32+
# Cache variables
33+
if(METIS_DIR)
34+
set(METIS_DIR "${METIS_DIR}" CACHE PATH "Path to search for METIS include and library files")
35+
endif()
36+
37+
if(METIS_INCLUDE_DIR)
38+
set(METIS_INCLUDE_DIR "${METIS_INCLUDE_DIR}" CACHE PATH "Path to search for METIS include files")
39+
endif()
40+
41+
if(METIS_LIBRARY_DIR)
42+
set(METIS_LIBRARY_DIR "${METIS_LIBRARY_DIR}" CACHE PATH "Path to search for METIS library files")
43+
endif()
44+
45+
46+
# Search for include files
47+
# Search order preference:
48+
# (1) METIS_INCLUDE_DIR - check existence of path AND if the include files exist
49+
# (2) METIS_DIR/<include>
50+
# (3) Default CMake paths See cmake --html-help=out.html file for more information.
51+
#
52+
set(metis_inc_names "metis.h")
53+
if (METIS_INCLUDE_DIR)
54+
55+
if (EXISTS "${METIS_INCLUDE_DIR}")
56+
57+
find_path(metis_test_include_path
58+
NAMES ${metis_inc_names}
59+
HINTS ${METIS_INCLUDE_DIR}
60+
NO_DEFAULT_PATH)
61+
if(NOT metis_test_include_path)
62+
message(SEND_ERROR "Can not locate ${metis_inc_names} in ${METIS_INCLUDE_DIR}")
63+
endif()
64+
set(METIS_INCLUDE_DIR "${metis_test_include_path}")
65+
66+
else()
67+
message(SEND_ERROR "METIS_INCLUDE_DIR=${METIS_INCLUDE_DIR} does not exist")
68+
set(METIS_INCLUDE_DIR "METIS_INCLUDE_DIR-NOTFOUND")
69+
endif()
70+
71+
else()
72+
73+
# Metis sometimes puts the include files in a subdir called Lib
74+
75+
set(metis_inc_suffixes "include" "Lib")
76+
if(METIS_DIR)
77+
78+
if (EXISTS "${METIS_DIR}" )
79+
80+
find_path(METIS_INCLUDE_DIR
81+
NAMES ${metis_inc_names}
82+
HINTS ${METIS_DIR}
83+
PATH_SUFFIXES ${metis_inc_suffixes}
84+
NO_DEFAULT_PATH)
85+
86+
else()
87+
message(SEND_ERROR "METIS_DIR=${METIS_DIR} does not exist")
88+
set(METIS_INCLUDE_DIR "METIS_INCLUDE_DIR-NOTFOUND")
89+
endif()
90+
91+
92+
else()
93+
94+
find_path(METIS_INCLUDE_DIR
95+
NAMES ${metis_inc_names}
96+
PATH_SUFFIXES ${metis_inc_suffixes})
97+
98+
endif()
99+
100+
endif()
101+
102+
if ( NOT METIS_INCLUDE_DIR )
103+
message(SEND_ERROR "Can not locate METIS include directory")
104+
endif()
105+
106+
# Search for libraries
107+
# Search order preference:
108+
# (1) METIS_LIBRARY_DIR - check existence of path AND if the library file exists
109+
# (2) METIS_DIR/<lib,Lib>
110+
# (3) Default CMake paths See cmake --html-help=out.html file for more information.
111+
#
112+
set(metis_lib_names "metis")
113+
if (METIS_LIBRARY_DIR)
114+
115+
if (EXISTS "${METIS_LIBRARY_DIR}")
116+
117+
find_library(METIS_LIBRARY
118+
NAMES ${metis_lib_names}
119+
HINTS ${METIS_LIBRARY_DIR}
120+
NO_DEFAULT_PATH)
121+
else()
122+
message(SEND_ERROR "METIS_LIBRARY_DIR=${METIS_LIBRARY_DIR} does not exist")
123+
set(METIS_LIBRARY "METIS_LIBRARY-NOTFOUND")
124+
endif()
125+
126+
else()
127+
128+
list(APPEND metis_lib_suffixes "lib" "Lib")
129+
if(METIS_DIR)
130+
131+
if (EXISTS "${METIS_DIR}" )
132+
133+
find_library(METIS_LIBRARY
134+
NAMES ${metis_lib_names}
135+
HINTS ${METIS_DIR}
136+
PATH_SUFFIXES ${metis_lib_suffixes}
137+
NO_DEFAULT_PATH)
138+
139+
else()
140+
message(SEND_ERROR "METIS_DIR=${METIS_DIR} does not exist")
141+
set(METISLIBRARY "METIS_LIBRARY-NOTFOUND")
142+
endif()
143+
144+
145+
else()
146+
147+
find_library(METIS_LIBRARY
148+
NAMES ${metis_lib_names}
149+
PATH_SUFFIXES ${metis_lib_suffixes})
150+
151+
endif()
152+
153+
endif()
154+
155+
if ( NOT METIS_LIBRARY )
156+
message(SEND_ERROR "Can not locate METIS library")
157+
endif()
158+
159+
160+
# Define prerequisite packages
161+
set(METIS_INCLUDE_DIRS ${METIS_INCLUDE_DIR})
162+
set(METIS_LIBRARIES ${METIS_LIBRARY})
163+
164+
165+
endif(METIS_LIBRARIES AND METIS_INCLUDE_DIRS )
166+
167+
# Send useful message if everything is found
168+
find_package_handle_standard_args(METIS DEFAULT_MSG
169+
METIS_LIBRARIES
170+
METIS_INCLUDE_DIRS)
171+
172+
# find_package_handle_standard_args should set METIS_FOUND but it does not!
173+
if ( METIS_LIBRARIES AND METIS_INCLUDE_DIRS)
174+
set(METIS_FOUND TRUE)
175+
else()
176+
set(METIS_FOUND FALSE)
177+
endif()
178+
179+
# Define the version
180+
181+
mark_as_advanced(
182+
METIS_INCLUDE_DIR
183+
METIS_INCLUDE_DIRS
184+
METIS_LIBRARY
185+
METIS_LIBRARIES
186+
METIS_LIBRARY_DIR
187+
)

0 commit comments

Comments
 (0)