Attention une mise à jour du service Gitlab va être effectuée le mardi 18 janvier (et non lundi 17 comme annoncé précédemment) entre 18h00 et 18h30. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

CMakeLists.txt 45.8 KB
Newer Older
1
2
3
4
5
6
###
#
# @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.
7
# @copyright (c) 2012-2015 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
8
9
10
11
12
#
###
#
#  @file CMakeLists.txt
#
13
14
#  @project CHAMELEON
#  CHAMELEON is a software package provided by:
15
16
17
18
19
20
#     Inria Bordeaux - Sud-Ouest,
#     Univ. of Tennessee,
#     King Abdullah Univesity of Science and Technology
#     Univ. of California Berkeley,
#     Univ. of Colorado Denver.
#
21
#  @version 0.9.0
22
23
24
25
26
27
28
29
#  @author Cedric Castagnede
#  @author Emmanuel Agullo
#  @author Mathieu Faverge
#  @author Florent Pruvost
#  @date 13-07-2012
#
###
cmake_minimum_required(VERSION 2.8)
30
project(CHAMELEON Fortran C CXX)
31
32
33
34
35
36
37
38
39

# 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
40
41
42
43
set(MORSE_VERSION_MAJOR 1)
set(MORSE_VERSION_MINOR 0)
set(MORSE_VERSION_MICRO 0)
# set subproject version number
44
45
set(CHAMELEON_VERSION_MAJOR 0)
set(CHAMELEON_VERSION_MINOR 9)
46
set(CHAMELEON_VERSION_MICRO 1)
47

48
49
50
51
52
53
54
55
56
57
58
59
60
61
set( MORSE_DISTRIB_DIR "" CACHE PATH "Directory of MORSE distribution")

if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_SOURCE_DIR}/cmake_modules/")

    # Add extra cmake module path and initialize morse cmake modules
    # --------------------------------------------------------------
    if(MORSE_DISTRIB_DIR)
        list(APPEND CMAKE_MODULE_PATH ${MORSE_DISTRIB_DIR}/cmake_modules)
        list(APPEND CMAKE_MODULE_PATH "${MORSE_DISTRIB_DIR}/cmake_modules/morse")
        set(MORSE_CMAKE_MODULE_PATH ${MORSE_DISTRIB_DIR}/cmake_modules/morse )
    elseif(EXISTS "${CMAKE_SOURCE_DIR}/cmake_modules/")
        list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules)
        list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/morse")
        set(MORSE_CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules/morse )
62
    endif()
63
64
    include(MorseInit)
    include(GenPkgConfig)
65

66
67
68
69
70
    #############################################
    #                                           #
    #        Compilation of CHAMELEON           #
    #                                           #
    #############################################
71
72


73
74
75
    ###############################################################################
    # Parameters/Options #
    ######################
76

77
    set(CHAMELEON_DEFINITIONS_LIST "")
78

79
80
    # Set the RPATH config
    # --------------------
81

82
83
    # use, i.e. don't skip the full RPATH for the build tree
    set(CMAKE_SKIP_BUILD_RPATH  FALSE)
84

85
86
87
    # when building, don't use the install RPATH already
    # (but later on when installing)
    set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
88

89
90
    # the RPATH to be used when installing
    set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
91

92
93
94
    # Misc options
    # ------------
    option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
95

96
97
98
99
100
101
102
103
104
105
    # Define precision supported by CHAMELEON
    # -----------------------------------------
    set( RP_CHAMELEON_DICTIONNARY ${MORSE_CMAKE_MODULE_PATH}/precision_generator/subs.py )
    set( RP_CHAMELEON_PRECISIONS  "s;d;c;z" )
    include(RulesPrecisions)

    # Options to select the runtime
    # -----------------------------

    # Create a list of possible runtime
Mathieu Faverge's avatar
Mathieu Faverge committed
106
    set(CHAMELEON_SCHED_list "PARSEC" "STARPU" "QUARK")
107

