Skip to content

Commit

Permalink
Added PMRRR into the CMake automated build system.
Browse files Browse the repository at this point in the history
  • Loading branch information
poulson committed Dec 1, 2010
1 parent 784e826 commit 5915582
Show file tree
Hide file tree
Showing 86 changed files with 17,627 additions and 32 deletions.
13 changes: 10 additions & 3 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
Authors of Elemental

Jack Poulson <jack.poulson@gmail.com>:
The entire library, with the exception of basing the safe inversion portion of
the files ColReflector.cpp, RowReflector.cpp, and Reflector.cpp on the LAPACK
source for real and complex Householder reflectors, dlarfg.f and zlarfg.f.
The entire library, with the following exceptions:
1) Elemental now optionally builds and links the PMRRR library located in
the contrib/ folder. PMRRR was written by Matthias Petschow and Paolo
Bientinesi.
2) The safe inversion portion of the files ColReflector.cpp, RowReflector.cpp,
and Reflector.cpp were partially based on the LAPACK source for real and
complex Householder reflectors, dlarfg.f and zlarfg.f.

Matthias Petschow and Paolo Bientinesi:
The PMRRR library for hybrid symmetric tridiagonal eigensolutions.

Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.:
The serial code for the safe inversion process during the calculation of
Expand Down
72 changes: 47 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ option(BUILD_HYBRID "Build a hybrid OpenMP/MPI version of Elemental" OFF)
option(BUILD_DEBUG "Build a version with many consistency checks" OFF)
option(BUILD_RELEASE "Build the release (optimized) version of Elemental" ON)
option(BUILD_TESTS "Build a collection of test executables" ON)
option(LINK_PMRRR "Link against the eigensolver PMRRR" ON)
option(BUILD_PMRRR "Build and link against eigensolver PMRRR" ON)

option(WITHOUT_COMPLEX "Avoid all usage of complex numbers" OFF)
if(NOT WITHOUT_COMPLEX)
Expand All @@ -56,6 +56,8 @@ option(CACHE_WARNINGS "Warns when using cache-unfriendly routines" OFF)
option(UNALIGNED_WARNINGS "Warn when performing unaligned redistributions" OFF)
option(VECTOR_WARNINGS "Warn when vector redistribution chances are missed" OFF)
option(ENABLE_ALL_DISTRIBUTED_DOT "Build every parallel dot product." OFF)
MARK_AS_ADVANCED(AVOID_COMPLEX_MPI TIMING CACHE_WARNINGS UNALIGNED_WARNINGS
VECTOR_WARNINGS ENABLE_ALL_DISTRIBUTED_DOT)

if(BUILD_PURE AND BUILD_DEBUG)
set(CXX_PURE_DEBUG_FLAGS "-O2 -g" CACHE STRING
Expand All @@ -74,23 +76,38 @@ if(BUILD_HYBRID AND BUILD_RELEASE)
"CXX optimization flags for hybrid OpenMP/MPI release build")
endif(BUILD_HYBRID AND BUILD_RELEASE)

if(MPI_CXX_COMPILER AND NOT EXISTS ${MPI_CXX_COMPILER})
message(FATAL_ERROR
"Invalid MPI_CXX_COMPILER: ${MPI_CXX_COMPILER} does not exist.")
endif(MPI_CXX_COMPILER AND NOT EXISTS ${MPI_CXX_COMPILER})
if(NOT MPI_CXX_COMPILER)
find_package(MPI)
set(MPI_CXX_DESC "Full path to MPI CXX compiler. If blank, CMake will search for it.")
set(MPI_CXX_DESC
"Full path to MPI CXX compiler. If blank, CMake will search for it.")
if(NOT MPI_FOUND)
set(MPI_CXX_COMPILER "" CACHE STRING ${MPI_CXX_MSG})
message(FATAL_ERROR "Could not find MPI CXX compiler. Please manually set MPI_CXX_COMPILER")
# Try a manual search for the common MPI names
find_program(MPI_COMPILER mpicxx mpic++ mpixlC mpixlC_r
DOC "Full path to MPI CXX compiler")
if(NOT MPI_COMPILER)
set(MPI_CXX_COMPILER "" CACHE STRING ${MPI_CXX_MSG})
message(FATAL_ERROR
"Could not find MPI CXX compiler. Please manually set MPI_CXX_COMPILER")
endif(NOT MPI_COMPILER)
endif(NOT MPI_FOUND)
# Regrettably, 'find_package(MPI)' does not qualify the compiler as CXX
set(MPI_CXX_COMPILER ${MPI_COMPILER} CACHE STRING ${MPI_CXX_DESC})
endif(NOT MPI_CXX_COMPILER)
set(CMAKE_CXX_COMPILER ${MPI_CXX_COMPILER})

