Commit 74616e26 authored by PRUVOST Florent's avatar PRUVOST Florent

Branching from branches/new_magmamorse to trunk/chameleon at 2005

parent 0eddec2c

Too many changes to show.

To preserve performance only 213 of 213+ files are displayed.
;; C style for Emacs, to assist in following DAGuE coding conventions (originally from PETSc project)
((nil . ((indent-tabs-mode . nil)
(tab-width . 8)
(show-trailing-whitespace . t)))
(c-mode . ((c-tab-always-indent . t)
(c-basic-offset . 4)
(c-comment-only-line-offset . 0)
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open after)
(brace-entry-open)
(defun-open after)
(class-open after)
(inline-open after)
(block-open after)
(block-close . c-snug-do-while)
(statement-case-open after)
(substatement after)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-hanging-semi&comma-criteria . (c-semi&comma-no-newlines-before-nonblanks))
(c-cleanup-list . (scope-operator
brace-else-brace
brace-elseif-brace
brace-catch-brace
empty-defun-braces
list-close-comma
defun-close-semi))
(c-offsets-alist . ((inexpr-class . +)
(inexpr-statement . +)
(lambda-intro-cont . +)
(inlambda . c-lineup-inexpr-block)
(template-args-cont c-lineup-template-args +)
(incomposition . +)
(inmodule . +)
(innamespace . +)
(inextern-lang . +)
(composition-close . 0)
(module-close . 0)
(namespace-close . 0)
(extern-lang-close . 0)
(composition-open . 0)
(module-open . 0)
(namespace-open . 0)
(extern-lang-open . 0)
(objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call +)
(objc-method-args-cont . c-lineup-ObjC-method-args)
(objc-method-intro .
[0])
(friend . 0)
(cpp-define-intro c-lineup-cpp-define +)
(cpp-macro-cont . +)
(cpp-macro .
[0])
(inclass . +)
(stream-op . c-lineup-streamop)
(arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist)
(arglist-cont c-lineup-gcc-asm-reg 0)
(arglist-intro . +)
(catch-clause . 0)
(else-clause . 0)
(do-while-closure . 0)
(label . 2)
(access-label . -)
(substatement-label . 2)
(substatement . +)
(statement-case-open . 0)
(statement-case-intro . +)
(statement-block-intro . +)
(statement-cont . +)
(statement . 0)
(brace-entry-open . 0)
(brace-list-entry . 0)
(brace-list-intro . +)
(brace-list-close . 0)
(brace-list-open . 0)
(block-close . 0)
(inher-cont . c-lineup-multi-inher)
(inher-intro . +)
(member-init-cont . c-lineup-multi-inher)
(member-init-intro . +)
(annotation-var-cont . +)
(annotation-top-cont . 0)
(topmost-intro-cont . c-lineup-topmost-intro-cont)
(topmost-intro . 0)
(knr-argdecl . 0)
(func-decl-cont . +)
(inline-close . 0)
(inline-open . +)
(class-close . 0)
(class-open . 0)
(defun-block-intro . +)
(defun-close . 0)
(defun-open . 0)
(string . c-lineup-dont-change)
(arglist-close . c-lineup-arglist)
(substatement-open . 0)
(case-label . 0)
(block-open . 0)
(c . 1)
(comment-intro . 0)
(knr-argdecl-intro . -)))
(fill-column . 80))))
###
#
# @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 IPB. All rights reserved.
#
###
#
# @file CMakeLists.txt
#
# @project MAGMAMORSE
# MAGMAMORSE is a software package provided by:
# Inria Bordeaux - Sud-Ouest,
# Univ. of Tennessee,
# King Abdullah Univesity of Science and Technology
# Univ. of California Berkeley,
# Univ. of Colorado Denver.
#
# @version 1.1.0
# @author Cedric Castagnede
# @author Emmanuel Agullo
# @author Mathieu Faverge
# @author Florent Pruvost
# @date 13-07-2012
#
###
cmake_minimum_required(VERSION 2.8)
project(MAGMAMORSE Fortran C CXX)
# directly make an error if in-source build
if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not allowed.\n"
"Please create a build directory first and execute cmake configuration from "
"this directory. Example: mkdir build && cd build && cmake ..")
endif()
# set project version number
set(MAGMAMORSE_VERSION_MAJOR 1)
set(MAGMAMORSE_VERSION_MINOR 1)
set(MAGMAMORSE_VERSION_PATCH 0)
# Add extra cmake module path and initialize morse cmake modules
# --------------------------------------------------------------
set( MORSE_CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules/morse )
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules)
list(APPEND CMAKE_MODULE_PATH ${MORSE_CMAKE_MODULE_PATH})
include(MorseInit)
include(GenPkgConfig)
#############################################
# #
# Compilation of MAGMAMORSE #
# #
#############################################
###############################################################################
# Parameters/Options #
######################
# Add define for Fortran Mangling (should be defined somewhere else)
# ------------------------------------------------------------------
add_definitions(-DADD_)
# Misc options
# ------------
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
# Define precision supported by MAGMA_MORSE
# -----------------------------------------
set( RP_MAGMAMORSE_DICTIONNARY ${MORSE_CMAKE_MODULE_PATH}/precision_generator/subs.py )
set( RP_MAGMAMORSE_PRECISIONS "s;d;c;z" )
include(RulesPrecisions)
# Options to select the runtime
# -----------------------------
# Create a list of possible runtime
set(MAGMAMORSE_SCHED_list "STARPU" "QUARK")
# Initially StarPU runtime is enabled
option(MAGMAMORSE_SCHED_STARPU
"Enable StarPU scheduler as the default runtime
(Conflict with other MAGMAMORSE_SCHED_* options)" ON)
option(MAGMAMORSE_SCHED_QUARK
"Enable Quark scheduler as the default runtime
(Conflict with other MAGMAMORSE_SCHED_* options)" OFF)
if (MAGMAMORSE_SCHED_QUARK)
set(MAGMAMORSE_SCHED_STARPU OFF)
elseif (MAGMAMORSE_SCHED_STARPU)
set(MAGMAMORSE_SCHED_QUARK OFF)
endif()
# Check that one, and only one, SCHED option is set to ON
# count number of runtime sets to ON
math(EXPR number_of_active_runtime 0)
foreach (runtime ${MAGMAMORSE_SCHED_list})
if (MAGMAMORSE_SCHED_${runtime})
math(EXPR number_of_active_runtime "${number_of_active_runtime}+1")
endif()
endforeach()
if (NOT number_of_active_runtime STREQUAL 1)
message(FATAL_ERROR
"Number of active runtime is ${number_of_active_runtime}, "
"the user should activate one (and only one) runtime. ")
endif()
# Warning if not coherent options
if (MAGMAMORSE_USE_MPI AND NOT MAGMAMORSE_SCHED_STARPU)
message(WARNING "You have activated MPI but MAGMAMORSE_SCHED_STARPU is OFF.\n"
"You should use StarPU Runtime system if you want to benefit from MPI.\n"
"Use -DMAGMAMORSE_SCHED_QUARK=OFF -DMAGMAMORSE_SCHED_STARPU=ON at cmake \n"
"configure to do so.")
endif()
if(MAGMAMORSE_USE_CUDA AND NOT MAGMAMORSE_SCHED_STARPU)
message(WARNING "You have activated CUDA but MAGMAMORSE_SCHED_STARPU is OFF.\n"
"You should use StarPU Runtime system if you want to benefit from GPUs.\n"
"Use -DMAGMAMORSE_SCHED_QUARK=OFF -DMAGMAMORSE_SCHED_STARPU=ON at cmake \n"
"configure to do so.")
endif()
if(MAGMAMORSE_USE_MAGMA AND NOT MAGMAMORSE_SCHED_STARPU)
message(WARNING "You have activated MAGMA but MAGMAMORSE_SCHED_STARPU is OFF.\n"
"You should use StarPU Runtime system if you want to benefit from GPUs.\n"
"Use -DMAGMAMORSE_SCHED_QUARK=OFF -DMAGMAMORSE_SCHED_STARPU=ON at cmake \n"
"configure to do so.")
endif()
if(MAGMAMORSE_USE_FXT AND NOT MAGMAMORSE_SCHED_STARPU)
message(WARNING "You have activated FXT but MAGMAMORSE_SCHED_STARPU is OFF.\n"
"You should use StarPU Runtime system if you want to benefit from FxT.\n"
"Use -DMAGMAMORSE_SCHED_QUARK=OFF -DMAGMAMORSE_SCHED_STARPU=ON at cmake \n"
"configure to do so.")
endif()
# Additional options
# ------------------
# Enable the distributed interface (allowed only when StarPU is enabled)
# TODO: Default should be changed to ON/OFF when it will be ok
cmake_dependent_option(MAGMAMORSE_USE_MPI
"Enable distributed memory through MPI" OFF
"MAGMAMORSE_SCHED_STARPU" OFF)
# Enable Cuda kernels if StarPU (only if StarPU runtime is enabled)
# TODO: Default should be changed to ON/OFF when it will be ok
cmake_dependent_option(MAGMAMORSE_USE_CUDA
"Enable CUDA kernels" OFF
"MAGMAMORSE_SCHED_STARPU" OFF)
# Enable MAGMA advanced kernels if CUDA is enabled
cmake_dependent_option(MAGMAMORSE_USE_MAGMA
"Enable MAGMA Cuda kernels" OFF
"MAGMAMORSE_USE_CUDA" OFF)
# Enable FXT if StarPU (only if StarPU runtime is enabled)
cmake_dependent_option(MAGMAMORSE_USE_FXT
"Enable FXT with STARPU" OFF
"MAGMAMORSE_SCHED_STARPU" OFF)
# Options to enable/disable testings and timings
# ----------------------------------------------
option(MAGMAMORSE_ENABLE_DOCS "Enable documentation build" ON)
option(MAGMAMORSE_ENABLE_EXAMPLE "Enable examples build" ON)
option(MAGMAMORSE_ENABLE_TESTING "Enable testings build" ON)
option(MAGMAMORSE_ENABLE_TIMING "Enable timings build" ON)
# Option to activate or not simulation mode (use Simgrid through StarPU)
# ----------------------------------------------------------------------
if(MAGMAMORSE_SCHED_STARPU)
option(MAGMAMORSE_SIMULATION "Enable simulation mode using Simgrid through StarPU" OFF)
endif()
# Initially we need to generate files for different precisions
# TODO: use this option to avoid generate multiple precisions each time we launch cmake
#option(MAGMAMORSE_GEN_PREC "Generate source files precisions" ON)
#------------------------------------------------------------------------------
###############################################################################
# Look for dependencies #
#########################
# Check for Thread library
# ------------------------
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
if( THREADS_FOUND )
list(APPEND 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
set(M_LIBRARIES "")
if(UNIX OR WIN32)
find_library(
M_m_LIBRARY
NAMES m
)
mark_as_advanced(M_m_LIBRARY)
if (M_m_LIBRARY)
list(APPEND M_LIBRARIES "${M_m_LIBRARY}")
list(APPEND EXTRA_LIBRARIES "${M_m_LIBRARY}")
else()
message(FATAL_ERROR "Could NOT find libm on your system."
"Are you sure to a have a C compiler installed?")
endif()
endif()
# Try to find librt (libposix4 - POSIX.1b Realtime Extensions library)
# on Unix systems except Apple ones because it does not exist on it
set(RT_LIBRARIES "")
if(UNIX AND NOT APPLE)
find_library(
RT_rt_LIBRARY
NAMES rt
)
mark_as_advanced(RT_rt_LIBRARY)
if (RT_rt_LIBRARY)
list(APPEND RT_LIBRARIES "${RT_rt_LIBRARY}")
list(APPEND EXTRA_LIBRARIES "${RT_rt_LIBRARY}")
else()
message(FATAL_ERROR "Could NOT find librt on your system")
endif()
endif()
# If simulation we don't enter in kernel functions so that we don't need to
# link with concerned libraries
if(NOT MAGMAMORSE_SIMULATION)
# MAGMAMORSE depends on CBLAS
#----------------------------
find_package(BLASEXT REQUIRED)
set(HAVE_BLAS ${BLAS_FOUND})
find_package(CBLAS REQUIRED)
set(HAVE_CBLAS ${CBLAS_FOUND})
if(CBLAS_FOUND)
include_directories(${CBLAS_INCLUDE_DIRS})
endif()
#---------------------------------------------
# MAGMAMORSE depends on LAPACKE (via coreblas)
find_package(LAPACKEXT REQUIRED)
set(HAVE_LAPACK ${LAPACK_FOUND})
# standalone version of lapacke seems useless for now
# let the comment in case we meet some problems of non existing lapacke
# functions in lapack library such as mkl, acml, ...
#set(LAPACKE_STANDALONE TRUE)
find_package(LAPACKE REQUIRED)
set(HAVE_LAPACKE ${LAPACKE_FOUND})
if(LAPACKE_FOUND)
include_directories(${LAPACKE_INCLUDE_DIRS})
endif()
# MAGMAMORSE depends on TMG
#--------------------------
if (MAGMAMORSE_ENABLE_TESTING OR MAGMAMORSE_ENABLE_TIMING)
find_package(TMG REQUIRED)
set(HAVE_TMG ${TMG_FOUND})
endif()
# MAGMAMORSE depends on CUDA/CUBLAS
#----------------------------------
if (MAGMAMORSE_USE_CUDA)
find_package(CUDA REQUIRED)
set(HAVE_CUDA ${CUDA_FOUND})
if (CUDA_FOUND)
add_definitions(-DMAGMAMORSE_USE_CUDA)
if(CUDA_VERSION VERSION_LESS "3.0")
set(CUDA_HOST_COMPILATION_CPP OFF)
endif(CUDA_VERSION VERSION_LESS "3.0")
set(CUDA_BUILD_EMULATION OFF)
include_directories(${CUDA_INCLUDE_DIRS})
list(APPEND EXTRA_LIBRARIES ${CUDA_LIBRARIES}) # need CUDA libs to link.
list(APPEND EXTRA_SOURCES src/gpu_data.c)
set(saved_include "${CMAKE_REQUIRED_INCLUDES}")
set(saved_libs "${CMAKE_REQUIRED_LIBRARIES}")
set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${CUDA_INCLUDE_DIRS}")
set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};${CUDA_LIBRARIES}")
if(CUDA_VERSION VERSION_LESS "4.0")
set(CUDA_HAVE_PEER_DEVICE_MEMORY_ACCESS 0)
else()
check_function_exists(cuDeviceCanAccessPeer CUDA_HAVE_PEER_DEVICE_MEMORY_ACCESS)
endif()
set(CMAKE_REQUIRED_INCLUDES "${saved_include}")
set(CMAKE_REQUIRED_LIBRARIES "${saved_libs}")
endif (CUDA_FOUND)
# MAGMAMORSE depends on MAGMA gpu kernels
# call our cmake module to test (in cmake_modules)
# change this call position if not appropriated
#----------------------------------------------
if ( CUDA_FOUND )
if ( MAGMAMORSE_USE_MAGMA )
find_package(MAGMA REQUIRED COMPONENTS CBLAS LAPACK CUDA)
set(HAVE_MAGMA ${MAGMA_FOUND})
if ( MAGMA_FOUND )
add_definitions(-DHAVE_CUBLAS)
add_definitions(-DMAGMAMORSE_USE_MAGMA)
list(APPEND EXTRA_LIBRARIES ${CUDA_CUBLAS_LIBRARIES})
include_directories(${MAGMA_INCLUDE_DIRS})
endif( MAGMA_FOUND )
endif()
endif()
endif(MAGMAMORSE_USE_CUDA)
# MAGMAMORSE depends on MPI
#--------------------------
if (MAGMAMORSE_USE_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(NOT MPI_C_COMPILER)
set(MPI_C_COMPILER mpicc)
endif()
find_package(MPI REQUIRED)
set(HAVE_MPI ${MPI_C_FOUND})
if (MPI_C_FOUND)
add_definitions(-DMAGMAMORSE_USE_MPI)
list(APPEND EXTRA_LIBRARIES ${MPI_C_LIBRARIES} )
include_directories( ${MPI_C_INCLUDE_PATH} )
# tests for intel mpi
#list(APPEND MPI_C_COMPILE_FLAGS "-mt_mpi")
#list(APPEND MPI_COMPILE_FLAGS "-mt_mpi")
endif (MPI_C_FOUND)
endif (MAGMAMORSE_USE_MPI)
else (NOT MAGMAMORSE_SIMULATION)
message("${BoldBlue}Simulation mode of MAGMAMORSE is activated (MAGMAMORSE_SIMULATION=ON)."
"\nThis mode allows you to simulate execution of algorithms with StarPU compiled with SimGrid."
"\nTo do so, we provide some perfmodels in the simucore/perfmodels/ directory of MAGMAMORSE sources."
"\nThe resulting directory where to find perfmodels is: ${CMAKE_CURRENT_SOURCE_DIR}/simucore/perfmodels."
"\nTo use these perfmodels, please set your STARPU_HOME environment variable to ${CMAKE_CURRENT_SOURCE_DIR}/simucore/perfmodels."
"\nFinally, you need to set your STARPU_HOSTNAME environment variable to the name of the machine to simulate."
"For example: STARPU_HOSTNAME=mirage."
"\nNote that only POTRF kernels with block sizes of 320 or 960 (simple and double precision) on mirage machine are available for now."
"\nDatabase of models is subject to change, it should be enrich in a near future.${ColourReset}")
if (MAGMAMORSE_USE_CUDA)
set(MAGMAMORSE_USE_CUDA OFF)
message("${BoldBlue}MAGMAMORSE_USE_CUDA is set to ON but we turn it OFF."
"Because we are compiling the simulation mode (MAGMAMORSE_SIMULATION=ON),"
"we do not need to link with CUDA.${ColourReset}")
endif ()
if (MAGMAMORSE_USE_MAGMA)
set(MAGMAMORSE_USE_MAGMA OFF)
message("${BoldBlue}MAGMAMORSE_USE_MAGMA is set to ON but we turn it OFF."
"Because we are compiling the simulation mode (MAGMAMORSE_SIMULATION=ON),"
"we do not need to link with MAGMA.${ColourReset}")
endif ()
if (MAGMAMORSE_USE_MPI)
set(MAGMAMORSE_USE_MPI OFF)
message("${BoldBlue}MAGMAMORSE_USE_MPI is set to ON but we turn it OFF."
"Because we are compiling the simulation mode (MAGMAMORSE_SIMULATION=ON),"
"we do not need to link with MPI.${ColourReset}")
endif ()
if (MAGMAMORSE_ENABLE_TESTING)
set(MAGMAMORSE_ENABLE_TESTING OFF)
message("${BoldBlue}MAGMAMORSE_ENABLE_TESTING is set to ON but we turn it OFF."
"Because we are compiling the simulation mode (MAGMAMORSE_SIMULATION=ON),"
"there is no sense in compiling testing drivers that are used to check"
"numerical correctness of algorithms and kernels.${ColourReset}")
endif ()
endif(NOT MAGMAMORSE_SIMULATION)
# MAGMAMORSE depends on a runtime
# -------------------------------
# TODO: discuss on this with Manu
# try to find starpu runtime
if( MAGMAMORSE_SCHED_STARPU )
set(MAGMAMORSE_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...)
if(NOT MAGMAMORSE_SIMULATION)
set(STARPU_COMPONENT_LIST "HWLOC")
if(MAGMAMORSE_USE_MPI)
list(APPEND STARPU_COMPONENT_LIST "MPI")
endif()
if(MAGMAMORSE_USE_CUDA)
list(APPEND STARPU_COMPONENT_LIST "CUDA")
endif()
endif()
if(MAGMAMORSE_USE_FXT)
list(APPEND STARPU_COMPONENT_LIST "FXT")
endif()
find_package(STARPU ${MAGMAMORSE_STARPU_VERSION} REQUIRED
COMPONENTS ${STARPU_COMPONENT_LIST})
# Is this useful??
set(HAVE_STARPU ${STARPU_FOUND})
# Add definition and include_dir if found
if(STARPU_FOUND)
add_definitions(-DMAGMAMORSE_SCHED_STARPU) # TODO: remove that
include_directories(${STARPU_INCLUDE_DIRS})
set(CMAKE_REQUIRED_INCLUDES "${STARPU_INCLUDE_DIRS}")
foreach(libdir ${STARPU_LIBRARY_DIRS})
list(APPEND CMAKE_REQUIRED_FLAGS "-L${libdir}")
endforeach()
string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
if(MAGMAMORSE_USE_FXT)
# check if fxt profiling is accessible in starpu and activate it in magmamorse
set(CMAKE_REQUIRED_LIBRARIES "${STARPU_SHM_LIBRARIES}")
unset(STARPU_FXT_START_PROFILING_FOUND CACHE)
check_function_exists(starpu_fxt_start_profiling STARPU_FXT_START_PROFILING_FOUND)
if ( STARPU_FXT_START_PROFILING_FOUND )
message(STATUS "Set HAVE_STARPU_FXT_PROFILING - Activate FxT profiling through StarPU")
add_definitions(-DHAVE_STARPU_FXT_PROFILING)
endif()
endif()
if (MAGMAMORSE_USE_MPI AND STARPU_MPI_LIBRARIES)
# Check if a specific function exist
set(CMAKE_REQUIRED_LIBRARIES "${STARPU_MPI_LIBRARIES}")
unset(STARPU_MPI_DATA_REGISTER_FOUND CACHE)
check_function_exists(starpu_mpi_data_register STARPU_MPI_DATA_REGISTER_FOUND)
if ( STARPU_MPI_DATA_REGISTER_FOUND )
add_definitions(-DHAVE_STARPU_MPI_DATA_REGISTER)
endif()
endif()
endif()
endif()
# try to find quark runtime