Mathieu Faverge's avatar
Mathieu Faverge committed
108
109
110
111
    # Initially PaRSEC runtime is enabled
    option(CHAMELEON_SCHED_PARSEC
        "Enable PaRSEC scheduler as the default runtime
        (Conflict with other CHAMELEON_SCHED_* options)" OFF)
112
113
    option(CHAMELEON_SCHED_STARPU
        "Enable StarPU scheduler as the default runtime
Mathieu Faverge's avatar
Mathieu Faverge committed
114
        (Conflict with other CHAMELEON_SCHED_* options)" OFF)
115
116
117
118
    option(CHAMELEON_SCHED_QUARK
        "Enable Quark scheduler as the default runtime
        (Conflict with other CHAMELEON_SCHED_* options)" OFF)

Mathieu Faverge's avatar
Mathieu Faverge committed
119
    # For now, we are able to compile only one runtime at a time, so we disable combinations of runtimes
120
121
    if (CHAMELEON_SCHED_QUARK)
        set(CHAMELEON_SCHED_STARPU OFF)
Mathieu Faverge's avatar
Mathieu Faverge committed
122
        set(CHAMELEON_SCHED_PARSEC OFF)
123
124
    elseif (CHAMELEON_SCHED_STARPU)
        set(CHAMELEON_SCHED_QUARK OFF)
Mathieu Faverge's avatar
Mathieu Faverge committed
125
126
127
128
129
130
131
132
        set(CHAMELEON_SCHED_PARSEC OFF)
    elseif (CHAMELEON_SCHED_PARSEC)
        set(CHAMELEON_SCHED_QUARK OFF)
        set(CHAMELEON_SCHED_STARPU OFF)
    endif()
    # Set default to StarPU if nothing specific is required by the user
    if ( NOT CHAMELEON_SCHED_STARPU AND NOT CHAMELEON_SCHED_PARSEC AND NOT CHAMELEON_SCHED_QUARK )
        set(CHAMELEON_SCHED_STARPU ON)
133
134
    endif()
    if (CHAMELEON_SCHED_STARPU)
Mathieu Faverge's avatar
Mathieu Faverge committed
135
136
137
138
        message("-- ${BoldGreen}CHAMELEON_SCHED_STARPU is set to ON: CHAMELEON uses StarPU runtime\n"
                "  To use CHAMELEON with Quark  runtime: set CHAMELEON_SCHED_QUARK  to ON\n"
                "  To use CHAMELEON with PaRSEC runtime: set CHAMELEON_SCHED_PARSEC to ON\n"
                "  (CHAMELEON_SCHED_STARPU will be disabled)${ColourReset}")
139
    elseif(CHAMELEON_SCHED_QUARK)
Mathieu Faverge's avatar
Mathieu Faverge committed
140
141
142
143
144
145
146
147
148
        message("-- ${BoldGreen}CHAMELEON_SCHED_QUARK is set to ON: CHAMELEON uses Quark runtime\n"
                "  To use CHAMELEON with StarPU runtime: set CHAMELEON_SCHED_STARPU to ON\n"
                "  To use CHAMELEON with PaRSEC runtime: set CHAMELEON_SCHED_PARSEC to ON\n"
                "  (CHAMELEON_SCHED_QUARK will be disabled)${ColourReset}")
    elseif(CHAMELEON_SCHED_PARSEC)
        message("-- ${BoldGreen}CHAMELEON_SCHED_PARSEC is set to ON: CHAMELEON uses PaRSEC runtime\n"
                "  To use CHAMELEON with StarPU runtime: set CHAMELEON_SCHED_STARPU to ON\n"
                "  To use CHAMELEON with Quark  runtime: set CHAMELEON_SCHED_QUARK  to ON\n"
                "  (CHAMELEON_SCHED_PARSEC will be disabled)${ColourReset}")
149
150
    endif()

151
152
153
154
155
156
157
158
159
160
161
162
    # 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 ${CHAMELEON_SCHED_list})
        if (CHAMELEON_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. ")
163
164
    endif()

Mathieu Faverge's avatar
Mathieu Faverge committed
165
166
    # Use intermediate variable since cmake_dependent_option doesn't have OR conditions
    set(CHAMELEON_ENABLE_MPI OFF CACHE BOOL "Tells if MPI might be supported by the runtime")
THIBAULT Samuel's avatar
THIBAULT Samuel committed
167
    if ( CHAMELEON_SCHED_PARSEC OR CHAMELEON_SCHED_STARPU )
Mathieu Faverge's avatar
Mathieu Faverge committed
168
         set(CHAMELEON_ENABLE_MPI ON)
169
170
    endif()

Mathieu Faverge's avatar
Mathieu Faverge committed
171
172
    # Use intermediate variable since cmake_dependent_option doesn't have OR conditions
    set(CHAMELEON_ENABLE_CUDA OFF CACHE BOOL "Tells if CUDA might be supported by the runtime")
THIBAULT Samuel's avatar
THIBAULT Samuel committed
173
    if ( CHAMELEON_SCHED_PARSEC OR CHAMELEON_SCHED_STARPU )
Mathieu Faverge's avatar
Mathieu Faverge committed
174
         set(CHAMELEON_ENABLE_CUDA ON)
175
    endif()
176

177
178
179
    # Additional options
    # ------------------

Mathieu Faverge's avatar
Mathieu Faverge committed
180
    # Enable the distributed interface (allowed only when StarPU or PaRSEC is enabled)
181
182
183
    # TODO: Default should be changed to ON/OFF when it will be ok
    cmake_dependent_option(CHAMELEON_USE_MPI
                        "Enable distributed memory through MPI" OFF
Mathieu Faverge's avatar
Mathieu Faverge committed
184
185
186
                        "CHAMELEON_ENABLE_MPI" OFF)
    if (CHAMELEON_ENABLE_MPI AND NOT CHAMELEON_USE_MPI)
        message("-- ${BoldGreen}CHAMELEON_USE_MPI is set to OFF, turn it ON to use MPI (unsupported by Quark)${ColourReset}")
187
188
    endif()

Mathieu Faverge's avatar
Mathieu Faverge committed
189
    # Enable Cuda kernels if StarPU (only if StarPU or PaRSEC runtime is enabled)
190
191
192
    # TODO: Default should be changed to ON/OFF when it will be ok
    cmake_dependent_option(CHAMELEON_USE_CUDA
                        "Enable CUDA kernels" OFF
Mathieu Faverge's avatar
Mathieu Faverge committed
193
194
195
                        "CHAMELEON_ENABLE_CUDA" OFF)
    if (CHAMELEON_ENABLE_CUDA AND NOT CHAMELEON_USE_CUDA)
        message("-- ${BoldGreen}CHAMELEON_USE_CUDA is set to OFF, turn it ON to use CUDA (unsupported by Quark)${ColourReset}")
196
197
198
199
200
201
    endif()

    # Enable MAGMA advanced kernels if CUDA is enabled
    cmake_dependent_option(CHAMELEON_USE_MAGMA
                        "Enable MAGMA Cuda kernels" OFF
                        "CHAMELEON_USE_CUDA" OFF)
Mathieu Faverge's avatar
Mathieu Faverge committed
202
    if (CHAMELEON_USE_CUDA AND NOT CHAMELEON_USE_MAGMA)
203
204
205
        message("-- ${BoldGreen}CHAMELEON_USE_MAGMA is set to OFF, turn it ON to use MAGMA (only with StarPU)${ColourReset}")
    endif()

206
207
208
209
    # Enable FXT if StarPU
    option(CHAMELEON_ENABLE_TRACING "Enable tracing support" OFF)
    if (NOT CHAMELEON_ENABLE_TRACING)
        message("-- ${BoldGreen}CHAMELEON_ENABLE_TRACING is set to OFF, turn it ON to use FxT (with StarPU)${ColourReset}")
210
    endif()
211
    #option(CHAMELEON_USE_EZTRACE "Enable EZTRACE to build modules" OFF)
212
213
214

    # Options to enable/disable testings and timings
    # ----------------------------------------------
215
    option(CHAMELEON_ENABLE_DOCS     "Enable documentation build"  OFF)
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
    if (CHAMELEON_ENABLE_DOCS)
        message("-- ${BoldGreen}CHAMELEON_ENABLE_DOCS is set to ON, turn it OFF to avoid building docs${ColourReset}")
    endif()
    option(CHAMELEON_ENABLE_EXAMPLE  "Enable examples build"       ON)
    if (CHAMELEON_ENABLE_EXAMPLE)
        message("-- ${BoldGreen}CHAMELEON_ENABLE_EXAMPLE is set to ON, turn it OFF to avoid building examples${ColourReset}")
    endif()
    option(CHAMELEON_ENABLE_TESTING  "Enable testings build"       ON)
    if (CHAMELEON_ENABLE_TESTING)
        message("-- ${BoldGreen}CHAMELEON_ENABLE_TESTING is set to ON, turn it OFF to avoid building testing${ColourReset}")
    endif()
    option(CHAMELEON_ENABLE_TIMING   "Enable timings build"        ON)
    if (CHAMELEON_ENABLE_TIMING)
        message("-- ${BoldGreen}CHAMELEON_ENABLE_TIMING is set to ON, turn it OFF to avoid building timing${ColourReset}")
    endif()

    # Option to activate or not simulation mode (use Simgrid through StarPU)
    # ----------------------------------------------------------------------
    if(CHAMELEON_SCHED_STARPU)
        option(CHAMELEON_SIMULATION "Enable simulation mode using Simgrid through StarPU" OFF)
        if (NOT CHAMELEON_SIMULATION)
            message("-- ${BoldGreen}CHAMELEON_SIMULATION is set to OFF, turn it ON to use"
                "SIMULATION mode (only with StarPU compiled with SimGrid)${ColourReset}")
239
        endif()
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
    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(CHAMELEON_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}")
273
        else()
274
275
            message(FATAL_ERROR "Could NOT find libm on your system."
                "Are you sure to a have a C compiler installed?")
276
        endif()
277
    endif()
278

279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
    # 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()
294
    endif()
295

296
297
298
299
300
    # If simulation we don't enter in kernel functions so that we don't need to
    # link with concerned libraries
    if(NOT CHAMELEON_SIMULATION)

        # CHAMELEON depends on CBLAS
301
302
        #---------------------------
        find_package(CBLAS COMPONENTS BLASEXT)
303
304
305
306
307
308
309
310
        if(BLAS_FOUND)
            if (BLAS_LIBRARY_DIRS)
                # the RPATH to be used when installing
                list(APPEND CMAKE_INSTALL_RPATH "${BLAS_LIBRARY_DIRS}")
            endif()
            if(BLAS_LINKER_FLAGS)
                list(APPEND CMAKE_EXE_LINKER_FLAGS "${BLAS_LINKER_FLAGS}")
            endif()
311
        else()
312
            message(FATAL_ERROR "BLAS library has not been found")
313
        endif()
314
315
316
317
318
        if(CBLAS_FOUND)
            include_directories(${CBLAS_INCLUDE_DIRS})
            if(CBLAS_LIBRARY_DIRS)
                # the RPATH to be used when installing
                list(APPEND CMAKE_INSTALL_RPATH "${CBLAS_LIBRARY_DIRS}")
319
            endif()
320
        else()
321
322
323
324
325
326
327
328
329
330
331
332
333
334
            if(MORSE_VERBOSE_FIND_PACKAGE)
                if(CBLAS_STANDALONE OR NOT CBLAS_WORKS)
                    if (NOT CBLAS_cblas.h_DIRS)
                        Print_Find_Header_Status(cblas cblas.h)
                    endif ()
                    if (NOT CBLAS_cblas_LIBRARY)
                        Print_Find_Library_Status(cblas libcblas)
                    endif ()
                endif()
            else()
                message(WARNING "CBLAS library has not been found and MORSE_VERBOSE_FIND_PACKAGE is set to OFF"
                "Try to activate MORSE_VERBOSE_FIND_PACKAGE option (-DMORSE_VERBOSE_FIND_PACKAGE=ON) to get some hints for the detection")
            endif()
            message(FATAL_ERROR "A CBLAS library is required but has not been found")
335
        endif()
336

337
338
        # CHAMELEON depends on LAPACKE
        #-----------------------------
339
340
341
342
343
        # 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 COMPONENTS LAPACKEXT)
344
        if(LAPACK_FOUND AND LAPACK_LIBRARY_DIRS)
345
            # the RPATH to be used when installing
346
            list(APPEND CMAKE_INSTALL_RPATH "${LAPACK_LIBRARY_DIRS}")
347
        else()
348
            message(FATAL_ERROR "A LAPACK library is required but has not been found")
349
        endif()
350
351
352
353
354
        if(LAPACKE_FOUND)
            include_directories(${LAPACKE_INCLUDE_DIRS})
            if(LAPACKE_LIBRARY_DIRS)
                # the RPATH to be used when installing
                list(APPEND CMAKE_INSTALL_RPATH "${LAPACKE_LIBRARY_DIRS}")
355
            endif()
356
357
358
            if(LAPACKE_LINKER_FLAGS)
                list(APPEND CMAKE_EXE_LINKER_FLAGS "${LAPACKE_LINKER_FLAGS}")
            endif()
359
360
361
362
363
        else()
            if(MORSE_VERBOSE_FIND_PACKAGE)
                if (LAPACKE_STANDALONE OR NOT LAPACKE_WORKS)
                    if (NOT LAPACKE_lapacke.h_DIRS)
                        Print_Find_Header_Status(lapacke lapacke.h)
364
                    endif ()
365
366
                    if (NOT LAPACKE_lapacke_LIBRARY)
                        Print_Find_Library_Status(lapacke liblapacke)
367
368
                    endif ()
                endif()
369
370
371
372
373
            else()
                message(WARNING "LAPACKE library has not been found and MORSE_VERBOSE_FIND_PACKAGE is set to OFF"
                "Try to activate MORSE_VERBOSE_FIND_PACKAGE option (-DMORSE_VERBOSE_FIND_PACKAGE=ON) to get some hints for the detection")
            endif()
            message(FATAL_ERROR "A LAPACKE library is required but has not been found")
374
375
        endif()

376
        # CHAMELEON depends on TMG
377
        #-------------------------
378
379
380
381
382
383
384
385
        if (CHAMELEON_ENABLE_TESTING OR CHAMELEON_ENABLE_TIMING)
            find_package(TMG)
            if(TMG_FOUND AND TMG_LIBRARY_DIRS)
                # the RPATH to be used when installing
                list(APPEND CMAKE_INSTALL_RPATH "${TMG_LIBRARY_DIRS}")
            else()
                message(FATAL_ERROR "A TMG library is required but has not been found")
            endif()
386
387
388
            if(TMG_LINKER_FLAGS)
                list(APPEND CMAKE_EXE_LINKER_FLAGS "${TMG_LINKER_FLAGS}")
            endif()
389
390
        endif()

391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
        # CHAMELEON depends on CUDA/CUBLAS
        #----------------------------------
        if (CHAMELEON_USE_CUDA)

            find_package(CUDA REQUIRED)

            if (CUDA_FOUND)
                message("-- ${Blue}Add definition CHAMELEON_USE_CUDA"
                " - Activate CUDA in Chameleon${ColourReset}")
                add_definitions(-DCHAMELEON_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}")
419
420
421
422
423
424
425
                # Add cublas if found
                if (CUDA_CUBLAS_LIBRARIES)
                    message("-- ${Blue}Add definition CHAMELEON_USE_CUBLAS"
                    " - Use GPU kernels from cuBLAS${ColourReset}")
                    add_definitions(-DCHAMELEON_USE_CUBLAS)
                    list(APPEND EXTRA_LIBRARIES ${CUDA_CUBLAS_LIBRARIES})
                endif()
426
427
428
429
430
431
432
433
434
435
436
437
                #FindHeader(CUDA cublas_v2.h)
                #if(CUDA_cublas_v2.h_DIRS)
                    #add_definitions(-DCHAMELEON_USE_CUBLAS_V2)
                #endif()
            endif (CUDA_FOUND)

            # CHAMELEON depends on MAGMA gpu kernels
            # call our cmake module to test (in cmake_modules)
            # change this call position if not appropriated
            #----------------------------------------------
            if ( CUDA_FOUND AND CHAMELEON_USE_MAGMA )
                set(CHAMELEON_MAGMA_VERSION "1.4" CACHE STRING "oldest MAGMA version desired")
438
                find_package(MAGMA ${CHAMELEON_MAGMA_VERSION})
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
                if ( MAGMA_FOUND )
                    message("-- ${Blue}Add definition CHAMELEON_USE_MAGMA"
                    " - Use GPU kernels from MAGMA${ColourReset}")
                    add_definitions(-DCHAMELEON_USE_MAGMA)
                    include_directories(${MAGMA_INCLUDE_DIRS})
                    if(MAGMA_LIBRARY_DIRS)
                        # the RPATH to be used when installing
                        list(APPEND CMAKE_INSTALL_RPATH "${MAGMA_LIBRARY_DIRS}")
                    endif()
                else( MAGMA_FOUND )
                    if(MORSE_VERBOSE_FIND_PACKAGE)
                        if (NOT MAGMA_magma.h_DIRS)
                            Print_Find_Header_Status(magma magma.h)
                        endif ()
                        if (NOT MAGMA_magma_LIBRARY)
                            Print_Find_Library_Status(magma libmagma)
                        endif ()
                    else()
                        message(WARNING "MAGMA library has not been found and MORSE_VERBOSE_FIND_PACKAGE is set to OFF"
                        "Try to activate MORSE_VERBOSE_FIND_PACKAGE option (-DMORSE_VERBOSE_FIND_PACKAGE=ON) to get some hints for the detection")
                    endif()
                    message(FATAL_ERROR "MAGMA library is required but has not been found")
                endif( MAGMA_FOUND )
            endif()
463

464
        endif(CHAMELEON_USE_CUDA)
465

466
467
468
        # CHAMELEON depends on MPI
        #-------------------------
        if (CHAMELEON_USE_MPI)
469

470
471
472
473
            # 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)
474
		set(MPI_C_COMPILER mpicc)
475
476
477
478
479
480
481
482
483
484
485
486
            endif()
            find_package(MPI REQUIRED)

            if (MPI_C_FOUND)
                message("-- ${Blue}Add definition CHAMELEON_USE_MPI"
                " - Activate MPI in Chameleon${ColourReset}")
                add_definitions(-DCHAMELEON_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")
487
488
489
                if(MPI_C_LINK_FLAGS)
                    list(APPEND CMAKE_EXE_LINKER_FLAGS "${MPI_C_LINK_FLAGS}")
                endif()
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
            endif (MPI_C_FOUND)

        endif (CHAMELEON_USE_MPI)

    else (NOT CHAMELEON_SIMULATION)

        message("${BoldBlue}Simulation mode of CHAMELEON is activated (CHAMELEON_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 CHAMELEON 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 (CHAMELEON_USE_CUDA)
            set(CHAMELEON_USE_CUDA OFF)
            message("${BoldBlue}CHAMELEON_USE_CUDA is set to ON but we turn it OFF."
            "Because we are compiling the simulation mode (CHAMELEON_SIMULATION=ON),"
            "we do not need to link with CUDA.${ColourReset}")
        endif ()
        if (CHAMELEON_USE_MAGMA)
            set(CHAMELEON_USE_MAGMA OFF)
            message("${BoldBlue}CHAMELEON_USE_MAGMA is set to ON but we turn it OFF."
            "Because we are compiling the simulation mode (CHAMELEON_SIMULATION=ON),"
            "we do not need to link with MAGMA.${ColourReset}")
        endif ()
        if (CHAMELEON_ENABLE_TESTING)
            set(CHAMELEON_ENABLE_TESTING OFF)
            message("${BoldBlue}CHAMELEON_ENABLE_TESTING is set to ON but we turn it OFF."
            "Because we are compiling the simulation mode (CHAMELEON_SIMULATION=ON),"
            "there is no sense in compiling testing drivers that are used to check"
            "numerical correctness of algorithms and kernels.${ColourReset}")
        endif ()

526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
        # CHAMELEON depends on MPI
        #-------------------------
        if (CHAMELEON_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 smpicc)
            endif()
            if(NOT MPI_C_LIBRARIES)
                set(MPI_C_LIBRARIES -lsimgrid)
            endif()
            find_package(MPI REQUIRED)

            if (MPI_C_FOUND)
                message("-- ${Blue}Add definition CHAMELEON_USE_MPI"
                " - Activate MPI in Chameleon${ColourReset}")
                add_definitions(-DCHAMELEON_USE_MPI)
                list(APPEND EXTRA_LIBRARIES ${MPI_C_LIBRARIES} )
                include_directories( ${MPI_C_INCLUDE_PATH} )
                if(MPI_C_LINK_FLAGS)
                    list(APPEND CMAKE_EXE_LINKER_FLAGS "${MPI_C_LINK_FLAGS}")
                endif()
            endif (MPI_C_FOUND)

        endif (CHAMELEON_USE_MPI)

554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
    endif(NOT CHAMELEON_SIMULATION)


    # CHAMELEON depends on a runtime
    # -------------------------------

    if( CHAMELEON_SCHED_STARPU )

        set(CHAMELEON_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 CHAMELEON_SIMULATION)
            set(STARPU_COMPONENT_LIST "HWLOC")
            if(CHAMELEON_USE_CUDA)
                list(APPEND STARPU_COMPONENT_LIST "CUDA")
            endif()
570
        endif()
571
572
573
        if(CHAMELEON_USE_MPI)
            list(APPEND STARPU_COMPONENT_LIST "MPI")
        endif()
574
        if(CHAMELEON_ENABLE_TRACING)
575
            list(APPEND STARPU_COMPONENT_LIST "FXT")
576
577
        endif()

578
        find_package(STARPU ${CHAMELEON_STARPU_VERSION} REQUIRED
579
580
581
582
583
584
585
586
                     COMPONENTS ${STARPU_COMPONENT_LIST})

        # Add definition and include_dir if found
        if ( STARPU_FOUND )
            message("-- ${Blue}Add definition CHAMELEON_SCHED_STARPU"
            " - Activate StarPU in Chameleon${ColourReset}")
            add_definitions(-DCHAMELEON_SCHED_STARPU) # TODO: remove that
            include_directories(${STARPU_INCLUDE_DIRS})
587
588
589
            if(STARPU_LINKER_FLAGS)
                list(APPEND CMAKE_EXE_LINKER_FLAGS "${STARPU_LINKER_FLAGS}")
            endif()
590
591
592
593
            set(CMAKE_REQUIRED_INCLUDES "${STARPU_INCLUDE_DIRS}")
            foreach(libdir ${STARPU_LIBRARY_DIRS})
                list(APPEND CMAKE_REQUIRED_FLAGS "-L${libdir}")
            endforeach()
594
            list(APPEND CMAKE_REQUIRED_FLAGS "-include" "starpu_simgrid_wrap.h")
595
            string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
596
597
            set(CMAKE_REQUIRED_LIBRARIES "${STARPU_SHM_LIBRARIES}")
            check_function_exists(starpu_data_idle_prefetch_on_node STARPU_IDLE_PREFETCH_FOUND)
THIBAULT Samuel's avatar
THIBAULT Samuel committed
598
            if ( STARPU_IDLE_PREFETCH_FOUND )
599
                add_definitions(-DCHAMELEON_USE_STARPU_IDLE_PREFETCH)
THIBAULT Samuel's avatar
THIBAULT Samuel committed
600
            endif()
601
            check_function_exists(starpu_data_wont_use STARPU_DATA_WONT_USE_FOUND)
THIBAULT Samuel's avatar
THIBAULT Samuel committed
602
            if ( STARPU_DATA_WONT_USE_FOUND )
603
                add_definitions(-DCHAMELEON_USE_STARPU_DATA_WONT_USE)
THIBAULT Samuel's avatar
THIBAULT Samuel committed
604
            endif()
605
            if(CHAMELEON_ENABLE_TRACING)
606
607
608
609
610
611
612
613
614
615
616
617
618
                # check if fxt profiling is accessible in starpu and activate it in chameleon
                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("-- ${Blue}Add definition HAVE_STARPU_FXT_PROFILING"
                    " - Activate FxT profiling through StarPU${ColourReset}")
                    add_definitions(-DHAVE_STARPU_FXT_PROFILING)
                else()
                    message("-- ${Red}Looking for starpu with fxt"
                    " - starpu_fxt_start_profiling() test fails in StarPU${ColourReset}")
                    message("-- ${Red}Check in CMakeFiles/CMakeError.log to figure out why it fails${ColourReset}")
                endif()
619
            endif()
620
621
622
623
624
625
626
627
628
629
630
631
632
            if (CHAMELEON_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_comm STARPU_MPI_DATA_REGISTER_FOUND)
                if ( STARPU_MPI_DATA_REGISTER_FOUND )
                    message("-- ${Blue}Add definition HAVE_STARPU_MPI_DATA_REGISTER - Activate"
                    "use of starpu_mpi_data_register() in Chameleon with StarPU${ColourReset}")
                    add_definitions(-DHAVE_STARPU_MPI_DATA_REGISTER)
                else()
                    message("-- ${Red}Looking for starpu with starpu_mpi_data_register"
                    " - starpu_mpi_data_register() test fails in StarPU${ColourReset}")
                    message("-- ${Red}Check in CMakeFiles/CMakeError.log to figure out why it fails${ColourReset}")
633
                endif()
PRUVOST Florent's avatar
PRUVOST Florent committed
634
635
636
                unset(STARPU_MPI_COMM_RANK_FOUND CACHE)
                check_function_exists(starpu_mpi_comm_rank STARPU_MPI_COMM_RANK_FOUND)
                if ( STARPU_MPI_COMM_RANK_FOUND )
637
638
639
640
                    message("-- ${Blue}Add definition HAVE_STARPU_MPI_COMM_RANK - Activate"
                    "use of starpu_mpi_comm_rank() in Chameleon with StarPU${ColourReset}")
                    add_definitions(-DHAVE_STARPU_MPI_COMM_RANK)
                else()
THIBAULT Samuel's avatar
THIBAULT Samuel committed
641
                    message("-- ${Red}Looking for starpu with starpu_mpi_comm_rank"
642
643
                    " - starpu_mpi_comm_rank() test fails in StarPU${ColourReset}")
                    message("-- ${Red}Check in CMakeFiles/CMakeError.log to figure out why it fails${ColourReset}")
644
                endif()
645
            endif()
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
            if(HWLOC_FOUND AND HWLOC_LIBRARY_DIRS)
                # the RPATH to be used when installing
                list(APPEND CMAKE_INSTALL_RPATH "${HWLOC_LIBRARY_DIRS}")
            endif()
            if(FXT_FOUND AND FXT_LIBRARY_DIRS)
                # the RPATH to be used when installing
                list(APPEND CMAKE_INSTALL_RPATH "${FXT_LIBRARY_DIRS}")
            endif()
            if(STARPU_FOUND AND STARPU_LIBRARY_DIRS)
                # the RPATH to be used when installing
                list(APPEND CMAKE_INSTALL_RPATH "${STARPU_LIBRARY_DIRS}")
            endif()
        else ( STARPU_FOUND )
            if(MORSE_VERBOSE_FIND_PACKAGE)
                if(NOT HWLOC_FOUND OR NOT HWLOC_LIBRARIES)
                    if (NOT HWLOC_hwloc.h_DIRS)
                        Print_Find_Header_Status(hwloc hwloc.h)
                    endif ()
                    if (NOT HWLOC_hwloc_LIBRARY)
                        Print_Find_Library_Status(hwloc libhwloc)
                    endif ()
                endif()
668
                if(CHAMELEON_ENABLE_TRACING AND (NOT FXT_FOUND OR NOT FXT_LIBRARIES))
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
                    if (NOT FXT_fxt.h_DIRS)
                        Print_Find_Header_Status(fxt fxt.h)
                    endif ()
                    if (NOT FXT_fxt_LIBRARY)
                        Print_Find_Library_Status(fxt libfxt)
                    endif ()
                endif()
                if( (NOT STARPU_SHM_FOUND) OR (NOT STARPU_SHM_LIBRARIES) OR
                    ( STARPU_LOOK_FOR_MPI AND (NOT STARPU_MPI_FOUND OR NOT STARPU_MPI_LIBRARIES) )
                  )
                    foreach(starpu_hdr ${STARPU_hdrs_to_find})
                        if (NOT STARPU_${starpu_hdr}_INCLUDE_DIRS)
                            Print_Find_Header_Status(starpu ${starpu_hdr})
                        endif ()
                    endforeach()
                    if(STARPU_VERSION_STRING)
                        foreach(starpu_lib ${STARPU_libs_to_find})
                            if (NOT STARPU_${starpu_lib}_LIBRARY)
                                Print_Find_Library_Status(starpu ${starpu_lib})
                            endif ()
                        endforeach()
Mathieu Faverge's avatar
Mathieu Faverge committed
690
691
                    endif ()
                endif ()
692
693
694
695
            else(MORSE_VERBOSE_FIND_PACKAGE)
                message(WARNING "StarPU library has not been found and MORSE_VERBOSE_FIND_PACKAGE is set to OFF"
                "Try to activate MORSE_VERBOSE_FIND_PACKAGE option (-DMORSE_VERBOSE_FIND_PACKAGE=ON) to get some hints for the detection")
            endif(MORSE_VERBOSE_FIND_PACKAGE)
696
            if(NOT HWLOC_FOUND OR NOT HWLOC_LIBRARIES)
697
                message(FATAL_ERROR "hwloc library is required but has not been found")
698
            endif()
699
            if(CHAMELEON_ENABLE_TRACING AND (NOT FXT_FOUND OR NOT FXT_LIBRARIES))
700
                message(FATAL_ERROR "FxT library is required but has not been found")
701
702
703
704
            endif()
            if( (NOT STARPU_SHM_FOUND) OR (NOT STARPU_SHM_LIBRARIES) OR
                ( STARPU_LOOK_FOR_MPI AND (NOT STARPU_MPI_FOUND OR NOT STARPU_MPI_LIBRARIES) )
              )
705
                message(FATAL_ERROR "StarPU library is required but has not been found")
706
            endif()
707
        endif ( STARPU_FOUND )
708

709
    endif( CHAMELEON_SCHED_STARPU )
710

Mathieu Faverge's avatar
Mathieu Faverge committed
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
    if( CHAMELEON_SCHED_PARSEC )

        # create list of components in order to make a single call to find_package(starpu...)
        set(PARSEC_COMPONENT_LIST "HWLOC")
        if(CHAMELEON_USE_MPI)
            list(APPEND PARSEC_COMPONENT_LIST "MPI")
        endif()
        if(CHAMELEON_USE_CUDA)
            list(APPEND PARSEC_COMPONENT_LIST "CUDA")
        endif()
        # TODO: Add a CHAMELEON_WITH_PROFILING option that enables Fxt for StarPU, or PAPI for PaRSEC
        #if(CHAMELEON_WITH_PROFILING)
        #    list(APPEND PARSEC_COMPONENT_LIST "PAPI")
        #endif()

        find_package(PARSEC COMPONENTS ${PARSEC_COMPONENT_LIST})

        # Add definition and include_dir if found
        if(PARSEC_FOUND)
            message("-- ${Blue}Add definition CHAMELEON_SCHED_PARSEC"
            " - Activate PaRSEC in Chameleon${ColourReset}")

          add_definitions(-DCHAMELEON_SCHED_PARSEC) # TODO: remove that
          include_directories(${PARSEC_INCLUDE_DIRS_DEP})
          include_directories(${PARSEC_INCLUDE_DIRS}/daguepp)
          set(CMAKE_REQUIRED_INCLUDES "${PARSEC_INCLUDE_DIRS_DEP}")

          if(PARSEC_LINKER_FLAGS)
               list(APPEND CMAKE_EXE_LINKER_FLAGS "${PARSEC_LINKER_FLAGS}")
          endif()
          foreach(libdir ${PARSEC_LIBRARY_DIRS_DEP})
              list(APPEND CMAKE_REQUIRED_FLAGS "-L${libdir}")
          endforeach()
          string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
          set(CMAKE_REQUIRED_LIBRARIES "${PARSEC_LIBRARIES_DEP}")

          if(HWLOC_FOUND AND HWLOC_LIBRARY_DIRS)
                # the RPATH to be used when installing
              list(APPEND CMAKE_INSTALL_RPATH "${HWLOC_LIBRARY_DIRS}")
          endif()
          if(PARSEC_FOUND AND PARSEC_LIBRARY_DIRS_DEP)
              # the RPATH to be used when installing
              list(APPEND CMAKE_INSTALL_RPATH "${PARSEC_LIBRARY_DIRS_DEP}")
          endif()
        else ( PARSEC_FOUND )
            if(MORSE_VERBOSE_FIND_PACKAGE)
                if(NOT HWLOC_FOUND OR NOT HWLOC_LIBRARIES)
                    if (NOT HWLOC_hwloc.h_DIRS)
                        Print_Find_Header_Status(hwloc hwloc.h)
                    endif ()
                    if (NOT HWLOC_hwloc_LIBRARY)
                        Print_Find_Library_Status(hwloc libhwloc)
                    endif ()
                endif()
                if( (NOT PARSEC_FOUND) OR (NOT PARSEC_LIBRARIES_DEP) )
                  foreach(parsec_hdr ${PARSEC_hdrs_to_find})
                        if (NOT PARSEC_${parsec_hdr}_INCLUDE_DIRS)
                            Print_Find_Header_Status(parsec ${parsec_hdr})
                        endif ()
                    endforeach()
                    if(PARSEC_VERSION_STRING)
                        foreach(parsec_lib ${PARSEC_libs_to_find})
                            if (NOT PARSEC_${parsec_lib}_LIBRARY)
                                Print_Find_Library_Status(parsec ${parsec_lib})
                            endif ()
                        endforeach()
                    endif()
                endif()
            else(MORSE_VERBOSE_FIND_PACKAGE)
                message(WARNING "PaRSEC library has not been found and MORSE_VERBOSE_FIND_PACKAGE is set to OFF"
                "Try to activate MORSE_VERBOSE_FIND_PACKAGE option (-DMORSE_VERBOSE_FIND_PACKAGE=ON) to get some hints for the detection")
            endif(MORSE_VERBOSE_FIND_PACKAGE)
            if(NOT HWLOC_FOUND OR NOT HWLOC_LIBRARIES)
                message(FATAL_ERROR "hwloc library is required but has not been found")
            endif()
            if( (NOT PARSEC_FOUND) OR (NOT PARSEC_LIBRARIES_DEP) )
                message(FATAL_ERROR "PaRSEC library is required but has not been found")
            endif()
        endif ( PARSEC_FOUND )

    endif( CHAMELEON_SCHED_PARSEC )

          # try to find quark runtime
794
    if( CHAMELEON_SCHED_QUARK )
795

796
        find_package(QUARK COMPONENTS HWLOC)
797

798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
        # Add definition and include_dir if found
        if(QUARK_FOUND)
            message("-- ${Blue}Add definition CHAMELEON_SCHED_QUARK"
            " - Activate QUARK in Chameleon${ColourReset}")
            add_definitions(-DCHAMELEON_SCHED_QUARK) # TODO: remove that
            include_directories(${QUARK_INCLUDE_DIRS})
            if(QUARK_LIBRARY_DIRS)
                # the RPATH to be used when installing
                list(APPEND CMAKE_INSTALL_RPATH "${QUARK_LIBRARY_DIRS}")
            endif()
        else(QUARK_FOUND)
            if(MORSE_VERBOSE_FIND_PACKAGE)
                if(NOT HWLOC_FOUND OR NOT HWLOC_LIBRARIES)
                    if (NOT HWLOC_hwloc.h_DIRS)
                        Print_Find_Header_Status(hwloc hwloc.h)
                    endif ()
                    if (NOT HWLOC_hwloc_LIBRARY)
                        Print_Find_Library_Status(hwloc libhwloc)
                    endif ()
                endif()
                if (NOT QUARK_quark.h_DIRS)
                    Print_Find_Header_Status(quark quark.h)
820
                endif ()
821
822
                if (NOT QUARK_quark_LIBRARY)
                    Print_Find_Library_Status(quark libquark)
823
                endif ()
824
825
826
            else()
                message(WARNING "QUARK library has not been found and MORSE_VERBOSE_FIND_PACKAGE is set to OFF"
                "Try to activate MORSE_VERBOSE_FIND_PACKAGE option (-DMORSE_VERBOSE_FIND_PACKAGE=ON) to get some hints for the detection")
827
            endif()
828
829
830
831
832
833
834
835
            if(NOT HWLOC_FOUND OR NOT HWLOC_LIBRARIES)
                message(FATAL_ERROR "hwloc library is required but has not been found")
            endif()
            message(FATAL_ERROR "QUARK library is required but has not been found")
        endif(QUARK_FOUND)

    endif()

836
    list(REMOVE_DUPLICATES CMAKE_EXE_LINKER_FLAGS)
837
    string(REPLACE ";" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
838
839
840
841
    # Fix a problem on Mac OS X when building shared libraries
    if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
        set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
    endif()
842

843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
    # Add define for Fortran Mangling (should be defined somewhere else)
    # ------------------------------------------------------------------
    message("-- ${Blue}Add definition ADD_"
            " - For Fortran mangling${ColourReset}")
    add_definitions(-DADD_)

    #------------------------------------------------------------------------------
    # Save all dependencies (all required links)
    set(CHAMELEON_DEP -lchameleon)
    if(CHAMELEON_SCHED_STARPU)
        if ( CHAMELEON_USE_MPI )
            list(APPEND CHAMELEON_DEP
              -lchameleon_starpu
              ${STARPU_MPI_LIBRARIES}
            )
858
        else()
859
860
861
862
863
            list(APPEND CHAMELEON_DEP
              -lchameleon_starpu
              ${STARPU_SHM_LIBRARIES}
            )
        endif()
Mathieu Faverge's avatar
Mathieu Faverge committed
864
865
866
867
868
869
    elseif(CHAMELEON_SCHED_PARSEC)
        list(APPEND CHAMELEON_DEP
          -lchameleon_parsec
          ${PARSEC_LIBRARIES_DEP}
          )
        link_directories(${PARSEC_LIBRARY_DIRS_DEP})
870
871
872
873
874
875
876
877
878
879
880
881
882
    elseif(CHAMELEON_SCHED_QUARK)
        list(APPEND CHAMELEON_DEP
          -lchameleon_quark
          ${QUARK_LIBRARIES}
          )
        link_directories(${QUARK_LIBRARY_DIRS})
    endif()
    if(NOT CHAMELEON_SIMULATION)
        if(CHAMELEON_USE_CUDA)
            list(APPEND CHAMELEON_DEP
            ${CUDA_LIBRARIES}
            )
            link_directories(${CUDA_LIBRARY_DIRS})
883
        endif()
884
885
886
887
888
        if(CHAMELEON_USE_MAGMA)
            list(APPEND CHAMELEON_DEP
            ${MAGMA_LIBRARIES}
            )
            link_directories(${MAGMA_LIBRARY_DIRS})
889
        endif()
890
891
892
        if(CHAMELEON_USE_CUDA OR CHAMELEON_USE_MAGMA)
            list(APPEND CHAMELEON_DEP -lcudablas)
        endif()
893

894
        list(APPEND CHAMELEON_DEP
895
896
897
898
899
900
901
        -lcoreblas
        ${LAPACKE_LIBRARIES}
        ${CBLAS_LIBRARIES}
        ${LAPACK_SEQ_LIBRARIES}
        ${BLAS_SEQ_LIBRARIES}
        ${HWLOC_LIBRARIES}
        ${EXTRA_LIBRARIES}
902
903
        )
    else()
904
        list(APPEND CHAMELEON_DEP
905
906
907
908
909
        -lcoreblas
        -lsimulapacke
        -lsimucblas
        ${HWLOC_LIBRARIES}
        ${EXTRA_LIBRARIES}
910
911
        )
    endif()
912
913
914
915
916
917
918
919
920
921
922
923
    list(REMOVE_DUPLICATES CHAMELEON_DEP)

    # Check for the subdirectories
    # ----------------------------

    # include headers
    # ---------------
    include_directories(${CMAKE_CURRENT_SOURCE_DIR})
    include_directories(${CMAKE_CURRENT_BINARY_DIR})
    include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
    include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)

924

925
926
927
928
929
930
931
932
933
    ###############################################################################
    # simucore libraries #
    ######################

    if ( CHAMELEON_SIMULATION )
        add_subdirectory(simucore)
        message("-- ${Blue}Add definition CHAMELEON_SIMULATION"
        " - Activate simulation mode in Chameleon (to use with StarPU+SimGrid)${ColourReset}")
        add_definitions(-DCHAMELEON_SIMULATION)
934
    endif()
935
    #------------------------------------------------------------------------------
936
937


938
939
940
    ###############################################################################
    # Coreblas library (kernels for CPUs) #
    #######################################
941

942
943
    add_subdirectory(coreblas)
    #------------------------------------------------------------------------------
944
945


946
947
948
949
950
951
952
953
954
955
    ###############################################################################
    # Cudablas library (kernels for CUDAs) #
    ########################################

    if(CHAMELEON_USE_CUDA)
        add_subdirectory(cudablas)
    endif()
    #------------------------------------------------------------------------------


956
957
958
    ###############################################################################
    # Main library #
    ################
959

960
961
962
963
    add_subdirectory(include)
    add_subdirectory(control)
    add_subdirectory(compute)
    #------------------------------------------------------------------------------
964
965


966
967
968
    ###############################################################################
    # Runtime library #
    ###################
969

970
971
    add_subdirectory(runtime)
    #------------------------------------------------------------------------------
972
973


974
975
976
    ###############################################################################
    # Executables and Tests #
    #########################
977

978
979
980
    enable_testing()
    include(CTest)
    #enable_testing()
981

982
983
984
985
986
    # Necessary to compile executables (temporary)
    # should use SystemDetection.cmake module?
    string(REGEX MATCH ".*ifort$" _match_ifort ${CMAKE_Fortran_COMPILER})
    if(_match_ifort)
        #message(STATUS "Add -nofor_main to the Fortran linker")
987
        list(APPEND CMAKE_Fortran_FLAGS "-nofor_main")
988
    endif(_match_ifort)
989

990
991
992
993
    # Testing executables
    if(CHAMELEON_ENABLE_EXAMPLE)
      add_subdirectory(example)
    endif(CHAMELEON_ENABLE_EXAMPLE)
994

995
996
997
998
    # Testing executables
    if(CHAMELEON_ENABLE_TESTING)
      add_subdirectory(testing)
    endif(CHAMELEON_ENABLE_TESTING)
999

1000
1001
1002
1003
1004
    # Timing executables
    if(CHAMELEON_ENABLE_TIMING)
      add_subdirectory(timing)
    endif(CHAMELEON_ENABLE_TIMING)
    #------------------------------------------------------------------------------
1005
1006


1007
1008
1009
    ###############################################################################
    # Documentation #
    #################
1010

1011
1012
1013
1014
    if(CHAMELEON_ENABLE_DOCS)
        add_subdirectory(docs)
    endif()
    #------------------------------------------------------------------------------
1015
1016


1017
1018
1019
    ###############################################################################
    # Config files (pkg_config) #
    #############################
1020

1021
1022
1023
1024
1025
    # Create file morse_starpu.pc
    # ---------------------------
    if(CHAMELEON_SCHED_STARPU)
        generate_pkgconfig_file("${CMAKE_CURRENT_SOURCE_DIR}/lib/pkgconfig/chameleon-starpu.pc.in")
    endif()
1026

1027
1028
1029
1030
1031
1032
    # # Create file morse_quark.pc
    # # --------------------------
    if(CHAMELEON_SCHED_QUARK)
        generate_pkgconfig_file("${CMAKE_CURRENT_SOURCE_DIR}/lib/pkgconfig/chameleon-quark.pc.in")
    endif()
    #------------------------------------------------------------------------------
1033
1034


1035
1036
1037
1038
1039
    ###############################################################################
    # Print Options #
    #################
    get_directory_property( CHAMELEON_DEFINITIONS_LIST DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
    include(PrintOpts)
1040

1041
    if (CMAKE_INSTALL_PREFIX STREQUAL "/usr/local" OR CMAKE_INSTALL_PREFIX STREQUAL "C:/Program Files")
1042
        message("-- ${Yellow}Your CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX} which is a default system path."
1043
        "You may want to change it: set the CMAKE_INSTALL_PREFIX variable to do so${ColourReset}")
1044
    else()
1045
        message("-- ${Yellow}Your CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX}${ColourReset}")
1046
    endif()
1047

1048
1049
1050
1051
1052
1053
1054
1055
1056
else(MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_SOURCE_DIR}/cmake_modules/")

    message(STATUS "MORSE_DISTRIB_DIR is not set")
    message(STATUS "Please indicate where is located your MORSE distribution directory."
    " This is necessary to find cmake_modules.")
    message(STATUS "If you are a MORSE developer, you normally have access to the svn repository of the MORSE_DISTRIB_DIR: "
    "svn checkout svn+ssh://yourlogin@scm.gforge.inria.fr/svnroot/morse/trunk/morse_distrib")

endif(MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_SOURCE_DIR}/cmake_modules/")
1057

1058
1059
1060
###
### END CMakeLists.txt
###