if(BUILD_HYBRID)
find_package(OpenMP)
if(NOT OpenMP_FOUND)
message("Hybrid build disabled because OpenMP support was not found")
endif(NOT OpenMP_FOUND)
if(NOT MANUAL_OPENMP_CXX_FLAGS)
find_package(OpenMP)
if(NOT OpenMP_FOUND)
set(MANUAL_OPENMP_CXX_FLAGS "" CACHE STRING "OpenMP CXX FLAGS")
message("Hybrid build disabled because OpenMP support was not verified.")
message("You can alternatively manually specify OpenMP_CXX_FLAGS.")
endif(NOT OpenMP_FOUND)
endif(NOT MANUAL_OPENMP_CXX_FLAGS)
endif(BUILD_HYBRID)

# A simple extension of find_library from a single lib to a list of libs
Expand All @@ -104,6 +121,10 @@ macro(find_library_list FOUND_LIST SEARCH_LIST PATH PATH_SUFFIX)
if(FOUND_${LIB})
list(APPEND ${FOUND_LIST} ${FOUND_${LIB}})
endif(FOUND_${LIB})
# On some machines, all of the above FOUND_${LIB} variables show up in
# the CMake wizard's cache. This is annoying, so we should explicitly
# remove them by forcing them to be internal.
set(FOUND_${LIB} CACHE INTERNAL "")
endforeach(LIB)
# If FOUND_LIST is not the same length as SEARCH_LIST, then empty it so that
# it is easy to check whether or not all of the libraries were found.
Expand All @@ -124,6 +145,13 @@ endif(${CMAKE_SIZEOF_VOID_P} MATCHES 4)

# Since the CMake find_blas for some reason requires a Fortran compiler, we
# must build our own.
if(BLAS_LAPACK_LIBS)
foreach(LIB ${BLAS_LAPACK_LIBS})
if(NOT EXISTS ${LIB})
message(FATAL_ERROR "Invalid BLAS_LAPACK_LIBS: ${LIB} does not exist.")
endif(NOT EXISTS ${LIB})
endforeach(LIB)
endif(BLAS_LAPACK_LIBS)
if(NOT BLAS_LAPACK_LIBS)
set(BLAS_LAPACK_DESC "BLAS/LAPACK link flags")
if(APPLE)
Expand Down Expand Up @@ -234,28 +262,22 @@ if(NOT HAVE_DPOTRF)
endif(HAVE_DPOTRF_PRE)
endif(NOT HAVE_DPOTRF)

# Search for PMRRR
if(LINK_PMRRR)
find_library(PMRRR_LIB pmrrr
DOC "Parallel Multiple Relatively Robust Representations (PMRRR) library")
if(NOT PMRRR_LIB)
set(CXX_BASE_FLAGS "${CXX_BASE_FLAGS} -DWITHOUT_PMRRR")
message("Could not find PMRRR; Elemental will not have eigensolvers.")
endif(NOT PMRRR_LIB)
endif(LINK_PMRRR)
if(BUILD_PMRRR)
add_subdirectory(contrib/PMRRR-0.6)
endif(BUILD_PMRRR)

# Grab all of the .cpp and .hpp Elemental files
file(GLOB_RECURSE ELEMENTAL_CPP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"src/*.cpp")
file(GLOB_RECURSE ELEMENTAL_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"include/*.hpp")
if(NOT LINK_PMRRR OR NOT PMRRR_LIB)
if(NOT BUILD_PMRRR)
# It might be cleaner to force these to be empty through the preprocessor
list(REMOVE_ITEM ELEMENTAL_CPP
"src/lapack/HermitianEig/HermitianEig.cpp")
list(REMOVE_ITEM ELEMENTAL_CPP
"src/lapack/GeneralizedHermitianEig/GeneralizedHermitianEig.cpp")
endif(NOT LINK_PMRRR OR NOT PMRRR_LIB)
endif(NOT BUILD_PMRRR)
set(ELEMENTAL_SRC "${ELEMENTAL_CPP};${ELEMENTAL_HEADERS}")

