Commit 16b3a43f authored by PRUVOST Florent's avatar PRUVOST Florent

add the ability to use BLAS/LAPACK/FFTW from IBM ESSL

parent 26421d22
......@@ -328,9 +328,10 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/morse/
# SYMBOL_NAMESPACE "PM_"
# SYMBOLS init testPPM:init)
message(STATUS "CMAKE_CXX_COMPILER_ID STREQUAL ${CMAKE_CXX_COMPILER_ID}")
option( SCALFMM_USE_MKL_AS_BLAS "Set to ON to use MKL CBLAS" OFF )
option( SCALFMM_USE_MKL_AS_BLAS "Set to ON to use MKL BLAS/LAPACK" OFF )
option( SCALFMM_USE_ESSL_AS_BLAS "Set to ON to use ESSL BLAS/LAPACK" OFF )
if( SCALFMM_USE_MKL_AS_BLAS )
set(BLA_VENDOR "Intel10_64lp_seq")
find_package(BLASEXT QUIET) # not REQUIRED
......@@ -338,6 +339,16 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/morse/
if (BLAS_LIBRARIES)
set(BLASLAPACK_LIBRARIES ${BLAS_LIBRARIES})
endif()
elseif(SCALFMM_USE_ESSL_AS_BLAS)
set(BLA_VENDOR "IBMESSL")
find_package(BLASEXT QUIET) # not REQUIRED
find_package(LAPACKEXT QUIET) # not REQUIRED
if (LAPACK_LIBRARIES)
set(BLASLAPACK_LIBRARIES "${LAPACK_LIBRARIES}")
endif()
if (BLAS_LIBRARIES)
list(APPEND BLASLAPACK_LIBRARIES ${BLAS_LIBRARIES})
endif()
elseif(SCALFMM_USE_EXTERNAL_BLAS)
message(STATUS "BLAS SET BY EXTERNAL PROGRAM = ${BLAS_LIBRARIES}")
list(APPEND BLASLAPACK_LIBRARIES "${BLAS_LIBRARIES}")
......@@ -352,7 +363,7 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/morse/
list(APPEND BLASLAPACK_LIBRARIES "${BLAS_LIBRARIES}")
endif()
endif()
if(BLAS_FOUND)
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};${BLASLAPACK_LIBRARIES}")
if(BLAS_LIBRARY_DIRS)
......@@ -363,6 +374,7 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/morse/
# the RPATH to be used when installing
list(APPEND CMAKE_INSTALL_RPATH "${LAPACK_LIBRARY_DIRS}")
endif()
message (STATUS "check BLAS Fortran mangling")
# check blas and lapack symbols naming
set(CMAKE_REQUIRED_LIBRARIES "${BLAS_LIBRARIES}")
check_function_exists(dgemv_ DGEMV_ADD_)
......@@ -374,19 +386,19 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/morse/
message (STATUS "BLAS dgemv_ symbol found, SCALFMM_BLAS_ADD_ is ON")
else (DGEMV_ADD_)
set (SCALFMM_BLAS_ADD_ OFF)
check_function_exists(DGEMV DGEMV_UPCASE)
if (DGEMV_UPCASE)
set (SCALFMM_BLAS_UPCASE ON)
message (STATUS "BLAS DGEMV symbol found, SCALFMM_BLAS_UPCASE is ON")
else (DGEMV_UPCASE)
# set (SCALFMM_BLAS_UPCASE OFF)
check_function_exists(DGEMV DGEMV_UPCASE)
if (DGEMV_UPCASE)
set (SCALFMM_BLAS_UPCASE ON)
message (STATUS "BLAS DGEMV symbol found, SCALFMM_BLAS_UPCASE is ON")
else (DGEMV_UPCASE)
# set (SCALFMM_BLAS_UPCASE OFF)
check_function_exists(dgemv DGEMV_NOCHANGE)
if (DGEMV_NOCHANGE)
set (SCALFMM_BLAS_NOCHANGE ON)
message (STATUS "BLAS dgemv symbol found, SCALFMM_BLAS_NOCHANGE is ON")
# else (DGEMV_NOCHANGE)
# set (SCALFMM_BLAS_NOCHANGE OFF)
endif (DGEMV_NOCHANGE)
# else (DGEMV_NOCHANGE)
# set (SCALFMM_BLAS_NOCHANGE OFF)
endif (DGEMV_NOCHANGE)
endif (DGEMV_UPCASE)
endif (DGEMV_ADD_)
if ( (NOT DGEMV_ADD_) AND (NOT DGEMV_UPCASE) AND (NOT DGEMV_NOCHANGE) )
......@@ -403,88 +415,59 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/morse/
#
# FFT option
#
CMAKE_DEPENDENT_OPTION(SCALFMM_USE_MKL_AS_FFTW "Set to ON to use MKL FFTW" ON "SCALFMM_USE_FFT;SCALFMM_USE_MKL_AS_BLAS" OFF )
CMAKE_DEPENDENT_OPTION(SCALFMM_USE_MKL_AS_FFTW "Set to ON to use MKL FFTW" ON "SCALFMM_USE_FFT;SCALFMM_USE_MKL_AS_BLAS" OFF )
CMAKE_DEPENDENT_OPTION(SCALFMM_USE_ESSL_AS_FFTW "Set to ON to use ESSL FFTW" ON "SCALFMM_USE_FFT;SCALFMM_USE_ESSL_AS_BLAS" OFF )
if( SCALFMM_USE_FFT )
message(STATUS "SCALFMM USE FFT Configure:")
# The package find_package(FFTW) can be used with the following COMPONENTS:
# MKL, ESSL, THREADS|OMP and/or SIMPLE|LONG|QUAD
# Default will find the real double precision fftw library version without THREADS|OMP
if( SCALFMM_USE_MKL_AS_FFTW )
message(STATUS " SCALFMM USE FFT from MKL")
find_package(FFTW COMPONENTS MKL)
elseif (SCALFMM_USE_ESSL_AS_FFTW)
message(STATUS " SCALFMM USE FFT from ESSL ")
find_package(FFTW COMPONENTS ESSL)
add_definitions(-DSCALFMM_USE_ESSL_AS_FFTW)
else()
message(STATUS " SCALFMM USE FFTW")
find_package(FFTW COMPONENTS SIMPLE)
endif()
message(STATUS " SCALFMM USE MKL ")
if( SCALFMM_USE_MKL_AS_BLAS )
unset(FFT_LIBRARIES CACHE)
message(STATUS " SCALFMM USE MKL already defined")
set(FFT_INCLUDES "$ENV{MKLROOT}/include/fftw" CACHE STRING "Set your MKL flags")
if (BLAS_FOUND)
set(FFTW_FOUND ON)
endif()
else(SCALFMM_USE_MKL_AS_BLAS)
# The package can be used with the following COMPONENTS:
# MKL, THREADS|OMP and/or SIMPLE|DOUBLE|LONG|QUAD
# Default is DOUBLE and without THREADS|OMP
find_package(FFTW COMPONENTS MKL) # not REQUIRED
if (FFTW_LIBRARY_DIRS_DEP)
set(FFT_LIBRARIES "-L${FFTW_LIBRARY_DIRS_DEP};" CACHE STRING "Set your MKL flags")
endif()
if (FFTW_LIBRARIES_DEP)
foreach (fft_lib ${FFTW_LIBRARIES_DEP})
set(FFT_LIBRARIES "${FFT_LIBRARIES};${fft_lib};")
endforeach()
endif()
set(FFT_INCLUDES "${FFTW_INCLUDE_DIRS_DEP}" )
if (FFT_LIBRARIES)
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};${FFT_LIBRARIES}")
endif()
endif(SCALFMM_USE_MKL_AS_BLAS)
else(SCALFMM_USE_MKL_AS_FFTW)
message(STATUS " SCALFMM USE FFTW ")
# The package can be used with the following COMPONENTS:
# MKL, THREADS|OMP and/or SIMPLE|DOUBLE|LONG|QUAD
# Default is DOUBLE and without THREADS|OMP
find_package(FFTW COMPONENTS SIMPLE) # not REQUIRED
if (FFTW_LIBRARY_DIRS_DEP)
set(FFT_LIBRARIES "-L${FFTW_LIBRARY_DIRS_DEP};" CACHE STRING "Set your FFTW path")
endif()
if (FFTW_LIBRARIES_DEP)
foreach (fft_lib ${FFTW_LIBRARIES_DEP})
set(FFT_LIBRARIES "${FFT_LIBRARIES};${fft_lib};")
endforeach()
endif()
set(FFT_INCLUDES "${FFTW_INCLUDE_DIRS_DEP}" )
if (FFT_LIBRARIES)
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};${FFT_LIBRARIES}")
endif()
if(FFTW_LIBRARY_DIRS)
# the RPATH to be used when installing
list(APPEND CMAKE_INSTALL_RPATH "${FFTW_LIBRARY_DIRS}")
endif()
if (FFTW_LIBRARY_DIRS_DEP)
set(FFT_LIBRARIES "-L${FFTW_LIBRARY_DIRS_DEP};" CACHE STRING "Set your MKL flags")
endif()
if (FFTW_LIBRARIES_DEP)
foreach (fft_lib ${FFTW_LIBRARIES_DEP})
set(FFT_LIBRARIES "${FFT_LIBRARIES};${fft_lib};")
endforeach()
endif()
endif(SCALFMM_USE_MKL_AS_FFTW)
set(FFT_INCLUDES "${FFTW_INCLUDE_DIRS_DEP}" )
if (FFT_LIBRARIES)
set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};${FFT_LIBRARIES}")
endif()
if(FFTW_LIBRARY_DIRS)
# the RPATH to be used when installing
list(APPEND CMAKE_INSTALL_RPATH "${FFTW_LIBRARY_DIRS}")
endif()
if (FFT_INCLUDES)
set(SCALFMM_INCLUDES "${SCALFMM_INCLUDES}; ${FFT_INCLUDES}")
endif()
if(FFTW_FOUND)
message(STATUS " SCALFMM_LIBRARIES = ${SCALFMM_LIBRARIES}")
message(STATUS " SCALFMM_INCLUDES = ${SCALFMM_INCLUDES}")
else()
if(NOT FFTW_FOUND)
message(WARNING "FFTW has not been found, SCALFMM will continue to compile but some applications will be disabled.")
message(WARNING "If you have FFTW set FFTW_LIBDIR, FFTW_INCDIR or FFTW_DIR (CMake variables using -D or environment variables).")
set(SCALFMM_USE_FFT OFF)
endif()
endif(SCALFMM_USE_FFT)
list(APPEND FUSE_LIST "FFT")
message(STATUS " SCALFMM_LIBRARIES = ${SCALFMM_LIBRARIES}")
message(STATUS " SCALFMM_INCLUDES = ${SCALFMM_INCLUDES}")
message(STATUS "SCALFMM_USE_FFT = ${SCALFMM_USE_FFT}")
list(REMOVE_DUPLICATES SCALFMM_INCLUDES)
list(REMOVE_DUPLICATES SCALFMM_LIBRARIES)
#
# C++ 2011
......@@ -788,7 +771,7 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/morse/
set(SCALFMM_COMPILE_LIBS "")
foreach(lib_var ${SCALFMM_LIBRARIES})
string(STRIP ${lib_var} lib_var)
LIST(APPEND SCALFMM_COMPILE_LIBS ${lib_var})
LIST(APPEND SCALFMM_COMPILE_LIBS ${lib_var})
endforeach()
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Src/ScalFmmConfig.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/Src/ScalFmmConfig.h )
......
......@@ -38,6 +38,7 @@
#cmakedefine SCALFMM_USE_FFT
#cmakedefine SCALFMM_USE_MKL_AS_FFTW
#cmakedefine SCALFMM_USE_ESSL_AS_FFTW
//////////////////////////////////////////////////////
// MPI
......
......@@ -26,10 +26,11 @@
#include <iostream>
#include <stdlib.h>
// include fftw3 (specify path in cmake)
// if MKL: path/to/mkl/include/fftw/fftw3.h
// elseif libfftw_dev: usr/include/fftw3.h
#ifdef SCALFMM_USE_ESSL_AS_FFTW
#include <fftw3_essl.h>
#else
#include <fftw3.h>
#endif
// for @class FDft only
#include "FBlas.hpp"
......
......@@ -21,7 +21,11 @@
#include <iostream>
#include <stdlib.h>
#ifdef SCALFMM_USE_ESSL_AS_FFTW
#include <fftw3_essl.h>
#else
#include <fftw3.h>
#endif
#include "Utils/FGlobal.hpp"
#include "Utils/FComplex.hpp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment