Merged eigen/eigen into default

This commit is contained in:
Benoit Steiner 2017-05-26 09:01:04 -07:00
commit 9dee55ec33
15 changed files with 3803 additions and 386 deletions

View File

@ -302,8 +302,12 @@ template<typename VectorX, typename VectorY, typename OtherScalar>
void /*EIGEN_DONT_INLINE*/ apply_rotation_in_the_plane(DenseBase<VectorX>& xpr_x, DenseBase<VectorY>& xpr_y, const JacobiRotation<OtherScalar>& j)
{
typedef typename VectorX::Scalar Scalar;
enum { PacketSize = packet_traits<Scalar>::size };
enum {
PacketSize = packet_traits<Scalar>::size,
OtherPacketSize = packet_traits<OtherScalar>::size
};
typedef typename packet_traits<Scalar>::type Packet;
typedef typename packet_traits<OtherScalar>::type OtherPacket;
eigen_assert(xpr_x.size() == xpr_y.size());
Index size = xpr_x.size();
Index incrx = xpr_x.derived().innerStride();
@ -321,6 +325,7 @@ void /*EIGEN_DONT_INLINE*/ apply_rotation_in_the_plane(DenseBase<VectorX>& xpr_x
if(VectorX::SizeAtCompileTime == Dynamic &&
(VectorX::Flags & VectorY::Flags & PacketAccessBit) &&
(PacketSize == OtherPacketSize) &&
((incrx==1 && incry==1) || PacketSize == 1))
{
// both vectors are sequentially stored in memory => vectorization
@ -329,9 +334,10 @@ void /*EIGEN_DONT_INLINE*/ apply_rotation_in_the_plane(DenseBase<VectorX>& xpr_x
Index alignedStart = internal::first_default_aligned(y, size);
Index alignedEnd = alignedStart + ((size-alignedStart)/PacketSize)*PacketSize;
const Packet pc = pset1<Packet>(c);
const Packet ps = pset1<Packet>(s);
conj_helper<Packet,Packet,NumTraits<Scalar>::IsComplex,false> pcj;
const OtherPacket pc = pset1<OtherPacket>(c);
const OtherPacket ps = pset1<OtherPacket>(s);
conj_helper<OtherPacket,Packet,NumTraits<OtherScalar>::IsComplex,false> pcj;
conj_helper<OtherPacket,Packet,false,false> pm;
for(Index i=0; i<alignedStart; ++i)
{
@ -350,8 +356,8 @@ void /*EIGEN_DONT_INLINE*/ apply_rotation_in_the_plane(DenseBase<VectorX>& xpr_x
{
Packet xi = pload<Packet>(px);
Packet yi = pload<Packet>(py);
pstore(px, padd(pmul(pc,xi),pcj.pmul(ps,yi)));
pstore(py, psub(pcj.pmul(pc,yi),pmul(ps,xi)));
pstore(px, padd(pm.pmul(pc,xi),pcj.pmul(ps,yi)));
pstore(py, psub(pcj.pmul(pc,yi),pm.pmul(ps,xi)));
px += PacketSize;
py += PacketSize;
}
@ -365,10 +371,10 @@ void /*EIGEN_DONT_INLINE*/ apply_rotation_in_the_plane(DenseBase<VectorX>& xpr_x
Packet xi1 = ploadu<Packet>(px+PacketSize);
Packet yi = pload <Packet>(py);
Packet yi1 = pload <Packet>(py+PacketSize);
pstoreu(px, padd(pmul(pc,xi),pcj.pmul(ps,yi)));
pstoreu(px+PacketSize, padd(pmul(pc,xi1),pcj.pmul(ps,yi1)));
pstore (py, psub(pcj.pmul(pc,yi),pmul(ps,xi)));
pstore (py+PacketSize, psub(pcj.pmul(pc,yi1),pmul(ps,xi1)));
pstoreu(px, padd(pm.pmul(pc,xi),pcj.pmul(ps,yi)));
pstoreu(px+PacketSize, padd(pm.pmul(pc,xi1),pcj.pmul(ps,yi1)));
pstore (py, psub(pcj.pmul(pc,yi),pm.pmul(ps,xi)));
pstore (py+PacketSize, psub(pcj.pmul(pc,yi1),pm.pmul(ps,xi1)));
px += Peeling*PacketSize;
py += Peeling*PacketSize;
}
@ -376,8 +382,8 @@ void /*EIGEN_DONT_INLINE*/ apply_rotation_in_the_plane(DenseBase<VectorX>& xpr_x
{
Packet xi = ploadu<Packet>(x+peelingEnd);
Packet yi = pload <Packet>(y+peelingEnd);
pstoreu(x+peelingEnd, padd(pmul(pc,xi),pcj.pmul(ps,yi)));
pstore (y+peelingEnd, psub(pcj.pmul(pc,yi),pmul(ps,xi)));
pstoreu(x+peelingEnd, padd(pm.pmul(pc,xi),pcj.pmul(ps,yi)));
pstore (y+peelingEnd, psub(pcj.pmul(pc,yi),pm.pmul(ps,xi)));
}
}
@ -393,19 +399,21 @@ void /*EIGEN_DONT_INLINE*/ apply_rotation_in_the_plane(DenseBase<VectorX>& xpr_x
/*** fixed-size vectorized path ***/
else if(VectorX::SizeAtCompileTime != Dynamic &&
(VectorX::Flags & VectorY::Flags & PacketAccessBit) &&
(PacketSize == OtherPacketSize) &&
(EIGEN_PLAIN_ENUM_MIN(evaluator<VectorX>::Alignment, evaluator<VectorY>::Alignment)>0)) // FIXME should be compared to the required alignment
{
const Packet pc = pset1<Packet>(c);
const Packet ps = pset1<Packet>(s);
conj_helper<Packet,Packet,NumTraits<Scalar>::IsComplex,false> pcj;
const OtherPacket pc = pset1<OtherPacket>(c);
const OtherPacket ps = pset1<OtherPacket>(s);
conj_helper<OtherPacket,Packet,NumTraits<OtherPacket>::IsComplex,false> pcj;
conj_helper<OtherPacket,Packet,false,false> pm;
Scalar* EIGEN_RESTRICT px = x;
Scalar* EIGEN_RESTRICT py = y;
for(Index i=0; i<size; i+=PacketSize)
{
Packet xi = pload<Packet>(px);
Packet yi = pload<Packet>(py);
pstore(px, padd(pmul(pc,xi),pcj.pmul(ps,yi)));
pstore(py, psub(pcj.pmul(pc,yi),pmul(ps,xi)));
pstore(px, padd(pm.pmul(pc,xi),pcj.pmul(ps,yi)));
pstore(py, psub(pcj.pmul(pc,yi),pm.pmul(ps,xi)));
px += PacketSize;
py += PacketSize;
}

View File

@ -505,8 +505,8 @@ void ColPivHouseholderQR<MatrixType>::computeInPlace()
m_colNormsUpdated.coeffRef(k) = m_colNormsDirect.coeffRef(k);
}
RealScalar threshold_helper = numext::abs2<Scalar>(m_colNormsUpdated.maxCoeff() * NumTraits<Scalar>::epsilon()) / RealScalar(rows);
RealScalar norm_downdate_threshold = numext::sqrt(NumTraits<Scalar>::epsilon());
RealScalar threshold_helper = numext::abs2<RealScalar>(m_colNormsUpdated.maxCoeff() * NumTraits<RealScalar>::epsilon()) / RealScalar(rows);
RealScalar norm_downdate_threshold = numext::sqrt(NumTraits<RealScalar>::epsilon());
m_nonzero_pivots = size; // the generic case is that in which all pivots are nonzero (invertible case)
m_maxpivot = RealScalar(0);
@ -556,7 +556,7 @@ void ColPivHouseholderQR<MatrixType>::computeInPlace()
RealScalar temp = abs(m_qr.coeffRef(k, j)) / m_colNormsUpdated.coeffRef(j);
temp = (RealScalar(1) + temp) * (RealScalar(1) - temp);
temp = temp < 0 ? 0 : temp;
RealScalar temp2 = temp * numext::abs2<Scalar>(m_colNormsUpdated.coeffRef(j) /
RealScalar temp2 = temp * numext::abs2<RealScalar>(m_colNormsUpdated.coeffRef(j) /
m_colNormsDirect.coeffRef(j));
if (temp2 <= norm_downdate_threshold) {
// The updated norm has become too inaccurate so re-compute the column

View File

@ -47,6 +47,7 @@ template<typename MatrixType, unsigned int _Mode> class SparseSelfAdjointView
enum {
Mode = _Mode,
TransposeMode = ((Mode & Upper) ? Lower : 0) | ((Mode & Lower) ? Upper : 0),
RowsAtCompileTime = internal::traits<SparseSelfAdjointView>::RowsAtCompileTime,
ColsAtCompileTime = internal::traits<SparseSelfAdjointView>::ColsAtCompileTime
};
@ -368,7 +369,7 @@ struct generic_product_impl<Lhs, RhsView, DenseShape, SparseSelfAdjointShape, Pr
// transpose everything
Transpose<Dest> dstT(dst);
internal::sparse_selfadjoint_time_dense_product<RhsView::Mode>(rhsNested.transpose(), lhsNested.transpose(), dstT, alpha);
internal::sparse_selfadjoint_time_dense_product<RhsView::TransposeMode>(rhsNested.transpose(), lhsNested.transpose(), dstT, alpha);
}
};

View File

@ -38,25 +38,32 @@ if(SUPERLU_FOUND AND BLAS_FOUND)
endif()
find_package(Pastix)
find_package(Scotch)
find_package(Metis)
if(PASTIX_FOUND AND BLAS_FOUND)
find_package(PASTIX QUIET COMPONENTS METIS SCOTCH)
# check that the PASTIX found is a version without MPI
find_path(PASTIX_pastix_nompi.h_INCLUDE_DIRS
NAMES pastix_nompi.h
HINTS ${PASTIX_INCLUDE_DIRS}
)
if (NOT PASTIX_pastix_nompi.h_INCLUDE_DIRS)
message(STATUS "A version of Pastix has been found but pastix_nompi.h does not exist in the include directory."
" Because Eigen tests require a version without MPI, we disable the Pastix backend.")
endif()
if(PASTIX_FOUND AND PASTIX_pastix_nompi.h_INCLUDE_DIRS AND BLAS_FOUND)
add_definitions("-DEIGEN_PASTIX_SUPPORT")
include_directories(${PASTIX_INCLUDES})
include_directories(${PASTIX_INCLUDE_DIRS_DEP})
if(SCOTCH_FOUND)
include_directories(${SCOTCH_INCLUDES})
include_directories(${SCOTCH_INCLUDE_DIRS})
set(PASTIX_LIBRARIES ${PASTIX_LIBRARIES} ${SCOTCH_LIBRARIES})
elseif(METIS_FOUND)
include_directories(${METIS_INCLUDES})
include_directories(${METIS_INCLUDE_DIRS})
set(PASTIX_LIBRARIES ${PASTIX_LIBRARIES} ${METIS_LIBRARIES})
endif(SCOTCH_FOUND)
set(SPARSE_LIBS ${SPARSE_LIBS} ${PASTIX_LIBRARIES} ${ORDERING_LIBRARIES} ${BLAS_LIBRARIES})
set(PASTIX_ALL_LIBS ${PASTIX_LIBRARIES} ${BLAS_LIBRARIES})
set(SPARSE_LIBS ${SPARSE_LIBS} ${PASTIX_LIBRARIES_DEP} ${ORDERING_LIBRARIES})
set(PASTIX_ALL_LIBS ${PASTIX_LIBRARIES_DEP})
endif(PASTIX_FOUND AND BLAS_FOUND)
if(METIS_FOUND)
include_directories(${METIS_INCLUDES})
include_directories(${METIS_INCLUDE_DIRS})
set (SPARSE_LIBS ${SPARSE_LIBS} ${METIS_LIBRARIES})
add_definitions("-DEIGEN_METIS_SUPPORT")
endif(METIS_FOUND)

File diff suppressed because it is too large Load Diff

380
cmake/FindBLASEXT.cmake Normal file
View File

@ -0,0 +1,380 @@
###
#
# @copyright (c) 2009-2014 The University of Tennessee and The University
# of Tennessee Research Foundation.
# All rights reserved.
# @copyright (c) 2012-2016 Inria. All rights reserved.
# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
#
###
#
# - Find BLAS EXTENDED for MORSE projects: find include dirs and libraries
#
# This module allows to find BLAS libraries by calling the official FindBLAS module
# and handles the creation of different library lists whether the user wishes to link
# with a sequential BLAS or a multihreaded (BLAS_SEQ_LIBRARIES and BLAS_PAR_LIBRARIES).
# BLAS is detected with a FindBLAS call then if the BLAS vendor is Intel10_64lp, ACML
# or IBMESSLMT then the module attempts to find the corresponding multithreaded libraries.
#
# The following variables have been added to manage links with sequential or multithreaded
# versions:
# BLAS_INCLUDE_DIRS - BLAS include directories
# BLAS_LIBRARY_DIRS - Link directories for BLAS libraries
# BLAS_SEQ_LIBRARIES - BLAS component libraries to be linked (sequential)
# BLAS_PAR_LIBRARIES - BLAS component libraries to be linked (multithreaded)
#=============================================================================
# Copyright 2012-2013 Inria
# Copyright 2012-2013 Emmanuel Agullo
# Copyright 2012-2013 Mathieu Faverge
# Copyright 2012 Cedric Castagnede
# Copyright 2013-2016 Florent Pruvost
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file MORSE-Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of Morse, substitute the full
# License text for the above reference.)
# macro to factorize this call
macro(find_package_blas)
if(BLASEXT_FIND_REQUIRED)
if(BLASEXT_FIND_QUIETLY)
find_package(BLAS REQUIRED QUIET)
else()
find_package(BLAS REQUIRED)
endif()
else()
if(BLASEXT_FIND_QUIETLY)
find_package(BLAS QUIET)
else()
find_package(BLAS)
endif()
endif()
endmacro()
# add a cache variable to let the user specify the BLAS vendor
set(BLA_VENDOR "" CACHE STRING "list of possible BLAS vendor:
Open, Eigen, Goto, ATLAS PhiPACK, CXML, DXML, SunPerf, SCSL, SGIMATH, IBMESSL, IBMESSLMT,
Intel10_32 (intel mkl v10 32 bit),
Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model),
Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model),
Intel( older versions of mkl 32 and 64 bit),
ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic")
if(NOT BLASEXT_FIND_QUIETLY)
message(STATUS "In FindBLASEXT")
message(STATUS "If you want to force the use of one specific library, "
"\n please specify the BLAS vendor by setting -DBLA_VENDOR=blas_vendor_name"
"\n at cmake configure.")
message(STATUS "List of possible BLAS vendor: Goto, ATLAS PhiPACK, CXML, "
"\n DXML, SunPerf, SCSL, SGIMATH, IBMESSL, IBMESSLMT, Intel10_32 (intel mkl v10 32 bit),"
"\n Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model),"
"\n Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model),"
"\n Intel( older versions of mkl 32 and 64 bit),"
"\n ACML, ACML_MP, ACML_GPU, Apple, NAS, Generic")
endif()
if (NOT BLAS_FOUND)
# First try to detect two cases:
# 1: only SEQ libs are handled
# 2: both SEQ and PAR libs are handled
find_package_blas()
endif ()
# detect the cases where SEQ and PAR libs are handled
if(BLA_VENDOR STREQUAL "All" AND
(BLAS_mkl_core_LIBRARY OR BLAS_mkl_core_dll_LIBRARY)
)
set(BLA_VENDOR "Intel")
if(BLAS_mkl_intel_LIBRARY)
set(BLA_VENDOR "Intel10_32")
endif()
if(BLAS_mkl_intel_lp64_LIBRARY)
set(BLA_VENDOR "Intel10_64lp")
endif()
if(NOT BLASEXT_FIND_QUIETLY)
message(STATUS "A BLAS library has been found (${BLAS_LIBRARIES}) but we"
"\n have also potentially detected some multithreaded BLAS libraries from the MKL."
"\n We try to find both libraries lists (Sequential/Multithreaded).")
endif()
set(BLAS_FOUND "")
elseif(BLA_VENDOR STREQUAL "All" AND BLAS_acml_LIBRARY)
set(BLA_VENDOR "ACML")
if(NOT BLASEXT_FIND_QUIETLY)
message(STATUS "A BLAS library has been found (${BLAS_LIBRARIES}) but we"
"\n have also potentially detected some multithreaded BLAS libraries from the ACML."
"\n We try to find both libraries lists (Sequential/Multithreaded).")
endif()
set(BLAS_FOUND "")
elseif(BLA_VENDOR STREQUAL "All" AND BLAS_essl_LIBRARY)
set(BLA_VENDOR "IBMESSL")
if(NOT BLASEXT_FIND_QUIETLY)
message(STATUS "A BLAS library has been found (${BLAS_LIBRARIES}) but we"
"\n have also potentially detected some multithreaded BLAS libraries from the ESSL."
"\n We try to find both libraries lists (Sequential/Multithreaded).")
endif()
set(BLAS_FOUND "")
endif()
# Intel case
if(BLA_VENDOR MATCHES "Intel*")
###
# look for include path if the BLAS vendor is Intel
###
# gather system include paths
unset(_inc_env)
if(WIN32)
string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
else()
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{CPATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
endif()
list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
set(ENV_MKLROOT "$ENV{MKLROOT}")
if (ENV_MKLROOT)
list(APPEND _inc_env "${ENV_MKLROOT}/include")
endif()
list(REMOVE_DUPLICATES _inc_env)
# find mkl.h inside known include paths
set(BLAS_mkl.h_INCLUDE_DIRS "BLAS_mkl.h_INCLUDE_DIRS-NOTFOUND")
if(BLAS_INCDIR)
set(BLAS_mkl.h_INCLUDE_DIRS "BLAS_mkl.h_INCLUDE_DIRS-NOTFOUND")
find_path(BLAS_mkl.h_INCLUDE_DIRS
NAMES mkl.h
HINTS ${BLAS_INCDIR})
else()
if(BLAS_DIR)
set(BLAS_mkl.h_INCLUDE_DIRS "BLAS_mkl.h_INCLUDE_DIRS-NOTFOUND")
find_path(BLAS_mkl.h_INCLUDE_DIRS
NAMES mkl.h
HINTS ${BLAS_DIR}
PATH_SUFFIXES include)
else()
set(BLAS_mkl.h_INCLUDE_DIRS "BLAS_mkl.h_INCLUDE_DIRS-NOTFOUND")
find_path(BLAS_mkl.h_INCLUDE_DIRS
NAMES mkl.h
HINTS ${_inc_env})
endif()
endif()
mark_as_advanced(BLAS_mkl.h_INCLUDE_DIRS)
## Print status if not found
## -------------------------
#if (NOT BLAS_mkl.h_INCLUDE_DIRS AND MORSE_VERBOSE)
# Print_Find_Header_Status(blas mkl.h)
#endif ()
set(BLAS_INCLUDE_DIRS "")
if(BLAS_mkl.h_INCLUDE_DIRS)
list(APPEND BLAS_INCLUDE_DIRS "${BLAS_mkl.h_INCLUDE_DIRS}" )
endif()
###
# look for libs
###
# if Intel 10 64 bit -> look for sequential and multithreaded versions
if(BLA_VENDOR MATCHES "Intel10_64lp*")
## look for the sequential version
set(BLA_VENDOR "Intel10_64lp_seq")
if(NOT BLASEXT_FIND_QUIETLY)
message(STATUS "Look for the sequential version Intel10_64lp_seq")
endif()
find_package_blas()
if(BLAS_FOUND)
set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}")
else()
set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}")
endif()
## look for the multithreaded version
set(BLA_VENDOR "Intel10_64lp")
if(NOT BLASEXT_FIND_QUIETLY)
message(STATUS "Look for the multithreaded version Intel10_64lp")
endif()
find_package_blas()
if(BLAS_FOUND)
set(BLAS_PAR_LIBRARIES "${BLAS_LIBRARIES}")
else()
set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}")
endif()
else()
if(BLAS_FOUND)
set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}")
else()
set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}")
endif()
endif()
# ACML case
elseif(BLA_VENDOR MATCHES "ACML*")
## look for the sequential version
set(BLA_VENDOR "ACML")
find_package_blas()
if(BLAS_FOUND)
set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}")
else()
set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}")
endif()
## look for the multithreaded version
set(BLA_VENDOR "ACML_MP")
find_package_blas()
if(BLAS_FOUND)
set(BLAS_PAR_LIBRARIES "${BLAS_LIBRARIES}")
else()
set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}")
endif()
# IBMESSL case
elseif(BLA_VENDOR MATCHES "IBMESSL*")
## look for the sequential version
set(BLA_VENDOR "IBMESSL")
find_package_blas()
if(BLAS_FOUND)
set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}")
else()
set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}")
endif()
## look for the multithreaded version
set(BLA_VENDOR "IBMESSLMT")
find_package_blas()
if(BLAS_FOUND)
set(BLAS_PAR_LIBRARIES "${BLAS_LIBRARIES}")
else()
set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}")
endif()
else()
if(BLAS_FOUND)
# define the SEQ libs as the BLAS_LIBRARIES
set(BLAS_SEQ_LIBRARIES "${BLAS_LIBRARIES}")
else()
set(BLAS_SEQ_LIBRARIES "${BLAS_SEQ_LIBRARIES-NOTFOUND}")
endif()
set(BLAS_PAR_LIBRARIES "${BLAS_PAR_LIBRARIES-NOTFOUND}")
endif()
if(BLAS_SEQ_LIBRARIES)
set(BLAS_LIBRARIES "${BLAS_SEQ_LIBRARIES}")
endif()
# extract libs paths
# remark: because it is not given by find_package(BLAS)
set(BLAS_LIBRARY_DIRS "")
string(REPLACE " " ";" BLAS_LIBRARIES "${BLAS_LIBRARIES}")
foreach(blas_lib ${BLAS_LIBRARIES})
if (EXISTS "${blas_lib}")
get_filename_component(a_blas_lib_dir "${blas_lib}" PATH)
list(APPEND BLAS_LIBRARY_DIRS "${a_blas_lib_dir}" )
else()
string(REPLACE "-L" "" blas_lib "${blas_lib}")
if (EXISTS "${blas_lib}")
list(APPEND BLAS_LIBRARY_DIRS "${blas_lib}" )
else()
get_filename_component(a_blas_lib_dir "${blas_lib}" PATH)
if (EXISTS "${a_blas_lib_dir}")
list(APPEND BLAS_LIBRARY_DIRS "${a_blas_lib_dir}" )
endif()
endif()
endif()
endforeach()
if (BLAS_LIBRARY_DIRS)
list(REMOVE_DUPLICATES BLAS_LIBRARY_DIRS)
endif ()
# check that BLAS has been found
# ---------------------------------
include(FindPackageHandleStandardArgs)
if(BLA_VENDOR MATCHES "Intel*")
if(BLA_VENDOR MATCHES "Intel10_64lp*")
if(NOT BLASEXT_FIND_QUIETLY)
message(STATUS "BLAS found is Intel MKL:"
"\n we manage two lists of libs, one sequential and one parallel if found"
"\n (see BLAS_SEQ_LIBRARIES and BLAS_PAR_LIBRARIES)")
message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES")
endif()
find_package_handle_standard_args(BLAS DEFAULT_MSG
BLAS_SEQ_LIBRARIES
BLAS_LIBRARY_DIRS
BLAS_INCLUDE_DIRS)
if(BLAS_PAR_LIBRARIES)
if(NOT BLASEXT_FIND_QUIETLY)
message(STATUS "BLAS parallel libraries stored in BLAS_PAR_LIBRARIES")
endif()
find_package_handle_standard_args(BLAS DEFAULT_MSG
BLAS_PAR_LIBRARIES)
endif()
else()
if(NOT BLASEXT_FIND_QUIETLY)
message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES")
endif()
find_package_handle_standard_args(BLAS DEFAULT_MSG
BLAS_SEQ_LIBRARIES
BLAS_LIBRARY_DIRS
BLAS_INCLUDE_DIRS)
endif()
elseif(BLA_VENDOR MATCHES "ACML*")
if(NOT BLASEXT_FIND_QUIETLY)
message(STATUS "BLAS found is ACML:"
"\n we manage two lists of libs, one sequential and one parallel if found"
"\n (see BLAS_SEQ_LIBRARIES and BLAS_PAR_LIBRARIES)")
message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES")
endif()
find_package_handle_standard_args(BLAS DEFAULT_MSG
BLAS_SEQ_LIBRARIES
BLAS_LIBRARY_DIRS)
if(BLAS_PAR_LIBRARIES)
if(NOT BLASEXT_FIND_QUIETLY)
message(STATUS "BLAS parallel libraries stored in BLAS_PAR_LIBRARIES")
endif()
find_package_handle_standard_args(BLAS DEFAULT_MSG
BLAS_PAR_LIBRARIES)
endif()
elseif(BLA_VENDOR MATCHES "IBMESSL*")
if(NOT BLASEXT_FIND_QUIETLY)
message(STATUS "BLAS found is ESSL:"
"\n we manage two lists of libs, one sequential and one parallel if found"
"\n (see BLAS_SEQ_LIBRARIES and BLAS_PAR_LIBRARIES)")
message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES")
endif()
find_package_handle_standard_args(BLAS DEFAULT_MSG
BLAS_SEQ_LIBRARIES
BLAS_LIBRARY_DIRS)
if(BLAS_PAR_LIBRARIES)
if(NOT BLASEXT_FIND_QUIETLY)
message(STATUS "BLAS parallel libraries stored in BLAS_PAR_LIBRARIES")
endif()
find_package_handle_standard_args(BLAS DEFAULT_MSG
BLAS_PAR_LIBRARIES)
endif()
else()
if(NOT BLASEXT_FIND_QUIETLY)
message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES")
endif()
find_package_handle_standard_args(BLAS DEFAULT_MSG
BLAS_SEQ_LIBRARIES
BLAS_LIBRARY_DIRS)
endif()

331
cmake/FindHWLOC.cmake Normal file
View File

@ -0,0 +1,331 @@
###
#
# @copyright (c) 2009-2014 The University of Tennessee and The University
# of Tennessee Research Foundation.
# All rights reserved.
# @copyright (c) 2012-2014 Inria. All rights reserved.
# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
#
###
#
# - Find HWLOC include dirs and libraries
# Use this module by invoking find_package with the form:
# find_package(HWLOC
# [REQUIRED]) # Fail with error if hwloc is not found
#
# This module finds headers and hwloc library.
# Results are reported in variables:
# HWLOC_FOUND - True if headers and requested libraries were found
# HWLOC_INCLUDE_DIRS - hwloc include directories
# HWLOC_LIBRARY_DIRS - Link directories for hwloc libraries
# HWLOC_LIBRARIES - hwloc component libraries to be linked
#
# The user can give specific paths where to find the libraries adding cmake
# options at configure (ex: cmake path/to/project -DHWLOC_DIR=path/to/hwloc):
# HWLOC_DIR - Where to find the base directory of hwloc
# HWLOC_INCDIR - Where to find the header files
# HWLOC_LIBDIR - Where to find the library files
# The module can also look for the following environment variables if paths
# are not given as cmake variable: HWLOC_DIR, HWLOC_INCDIR, HWLOC_LIBDIR
#=============================================================================
# Copyright 2012-2013 Inria
# Copyright 2012-2013 Emmanuel Agullo
# Copyright 2012-2013 Mathieu Faverge
# Copyright 2012 Cedric Castagnede
# Copyright 2013 Florent Pruvost
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file MORSE-Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of Morse, substitute the full
# License text for the above reference.)
include(CheckStructHasMember)
include(CheckCSourceCompiles)
if (NOT HWLOC_FOUND)
set(HWLOC_DIR "" CACHE PATH "Installation directory of HWLOC library")
if (NOT HWLOC_FIND_QUIETLY)
message(STATUS "A cache variable, namely HWLOC_DIR, has been set to specify the install directory of HWLOC")
endif()
endif()
set(ENV_HWLOC_DIR "$ENV{HWLOC_DIR}")
set(ENV_HWLOC_INCDIR "$ENV{HWLOC_INCDIR}")
set(ENV_HWLOC_LIBDIR "$ENV{HWLOC_LIBDIR}")
set(HWLOC_GIVEN_BY_USER "FALSE")
if ( HWLOC_DIR OR ( HWLOC_INCDIR AND HWLOC_LIBDIR) OR ENV_HWLOC_DIR OR (ENV_HWLOC_INCDIR AND ENV_HWLOC_LIBDIR) )
set(HWLOC_GIVEN_BY_USER "TRUE")
endif()
# Optionally use pkg-config to detect include/library dirs (if pkg-config is available)
# -------------------------------------------------------------------------------------
include(FindPkgConfig)
find_package(PkgConfig QUIET)
if( PKG_CONFIG_EXECUTABLE AND NOT HWLOC_GIVEN_BY_USER )
pkg_search_module(HWLOC hwloc)
if (NOT HWLOC_FIND_QUIETLY)
if (HWLOC_FOUND AND HWLOC_LIBRARIES)
message(STATUS "Looking for HWLOC - found using PkgConfig")
#if(NOT HWLOC_INCLUDE_DIRS)
# message("${Magenta}HWLOC_INCLUDE_DIRS is empty using PkgConfig."
# "Perhaps the path to hwloc headers is already present in your"
# "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}")
#endif()
else()
message(STATUS "${Magenta}Looking for HWLOC - not found using PkgConfig."
"\n Perhaps you should add the directory containing hwloc.pc to"
"\n the PKG_CONFIG_PATH environment variable.${ColourReset}")
endif()
endif()
endif( PKG_CONFIG_EXECUTABLE AND NOT HWLOC_GIVEN_BY_USER )
if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR (HWLOC_GIVEN_BY_USER) )
if (NOT HWLOC_FIND_QUIETLY)
message(STATUS "Looking for HWLOC - PkgConfig not used")
endif()
# Looking for include
# -------------------
# Add system include paths to search include
# ------------------------------------------
unset(_inc_env)
if(ENV_HWLOC_INCDIR)
list(APPEND _inc_env "${ENV_HWLOC_INCDIR}")
elseif(ENV_HWLOC_DIR)
list(APPEND _inc_env "${ENV_HWLOC_DIR}")
list(APPEND _inc_env "${ENV_HWLOC_DIR}/include")
list(APPEND _inc_env "${ENV_HWLOC_DIR}/include/hwloc")
else()
if(WIN32)
string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
else()
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{CPATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
endif()
endif()
list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
list(REMOVE_DUPLICATES _inc_env)
# set paths where to look for
set(PATH_TO_LOOK_FOR "${_inc_env}")
# Try to find the hwloc header in the given paths
# -------------------------------------------------
# call cmake macro to find the header path
if(HWLOC_INCDIR)
set(HWLOC_hwloc.h_DIRS "HWLOC_hwloc.h_DIRS-NOTFOUND")
find_path(HWLOC_hwloc.h_DIRS
NAMES hwloc.h
HINTS ${HWLOC_INCDIR})
else()
if(HWLOC_DIR)
set(HWLOC_hwloc.h_DIRS "HWLOC_hwloc.h_DIRS-NOTFOUND")
find_path(HWLOC_hwloc.h_DIRS
NAMES hwloc.h
HINTS ${HWLOC_DIR}
PATH_SUFFIXES "include" "include/hwloc")
else()
set(HWLOC_hwloc.h_DIRS "HWLOC_hwloc.h_DIRS-NOTFOUND")
find_path(HWLOC_hwloc.h_DIRS
NAMES hwloc.h
HINTS ${PATH_TO_LOOK_FOR}
PATH_SUFFIXES "hwloc")
endif()
endif()
mark_as_advanced(HWLOC_hwloc.h_DIRS)
# Add path to cmake variable
# ------------------------------------
if (HWLOC_hwloc.h_DIRS)
set(HWLOC_INCLUDE_DIRS "${HWLOC_hwloc.h_DIRS}")
else ()
set(HWLOC_INCLUDE_DIRS "HWLOC_INCLUDE_DIRS-NOTFOUND")
if(NOT HWLOC_FIND_QUIETLY)
message(STATUS "Looking for hwloc -- hwloc.h not found")
endif()
endif ()
if (HWLOC_INCLUDE_DIRS)
list(REMOVE_DUPLICATES HWLOC_INCLUDE_DIRS)
endif ()
# Looking for lib
# ---------------
# Add system library paths to search lib
# --------------------------------------
unset(_lib_env)
if(ENV_HWLOC_LIBDIR)
list(APPEND _lib_env "${ENV_HWLOC_LIBDIR}")
elseif(ENV_HWLOC_DIR)
list(APPEND _lib_env "${ENV_HWLOC_DIR}")
list(APPEND _lib_env "${ENV_HWLOC_DIR}/lib")
else()
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
else()
if(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
endif()
list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
endif()
endif()
list(REMOVE_DUPLICATES _lib_env)
# set paths where to look for
set(PATH_TO_LOOK_FOR "${_lib_env}")
# Try to find the hwloc lib in the given paths
# ----------------------------------------------
# call cmake macro to find the lib path
if(HWLOC_LIBDIR)
set(HWLOC_hwloc_LIBRARY "HWLOC_hwloc_LIBRARY-NOTFOUND")
find_library(HWLOC_hwloc_LIBRARY
NAMES hwloc
HINTS ${HWLOC_LIBDIR})
else()
if(HWLOC_DIR)
set(HWLOC_hwloc_LIBRARY "HWLOC_hwloc_LIBRARY-NOTFOUND")
find_library(HWLOC_hwloc_LIBRARY
NAMES hwloc
HINTS ${HWLOC_DIR}
PATH_SUFFIXES lib lib32 lib64)
else()
set(HWLOC_hwloc_LIBRARY "HWLOC_hwloc_LIBRARY-NOTFOUND")
find_library(HWLOC_hwloc_LIBRARY
NAMES hwloc
HINTS ${PATH_TO_LOOK_FOR})
endif()
endif()
mark_as_advanced(HWLOC_hwloc_LIBRARY)
# If found, add path to cmake variable
# ------------------------------------
if (HWLOC_hwloc_LIBRARY)
get_filename_component(hwloc_lib_path ${HWLOC_hwloc_LIBRARY} PATH)
# set cmake variables (respects naming convention)
set(HWLOC_LIBRARIES "${HWLOC_hwloc_LIBRARY}")
set(HWLOC_LIBRARY_DIRS "${hwloc_lib_path}")
else ()
set(HWLOC_LIBRARIES "HWLOC_LIBRARIES-NOTFOUND")
set(HWLOC_LIBRARY_DIRS "HWLOC_LIBRARY_DIRS-NOTFOUND")
if(NOT HWLOC_FIND_QUIETLY)
message(STATUS "Looking for hwloc -- lib hwloc not found")
endif()
endif ()
if (HWLOC_LIBRARY_DIRS)
list(REMOVE_DUPLICATES HWLOC_LIBRARY_DIRS)
endif ()
# check a function to validate the find
if(HWLOC_LIBRARIES)
set(REQUIRED_INCDIRS)
set(REQUIRED_LIBDIRS)
set(REQUIRED_LIBS)
# HWLOC
if (HWLOC_INCLUDE_DIRS)
set(REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}")
endif()
if (HWLOC_LIBRARY_DIRS)
set(REQUIRED_LIBDIRS "${HWLOC_LIBRARY_DIRS}")
endif()
set(REQUIRED_LIBS "${HWLOC_LIBRARIES}")
# set required libraries for link
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
set(CMAKE_REQUIRED_LIBRARIES)
foreach(lib_dir ${REQUIRED_LIBDIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
endforeach()
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
# test link
unset(HWLOC_WORKS CACHE)
include(CheckFunctionExists)
check_function_exists(hwloc_topology_init HWLOC_WORKS)
mark_as_advanced(HWLOC_WORKS)
if(NOT HWLOC_WORKS)
if(NOT HWLOC_FIND_QUIETLY)
message(STATUS "Looking for hwloc : test of hwloc_topology_init with hwloc library fails")
message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
endif()
endif()
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_LIBRARIES)
endif(HWLOC_LIBRARIES)
endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR (HWLOC_GIVEN_BY_USER) )
if (HWLOC_LIBRARIES)
if (HWLOC_LIBRARY_DIRS)
list(GET HWLOC_LIBRARY_DIRS 0 first_lib_path)
else()
list(GET HWLOC_LIBRARIES 0 first_lib)
get_filename_component(first_lib_path "${first_lib}" PATH)
endif()
if (${first_lib_path} MATCHES "/lib(32|64)?$")
string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}")
set(HWLOC_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of HWLOC library" FORCE)
else()
set(HWLOC_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of HWLOC library" FORCE)
endif()
endif()
mark_as_advanced(HWLOC_DIR)
mark_as_advanced(HWLOC_DIR_FOUND)
# check that HWLOC has been found
# -------------------------------
include(FindPackageHandleStandardArgs)
if (PKG_CONFIG_EXECUTABLE AND HWLOC_FOUND)
find_package_handle_standard_args(HWLOC DEFAULT_MSG
HWLOC_LIBRARIES)
else()
find_package_handle_standard_args(HWLOC DEFAULT_MSG
HWLOC_LIBRARIES
HWLOC_WORKS)
endif()
if (HWLOC_FOUND)
set(HWLOC_SAVE_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
list(APPEND CMAKE_REQUIRED_INCLUDES ${HWLOC_INCLUDE_DIRS})
# test headers to guess the version
check_struct_has_member( "struct hwloc_obj" parent hwloc.h HAVE_HWLOC_PARENT_MEMBER )
check_struct_has_member( "struct hwloc_cache_attr_s" size hwloc.h HAVE_HWLOC_CACHE_ATTR )
check_c_source_compiles( "#include <hwloc.h>
int main(void) { hwloc_obj_t o; o->type = HWLOC_OBJ_PU; return 0;}" HAVE_HWLOC_OBJ_PU)
include(CheckLibraryExists)
check_library_exists(${HWLOC_LIBRARIES} hwloc_bitmap_free "" HAVE_HWLOC_BITMAP)
set(CMAKE_REQUIRED_INCLUDES ${HWLOC_SAVE_CMAKE_REQUIRED_INCLUDES})
endif()

View File

@ -1,59 +1,264 @@
# Pastix requires METIS or METIS (partitioning and reordering tools)
###
#
# @copyright (c) 2009-2014 The University of Tennessee and The University
# of Tennessee Research Foundation.
# All rights reserved.
# @copyright (c) 2012-2014 Inria. All rights reserved.
# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
#
###
#
# - Find METIS include dirs and libraries
# Use this module by invoking find_package with the form:
# find_package(METIS
# [REQUIRED] # Fail with error if metis is not found
# )
#
# This module finds headers and metis library.
# Results are reported in variables:
# METIS_FOUND - True if headers and requested libraries were found
# METIS_INCLUDE_DIRS - metis include directories
# METIS_LIBRARY_DIRS - Link directories for metis libraries
# METIS_LIBRARIES - metis component libraries to be linked
#
# The user can give specific paths where to find the libraries adding cmake
# options at configure (ex: cmake path/to/project -DMETIS_DIR=path/to/metis):
# METIS_DIR - Where to find the base directory of metis
# METIS_INCDIR - Where to find the header files
# METIS_LIBDIR - Where to find the library files
# The module can also look for the following environment variables if paths
# are not given as cmake variable: METIS_DIR, METIS_INCDIR, METIS_LIBDIR
if (METIS_INCLUDES AND METIS_LIBRARIES)
set(METIS_FIND_QUIETLY TRUE)
endif (METIS_INCLUDES AND METIS_LIBRARIES)
#=============================================================================
# Copyright 2012-2013 Inria
# Copyright 2012-2013 Emmanuel Agullo
# Copyright 2012-2013 Mathieu Faverge
# Copyright 2012 Cedric Castagnede
# Copyright 2013 Florent Pruvost
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file MORSE-Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of Morse, substitute the full
# License text for the above reference.)
find_path(METIS_INCLUDES
NAMES
metis.h
PATHS
$ENV{METISDIR}
${INCLUDE_INSTALL_DIR}
PATH_SUFFIXES
.
metis
include
)
macro(_metis_check_version)
file(READ "${METIS_INCLUDES}/metis.h" _metis_version_header)
string(REGEX MATCH "define[ \t]+METIS_VER_MAJOR[ \t]+([0-9]+)" _metis_major_version_match "${_metis_version_header}")
set(METIS_MAJOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+METIS_VER_MINOR[ \t]+([0-9]+)" _metis_minor_version_match "${_metis_version_header}")
set(METIS_MINOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+METIS_VER_SUBMINOR[ \t]+([0-9]+)" _metis_subminor_version_match "${_metis_version_header}")
set(METIS_SUBMINOR_VERSION "${CMAKE_MATCH_1}")
if(NOT METIS_MAJOR_VERSION)
message(STATUS "Could not determine Metis version. Assuming version 4.0.0")
set(METIS_VERSION 4.0.0)
else()
set(METIS_VERSION ${METIS_MAJOR_VERSION}.${METIS_MINOR_VERSION}.${METIS_SUBMINOR_VERSION})
if (NOT METIS_FOUND)
set(METIS_DIR "" CACHE PATH "Installation directory of METIS library")
if (NOT METIS_FIND_QUIETLY)
message(STATUS "A cache variable, namely METIS_DIR, has been set to specify the install directory of METIS")
endif()
if(${METIS_VERSION} VERSION_LESS ${Metis_FIND_VERSION})
set(METIS_VERSION_OK FALSE)
else()
set(METIS_VERSION_OK TRUE)
endif()
if(NOT METIS_VERSION_OK)
message(STATUS "Metis version ${METIS_VERSION} found in ${METIS_INCLUDES}, "
"but at least version ${Metis_FIND_VERSION} is required")
endif(NOT METIS_VERSION_OK)
endmacro(_metis_check_version)
# Looking for include
# -------------------
if(METIS_INCLUDES AND Metis_FIND_VERSION)
_metis_check_version()
# Add system include paths to search include
# ------------------------------------------
unset(_inc_env)
set(ENV_METIS_DIR "$ENV{METIS_DIR}")
set(ENV_METIS_INCDIR "$ENV{METIS_INCDIR}")
if(ENV_METIS_INCDIR)
list(APPEND _inc_env "${ENV_METIS_INCDIR}")
elseif(ENV_METIS_DIR)
list(APPEND _inc_env "${ENV_METIS_DIR}")
list(APPEND _inc_env "${ENV_METIS_DIR}/include")
list(APPEND _inc_env "${ENV_METIS_DIR}/include/metis")
else()
set(METIS_VERSION_OK TRUE)
if(WIN32)
string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
else()
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{CPATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
endif()
endif()
list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
list(REMOVE_DUPLICATES _inc_env)
# Try to find the metis header in the given paths
# -------------------------------------------------
# call cmake macro to find the header path
if(METIS_INCDIR)
set(METIS_metis.h_DIRS "METIS_metis.h_DIRS-NOTFOUND")
find_path(METIS_metis.h_DIRS
NAMES metis.h
HINTS ${METIS_INCDIR})
else()
if(METIS_DIR)
set(METIS_metis.h_DIRS "METIS_metis.h_DIRS-NOTFOUND")
find_path(METIS_metis.h_DIRS
NAMES metis.h
HINTS ${METIS_DIR}
PATH_SUFFIXES "include" "include/metis")
else()
set(METIS_metis.h_DIRS "METIS_metis.h_DIRS-NOTFOUND")
find_path(METIS_metis.h_DIRS
NAMES metis.h
HINTS ${_inc_env})
endif()
endif()
mark_as_advanced(METIS_metis.h_DIRS)
# If found, add path to cmake variable
# ------------------------------------
if (METIS_metis.h_DIRS)
set(METIS_INCLUDE_DIRS "${METIS_metis.h_DIRS}")
else ()
set(METIS_INCLUDE_DIRS "METIS_INCLUDE_DIRS-NOTFOUND")
if(NOT METIS_FIND_QUIETLY)
message(STATUS "Looking for metis -- metis.h not found")
endif()
endif()
find_library(METIS_LIBRARIES metis PATHS $ENV{METISDIR} ${LIB_INSTALL_DIR} PATH_SUFFIXES lib)
# Looking for lib
# ---------------
# Add system library paths to search lib
# --------------------------------------
unset(_lib_env)
set(ENV_METIS_LIBDIR "$ENV{METIS_LIBDIR}")
if(ENV_METIS_LIBDIR)
list(APPEND _lib_env "${ENV_METIS_LIBDIR}")
elseif(ENV_METIS_DIR)
list(APPEND _lib_env "${ENV_METIS_DIR}")
list(APPEND _lib_env "${ENV_METIS_DIR}/lib")
else()
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
else()
if(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
endif()
list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
endif()
endif()
list(REMOVE_DUPLICATES _lib_env)
# Try to find the metis lib in the given paths
# ----------------------------------------------
# call cmake macro to find the lib path
if(METIS_LIBDIR)
set(METIS_metis_LIBRARY "METIS_metis_LIBRARY-NOTFOUND")
find_library(METIS_metis_LIBRARY
NAMES metis
HINTS ${METIS_LIBDIR})
else()
if(METIS_DIR)
set(METIS_metis_LIBRARY "METIS_metis_LIBRARY-NOTFOUND")
find_library(METIS_metis_LIBRARY
NAMES metis
HINTS ${METIS_DIR}
PATH_SUFFIXES lib lib32 lib64)
else()
set(METIS_metis_LIBRARY "METIS_metis_LIBRARY-NOTFOUND")
find_library(METIS_metis_LIBRARY
NAMES metis
HINTS ${_lib_env})
endif()
endif()
mark_as_advanced(METIS_metis_LIBRARY)
# If found, add path to cmake variable
# ------------------------------------
if (METIS_metis_LIBRARY)
get_filename_component(metis_lib_path "${METIS_metis_LIBRARY}" PATH)
# set cmake variables
set(METIS_LIBRARIES "${METIS_metis_LIBRARY}")
set(METIS_LIBRARY_DIRS "${metis_lib_path}")
else ()
set(METIS_LIBRARIES "METIS_LIBRARIES-NOTFOUND")
set(METIS_LIBRARY_DIRS "METIS_LIBRARY_DIRS-NOTFOUND")
if(NOT METIS_FIND_QUIETLY)
message(STATUS "Looking for metis -- lib metis not found")
endif()
endif ()
# check a function to validate the find
if(METIS_LIBRARIES)
set(REQUIRED_INCDIRS)
set(REQUIRED_LIBDIRS)
set(REQUIRED_LIBS)
# METIS
if (METIS_INCLUDE_DIRS)
set(REQUIRED_INCDIRS "${METIS_INCLUDE_DIRS}")
endif()
if (METIS_LIBRARY_DIRS)
set(REQUIRED_LIBDIRS "${METIS_LIBRARY_DIRS}")
endif()
set(REQUIRED_LIBS "${METIS_LIBRARIES}")
# m
find_library(M_LIBRARY NAMES m)
mark_as_advanced(M_LIBRARY)
if(M_LIBRARY)
list(APPEND REQUIRED_LIBS "-lm")
endif()
# set required libraries for link
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
set(CMAKE_REQUIRED_LIBRARIES)
foreach(lib_dir ${REQUIRED_LIBDIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
endforeach()
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
# test link
unset(METIS_WORKS CACHE)
include(CheckFunctionExists)
check_function_exists(METIS_NodeND METIS_WORKS)
mark_as_advanced(METIS_WORKS)
if(NOT METIS_WORKS)
if(NOT METIS_FIND_QUIETLY)
message(STATUS "Looking for METIS : test of METIS_NodeND with METIS library fails")
message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
endif()
endif()
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_LIBRARIES)
endif(METIS_LIBRARIES)
if (METIS_LIBRARIES)
list(GET METIS_LIBRARIES 0 first_lib)
get_filename_component(first_lib_path "${first_lib}" PATH)
if (${first_lib_path} MATCHES "/lib(32|64)?$")
string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}")
set(METIS_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of METIS library" FORCE)
else()
set(METIS_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of METIS library" FORCE)
endif()
endif()
mark_as_advanced(METIS_DIR)
mark_as_advanced(METIS_DIR_FOUND)
# check that METIS has been found
# ---------------------------------
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(METIS DEFAULT_MSG
METIS_INCLUDES METIS_LIBRARIES METIS_VERSION_OK)
mark_as_advanced(METIS_INCLUDES METIS_LIBRARIES)
METIS_LIBRARIES
METIS_WORKS)
#
# TODO: Add possibility to check for specific functions in the library
#

423
cmake/FindPTSCOTCH.cmake Normal file
View File

@ -0,0 +1,423 @@
###
#
# @copyright (c) 2009-2014 The University of Tennessee and The University
# of Tennessee Research Foundation.
# All rights reserved.
# @copyright (c) 2012-2016 Inria. All rights reserved.
# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
#
###
#
# - Find PTSCOTCH include dirs and libraries
# Use this module by invoking find_package with the form:
# find_package(PTSCOTCH
# [REQUIRED] # Fail with error if ptscotch is not found
# [COMPONENTS <comp1> <comp2> ...] # dependencies
# )
#
# PTSCOTCH depends on the following libraries:
# - Threads
# - MPI
#
# COMPONENTS can be some of the following:
# - ESMUMPS: to activate detection of PT-Scotch with the esmumps interface
#
# This module finds headers and ptscotch library.
# Results are reported in variables:
# PTSCOTCH_FOUND - True if headers and requested libraries were found
# PTSCOTCH_LINKER_FLAGS - list of required linker flags (excluding -l and -L)
# PTSCOTCH_INCLUDE_DIRS - ptscotch include directories
# PTSCOTCH_LIBRARY_DIRS - Link directories for ptscotch libraries
# PTSCOTCH_LIBRARIES - ptscotch component libraries to be linked
# PTSCOTCH_INCLUDE_DIRS_DEP - ptscotch + dependencies include directories
# PTSCOTCH_LIBRARY_DIRS_DEP - ptscotch + dependencies link directories
# PTSCOTCH_LIBRARIES_DEP - ptscotch libraries + dependencies
# PTSCOTCH_INTSIZE - Number of octets occupied by a SCOTCH_Num
#
# The user can give specific paths where to find the libraries adding cmake
# options at configure (ex: cmake path/to/project -DPTSCOTCH=path/to/ptscotch):
# PTSCOTCH_DIR - Where to find the base directory of ptscotch
# PTSCOTCH_INCDIR - Where to find the header files
# PTSCOTCH_LIBDIR - Where to find the library files
# The module can also look for the following environment variables if paths
# are not given as cmake variable: PTSCOTCH_DIR, PTSCOTCH_INCDIR, PTSCOTCH_LIBDIR
#=============================================================================
# Copyright 2012-2013 Inria
# Copyright 2012-2013 Emmanuel Agullo
# Copyright 2012-2013 Mathieu Faverge
# Copyright 2012 Cedric Castagnede
# Copyright 2013-2016 Florent Pruvost
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file MORSE-Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of Morse, substitute the full
# License text for the above reference.)
if (NOT PTSCOTCH_FOUND)
set(PTSCOTCH_DIR "" CACHE PATH "Installation directory of PTSCOTCH library")
if (NOT PTSCOTCH_FIND_QUIETLY)
message(STATUS "A cache variable, namely PTSCOTCH_DIR, has been set to specify the install directory of PTSCOTCH")
endif()
endif()
# Set the version to find
set(PTSCOTCH_LOOK_FOR_ESMUMPS OFF)
if( PTSCOTCH_FIND_COMPONENTS )
foreach( component ${PTSCOTCH_FIND_COMPONENTS} )
if (${component} STREQUAL "ESMUMPS")
# means we look for esmumps library
set(PTSCOTCH_LOOK_FOR_ESMUMPS ON)
endif()
endforeach()
endif()
# PTSCOTCH depends on Threads, try to find it
if (NOT THREADS_FOUND)
if (PTSCOTCH_FIND_REQUIRED)
find_package(Threads REQUIRED)
else()
find_package(Threads)
endif()
endif()
# PTSCOTCH depends on MPI, try to find it
if (NOT MPI_FOUND)
if (PTSCOTCH_FIND_REQUIRED)
find_package(MPI REQUIRED)
else()
find_package(MPI)
endif()
endif()
# Looking for include
# -------------------
# Add system include paths to search include
# ------------------------------------------
unset(_inc_env)
set(ENV_PTSCOTCH_DIR "$ENV{PTSCOTCH_DIR}")
set(ENV_PTSCOTCH_INCDIR "$ENV{PTSCOTCH_INCDIR}")
if(ENV_PTSCOTCH_INCDIR)
list(APPEND _inc_env "${ENV_PTSCOTCH_INCDIR}")
elseif(ENV_PTSCOTCH_DIR)
list(APPEND _inc_env "${ENV_PTSCOTCH_DIR}")
list(APPEND _inc_env "${ENV_PTSCOTCH_DIR}/include")
list(APPEND _inc_env "${ENV_PTSCOTCH_DIR}/include/ptscotch")
else()
if(WIN32)
string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
else()
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{CPATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
endif()
endif()
list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
list(REMOVE_DUPLICATES _inc_env)
# Try to find the ptscotch header in the given paths
# -------------------------------------------------
set(PTSCOTCH_hdrs_to_find "ptscotch.h;scotch.h")
# call cmake macro to find the header path
if(PTSCOTCH_INCDIR)
foreach(ptscotch_hdr ${PTSCOTCH_hdrs_to_find})
set(PTSCOTCH_${ptscotch_hdr}_DIRS "PTSCOTCH_${ptscotch_hdr}_DIRS-NOTFOUND")
find_path(PTSCOTCH_${ptscotch_hdr}_DIRS
NAMES ${ptscotch_hdr}
HINTS ${PTSCOTCH_INCDIR})
mark_as_advanced(PTSCOTCH_${ptscotch_hdr}_DIRS)
endforeach()
else()
if(PTSCOTCH_DIR)
foreach(ptscotch_hdr ${PTSCOTCH_hdrs_to_find})
set(PTSCOTCH_${ptscotch_hdr}_DIRS "PTSCOTCH_${ptscotch_hdr}_DIRS-NOTFOUND")
find_path(PTSCOTCH_${ptscotch_hdr}_DIRS
NAMES ${ptscotch_hdr}
HINTS ${PTSCOTCH_DIR}
PATH_SUFFIXES "include" "include/scotch")
mark_as_advanced(PTSCOTCH_${ptscotch_hdr}_DIRS)
endforeach()
else()
foreach(ptscotch_hdr ${PTSCOTCH_hdrs_to_find})
set(PTSCOTCH_${ptscotch_hdr}_DIRS "PTSCOTCH_${ptscotch_hdr}_DIRS-NOTFOUND")
find_path(PTSCOTCH_${ptscotch_hdr}_DIRS
NAMES ${ptscotch_hdr}
HINTS ${_inc_env}
PATH_SUFFIXES "scotch")
mark_as_advanced(PTSCOTCH_${ptscotch_hdr}_DIRS)
endforeach()
endif()
endif()
# If found, add path to cmake variable
# ------------------------------------
foreach(ptscotch_hdr ${PTSCOTCH_hdrs_to_find})
if (PTSCOTCH_${ptscotch_hdr}_DIRS)
list(APPEND PTSCOTCH_INCLUDE_DIRS "${PTSCOTCH_${ptscotch_hdr}_DIRS}")
else ()
set(PTSCOTCH_INCLUDE_DIRS "PTSCOTCH_INCLUDE_DIRS-NOTFOUND")
if (NOT PTSCOTCH_FIND_QUIETLY)
message(STATUS "Looking for ptscotch -- ${ptscotch_hdr} not found")
endif()
endif()
endforeach()
list(REMOVE_DUPLICATES PTSCOTCH_INCLUDE_DIRS)
# Looking for lib
# ---------------
# Add system library paths to search lib
# --------------------------------------
unset(_lib_env)
set(ENV_PTSCOTCH_LIBDIR "$ENV{PTSCOTCH_LIBDIR}")
if(ENV_PTSCOTCH_LIBDIR)
list(APPEND _lib_env "${ENV_PTSCOTCH_LIBDIR}")
elseif(ENV_PTSCOTCH_DIR)
list(APPEND _lib_env "${ENV_PTSCOTCH_DIR}")
list(APPEND _lib_env "${ENV_PTSCOTCH_DIR}/lib")
else()
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
else()
if(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
endif()
list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
endif()
endif()
list(REMOVE_DUPLICATES _lib_env)
# Try to find the ptscotch lib in the given paths
# ----------------------------------------------
set(PTSCOTCH_libs_to_find "ptscotch;ptscotcherr")
if (PTSCOTCH_LOOK_FOR_ESMUMPS)
list(INSERT PTSCOTCH_libs_to_find 0 "ptesmumps")
list(APPEND PTSCOTCH_libs_to_find "esmumps" )
endif()
list(APPEND PTSCOTCH_libs_to_find "scotch;scotcherr")
# call cmake macro to find the lib path
if(PTSCOTCH_LIBDIR)
foreach(ptscotch_lib ${PTSCOTCH_libs_to_find})
set(PTSCOTCH_${ptscotch_lib}_LIBRARY "PTSCOTCH_${ptscotch_lib}_LIBRARY-NOTFOUND")
find_library(PTSCOTCH_${ptscotch_lib}_LIBRARY
NAMES ${ptscotch_lib}
HINTS ${PTSCOTCH_LIBDIR})
endforeach()
else()
if(PTSCOTCH_DIR)
foreach(ptscotch_lib ${PTSCOTCH_libs_to_find})
set(PTSCOTCH_${ptscotch_lib}_LIBRARY "PTSCOTCH_${ptscotch_lib}_LIBRARY-NOTFOUND")
find_library(PTSCOTCH_${ptscotch_lib}_LIBRARY
NAMES ${ptscotch_lib}
HINTS ${PTSCOTCH_DIR}
PATH_SUFFIXES lib lib32 lib64)
endforeach()
else()
foreach(ptscotch_lib ${PTSCOTCH_libs_to_find})
set(PTSCOTCH_${ptscotch_lib}_LIBRARY "PTSCOTCH_${ptscotch_lib}_LIBRARY-NOTFOUND")
find_library(PTSCOTCH_${ptscotch_lib}_LIBRARY
NAMES ${ptscotch_lib}
HINTS ${_lib_env})
endforeach()
endif()
endif()
set(PTSCOTCH_LIBRARIES "")
set(PTSCOTCH_LIBRARY_DIRS "")
# If found, add path to cmake variable
# ------------------------------------
foreach(ptscotch_lib ${PTSCOTCH_libs_to_find})
if (PTSCOTCH_${ptscotch_lib}_LIBRARY)
get_filename_component(${ptscotch_lib}_lib_path "${PTSCOTCH_${ptscotch_lib}_LIBRARY}" PATH)
# set cmake variables
list(APPEND PTSCOTCH_LIBRARIES "${PTSCOTCH_${ptscotch_lib}_LIBRARY}")
list(APPEND PTSCOTCH_LIBRARY_DIRS "${${ptscotch_lib}_lib_path}")
else ()
list(APPEND PTSCOTCH_LIBRARIES "${PTSCOTCH_${ptscotch_lib}_LIBRARY}")
if (NOT PTSCOTCH_FIND_QUIETLY)
message(STATUS "Looking for ptscotch -- lib ${ptscotch_lib} not found")
endif()
endif ()
mark_as_advanced(PTSCOTCH_${ptscotch_lib}_LIBRARY)
endforeach()
list(REMOVE_DUPLICATES PTSCOTCH_LIBRARY_DIRS)
# check a function to validate the find
if(PTSCOTCH_LIBRARIES)
set(REQUIRED_LDFLAGS)
set(REQUIRED_INCDIRS)
set(REQUIRED_LIBDIRS)
set(REQUIRED_LIBS)
# PTSCOTCH
if (PTSCOTCH_INCLUDE_DIRS)
set(REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS}")
endif()
if (PTSCOTCH_LIBRARY_DIRS)
set(REQUIRED_LIBDIRS "${PTSCOTCH_LIBRARY_DIRS}")
endif()
set(REQUIRED_LIBS "${PTSCOTCH_LIBRARIES}")
# MPI
if (MPI_FOUND)
if (MPI_C_INCLUDE_PATH)
list(APPEND CMAKE_REQUIRED_INCLUDES "${MPI_C_INCLUDE_PATH}")
endif()
if (MPI_C_LINK_FLAGS)
if (${MPI_C_LINK_FLAGS} MATCHES " -")
string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS})
endif()
list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}")
endif()
list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}")
endif()
# THREADS
if(CMAKE_THREAD_LIBS_INIT)
list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}")
endif()
set(Z_LIBRARY "Z_LIBRARY-NOTFOUND")
find_library(Z_LIBRARY NAMES z)
mark_as_advanced(Z_LIBRARY)
if(Z_LIBRARY)
list(APPEND REQUIRED_LIBS "-lz")
endif()
set(M_LIBRARY "M_LIBRARY-NOTFOUND")
find_library(M_LIBRARY NAMES m)
mark_as_advanced(M_LIBRARY)
if(M_LIBRARY)
list(APPEND REQUIRED_LIBS "-lm")
endif()
set(RT_LIBRARY "RT_LIBRARY-NOTFOUND")
find_library(RT_LIBRARY NAMES rt)
mark_as_advanced(RT_LIBRARY)
if(RT_LIBRARY)
list(APPEND REQUIRED_LIBS "-lrt")
endif()
# set required libraries for link
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
set(CMAKE_REQUIRED_LIBRARIES)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
foreach(lib_dir ${REQUIRED_LIBDIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
endforeach()
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
list(APPEND CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
# test link
unset(PTSCOTCH_WORKS CACHE)
include(CheckFunctionExists)
check_function_exists(SCOTCH_dgraphInit PTSCOTCH_WORKS)
mark_as_advanced(PTSCOTCH_WORKS)
if(PTSCOTCH_WORKS)
# save link with dependencies
set(PTSCOTCH_LIBRARIES_DEP "${REQUIRED_LIBS}")
set(PTSCOTCH_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
set(PTSCOTCH_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
set(PTSCOTCH_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
list(REMOVE_DUPLICATES PTSCOTCH_LIBRARY_DIRS_DEP)
list(REMOVE_DUPLICATES PTSCOTCH_INCLUDE_DIRS_DEP)
list(REMOVE_DUPLICATES PTSCOTCH_LINKER_FLAGS)
else()
if(NOT PTSCOTCH_FIND_QUIETLY)
message(STATUS "Looking for PTSCOTCH : test of SCOTCH_dgraphInit with PTSCOTCH library fails")
message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
endif()
endif()
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_LIBRARIES)
endif(PTSCOTCH_LIBRARIES)
if (PTSCOTCH_LIBRARIES)
list(GET PTSCOTCH_LIBRARIES 0 first_lib)
get_filename_component(first_lib_path "${first_lib}" PATH)
if (${first_lib_path} MATCHES "/lib(32|64)?$")
string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}")
set(PTSCOTCH_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PTSCOTCH library" FORCE)
else()
set(PTSCOTCH_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of PTSCOTCH library" FORCE)
endif()
endif()
mark_as_advanced(PTSCOTCH_DIR)
mark_as_advanced(PTSCOTCH_DIR_FOUND)
# Check the size of SCOTCH_Num
# ---------------------------------
set(CMAKE_REQUIRED_INCLUDES ${PTSCOTCH_INCLUDE_DIRS})
include(CheckCSourceRuns)
#stdio.h and stdint.h should be included by scotch.h directly
set(PTSCOTCH_C_TEST_SCOTCH_Num_4 "
#include <stdio.h>
#include <stdint.h>
#include <ptscotch.h>
int main(int argc, char **argv) {
if (sizeof(SCOTCH_Num) == 4)
return 0;
else
return 1;
}
")
set(PTSCOTCH_C_TEST_SCOTCH_Num_8 "
#include <stdio.h>
#include <stdint.h>
#include <ptscotch.h>
int main(int argc, char **argv) {
if (sizeof(SCOTCH_Num) == 8)
return 0;
else
return 1;
}
")
check_c_source_runs("${PTSCOTCH_C_TEST_SCOTCH_Num_4}" PTSCOTCH_Num_4)
if(NOT PTSCOTCH_Num_4)
check_c_source_runs("${PTSCOTCH_C_TEST_SCOTCH_Num_8}" PTSCOTCH_Num_8)
if(NOT PTSCOTCH_Num_8)
set(PTSCOTCH_INTSIZE -1)
else()
set(PTSCOTCH_INTSIZE 8)
endif()
else()
set(PTSCOTCH_INTSIZE 4)
endif()
set(CMAKE_REQUIRED_INCLUDES "")
# check that PTSCOTCH has been found
# ---------------------------------
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PTSCOTCH DEFAULT_MSG
PTSCOTCH_LIBRARIES
PTSCOTCH_WORKS)
#
# TODO: Add possibility to check for specific functions in the library
#

View File

@ -1,25 +1,704 @@
# Pastix lib requires linking to a blas library.
# It is up to the user of this module to find a BLAS and link to it.
# Pastix requires SCOTCH or METIS (partitioning and reordering tools) as well
###
#
# @copyright (c) 2009-2014 The University of Tennessee and The University
# of Tennessee Research Foundation.
# All rights reserved.
# @copyright (c) 2012-2014 Inria. All rights reserved.
# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
#
###
#
# - Find PASTIX include dirs and libraries
# Use this module by invoking find_package with the form:
# find_package(PASTIX
# [REQUIRED] # Fail with error if pastix is not found
# [COMPONENTS <comp1> <comp2> ...] # dependencies
# )
#
# PASTIX depends on the following libraries:
# - Threads, m, rt
# - MPI
# - HWLOC
# - BLAS
#
# COMPONENTS are optional libraries PASTIX could be linked with,
# Use it to drive detection of a specific compilation chain
# COMPONENTS can be some of the following:
# - MPI: to activate detection of the parallel MPI version (default)
# it looks for Threads, HWLOC, BLAS, MPI and ScaLAPACK libraries
# - SEQ: to activate detection of the sequential version (exclude MPI version)
# - STARPU: to activate detection of StarPU version
# it looks for MPI version of StarPU (default behaviour)
# if SEQ and STARPU are given, it looks for a StarPU without MPI
# - STARPU_CUDA: to activate detection of StarPU with CUDA
# - STARPU_FXT: to activate detection of StarPU with FxT
# - SCOTCH: to activate detection of PASTIX linked with SCOTCH
# - PTSCOTCH: to activate detection of PASTIX linked with SCOTCH
# - METIS: to activate detection of PASTIX linked with SCOTCH
#
# This module finds headers and pastix library.
# Results are reported in variables:
# PASTIX_FOUND - True if headers and requested libraries were found
# PASTIX_LINKER_FLAGS - list of required linker flags (excluding -l and -L)
# PASTIX_INCLUDE_DIRS - pastix include directories
# PASTIX_LIBRARY_DIRS - Link directories for pastix libraries
# PASTIX_LIBRARIES - pastix libraries
# PASTIX_INCLUDE_DIRS_DEP - pastix + dependencies include directories
# PASTIX_LIBRARY_DIRS_DEP - pastix + dependencies link directories
# PASTIX_LIBRARIES_DEP - pastix libraries + dependencies
#
# The user can give specific paths where to find the libraries adding cmake
# options at configure (ex: cmake path/to/project -DPASTIX_DIR=path/to/pastix):
# PASTIX_DIR - Where to find the base directory of pastix
# PASTIX_INCDIR - Where to find the header files
# PASTIX_LIBDIR - Where to find the library files
# The module can also look for the following environment variables if paths
# are not given as cmake variable: PASTIX_DIR, PASTIX_INCDIR, PASTIX_LIBDIR
if (PASTIX_INCLUDES AND PASTIX_LIBRARIES)
set(PASTIX_FIND_QUIETLY TRUE)
endif (PASTIX_INCLUDES AND PASTIX_LIBRARIES)
#=============================================================================
# Copyright 2012-2013 Inria
# Copyright 2012-2013 Emmanuel Agullo
# Copyright 2012-2013 Mathieu Faverge
# Copyright 2012 Cedric Castagnede
# Copyright 2013 Florent Pruvost
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file MORSE-Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of Morse, substitute the full
# License text for the above reference.)
find_path(PASTIX_INCLUDES
NAMES
pastix_nompi.h
PATHS
$ENV{PASTIXDIR}
${INCLUDE_INSTALL_DIR}
if (NOT PASTIX_FOUND)
set(PASTIX_DIR "" CACHE PATH "Installation directory of PASTIX library")
if (NOT PASTIX_FIND_QUIETLY)
message(STATUS "A cache variable, namely PASTIX_DIR, has been set to specify the install directory of PASTIX")
endif()
endif()
# Set the version to find
set(PASTIX_LOOK_FOR_MPI ON)
set(PASTIX_LOOK_FOR_SEQ OFF)
set(PASTIX_LOOK_FOR_STARPU OFF)
set(PASTIX_LOOK_FOR_STARPU_CUDA OFF)
set(PASTIX_LOOK_FOR_STARPU_FXT OFF)
set(PASTIX_LOOK_FOR_SCOTCH ON)
set(PASTIX_LOOK_FOR_PTSCOTCH OFF)
set(PASTIX_LOOK_FOR_METIS OFF)
if( PASTIX_FIND_COMPONENTS )
foreach( component ${PASTIX_FIND_COMPONENTS} )
if (${component} STREQUAL "SEQ")
# means we look for the sequential version of PaStiX (without MPI)
set(PASTIX_LOOK_FOR_SEQ ON)
set(PASTIX_LOOK_FOR_MPI OFF)
endif()
if (${component} STREQUAL "MPI")
# means we look for the MPI version of PaStiX (default)
set(PASTIX_LOOK_FOR_SEQ OFF)
set(PASTIX_LOOK_FOR_MPI ON)
endif()
if (${component} STREQUAL "STARPU")
# means we look for PaStiX with StarPU
set(PASTIX_LOOK_FOR_STARPU ON)
endif()
if (${component} STREQUAL "STARPU_CUDA")
# means we look for PaStiX with StarPU + CUDA
set(PASTIX_LOOK_FOR_STARPU ON)
set(PASTIX_LOOK_FOR_STARPU_CUDA ON)
endif()
if (${component} STREQUAL "STARPU_FXT")
# means we look for PaStiX with StarPU + FxT
set(PASTIX_LOOK_FOR_STARPU_FXT ON)
endif()
if (${component} STREQUAL "SCOTCH")
set(PASTIX_LOOK_FOR_SCOTCH ON)
endif()
if (${component} STREQUAL "SCOTCH")
set(PASTIX_LOOK_FOR_PTSCOTCH ON)
endif()
if (${component} STREQUAL "METIS")
set(PASTIX_LOOK_FOR_METIS ON)
endif()
endforeach()
endif()
# Dependencies detection
# ----------------------
# Required dependencies
# ---------------------
if (NOT PASTIX_FIND_QUIETLY)
message(STATUS "Looking for PASTIX - Try to detect pthread")
endif()
if (PASTIX_FIND_REQUIRED)
find_package(Threads REQUIRED QUIET)
else()
find_package(Threads QUIET)
endif()
set(PASTIX_EXTRA_LIBRARIES "")
if( THREADS_FOUND )
list(APPEND PASTIX_EXTRA_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif ()
# Add math library to the list of extra
# it normally exists on all common systems provided with a C compiler
if (NOT PASTIX_FIND_QUIETLY)
message(STATUS "Looking for PASTIX - Try to detect libm")
endif()
set(PASTIX_M_LIBRARIES "")
if(UNIX OR WIN32)
find_library(
PASTIX_M_m_LIBRARY
NAMES m
)
mark_as_advanced(PASTIX_M_m_LIBRARY)
if (PASTIX_M_m_LIBRARY)
list(APPEND PASTIX_M_LIBRARIES "${PASTIX_M_m_LIBRARY}")
list(APPEND PASTIX_EXTRA_LIBRARIES "${PASTIX_M_m_LIBRARY}")
else()
if (PASTIX_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find libm on your system."
"Are you sure to a have a C compiler installed?")
endif()
endif()
endif()
find_library(PASTIX_LIBRARIES pastix PATHS $ENV{PASTIXDIR} ${LIB_INSTALL_DIR})
# Try to find librt (libposix4 - POSIX.1b Realtime Extensions library)
# on Unix systems except Apple ones because it does not exist on it
if (NOT PASTIX_FIND_QUIETLY)
message(STATUS "Looking for PASTIX - Try to detect librt")
endif()
set(PASTIX_RT_LIBRARIES "")
if(UNIX AND NOT APPLE)
find_library(
PASTIX_RT_rt_LIBRARY
NAMES rt
)
mark_as_advanced(PASTIX_RT_rt_LIBRARY)
if (PASTIX_RT_rt_LIBRARY)
list(APPEND PASTIX_RT_LIBRARIES "${PASTIX_RT_rt_LIBRARY}")
list(APPEND PASTIX_EXTRA_LIBRARIES "${PASTIX_RT_rt_LIBRARY}")
else()
if (PASTIX_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find librt on your system")
endif()
endif()
endif()
# PASTIX depends on HWLOC
#------------------------
if (NOT PASTIX_FIND_QUIETLY)
message(STATUS "Looking for PASTIX - Try to detect HWLOC")
endif()
if (PASTIX_FIND_REQUIRED)
find_package(HWLOC REQUIRED QUIET)
else()
find_package(HWLOC QUIET)
endif()
# PASTIX depends on BLAS
#-----------------------
if (NOT PASTIX_FIND_QUIETLY)
message(STATUS "Looking for PASTIX - Try to detect BLAS")
endif()
if (PASTIX_FIND_REQUIRED)
find_package(BLASEXT REQUIRED QUIET)
else()
find_package(BLASEXT QUIET)
endif()
# Optional dependencies
# ---------------------
# PASTIX may depend on MPI
#-------------------------
if (NOT MPI_FOUND AND PASTIX_LOOK_FOR_MPI)
if (NOT PASTIX_FIND_QUIETLY)
message(STATUS "Looking for PASTIX - Try to detect MPI")
endif()
# allows to use an external mpi compilation by setting compilers with
# -DMPI_C_COMPILER=path/to/mpicc -DMPI_Fortran_COMPILER=path/to/mpif90
# at cmake configure
if(NOT MPI_C_COMPILER)
set(MPI_C_COMPILER mpicc)
endif()
if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_MPI)
find_package(MPI REQUIRED QUIET)
else()
find_package(MPI QUIET)
endif()
if (MPI_FOUND)
mark_as_advanced(MPI_LIBRARY)
mark_as_advanced(MPI_EXTRA_LIBRARY)
endif()
endif (NOT MPI_FOUND AND PASTIX_LOOK_FOR_MPI)
# PASTIX may depend on STARPU
#----------------------------
if( NOT STARPU_FOUND AND PASTIX_LOOK_FOR_STARPU)
if (NOT PASTIX_FIND_QUIETLY)
message(STATUS "Looking for PASTIX - Try to detect StarPU")
endif()
set(PASTIX_STARPU_VERSION "1.1" CACHE STRING "oldest STARPU version desired")
# create list of components in order to make a single call to find_package(starpu...)
# we explicitly need a StarPU version built with hwloc
set(STARPU_COMPONENT_LIST "HWLOC")
# StarPU may depend on MPI
# allows to use an external mpi compilation by setting compilers with
# -DMPI_C_COMPILER=path/to/mpicc -DMPI_Fortran_COMPILER=path/to/mpif90
# at cmake configure
if (PASTIX_LOOK_FOR_MPI)
if(NOT MPI_C_COMPILER)
set(MPI_C_COMPILER mpicc)
endif()
list(APPEND STARPU_COMPONENT_LIST "MPI")
endif()
if (PASTIX_LOOK_FOR_STARPU_CUDA)
list(APPEND STARPU_COMPONENT_LIST "CUDA")
endif()
if (PASTIX_LOOK_FOR_STARPU_FXT)
list(APPEND STARPU_COMPONENT_LIST "FXT")
endif()
# set the list of optional dependencies we may discover
if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_STARPU)
find_package(STARPU ${PASTIX_STARPU_VERSION} REQUIRED
COMPONENTS ${STARPU_COMPONENT_LIST})
else()
find_package(STARPU ${PASTIX_STARPU_VERSION}
COMPONENTS ${STARPU_COMPONENT_LIST})
endif()
endif( NOT STARPU_FOUND AND PASTIX_LOOK_FOR_STARPU)
# PASTIX may depends on SCOTCH
#-----------------------------
if (NOT SCOTCH_FOUND AND PASTIX_LOOK_FOR_SCOTCH)
if (NOT PASTIX_FIND_QUIETLY)
message(STATUS "Looking for PASTIX - Try to detect SCOTCH")
endif()
if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_SCOTCH)
find_package(SCOTCH REQUIRED QUIET)
else()
find_package(SCOTCH QUIET)
endif()
endif()
# PASTIX may depends on PTSCOTCH
#-------------------------------
if (NOT PTSCOTCH_FOUND AND PASTIX_LOOK_FOR_PTSCOTCH)
if (NOT PASTIX_FIND_QUIETLY)
message(STATUS "Looking for PASTIX - Try to detect PTSCOTCH")
endif()
if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_PTSCOTCH)
find_package(PTSCOTCH REQUIRED QUIET)
else()
find_package(PTSCOTCH QUIET)
endif()
endif()
# PASTIX may depends on METIS
#----------------------------
if (NOT METIS_FOUND AND PASTIX_LOOK_FOR_METIS)
if (NOT PASTIX_FIND_QUIETLY)
message(STATUS "Looking for PASTIX - Try to detect METIS")
endif()
if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_METIS)
find_package(METIS REQUIRED QUIET)
else()
find_package(METIS QUIET)
endif()
endif()
# Error if pastix required and no partitioning lib found
if (PASTIX_FIND_REQUIRED AND NOT SCOTCH_FOUND AND NOT PTSCOTCH_FOUND AND NOT METIS_FOUND)
message(FATAL_ERROR "Could NOT find any partitioning library on your system"
" (install scotch, ptscotch or metis)")
endif()
# Looking for PaStiX
# ------------------
# Looking for include
# -------------------
# Add system include paths to search include
# ------------------------------------------
unset(_inc_env)
set(ENV_PASTIX_DIR "$ENV{PASTIX_DIR}")
set(ENV_PASTIX_INCDIR "$ENV{PASTIX_INCDIR}")
if(ENV_PASTIX_INCDIR)
list(APPEND _inc_env "${ENV_PASTIX_INCDIR}")
elseif(ENV_PASTIX_DIR)
list(APPEND _inc_env "${ENV_PASTIX_DIR}")
list(APPEND _inc_env "${ENV_PASTIX_DIR}/include")
list(APPEND _inc_env "${ENV_PASTIX_DIR}/include/pastix")
else()
if(WIN32)
string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
else()
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{CPATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
endif()
endif()
list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
list(REMOVE_DUPLICATES _inc_env)
# Try to find the pastix header in the given paths
# ---------------------------------------------------
# call cmake macro to find the header path
if(PASTIX_INCDIR)
set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND")
find_path(PASTIX_pastix.h_DIRS
NAMES pastix.h
HINTS ${PASTIX_INCDIR})
else()
if(PASTIX_DIR)
set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND")
find_path(PASTIX_pastix.h_DIRS
NAMES pastix.h
HINTS ${PASTIX_DIR}
PATH_SUFFIXES "include" "include/pastix")
else()
set(PASTIX_pastix.h_DIRS "PASTIX_pastix.h_DIRS-NOTFOUND")
find_path(PASTIX_pastix.h_DIRS
NAMES pastix.h
HINTS ${_inc_env}
PATH_SUFFIXES "pastix")
endif()
endif()
mark_as_advanced(PASTIX_pastix.h_DIRS)
# If found, add path to cmake variable
# ------------------------------------
if (PASTIX_pastix.h_DIRS)
set(PASTIX_INCLUDE_DIRS "${PASTIX_pastix.h_DIRS}")
else ()
set(PASTIX_INCLUDE_DIRS "PASTIX_INCLUDE_DIRS-NOTFOUND")
if(NOT PASTIX_FIND_QUIETLY)
message(STATUS "Looking for pastix -- pastix.h not found")
endif()
endif()
# Looking for lib
# ---------------
# Add system library paths to search lib
# --------------------------------------
unset(_lib_env)
set(ENV_PASTIX_LIBDIR "$ENV{PASTIX_LIBDIR}")
if(ENV_PASTIX_LIBDIR)
list(APPEND _lib_env "${ENV_PASTIX_LIBDIR}")
elseif(ENV_PASTIX_DIR)
list(APPEND _lib_env "${ENV_PASTIX_DIR}")
list(APPEND _lib_env "${ENV_PASTIX_DIR}/lib")
else()
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
else()
if(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
endif()
list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
endif()
endif()
list(REMOVE_DUPLICATES _lib_env)
# Try to find the pastix lib in the given paths
# ------------------------------------------------
# create list of libs to find
set(PASTIX_libs_to_find "pastix_murge;pastix")
# call cmake macro to find the lib path
if(PASTIX_LIBDIR)
foreach(pastix_lib ${PASTIX_libs_to_find})
set(PASTIX_${pastix_lib}_LIBRARY "PASTIX_${pastix_lib}_LIBRARY-NOTFOUND")
find_library(PASTIX_${pastix_lib}_LIBRARY
NAMES ${pastix_lib}
HINTS ${PASTIX_LIBDIR})
endforeach()
else()
if(PASTIX_DIR)
foreach(pastix_lib ${PASTIX_libs_to_find})
set(PASTIX_${pastix_lib}_LIBRARY "PASTIX_${pastix_lib}_LIBRARY-NOTFOUND")
find_library(PASTIX_${pastix_lib}_LIBRARY
NAMES ${pastix_lib}
HINTS ${PASTIX_DIR}
PATH_SUFFIXES lib lib32 lib64)
endforeach()
else()
foreach(pastix_lib ${PASTIX_libs_to_find})
set(PASTIX_${pastix_lib}_LIBRARY "PASTIX_${pastix_lib}_LIBRARY-NOTFOUND")
find_library(PASTIX_${pastix_lib}_LIBRARY
NAMES ${pastix_lib}
HINTS ${_lib_env})
endforeach()
endif()
endif()
# If found, add path to cmake variable
# ------------------------------------
foreach(pastix_lib ${PASTIX_libs_to_find})
get_filename_component(${pastix_lib}_lib_path ${PASTIX_${pastix_lib}_LIBRARY} PATH)
# set cmake variables (respects naming convention)
if (PASTIX_LIBRARIES)
list(APPEND PASTIX_LIBRARIES "${PASTIX_${pastix_lib}_LIBRARY}")
else()
set(PASTIX_LIBRARIES "${PASTIX_${pastix_lib}_LIBRARY}")
endif()
if (PASTIX_LIBRARY_DIRS)
list(APPEND PASTIX_LIBRARY_DIRS "${${pastix_lib}_lib_path}")
else()
set(PASTIX_LIBRARY_DIRS "${${pastix_lib}_lib_path}")
endif()
mark_as_advanced(PASTIX_${pastix_lib}_LIBRARY)
endforeach(pastix_lib ${PASTIX_libs_to_find})
# check a function to validate the find
if(PASTIX_LIBRARIES)
set(REQUIRED_LDFLAGS)
set(REQUIRED_INCDIRS)
set(REQUIRED_LIBDIRS)
set(REQUIRED_LIBS)
# PASTIX
if (PASTIX_INCLUDE_DIRS)
set(REQUIRED_INCDIRS "${PASTIX_INCLUDE_DIRS}")
endif()
foreach(libdir ${PASTIX_LIBRARY_DIRS})
if (libdir)
list(APPEND REQUIRED_LIBDIRS "${libdir}")
endif()
endforeach()
set(REQUIRED_LIBS "${PASTIX_LIBRARIES}")
# STARPU
if (PASTIX_LOOK_FOR_STARPU AND STARPU_FOUND)
if (STARPU_INCLUDE_DIRS_DEP)
list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS_DEP}")
elseif (STARPU_INCLUDE_DIRS)
list(APPEND REQUIRED_INCDIRS "${STARPU_INCLUDE_DIRS}")
endif()
if(STARPU_LIBRARY_DIRS_DEP)
list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS_DEP}")
elseif(STARPU_LIBRARY_DIRS)
list(APPEND REQUIRED_LIBDIRS "${STARPU_LIBRARY_DIRS}")
endif()
if (STARPU_LIBRARIES_DEP)
list(APPEND REQUIRED_LIBS "${STARPU_LIBRARIES_DEP}")
elseif (STARPU_LIBRARIES)
foreach(lib ${STARPU_LIBRARIES})
if (EXISTS ${lib} OR ${lib} MATCHES "^-")
list(APPEND REQUIRED_LIBS "${lib}")
else()
list(APPEND REQUIRED_LIBS "-l${lib}")
endif()
endforeach()
endif()
endif()
# CUDA
if (PASTIX_LOOK_FOR_STARPU_CUDA AND CUDA_FOUND)
if (CUDA_INCLUDE_DIRS)
list(APPEND REQUIRED_INCDIRS "${CUDA_INCLUDE_DIRS}")
endif()
foreach(libdir ${CUDA_LIBRARY_DIRS})
if (libdir)
list(APPEND REQUIRED_LIBDIRS "${libdir}")
endif()
endforeach()
list(APPEND REQUIRED_LIBS "${CUDA_CUBLAS_LIBRARIES};${CUDA_LIBRARIES}")
endif()
# MPI
if (PASTIX_LOOK_FOR_MPI AND MPI_FOUND)
if (MPI_C_INCLUDE_PATH)
list(APPEND REQUIRED_INCDIRS "${MPI_C_INCLUDE_PATH}")
endif()
if (MPI_C_LINK_FLAGS)
if (${MPI_C_LINK_FLAGS} MATCHES " -")
string(REGEX REPLACE " -" "-" MPI_C_LINK_FLAGS ${MPI_C_LINK_FLAGS})
endif()
list(APPEND REQUIRED_LDFLAGS "${MPI_C_LINK_FLAGS}")
endif()
list(APPEND REQUIRED_LIBS "${MPI_C_LIBRARIES}")
endif()
# HWLOC
if (HWLOC_FOUND)
if (HWLOC_INCLUDE_DIRS)
list(APPEND REQUIRED_INCDIRS "${HWLOC_INCLUDE_DIRS}")
endif()
foreach(libdir ${HWLOC_LIBRARY_DIRS})
if (libdir)
list(APPEND REQUIRED_LIBDIRS "${libdir}")
endif()
endforeach()
foreach(lib ${HWLOC_LIBRARIES})
if (EXISTS ${lib} OR ${lib} MATCHES "^-")
list(APPEND REQUIRED_LIBS "${lib}")
else()
list(APPEND REQUIRED_LIBS "-l${lib}")
endif()
endforeach()
endif()
# BLAS
if (BLAS_FOUND)
if (BLAS_INCLUDE_DIRS)
list(APPEND REQUIRED_INCDIRS "${BLAS_INCLUDE_DIRS}")
endif()
foreach(libdir ${BLAS_LIBRARY_DIRS})
if (libdir)
list(APPEND REQUIRED_LIBDIRS "${libdir}")
endif()
endforeach()
list(APPEND REQUIRED_LIBS "${BLAS_LIBRARIES}")
if (BLAS_LINKER_FLAGS)
list(APPEND REQUIRED_LDFLAGS "${BLAS_LINKER_FLAGS}")
endif()
endif()
# SCOTCH
if (PASTIX_LOOK_FOR_SCOTCH AND SCOTCH_FOUND)
if (SCOTCH_INCLUDE_DIRS)
list(APPEND REQUIRED_INCDIRS "${SCOTCH_INCLUDE_DIRS}")
endif()
foreach(libdir ${SCOTCH_LIBRARY_DIRS})
if (libdir)
list(APPEND REQUIRED_LIBDIRS "${libdir}")
endif()
endforeach()
list(APPEND REQUIRED_LIBS "${SCOTCH_LIBRARIES}")
endif()
# PTSCOTCH
if (PASTIX_LOOK_FOR_PTSCOTCH AND PTSCOTCH_FOUND)
if (PTSCOTCH_INCLUDE_DIRS)
list(APPEND REQUIRED_INCDIRS "${PTSCOTCH_INCLUDE_DIRS}")
endif()
foreach(libdir ${PTSCOTCH_LIBRARY_DIRS})
if (libdir)
list(APPEND REQUIRED_LIBDIRS "${libdir}")
endif()
endforeach()
list(APPEND REQUIRED_LIBS "${PTSCOTCH_LIBRARIES}")
endif()
# METIS
if (PASTIX_LOOK_FOR_METIS AND METIS_FOUND)
if (METIS_INCLUDE_DIRS)
list(APPEND REQUIRED_INCDIRS "${METIS_INCLUDE_DIRS}")
endif()
foreach(libdir ${METIS_LIBRARY_DIRS})
if (libdir)
list(APPEND REQUIRED_LIBDIRS "${libdir}")
endif()
endforeach()
list(APPEND REQUIRED_LIBS "${METIS_LIBRARIES}")
endif()
# Fortran
if (CMAKE_C_COMPILER_ID MATCHES "GNU")
find_library(
FORTRAN_gfortran_LIBRARY
NAMES gfortran
HINTS ${_lib_env}
)
mark_as_advanced(FORTRAN_gfortran_LIBRARY)
if (FORTRAN_gfortran_LIBRARY)
list(APPEND REQUIRED_LIBS "${FORTRAN_gfortran_LIBRARY}")
endif()
elseif (CMAKE_C_COMPILER_ID MATCHES "Intel")
find_library(
FORTRAN_ifcore_LIBRARY
NAMES ifcore
HINTS ${_lib_env}
)
mark_as_advanced(FORTRAN_ifcore_LIBRARY)
if (FORTRAN_ifcore_LIBRARY)
list(APPEND REQUIRED_LIBS "${FORTRAN_ifcore_LIBRARY}")
endif()
endif()
# EXTRA LIBS such that pthread, m, rt
list(APPEND REQUIRED_LIBS ${PASTIX_EXTRA_LIBRARIES})
# set required libraries for link
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
set(CMAKE_REQUIRED_LIBRARIES)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LDFLAGS}")
foreach(lib_dir ${REQUIRED_LIBDIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
endforeach()
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
list(APPEND CMAKE_REQUIRED_FLAGS "${REQUIRED_FLAGS}")
string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
# test link
unset(PASTIX_WORKS CACHE)
include(CheckFunctionExists)
check_function_exists(pastix PASTIX_WORKS)
mark_as_advanced(PASTIX_WORKS)
if(PASTIX_WORKS)
# save link with dependencies
set(PASTIX_LIBRARIES_DEP "${REQUIRED_LIBS}")
set(PASTIX_LIBRARY_DIRS_DEP "${REQUIRED_LIBDIRS}")
set(PASTIX_INCLUDE_DIRS_DEP "${REQUIRED_INCDIRS}")
set(PASTIX_LINKER_FLAGS "${REQUIRED_LDFLAGS}")
list(REMOVE_DUPLICATES PASTIX_LIBRARY_DIRS_DEP)
list(REMOVE_DUPLICATES PASTIX_INCLUDE_DIRS_DEP)
list(REMOVE_DUPLICATES PASTIX_LINKER_FLAGS)
else()
if(NOT PASTIX_FIND_QUIETLY)
message(STATUS "Looking for PASTIX : test of pastix() fails")
message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
message(STATUS "Maybe PASTIX is linked with specific libraries. "
"Have you tried with COMPONENTS (MPI/SEQ, STARPU, STARPU_CUDA, SCOTCH, PTSCOTCH, METIS)? "
"See the explanation in FindPASTIX.cmake.")
endif()
endif()
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_LIBRARIES)
endif(PASTIX_LIBRARIES)
if (PASTIX_LIBRARIES)
list(GET PASTIX_LIBRARIES 0 first_lib)
get_filename_component(first_lib_path "${first_lib}" PATH)
if (${first_lib_path} MATCHES "/lib(32|64)?$")
string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}")
set(PASTIX_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of PASTIX library" FORCE)
else()
set(PASTIX_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of PASTIX library" FORCE)
endif()
endif()
mark_as_advanced(PASTIX_DIR)
mark_as_advanced(PASTIX_DIR_FOUND)
# check that PASTIX has been found
# ---------------------------------
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PASTIX DEFAULT_MSG
PASTIX_INCLUDES PASTIX_LIBRARIES)
mark_as_advanced(PASTIX_INCLUDES PASTIX_LIBRARIES)
PASTIX_LIBRARIES
PASTIX_WORKS)

View File

@ -1,24 +1,369 @@
# Pastix requires SCOTCH or METIS (partitioning and reordering tools)
###
#
# @copyright (c) 2009-2014 The University of Tennessee and The University
# of Tennessee Research Foundation.
# All rights reserved.
# @copyright (c) 2012-2014 Inria. All rights reserved.
# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
#
###
#
# - Find SCOTCH include dirs and libraries
# Use this module by invoking find_package with the form:
# find_package(SCOTCH
# [REQUIRED] # Fail with error if scotch is not found
# [COMPONENTS <comp1> <comp2> ...] # dependencies
# )
#
# COMPONENTS can be some of the following:
# - ESMUMPS: to activate detection of Scotch with the esmumps interface
#
# This module finds headers and scotch library.
# Results are reported in variables:
# SCOTCH_FOUND - True if headers and requested libraries were found
# SCOTCH_INCLUDE_DIRS - scotch include directories
# SCOTCH_LIBRARY_DIRS - Link directories for scotch libraries
# SCOTCH_LIBRARIES - scotch component libraries to be linked
# SCOTCH_INTSIZE - Number of octets occupied by a SCOTCH_Num
#
# The user can give specific paths where to find the libraries adding cmake
# options at configure (ex: cmake path/to/project -DSCOTCH=path/to/scotch):
# SCOTCH_DIR - Where to find the base directory of scotch
# SCOTCH_INCDIR - Where to find the header files
# SCOTCH_LIBDIR - Where to find the library files
# The module can also look for the following environment variables if paths
# are not given as cmake variable: SCOTCH_DIR, SCOTCH_INCDIR, SCOTCH_LIBDIR
if (SCOTCH_INCLUDES AND SCOTCH_LIBRARIES)
set(SCOTCH_FIND_QUIETLY TRUE)
endif (SCOTCH_INCLUDES AND SCOTCH_LIBRARIES)
#=============================================================================
# Copyright 2012-2013 Inria
# Copyright 2012-2013 Emmanuel Agullo
# Copyright 2012-2013 Mathieu Faverge
# Copyright 2012 Cedric Castagnede
# Copyright 2013 Florent Pruvost
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file MORSE-Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of Morse, substitute the full
# License text for the above reference.)
find_path(SCOTCH_INCLUDES
NAMES
scotch.h
PATHS
$ENV{SCOTCHDIR}
${INCLUDE_INSTALL_DIR}
PATH_SUFFIXES
scotch
)
if (NOT SCOTCH_FOUND)
set(SCOTCH_DIR "" CACHE PATH "Installation directory of SCOTCH library")
if (NOT SCOTCH_FIND_QUIETLY)
message(STATUS "A cache variable, namely SCOTCH_DIR, has been set to specify the install directory of SCOTCH")
endif()
endif()
# Set the version to find
set(SCOTCH_LOOK_FOR_ESMUMPS OFF)
if( SCOTCH_FIND_COMPONENTS )
foreach( component ${SCOTCH_FIND_COMPONENTS} )
if (${component} STREQUAL "ESMUMPS")
# means we look for esmumps library
set(SCOTCH_LOOK_FOR_ESMUMPS ON)
endif()
endforeach()
endif()
# SCOTCH may depend on Threads, try to find it
if (NOT THREADS_FOUND)
if (SCOTCH_FIND_REQUIRED)
find_package(Threads REQUIRED)
else()
find_package(Threads)
endif()
endif()
# Looking for include
# -------------------
# Add system include paths to search include
# ------------------------------------------
unset(_inc_env)
set(ENV_SCOTCH_DIR "$ENV{SCOTCH_DIR}")
set(ENV_SCOTCH_INCDIR "$ENV{SCOTCH_INCDIR}")
if(ENV_SCOTCH_INCDIR)
list(APPEND _inc_env "${ENV_SCOTCH_INCDIR}")
elseif(ENV_SCOTCH_DIR)
list(APPEND _inc_env "${ENV_SCOTCH_DIR}")
list(APPEND _inc_env "${ENV_SCOTCH_DIR}/include")
list(APPEND _inc_env "${ENV_SCOTCH_DIR}/include/scotch")
else()
if(WIN32)
string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
else()
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{CPATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
endif()
endif()
list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
list(REMOVE_DUPLICATES _inc_env)
find_library(SCOTCH_LIBRARIES scotch PATHS $ENV{SCOTCHDIR} ${LIB_INSTALL_DIR})
# Try to find the scotch header in the given paths
# -------------------------------------------------
# call cmake macro to find the header path
if(SCOTCH_INCDIR)
set(SCOTCH_scotch.h_DIRS "SCOTCH_scotch.h_DIRS-NOTFOUND")
find_path(SCOTCH_scotch.h_DIRS
NAMES scotch.h
HINTS ${SCOTCH_INCDIR})
else()
if(SCOTCH_DIR)
set(SCOTCH_scotch.h_DIRS "SCOTCH_scotch.h_DIRS-NOTFOUND")
find_path(SCOTCH_scotch.h_DIRS
NAMES scotch.h
HINTS ${SCOTCH_DIR}
PATH_SUFFIXES "include" "include/scotch")
else()
set(SCOTCH_scotch.h_DIRS "SCOTCH_scotch.h_DIRS-NOTFOUND")
find_path(SCOTCH_scotch.h_DIRS
NAMES scotch.h
HINTS ${_inc_env}
PATH_SUFFIXES "scotch")
endif()
endif()
mark_as_advanced(SCOTCH_scotch.h_DIRS)
# If found, add path to cmake variable
# ------------------------------------
if (SCOTCH_scotch.h_DIRS)
set(SCOTCH_INCLUDE_DIRS "${SCOTCH_scotch.h_DIRS}")
else ()
set(SCOTCH_INCLUDE_DIRS "SCOTCH_INCLUDE_DIRS-NOTFOUND")
if (NOT SCOTCH_FIND_QUIETLY)
message(STATUS "Looking for scotch -- scotch.h not found")
endif()
endif()
list(REMOVE_DUPLICATES SCOTCH_INCLUDE_DIRS)
# Looking for lib
# ---------------
# Add system library paths to search lib
# --------------------------------------
unset(_lib_env)
set(ENV_SCOTCH_LIBDIR "$ENV{SCOTCH_LIBDIR}")
if(ENV_SCOTCH_LIBDIR)
list(APPEND _lib_env "${ENV_SCOTCH_LIBDIR}")
elseif(ENV_SCOTCH_DIR)
list(APPEND _lib_env "${ENV_SCOTCH_DIR}")
list(APPEND _lib_env "${ENV_SCOTCH_DIR}/lib")
else()
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
else()
if(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
endif()
list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
endif()
endif()
list(REMOVE_DUPLICATES _lib_env)
# Try to find the scotch lib in the given paths
# ----------------------------------------------
set(SCOTCH_libs_to_find "scotch;scotcherrexit")
if (SCOTCH_LOOK_FOR_ESMUMPS)
list(INSERT SCOTCH_libs_to_find 0 "esmumps")
endif()
# call cmake macro to find the lib path
if(SCOTCH_LIBDIR)
foreach(scotch_lib ${SCOTCH_libs_to_find})
set(SCOTCH_${scotch_lib}_LIBRARY "SCOTCH_${scotch_lib}_LIBRARY-NOTFOUND")
find_library(SCOTCH_${scotch_lib}_LIBRARY
NAMES ${scotch_lib}
HINTS ${SCOTCH_LIBDIR})
endforeach()
else()
if(SCOTCH_DIR)
foreach(scotch_lib ${SCOTCH_libs_to_find})
set(SCOTCH_${scotch_lib}_LIBRARY "SCOTCH_${scotch_lib}_LIBRARY-NOTFOUND")
find_library(SCOTCH_${scotch_lib}_LIBRARY
NAMES ${scotch_lib}
HINTS ${SCOTCH_DIR}
PATH_SUFFIXES lib lib32 lib64)
endforeach()
else()
foreach(scotch_lib ${SCOTCH_libs_to_find})
set(SCOTCH_${scotch_lib}_LIBRARY "SCOTCH_${scotch_lib}_LIBRARY-NOTFOUND")
find_library(SCOTCH_${scotch_lib}_LIBRARY
NAMES ${scotch_lib}
HINTS ${_lib_env})
endforeach()
endif()
endif()
set(SCOTCH_LIBRARIES "")
set(SCOTCH_LIBRARY_DIRS "")
# If found, add path to cmake variable
# ------------------------------------
foreach(scotch_lib ${SCOTCH_libs_to_find})
if (SCOTCH_${scotch_lib}_LIBRARY)
get_filename_component(${scotch_lib}_lib_path "${SCOTCH_${scotch_lib}_LIBRARY}" PATH)
# set cmake variables
list(APPEND SCOTCH_LIBRARIES "${SCOTCH_${scotch_lib}_LIBRARY}")
list(APPEND SCOTCH_LIBRARY_DIRS "${${scotch_lib}_lib_path}")
else ()
list(APPEND SCOTCH_LIBRARIES "${SCOTCH_${scotch_lib}_LIBRARY}")
if (NOT SCOTCH_FIND_QUIETLY)
message(STATUS "Looking for scotch -- lib ${scotch_lib} not found")
endif()
endif ()
mark_as_advanced(SCOTCH_${scotch_lib}_LIBRARY)
endforeach()
list(REMOVE_DUPLICATES SCOTCH_LIBRARY_DIRS)
# check a function to validate the find
if(SCOTCH_LIBRARIES)
set(REQUIRED_INCDIRS)
set(REQUIRED_LIBDIRS)
set(REQUIRED_LIBS)
# SCOTCH
if (SCOTCH_INCLUDE_DIRS)
set(REQUIRED_INCDIRS "${SCOTCH_INCLUDE_DIRS}")
endif()
if (SCOTCH_LIBRARY_DIRS)
set(REQUIRED_LIBDIRS "${SCOTCH_LIBRARY_DIRS}")
endif()
set(REQUIRED_LIBS "${SCOTCH_LIBRARIES}")
# THREADS
if(CMAKE_THREAD_LIBS_INIT)
list(APPEND REQUIRED_LIBS "${CMAKE_THREAD_LIBS_INIT}")
endif()
set(Z_LIBRARY "Z_LIBRARY-NOTFOUND")
find_library(Z_LIBRARY NAMES z)
mark_as_advanced(Z_LIBRARY)
if(Z_LIBRARY)
list(APPEND REQUIRED_LIBS "-lz")
endif()
set(M_LIBRARY "M_LIBRARY-NOTFOUND")
find_library(M_LIBRARY NAMES m)
mark_as_advanced(M_LIBRARY)
if(M_LIBRARY)
list(APPEND REQUIRED_LIBS "-lm")
endif()
set(RT_LIBRARY "RT_LIBRARY-NOTFOUND")
find_library(RT_LIBRARY NAMES rt)
mark_as_advanced(RT_LIBRARY)
if(RT_LIBRARY)
list(APPEND REQUIRED_LIBS "-lrt")
endif()
# set required libraries for link
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
set(CMAKE_REQUIRED_LIBRARIES)
foreach(lib_dir ${REQUIRED_LIBDIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
endforeach()
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
# test link
unset(SCOTCH_WORKS CACHE)
include(CheckFunctionExists)
check_function_exists(SCOTCH_graphInit SCOTCH_WORKS)
mark_as_advanced(SCOTCH_WORKS)
if(SCOTCH_WORKS)
# save link with dependencies
set(SCOTCH_LIBRARIES "${REQUIRED_LIBS}")
else()
if(NOT SCOTCH_FIND_QUIETLY)
message(STATUS "Looking for SCOTCH : test of SCOTCH_graphInit with SCOTCH library fails")
message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
endif()
endif()
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_LIBRARIES)
endif(SCOTCH_LIBRARIES)
if (SCOTCH_LIBRARIES)
list(GET SCOTCH_LIBRARIES 0 first_lib)
get_filename_component(first_lib_path "${first_lib}" PATH)
if (${first_lib_path} MATCHES "/lib(32|64)?$")
string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}")
set(SCOTCH_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of SCOTCH library" FORCE)
else()
set(SCOTCH_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of SCOTCH library" FORCE)
endif()
endif()
mark_as_advanced(SCOTCH_DIR)
mark_as_advanced(SCOTCH_DIR_FOUND)
# Check the size of SCOTCH_Num
# ---------------------------------
set(CMAKE_REQUIRED_INCLUDES ${SCOTCH_INCLUDE_DIRS})
include(CheckCSourceRuns)
#stdio.h and stdint.h should be included by scotch.h directly
set(SCOTCH_C_TEST_SCOTCH_Num_4 "
#include <stdio.h>
#include <stdint.h>
#include <scotch.h>
int main(int argc, char **argv) {
if (sizeof(SCOTCH_Num) == 4)
return 0;
else
return 1;
}
")
set(SCOTCH_C_TEST_SCOTCH_Num_8 "
#include <stdio.h>
#include <stdint.h>
#include <scotch.h>
int main(int argc, char **argv) {
if (sizeof(SCOTCH_Num) == 8)
return 0;
else
return 1;
}
")
check_c_source_runs("${SCOTCH_C_TEST_SCOTCH_Num_4}" SCOTCH_Num_4)
if(NOT SCOTCH_Num_4)
check_c_source_runs("${SCOTCH_C_TEST_SCOTCH_Num_8}" SCOTCH_Num_8)
if(NOT SCOTCH_Num_8)
set(SCOTCH_INTSIZE -1)
else()
set(SCOTCH_INTSIZE 8)
endif()
else()
set(SCOTCH_INTSIZE 4)
endif()
set(CMAKE_REQUIRED_INCLUDES "")
# check that SCOTCH has been found
# ---------------------------------
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SCOTCH DEFAULT_MSG
SCOTCH_INCLUDES SCOTCH_LIBRARIES)
mark_as_advanced(SCOTCH_INCLUDES SCOTCH_LIBRARIES)
SCOTCH_LIBRARIES
SCOTCH_WORKS)
#
# TODO: Add possibility to check for specific functions in the library
#

View File

@ -27,7 +27,7 @@ endif()
if(NOT EIGEN_Fortran_COMPILER_WORKS)
# search for a default Lapack library to complete Eigen's one
find_package(LAPACK)
find_package(LAPACK QUIET)
endif()
# configure blas/lapack (use Eigen's ones)
@ -80,23 +80,30 @@ else()
endif()
find_package(Pastix)
find_package(Scotch)
find_package(Metis 5.0 REQUIRED)
if(PASTIX_FOUND)
find_package(PASTIX QUIET COMPONENTS METIS SCOTCH)
# check that the PASTIX found is a version without MPI
find_path(PASTIX_pastix_nompi.h_INCLUDE_DIRS
NAMES pastix_nompi.h
HINTS ${PASTIX_INCLUDE_DIRS}
)
if (NOT PASTIX_pastix_nompi.h_INCLUDE_DIRS)
message(STATUS "A version of Pastix has been found but pastix_nompi.h does not exist in the include directory."
" Because Eigen tests require a version without MPI, we disable the Pastix backend.")
endif()
if(PASTIX_FOUND AND PASTIX_pastix_nompi.h_INCLUDE_DIRS)
add_definitions("-DEIGEN_PASTIX_SUPPORT")
include_directories(${PASTIX_INCLUDES})
include_directories(${PASTIX_INCLUDE_DIRS_DEP})
if(SCOTCH_FOUND)
include_directories(${SCOTCH_INCLUDES})
include_directories(${SCOTCH_INCLUDE_DIRS})
set(PASTIX_LIBRARIES ${PASTIX_LIBRARIES} ${SCOTCH_LIBRARIES})
elseif(METIS_FOUND)
include_directories(${METIS_INCLUDES})
include_directories(${METIS_INCLUDE_DIRS})
set(PASTIX_LIBRARIES ${PASTIX_LIBRARIES} ${METIS_LIBRARIES})
else(SCOTCH_FOUND)
ei_add_property(EIGEN_MISSING_BACKENDS "PaStiX, ")
endif(SCOTCH_FOUND)
set(SPARSE_LIBS ${SPARSE_LIBS} ${PASTIX_LIBRARIES} ${ORDERING_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
set(PASTIX_ALL_LIBS ${PASTIX_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
set(SPARSE_LIBS ${SPARSE_LIBS} ${PASTIX_LIBRARIES_DEP} ${ORDERING_LIBRARIES})
set(PASTIX_ALL_LIBS ${PASTIX_LIBRARIES_DEP})
ei_add_property(EIGEN_TESTED_BACKENDS "PaStiX, ")
else()
ei_add_property(EIGEN_MISSING_BACKENDS "PaStiX, ")
@ -104,7 +111,7 @@ endif()
if(METIS_FOUND)
add_definitions("-DEIGEN_METIS_SUPPORT")
include_directories(${METIS_INCLUDES})
include_directories(${METIS_INCLUDE_DIRS})
ei_add_property(EIGEN_TESTED_BACKENDS "METIS, ")
else()
ei_add_property(EIGEN_MISSING_BACKENDS "METIS, ")

View File

@ -297,6 +297,10 @@ template<typename SparseMatrixType> void sparse_product()
VERIFY_IS_APPROX(x=mLo.template selfadjointView<Lower>()*b, refX=refS*b);
VERIFY_IS_APPROX(x=mS.template selfadjointView<Upper|Lower>()*b, refX=refS*b);
VERIFY_IS_APPROX(x=b * mUp.template selfadjointView<Upper>(), refX=b*refS);
VERIFY_IS_APPROX(x=b * mLo.template selfadjointView<Lower>(), refX=b*refS);
VERIFY_IS_APPROX(x=b * mS.template selfadjointView<Upper|Lower>(), refX=b*refS);
VERIFY_IS_APPROX(x.noalias()+=mUp.template selfadjointView<Upper>()*b, refX+=refS*b);
VERIFY_IS_APPROX(x.noalias()-=mLo.template selfadjointView<Lower>()*b, refX-=refS*b);
VERIFY_IS_APPROX(x.noalias()+=mS.template selfadjointView<Upper|Lower>()*b, refX+=refS*b);

View File

@ -166,7 +166,8 @@ template <typename T> struct MeanReducer
return pset1<Packet>(initialize());
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T finalize(const T accum) const {
return accum / scalarCount_;
internal::scalar_quotient_op<T> quotient_op;
return quotient_op(accum, T(scalarCount_));
}
template <typename Packet>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet finalizePacket(const Packet& vaccum) const {
@ -175,7 +176,10 @@ template <typename T> struct MeanReducer
template <typename Packet>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T finalizeBoth(const T saccum, const Packet& vaccum) const {
internal::scalar_sum_op<T> sum_op;
return sum_op(saccum, predux(vaccum)) / (scalarCount_ + packetCount_ * unpacket_traits<Packet>::size);
internal::scalar_quotient_op<T> quotient_op;
return quotient_op(
sum_op(saccum, predux(vaccum)),
T(scalarCount_ + packetCount_ * unpacket_traits<Packet>::size));
}
protected:

View File

@ -107,6 +107,41 @@ static void test_cuda_sum_reductions() {
gpu_device.deallocate(gpu_out_ptr);
}
static void test_cuda_mean_reductions() {
Eigen::CudaStreamDevice stream;
Eigen::GpuDevice gpu_device(&stream);
const int num_rows = internal::random<int>(1024, 5*1024);
const int num_cols = internal::random<int>(1024, 5*1024);
Tensor<std::complex<float>, 2> in(num_rows, num_cols);
in.setRandom();
Tensor<std::complex<float>, 0> full_redux;
full_redux = in.mean();
std::size_t in_bytes = in.size() * sizeof(std::complex<float>);
std::size_t out_bytes = full_redux.size() * sizeof(std::complex<float>);
std::complex<float>* gpu_in_ptr = static_cast<std::complex<float>*>(gpu_device.allocate(in_bytes));
std::complex<float>* gpu_out_ptr = static_cast<std::complex<float>*>(gpu_device.allocate(out_bytes));
gpu_device.memcpyHostToDevice(gpu_in_ptr, in.data(), in_bytes);
TensorMap<Tensor<std::complex<float>, 2> > in_gpu(gpu_in_ptr, num_rows, num_cols);
TensorMap<Tensor<std::complex<float>, 0> > out_gpu(gpu_out_ptr);
out_gpu.device(gpu_device) = in_gpu.mean();
Tensor<std::complex<float>, 0> full_redux_gpu;
gpu_device.memcpyDeviceToHost(full_redux_gpu.data(), gpu_out_ptr, out_bytes);
gpu_device.synchronize();
// Check that the CPU and GPU reductions return the same result.
VERIFY_IS_APPROX(full_redux(), full_redux_gpu());
gpu_device.deallocate(gpu_in_ptr);
gpu_device.deallocate(gpu_out_ptr);
}
static void test_cuda_product_reductions() {
@ -149,5 +184,6 @@ void test_cxx11_tensor_complex()
{
CALL_SUBTEST(test_cuda_nullary());
CALL_SUBTEST(test_cuda_sum_reductions());
CALL_SUBTEST(test_cuda_mean_reductions());
CALL_SUBTEST(test_cuda_product_reductions());
}