# Create the lists of test executables
Expand All @@ -264,18 +286,18 @@ if(BUILD_TESTS)
set(CORE_TESTS DistMatrix Matrix)
set(BLAS_TESTS Gemm Hemm Her2k Herk Symm Symv Syr2k Syrk Trmm Trsm)
set(LAPACK_TESTS Chol Hegst LU QR Tridiag Trinv UT)
if(LINK_PMRRR AND PMRRR_LIB)
if(BUILD_PMRRR)
list(APPEND LAPACK_TESTS GeneralizedHermitianEig)
list(APPEND LAPACK_TESTS HermitianEig)
endif(LINK_PMRRR AND PMRRR_LIB)
endif(BUILD_PMRRR)
endif(BUILD_TESTS)

# Set up the include directories and the required libraries
include_directories("${PROJECT_SOURCE_DIR}/include")
set(ELEMENTAL_REQUIRED_LIBS ${BLAS_LAPACK_LIBS})
if(LINK_PMRRR AND PMRRR_LIB)
list(APPEND ELEMENTAL_REQUIRED_LIBS ${PMRRR_LIB})
endif(LINK_PMRRR AND PMRRR_LIB)
if(BUILD_PMRRR)
list(APPEND ELEMENTAL_REQUIRED_LIBS pmrrr)
endif(BUILD_PMRRR)

# Build the pure-debug version (if necessary)
if(BUILD_PURE AND BUILD_DEBUG)
Expand All @@ -296,7 +318,7 @@ if(BUILD_PURE AND BUILD_DEBUG)
endforeach(TEST)
# Build the blas tests
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin/pure/debug/blas)
foreach(TEST ${BLASE_TESTS})
foreach(TEST ${BLAS_TESTS})
add_executable(pure-debug-blas-${TEST} ${TEST_DIR}/blas/${TEST}.cpp)
target_link_libraries(pure-debug-blas-${TEST}
pure-debug ${ELEMENTAL_REQUIRED_LIBS})
Expand Down
90 changes: 90 additions & 0 deletions contrib/PMRRR-0.6/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#
# Copyright (c) 2009-2010, Jack Poulson
# All rights reserved.
#
# This file is part of Elemental.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# - Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# - Neither the name of the owner nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
cmake_minimum_required(VERSION 2.6)
enable_language(Fortran)

if(CMAKE_BUILD_TYPE)
message("PMRRR does not use CMAKE_BUILD_TYPE.")
endif(CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "" CACHE INTERNAL "Removing GUI option" FORCE)

option(HAVE_SPINLOCKS "Enable if pthread lib supports spinlocks" OFF)
option(INCLUDE_LAPACK "Enable if PMRRR should build LAPACK dependencies" ON)
MARK_AS_ADVANCED(HAVE_SPINLOCKS INCLUDE_LAPACK)

set(CXX_BASE_FLAGS "")
if(NOT HAVE_SPINLOCKS)
set(CXX_BASE_FLAGS "${CXX_BASE_FLAGS} -DNOSPINLOCKS")
endif(NOT HAVE_SPINLOCKS)

