Skip to content
Commits on Source (299)
......@@ -28,6 +28,9 @@ src/misc/version.inc
# noise simulations
save/nsv/*.dat
# fftw wisdoms
save/fftw/*.fftw
# ctags
tags
GTAGS
......
language: c
env:
addons:
apt:
packages: &default_packages
......@@ -8,52 +10,44 @@ addons:
- libpng-dev
matrix:
allow_failures:
- env: MAYFAIL=1
include:
- env: PARALLEL=1
- name: "Makefile PARALLEL"
env: PARALLEL=1
os: linux
compiler: gcc
compiler: gcc-5
sudo: required
dist: trusty
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- *default_packages
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq liblapacke-dev
- gcc-5
- liblapacke-dev
- env:
- name: "Makefile + test + utest"
env:
os: linux
compiler: gcc
compiler: gcc-5
sudo: required
dist: trusty
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- *default_packages
- gcc-5
- liblapacke-dev
script:
- make test
- make utest
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq liblapacke-dev
- env: SLINK=1
os: linux
compiler: gcc
sudo: required
dist: trusty
addons:
apt:
packages:
- *default_packages
- gfortran
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq liblapacke-dev liblapack-dev
- env: OMP=0
- name: "Makefile Clang"
env: OMP=0
os: linux
compiler: clang
sudo: required
......@@ -62,149 +56,109 @@ matrix:
apt:
packages:
- *default_packages
- liblapacke-dev
- libblocksruntime-dev
script:
- make test
- make utest
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq liblapacke-dev
- env: OMP=1
- name: "Makefile OpenMP"
env: OMP=1
os: linux
compiler: gcc
compiler: gcc-5
sudo: required
dist: trusty
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- *default_packages
- gcc-5
- liblapacke-dev
script:
- make test
- make utest
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq liblapacke-dev
- env: NOLAPACKE=1
- name: "Makefile NOLAPACKE"
env: NOLAPACKE=1
os: linux
compiler: gcc
compiler: gcc-5
sudo: required
dist: trusty
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- *default_packages
- gcc-5
- gfortran
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq liblapack-dev
- liblapack-dev
- env: CUDA=1 CUDA_BASE=/usr/local/cuda-7.5/
- name: "CMake GCC-5"
env: MAYFAIL=1
os: linux
compiler: clang-3.5
compiler: gcc-5
sudo: required
dist: trusty
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- *default_packages
before_install:
- wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb
- sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb
- sudo apt-get update -qq
- sudo apt-get install -qq clang-3.5
- sudo apt-get install -qq --no-install-recommends cuda-drivers cuda-core-7.5 cuda-cudart-dev-7.5 cuda-cufft-dev-7.5 cuda-cublas-dev-7.5
- sudo apt-get install -qq liblapacke-dev
- gcc-5
- libatlas-base-dev
- liblapacke-dev
before_script:
- mkdir build && cd build
# NB: CC is automatically set to `compiler` by Travis
- cmake .. -DLINALG_VENDOR=ATLAS -DBART_ENABLE_MEM_CFL=OFF -DBUILD_TESTING=OFF -DBART_LOG_BACKEND=OFF -DUSE_OPENMP=ON -DBART_GENERATE_DOC=OFF
- env: BUILD_NAME="CMake"
- name: "CMake GCC-5 NOLAPACKE"
env: MAYFAIL=1
os: linux
compiler: gcc
compiler: gcc-5
sudo: required
dist: trusty
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- *default_packages
- gcc-5
- gfortran
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq liblapack-dev liblapacke-dev
script:
- wget http://www.netlib.org/blas/blast-forum/cblas.tgz
- tar zxvf cblas.tgz && rm cblas.tgz
- pushd CBLAS
- |
cat << EOF > Makefile.in
SHELL = /bin/sh
PLAT = LINUX
CBLIB = ../lib/libcblas.so
CFLAGS = -O3 -DADD_ -fPIC
FFLAGS = -O3 -fPIC
CC = gcc
FC = gfortran
LOADER = $(FC)
ARCH = cc
ARCHFLAGS = -shared -o
RANLIB = echo
EOF
- cd src && make all && sudo cp -v ../lib/libcblas.so /usr/lib/
- popd
- libatlas-base-dev
- liblapack-dev
before_script:
- mkdir build && cd build
- export FC=$(which gfortran)
- CC=gcc CXX=g++ cmake -DLINALG_VENDOR=LAPACKE -DLAPACKE_DIR=/usr/lib -DUSE_MATLAB=OFF ..
- make
# NB: CC is automatically set to `compiler` by Travis
- cmake .. -DBART_ENABLE_MEM_CFL=OFF -DBUILD_TESTING=OFF -DBART_LOG_BACKEND=OFF -DUSE_OPENMP=ON -DBART_GENERATE_DOC=OFF -DBART_NO_LAPACKE=ON
- env: BUILD_NAME="CMake + CUDA" CUDA_BASE=/usr/local/cuda-7.5/
- name: "CMake GCC-5/G++-5 (with mem-CFL support) + utest"
env: MAYFAIL=1
os: linux
compiler: clang-3.5
compiler: gcc-5
sudo: required
dist: trusty
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- *default_packages
- gfortran
before_install:
- wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb
- sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb
- sudo apt-get update -qq
- sudo apt-get install -qq clang-3.5
- sudo apt-get install -qq --no-install-recommends cuda-drivers cuda-core-7.5 cuda-cudart-dev-7.5 cuda-cufft-dev-7.5 cuda-cublas-dev-7.5
- sudo apt-get install -qq liblapack-dev liblapacke-dev
script:
- wget http://www.netlib.org/blas/blast-forum/cblas.tgz
- tar zxvf cblas.tgz && rm cblas.tgz
- pushd CBLAS
- |
cat << EOF > Makefile.in
SHELL = /bin/sh
PLAT = LINUX
CBLIB = ../lib/libcblas.so
CFLAGS = -O3 -DADD_ -fPIC
FFLAGS = -O3 -fPIC
CC = gcc
FC = gfortran
LOADER = $(FC)
ARCH = cc
ARCHFLAGS = -shared -o
RANLIB = echo
EOF
- cd src && make all && sudo cp -v ../lib/libcblas.so /usr/lib/
- popd
- gcc-5
- g++-5
- libatlas-base-dev
- liblapacke-dev
before_script:
- mkdir build && cd build
- export FC=$(which gfortran)
- CC=gcc CXX=g++ cmake -DLINALG_VENDOR=LAPACKE -DLAPACKE_DIR=/usr/lib -DUSE_MATLAB=OFF -DUSE_CUDA=ON -DCUDA_TOOLKIT_ROOT_DIR=${CUDA_BASE} ..
- make
- env: MACPORTS=0
os: osx
compiler: gcc-4.8
script:
# NB: CC is automatically set to `compiler` by Travis
- CXX=g++-5 cmake .. -DLINALG_VENDOR=ATLAS -DBART_ENABLE_MEM_CFL=ON -DBUILD_TESTING=ON -DBART_LOG_BACKEND=OFF -DUSE_OPENMP=ON -DBART_GENERATE_DOC=OFF
after_script:
- make test
# make utest
before_install:
- brew update
- brew install fftw gcc48 homebrew/science/openblas
script:
- make bart
......
Contributors:
We want to acknowledge the following persons for supporting
BART by contributing source code, testing, feedback, data,
bug reports, etc.
(alphabetrical)
Marcus T. Alley
Michael Anderson
Jakob Asslaender
Dara Bahri
Soumick Chatterjee
Joseph Y. Cheng
Sofia Dimoudi
Siddharth Iyer
Miki Lustig
Mark Murphy
Hans Johnson
Christian Holme
Gregory R. Lee
Evan G. Levine
Tim Loderhose
Michael Lustig
Lyu Mengye
Damien Nguyen
Frank Ong
Jonathan Tamir
Sebastian Rosenzweig
Nick Scholand
David Smith
Jonathan I. Tamir
Michelle Tamir (logo)
Johannes Toger
Martin Uecker
Shreyas S. Vasanawala
Sana Vaziri
Pat Virtue
Patrick Virtue
Simon Yeung
Tao Zhang
Logo designed by: Michelle Tamir
Different parts of this software have been written for
projects funded by:
American Heart Association Grant 12BGIA9660006
NIH Grant P41RR09784 and Grant R01EB009690
UC Discovery Grant 193037
Sloan Research Fellowship
GE Healthcare
A personal donation by David Donoho
This diff is collapsed.
Copyright (c) 2013-2017. The Regents of the University of California.
Copyright (c) 2013-2017. BART Developer Team and Contributors.
Copyright (c) 2012. Intel Coorperation. (src/lapacke/)
Copyright (c) 2013-2018. The Regents of the University of California.
Copyright (c) 2013-2018. BART Developer Team and Contributors.
Copyright (c) 2012. Intel Corporation. (src/lapacke/)
All rights reserved.
Redistribution and use in source and binary forms, with or without
......
# Copyright 2013-2015. The Regents of the University of California.
# Copyright 2015-2016. Martin Uecker <martin.uecker@med.uni-goettingen.de>
# Copyright 2015-2018. Martin Uecker <martin.uecker@med.uni-goettingen.de>
# All rights reserved. Use of this source code is governed by
# a BSD-style license which can be found in the LICENSE file.
......@@ -15,6 +15,7 @@ MAKEFLAGS += -R
# use for parallel make
AR=./ar_lock.sh
MKL?=0
CUDA?=0
ACML?=0
OMP?=1
......@@ -23,6 +24,14 @@ DEBUG?=0
FFTWTHREADS?=1
ISMRMRD?=0
LOG_BACKEND?=0
LOG_SIEMENS_BACKEND?=0
LOG_ORCHESTRA_BACKEND?=0
LOG_GADGETRON_BACKEND?=0
ENABLE_MEM_CFL?=0
MEMONLY_CFL?=0
DESTDIR ?= /
PREFIX ?= usr/
......@@ -91,14 +100,13 @@ CFLAGS ?= $(OPT) -Wmissing-prototypes
CXXFLAGS ?= $(OPT)
ifeq ($(BUILDTYPE), MacOSX)
CC ?= gcc-mp-4.7
CC ?= gcc-mp-6
else
CC ?= gcc
# for symbols in backtraces
LDFLAGS += -rdynamic
endif
CXX ?= g++
......@@ -123,6 +131,9 @@ CUDA_BASE ?= /usr/local/
ACML_BASE ?= /usr/local/acml/acml4.4.0/gfortran64_mp/
# mkl
MKL_BASE ?= /opt/intel/mkl/lib/intel64/
# fftw
ifneq ($(BUILDTYPE), MacOSX)
......@@ -177,6 +188,7 @@ MODULES_lrmatrix = -llowrank -liter -llinops
MODULES_estdims = -lnoncart -llinops
MODULES_ismrmrd = -lismrm
MODULES_wavelet = -llinops -lwavelet
MODULES_wshfl = -llinops -lwavelet -liter -llowrank -llinops
MAKEFILES = $(root)/Makefiles/Makefile.*
......@@ -186,6 +198,19 @@ MAKEFILES = $(root)/Makefiles/Makefile.*
-include $(MAKEFILES)
# clang
ifeq ($(findstring clang,$(CC)),clang)
CFLAGS += -fblocks
LDFLAGS += -lBlocksRuntime
endif
CXX ?= g++
LINKER ?= $(CC)
ifeq ($(ISMRMRD),1)
TMRI += ismrmrd
MODULES_bart += -lismrm
......@@ -221,9 +246,9 @@ default all clean allclean distclean doc/commands.txt doxygen test utest gputest
else
CPPFLAGS += $(DEPFLAG) -I$(srcdir)/
CFLAGS += -std=gnu11 -I$(srcdir)/
CXXFLAGS += -I$(srcdir)/
CPPFLAGS += $(DEPFLAG) -iquote $(srcdir)/
CFLAGS += -std=gnu11
CXXFLAGS += -std=c++11
......@@ -297,6 +322,12 @@ endif
endif
endif
ifeq ($(MKL),1)
BLAS_H := -I$(MKL_BASE)/include
BLAS_L := -L$(MKL_BASE)/lib/intel64 -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core
CPPFLAGS += -DUSE_MKL -DMKL_Complex8="complex float" -DMKL_Complex16="complex double"
CFLAGS += -DUSE_MKL -DMKL_Complex8="complex float" -DMKL_Complex16="complex double"
endif
......@@ -311,6 +342,10 @@ ifeq ($(SLINK),1)
PNG_L += -lz
endif
ifeq ($(LINKER),icc)
PNG_L += -lz
endif
# fftw
......@@ -338,11 +373,41 @@ ISMRM_H :=
ISMRM_L :=
endif
# Enable in-memory CFL files
ifeq ($(ENABLE_MEM_CFL),1)
CPPFLAGS += -DUSE_MEM_CFL
miscextracxxsrcs += $(srcdir)/misc/mmiocc.cc
LDFLAGS += -lstdc++
endif
# Only allow in-memory CFL files (ie. disable support for all other files)
ifeq ($(MEMONLY_CFL),1)
CPPFLAGS += -DMEMONLY_CFL
miscextracxxsrcs += $(srcdir)/misc/mmiocc.cc
LDFLAGS += -lstdc++
endif
# Logging backends
ifeq ($(LOG_BACKEND),1)
CPPFLAGS += -DUSE_LOG_BACKEND
ifeq ($(LOG_SIEMENS_BACKEND),1)
miscextracxxsrcs += $(srcdir)/misc/UTrace.cc
endif
ifeq ($(LOG_ORCHESTRA_BACKEND),1)
miscextracxxsrcs += $(srcdir)/misc/Orchestra.cc
endif
endif
# change for static linking
ifeq ($(SLINK),1)
# work around fortran problems with static linking
LDFLAGS += -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -Wl,--allow-multiple-definition
LIBS += -lmvec
BLAS_L += -llapack -lblas -lgfortran -lquadmath
endif
......@@ -426,14 +491,14 @@ endif
.SECONDEXPANSION:
$(TARGETS): % : src/main.c $(srcdir)/%.o $$(MODULES_%) $(MODULES)
$(CC) $(LDFLAGS) $(CFLAGS) -Dmain_real=main_$@ -o $@ $+ $(FFTW_L) $(CUDA_L) $(BLAS_L) $(PNG_L) $(ISMRM_L) -lm
$(LINKER) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) -Dmain_real=main_$@ -o $@ $+ $(FFTW_L) $(CUDA_L) $(BLAS_L) $(PNG_L) $(ISMRM_L) $(LIBS) -lm
# rm $(srcdir)/$@.o
UTESTS=$(shell $(root)/utests/utests-collect.sh ./utests/$@.c)
.SECONDEXPANSION:
$(UTARGETS): % : utests/utest.c utests/%.o $$(MODULES_%) $(MODULES)
$(CC) $(LDFLAGS) $(CFLAGS) -DUTESTS="$(UTESTS)" -o $@ $+ $(FFTW_L) $(CUDA_L) $(BLAS_L) -lm
$(CC) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) -DUTESTS="$(UTESTS)" -o $@ $+ $(FFTW_L) $(CUDA_L) $(BLAS_L) $(LIBS) -lm
# linker script version - does not work on MacOS X
......@@ -495,7 +560,6 @@ install: bart $(root)/doc/commands.txt
install bart $(DESTDIR)/$(PREFIX)/bin/
install -d $(DESTDIR)/$(PREFIX)/share/doc/bart/
install $(root)/doc/*.txt $(root)/README $(DESTDIR)/$(PREFIX)/share/doc/bart/
install -d $(DESTDIR)/$(PREFIX)/lib/bart/commands/
# generate release tar balls (identical to github)
......
......@@ -49,6 +49,10 @@ Updates and further information can be found here:
GCC compiler, the FFTW library, and optionally CUDA.
(see recon/Makefile to turn options on or off)
The minimum GCC supported is 5.0. It should also be possible
to use the clang compiler, but older version before version
4.0 are known to cause problems.
The software can be used in combination with Matlab or octave.
......@@ -81,11 +85,11 @@ To install the required libraries on Debian and Ubuntu run:
### 2.1.2. Mac OS X
Xcode is required and it is recommended to install a newer version
of gcc (4.7 seems to work) from MacPorts (http://www.macports.org/).
of gcc from MacPorts (http://www.macports.org/).
$ sudo port install fftw-3-single
$ sudo port install gcc47
$ sudo port install gcc6
$ sudo port install libpng
$ sudo port install openblas
......@@ -99,8 +103,14 @@ of gcc (4.7 seems to work) from MacPorts (http://www.macports.org/).
### 2.1.3. Windows
Note that Windows is currently not supported. Nevertheless, many people
use BART on Windows. If you have trouble to get it to work, you may
want to try an older version (e.g. version 4.00).
The recommended way to use BART on Windows is with the Windows Subsystem for
Linux (WSL) which is available for Windows 10.
Linux (WSL) which is available for Windows 10. If you use WSL, you need to
use the clang compiler.
BART should also work with Cygwin:
......
# Main build targets
#
TBASE=show slice crop resize join transpose squeeze flatten zeros ones flip circshift extract repmat bitmask reshape version delta copy casorati vec
TFLP=scale invert conj fmac saxpy sdot spow cpyphs creal carg normalize cdf97 pattern nrmse mip avg cabs zexpj
TBASE=show slice crop resize join transpose squeeze flatten zeros ones flip circshift extract repmat bitmask reshape version delta copy casorati vec poly index
TFLP=scale invert conj fmac saxpy sdot spow cpyphs creal carg normalize cdf97 pattern nrmse mip avg cabs zexp
TNUM=fft fftmod fftshift noise bench threshold conv rss filter mandelbrot wavelet window var std
TRECO=pics pocsense sqpics itsense nlinv nufft rof sake wave lrmatrix estdims estshift estdelay wavepsf
TRECO=pics pocsense sqpics itsense nlinv nufft rof sake wave lrmatrix estdims estshift estdelay wavepsf wshfl
TCALIB=ecalib ecaltwo caldir walsh cc ccapply calmat svd estvar whiten
TMRI=homodyne poisson twixread fakeksp
TSIM=phantom traj
......
# Copyright 2018. Damien Nguyen <damien.nguyen@alumni.epfl.ch>
# All rights reserved. Use of this source code is governed by
# a BSD-style license which can be found in the LICENSE file.
# \author Damien Nguyen <damien.nguyen@alumni.epfl.ch>
@PACKAGE_INIT@
set(BART_ENABLE_MEM_CFL @BART_ENABLE_MEM_CFL@)
set(BART_FPIC @BART_FPIC@)
set(BART_FFTWTHREADS @BART_FFTWTHREADS@)
set(BART_DISABLE_PNG @BART_DISABLE_PNG@)
set(BART_ISMRMRD @BART_ISMRMRD@)
set(BART_LOCAL_FFTW @BART_LOCAL_FFTW@)
set(BART_LOG_BACKEND @BART_LOG_BACKEND@)
set(BART_LOG_SIEMENS_BACKEND @BART_LOG_SIEMENS_BACKEND@)
set(BART_LOG_ORCHESTRA_BACKEND @BART_LOG_ORCHESTRA_BACKEND@)
set(BART_LOG_GADGETRON_BACKEND @BART_LOG_GADGETRON_BACKEND@)
set(BART_NO_LAPACKE @BART_NO_LAPACKE@)
set(BART_MATLAB @BART_MATLAB@)
set(BART_MEMONLY_CFL @BART_MEMONLY_CFL@)
set(BART_USE_CUDA @USE_CUDA@)
set(BART_USE_NATIVE_CUDA @BART_USE_NATIVE_CUDA@)
set(BART_USE_OPENMP @USE_OPENMP@)
set(BART_REDEFINE_PRINTF_FOR_TRACE @BART_REDEFINE_PRINTF_FOR_TRACE@)
set(BART_LINALG_VENDOR "@LINALG_VENDOR@")
set(LINALG_VENDOR "@LINALG_VENDOR@")
# ------------------------------------------------------------------------------
get_filename_component(BART_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
list(INSERT CMAKE_MODULE_PATH 0 ${BART_CMAKE_DIR})
include(CMakeFindDependencyMacro)
include(${BART_CMAKE_DIR}/BARTFindBLASlib.cmake)
if(BART_ISMRMRD)
find_dependency(ISMRMRD)
endif()
if(NOT BART_LOCAL_FFTW)
if(CMAKE_VERSION VERSION_LESS 3.9)
find_package(FFTW 3 REQUIRED COMPONENTS FFTWF FFTWF_MT)
else()
find_dependency(FFTW 3 COMPONENTS FFTWF FFTWF_MT)
endif()
else()
find_dependency(Threads)
endif()
if(NOT BART_DISABLE_PNG)
find_dependency(PNG)
if(CMAKE_VERSION VERSION_LESS 3.5)
add_library(PNG::PNG SHARED IMPORTED GLOBAL)
set_target_properties(PNG::PNG
PROPERTIES
IMPORTED_LOCATION "${PNG_LIBRARY}"
INTERFACE_DEFINITIONS "${PNG_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${PNG_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${PNG_LIBRARIES}"
)
endif()
endif()
if(BART_USE_OPENMP)
if(CMAKE_VERSION VERSION_LESS 3.11)
# Actually CMake 3.9 should be enough for OpenMP::OpenMP support,
# however, until CMake 3.11 we might get problems with the
# INTERFACE_COMPILE_OPTIONS property if we are compiling with
# CMake's native CUDA compilation
find_package(BOpenMP REQUIRED) # BOpenMP is FindOpenMP.cmake from 3.12
else()
find_package(OpenMP REQUIRED)
endif()
endif()
if(BART_USE_NATIVE_CUDA)
find_dependency(CUDAlibs COMPONENTS CUBLAS CUFFT)
endif()
list(REMOVE_AT CMAKE_MODULE_PATH 0)
# ==============================================================================
set_and_check(BARTTargetForEmbedding "${BART_CMAKE_DIR}/BARTTargetsForEmbedding.cmake")
include(${BARTTargetForEmbedding})
set(BARTTargetGeneral "${BART_CMAKE_DIR}/BARTTargets.cmake")
if(NOT TARGET BART::BART AND EXISTS ${BARTTargetGeneral})
include(${BARTTargetGeneral})
endif()
# ==============================================================================
# Copyright 2018. Damien Nguyen <damien.nguyen@alumni.epfl.ch>
# All rights reserved. Use of this source code is governed by
# a BSD-style license which can be found in the LICENSE file.
# \author Damien Nguyen <damien.nguyen@alumni.epfl.ch>
macro(setup_linalg_vendor_on_success vendor target)
if(${target}_FOUND)
set(LINALG_VENDOR_LIB ${ARGN})
set(LINALG_VENDOR_FOUND TRUE)
set(LINALG_VENDOR ${vendor} CACHE STRING "Vendor type for linear algebra library" FORCE)
set(LINALG_VENDOR_TGT ${target})
endif()
endmacro()
##==============================================================
if(NOT "${LINALG_VENDOR}" STREQUAL "")
# If the user specifies LINALG_VENDOR, make sure we find what he wants
set(FIND_PACKAGE_ARG "REQUIRED")
else()
set(FIND_PACKAGE_ARG)
endif()
## Switch based on the linear algebra optimized library to
## use. Note that the first library successfully found
## will be used
##
## -*-*- Try with only a BLAS library first if BART_NO_LAPACKE is set
if(BART_NO_LAPACKE AND (NOT LINALG_VENDOR OR LINALG_VENDOR STREQUAL "BLAS"))
find_package(LAPACKE ${FIND_PACKAGE_ARG} COMPONENTS lapack cblas blas)
setup_linalg_vendor_on_success("BLAS" LAPACKE LAPACKE::LAPACK LAPACKE::CBLAS LAPACKE::BLAS)
endif()
## -*-*- Try AMD BLIS/libFlame next
if(NOT LINALG_VENDOR OR LINALG_VENDOR MATCHES "AMD_FLAME")
find_package(libFlame ${FIND_PACKAGE_ARG})
setup_linalg_vendor_on_success("AMD_FLAME" libFlame libFlame::libFlame)
if(libFlame_FOUND)
if(NOT BART_NO_LAPACKE)
find_package(LAPACKE REQUIRED COMPONENTS LAPACKE)
get_target_property(
libFlame_INTERFACE_LINK_LIBRARIES
${LINALG_VENDOR_LIB}
INTERFACE_LINK_LIBRARIES)
set_target_properties(${LINALG_VENDOR_LIB} PROPERTIES
INTERFACE_LINK_LIBRARIES "${libFlame_INTERFACE_LINK_LIBRARIES};LAPACKE::LAPACKE")
endif()
endif()
endif()
## -*-*- Try OpenBLAS next
if(NOT LINALG_VENDOR OR LINALG_VENDOR MATCHES "OpenBLAS")
find_package(OpenBLAS ${FIND_PACKAGE_ARG})
setup_linalg_vendor_on_success("OpenBLAS" OpenBLAS OpenBLAS::OpenBLAS)
endif()
##
## -*-*- Try ATLAS version next
if(NOT LINALG_VENDOR OR LINALG_VENDOR MATCHES "ATLAS")
find_package(ATLAS ${FIND_PACKAGE_ARG})
setup_linalg_vendor_on_success("ATLAS" ATLAS ATLAS::ATLAS)
endif()
##
## -*-*- Try Generic LAPACKE version Last
if(NOT LINALG_VENDOR OR LINALG_VENDOR MATCHES "LAPACKE")
#NOTE: By specifying Fortran here, linking to lapack becomes easier
# See https://blog.kitware.com/fortran-for-cc-developers-made-easier-with-cmake/
if(NOT WIN32)
enable_language(Fortran)
endif()
## Only very new versions of LAPACK (> 3.5.0) have built in support
## for cblas and lapacke. This method is not very robust to older
## versions of lapack that might be able to be supported.
## It is know to work local builds
find_package(LAPACKE ${FIND_PACKAGE_ARG})
setup_linalg_vendor_on_success("LAPACKE" LAPACKE LAPACKE::LAPACKE LAPACKE::LAPACKE LAPACKE::CBLAS LAPACKE::BLAS)
endif()
# Fix weird error when compiling on Mac...
if(APPLE)
include_directories(${${LINALG_VENDOR_TGT}_INCLUDE_DIRS})
endif()
##
## -*-*- Finally, set include_directories -*-*-*
if(NOT LINALG_VENDOR_FOUND)
message(FATAL_ERROR "No valid linear algebra libraries found!")
endif()
......@@ -2,23 +2,17 @@
# FindATLAS
# -------------
#
# Find the ATLAS library
# Find ATLAS include dirs and libraries
#
# Using ATLAS:
# Use this module by invoking find_package with the form::
#
# ::
# find_package(ATLAS
# [REQUIRED] # Fail with error if ATLAS is not found
# )
#
# [OPTIONAL] set(ATLAS_REQUIRE_THREADED [TRUE|FALSE]) to find threaded versions of the libraries
# find_package(ATLAS REQUIRED)
# include_directories(${ATLAS_INCLUDE_DIRS})
# add_executable(foo foo.cc)
# target_link_libraries(foo ${ATLAS_LIBRARIES})
# -- OR --
# target_link_libraries(foo ${ATLAS_PARALLEL_LIBRARIES})
#
# This module sets the following variables:
#
# ::
# This module defines::
#
# ATLAS_FOUND - set to true if the library is found
# ATLAS_INCLUDE_DIRS - list of required include directories
......@@ -27,30 +21,72 @@
# ATLAS_VERSION_MINOR - minor version number
# ATLAS_VERSION_PATCH - patch version number
# ATLAS_VERSION_STRING - version number as a string (ex: "0.2.18")
#
#
# This module reads hints about search locations from variables
# (either CMake variables or environment variables)::
#
# ATLAS_ROOT - Preferred installation prefix for ATLAS
# ATLAS_DIR - Preferred installation prefix for ATLAS
#
#
# ATLAS::ATLAS - Imported target for the ATLAS library
#
#=============================================================================
# ==============================================================================
# Copyright 2016 Hans J. Johnson <hans-johnson@uiowa.edu>
# Copyright 2018 Damien Nguyen <damien.nguyen@alumni.epfl.ch>
#
# Distributed under the OSI-approved BSD License (the "License")
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#=============================================================================
#
# ==============================================================================
set(ATLAS_SEARCH_PATHS
${ATLAS_ROOT}
$ENV{ATLAS_ROOT}
${ATLAS_DIR}
$ENV{ATLAS_DIR}
$ENV{CMAKE_PREFIX_PATH}
${CMAKE_PREFIX_PATH}
$ENV{CMAKE_PREFIX_PATH}
/usr
/usr/local
/usr/local/opt/openblas ## Mac Homebrew install path
/usr/local/
/usr/local/opt # homebrew on mac
/opt
/opt/local
/opt/ATLAS
)
set(CMAKE_PREFIX_PATH ${ATLAS_SEARCH_PATHS})
list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH)
set(PATH_SUFFIXES_LIST
lib64/atlas-sse3 #openSUSE 13.2 (Harlequin)
lib64/atlas-sse2 #openSUSE 13.2 (Harlequin)
lib64/atlas-sse #openSUSE 13.2 (Harlequin)
lib64/atlas #openSUSE 13.2 (Harlequin)
lib64
lib/atlas-sse3 #openSUSE 13.2 (Harlequin)
lib/atlas-sse2 #openSUSE 13.2 (Harlequin)
lib/atlas-sse #openSUSE 13.2 (Harlequin)
lib/atlas #openSUSE 13.2 (Harlequin)
lib
)
if(APPLE)
list(APPEND PATH_SUFFIXES_LIST openblas/lib)
endif()
# ==============================================================================
# Prepare some helper variables
set(ATLAS_INCLUDE_DIRS)
set(ATLAS_LIBRARIES)
set(ATLAS_THREAD_PREFIX "")
if(ATLAS_REQUIRE_THREADED)
set(ATLAS_THREAD_PREFIX "pt")
endif()
# ==============================================================================
## First try to find ATLAS with NO_MODULE,
## As of 20160706 version 0.2.18 there is limited cmake support for ATLAS
......@@ -61,62 +97,55 @@ if(ATLAS_VERSION)
set(ATLAS_VERSION_STRING ${ATLAS_VERSION})
unset(ATLAS_VERSION) # Use cmake conventional naming
endif()
##################################################################################################
# ==============================================================================
### First search for headers
find_path(ATLAS_CBLAS_INCLUDE_DIR
NAMES cblas.h
PATHS ${ATLAS_SEARCH_PATHS}
PATH_SUFFIXES include include/openblas)
find_path(ATLAS_LAPACKE_INCLUDE_DIR
NAMES lapacke.h
PATHS ${ATLAS_SEARCH_PATHS}
PATH_SUFFIXES include)
##################################################################################################
set(PATH_SUFFIXES_LIST
lib64/atlas-sse3 #openSUSE 13.2 (Harlequin)
lib64/atlas-sse2 #openSUSE 13.2 (Harlequin)
lib64/atlas-sse #openSUSE 13.2 (Harlequin)
lib64/atlas #openSUSE 13.2 (Harlequin)
lib64
lib/atlas-sse3 #openSUSE 13.2 (Harlequin)
lib/atlas-sse2 #openSUSE 13.2 (Harlequin)
lib/atlas-sse #openSUSE 13.2 (Harlequin)
lib/atlas #openSUSE 13.2 (Harlequin)
lib
)
# ==============================================================================
### Second, search for libraries
find_library(ATLAS_LIB
NAMES atlas
PATHS ${ATLAS_SEARCH_PATHS}
PATH_SUFFIXES ${PATH_SUFFIXES_LIST})
set(ATLAS_THREAD_PREFIX "")
if(ATLAS_REQUIRE_THREADED)
set(ATLAS_THREAD_PREFIX "pt")
endif()
find_library(CBLAS_LIB
NAMES ${ATLAS_THREAD_PREFIX}cblas
PATHS ${LAPACKE_SEARCH_PATHS}
PATH_SUFFIXES ${PATH_SUFFIXES_LIST})
find_library(LAPACK_LIB
NAMES ${ATLAS_THREAD_PREFIX}lapack
PATHS ${LAPACKE_SEARCH_PATHS}
PATH_SUFFIXES ${PATH_SUFFIXES_LIST})
find_library(LAPACKE_LIB
NAMES ${ATLAS_THREAD_PREFIX}lapacke
PATHS ${LAPACKE_SEARCH_PATHS}
PATH_SUFFIXES ${PATH_SUFFIXES_LIST})
if(NOT DEFINED ATLAS_NO_LAPACKE OR NOT ATLAS_NO_LAPACKE)
if(ATLAS_LIB)
include(CheckLibraryExists)
check_library_exists(${ATLAS_LIB} LAPACKE_cheev "" HAVE_LAPACKE_CHEEV)
check_library_exists(${ATLAS_LIB} LAPACKE_zgesdd "" HAVE_LAPACKE_ZGESDD)
if(NOT HAVE_LAPACKE_CHEEV OR NOT HAVE_LAPACKE_ZGESDD)
message(WARNING "ATLAS has no LAPACKE symbols. Attempting to look for a LAPACKE library")
find_package(LAPACKE QUIET REQUIRED COMPONENTS lapacke)
list(APPEND ATLAS_LIBRARIES ${LAPACKE_LIBRARIES})
endif()
endif()
set(LAPACKE_LIB_VAR "LAPACKE_LIBRARIES")
else()
set(LAPACKE_LIB_VAR "")
endif()
find_library(F77BLAS_LIB
NAMES ${ATLAS_THREAD_PREFIX}f77blas
PATHS ${LAPACKE_SEARCH_PATHS}
PATH_SUFFIXES ${PATH_SUFFIXES_LIST})
# ------------------------------------------------------------------------
# Extract version information
# ------------------------------------------------------------------------
# WARNING: We may not be able to determine the version of some ATLAS
set(ATLAS_VERSION_MAJOR 0)
set(ATLAS_VERSION_MINOR 0)
......@@ -125,36 +154,81 @@ if(ATLAS_VERSION_STRING)
string(REGEX REPLACE "([0-9]+).([0-9]+).([0-9]+)" "\\1" ATLAS_VERSION_MAJOR "${ATLAS_VERSION_STRING}")
string(REGEX REPLACE "([0-9]+).([0-9]+).([0-9]+)" "\\2" ATLAS_VERSION_MINOR "${ATLAS_VERSION_STRING}")
string(REGEX REPLACE "([0-9]+).([0-9]+).([0-9]+)" "\\3" ATLAS_VERSION_PATCH "${ATLAS_VERSION_STRING}")
else()
elseif(ATLAS_LIB)
set(ATLAS_VERSION_STRING "ATLAS.UNKOWN.VERSION")
else()
set(ATLAS_VERSION_STRING)
endif()
#======================
# ==============================================================================
# Checks 'REQUIRED', 'QUIET' and versions.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ATLAS FOUND_VAR ATLAS_FOUND
REQUIRED_VARS
ATLAS_CBLAS_INCLUDE_DIR
ATLAS_LAPACKE_INCLUDE_DIR
LAPACKE_LIB
${LAPACKE_INCLUDE_VAR}
${LAPACKE_LIB_VAR}
LAPACK_LIB
F77BLAS_LIB
CBLAS_LIB
ATLAS_LIB
VERSION_VAR ATLAS_VERSION_STRING
)
# ------------------------------------------------------------------------------
if (ATLAS_FOUND)
set(ATLAS_INCLUDE_DIRS ${ATLAS_CBLAS_INCLUDE_DIR} ${ATLAS_CBLAS_INCLUDE_DIR})
list(APPEND ATLAS_INCLUDE_DIRS
${ATLAS_CBLAS_INCLUDE_DIR}
${ATLAS_CBLAS_INCLUDE_DIR})
list(REMOVE_DUPLICATES ATLAS_INCLUDE_DIRS)
if("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*" OR
"${CMAKE_C_COMPILER_ID}" MATCHES ".*GNU.*" OR
"${CMAKE_C_COMPILER_ID}" MATCHES ".*Intel.*"
) #NOT MSVC
set(MATH_LIB m)
endif()
list(APPEND ATLAS_LIBRARIES ${LAPACKE_LIB} ${LAPACK_LIB} ${F77BLAS_LIB} ${CBLAS_LIB} ${ATLAS_LIB} ${MATH_LIB})
list(APPEND ATLAS_LIBRARIES ${LAPACKE_LIBRARIES} ${LAPACK_LIB} ${F77BLAS_LIB} ${CBLAS_LIB} ${ATLAS_LIB} ${MATH_LIB})
if(NOT TARGET ATLAS::ATLAS)
get_filename_component(LIB_EXT "${ATLAS_LIB}" EXT)
if(LIB_EXT STREQUAL ".a" OR LIB_EXT STREQUAL ".lib")
set(LIB_TYPE STATIC)
else()
set(LIB_TYPE SHARED)
endif()
add_library(ATLAS::ATLAS ${LIB_TYPE} IMPORTED GLOBAL)
set(_tmp_dep_libs "${LAPACKE_LIBRARIES};${LAPACK_LIB};${F77BLAS_LIB};${CBLAS_LIB};${MATH_LIB}")
list(REMOVE_DUPLICATES _tmp_dep_libs)
set_target_properties(ATLAS::ATLAS
PROPERTIES
IMPORTED_LOCATION "${ATLAS_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${ATLAS_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${_tmp_dep_libs}")
endif()
if(NOT ATLAS_FIND_QUIETLY)
get_target_property(_dep_libs ATLAS::ATLAS INTERFACE_LINK_LIBRARIES)
set(_version "${ATLAS_VERSION_STRING}")
if(_version STREQUAL "ATLAS.UNKOWN.VERSION")
set(_version)
else()
set(_version " (${_version})")
endif()
message(STATUS "Found ATLAS${_version} and defined the ATLAS::ATLAS imported target:")
message(STATUS " - include: ${ATLAS_INCLUDE_DIRS}")
message(STATUS " - library: ${ATLAS_LIB}")
message(STATUS " - dependencies: ${_dep_libs}")
endif()
endif()
# ==============================================================================
mark_as_advanced(
ATLAS_FOUND
ATLAS_INCLUDE_DIRS
......@@ -165,11 +239,5 @@ mark_as_advanced(
ATLAS_VERSION_STRING
)
## For debugging
message(STATUS "ATLAS_FOUND :${ATLAS_FOUND}: - set to true if the library is found")
message(STATUS "ATLAS_INCLUDE_DIRS :${ATLAS_INCLUDE_DIRS}: - list of required include directories")
message(STATUS "ATLAS_LIBRARIES :${ATLAS_LIBRARIES}: - list of libraries to be linked")
message(STATUS "ATLAS_VERSION_MAJOR :${ATLAS_VERSION_MAJOR}: - major version number")
message(STATUS "ATLAS_VERSION_MINOR :${ATLAS_VERSION_MINOR}: - minor version number")
message(STATUS "ATLAS_VERSION_PATCH :${ATLAS_VERSION_PATCH}: - patch version number")
message(STATUS "ATLAS_VERSION_STRING :${ATLAS_VERSION_STRING}: - version number as a string")
# ==============================================================================
This diff is collapsed.
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
# FindBPython
# ----------
# Find Python interpreter, compiler and development environment (include
# directories and libraries).
# Three components are supported:
# * ``Interpreter``: search for Python interpreter.
# * ``Compiler``: search for Python compiler. Only offered by IronPython.
# * ``Development``: search for development artifacts (include directories and
# libraries).
# If no ``COMPONENTS`` is specified, ``Interpreter`` is assumed.
# To ensure consistent versions between components ``Interpreter``, ``Compiler``
# and ``Development``, specify all components at the same time::
# find_package (BPython COMPONENTS Interpreter Development)
# This module looks preferably for version 3 of Python. If not found, version 2
# is searched.
# To manage concurrent versions 3 and 2 of Python, use :module:`FindBPython3` and
# :module:`FindBPython2` modules rather than this one.
# Imported Targets
# ^^^^^^^^^^^^^^^^
# This module defines the following :ref:`Imported Targets <Imported Targets>`:
# ``Python::Interpreter``
# Python interpreter. Target defined if component ``Interpreter`` is found.
# ``Python::Compiler``
# Python compiler. Target defined if component ``Compiler`` is found.
# ``Python::Python``
# Python library. Target defined if component ``Development`` is found.
# Result Variables
# ^^^^^^^^^^^^^^^^
# This module will set the following variables in your project
# (see :ref:`Standard Variable Names <CMake Developer Standard Variable Names>`):
# ``Python_FOUND``
# System has the Python requested components.
# ``Python_Interpreter_FOUND``
# System has the Python interpreter.
# ``Python_EXECUTABLE``
# Path to the Python interpreter.
# ``Python_INTERPRETER_ID``
# A short string unique to the interpreter. Possible values include:
# * Python
# * ActivePython
# * Anaconda
# * Canopy
# * IronPython
# ``Python_STDLIB``
# Standard platform independent installation directory.
# Information returned by
# ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``.
# ``Python_STDARCH``
# Standard platform dependent installation directory.
# Information returned by
# ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``.
# ``Python_SITELIB``
# Third-party platform independent installation directory.
# Information returned by
# ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``.
# ``Python_SITEARCH``
# Third-party platform dependent installation directory.
# Information returned by
# ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``.
# ``Python_Compiler_FOUND``
# System has the Python compiler.
# ``Python_COMPILER``
# Path to the Python compiler. Only offered by IronPython.
# ``Python_COMPILER_ID``
# A short string unique to the compiler. Possible values include:
# * IronPython
# ``Python_Development_FOUND``
# System has the Python development artifacts.
# ``Python_INCLUDE_DIRS``
# The Python include directories.
# ``Python_LIBRARIES``
# The Python libraries.
# ``Python_LIBRARY_DIRS``
# The Python library directories.
# ``Python_RUNTIME_LIBRARY_DIRS``
# The Python runtime library directories.
# ``Python_VERSION``
# Python version.
# ``Python_VERSION_MAJOR``
# Python major version.
# ``Python_VERSION_MINOR``
# Python minor version.
# ``Python_VERSION_PATCH``
# Python patch version.
# Hints
# ^^^^^
# ``Python_ROOT_DIR``
# Define the root directory of a Python installation.
# ``Python_USE_STATIC_LIBS``
# * If not defined, search for shared libraries and static libraries in that
# order.
# * If set to TRUE, search **only** for static libraries.
# * If set to FALSE, search **only** for shared libraries.
# Commands
# ^^^^^^^^
# This module defines the command ``Python_add_library`` which have the same
# semantic as :command:`add_library` but take care of Python module naming rules
# (only applied if library is of type ``MODULE``) and add dependency to target
# ``Python::Python``::
# Python_add_library (my_module MODULE src1.cpp)
# If library type is not specified, ``MODULE`` is assumed.
#]=======================================================================]
set(_PYTHON_PREFIX Python)
set(Python_FIND_REQUIRED ${BPython_FIND_REQUIRED})
set(Python_FIND_QUIETLY ${BPython_FIND_QUIETLY})
set(Python_FIND_VERSION ${BPython_FIND_VERSION})
set(Python_FIND_VERSION_MAJOR ${BPython_FIND_VERSION_MAJOR})
set(Python_FIND_VERSION_MINOR ${BPython_FIND_VERSION_MINOR})
set(Python_FIND_VERSION_PATCH ${BPython_FIND_VERSION_PATCH})
set(Python_FIND_VERSION_TWEAK ${BPython_FIND_VERSION_TWEAK})
set(Python_FIND_VERSION_COUNT ${BPython_FIND_VERSION_COUNT})
set(Python_FIND_VERSION_EXACT ${BPython_FIND_VERSION_EXACT})
set(Python_FIND_COMPONENTS ${BPython_FIND_COMPONENTS})
foreach(_comp ${BPython_FIND_COMPONENTS})
set(Python_FIND_REQUIRED_${_comp} ${BPython_FIND_REQUIRED_${_comp}})
endforeach()
if (DEFINED Python_FIND_VERSION)
set (_Python_REQUIRED_VERSION_MAJOR ${Python_FIND_VERSION_MAJOR})
include (${CMAKE_CURRENT_LIST_DIR}/FindPythonSupport.cmake)
else()
# iterate over versions in quiet and NOT required modes to avoid multiple
# "Found" messages and prematurally failure.
set (_Python_QUIETLY ${BPython_FIND_QUIETLY})
set (_Python_REQUIRED ${BPython_FIND_REQUIRED})
set (Python_FIND_QUIETLY TRUE)
set (Python_FIND_REQUIRED FALSE)
set (_Python_REQUIRED_VERSIONS 3 2)
set (_Python_REQUIRED_VERSION_LAST 2)
foreach (_Python_REQUIRED_VERSION_MAJOR IN LISTS _Python_REQUIRED_VERSIONS)
set (Python_FIND_VERSION ${_Python_REQUIRED_VERSION_MAJOR})
include (${CMAKE_CURRENT_LIST_DIR}/FindPythonSupport.cmake)
if (Python_FOUND OR
_Python_REQUIRED_VERSION_MAJOR EQUAL _Python_REQUIRED_VERSION_LAST)
break()
endif()
# clean-up some CACHE variables to ensure look-up restart from scratch
foreach (_Python_ITEM IN LISTS _Python_CACHED_VARS)
unset (${_Python_ITEM} CACHE)
endforeach()
endforeach()
unset (Python_FIND_VERSION)
set (BPython_FIND_QUIETLY ${_Python_QUIETLY})
set (BPython_FIND_REQUIRED ${_Python_REQUIRED})
if (Python_FIND_REQUIRED OR NOT Python_FIND_QUIETLY)
# call again validation command to get "Found" or error message
find_package_handle_standard_args (Python HANDLE_COMPONENTS
REQUIRED_VARS ${_Python_REQUIRED_VARS}
VERSION_VAR Python_VERSION)
endif()
endif()
if (COMMAND __Python_add_library)
macro (Python_add_library)
__Python_add_library (Python ${ARGV})
endmacro()
endif()
unset (_PYTHON_PREFIX)
#.rst:
# FindCUDAlibs
# -------------
#
# Find CUDA include dirs and libraries
#
# Use this module by invoking find_package with the form::
#
# find_package(CUDAlibs
# [REQUIRED] # Fail with error if LAPACKE is not found
# [COMPONENTS <comp>...] # List of components to look for
# ) # Not specifying any components is equivalent to
# looking for the BASIC libraries
#
# Valid names for COMPONENTS libraries are::
#
# ALL - Find all libraries
# BASIC - Equivalent to CUDART;CUBLAS;CUFFT
#
# CUDART - CUDA RT library
# CUBLAS - CUDA BLAS library
# CUFFT - CUDA FFT library
# CUFFTW - CUDA FFTW library
# CUPTI - CUDA Profiling Tools Interface library.
# CURAND - CUDA Random Number Generation library.
# CUSOLVER - CUDA Direct Solver library.
# CUSPARSE - CUDA Sparse Matrix library.
# NPP - NVIDIA Performance Primitives lib.
# NPPC - NVIDIA Performance Primitives lib (core).
# NPPI - NVIDIA Performance Primitives lib (image processing).
# NPPIAL - NVIDIA Performance Primitives lib (image processing).
# NPPICC - NVIDIA Performance Primitives lib (image processing).
# NPPICOM - NVIDIA Performance Primitives lib (image processing).
# NPPIDEI - NVIDIA Performance Primitives lib (image processing).
# NPPIF - NVIDIA Performance Primitives lib (image processing).
# NPPIG - NVIDIA Performance Primitives lib (image processing).
# NPPIM - NVIDIA Performance Primitives lib (image processing).
# NPPIST - NVIDIA Performance Primitives lib (image processing).
# NPPISU - NVIDIA Performance Primitives lib (image processing).
# NPPITC - NVIDIA Performance Primitives lib (image processing).
# NPPS - NVIDIA Performance Primitives lib (signal processing).
# NVBLAS - NVIDIA BLAS library
#
# Not specifying COMPONENTS is identical to choosing ALL
#
# This module reads hints about search locations from variables
# (either CMake variables or environment variables)::
#
# CUDA_TOOLKIT_ROOT_DIR
# CUDA_ROOT
#
# The following :prop_tgt:`IMPORTED` targets are defined if required::
#
# CUDAlibs::CUDART - Imported target for the CUDA RT library
# CUDAlibs::CUBLAS - Imported target for the CUDA cublas library
# CUDAlibs::CUFFT - Imported target for the CUDA cufft library
# CUDAlibs::CUFFTW - Imported target for the CUDA cufftw library
# CUDAlibs::CUPTI - Imported target for the CUDA cupti library
# CUDAlibs::CURAND - Imported target for the CUDA curand library
# CUDAlibs::CUSOLVER - Imported target for the CUDA cusolver library
# CUDAlibs::CUSPARSE - Imported target for the CUDA cusparse library
# CUDAlibs::NPP - Imported target for the CUDA npp library
# CUDAlibs::NPPC - Imported target for the CUDA nppc library
# CUDAlibs::NPPI - Imported target for the CUDA nppi library
# CUDAlibs::NPPIAL - Imported target for the CUDA nppial library
# CUDAlibs::NPPICC - Imported target for the CUDA nppicc library
# CUDAlibs::NPPICOM - Imported target for the CUDA nppicom library
# CUDAlibs::NPPIDEI - Imported target for the CUDA nppidei library
# CUDAlibs::NPPIF - Imported target for the CUDA nppif library
# CUDAlibs::NPPIG - Imported target for the CUDA nppig library
# CUDAlibs::NPPIM - Imported target for the CUDA nppim library
# CUDAlibs::NPPIST - Imported target for the CUDA nppist library
# CUDAlibs::NPPISU - Imported target for the CUDA nppisu library
# CUDAlibs::NPPITC - Imported target for the CUDA nppitc library
# CUDAlibs::NPPS - Imported target for the CUDA npps library
# CUDAlibs::NVBLAS - Imported target for the CUDA nvblas library
#
# ==============================================================================
# Copyright 2018 Damien Nguyen <damien.nguyen@alumni.epfl.ch>
#
# Distributed under the OSI-approved BSD License (the "License")
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# ==============================================================================
if(CMAKE_VERSION VERSION_LESS 3.8)
message(FATAL_ERROR "Cannot use find_package(CUDAlibs ...) with CMake < 3.8! Use find_package(CUDA) instead.")
endif()
# ------------------------------------------------------------------------------
set(_cuda_root_dir_hint)
foreach(_dir ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
get_filename_component(_dirname "${_dir}" DIRECTORY)
list(APPEND _cuda_root_dir_hint ${_dirname})
endforeach()
set(CUDAlibs_SEARCH_PATHS
${_cuda_root_dir_hint}
${CUDA_ROOT}
$ENV{CUDA_ROOT}
${CUDA_TOOLKIT_ROOT_DIR}
$ENV{CUDA_TOOLKIT_ROOT_DIR}
${CMAKE_PREFIX_PATH}
$ENV{CMAKE_PREFIX_PATH}
/usr
/usr/local
/usr/local/cuda
/opt
/opt/local
)
set(PATH_SUFFIXES_LIST lib/x64 lib64 libx64 lib lib/Win32 lib libWin32)
if(WIN32)
set(_root_dir "C:/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA")
file(GLOB _children RELATIVE ${_root_dir} ${_root_dir}/*)
list(SORT _children)
list(REVERSE _children)
foreach(_child ${_children})
if(IS_DIRECTORY ${_root_dir}/${_child} AND ${_child} MATCH "v[0-9]+.[0-9]")
list(APPEND CUDAlibs_SEARCH_PATHS ${_root_dir}/${child})
endif()
endforeach()
endif()
# ==============================================================================
# Prepare some helper variables
set(CUDAlibs_REQUIRED_VARS)
# ==============================================================================
macro(cuda_find_library component)
string(TOLOWER ${COMPONENT} libnames)
find_library(CUDAlibs_${component}_LIB
NAMES ${libnames}
PATHS ${CUDAlibs_SEARCH_PATHS}
PATH_SUFFIXES ${PATH_SUFFIXES_LIST}
NO_DEFAULT_PATH)
if(CUDAlibs_${component}_LIB)
set(CUDAlibs_${component}_LIB_FOUND 1)
endif()
list(APPEND CUDAlibs_REQUIRED_VARS "CUDAlibs_${component}_LIB")
if(CUDAlibs_${component}_LIB_FOUND)
set(CUDAlibs_${component}_FOUND 1)
else()
set(CUDAlibs_${component}_FOUND 0)
endif()
endmacro()
# ------------------------------------------------------------------------------
set(CUDAlibs_ALL_LIBS "CUDART;CUBLAS;CUFFT;CUFFTW;CUPTI;CURAND;CUSOLVER;CUSPARSE;NPP;NPPC;NPPI;NPPIAL;NPPICC;NPPICOM;NPPIDEI;NPPIF;NPPIG;NPPIM;NPPIST;NPPISU;NPPITC;NPPS;NVBLAS")
# List dependent libraries for relevant targets
set(CUDAlibs_DEP_CUFFTW "CUFFT")
set(CUDAlibs_DEP_NPPIAL "NPPC")
set(CUDAlibs_DEP_NPPICC "NPPC")
set(CUDAlibs_DEP_NPPICOM "NPPC")
set(CUDAlibs_DEP_NPPIDEI "NPPC")
set(CUDAlibs_DEP_NPPIF "NPPC")
set(CUDAlibs_DEP_NPPIG "NPPC")
set(CUDAlibs_DEP_NPPIM "NPPC")
set(CUDAlibs_DEP_NPPIST "NPPC")
set(CUDAlibs_DEP_NPPISU "NPPC")
set(CUDAlibs_DEP_NPPITC "NPPC")
set(CUDAlibs_DEP_NPPS "NPPC")
set(CUDAlibs_DEP_NVBLAS "CUBLAS")
# ------------------------------------------------------------------------------
if(NOT CUDAlibs_FIND_COMPONENTS OR CUDAlibs_FIND_COMPONENTS STREQUAL "BASIC")
set(CUDAlibs_FIND_COMPONENTS "CUDART;CUBLAS;CUFFT")
elseif(CUDAlibs_FIND_COMPONENTS STREQUAL "ALL")
set(CUDAlibs_FIND_COMPONENTS ${CUDAlibs_ALL_LIBS})
endif()
foreach(COMPONENT ${CUDAlibs_FIND_COMPONENTS})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
if (${UPPERCOMPONENT} IN_LIST CUDAlibs_ALL_LIBS)
cuda_find_library(${UPPERCOMPONENT})
foreach(_dep "${CUDAlibs_DEP_${UPPERCOMPONENT}}")
if(NOT "${_dep}" STREQUAL "")
cuda_find_library(${_dep})
endif()
endforeach()
else()
message(FATAL_ERROR "Unknown component: ${COMPONENT}")
endif()
mark_as_advanced(
CUDAlibs_${UPPERCOMPONENT}_LIB
CUDAlibs_${UPPERCOMPONENT}_INCLUDE_DIR)
endforeach()
# ==============================================================================
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CUDAlibs
FOUND_VAR CUDAlibs_FOUND
REQUIRED_VARS ${CUDAlibs_REQUIRED_VARS}
HANDLE_COMPONENTS)
# ==============================================================================
if(CUDAlibs_FOUND)
# Inspired by FindBoost.cmake
foreach(COMPONENT ${CUDAlibs_FIND_COMPONENTS})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
if(NOT TARGET CUDAlibs::${UPPERCOMPONENT} AND CUDAlibs_${UPPERCOMPONENT}_FOUND)
get_filename_component(LIB_EXT "${CUDAlibs_${UPPERCOMPONENT}_LIB}" EXT)
if(LIB_EXT STREQUAL ".a" OR LIB_EXT STREQUAL ".lib")
set(LIB_TYPE STATIC)
else()
set(LIB_TYPE SHARED)
endif()
add_library(CUDAlibs::${UPPERCOMPONENT} ${LIB_TYPE} IMPORTED GLOBAL)
set_target_properties(CUDAlibs::${UPPERCOMPONENT} PROPERTIES
IMPORTED_LOCATION "${CUDAlibs_${UPPERCOMPONENT}_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}")
# ------------------------------------------------------------------------
set(_dependent_libraries)
foreach(_dep "${CUDAlibs_DEP_${UPPERCOMPONENT}}")
list(APPEND _dependent_libraries ${_dep})
endforeach()
if(NOT "${_dependent_libraries}" STREQUAL "")
message(STATUS "Adding dependencies: ${_dependent_libraries}")
set_target_properties(CUDAlibs::${UPPERCOMPONENT} PROPERTIES
INTERFACE_LINK_LIBRARIES "${_dependent_libraries}")
endif()
endif()
endforeach()
# ----------------------------------------------------------------------------
if(NOT CUDAlibs_FIND_QUIETLY)
message(STATUS "Found CUDAlibs and defined the following imported targets:")
foreach(_comp ${CUDAlibs_FIND_COMPONENTS})
message(STATUS " - CUDAlibs::${_comp}")
endforeach()
endif()
endif()
# ==============================================================================
mark_as_advanced(
CUDAlibs_FOUND
)
#.rst:
# FindFFTW
# -------------
#
# Find FFTW3 include dirs and libraries
#
# Use this module by invoking find_package with the form::
#
# find_package(Boost
# [REQUIRED] # Fail with error if FFTW is not found
# [VERSION [2,3]] # Version of FFTW to look for (only considers major version)
# [COMPONENTS <libs>...] # List of libraries to look for
# )
#
# Valid names for COMPONENTS libraries are::
#
# ALL - Find all libraries
# FFTW - Find a FFTW (double) library
# FFTW_MT - Find a FFTW multi-threaded (double) library
# FFTWF - Find a FFTW (single) library
# FFTWF_MT - Find a FFTW multi-threaded (single) library
#
# Not specifying COMPONENTS is identical to choosing ALL
#
# This module defines::
#
# FFTW_FOUND - True if headers and requested libraries were found
# FFTW_VERSION - Version of the FFTW libraries
# FFTW_INCLUDE_DIRS - FFTW include directories
# FFTW_LIBRARIES - FFTW component libraries to be linked
#
#
# This module reads hints about search locations from variables
# (either CMake variables or environment variables)::
#
# FFTW_ROOT - Preferred installation prefix for FFTW
# FFTW_DIR - Preferred installation prefix for FFTW
#
#
# The following :prop_tgt:`IMPORTED` targets are also defined::
#
# FFTW::FFTW - Imported target for the FFTW (double) library
# FFTW::FFTW_MT - Imported target for the FFTW multi-thread (double) library
# FFTW::FFTWF - Imported target for the FFTW (single) library
# FFTW::FFTWF_MT - Imported target for the FFTW multi-thread (single) library
#
# ==============================================================================
# Copyright 2018 Damien Nguyen <damien.nguyen@alumni.epfl.ch>
#
# Distributed under the OSI-approved BSD License (the "License")
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# ==============================================================================
set(FFTW_SEARCH_PATHS
${FFTW_ROOT}
$ENV{FFTW_ROOT}
${FFTW_DIR}
$ENV{FFTW_DIR}
${CMAKE_PREFIX_PATH}
$ENV{CMAKE_PREFIX_PATH}
/sw
/usr
/usr/local/
/usr/local/opt # homebrew on mac
/opt
/opt/local
/opt/FFTW
)
set(INC_PATH_SUFFIXES_LIST
include
include/fftw
include/fftw3
)
set(LIB_PATH_SUFFIXES_LIST
lib64
lib
lib/fftw
lib/x86_64-linux-gnu
lib32
)
# ==============================================================================
# Prepare some helper variables
set(FFTW_REQUIRED_VARS)
set(FFTW_INCLUDE_DIRS)
set(FFTW_LIBRARIES)
# ==============================================================================
macro(_find_library_with_header component libnames incnames)
find_library(FFTW_${component}_LIB
NAMES ${libnames}
PATHS ${FFTW_SEARCH_PATHS}
PATH_SUFFIXES ${LIB_PATH_SUFFIXES_LIST})
if(FFTW_${component}_LIB)
set(FFTW_${component}_LIB_FOUND 1)
endif()
list(APPEND FFTW_REQUIRED_VARS "FFTW_${component}_LIB")
# If necessary, look for the header file as well
if(NOT "${incnames}" STREQUAL "")
find_path(FFTW_${component}_INCLUDE_DIR
NAMES ${incnames}
PATHS ${FFTW_SEARCH_PATHS}
PATH_SUFFIXES ${INC_PATH_SUFFIXES_LIST})
list(APPEND FFTW_REQUIRED_VARS "FFTW_${component}_INCLUDE_DIR")
if(FFTW_${component}_LIB)
set(FFTW_${component}_INC_FOUND 1)
endif()
else()
set(FFTW_${component}_INC_FOUND 1)
endif()
if(FFTW_${component}_LIB_FOUND AND FFTW_${component}_INC_FOUND)
set(FFTW_${component}_FOUND 1)
else()
set(FFTW_${component}_FOUND 0)
endif()
endmacro()
macro(_mangle_names)
endmacro()
# ------------------------------------------------------------------------------
# Make sure that all components are in capitals
set(_tmp_component_list)
foreach(_comp ${FFTW_FIND_COMPONENTS})
string(TOUPPER ${_comp} _comp)
list(APPEND _tmp_component_list ${_comp})
endforeach()
set(FFTW_FIND_COMPONENTS ${_tmp_component_list})
set(_tmp_component_list)
# ------------------------------------------------------------------------------
## FFTW can be compiled and subsequently linked against
## various data types.
## There is a single set of include files, and then muttiple libraries,
## One for each type. I.e. libfftw.a-->double, libfftwf.a-->float
set(FFTW_INC_SEARCHPATH
/sw/include
/usr/include
/usr/local/include
/usr/include/fftw
/usr/include/fftw3
/usr/local/include/fftw
/usr/local/include/fftw3
)
find_path(FFTW_INCLUDE_PATH fftw3.h ${FFTW_INC_SEARCHPATH})
if(NOT FFTW_FIND_COMPONENTS OR FFTW_FIND_COMPONENTS STREQUAL "ALL")
set(FFTW_FIND_ALL_COMPONENTS 1)
set(FFTW_FIND_COMPONENTS "FFTW;FFTW_MT;FFTWF;FFTWF_MT")
endif()
if(FFTW_INCLUDE_PATH)
file(TO_CMAKE_PATH "${FFTW_INCLUDE_PATH}" FFTW_INCLUDE_PATH)
set(FFTW_INCLUDE ${FFTW_INCLUDE_PATH})
if(NOT DEFINED FFTW_FIND_VERSION_MAJOR)
set(FFTW_FIND_VERSION_MAJOR 3)
endif()
if(FFTW_INCLUDE)
include_directories(${FFTW_INCLUDE})
if(FFTW_FIND_VERSION_MAJOR EQUAL 2)
set(_fftw_suffix "")
elseif(FFTW_FIND_VERSION_MAJOR EQUAL 3)
set(_fftw_suffix "3")
else()
message(FATAL_ERROR "Unsupported version number for FFTW")
endif()
get_filename_component(FFTW_INSTALL_BASE_PATH ${FFTW_INCLUDE_PATH} PATH)
# ------------------------------------------------------------------------------
set(FFTW_LIB_SEARCHPATH
${FFTW_INSTALL_BASE_PATH}/lib
${FFTW_INSTALL_BASE_PATH}/lib64
/usr/lib/fftw
/usr/local/lib/fftw
)
foreach(_comp ${FFTW_FIND_COMPONENTS})
if(_comp STREQUAL "FFTW")
_find_library_with_header(${_comp} fftw${_fftw_suffix} fftw${_fftw_suffix}.h)
elseif(_comp STREQUAL "FFTW_MT")
_find_library_with_header(${_comp} fftw${_fftw_suffix}_threads fftw${_fftw_suffix}.h)
elseif(_comp STREQUAL "FFTWF" AND FFTW_FIND_VERSION_MAJOR GREATER 2)
_find_library_with_header(${_comp} fftw${_fftw_suffix}f fftw${_fftw_suffix}.h)
elseif(_comp STREQUAL "FFTWF_MT" AND FFTW_FIND_VERSION_MAJOR GREATER 2)
_find_library_with_header(${_comp} fftw${_fftw_suffix}f_threads fftw${_fftw_suffix}.h)
else()
message(FATAL_ERROR "Unknown component (looked for FFTW ${FFTW_FIND_VERSION_MAJOR}): ${_comp}")
endif()
mark_as_advanced(
FFTW_${_comp}_LIB
FFTW_${_comp}_INCLUDE_DIR)
endforeach()
# ==============================================================================
if(USE_FFTWD)
mark_as_advanced(FFTWD_LIB)
find_library(FFTWD_LIB fftw3 ${FFTW_LIB_SEARCHPATH}) #Double Precision Lib
find_library(FFTWD_THREADS_LIB fftw3_threads ${FFTW_LIB_SEARCHPATH}) #Double Precision Lib only if compiled with threads support
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFTW
FOUND_VAR FFTW_FOUND
REQUIRED_VARS ${FFTW_REQUIRED_VARS}
HANDLE_COMPONENTS)
if(FFTWD_LIB)
set(FFTWD_FOUND 1)
get_filename_component(FFTW_LIBDIR ${FFTWD_LIB} PATH)
if(FFTWD_THREADS_LIB)
set(FFTWD_LIB ${FFTWD_LIB} ${FFTWD_THREADS_LIB} )
# ==============================================================================
if(FFTW_FOUND)
# Inspired by FindBoost.cmake
foreach(_comp ${FFTW_FIND_COMPONENTS})
if(NOT TARGET FFTW::${_comp} AND FFTW_${_comp}_FOUND)
get_filename_component(LIB_EXT "${FFTW_${_comp}_LIB}" EXT)
if(LIB_EXT STREQUAL ".a" OR LIB_EXT STREQUAL ".lib")
set(LIB_TYPE STATIC)
else()
set(LIB_TYPE SHARED)
endif()
add_library(FFTW::${_comp} ${LIB_TYPE} IMPORTED GLOBAL)
set_target_properties(FFTW::${_comp}
PROPERTIES
IMPORTED_LOCATION "${FFTW_${_comp}_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${FFTW_${_comp}_INCLUDE_DIR}")
endif()
if(FFTW_${_comp}_FOUND)
set(APPEND FFTW_INCLUDE_DIRS "${FFTW_${_comp}_INCLUDE_DIR}")
set(APPEND FFTW_LIBRARIES "${FFTW_${_comp}_LIB}")
endif()
endforeach()
if(USE_FFTWF)
mark_as_advanced(FFTWF_LIB)
find_library(FFTWF_LIB fftw3f ${FFTW_LIB_SEARCHPATH}) #Single Precision Lib
find_library(FFTWF_THREADS_LIB fftw3f_threads ${FFTW_LIB_SEARCHPATH}) #Single Precision Lib only if compiled with threads support
# ----------------------------------------------------------------------------
if(FFTWF_LIB)
set(FFTWF_FOUND 1)
get_filename_component(FFTW_LIBDIR ${FFTWF_LIB} PATH)
if(FFTWF_THREADS_LIB)
set(FFTWF_LIB ${FFTWF_LIB} ${FFTWF_THREADS_LIB} )
endif()
if(NOT FFTW_FIND_QUIETLY)
message(STATUS "Found FFTW and defined the following imported targets:")
foreach(_comp ${FFTW_FIND_COMPONENTS})
message(STATUS " - FFTW::${_comp}:")
message(STATUS " + include: ${FFTW_${_comp}_INCLUDE_DIR}")
message(STATUS " + library: ${FFTW_${_comp}_LIB}")
endforeach()
endif()
endif()
set(FFTWD_LIBRARIES ${FFTWD_LIB})
set(FFTWF_LIBRARIES ${FFTWF_LIB})
# ==============================================================================
mark_as_advanced(
FFTW_FOUND
FFTW_INCLUDE_DIRS
FFTW_LIBRARIES
)
......@@ -2,189 +2,248 @@
# FindLAPACKE
# -------------
#
# Find the LAPACKE library
# Find LAPACKE include dirs and libraries
#
# Using LAPACKE:
# Use this module by invoking find_package with the form::
#
# ::
# find_package(LAPACKE
# [REQUIRED] # Fail with error if LAPACKE is not found
# [COMPONENTS <libs>...] # List of libraries to look for
# )
#
# find_package(LAPACKE REQUIRED)
# include_directories(${LAPACKE_INCLUDE_DIRS})
# add_executable(foo foo.cc)
# target_link_libraries(foo ${LAPACKE_LIBRARIES})
# Valid names for COMPONENTS libraries are::
#
# This module sets the following variables:
# ALL - Find all libraries
# LAPACKE_H - Find the lapacke.h header file
# LAPACKE - Find a LAPACKE library
# LAPACK - Find a LAPACK library
# CBLAS - Find a CBLAS library
# BLAS - Find a BLAS library
#
# ::
# Not specifying COMPONENTS is identical to choosing ALL
#
# This module defines::
#
# LAPACKE_FOUND - True if headers and requested libraries were found
# LAPACKE_INCLUDE_DIRS - LAPACKE include directories
# LAPACKE_LIBRARIES - LAPACKE component libraries to be linked
#
#
# This module reads hints about search locations from variables
# (either CMake variables or environment variables)::
#
# LAPACKE_ROOT - Preferred installation prefix for LAPACKE
# LAPACKE_DIR - Preferred installation prefix for LAPACKE
#
#
# The following :prop_tgt:`IMPORTED` targets are also defined::
#
# LAPACKE::LAPACKE - Imported target for the LAPACKE library
# LAPACKE::LAPACK - Imported target for the LAPACK library
# LAPACKE::CBLAS - Imported target for the CBLAS library
# LAPACKE::BLAS - Imported target for the BLAS library
#
# LAPACKE_FOUND - set to true if the library is found
# LAPACKE_INCLUDE_DIRS - list of required include directories
# LAPACKE_LIBRARIES - list of libraries to be linked
# LAPACKE_VERSION_MAJOR - major version number
# LAPACKE_VERSION_MINOR - minor version number
# LAPACKE_VERSION_PATCH - patch version number
# LAPACKE_VERSION_STRING - version number as a string (ex: "0.2.18")
#=============================================================================
# Copyright 2016 Hans J. Johnson <hans-johnson@uiowa.edu>
# ==============================================================================
# Copyright 2018 Damien Nguyen <damien.nguyen@alumni.epfl.ch>
#
# Distributed under the OSI-approved BSD License (the "License")
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#=============================================================================
#
# ==============================================================================
set(LAPACKE_SEARCH_PATHS
${LAPACKE_ROOT}
$ENV{LAPACKE_ROOT}
${LAPACKE_DIR}
$ENV{LAPACKE_DIR}
$ENV{CMAKE_PREFIX_PATH}
${CMAKE_PREFIX_PATH}
$ENV{CMAKE_PREFIX_PATH}
/usr
/usr/local
/usr/local/opt/lapack ## Mac Homebrew install path
/usr/local/
/usr/local/opt # homebrew on mac
/opt
/opt/local
/opt/LAPACKE
)
message(STATUS "LAPACKE_SEARCH_PATHS: ${LAPACKE_SEARCH_PATHS}")
set(CMAKE_PREFIX_PATH ${LAPACKE_SEARCH_PATHS})
list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH)
set(LIB_PATH_SUFFIXES
lib64
lib
lib/x86_64-linux-gnu
lib32
)
set(INC_PATH_SUFFIXES
include
include/lapack
include/lapacke/
lapack/include
lapacke/include
)
## First try to find LAPACKE with NO_MODULE,
## As of 20160706 version 0.2.18 there is limited cmake support for LAPACKE
## that is not as complete as this version, if found, use it
## to identify the LAPACKE_VERSION_STRING and improve searching.
find_package(LAPACKE NO_MODULE QUIET)
if(LAPACKE_FOUND)
if(EXISTS ${LAPACKE_DIR}/lapacke-config-version.cmake)
include(${LAPACKE_DIR}/lapacke-config-version.cmake)
set(LAPACKE_VERSION_STRING ${PACKAGE_VERSION})
unset(PACKAGE_VERSION) # Use cmake conventional naming
endif()
find_package(LAPACK NO_MODULE QUIET) #Require matching versions here!
find_package(BLAS NO_MODULE QUIET) #Require matching versions here!
if(APPLE)
list(APPEND LIB_PATH_SUFFIXES lapack/lib openblas/lib)
elseif(WIN32)
list(APPEND LAPACKE_SEARCH_PATHS "C:/Program Files (x86)/LAPACK")
list(APPEND LAPACKE_SEARCH_PATHS "C:/Program Files/LAPACK")
endif()
##################################################################################################
### First search for headers
find_path(LAPACKE_CBLAS_INCLUDE_DIR
NAMES cblas.h
PATHS ${LAPACKE_SEARCH_PATHS}
PATH_SUFFIXES include include/lapack)
find_path(LAPACKE_LAPACKE_INCLUDE_DIR
NAMES lapacke.h
PATHS ${LAPACKE_SEARCH_PATHS}
PATH_SUFFIXES include)
# ==============================================================================
# Prepare some helper variables
##################################################################################################
### Second, search for libraries
set(PATH_SUFFIXES_LIST
lib64
lib
)
find_library(LAPACKE_LIB
NAMES lapacke
PATHS ${LAPACKE_SEARCH_PATHS}
PATH_SUFFIXES ${PATH_SUFFIXES_LIST})
find_library(CBLAS_LIB
NAMES cblas
set(LAPACKE_INCLUDE_DIRS)
set(LAPACKE_LIBRARIES)
set(LAPACKE_REQUIRED_VARS)
set(LAPACKE_FIND_ALL_COMPONENTS 0)
# ==============================================================================
macro(_find_library_with_header component incname)
find_library(LAPACKE_${component}_LIB
NAMES ${ARGN}
NAMES_PER_DIR
PATHS ${LAPACKE_SEARCH_PATHS}
PATH_SUFFIXES ${PATH_SUFFIXES_LIST})
find_library(LAPACK_LIB
NAMES lapack
PATH_SUFFIXES ${LIB_PATH_SUFFIXES})
if(LAPACKE_${component}_LIB)
set(LAPACKE_${component}_LIB_FOUND 1)
endif()
list(APPEND LAPACKE_REQUIRED_VARS "LAPACKE_${component}_LIB")
# If necessary, look for the header file as well
if(NOT "${incname}" STREQUAL "")
find_path(LAPACKE_${component}_INCLUDE_DIR
NAMES ${incname}
PATHS ${LAPACKE_SEARCH_PATHS}
PATH_SUFFIXES ${PATH_SUFFIXES_LIST})
find_library(BLAS_LIB
NAMES blas
PATH_SUFFIXES ${INC_PATH_SUFFIXES})
list(APPEND LAPACKE_REQUIRED_VARS "LAPACKE_${component}_INCLUDE_DIR")
if(LAPACKE_${component}_LIB)
set(LAPACKE_${component}_INC_FOUND 1)
endif()
else()
set(LAPACKE_${component}_INC_FOUND 1)
endif()
if(LAPACKE_${component}_LIB_FOUND AND LAPACKE_${component}_INC_FOUND)
set(LAPACKE_${component}_FOUND 1)
else()
set(LAPACKE_${component}_FOUND 0)
endif()
endmacro()
# ------------------------------------------------------------------------------
if(NOT LAPACKE_FIND_COMPONENTS OR LAPACKE_FIND_COMPONENTS STREQUAL "ALL")
set(LAPACKE_FIND_ALL_COMPONENTS 1)
set(LAPACKE_FIND_COMPONENTS "LAPACKE;LAPACK;CBLAS;BLAS")
endif(NOT LAPACKE_FIND_COMPONENTS OR LAPACKE_FIND_COMPONENTS STREQUAL "ALL")
# Make sure that all components are in capitals
set(_tmp_component_list)
foreach(_comp ${LAPACKE_FIND_COMPONENTS})
string(TOUPPER ${_comp} _comp)
list(APPEND _tmp_component_list ${_comp})
endforeach()
set(LAPACKE_FIND_COMPONENTS ${_tmp_component_list})
set(_tmp_component_list)
foreach(_comp ${LAPACKE_FIND_COMPONENTS})
if(_comp STREQUAL "LAPACKE")
_find_library_with_header(${_comp} lapacke.h lapacke liblapacke)
elseif(_comp STREQUAL "LAPACKE_H")
find_path(LAPACKE_${_comp}_INCLUDE_DIR
NAMES lapacke.h
PATHS ${LAPACKE_SEARCH_PATHS}
PATH_SUFFIXES ${PATH_SUFFIXES_LIST})
## TODO: Get version components
# ------------------------------------------------------------------------
# Extract version information
# ------------------------------------------------------------------------
# WARNING: We may not be able to determine the version of some LAPACKE
set(LAPACKE_VERSION_MAJOR 0)
set(LAPACKE_VERSION_MINOR 0)
set(LAPACKE_VERSION_PATCH 0)
if(LAPACKE_VERSION_STRING)
string(REGEX REPLACE "([0-9]+).([0-9]+).([0-9]+)" "\\1" LAPACKE_VERSION_MAJOR "${LAPACKE_VERSION_STRING}")
string(REGEX REPLACE "([0-9]+).([0-9]+).([0-9]+)" "\\2" LAPACKE_VERSION_MINOR "${LAPACKE_VERSION_STRING}")
string(REGEX REPLACE "([0-9]+).([0-9]+).([0-9]+)" "\\3" LAPACKE_VERSION_PATCH "${LAPACKE_VERSION_STRING}")
PATH_SUFFIXES include lapack/include)
list(APPEND LAPACKE_REQUIRED_VARS "LAPACKE_${_comp}_INCLUDE_DIR")
if(LAPACKE_${_comp}_LIB)
set(LAPACKE_${_comp}_INC_FOUND 1)
endif()
elseif(_comp STREQUAL "LAPACK")
_find_library_with_header(${_comp} "" lapack liblapack)
elseif(_comp STREQUAL "CBLAS")
_find_library_with_header(${_comp} cblas.h cblas libcblas)
elseif(_comp STREQUAL "BLAS")
_find_library_with_header(${_comp} "" blas blas)
else()
message(FATAL_ERROR "Unknown component: ${_comp}")
endif()
mark_as_advanced(
LAPACKE_${_comp}_LIB
LAPACKE_${_comp}_INCLUDE_DIR)
endforeach()
# ==============================================================================
#======================
# Checks 'REQUIRED', 'QUIET' and versions.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LAPACKE FOUND_VAR LAPACKE_FOUND
REQUIRED_VARS LAPACKE_CBLAS_INCLUDE_DIR
LAPACKE_LAPACKE_INCLUDE_DIR
LAPACKE_LIB
LAPACK_LIB
CBLAS_LIB
BLAS_LIB
VERSION_VAR LAPACKE_VERSION_STRING
)
find_package_handle_standard_args(LAPACKE
FOUND_VAR LAPACKE_FOUND
REQUIRED_VARS ${LAPACKE_REQUIRED_VARS}
HANDLE_COMPONENTS)
# ==============================================================================
if(LAPACKE_FOUND)
set(LAPACKE_INCLUDE_DIRS ${LAPACKE_CBLAS_INCLUDE_DIR} ${LAPACKE_CBLAS_INCLUDE_DIR})
list(REMOVE_DUPLICATES LAPACKE_INCLUDE_DIRS)
foreach(_comp ${LAPACKE_FIND_COMPONENTS})
list(APPEND LAPACKE_INCLUDE_DIRS ${LAPACKE_${_comp}_INCLUDE_DIR})
list(APPEND LAPACKE_LIBRARIES ${LAPACKE_${_comp}_LIB})
endforeach()
if("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*" OR
"${CMAKE_C_COMPILER_ID}" MATCHES ".*GNU.*" OR
"${CMAKE_C_COMPILER_ID}" MATCHES ".*Intel.*"
) #NOT MSVC
set(MATH_LIB m)
set(MATH_LIB "m")
list(APPEND LAPACKE_LIBRARIES m)
endif()
list(APPEND LAPACKE_LIBRARIES ${LAPACKE_LIB} ${LAPACK_LIB} ${BLAS_LIB} ${CBLAS_LIB})
# Check for a common combination, and find required gfortran support libraries
if(1)
if("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*" AND "${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
message(STATUS "\n\n WARNING: ${CMAKE_C_COMPILER} identified as ${CMAKE_C_COMPILER_ID}\n"
"AND: ${CMAKE_Fortran_COMPILER} identified as ${CMAKE_Fortran_COMPILER_ID}\n"
"\n"
"may be require special configurations. The most common is the need to"
"explicitly link C programs against the gfortran support library.")
endif()
else()
## This code automated code is hard to determine if it is robust in many different environments.
# Check for a common combination, and find required gfortran support libraries
if("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*" AND "${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
include(FortranCInterface)
FortranCInterface_VERIFY()
if(NOT FortranCInterface_VERIFIED_C)
message(FATAL_ERROR "C and fortran compilers are not compatible:\n${CMAKE_Fortran_COMPILER}:${CMAKE_C_COMPILER}")
if(NOT "${LAPACKE_INCLUDE_DIRS}" STREQUAL "")
list(REMOVE_DUPLICATES LAPACKE_INCLUDE_DIRS)
endif()
execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -print-file-name=libgfortran.a OUTPUT_VARIABLE FORTRANSUPPORTLIB ERROR_QUIET)
string(STRIP ${FORTRANSUPPORTLIB} FORTRANSUPPORTLIB)
if(EXISTS "${FORTRANSUPPORTLIB}")
list(APPEND LAPACKE_LIBRARIES ${FORTRANSUPPORTLIB})
message(STATUS "Appending fortran support lib: ${FORTRANSUPPORTLIB}")
# ----------------------------------------------------------------------------
# Inspired by FindBoost.cmake
foreach(_comp ${LAPACKE_FIND_COMPONENTS})
if(NOT TARGET LAPACKE::${_comp} AND LAPACKE_${_comp}_FOUND)
get_filename_component(LIB_EXT "${LAPACKE_${_comp}_LIB}" EXT)
if(LIB_EXT STREQUAL ".a" OR LIB_EXT STREQUAL ".lib")
set(LIB_TYPE STATIC)
else()
message(FATAL_ERROR "COULD NOT FIND libgfortran.a support library:${FORTRANSUPPORTLIB}:")
set(LIB_TYPE SHARED)
endif()
add_library(LAPACKE::${_comp} ${LIB_TYPE} IMPORTED GLOBAL)
if(LAPACKE_INCLUDE_DIRS)
set_target_properties(LAPACKE::${_comp} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${LAPACKE_INCLUDE_DIRS}")
endif()
if(EXISTS "${LAPACKE_${_comp}_LIB}")
set_target_properties(LAPACKE::${_comp} PROPERTIES
IMPORTED_LOCATION "${LAPACKE_${_comp}_LIB}")
endif()
list(APPEND LAPACKE_LIBRARIES ${MATH_LIB})
set_target_properties(LAPACKE::${_comp} PROPERTIES
INTERFACE_LINK_LIBRARIES "${MATH_LIB}")
endif()
endforeach()
# ----------------------------------------------------------------------------
if(NOT LAPACKE_FIND_QUIETLY)
message(STATUS "Found LAPACKE and defined the following imported targets:")
foreach(_comp ${LAPACKE_FIND_COMPONENTS})
message(STATUS " - LAPACKE::${_comp}:")
message(STATUS " + include: ${LAPACKE_INCLUDE_DIRS}")
message(STATUS " + library: ${LAPACKE_${_comp}_LIB}")
message(STATUS " + dependencies: ${MATH_LIB}")
endforeach()
endif()
endif()
# ==============================================================================
mark_as_advanced(
LAPACKE_FOUND
LAPACKE_INCLUDE_DIRS
LAPACKE_LIBRARIES
LAPACKE_VERSION_MAJOR
LAPACKE_VERSION_MINOR
LAPACKE_VERSION_PATCH
LAPACKE_VERSION_STRING
)
## For debugging
message(STATUS "LAPACKE_FOUND :${LAPACKE_FOUND}: - set to true if the library is found")
message(STATUS "LAPACKE_INCLUDE_DIRS :${LAPACKE_INCLUDE_DIRS}: - list of required include directories")
message(STATUS "LAPACKE_LIBRARIES :${LAPACKE_LIBRARIES}: - list of libraries to be linked")
message(STATUS "LAPACKE_VERSION_MAJOR :${LAPACKE_VERSION_MAJOR}: - major version number")
message(STATUS "LAPACKE_VERSION_MINOR :${LAPACKE_VERSION_MINOR}: - minor version number")
message(STATUS "LAPACKE_VERSION_PATCH :${LAPACKE_VERSION_PATCH}: - patch version number")
message(STATUS "LAPACKE_VERSION_STRING :${LAPACKE_VERSION_STRING}: - version number as a string")
......@@ -2,22 +2,16 @@
# FindOpenBLAS
# -------------
#
# Find the OpenBLAS library
# Find OpenBLAS include dirs and libraries
#
# Using OpenBLAS:
# Use this module by invoking find_package with the form::
#
# ::
# find_package(OpenBLAS
# [REQUIRED] # Fail with error if OpenBLAS is not found
# )
#
# find_package(OpenBLAS REQUIRED)
# include_directories(${OpenBLAS_INCLUDE_DIRS})
# add_executable(foo foo.cc)
# target_link_libraries(foo ${OpenBLAS_LIBRARIES})
# -- OR --
# target_link_libraries(foo ${OpenBLAS_PARALLEL_LIBRARIES})
#
# This module sets the following variables:
#
# ::
# This module defines::
#
# OpenBLAS_FOUND - set to true if the library is found
# OpenBLAS_INCLUDE_DIRS - list of required include directories
......@@ -28,31 +22,62 @@
# OpenBLAS_VERSION_MINOR - minor version number
# OpenBLAS_VERSION_PATCH - patch version number
# OpenBLAS_VERSION_STRING - version number as a string (ex: "0.2.18")
#
#
# This module reads hints about search locations from variables
# (either CMake variables or environment variables)::
#
# OpenBLAS_ROOT - Preferred installation prefix for OpenBLAS
# OpenBLAS_DIR - (for compatibility purposes)
#
#
# OpenBLAS::OpenBLAS - Imported target for the OpenBLAS library
#
#=============================================================================
# ==============================================================================
# Copyright 2016 Hans J. Johnson <hans-johnson@uiowa.edu>
# Copyright 2018 Damien Nguyen <damien.nguyen@alumni.epfl.ch>
#
# Distributed under the OSI-approved BSD License (the "License")
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#=============================================================================
#
set(OpenBLAS_HAS_PARALLEL_LIBRARIES FALSE)
# ==============================================================================
set(OpenBLAS_SEARCH_PATHS
${OpenBLAS_ROOT}
$ENV{OpenBLAS_ROOT}
${OpenBLAS_DIR}
$ENV{OpenBLAS_DIR}
$ENV{CMAKE_PREFIX_PATH}
${CMAKE_PREFIX_PATH}
$ENV{CMAKE_PREFIX_PATH}
/usr
/usr/local
/usr/local/opt/openblas ## Mac Homebrew install path
/usr/local/
/usr/local/opt # homebrew on mac
/opt
/opt/local
/opt/OpenBLAS
)
set(CMAKE_PREFIX_PATH ${OpenBLAS_SEARCH_PATHS})
list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH)
set(PATH_SUFFIXES_LIST
lib64
lib
lib/x86_64-linux-gnu
lib32
)
if(APPLE)
list(APPEND PATH_SUFFIXES_LIST openblas/lib)
endif()
# ==============================================================================
# Prepare some helper variables
set(OpenBLAS_INCLUDE_DIRS)
set(OpenBLAS_LIBRARIES)
set(OpenBLAS_HAS_PARALLEL_LIBRARIES FALSE)
# ==============================================================================
## First try to find OpenBLAS with NO_MODULE,
## As of 20160706 version 0.2.18 there is limited cmake support for OpenBLAS
......@@ -63,33 +88,47 @@ if(OpenBLAS_VERSION)
set(OpenBLAS_VERSION_STRING ${OpenBLAS_VERSION})
unset(OpenBLAS_VERSION) # Use cmake conventional naming
endif()
##################################################################################################
# ==============================================================================
### First search for headers
find_path(OpenBLAS_CBLAS_INCLUDE_DIR
NAMES cblas.h
PATHS ${OpenBLAS_SEARCH_PATHS}
PATH_SUFFIXES include include/openblas)
find_path(OpenBLAS_LAPACKE_INCLUDE_DIR
NAMES lapacke.h
PATHS ${OpenBLAS_SEARCH_PATHS}
PATH_SUFFIXES include)
##################################################################################################
# ==============================================================================
### Second, search for libraries
set(PATH_SUFFIXES_LIST
lib64
lib
)
find_library(OpenBLAS_LIB
NAMES openblas
PATHS ${OpenBLAS_SEARCH_PATHS}
PATH_SUFFIXES ${PATH_SUFFIXES_LIST})
if(EXISTS ${OpenBLAS_LIB})
if(OpenBLAS_LIB)
get_filename_component(OpenBLAS_LIB_DIR i${OpenBLAS_LIB} DIRECTORY)
include(CheckLibraryExists)
check_library_exists(${OpenBLAS_LIB} LAPACKE_cheev "" HAVE_LAPACKE_CHEEV)
check_library_exists(${OpenBLAS_LIB} LAPACKE_zgesdd "" HAVE_LAPACKE_ZGESDD)
if(NOT HAVE_LAPACKE_CHEEV OR NOT HAVE_LAPACKE_ZGESDD)
message(WARNING "OpenBLAS has no LAPACKE symbols. Attempting to look for a LAPACKE library")
find_package(LAPACKE QUIET COMPONENTS LAPACKE)
if(LAPACKE_FOUND)
message(STATUS "Found LAPACKE: ${LAPACKE_LIBRARIES}")
list(APPEND OpenBLAS_LIBRARIES ${LAPACKE_LIBRARIES})
else()
message(WARNING "Unable to find a LAPACKE library. Consider configuring CMake with BART_NO_LAPACKE=ON")
endif()
else()
# Make sure we find lapacke.h
find_package(LAPACKE QUIET COMPONENTS LAPACKE_H)
endif()
endif()
## Find the named parallel version of openblas
set(OpenBLAS_SEARCH_VERSIONS ${OpenBLAS_VERSION_STRING} 0.2.19 0.2.18 0.2.17 0.2.16)
set(OpenBLAS_SEARCH_VERSIONS ${OpenBLAS_VERSION_STRING} 0.3.2 0.3.1 0.3.0 0.2.19 0.2.18 0.2.17 0.2.16)
list(REMOVE_DUPLICATES OpenBLAS_SEARCH_VERSIONS)
foreach(checkVersion ${OpenBLAS_SEARCH_VERSIONS})
find_library(OpenBLAS_PARALLEL_LIB
......@@ -106,10 +145,6 @@ foreach(checkVersion ${OpenBLAS_SEARCH_VERSIONS})
endif()
endforeach()
# ------------------------------------------------------------------------
# Extract version information
# ------------------------------------------------------------------------
# WARNING: We may not be able to determine the version of some OpenBLAS
set(OpenBLAS_VERSION_MAJOR 0)
set(OpenBLAS_VERSION_MINOR 0)
......@@ -120,20 +155,26 @@ if(OpenBLAS_VERSION_STRING)
string(REGEX REPLACE "([0-9]+).([0-9]+).([0-9]+)" "\\3" OpenBLAS_VERSION_PATCH "${OpenBLAS_VERSION_STRING}")
endif()
#======================
# ==============================================================================
# Checks 'REQUIRED', 'QUIET' and versions.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenBLAS FOUND_VAR OpenBLAS_FOUND
REQUIRED_VARS
OpenBLAS_CBLAS_INCLUDE_DIR
OpenBLAS_LAPACKE_INCLUDE_DIR
OpenBLAS_LIB
LAPACKE_INCLUDE_DIRS
VERSION_VAR OpenBLAS_VERSION_STRING
)
# ------------------------------------------------------------------------------
if (OpenBLAS_FOUND)
set(OpenBLAS_INCLUDE_DIRS ${OpenBLAS_CBLAS_INCLUDE_DIR} ${OpenBLAS_CBLAS_INCLUDE_DIR})
list(APPEND OpenBLAS_INCLUDE_DIRS
${OpenBLAS_CBLAS_INCLUDE_DIR}
${LAPACKE_INCLUDE_DIRS})
list(REMOVE_DUPLICATES OpenBLAS_INCLUDE_DIRS)
if("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*" OR
"${CMAKE_C_COMPILER_ID}" MATCHES ".*GNU.*" OR
"${CMAKE_C_COMPILER_ID}" MATCHES ".*Intel.*"
......@@ -141,11 +182,53 @@ if (OpenBLAS_FOUND)
set(MATH_LIB m)
endif()
list(APPEND OpenBLAS_LIBRARIES ${OpenBLAS_LIB} ${MATH_LIB})
if(OpenBLAS_HAS_PARALLEL_LIBRARIES)
list(APPEND OpenBLAS_PARALLEL_LIBRARIES ${OpenBLAS_PARALLEL_LIB})
endif()
# ----------------------------------------------------------------------------
if(NOT TARGET OpenBLAS::OpenBLAS)
get_filename_component(LIB_EXT "${LAPACKE_${UPPERCOMPONENT}_LIB}" EXT)
if(LIB_EXT STREQUAL ".a" OR LIB_EXT STREQUAL ".lib")
set(LIB_TYPE STATIC)
else()
set(LIB_TYPE SHARED)
endif()
add_library(OpenBLAS::OpenBLAS ${LIB_TYPE} IMPORTED GLOBAL)
set(_tmp_dep_libs "${MATH_LIB};${LAPACKE_LIBRARIES}")
list(REMOVE_DUPLICATES _tmp_dep_libs)
set_target_properties(OpenBLAS::OpenBLAS
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OpenBLAS_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${_tmp_dep_libs}")
if(OpenBLAS_HAS_PARALLEL_LIBRARIES)
set_target_properties(OpenBLAS::OpenBLAS
PROPERTIES
IMPORTED_LOCATION "${OpenBLAS_PARALLEL_LIB}")
else()
set_target_properties(OpenBLAS::OpenBLAS
PROPERTIES
IMPORTED_LOCATION "${OpenBLAS_LIB}")
endif()
endif()
# ----------------------------------------------------------------------------
if(NOT OpenBLAS_FIND_QUIETLY)
get_target_property(_lib OpenBLAS::OpenBLAS IMPORTED_LOCATION)
get_target_property(_dep_libs OpenBLAS::OpenBLAS INTERFACE_LINK_LIBRARIES)
message(STATUS "Found OpenBLAS and defined the OpenBLAS::OpenBLAS imported target:")
message(STATUS " - include: ${OpenBLAS_INCLUDE_DIRS}")
message(STATUS " - library: ${_lib}")
message(STATUS " - dependencies: ${_dep_libs}")
endif()
endif()
# ==============================================================================
mark_as_advanced(
OpenBLAS_FOUND
OpenBLAS_INCLUDE_DIRS
......@@ -158,13 +241,3 @@ mark_as_advanced(
OpenBLAS_VERSION_STRING
)
## For debugging
message(STATUS "OpenBLAS_FOUND :${OpenBLAS_FOUND}: - set to true if the library is found")
message(STATUS "OpenBLAS_INCLUDE_DIRS :${OpenBLAS_INCLUDE_DIRS}: - list of required include directories")
message(STATUS "OpenBLAS_LIBRARIES :${OpenBLAS_LIBRARIES}: - list of libraries to be linked")
message(STATUS "OpenBLAS_HAS_PARALLEL_LIBRARIES :${OpenBLAS_HAS_PARALLEL_LIBRARIES}: - determine if there are parallel libraries compiled")
message(STATUS "OpenBLAS_PARALLEL_LIBRARIES :${OpenBLAS_PARALLEL_LIBRARIES}: - list of libraries for parallel implementations")
message(STATUS "OpenBLAS_VERSION_MAJOR :${OpenBLAS_VERSION_MAJOR}: - major version number")
message(STATUS "OpenBLAS_VERSION_MINOR :${OpenBLAS_VERSION_MINOR}: - minor version number")
message(STATUS "OpenBLAS_VERSION_PATCH :${OpenBLAS_VERSION_PATCH}: - patch version number")
message(STATUS "OpenBLAS_VERSION_STRING :${OpenBLAS_VERSION_STRING}: - version number as a string")
This diff is collapsed.
#.rst:
# FindlibFlame
# -------------
#
# Find libFlame include dirs and libraries
#
# Use this module by invoking find_package with the form::
#
# find_package(libFlame
# [REQUIRED] # Fail with error if libFlame is not found
# )
#
# This module defines::
#
# libFlame_FOUND - True if headers and requested libraries were found
# libFlame_INCLUDE_DIRS - libFlame include directories
# libFlame_LIBRARIES - libFlame component libraries to be linked
#
#
# This module reads hints about search locations from variables
# (either CMake variables or environment variables)::
#
# libFlame_ROOT - Preferred installation prefix
# libFlame_DIR - Preferred installation prefix
#
#
# The following :prop_tgt:`IMPORTED` targets are also defined::
#
# libFlame::libFlame - Target for specific component dependency
# (shared or static library)
#
# ==============================================================================
# Copyright 2018 Damien Nguyen <damien.nguyen@alumni.epfl.ch>
#
# Distributed under the OSI-approved BSD License (the "License")
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# ==============================================================================
set(libFlame_SEARCH_PATHS
${libFlame_ROOT}
$ENV{libFlame_ROOT}
${libFlame_DIR}
$ENV{libFlame_DIR}
$ENV{CMAKE_PREFIX_PATH}
${CMAKE_PREFIX_PATH}
/usr
/usr/local/
/usr/local/amd
/opt
/opt/amd
/opt/local
)
find_library(libFlame_LIBRARY
NAMES flame
PATHS ${libFlame_SEARCH_PATHS}
PATH_SUFFIXES lib lib32 lib64 libflame/lib
)
if(libFLame_LIBRARY)
get_filename_component(libFlame_ROOT_HINT ${libFlame_LIBRARY} PATH) # for CMake > 2.8.11 we should really use DIRECTORY
get_filename_component(libFlame_ROOT_HINT ${libFlame_ROOT_HINT} PATH)
endif()
find_path(libFlame_INCLUDE_DIR
NAMES FLAME.h flame.h
HINTS ${libFlame_ROOT_HINT}
PATHS ${libFlame_SEARCH_PATHS}
PATH_SUFFIXES include libflame/include
)
set(libFlame_LAPACKE_COMPONENTS cblas)
# ==============================================================================
if(libFLame_LIBRARY)
include(CheckLibraryExists)
check_library_exists(${libFlame_LIBRARY} zgesdd_ "" HAVE_ZGESDD)
check_library_exists(${libFlame_LIBRARY} zgelss_ "" HAVE_ZGELSS)
if(HAVE_ZGESDD AND HAVE_ZGELSS)
set(HAVE_LAPACK_INTERFACE 1)
else()
set(HAVE_LAPACK_INTERFACE 0)
endif()
set(LAPACK_LIB_VAR "")
if(NOT HAVE_LAPACK_INTERFACE)
message(STATUS "libFlame has no LAPACK interface, looking for a LAPACK library")
list(APPEND libFlame_LAPACKE_COMPONENTS lapack)
endif()
# ----------------------------------------------------------------------------
find_package(LAPACKE QUIET REQUIRED COMPONENTS ${libFlame_LAPACKE_COMPONENTS})
endif()
# ==============================================================================
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(libFlame
FOUND_VAR libFlame_FOUND
REQUIRED_VARS
libFlame_INCLUDE_DIR
libFlame_LIBRARY
LAPACKE_FOUND
LAPACKE_LIBRARIES
LAPACKE_INCLUDE_DIRS
)
# ==============================================================================
if(libFlame_FOUND)
set(libFlame_INCLUDE_DIRS)
list(APPEND libFlame_INCLUDE_DIRS
${libFlame_INCLUDE_DIR}
${LAPACKE_INCLUDE_DIRS})
list(REMOVE_DUPLICATES libFlame_INCLUDE_DIRS)
set(libFlame_LIBRARIES)
list(APPEND libFlame_LIBRARIES
${libFlame_LIBRARY}
${LAPACKE_LIBRARIES})
# ----------------------------------------------------------------------------
if(NOT TARGET libFlame::libFlame)
get_filename_component(LIB_EXT "${libFlame_LIBRARY}" EXT)
if(LIB_EXT STREQUAL ".a" OR LIB_EXT STREQUAL ".lib")
set(LIB_TYPE STATIC)
else()
set(LIB_TYPE SHARED)
endif()
add_library(libFlame::libFlame ${LIB_TYPE} IMPORTED GLOBAL)
set_target_properties(libFlame::libFlame PROPERTIES
IMPORTED_LOCATION "${libFlame_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${libFlame_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${LAPACKE_LIBRARIES}"
)
endif()
# ----------------------------------------------------------------------------
## For debugging
if(NOT libFlame_FIND_QUIETLY)
get_target_property(_dep_libs libFlame::libFlame INTERFACE_LINK_LIBRARIES)
message(STATUS "Found libFlame and defined the libFlame::libFlame imported target:")
message(STATUS " - include: ${libFlame_INCLUDE_DIR}")
message(STATUS " - library: ${libFlame_LIBRARY}")
message(STATUS " - dependencies: ${_dep_libs}")
endif()
endif()
# ==============================================================================
mark_as_advanced(
libFlame_LIBRARY
libFlame_INCLUDE_DIR
libFlame_CBLAS_INCLUDE_DIR
)
# ==============================================================================
set(_required_vars INFILE OUTFILE PREFIX)
foreach(_var ${_required_vars})
if(NOT DEFINED "${_var}")
message(FATAL_ERROR "Variable ${_var} is undefined!")
endif()
endforeach()
if(NOT EXISTS "${INFILE}")
message(FATAL_ERROR "\n\nMissing input file '${INFILE}' for generating '${OUTFILE}'\n\n")
endif()
# ==============================================================================
file(READ "${INFILE}" _file_content)
set(_prefix_string)
foreach(_line ${PREFIX})
set(_prefix_string "${_prefix_string}\n${_line}")
endforeach()
file(WRITE "${OUTFILE}" "${_prefix_string}\n\n\n${_file_content}")