# Grab all of the .c and .h files
file(GLOB_RECURSE PMRRR_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c")
file(GLOB_RECURSE PMRRR_H RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
if(INCLUDE_LAPACK)
file(GLOB_RECURSE PMRRR_F RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.f")
else(INCLUDE_LAPACK)
set(PMRRR_F "SRC/LAPACK/SEQUENTIAL/odscal.f")
endif(INCLUDE_LAPACK)
set(PMRRR_SRC "${PMRRR_C};${PMRRR_H};${PMRRR_F}")

# Search for the MPI CXX and F77 compilers
if(MPI_C_COMPILER AND NOT EXISTS ${MPI_C_COMPILER})
message(FATAL_ERROR
"Invalid MPI_C_COMPILER: ${MPI_C_COMPILER} does not exist.")
endif(MPI_C_COMPILER AND NOT EXISTS ${MPI_C_COMPILER})
if(MPI_F77_COMPILER AND NOT EXISTS ${MPI_F77_COMPILER})
message(FATAL_ERROR
"Invalid MPI_F77_COMPILER: ${MPI_F77_COMPILER} does not exist.")
endif(MPI_F77_COMPILER AND NOT EXISTS ${MPI_F77_COMPILER})
if(NOT MPI_C_COMPILER)
find_program(MPI_C_COMPILER mpicc mpixlc mpixlc_r
DOC "Full path to MPI C compiler. If blank, CMake will search for it.")
if(NOT MPI_C_COMPILER)
message(FATAL_ERROR
"Could not find MPI C compiler. Please manually set MPI_C_COMPILER.")
endif(NOT MPI_C_COMPILER)
endif(NOT MPI_C_COMPILER)
if(NOT MPI_F77_COMPILER)
find_program(MPI_F77_COMPILER mpif77 mpixlf77 mpixlf77_r
DOC "Full path to MPI F77 compiler. If blank, CMake will search for it.")
if(NOT MPI_F77_COMPILER)
message(FATAL_ERROR
"Could not find MPI F77 compiler. Please manually set MPI_F77_COMPILER.")
endif(NOT MPI_F77_COMPILER)
endif(NOT MPI_F77_COMPILER)
set(CMAKE_C_COMPILER ${MPI_C_COMPILER})
set(CMAKE_Fortran_Compiler ${MPI_F77_COMPILER})

include_directories("${CMAKE_CURRENT_SOURCE_DIR}/INCLUDE")
add_library(pmrrr STATIC ${PMRRR_SRC})

52 changes: 52 additions & 0 deletions contrib/PMRRR-0.6/EXAMPLES/C/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
CC = mpicc
LD = mpicc

CFLAGS = -Wall -g -pthread
LDFLAGS = -D_THREAD_SAFE=1 -pthread

# Additional compiler flags for MPI Implementation
# Most MPI Implementations do not require additional
# flags, but e.g. Intel's MPI requieres
# the flag '-mt_mpi' to link to a MPI supporting
# multithreading
MPIFLAGS =

INCPATH = ../../INCLUDE
LIBPATH = ../../LIB
LIBS = pmrrr gfortran m pthread rt


######################## do not edit below ###########################


CFLAGS += $(MPIFLAGS) -I$(INCPATH)
LDFLAGS += $(MPIFLAGS) -I$(INCPATH)

.PHONY: all

all: main_all.x main_ind.x main_val.x

# All eigenpairs
main_all.x: main_all.o
$(LD) $(LDFLAGS) $< $(foreach LIBP,$(LIBPATH),-L$(LIBP)) \
$(foreach LIBRARY,$(LIBS),-l$(LIBRARY)) -o $@

main_all.o: main_all.c

# Subset of eigenpairs by index
main_ind.x: main_ind.o
$(LD) $(LDFLAGS) $< $(foreach LIBP,$(LIBPATH),-L$(LIBP)) \
$(foreach LIBRARY,$(LIBS),-l$(LIBRARY)) -o $@

main_ind.o: main_ind.c

# Subset of eigenpairs by value
main_val.x: main_val.o
$(LD) $(LDFLAGS) $< $(foreach LIBP,$(LIBPATH),-L$(LIBP)) \
$(foreach LIBRARY,$(LIBS),-l$(LIBRARY)) -o $@

main_val.o: main_val.c

.PHONY: clean
clean:
rm -f main_*.x core.* *__genmod.* *.o *~
52 changes: 52 additions & 0 deletions contrib/PMRRR-0.6/EXAMPLES/C/Makefile.gnu.jugene
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
CC = mpicc
LD = mpicc

CFLAGS = -Wall -g -pthread
LDFLAGS = -D_THREAD_SAFE=1 -pthread

# Additional compiler flags for MPI Implementation
# Most MPI Implementations do not require additional
# flags, but e.g. Intel's MPI requieres
# the flag '-mt_mpi' to link to a MPI supporting
# multithreading
MPIFLAGS =

INCPATH = ../../INCLUDE
LIBPATH = ../../LIB
LIBS = pmrrr gfortran m pthread rt


######################## do not edit below ###########################


CFLAGS += $(MPIFLAGS) -I$(INCPATH)
LDFLAGS += $(MPIFLAGS) -I$(INCPATH)

.PHONY: all

all: main_all.x main_ind.x main_val.x

# All eigenpairs
main_all.x: main_all.o
$(LD) $(LDFLAGS) $< $(foreach LIBP,$(LIBPATH),-L$(LIBP)) \
$(foreach LIBRARY,$(LIBS),-l$(LIBRARY)) -o $@

main_all.o: main_all.c

# Subset of eigenpairs by index
main_ind.x: main_ind.o
$(LD) $(LDFLAGS) $< $(foreach LIBP,$(LIBPATH),-L$(LIBP)) \
$(foreach LIBRARY,$(LIBS),-l$(LIBRARY)) -o $@

main_ind.o: main_ind.c

# Subset of eigenpairs by value
main_val.x: main_val.o
$(LD) $(LDFLAGS) $< $(foreach LIBP,$(LIBPATH),-L$(LIBP)) \
$(foreach LIBRARY,$(LIBS),-l$(LIBRARY)) -o $@

main_val.o: main_val.c

.PHONY: clean
clean:
rm -f main_*.x core.* *__genmod.* *.o *~
Loading

0 comments on commit 5915582

Please sign in to comment.