~ubuntu-branches/ubuntu/saucy/starpu-contrib/saucy

« back to all changes in this revision

Viewing changes to .pc/automake-Werror/configure.ac

  • Committer: Package Import Robot
  • Author(s): Logan Rosen
  • Date: 2013-07-12 23:10:36 UTC
  • mfrom: (7.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130712231036-idxuyf8ed54d4zft
Tags: 1.0.1-4ubuntu1
* Merge from Debian unstable. Remaining changes:
  - debian/control: Build-depend on nvidia-current | nvidia-current-updates
    rather than libcuda1 to fix FTBFS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# StarPU --- Runtime system for heterogeneous multicore architectures.
 
2
#
 
3
# Copyright (C) 2009-2012  Université de Bordeaux 1
 
4
# Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
 
5
# Copyright (C) 2011  Télécom-SudParis
 
6
# Copyright (C) 2011, 2012  Institut National de Recherche en Informatique et Automatique
 
7
#
 
8
# StarPU is free software; you can redistribute it and/or modify
 
9
# it under the terms of the GNU Lesser General Public License as published by
 
10
# the Free Software Foundation; either version 2.1 of the License, or (at
 
11
# your option) any later version.
 
12
#
 
13
# StarPU is distributed in the hope that it will be useful, but
 
14
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
16
#
 
17
# See the GNU Lesser General Public License in COPYING.LGPL for more details.
 
18
 
 
19
AC_INIT([StarPU],1.0.1, [starpu-devel@lists.gforge.inria.fr], starpu)
 
20
AC_CONFIG_SRCDIR(include/starpu.h)
 
21
AC_CONFIG_AUX_DIR([build-aux])
 
22
 
 
23
dnl Versioning.
 
24
 
 
25
STARPU_MAJOR_VERSION="`echo $PACKAGE_VERSION | cut -d . -f 1`"
 
26
STARPU_MINOR_VERSION="`echo $PACKAGE_VERSION | cut -d . -f 2`"
 
27
AC_SUBST([STARPU_MAJOR_VERSION])
 
28
AC_SUBST([STARPU_MINOR_VERSION])
 
29
AC_SUBST([STARPU_EFFECTIVE_VERSION])
 
30
AC_DEFINE_UNQUOTED([STARPU_MAJOR_VERSION], [$STARPU_MAJOR_VERSION],
 
31
  [Major version number of StarPU.])
 
32
AC_DEFINE_UNQUOTED([STARPU_MINOR_VERSION], [$STARPU_MINOR_VERSION],
 
33
  [Major version number of StarPU.])
 
34
 
 
35
. "$srcdir/STARPU-VERSION"
 
36
AC_SUBST([LIBSTARPU_INTERFACE_CURRENT])
 
37
AC_SUBST([LIBSTARPU_INTERFACE_REVISION])
 
38
AC_SUBST([LIBSTARPU_INTERFACE_AGE])
 
39
AC_SUBST([LIBSTARPUMPI_INTERFACE_CURRENT])
 
40
AC_SUBST([LIBSTARPUMPI_INTERFACE_REVISION])
 
41
AC_SUBST([LIBSTARPUMPI_INTERFACE_AGE])
 
42
AC_SUBST([LIBSTARPUFFT_INTERFACE_CURRENT])
 
43
AC_SUBST([LIBSTARPUFFT_INTERFACE_REVISION])
 
44
AC_SUBST([LIBSTARPUFFT_INTERFACE_AGE])
 
45
AC_SUBST([LIBSOCL_INTERFACE_CURRENT])
 
46
AC_SUBST([LIBSOCL_INTERFACE_REVISION])
 
47
AC_SUBST([LIBSOCL_INTERFACE_AGE])
 
48
 
 
49
AC_CANONICAL_SYSTEM
 
50
 
 
51
dnl Automake 1.11 introduced `silent-rules' and `color-tests'.  Use them
 
52
dnl when they're available.
 
53
m4_ifdef([AM_SILENT_RULES],
 
54
  [AM_INIT_AUTOMAKE([1.11 -Wall -Werror foreign silent-rules color-tests parallel-tests])],
 
55
  [AM_INIT_AUTOMAKE([1.10 -Wall -Werror foreign])])
 
56
 
 
57
m4_ifdef([AM_SILENT_RULES],
 
58
  [AM_SILENT_RULES(yes)])
 
59
 
 
60
AC_PREREQ(2.60)
 
61
 
 
62
AC_PROG_CC
 
63
AC_PROG_CXX
 
64
AC_PROG_CPP
 
65
AC_PROG_SED
 
66
AC_PROG_LN_S
 
67
AC_PROG_F77
 
68
 
 
69
LT_PREREQ([2.2])
 
70
LT_INIT([win32-dll])
 
71
 
 
72
AC_PROG_INSTALL
 
73
AC_PROG_MKDIR_P
 
74
AC_PROG_LN_S
 
75
 
 
76
AC_HEADER_STDC
 
77
 
 
78
AC_C_RESTRICT
 
79
 
 
80
AC_PATH_PROGS([STARPU_MS_LIB], [lib])
 
81
AC_ARG_VAR([STARPU_MS_LIB], [Path to Microsoft's Visual Studio `lib' tool])
 
82
AM_CONDITIONAL([STARPU_HAVE_MS_LIB], [test "x$STARPU_MS_LIB" != "x"])
 
83
case "$target" in
 
84
*-*-mingw*|*-*-cygwin*)
 
85
  starpu_windows=yes
 
86
  libext=a
 
87
  AC_DEFINE(STARPU_HAVE_WINDOWS, [], [Define this on windows.])
 
88
  ;;
 
89
esac
 
90
AM_CONDITIONAL([STARPU_HAVE_WINDOWS], [test "x$starpu_windows" = "xyes"])
 
91
 
 
92
# on Darwin, GCC targets i386 by default, so we don't have atomic ops
 
93
AC_CHECK_SIZEOF([void *])
 
94
SIZEOF_VOID_P=$ac_cv_sizeof_void_p
 
95
case $SIZEOF_VOID_P in
 
96
        4)
 
97
                case "$target" in
 
98
                i386-*darwin*) CFLAGS+=" -march=i686 " ;;
 
99
                esac
 
100
                STARPU_MS_LIB_ARCH=X86
 
101
                ;;
 
102
        8)
 
103
                STARPU_MS_LIB_ARCH=X64
 
104
                ;;
 
105
esac
 
106
AC_SUBST(STARPU_MS_LIB_ARCH)
 
107
 
 
108
# This will be useful for program which use CUDA (and .cubin files) which need
 
109
# some path to the CUDA code at runtime.
 
110
AC_DEFINE_UNQUOTED(STARPU_BUILD_DIR, "$PWD", [location of StarPU build directory])
 
111
AC_SUBST(STARPU_BUILD_DIR, $PWD)
 
112
case "${srcdir}" in
 
113
/*)  AC_DEFINE_UNQUOTED(STARPU_SRC_DIR, "$(eval echo ${srcdir})", [location of StarPU sources])
 
114
     AC_SUBST(STARPU_SRC_DIR, "$(eval echo ${srcdir})") ;;
 
115
*)   AC_DEFINE_UNQUOTED(STARPU_SRC_DIR, "$(eval echo $PWD/${srcdir})", [location of StarPU sources])
 
116
     AC_SUBST(STARPU_SRC_DIR, "$(eval echo $PWD/${srcdir})") ;;
 
117
esac
 
118
 
 
119
 
 
120
case "$target" in
 
121
*-*-mingw*|*-*-cygwin*)
 
122
    AC_ARG_ENABLE(native-winthreads, [AS_HELP_STRING([--enable-native-winthreads],
 
123
                                   [Use native windows threads instead of pthread])],
 
124
                                   enable_native_winthreads=$enableval, enable_native_winthreads=no)
 
125
    ;;
 
126
esac
 
127
if test x"$enable_native_winthreads" = xyes
 
128
then
 
129
    CPPFLAGS+=" -I$STARPU_SRC_DIR/include/pthread_win32 "
 
130
else
 
131
    AC_CHECK_LIB([pthread], [pthread_create])
 
132
fi
 
133
 
 
134
AC_COMPILE_IFELSE(
 
135
  AC_LANG_PROGRAM([[
 
136
    #include <pthread.h>
 
137
  ]], [[ pthread_t t; pthread_create(&t, NULL, NULL, NULL); ]]),,
 
138
  AC_MSG_ERROR([pthread_create unavailable]))
 
139
AC_SEARCH_LIBS([sqrt],[m],,AC_MSG_ERROR([math library unavailable]))
 
140
AC_HAVE_LIBRARY([ws2_32])
 
141
AC_CHECK_FUNCS([sysconf])
 
142
 
 
143
AC_CHECK_FUNC([pthread_spin_lock], have_pthread_spin_lock=yes, have_pthread_spin_lock=no)
 
144
if test x$have_pthread_spin_lock = xyes; then
 
145
        AC_DEFINE(HAVE_PTHREAD_SPIN_LOCK,[],[pthread_spin_lock is available])
 
146
fi
 
147
 
 
148
# yes, that's non portable, but it's still better than sched_setaffinity
 
149
AC_CHECK_FUNCS(pthread_setaffinity_np)
 
150
 
 
151
# There is no posix_memalign on Mac OS X, only memalign
 
152
AC_CHECK_FUNCS([posix_memalign], [AC_DEFINE([STARPU_HAVE_POSIX_MEMALIGN], [1], [Define to 1 if you have the `posix_memalign' function.])])
 
153
AC_CHECK_FUNCS([memalign], [AC_DEFINE([STARPU_HAVE_MEMALIGN], [1], [Define to 1 if you have the `memalign' function.])])
 
154
 
 
155
# Some systems don't have drand48
 
156
AC_CHECK_FUNC([drand48], have_drand48=yes, have_drand48=no)
 
157
AC_CHECK_FUNC([erand48_r], have_erand48_r=yes, have_erand48_r=no)
 
158
# Maybe the user still does not want to use the provided drand48
 
159
AC_ARG_ENABLE(default-drand48, [AS_HELP_STRING([--disable-default-drand48],
 
160
                                   [Do not use the default version of drand48])],
 
161
                                   enable_default_drand48=$enableval, enable_default_drand48=yes)
 
162
if test x$have_drand48 = xyes -a x$enable_default_drand48 = xyes ; then
 
163
   AC_DEFINE([STARPU_USE_DRAND48], [1], [Define to 1 if drandr48 is available and should be used])
 
164
fi
 
165
if test x$have_erand48_r = xyes ; then
 
166
   AC_DEFINE([STARPU_USE_ERAND48_R], [1], [Define to 1 if erandr48_r is available])
 
167
fi
 
168
 
 
169
# Some systems do not define strerror_r
 
170
AC_CHECK_FUNC([strerror_r], [AC_DEFINE([STARPU_HAVE_STRERROR_R], [1], [Define to 1 if the function strerro_r is available.])])
 
171
 
 
172
# Some systems do not define unsetenv
 
173
AC_CHECK_FUNC([unsetenv], [AC_DEFINE([STARPU_HAVE_UNSETENV], [1], [Define to 1 if the function unsetenv is available.])])
 
174
 
 
175
# Define slow machine
 
176
AC_ARG_ENABLE(slow-machine, [AS_HELP_STRING([--enable-slow-machine],
 
177
                                   [Lower default values for the testcases run by make check])],
 
178
                                   enable_slow_machine=$enableval, enable_slow_machine=false)
 
179
if  test x$enable_slow_machine = xyes; then
 
180
        AC_DEFINE(STARPU_SLOW_MACHINE, [1], [enable slow machine])
 
181
fi
 
182
 
 
183
AC_CHECK_HEADERS([malloc.h], [AC_DEFINE([STARPU_HAVE_MALLOC_H], [1], [Define to 1 if you have the <malloc.h> header file.])])
 
184
 
 
185
AC_CHECK_HEADERS([valgrind/valgrind.h], [AC_DEFINE([STARPU_HAVE_VALGRIND_H], [1], [Define to 1 if you have the <valgrind/valgrind.h> header file.])])
 
186
 
 
187
# This defines HAVE_SYNC_VAL_COMPARE_AND_SWAP
 
188
STARPU_CHECK_SYNC_VAL_COMPARE_AND_SWAP
 
189
 
 
190
# This defines HAVE_SYNC_BOOL_COMPARE_AND_SWAP
 
191
STARPU_CHECK_SYNC_BOOL_COMPARE_AND_SWAP
 
192
 
 
193
# This defines HAVE_SYNC_FETCH_AND_ADD
 
194
STARPU_CHECK_SYNC_FETCH_AND_ADD
 
195
 
 
196
# This defines HAVE_SYNC_FETCH_AND_OR
 
197
STARPU_CHECK_SYNC_FETCH_AND_OR
 
198
 
 
199
# This defines HAVE_SYNC_LOCK_TEST_AND_SET
 
200
STARPU_CHECK_SYNC_LOCK_TEST_AND_SET
 
201
 
 
202
# This defines HAVE_SYNC_SYNCHRONIZE
 
203
STARPU_CHECK_SYNC_SYNCHRONIZE
 
204
 
 
205
CPPFLAGS="${CPPFLAGS} -D_GNU_SOURCE "
 
206
 
 
207
STARPU_SEARCH_LIBS([LIBNUMA],[set_mempolicy],[numa],[enable_libnuma=yes],[enable_libnuma=no])
 
208
AC_MSG_CHECKING(whether libnuma is available)
 
209
AC_MSG_RESULT($enable_libnuma)
 
210
if test x$enable_libnuma = xyes; then
 
211
        AC_DEFINE(STARPU_HAVE_LIBNUMA,[],[libnuma is available])
 
212
fi
 
213
 
 
214
###############################################################################
 
215
#                                                                             #
 
216
#                                 CPUs settings                               #
 
217
#                                                                             #
 
218
###############################################################################
 
219
 
 
220
AC_MSG_CHECKING(maximum number of CPUs)
 
221
AC_ARG_ENABLE(maxcpus, [AS_HELP_STRING([--enable-maxcpus=<number>],
 
222
                        [maximum number of CPUs])],
 
223
                        maxcpus=$enableval, maxcpus=64)
 
224
AC_MSG_RESULT($maxcpus)
 
225
AC_DEFINE_UNQUOTED(STARPU_MAXCPUS, [$maxcpus], [Maximum number of CPUs supported])
 
226
 
 
227
AC_MSG_CHECKING(whether CPUs should be used)
 
228
AC_ARG_ENABLE(cpu, [AS_HELP_STRING([--disable-cpu],
 
229
                        [do not use the CPU(s)])],
 
230
                        enable_cpu=$enableval, enable_cpu=yes)
 
231
AC_MSG_RESULT($enable_cpu)
 
232
AC_SUBST(STARPU_USE_CPU, $enable_cpu)
 
233
 
 
234
AM_CONDITIONAL(STARPU_USE_CPU, test x$enable_cpu = xyes)
 
235
 
 
236
if test x$enable_cpu = xyes; then
 
237
        AC_DEFINE(STARPU_USE_CPU, [1], [CPU driver is activated])
 
238
fi
 
239
 
 
240
# How many parallel worker can we support ?
 
241
nmaxcombinedworkers=`expr 2 \* $maxcpus`
 
242
AC_DEFINE_UNQUOTED(STARPU_NMAX_COMBINEDWORKERS,
 
243
        [$nmaxcombinedworkers], [Maximum number of worker combinations])
 
244
 
 
245
###############################################################################
 
246
#                                                                             #
 
247
#                                 CUDA settings                               #
 
248
#                                                                             #
 
249
###############################################################################
 
250
 
 
251
AC_MSG_CHECKING(maximum number of CUDA devices)
 
252
AC_ARG_ENABLE(maxcudadev, [AS_HELP_STRING([--enable-maxcudadev=<number>],
 
253
                        [maximum number of CUDA devices])],
 
254
                        nmaxcudadev=$enableval, nmaxcudadev=4)
 
255
AC_MSG_RESULT($nmaxcudadev)
 
256
AC_DEFINE_UNQUOTED(STARPU_MAXCUDADEVS, [$nmaxcudadev],
 
257
                [maximum number of CUDA devices])
 
258
 
 
259
AC_ARG_ENABLE(cuda, [AS_HELP_STRING([--disable-cuda],
 
260
                [do not use CUDA device(s)])],, [enable_cuda=maybe])
 
261
 
 
262
#AC_MSG_CHECKING(whether CUDA is available)
 
263
AC_ARG_WITH(cuda-dir,
 
264
        [AS_HELP_STRING([--with-cuda-dir=<path>],
 
265
        [specify CUDA installation directory])],
 
266
        [
 
267
                cuda_dir="$withval"
 
268
                # in case this was not explicit yet
 
269
                enable_cuda=yes
 
270
        ], cuda_dir=no)
 
271
 
 
272
AC_ARG_WITH(cuda-include-dir,
 
273
        [AS_HELP_STRING([--with-cuda-include-dir=<path>],
 
274
        [specify where CUDA headers are installed])],
 
275
        [
 
276
                cuda_include_dir="$withval"
 
277
                # in case this was not explicit yet
 
278
                enable_cuda=yes
 
279
        ], [cuda_include_dir=no])
 
280
 
 
281
AC_ARG_WITH(cuda-lib-dir,
 
282
        [AS_HELP_STRING([--with-cuda-lib-dir=<path>],
 
283
        [specify where CUDA libraries are installed])],
 
284
        [
 
285
                cuda_lib_dir="$withval"
 
286
                # in case this was not explicit yet
 
287
                enable_cuda=yes
 
288
        ], [cuda_lib_dir=no])
 
289
 
 
290
AC_DEFUN([STARPU_CHECK_CUDA_L],
 
291
[
 
292
    __cuda_L=$1
 
293
    SAVED_LDFLAGS="${LDFLAGS}"
 
294
    STARPU_CUDA_LDFLAGS="${__cuda_L}"
 
295
    AC_MSG_CHECKING(whether CUDA is available with: $__cuda_L)
 
296
    AC_MSG_RESULT()
 
297
    LDFLAGS="${SAVED_LDFLAGS} ${__cuda_L}"
 
298
    AC_HAVE_LIBRARY([cuda],[have_valid_cuda=yes],[have_valid_cuda=no])
 
299
    unset ac_cv_lib_cuda_main
 
300
    if test "$have_valid_cuda" = "yes" ; then
 
301
        AC_HAVE_LIBRARY([cudart],[have_valid_cuda=yes],[have_valid_cuda=no])
 
302
        unset ac_cv_lib_cudart_main
 
303
        if test "$have_valid_cuda" = yes ; then
 
304
            STARPU_CUDA_LDFLAGS="$STARPU_CUDA_LDFLAGS -lcudart"
 
305
            LDFLAGS="${SAVED_LDFLAGS} ${STARPU_CUDA_LDFLAGS}"
 
306
            # we also check that CUBLAS is available
 
307
            AC_HAVE_LIBRARY([cublas],[have_valid_cuda=yes],[have_valid_cuda=no])
 
308
            unset ac_cv_lib_cublas_main
 
309
            if test "$have_valid_cuda" = "yes" ; then
 
310
                STARPU_CUDA_LDFLAGS="$STARPU_CUDA_LDFLAGS -lcublas"
 
311
            fi
 
312
        fi
 
313
    fi
 
314
    LDFLAGS="${SAVED_LDFLAGS}"
 
315
])
 
316
AC_DEFUN([STARPU_CHECK_CUDA],
 
317
[
 
318
    __cuda_dir=$1
 
319
    __cuda_include_dir=$2
 
320
    __cuda_lib_dir=$3
 
321
 
 
322
    if test -z "$__cuda_lib_dir" ; then
 
323
        __cuda_lib_dir=no
 
324
    fi
 
325
    if test -z "$__cuda_include_dir" ; then
 
326
        __cuda_include_dir=no
 
327
    fi
 
328
    if test -z "$__cuda_dir" ; then
 
329
        __cuda_dir=no
 
330
    fi
 
331
 
 
332
    if test "$__cuda_dir" != "no" ; then
 
333
        AC_MSG_CHECKING(whether CUDA is available in $__cuda_dir, $__cuda_include_dir and $__cuda_lib_dir)
 
334
    else
 
335
        AC_MSG_CHECKING(whether CUDA is available)
 
336
    fi
 
337
    AC_MSG_RESULT()
 
338
 
 
339
    if test "$__cuda_include_dir" = "no" -a "$__cuda_dir" != "no" ; then
 
340
        __cuda_include_dir="$__cuda_dir/include"
 
341
    fi
 
342
 
 
343
    SAVED_CPPFLAGS="$CPPFLAGS"
 
344
    have_valid_cuda=no
 
345
 
 
346
    if test "$__cuda_include_dir" != "no" ; then
 
347
        CPPFLAGS="${CPPFLAGS} -I$__cuda_include_dir"
 
348
    fi
 
349
 
 
350
    AC_CHECK_HEADER([cuda.h],[have_valid_cuda=yes],[have_valid_cuda=no])
 
351
    unset ac_cv_header_cuda_h
 
352
 
 
353
    if test "$have_valid_cuda" = "yes" ; then
 
354
        if test "$__cuda_lib_dir" != "no" ; then
 
355
            STARPU_CHECK_CUDA_L("-L${__cuda_lib_dir}")
 
356
        else
 
357
            if test "$__cuda_dir" != "no" ; then
 
358
                for __cuda_libdir in lib64 lib lib/x64 lib/Win32 ; do
 
359
                    STARPU_CHECK_CUDA_L("-L${__cuda_dir}/${__cuda_libdir}")
 
360
                    if test "$have_valid_cuda" = yes ; then
 
361
                        break
 
362
                    fi
 
363
                done
 
364
            else
 
365
                STARPU_CHECK_CUDA_L("")
 
366
            fi
 
367
        fi
 
368
    fi
 
369
 
 
370
    if test "$have_valid_cuda" = "no" ; then
 
371
        CPPFLAGS="${SAVED_CPPFLAGS}"
 
372
        unset STARPU_CUDA_LDFLAGS
 
373
    else
 
374
        if test "$__cuda_include_dir" != "no"; then
 
375
            STARPU_CUDA_CPPFLAGS="-I$__cuda_include_dir"
 
376
            NVCCFLAGS="${NVCCFLAGS} -I$__cuda_include_dir"
 
377
        fi
 
378
    fi
 
379
])
 
380
 
 
381
if test x$enable_cuda = xyes -o x$enable_cuda = xmaybe; then
 
382
    STARPU_CHECK_CUDA("$cuda_dir", "$cuda_include_dir", "$cuda_lib_dir")
 
383
    if test "$have_valid_cuda" = "no" ; then
 
384
        STARPU_CHECK_CUDA("$CUDA_PATH", "$CUDA_INC_PATH", "$CUDA_LIB_PATH")
 
385
    fi
 
386
    if test "$have_valid_cuda" = "no" ; then
 
387
        for f in "/usr/local/cuda" "/c/cuda" "/cygdrive/c/cuda" "/opt/cuda" "$CUDA_PATH" "$CUDA_INC_PATH/.." "$CUDA_INSTALL_PATH" "$CUDA_TOOLKIT"; do
 
388
            if test -n "$f" ; then
 
389
                STARPU_CHECK_CUDA("$f", "no", "no")
 
390
                if test "$have_valid_cuda" = "yes" ; then
 
391
                    break
 
392
                fi
 
393
            fi
 
394
        done
 
395
    fi
 
396
 
 
397
    # Check cuda is compatible with the C compiler
 
398
    AC_MSG_CHECKING(whether CUDA is working)
 
399
    if test "$have_valid_cuda" = "yes" ; then
 
400
        SAVED_CPPFLAGS="${CPPFLAGS}"
 
401
        CPPFLAGS="${CPPFLAGS} ${STARPU_CUDA_CPPFLAGS}"
 
402
        SAVED_LDFLAGS="${LDFLAGS}"
 
403
        LDFLAGS="${LDFLAGS} ${STARPU_CUDA_LDFLAGS} -lcuda"
 
404
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
 
405
                [[#include <cuda.h>]],
 
406
                [[]]
 
407
                )],
 
408
            [
 
409
              AC_RUN_IFELSE([AC_LANG_PROGRAM(
 
410
                [[#include <cuda.h>]],
 
411
                [[]]
 
412
                )],
 
413
                [have_valid_cuda="yes"],
 
414
                [
 
415
                  AC_MSG_RESULT([CUDA found and can be compiled, but compiled application can not be run, is the CUDA path missing in LD_LIBRARY_PATH?])
 
416
                  have_valid_cuda="no"
 
417
                ])
 
418
            ],
 
419
            [
 
420
            AC_MSG_ERROR([CUDA found, but cuda.h could not be compiled])
 
421
            have_valid_cuda="no"
 
422
            ]
 
423
        )
 
424
        CPPFLAGS="${SAVED_CPPFLAGS}"
 
425
        LDFLAGS="${SAVED_LDFLAGS}"
 
426
    fi
 
427
    AC_MSG_RESULT($have_valid_cuda)
 
428
 
 
429
    # in case CUDA was explicitely required, but is not available, this is an error
 
430
    if test x$enable_cuda = xyes -a x$have_valid_cuda = xno; then
 
431
        AC_MSG_ERROR([cannot find CUDA])
 
432
    fi
 
433
    # now we enable CUDA if and only if a proper setup is available
 
434
    enable_cuda=$have_valid_cuda
 
435
fi
 
436
 
 
437
if test x$enable_cuda = xyes; then
 
438
        AC_PATH_PROG([NVCC], [nvcc], [not-found],
 
439
          [$cuda_dir/bin:$PATH:/usr/local/cuda/bin:/usr/bin:/bin])
 
440
        if test "x$NVCC" = "xnot-found"; then
 
441
           AC_MSG_WARN(['nvcc' not found, disabling CUDA])
 
442
           enable_cuda=no
 
443
        fi
 
444
fi
 
445
 
 
446
AC_MSG_CHECKING(whether CUDA should be used)
 
447
AC_MSG_RESULT($enable_cuda)
 
448
AC_SUBST(STARPU_USE_CUDA, $enable_cuda)
 
449
AM_CONDITIONAL(STARPU_USE_CUDA, test x$enable_cuda = xyes)
 
450
if test x$enable_cuda = xyes; then
 
451
        AC_DEFINE(STARPU_USE_CUDA, [1], [CUDA support is activated])
 
452
 
 
453
        # On Darwin, the libstdc++ dependency is not automatically added by nvcc
 
454
#       case "$target" in
 
455
#               *-*darwin*) AC_HAVE_LIBRARY([stdc++], []) ;;
 
456
#               #*-*darwin*) AC_HAVE_LIBRARY([stdc++], [STARPU_CUDA_LDFLAGS="$STARPU_CUDA_LDFLAGS -lstdc++"]) ;;
 
457
#       esac
 
458
        STARPU_CUDA_LDFLAGS="$STARPU_CUDA_LDFLAGS -lcuda"
 
459
        STARPU_CUFFT_LDFLAGS="-lcufft"
 
460
 
 
461
        if test "$F77" = "gfortran" ; then
 
462
            STARPU_CUDA_FORTRAN_LDFLAGS="-lgfortran"
 
463
            AC_SUBST(STARPU_CUDA_FORTRAN_LDFLAGS)
 
464
        fi
 
465
 
 
466
        #in case this is a 64bit setup, we tell nvcc to use a -m64 flag
 
467
        if test x$SIZEOF_VOID_P = x8; then
 
468
                NVCCFLAGS="${NVCCFLAGS} -m64"
 
469
                AC_SUBST(NVCCFLAGS)
 
470
        fi
 
471
fi
 
472
 
 
473
have_magma=no
 
474
if test x$enable_cuda = xyes; then
 
475
        PKG_CHECK_MODULES([MAGMA],  [magma], [
 
476
        AC_DEFINE([STARPU_HAVE_MAGMA], [1], [Define to 1 if you have the MAGMA library.])
 
477
        AC_SUBST([STARPU_HAVE_MAGMA], [1])
 
478
        have_magma=yes
 
479
], [:])
 
480
fi
 
481
AM_CONDITIONAL(STARPU_HAVE_MAGMA, [test x$have_magma = xyes])
 
482
AC_MSG_CHECKING(whether MAGMA should be used)
 
483
AC_MSG_RESULT($have_magma)
 
484
 
 
485
# cufftDoubleComplex may not be available on an old CUDA setup
 
486
AC_CHECK_TYPE(cufftDoubleComplex,
 
487
        [have_cufftdoublecomplex=yes],
 
488
        [have_cufftdoublecomplex=no], [#include <cufft.h>])
 
489
AM_CONDITIONAL(STARPU_HAVE_CUFFTDOUBLECOMPLEX, test x$have_cufftdoublecomplex = xyes)
 
490
if test x$have_cufftdoublecomplex = xyes; then
 
491
        AC_DEFINE(STARPU_HAVE_CUFFTDOUBLECOMPLEX, [1], [cufftDoubleComplex is available])
 
492
fi
 
493
 
 
494
# The CURAND library is only available since CUDA 3.2
 
495
have_curand=$enable_cuda
 
496
if test x$enable_cuda = xyes; then
 
497
        SAVED_LDFLAGS="${LDFLAGS}"
 
498
        LDFLAGS="${LDFLAGS} ${STARPU_CUDA_LDFLAGS}"
 
499
        AC_HAVE_LIBRARY([curand],[have_curand=yes],[have_curand=no])
 
500
        LDFLAGS="${SAVED_LDFLAGS}"
 
501
fi
 
502
AC_MSG_CHECKING(whether CURAND is available)
 
503
AC_MSG_RESULT($have_curand)
 
504
if test x$have_curand = xyes; then
 
505
    AC_DEFINE(STARPU_HAVE_CURAND,[1], [CURAND is available])
 
506
    STARPU_CURAND_LDFLAGS="$STARPU_CURAND_LDFLAGS -lcurand"
 
507
    AC_SUBST(STARPU_CURAND_LDFLAGS)
 
508
fi
 
509
 
 
510
# Peer transfers are only supported since CUDA 4.0
 
511
# Disable them if user explicity wants to disable them
 
512
AC_ARG_ENABLE(cuda_memcpy_peer, [AS_HELP_STRING([--disable-cuda-memcpy-peer], [do not allow peer transfers when using CUDA 4.0])],, [enable_cuda_memcpy_peer=yes])
 
513
have_cuda_memcpy_peer=no
 
514
if test x$enable_cuda_memcpy_peer = xyes -a x$enable_cuda = xyes ; then
 
515
    SAVED_LDFLAGS="${LDFLAGS}"
 
516
    LDFLAGS="${LDFLAGS} ${STARPU_CUDA_LDFLAGS}"
 
517
    AC_CHECK_FUNC([cudaMemcpyPeer], have_cuda_memcpy_peer=yes, have_cuda_memcpy_peer=no)
 
518
    LDFLAGS="${SAVED_LDFLAGS}"
 
519
fi
 
520
if test x$have_cuda_memcpy_peer = xyes; then
 
521
    AC_DEFINE(HAVE_CUDA_MEMCPY_PEER,[],[Peer transfers are supported in CUDA])
 
522
fi
 
523
 
 
524
if test x$enable_cuda = xyes; then
 
525
    if test x$starpu_windows != xyes ; then
 
526
        STARPU_CUDA_LDFLAGS="$STARPU_CUDA_LDFLAGS -lstdc++"
 
527
    fi
 
528
    AC_SUBST(STARPU_CUDA_LDFLAGS)
 
529
    AC_SUBST(STARPU_CUFFT_LDFLAGS)
 
530
    AC_SUBST(STARPU_CUDA_CPPFLAGS)
 
531
fi
 
532
 
 
533
###############################################################################
 
534
#                                                                             #
 
535
#                                 OpenCL settings                             #
 
536
#                                                                             #
 
537
###############################################################################
 
538
 
 
539
AC_MSG_CHECKING(maximum number of OpenCL devices)
 
540
AC_ARG_ENABLE(maxopencldev, [AS_HELP_STRING([--enable-maxopencldev=<number>],
 
541
                        [maximum number of OPENCL devices])],
 
542
                        nmaxopencldev=$enableval, nmaxopencldev=8)
 
543
AC_MSG_RESULT($nmaxopencldev)
 
544
AC_DEFINE_UNQUOTED(STARPU_MAXOPENCLDEVS, [$nmaxopencldev],
 
545
                [maximum number of OPENCL devices])
 
546
AC_ARG_ENABLE(opencl, [AS_HELP_STRING([--disable-opencl],
 
547
                [do not use OpenCL device(s)])],, [enable_opencl=maybe])
 
548
 
 
549
AC_DEFUN([STARPU_CHECK_OPENCL],
 
550
[
 
551
    __opencl_dir=$1
 
552
    __opencl_include_dir=$2
 
553
    __opencl_lib_dir=$3
 
554
 
 
555
    if test "$__opencl_dir" != "no" ; then
 
556
        AC_MSG_CHECKING(whether OpenCL is available in $__opencl_dir $__opencl_include_dir and $__opencl_lib_dir)
 
557
    else
 
558
        AC_MSG_CHECKING(whether OpenCL is available)
 
559
    fi
 
560
    AC_MSG_RESULT()
 
561
 
 
562
    if test "$__opencl_include_dir" = "no" -a "$__opencl_dir" != "no" ; then
 
563
        __opencl_include_dir="$__opencl_dir/include"
 
564
    fi
 
565
 
 
566
    SAVED_CPPFLAGS="$CPPFLAGS"
 
567
    SAVED_LDFLAGS="${LDFLAGS}"
 
568
 
 
569
    if test "$__opencl_include_dir" != "no" ; then
 
570
        CPPFLAGS="${CPPFLAGS} -I$__opencl_include_dir"
 
571
    fi
 
572
    AC_CHECK_HEADER([CL/cl.h],[have_valid_opencl=yes],[have_valid_opencl=no])
 
573
    unset ac_cv_header_CL_cl_h
 
574
 
 
575
    if test "$have_valid_opencl" = "yes" ; then
 
576
        if test "$__opencl_lib_dir" != "no"; then
 
577
            LDFLAGS="${SAVED_LDFLAGS} -L$__opencl_lib_dir"
 
578
            AC_HAVE_LIBRARY([OpenCL],[have_valid_opencl=yes],[have_valid_opencl=no])
 
579
            unset ac_cv_lib_OpenCL_main
 
580
        else
 
581
            AC_MSG_CHECKING(whether OpenCL is available in $__opencl_dir)
 
582
            AC_MSG_RESULT()
 
583
            AC_HAVE_LIBRARY([OpenCL],[have_valid_opencl=yes],[have_valid_opencl=no])
 
584
            unset ac_cv_lib_OpenCL_main
 
585
            if test "$have_valid_opencl" = "no" -a "$__opencl_dir" != "no" ; then
 
586
                for __cuda_libdir in lib64 lib lib/x86 lib/Win32 ; do
 
587
                    __opencl_lib_dir="$__opencl_dir/$__cuda_libdir"
 
588
                    AC_MSG_CHECKING(whether OpenCL is available in $__opencl_dir and $__opencl_lib_dir)
 
589
                    AC_MSG_RESULT()
 
590
                    LDFLAGS="${SAVED_LDFLAGS} -L$__opencl_lib_dir"
 
591
                    AC_HAVE_LIBRARY([OpenCL],[have_valid_opencl=yes],[have_valid_opencl=no])
 
592
                    unset ac_cv_lib_OpenCL_main
 
593
                    if test "$have_valid_opencl" = yes ; then
 
594
                        break
 
595
                    fi
 
596
                done
 
597
            else
 
598
                LDFLAGS="${SAVED_LDFLAGS}"
 
599
                AC_HAVE_LIBRARY([OpenCL],[have_valid_opencl=yes],[have_valid_opencl=no])
 
600
                unset ac_cv_lib_OpenCL_main
 
601
            fi
 
602
        fi
 
603
    fi
 
604
 
 
605
    if test "$have_valid_opencl" = "yes" -a "$__opencl_include_dir" != "no"; then
 
606
        STARPU_OPENCL_CPPFLAGS="-I$__opencl_include_dir"
 
607
        AC_CHECK_HEADERS([CL/cl_ext.h])
 
608
    fi
 
609
 
 
610
    CPPFLAGS="${SAVED_CPPFLAGS}"
 
611
    LDFLAGS="${SAVED_LDFLAGS}"
 
612
 
 
613
    if test "$have_valid_opencl" = "yes" ; then
 
614
        if test "$__opencl_lib_dir" != "no"; then
 
615
            STARPU_OPENCL_LDFLAGS="-L$__opencl_lib_dir"
 
616
        fi
 
617
        STARPU_OPENCL_LDFLAGS="${STARPU_OPENCL_LDFLAGS} -lOpenCL"
 
618
    fi
 
619
 
 
620
])
 
621
 
 
622
#AC_MSG_CHECKING(whether OpenCL is available)
 
623
AC_ARG_WITH(opencl-dir,
 
624
        [AS_HELP_STRING([--with-opencl-dir=<path>],
 
625
        [specify OpenCL installation directory])],
 
626
        [
 
627
                opencl_dir="$withval"
 
628
                # in case this was not explicit yet
 
629
                enable_opencl=yes
 
630
        ], opencl_dir=no)
 
631
 
 
632
AC_ARG_WITH(opencl-include-dir,
 
633
        [AS_HELP_STRING([--with-opencl-include-dir=<path>],
 
634
        [specify where OpenCL headers are installed])],
 
635
        [
 
636
                opencl_include_dir="$withval"
 
637
                # in case this was not explicit yet
 
638
                enable_opencl=yes
 
639
        ], [opencl_include_dir=no])
 
640
 
 
641
AC_ARG_WITH(opencl-lib-dir,
 
642
        [AS_HELP_STRING([--with-opencl-lib-dir=<path>],
 
643
        [specify where OpenCL libraries are installed])],
 
644
        [
 
645
                opencl_lib_dir="$withval"
 
646
                # in case this was not explicit yet
 
647
                enable_opencl=yes
 
648
        ], [opencl_lib_dir=no])
 
649
 
 
650
AC_DEFUN([STARPU_LOOK_FOR_OPENCL],
 
651
[
 
652
        if test "x$has_opencl_being_checked" != "xyes" ; then
 
653
            STARPU_CHECK_OPENCL("$opencl_dir", "$opencl_include_dir", "$opencl_lib_dir")
 
654
            if test "$have_valid_opencl" = "no" ; then
 
655
                for f in "/usr/local/cuda" "/c/cuda" "/cygdrive/c/cuda" "/opt/cuda" "$CUDA_PATH" "$CUDA_INC_PATH/.." "$CUDA_INSTALL_PATH" "$CUDA_TOOLKIT"; do
 
656
                    if test -n "$f" ; then
 
657
                        STARPU_CHECK_OPENCL("$f", "no", "no")
 
658
                        if test "$have_valid_opencl" = "yes" ; then
 
659
                            break
 
660
                        fi
 
661
                    fi
 
662
                done
 
663
            fi
 
664
            has_opencl_being_checked=yes
 
665
        fi
 
666
])
 
667
 
 
668
if test x$enable_opencl = xyes -o x$enable_opencl = xmaybe; then
 
669
        STARPU_LOOK_FOR_OPENCL()
 
670
        # in case OpenCL was explicitely required, but is not available, this is an error
 
671
        if test x$enable_opencl = xyes -a x$have_valid_opencl = xno; then
 
672
            AC_MSG_ERROR([cannot find OpenCL])
 
673
        fi
 
674
 
 
675
        # now we enable OpenCL if and only if a proper setup is available
 
676
        enable_opencl=$have_valid_opencl
 
677
fi
 
678
 
 
679
AC_MSG_CHECKING(whether OpenCL should be used)
 
680
AC_MSG_RESULT($enable_opencl)
 
681
AC_SUBST(STARPU_USE_OPENCL, $enable_opencl)
 
682
AM_CONDITIONAL(STARPU_USE_OPENCL, test x$enable_opencl = xyes)
 
683
if test x$enable_opencl = xyes ; then
 
684
        AC_DEFINE(STARPU_USE_OPENCL, [1], [OpenCL support is activated])
 
685
        STARPU_OPENCL_CPPFLAGS="${STARPU_OPENCL_CPPFLAGS} -DSTARPU_OPENCL_DATADIR=${datarootdir}/starpu/opencl"
 
686
        AC_SUBST(STARPU_OPENCL_DATAdir, "$(eval echo ${datarootdir}/starpu/opencl/examples)")
 
687
        AC_SUBST(STARPU_OPENCL_CPPFLAGS)
 
688
        AC_SUBST(STARPU_OPENCL_LDFLAGS)
 
689
fi
 
690
 
 
691
###############################################################################
 
692
#                                                                             #
 
693
#                                 Cell settings                               #
 
694
#                                                                             #
 
695
###############################################################################
 
696
 
 
697
#TODO fix the default dir
 
698
AC_ARG_ENABLE(gordon, [AS_HELP_STRING([--enable-gordon],
 
699
                        [use Cell SPUs])],, enable_gordon=maybe)
 
700
 
 
701
if test x$enable_gordon = xyes -o x$enable_gordon = xmaybe; then
 
702
 
 
703
        AC_ARG_WITH(gordon-dir, [AS_HELP_STRING([--with-gordon-dir=<path>],
 
704
                        [specify Gordon installation directory (default is /usr/local/)])],
 
705
                        [
 
706
                                gordon_dir="$withval"
 
707
                                enable_gordon=yes
 
708
                        ], gordon_dir=/usr/local/)
 
709
 
 
710
        # do we have a valid Gordon setup ?
 
711
        have_valid_gordon=yes
 
712
 
 
713
        # can we use dynamic code loading facilities ?
 
714
        AC_CHECK_LIB(elf, elf_memory,, [have_valid_gordon=no])
 
715
 
 
716
        AC_CHECK_LIB(spe2, spe_context_create,,[have_valid_gordon=no])
 
717
        AC_CHECK_FUNC(spe_in_mbox_write, [], [have_valid_gordon=no])
 
718
 
 
719
        PKG_PROG_PKG_CONFIG
 
720
        if test -d "$gordon_dir"; then
 
721
                PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:$gordon_dir"
 
722
        fi
 
723
        AC_SUBST(PKG_CONFIG_PATH)
 
724
        PKG_CHECK_MODULES([GORDON], [libgordon], [], have_valid_gordon=no)
 
725
 
 
726
        CPPFLAGS="${CPPFLAGS} ${GORDON_CFLAGS}"
 
727
        LIBS="${LIBS} ${GORDON_LIBS}"
 
728
 
 
729
        # AC_CHECK_FUNC(gordon_init, [gordon], [have_valid_gordon=no])
 
730
 
 
731
        # in case Gordon was explicitely required, but is not available, this is an error
 
732
        if test x$enable_gordon = xyes -a x$have_valid_gordon = xno; then
 
733
                AC_MSG_ERROR([cannot find Gordon])
 
734
        fi
 
735
 
 
736
 
 
737
        # now we enable Gordon if and only if a proper setup is available
 
738
        enable_gordon=$have_valid_gordon
 
739
fi
 
740
 
 
741
AC_MSG_CHECKING(whether GORDON should be used)
 
742
AC_MSG_RESULT($enable_gordon)
 
743
AC_SUBST(STARPU_USE_GORDON, $enable_gordon)
 
744
AM_CONDITIONAL(STARPU_USE_GORDON, test x$enable_gordon = xyes)
 
745
 
 
746
if test x$enable_gordon = xyes; then
 
747
        AC_DEFINE(STARPU_USE_GORDON, [1], [Cell support is enabled])
 
748
        GORDON_REQUIRES=gordon
 
749
fi
 
750
AC_SUBST(GORDON_REQUIRES)
 
751
 
 
752
AC_MSG_CHECKING(whether blocking drivers should be disabled)
 
753
AC_ARG_ENABLE(blocking-drivers, [AS_HELP_STRING([--disable-blocking-drivers], [disable blocking drivers])],
 
754
                                enable_blocking=$enableval, enable_blocking=$enable_gordon)
 
755
AC_MSG_RESULT($enable_blocking)
 
756
 
 
757
if test x$enable_blocking = xno; then
 
758
        AC_DEFINE(STARPU_NON_BLOCKING_DRIVERS, [1], [drivers must progress])
 
759
fi
 
760
 
 
761
 
 
762
###############################################################################
 
763
#                                                                             #
 
764
#                   Debug and Performance analysis tools                      #
 
765
#                                                                             #
 
766
###############################################################################
 
767
 
 
768
AC_MSG_CHECKING(whether debug mode should be enabled)
 
769
AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug], [enable debug mode])],
 
770
                        enable_debug=$enableval, enable_debug=no)
 
771
AC_MSG_RESULT($enable_debug)
 
772
 
 
773
if test x$enable_debug = xyes; then
 
774
        CFLAGS="$CFLAGS -O0"
 
775
        AC_DEFINE(STARPU_SPINLOCK_CHECK, [1], [check spinlock use])
 
776
else
 
777
        CFLAGS="$CFLAGS -O3"
 
778
fi
 
779
CFLAGS+=" -gdwarf-2 -g3 "
 
780
 
 
781
AC_MSG_CHECKING(whether extra checks should be performed)
 
782
AC_ARG_ENABLE(fast, [AS_HELP_STRING([--enable-fast],
 
783
                        [do not enforce assertions])],
 
784
                        enable_fast=$enableval, enable_fast=no)
 
785
AC_MSG_RESULT($enable_fast)
 
786
if test x$enable_fast = xyes; then
 
787
        AC_DEFINE(STARPU_NO_ASSERT, [1], [disable assertions])
 
788
fi
 
789
 
 
790
AC_MSG_CHECKING(whether memory status should be displayed)
 
791
AC_ARG_ENABLE(memory-status, [AS_HELP_STRING([--enable-memory-status],
 
792
                             [display memory status at the end of execution])],
 
793
                             enable_memory_status=$enableval, enable_memory_status=no)
 
794
AC_MSG_RESULT($enable_memory_status)
 
795
if test x$enable_memory_status = xyes; then
 
796
        AC_DEFINE(STARPU_MEMORY_STATUS, [1], [display memory status])
 
797
fi
 
798
 
 
799
 
 
800
AC_MSG_CHECKING(whether debug messages should be displayed)
 
801
AC_ARG_ENABLE(verbose, [AS_HELP_STRING([--enable-verbose],
 
802
                        [display verbose debug messages])],
 
803
                        enable_verbose=$enableval, enable_verbose=no)
 
804
AC_MSG_RESULT($enable_verbose)
 
805
if test x$enable_verbose = xyes; then
 
806
        AC_DEFINE(STARPU_VERBOSE, [1], [display verbose debug messages])
 
807
fi
 
808
 
 
809
 
 
810
AC_MSG_CHECKING(whether coverage testing should be enabled)
 
811
AC_ARG_ENABLE(coverage, [AS_HELP_STRING([--enable-coverage],
 
812
                        [enable coverage checking])],
 
813
                        enable_coverage=$enableval, enable_coverage=no)
 
814
AC_MSG_RESULT($enable_coverage)
 
815
AC_SUBST(COVERAGE, $enable_coverage)
 
816
AM_CONDITIONAL(STARPU_COVERAGE_ENABLED, [test "x$enable_coverage" = "xyes"])
 
817
if test x$enable_coverage = xyes; then
 
818
        CPPFLAGS="${CPPFLAGS} --coverage"
 
819
        LDFLAGS="${LDFLAGS} --coverage"
 
820
fi
 
821
 
 
822
 
 
823
# shall we use FxT to generate trace of the execution ?
 
824
AC_MSG_CHECKING(whether FxT traces should be generated)
 
825
AC_ARG_WITH(fxt, [AS_HELP_STRING([--with-fxt[=<dir>]], [generate fxt traces])],
 
826
        [
 
827
                if test x$withval != xno; then
 
828
                        use_fxt=yes
 
829
                        if test x$withval = xyes; then
 
830
                                AC_MSG_RESULT(yes)
 
831
                                use_fxt_from_system=yes
 
832
                        else
 
833
                                # use specified path
 
834
                                # TODO check if the dir is actually containing FxT
 
835
                                use_fxt_from_system=no
 
836
                                fxtdir=$withval
 
837
                                AC_MSG_RESULT(yes using $fxtdir)
 
838
                                AC_SUBST(FXTDIR, $fxtdir)
 
839
                        fi
 
840
                else
 
841
                        use_fxt=no
 
842
                        AC_MSG_RESULT(no)
 
843
                fi
 
844
        ],
 
845
        [
 
846
                use_fxt=no
 
847
                AC_MSG_RESULT(no)
 
848
        ])
 
849
AC_SUBST(STARPU_USE_FXT, $use_fxt)
 
850
AM_CONDITIONAL(STARPU_USE_FXT, test x$use_fxt = xyes)
 
851
 
 
852
if test x$use_fxt = xyes; then
 
853
        AC_DEFINE(STARPU_USE_FXT, [1], [enable FxT traces])
 
854
        AC_DEFINE(CONFIG_FUT, [1], [enable FUT traces])
 
855
 
 
856
        if test x$use_fxt_from_system = xno; then
 
857
                CPPFLAGS="${CPPFLAGS} -I$fxtdir/include/ "
 
858
                LDFLAGS="${LDFLAGS} -L$fxtdir/lib/ -lfxt"
 
859
        else
 
860
            PKG_CHECK_MODULES([FXT],  [fxt])
 
861
        fi
 
862
fi
 
863
 
 
864
AC_MSG_CHECKING(whether performance debugging should be enabled)
 
865
AC_ARG_ENABLE(perf-debug, [AS_HELP_STRING([--enable-perf-debug],
 
866
                        [enable performance debugging through gprof])],
 
867
                        enable_perf_debug=$enableval, enable_perf_debug=no)
 
868
AC_MSG_RESULT($enable_perf_debug)
 
869
AC_SUBST(STARPU_PERF_DEBUG, $enable_perf_debug)
 
870
if test x$enable_perf_debug = xyes; then
 
871
        AC_DEFINE(STARPU_PERF_DEBUG, [1], [enable performance debug])
 
872
        CPPFLAGS="${CPPFLAGS} -pg -fprofile-arcs "
 
873
        LDFLAGS="${LDFLAGS} -pg -fprofile-arcs "
 
874
fi
 
875
 
 
876
AC_MSG_CHECKING(whether performance model debugging should be enabled)
 
877
AC_ARG_ENABLE(model-debug, [AS_HELP_STRING([--enable-model-debug],
 
878
                        [enable performance model debugging])],
 
879
                        enable_model_debug=$enableval, enable_model_debug=no)
 
880
AC_MSG_RESULT($enable_model_debug)
 
881
if  test x$enable_model_debug = xyes; then
 
882
        AC_DEFINE(STARPU_MODEL_DEBUG, [1], [enable performance model debug])
 
883
fi
 
884
 
 
885
AC_MSG_CHECKING(whether statistics should be generated)
 
886
AC_ARG_ENABLE(stats, [AS_HELP_STRING([--enable-stats],
 
887
                        [enable statistics])],
 
888
                        enable_stats=$enableval, enable_stats=no)
 
889
AC_MSG_RESULT($enable_stats)
 
890
AC_SUBST(STATS, $enable_stats)
 
891
AC_SUBST(STARPU_DATA_STATS, $enable_stats)
 
892
 
 
893
if test x$enable_stats = xyes; then
 
894
        AC_DEFINE(STARPU_DATA_STATS, [1], [enable statistics])
 
895
fi
 
896
 
 
897
AC_CHECK_HEADERS([glpk.h])
 
898
STARPU_HAVE_LIBRARY(GLPK, [glpk])
 
899
 
 
900
###############################################################################
 
901
#                                                                             #
 
902
#                  Miscellaneous options for StarPU                           #
 
903
#                                                                             #
 
904
###############################################################################
 
905
 
 
906
AC_MSG_CHECKING(how many buffers can be manipulated per task)
 
907
AC_ARG_ENABLE(maxbuffers, [AS_HELP_STRING([--enable-maxbuffers=<nbuffers>],
 
908
                        [maximum number of buffers per task])],
 
909
                        nmaxbuffers=$enableval, nmaxbuffers=8)
 
910
AC_MSG_RESULT($nmaxbuffers)
 
911
AC_DEFINE_UNQUOTED(STARPU_NMAXBUFS, [$nmaxbuffers],
 
912
                [how many buffers can be manipulated per task])
 
913
 
 
914
# We have one memory node shared by all CPU workers, one node per GPU, and
 
915
# currently the Cell driver is using the same memory node as the CPU.
 
916
maxnodes=1
 
917
if test x$enable_cuda = xyes ; then
 
918
        # we could have used nmaxcudadev + 1, but this would certainly give an
 
919
        # odd number.
 
920
        maxnodes=`expr $maxnodes + $nmaxcudadev`
 
921
fi
 
922
if test x$enable_opencl = xyes ; then
 
923
        # we could have used nmaxcudadev + 1, but this would certainly give an
 
924
        # odd number.
 
925
        maxnodes=`expr $maxnodes + $nmaxopencldev`
 
926
fi
 
927
# todo: set maxnodes to the next power of 2 greater than maxnodes
 
928
 
 
929
AC_MSG_CHECKING(maximum number of memory nodes)
 
930
AC_MSG_RESULT($maxnodes)
 
931
AC_DEFINE_UNQUOTED(STARPU_MAXNODES, [$maxnodes],
 
932
                [maximum number of memory nodes])
 
933
 
 
934
 
 
935
AC_MSG_CHECKING(whether allocation cache should be used)
 
936
AC_ARG_ENABLE(allocation-cache, [AS_HELP_STRING([--enable-allocation-cache],
 
937
                        [enable data allocation cache])],
 
938
                        enable_allocation_cache=$enableval, enable_allocation_cache=no)
 
939
AC_MSG_RESULT($enable_allocation_cache)
 
940
if test x$enable_allocation_cache = xyes; then
 
941
        AC_DEFINE(STARPU_USE_ALLOCATION_CACHE, [1], [enable data allocation cache])
 
942
fi
 
943
 
 
944
AC_ARG_WITH(perf-model-dir, [AS_HELP_STRING([--with-perf-model-dir=<dir>], [specify where performance models shoulds be stored])],
 
945
        [
 
946
                if test x$withval = xno; then
 
947
                        AC_MSG_ERROR(--without-perf-model-dir is not a valid option)
 
948
                fi
 
949
 
 
950
                perf_model_dir="$withval"
 
951
                have_explicit_perf_model_dir=yes
 
952
                AC_DEFINE_UNQUOTED(STARPU_PERF_MODEL_DIR, ["$perf_model_dir"], [performance models location])
 
953
        ], [
 
954
                # by default, we put the performance models in
 
955
                # $HOME/.starpu/sampling/
 
956
                have_explicit_perf_model_dir=no
 
957
                perf_model_dir="\$HOME/.starpu/sampling/"
 
958
        ]
 
959
        )
 
960
AC_MSG_CHECKING(using explicit performance model location)
 
961
AC_MSG_RESULT($have_explicit_perf_model_dir)
 
962
 
 
963
AC_MSG_CHECKING(performance models location)
 
964
AC_MSG_RESULT($perf_model_dir)
 
965
 
 
966
# On many multicore CPUs, clock cycles are not synchronized
 
967
AC_CHECK_LIB([rt], [clock_gettime])
 
968
AC_CHECK_FUNCS([clock_gettime])
 
969
 
 
970
# Compute the maximum number of workers (we round it to 16 for alignment
 
971
# purposes).
 
972
nmaxworkers=`expr 16 \* \( \( $maxcpus + $nmaxcudadev + $nmaxopencldev + 15 \) / 16 \) `
 
973
AC_MSG_CHECKING(Maximum number of workers)
 
974
AC_MSG_RESULT($nmaxworkers)
 
975
AC_DEFINE_UNQUOTED(STARPU_NMAXWORKERS, [$nmaxworkers], [Maximum number of workers])
 
976
 
 
977
# Computes the maximum number of implementations per arch
 
978
AC_MSG_CHECKING(maximum number of implementations)
 
979
AC_ARG_ENABLE(maximplementations, [AS_HELP_STRING([--enable-maximplementations=<number>],
 
980
                [maximum number of implementations])],
 
981
                maximplementations=$enableval, maximplementations=4)
 
982
AC_MSG_RESULT($maximplementations)
 
983
AC_DEFINE_UNQUOTED(STARPU_MAXIMPLEMENTATIONS, [$maximplementations],
 
984
                [maximum number of implementations])
 
985
 
 
986
###############################################################################
 
987
#                                                                             #
 
988
#                                    MPI                                      #
 
989
#                                                                             #
 
990
###############################################################################
 
991
 
 
992
AC_ARG_WITH(mpicc, [AS_HELP_STRING([--with-mpicc[=<path to mpicc>]],
 
993
                        [Path of the mpicc compiler])],
 
994
        [
 
995
                if test x$withval = xyes; then
 
996
                        AC_MSG_ERROR(--with-mpicc must be given a pathname)
 
997
                else
 
998
                        mpicc_path=$withval
 
999
                fi
 
1000
        ],
 
1001
        [
 
1002
                # nothing was specified: default value is used
 
1003
                AC_PATH_PROG(mpicc_path, mpicc, [no], [])
 
1004
        ])
 
1005
 
 
1006
# We test if the MPICC compiler exists
 
1007
if test ! -x $mpicc_path; then
 
1008
        #MPICC does not exists or is not executable
 
1009
        AC_MSG_RESULT(The mpicc compiler is not valid)
 
1010
        use_mpi=no
 
1011
else
 
1012
        use_mpi=yes
 
1013
fi
 
1014
 
 
1015
AC_MSG_CHECKING(mpicc path)
 
1016
AC_MSG_RESULT($mpicc_path)
 
1017
AC_SUBST(MPICC, $mpicc_path)
 
1018
if test x$use_mpi = xyes; then
 
1019
        cc_or_mpicc=$mpicc_path
 
1020
else
 
1021
        cc_or_mpicc=$CC
 
1022
fi
 
1023
AC_SUBST(CC_OR_MPICC, $cc_or_mpicc)
 
1024
 
 
1025
# If the user specifically asks for it, or if we are in a developer checkout, we enable mpi check
 
1026
AC_ARG_ENABLE(mpi-check, AC_HELP_STRING([--enable-mpi-check], [Enable execution of MPI testcases]))
 
1027
running_mpi_check=no
 
1028
if test -d "$srcdir/.svn" ; then
 
1029
    running_mpi_check=yes
 
1030
fi
 
1031
if test x$enable_mpi_check = xyes ; then
 
1032
    running_mpi_check=yes
 
1033
fi
 
1034
if test x$enable_mpi_check = xno ; then
 
1035
    running_mpi_check=no
 
1036
fi
 
1037
 
 
1038
# Check if mpiexec is available
 
1039
AC_ARG_WITH(mpiexec, [AS_HELP_STRING([--with-mpiexec[=<path to mpiexec>]],
 
1040
                        [Path of mpiexec])],
 
1041
        [
 
1042
                if test x$withval = xyes; then
 
1043
                        AC_MSG_ERROR(--with-mpiexec must be given a pathname)
 
1044
                else
 
1045
                        mpiexec_path=$withval
 
1046
                fi
 
1047
        ],
 
1048
        [
 
1049
                # nothing was specified: look in the path
 
1050
                AC_PATH_PROG(mpiexec_path, mpiexec, [no], [$(dirname $mpicc_path):$PATH])
 
1051
        ])
 
1052
 
 
1053
AC_MSG_CHECKING(whether mpiexec is available)
 
1054
AC_MSG_RESULT($mpiexec_path)
 
1055
 
 
1056
# We test if MPIEXEC exists
 
1057
if test ! -x $mpiexec_path; then
 
1058
        #MPIEXEC does not exists or is not executable
 
1059
        AC_MSG_RESULT(The mpiexec script is not valid)
 
1060
        running_mpi_check=no
 
1061
        mpiexec_path=""
 
1062
fi
 
1063
 
 
1064
AM_CONDITIONAL(STARPU_MPI_CHECK, test x$running_mpi_check = xyes)
 
1065
if test x$use_mpi = xyes; then
 
1066
        AC_MSG_CHECKING(whether MPI tests should be run)
 
1067
        AC_MSG_RESULT($running_mpi_check)
 
1068
        AC_SUBST(MPIEXEC,$mpiexec_path)
 
1069
fi
 
1070
 
 
1071
AC_MSG_CHECKING(whether the StarPU MPI library should be generated)
 
1072
AC_MSG_RESULT($use_mpi)
 
1073
AC_SUBST(USE_MPI, $use_mpi)
 
1074
AM_CONDITIONAL(USE_MPI, test x$use_mpi = xyes)
 
1075
if test x$use_mpi = xyes; then
 
1076
        AC_DEFINE(STARPU_USE_MPI,[],[whether the StarPU MPI library is available])
 
1077
fi
 
1078
 
 
1079
###############################################################################
 
1080
#                                                                             #
 
1081
#                               StarPU-Top                                    #
 
1082
#                                                                             #
 
1083
###############################################################################
 
1084
 
 
1085
AC_ARG_ENABLE([starpu-top],
 
1086
  [AS_HELP_STRING([--disable-starpu-top],
 
1087
    [build StarPU-Top])],
 
1088
  [enable_starpu_top="no"],
 
1089
  [enable_starpu_top="maybe"])
 
1090
 
 
1091
# Check whether StarPU-Top can be built
 
1092
AC_MSG_CHECKING(for StarPU-Top)
 
1093
 
 
1094
if test "x$enable_starpu_top" = "xmaybe" ; then
 
1095
        can_build_starpu_top=no
 
1096
        AC_PATH_PROGS([QMAKE], [qmake-qt4 qmake], [not-found])
 
1097
        if test x$QMAKE != xnot-found; then
 
1098
                QMAKE_VERSION=`$QMAKE --version 2>&1 | head -n 1 | cut -d '.' -f 1 | cut -d ' ' -f 3`
 
1099
                if test $QMAKE_VERSION -ge 2 ; then
 
1100
                        PKG_CHECK_EXISTS([QtGui QtNetwork QtOpenGL QtSql], [
 
1101
                                QT_MAJVERSION=`$PKG_CONFIG --modversion QtGui | cut -d '.' -f 1`
 
1102
                                QT_MINVERSION=`$PKG_CONFIG --modversion QtGui | cut -d '.' -f 2`
 
1103
                                if test $QT_MAJVERSION -gt 4 -o \( $QT_MAJVERSION -eq 4 -a $QT_MINVERSION -ge 7 \) ; then
 
1104
                                        can_build_starpu_top=yes
 
1105
                                fi
 
1106
                                QWT_PRI=embed
 
1107
                                AC_ARG_WITH(qwt-include-dir,
 
1108
                                        [AS_HELP_STRING([--with-qwt-include-dir=<path>],
 
1109
                                        [specify installed libqwt include path])],
 
1110
                                        [
 
1111
                                                STARPU_QWT_INCLUDE="$withval"
 
1112
                                                AC_SUBST(STARPU_QWT_INCLUDE)
 
1113
                                                QWT_PRI=system
 
1114
                                        ])
 
1115
                                AC_ARG_WITH(qwt-lib-dir,
 
1116
                                        [AS_HELP_STRING([--with-qwt-lib-dir=<path>],
 
1117
                                        [specify installed libqwt library path])],
 
1118
                                        [
 
1119
                                                STARPU_QWT_LDFLAGS="-L$withval"
 
1120
                                                QWT_PRI=system
 
1121
                                        ])
 
1122
                                AC_ARG_WITH(qwt-lib,
 
1123
                                        [AS_HELP_STRING([--with-qwt-lib=<name>],
 
1124
                                        [specify installed libqwt library name])],
 
1125
                                        [
 
1126
                                                STARPU_QWT_LDFLAGS="${STARPU_QWT_LDFLAGS} -l$withval"
 
1127
                                                QWT_PRI=system
 
1128
                                        ])
 
1129
                                AC_SUBST(STARPU_QWT_LDFLAGS)
 
1130
                                AC_SUBST(QWT_PRI)
 
1131
                        ])
 
1132
                fi
 
1133
        fi
 
1134
fi
 
1135
 
 
1136
if test "x$enable_starpu_top" = "xmaybe" ; then
 
1137
  build_starpu_top=$can_build_starpu_top
 
1138
else
 
1139
  build_starpu_top=no
 
1140
fi
 
1141
 
 
1142
AM_CONDITIONAL(BUILD_STARPU_TOP, test x$build_starpu_top = xyes)
 
1143
 
 
1144
###############################################################################
 
1145
#                                                                             #
 
1146
#                           Flags for C Compiler                              #
 
1147
#                                                                             #
 
1148
###############################################################################
 
1149
 
 
1150
# IS_SUPPORTED_CFLAG(flag)
 
1151
# ------------------------
 
1152
# Check if the CFLAGS `flag' is supported by the compiler
 
1153
AC_DEFUN([IS_SUPPORTED_CFLAG],
 
1154
[
 
1155
        AC_REQUIRE([AC_PROG_CC])
 
1156
 
 
1157
        AC_MSG_CHECKING([whether compiler support $1])
 
1158
 
 
1159
        SAVED_CFLAGS="$CFLAGS"
 
1160
        CFLAGS="$1" # -we10006"
 
1161
 
 
1162
        AC_COMPILE_IFELSE(
 
1163
                AC_LANG_PROGRAM(
 
1164
                        [[]],
 
1165
                        [[
 
1166
                                AC_LANG_SOURCE([
 
1167
                                        const char *hello = "Hello World";
 
1168
                                ])
 
1169
                        ]]
 
1170
                ),
 
1171
                [
 
1172
                        GLOBAL_AM_CFLAGS="$GLOBAL_AM_CFLAGS $1"
 
1173
                        AC_MSG_RESULT(yes)
 
1174
                ],
 
1175
                        AC_MSG_RESULT(no)
 
1176
        )
 
1177
        CFLAGS="$SAVED_CFLAGS"
 
1178
])
 
1179
 
 
1180
IS_SUPPORTED_CFLAG(-W)
 
1181
IS_SUPPORTED_CFLAG(-Wall)
 
1182
IS_SUPPORTED_CFLAG(-Wextra)
 
1183
AC_SUBST(GLOBAL_AM_CFLAGS)
 
1184
 
 
1185
if test "x$STARPU_DEVEL" != x; then
 
1186
        AC_DEFINE(STARPU_DEVEL, [1], [enable developer warnings])
 
1187
fi
 
1188
 
 
1189
# Same value as Automake's, for use in other places.
 
1190
pkglibdir="\${libdir}/$PACKAGE"
 
1191
AC_SUBST([pkglibdir])
 
1192
 
 
1193
 
 
1194
###############################################################################
 
1195
#                                                                             #
 
1196
#                               GCC extensions                                #
 
1197
#                                                                             #
 
1198
###############################################################################
 
1199
 
 
1200
AC_ARG_ENABLE([gcc-extensions],
 
1201
  [AS_HELP_STRING([--enable-gcc-extensions],
 
1202
    [build the GCC plug-in that provides C language extensions (experimental)])],
 
1203
  [enable_gcc_plugin="$enableval"],
 
1204
  [enable_gcc_plugin="maybe"])
 
1205
 
 
1206
if test "x$enable_gcc_plugin" = "xyes" -o "x$enable_gcc_plugin" = "xmaybe" ; then
 
1207
    STARPU_GCC_PLUGIN_SUPPORT
 
1208
 
 
1209
    if test "x$ac_cv_have_gcc_plugins" = "xno" ; then
 
1210
        if test "x$enable_gcc_plugin" = "xyes" ; then
 
1211
            # Since this was explicitly asked for, error out.
 
1212
            AC_MSG_ERROR([This compiler lacks GCC plug-in support.])
 
1213
        else
 
1214
            AC_MSG_WARN([GCC plug-ins not supported; StarPU's GCC plug-in will not be built])
 
1215
        fi
 
1216
    else
 
1217
        # What GCC version are we using?
 
1218
        STARPU_GCC_VERSION
 
1219
 
 
1220
        # The `.so' itself cannot be called `starpu-gcc.so' (because
 
1221
        # `-fplugin-arg-' option names and such must match the `.so'
 
1222
        # name), so use a meaningful directory name.
 
1223
        gccplugindir="\${pkglibdir}/${STARPU_EFFECTIVE_VERSION}/gcc/${STARPU_GCC_VERSION_MAJOR}.${STARPU_GCC_VERSION_MINOR}"
 
1224
        AC_SUBST([gccplugindir])
 
1225
 
 
1226
        # Lines to be inserted in the `.pc' file.
 
1227
        GCC_PLUGIN_DIR_PKGCONFIG="gccplugindir=$gccplugindir"
 
1228
        GCC_PLUGIN_PKGCONFIG="gccplugin=\${gccplugindir}/starpu.so"
 
1229
        AC_SUBST([GCC_PLUGIN_DIR_PKGCONFIG])
 
1230
        AC_SUBST([GCC_PLUGIN_PKGCONFIG])
 
1231
    fi
 
1232
fi
 
1233
 
 
1234
 
 
1235
if test "x$ac_cv_have_gcc_plugins" = "xyes" ; then
 
1236
    build_gcc_plugin="yes"
 
1237
 
 
1238
    # GNU Guile 1.8/2.0 is used to run the test suite.
 
1239
    AC_PATH_PROG([GUILE], [guile])
 
1240
    if test "x$GUILE" != "x"; then
 
1241
        if test "x$enable_cpu" = "xyes"; then
 
1242
           run_gcc_plugin_test_suite="yes"
 
1243
        else
 
1244
           AC_MSG_WARN([CPU back-end disabled; GCC plug-in test suite will not be run])
 
1245
           run_gcc_plugin_test_suite="no"
 
1246
        fi
 
1247
    else
 
1248
        run_gcc_plugin_test_suite="no"
 
1249
    fi
 
1250
else
 
1251
    build_gcc_plugin="no"
 
1252
    run_gcc_plugin_test_suite="no"
 
1253
fi
 
1254
 
 
1255
# Bison is used to generate the C expression parser.  The generated
 
1256
# parser is part of the distribution, though.
 
1257
AM_MISSING_PROG([YACC], [bison])
 
1258
 
 
1259
AM_CONDITIONAL([BUILD_GCC_PLUGIN], [test "x$build_gcc_plugin" = "xyes"])
 
1260
AM_CONDITIONAL([RUN_GCC_PLUGIN_TESTS],
 
1261
  [test "x$run_gcc_plugin_test_suite" = "xyes"])
 
1262
 
 
1263
###############################################################################
 
1264
#                                                                             #
 
1265
#                               SOCL interface                                #
 
1266
#                                                                             #
 
1267
###############################################################################
 
1268
 
 
1269
AC_ARG_ENABLE([socl],
 
1270
  [AS_HELP_STRING([--enable-socl],
 
1271
    [build the OpenCL interface (experimental)])],
 
1272
  [enable_socl="$enableval"],
 
1273
  [enable_socl="maybe"])
 
1274
 
 
1275
AC_MSG_CHECKING(for SOCL)
 
1276
 
 
1277
if test "x$enable_socl" = "xyes" -o "x$enable_socl" = "xmaybe" ; then
 
1278
    if test "$have_valid_opencl" = "no" ; then
 
1279
        STARPU_LOOK_FOR_OPENCL()
 
1280
    fi
 
1281
fi
 
1282
 
 
1283
# in case SOCL was explicitely required, but is not available, this is an error
 
1284
if test "x$enable_socl" = "xyes" -a "$have_valid_opencl" = "no" ; then
 
1285
    AC_MSG_ERROR([SOCL cannot be enabled without OpenCL])
 
1286
fi
 
1287
 
 
1288
# now we enable SOCL if and only if a proper setup is available
 
1289
if test "x$enable_socl" = "xyes" -o "x$enable_socl" = "xmaybe" ; then
 
1290
   build_socl=$have_valid_opencl
 
1291
else
 
1292
   build_socl=no
 
1293
fi
 
1294
 
 
1295
AC_MSG_RESULT($build_socl)
 
1296
AM_CONDITIONAL([BUILD_SOCL], [test "x$build_socl" = "xyes"])
 
1297
AM_CONDITIONAL([STARPU_USE_SOCL], [test "x$build_socl" = "xyes"])
 
1298
 
 
1299
###############################################################################
 
1300
#                                                                             #
 
1301
#                                 Debugging                                   #
 
1302
#                                                                             #
 
1303
###############################################################################
 
1304
 
 
1305
AC_PATH_PROG([GDB], [gdb], [not-found])
 
1306
if test "x$GDB" != "xnot-found"; then
 
1307
   AC_DEFINE_UNQUOTED([STARPU_GDB_PATH], ["$GDB"],
 
1308
     [Path to the GNU debugger.])
 
1309
fi
 
1310
 
 
1311
###############################################################################
 
1312
#                                                                             #
 
1313
#                                  Examples                                   #
 
1314
#                                                                             #
 
1315
###############################################################################
 
1316
 
 
1317
AC_ARG_ENABLE(opengl-render, [AS_HELP_STRING([--enable-opengl-render],
 
1318
                        [enable OpenGL rendering of some examples])],
 
1319
                        enable_opengl_render=$enableval, enable_opengl_render=no)
 
1320
 
 
1321
if test x$enable_opengl_render = xyes; then
 
1322
        STARPU_CHECK_LIB(OPENGL_RENDER, glut, glutInit,,AC_MSG_ERROR([cannot find glut]))
 
1323
        STARPU_CHECK_LIB(OPENGL_RENDER, GL, glXCreateContext,,AC_MSG_ERROR([cannot find GL]))
 
1324
        STARPU_CHECK_LIB(OPENGL_RENDER, GLU, gluLookAt,,AC_MSG_ERROR([cannot find GLU]))
 
1325
 
 
1326
        AC_DEFINE(STARPU_OPENGL_RENDER, [1], [enable OpenGL rendering of some examples])
 
1327
fi
 
1328
 
 
1329
AC_MSG_CHECKING(whether OpenGL rendering is enabled)
 
1330
AC_SUBST(STARPU_OPENGL_RENDER, $enable_opengl_render)
 
1331
AC_MSG_RESULT($enable_opengl_render)
 
1332
 
 
1333
AC_PATH_XTRA
 
1334
if test "x$no_x" != "xyes"; then
 
1335
        AC_DEFINE(STARPU_HAVE_X11, [1], [enable X11])
 
1336
fi
 
1337
AM_CONDITIONAL([HAVE_X11], [test "x$no_x" != "xyes"])
 
1338
 
 
1339
# In case there are BLAS kernels that are used by the example applications
 
1340
# we may specify which library to use. Note that this is not used for StarPU
 
1341
# itself.
 
1342
 
 
1343
blas_lib=maybe
 
1344
AC_ARG_ENABLE(blas-lib,
 
1345
 [  --enable-blas-lib[=blaslibname]:
 
1346
                      none [default]: no BLAS lib is used
 
1347
                      atlas: use ATLAS library
 
1348
                      goto: use GotoBLAS library],
 
1349
 [
 
1350
     if   test "x$enableval" = "xatlas" ; then
 
1351
        blas_lib=atlas
 
1352
     elif test "x$enableval" = "xgoto" ; then
 
1353
        blas_lib=goto
 
1354
     elif test "x$enableval" = "xnone" ; then
 
1355
        blas_lib=none
 
1356
     elif test x$enableval = xno; then
 
1357
        blas_lib=none
 
1358
     else
 
1359
        echo
 
1360
        echo "Error!"
 
1361
        echo "Unknown BLAS library"
 
1362
        exit -1
 
1363
     fi
 
1364
 ])
 
1365
 
 
1366
if test x$blas_lib = xmaybe -o x$blas_lib = xgoto; then
 
1367
AC_ARG_WITH(goto-dir, [AS_HELP_STRING([--with-goto-dir=<dir>], [specify GotoBLAS lib location])],
 
1368
        [
 
1369
                blas_lib=goto
 
1370
                gotodir=$withval
 
1371
                AC_SUBST(GOTODIR, $gotodir)
 
1372
 
 
1373
                CPPFLAGS="${CPPFLAGS} -I$gotodir/ "
 
1374
                LDFLAGS="${LDFLAGS} -L$gotodir/ "
 
1375
        ]
 
1376
        )
 
1377
 
 
1378
if test x$blas_lib = xgoto; then
 
1379
STARPU_CHECK_LIB(BLAS, gfortran, main,,)
 
1380
# Perhaps that GotoBLAS2 is available instead (so that we have libgotoblas2.{so,a})
 
1381
STARPU_CHECK_LIB(BLAS, goto2, sgemm_,, [havegoto2=no], [$STARPU_BLAS_LDFLAGS])
 
1382
if test x$havegoto2 = xno; then
 
1383
STARPU_CHECK_LIB(BLAS, goto, sgemm_,,AC_MSG_ERROR([cannot find goto lib]), [$STARPU_BLAS_LDFLAGS])
 
1384
fi
 
1385
AC_DEFINE(STARPU_GOTO, [1], [use STARPU_GOTO library])
 
1386
fi
 
1387
 
 
1388
fi
 
1389
 
 
1390
if test x$blas_lib = xmaybe -o x$blas_lib = xatlas; then
 
1391
AC_ARG_WITH(atlas-dir, [AS_HELP_STRING([--with-atlas-dir=<dir>], [specify ATLAS lib location])],
 
1392
        [
 
1393
                AC_MSG_CHECKING(STARPU_ATLAS location)
 
1394
                blas_lib=atlas
 
1395
                atlasdir=$withval
 
1396
                AC_MSG_RESULT($atlasdir)
 
1397
                AC_SUBST(ATLASDIR, $atlasdir)
 
1398
 
 
1399
                CPPFLAGS="${CPPFLAGS} -I$atlasdir/include/ "
 
1400
                LDFLAGS="${LDFLAGS} -L$atlasdir/lib/ "
 
1401
        ]
 
1402
        )
 
1403
 
 
1404
if test x$blas_lib = xatlas; then
 
1405
# test whether STARPU_ATLAS is actually available
 
1406
AC_CHECK_HEADER([cblas.h],,AC_MSG_ERROR([cannot find atlas headers]))
 
1407
STARPU_CHECK_LIB(BLAS, atlas, ATL_sgemm,,AC_MSG_ERROR([cannot find atlas lib]),)
 
1408
STARPU_CHECK_LIB(BLAS, cblas, cblas_sgemm,,AC_MSG_ERROR([cannot find atlas lib]),[-latlas])
 
1409
AC_DEFINE(STARPU_ATLAS, [1], [use STARPU_ATLAS library])
 
1410
fi
 
1411
 
 
1412
fi
 
1413
 
 
1414
if test x$blas_lib = xmaybe; then
 
1415
        # Should we use MKL ?
 
1416
        AC_ARG_WITH(mkl-cflags, [AS_HELP_STRING([--with-mkl-cflags], [specify MKL compilation flags])],
 
1417
                [
 
1418
                        CPPFLAGS="${CPPFLAGS} $withval"
 
1419
                        blas_lib=mkl
 
1420
                ])
 
1421
 
 
1422
        AC_ARG_WITH(mkl-ldflags, [AS_HELP_STRING([--with-mkl-ldflags], [specify MKL linking flags])],
 
1423
                [
 
1424
                        LDFLAGS="${LDFLAGS} $withval"
 
1425
                        blas_lib=mkl
 
1426
                ])
 
1427
        if test x$blas_lib = xmkl; then
 
1428
                AC_DEFINE(STARPU_MKL, [1], [use MKL library])
 
1429
        fi
 
1430
fi
 
1431
 
 
1432
if test x$blas_lib = xmaybe; then
 
1433
     #perhaps it is possible to use some BLAS lib from the system
 
1434
     use_system_blas=no
 
1435
     STARPU_SEARCH_LIBS(BLAS,[sgemm_],[blas],use_system_blas=yes,,)
 
1436
     if test x$use_system_blas = xyes; then
 
1437
        AC_DEFINE(STARPU_SYSTEM_BLAS, [1], [use refblas library])
 
1438
        blas_lib=system
 
1439
     else
 
1440
        blas_lib=none
 
1441
     fi
 
1442
fi
 
1443
 
 
1444
AM_CONDITIONAL(ATLAS_BLAS_LIB, test x$blas_lib = xatlas)
 
1445
AM_CONDITIONAL(GOTO_BLAS_LIB, test x$blas_lib = xgoto)
 
1446
AM_CONDITIONAL(MKL_BLAS_LIB, test x$blas_lib = xmkl)
 
1447
AM_CONDITIONAL(SYSTEM_BLAS_LIB, test x$blas_lib = xsystem)
 
1448
AM_CONDITIONAL(NO_BLAS_LIB, test x$blas_lib = xnone)
 
1449
 
 
1450
AC_MSG_CHECKING(which BLAS lib should be used)
 
1451
AC_MSG_RESULT($blas_lib)
 
1452
AC_SUBST(BLAS_LIB,$blas_lib)
 
1453
 
 
1454
##########################################
 
1455
# FFT                                    #
 
1456
##########################################
 
1457
 
 
1458
have_fftw=no
 
1459
have_fftwf=no
 
1460
have_fftwl=no
 
1461
fft_support=no
 
1462
 
 
1463
AC_ARG_ENABLE(starpufft, [AS_HELP_STRING([--disable-starpufft],
 
1464
                        [Disable build of StarPU-FFT])],
 
1465
                        enable_starpufft=$enableval,enable_starpufft=yes)
 
1466
 
 
1467
PKG_CHECK_MODULES([FFTW],  [fftw3],  [
 
1468
  AC_DEFINE([STARPU_HAVE_FFTW], [1], [Define to 1 if you have the libfftw3 library.])
 
1469
  AC_SUBST([STARPU_HAVE_FFTW], [1])
 
1470
  have_fftw=yes
 
1471
], [:])
 
1472
AM_CONDITIONAL(STARPU_HAVE_FFTW, [test x$have_fftw = xyes])
 
1473
 
 
1474
PKG_CHECK_MODULES([FFTWF], [fftw3f], [
 
1475
  AC_DEFINE([STARPU_HAVE_FFTWF], [1], [Define to 1 if you have the libfftw3f library.])
 
1476
  AC_SUBST([STARPU_HAVE_FFTWF], [1])
 
1477
  have_fftwf=yes
 
1478
], [:])
 
1479
AM_CONDITIONAL(STARPU_HAVE_FFTWF, [test x$have_fftwf = xyes])
 
1480
 
 
1481
PKG_CHECK_MODULES([FFTWL], [fftw3l], [
 
1482
  AC_DEFINE([STARPU_HAVE_FFTWL], [1], [Define to 1 if you have the libfftw3l library.])
 
1483
  AC_SUBST([HAVE_FFTWFL], [1])
 
1484
  have_fftwl=yes
 
1485
], [:])
 
1486
AM_CONDITIONAL(STARPU_HAVE_FFTWL, [test x$have_fftwl = xyes])
 
1487
 
 
1488
if test x$enable_starpufft = xyes -a \( \( x$enable_cpu = xyes -a x$have_fftw = xyes -a x$have_fftwf = xyes \) -o x$have_cufftdoublecomplex = xyes \); then
 
1489
   fft_support=yes
 
1490
fi
 
1491
AM_CONDITIONAL(BUILD_STARPUFFT, [test x$fft_support = xyes])
 
1492
 
 
1493
##########################################
 
1494
# hwloc                                  #
 
1495
##########################################
 
1496
 
 
1497
AC_ARG_WITH([hwloc],
 
1498
        [AS_HELP_STRING([--without-hwloc],
 
1499
        [Disable hwloc (enabled by default)])],
 
1500
        [hwloc_dir="$withval"])
 
1501
SAVED_LDFLAGS="${LDFLAGS}"
 
1502
SAVED_CPPFLAGS="${CPPFLAGS}"
 
1503
AS_IF([test "x$with_hwloc" != "xno"], [
 
1504
        PKG_CHECK_MODULES([HWLOC],[hwloc], [
 
1505
                have_valid_hwloc=yes
 
1506
                have_pkgconfig_hwloc=yes], [
 
1507
                have_valid_hwloc=no
 
1508
                have_pkgconfig_hwloc=no])
 
1509
        AS_IF([test "$have_valid_hwloc" = "no"], [
 
1510
                if test "$hwloc_dir" != "" ; then CPPFLAGS="${SAVED_CPPFLAGS} -I$hwloc_dir/include" ; fi
 
1511
                AC_CHECK_HEADER([hwloc.h],[have_valid_hwloc=yes],[have_valid_hwloc=no])
 
1512
                if test "$hwloc_dir" != "" ; then LDFLAGS="${SAVED_LDFLAGS} -L$hwloc_dir/lib" ; fi
 
1513
                AC_HAVE_LIBRARY([hwloc],[have_valid_hwloc=yes],[have_valid_hwloc=no])
 
1514
                ])
 
1515
    ],
 
1516
    have_valid_hwloc="no")
 
1517
AS_IF([test "$have_valid_hwloc" = "yes"], [
 
1518
        AC_DEFINE([STARPU_HAVE_HWLOC], [1], [Define to 1 if you have the hwloc library.])
 
1519
        HWLOC_REQUIRES=hwloc
 
1520
        AC_SUBST([STARPU_HAVE_HWLOC], [1])
 
1521
        AS_IF([test "$have_pkgconfig_hwloc" = "no"], [
 
1522
                HWLOC_CFLAGS="-I$hwloc_dir/include"
 
1523
                HWLOC_LIBS="-L$hwloc_dir/lib -lhwloc"])
 
1524
        ])
 
1525
LDFLAGS="${SAVED_LDFLAGS}"
 
1526
CPPFLAGS="${SAVED_CPPFLAGS}"
 
1527
 
 
1528
if test "$have_valid_hwloc" = "no" -a "$hwloc_dir" != "no" ; then
 
1529
   AC_MSG_ERROR([hwloc was not found on your system. If the target machine is hyperthreaded the performance may be impacted a lot.  It is strongly recommended to install hwloc. However, if you really want to use StarPU without enabling hwloc, please restart configure by specifying the option '--without-hwloc'.])
 
1530
fi
 
1531
AC_MSG_CHECKING(whether hwloc should be used)
 
1532
AC_MSG_RESULT($have_valid_hwloc)
 
1533
AC_SUBST(HWLOC_REQUIRES)
 
1534
 
 
1535
# is the header file f77.h available ?
 
1536
have_f77_h=yes
 
1537
AC_CHECK_HEADER([f77.h],,[have_f77_h=no])
 
1538
AC_MSG_CHECKING(whether header file f77.h is available)
 
1539
AC_MSG_RESULT($have_f77_h)
 
1540
AC_SUBST(STARPU_HAVE_F77_H, $have_f77_h)
 
1541
AM_CONDITIONAL(STARPU_HAVE_F77_H, test x$have_f77_h = xyes)
 
1542
if test x$have_f77_h = xyes; then
 
1543
        AC_DEFINE([STARPU_HAVE_F77_H], [1], [Define to 1 if you have the <f77.h> header file.])
 
1544
fi
 
1545
 
 
1546
# Check if icc is available
 
1547
AC_CHECK_PROGS([ICC], [icc])
 
1548
 
 
1549
# If cuda and icc are both available, check they are compatible
 
1550
if test "$enable_cuda" = "yes" -a "$ICC" != ""; then
 
1551
   AC_MSG_CHECKING(whether CUDA and ICC are compatible)
 
1552
   OLD_CC="$CC"
 
1553
   CC="$ICC"
 
1554
   OLD_CFLAGS="$CFLAGS"
 
1555
   CFLAGS="-I$PWD/include -I$srcdir/include"
 
1556
   AC_COMPILE_IFELSE(
 
1557
       AC_LANG_PROGRAM(
 
1558
           [[#include <cuda.h>
 
1559
           #include <starpu.h>]],
 
1560
           [[]]
 
1561
           ),
 
1562
       AC_MSG_RESULT(yes),
 
1563
       [ICC=""
 
1564
           AC_MSG_RESULT(no)]
 
1565
   )
 
1566
   CC="$OLD_CC"
 
1567
   CFLAGS="$OLD_CFLAGS"
 
1568
fi
 
1569
 
 
1570
# Disable ICC on windows
 
1571
if test "x$ICC" != "x" -a "$starpu_windows" = "yes" ; then
 
1572
    ICC=""
 
1573
fi
 
1574
if test "x$ICC" != "x"; then
 
1575
  AC_DEFINE(STARPU_HAVE_ICC, [], [Define this if icc is available])
 
1576
fi
 
1577
AM_CONDITIONAL([STARPU_HAVE_ICC], [test "x$ICC" != "x"])
 
1578
 
 
1579
# Do not generate manpages for the tools if we do not have help2man
 
1580
AC_CHECK_PROGS([HELP2MAN], [help2man])
 
1581
# Disable on windows
 
1582
if test "$starpu_windows" = "yes" ; then
 
1583
    HELP2MAN=""
 
1584
fi
 
1585
AM_CONDITIONAL([STARPU_HAVE_HELP2MAN], [test "x$HELP2MAN" != "x"])
 
1586
 
 
1587
AC_CHECK_MEMBER([struct cudaDeviceProp.pciDomainID],
 
1588
  AC_DEFINE([STARPU_HAVE_DOMAINID],[1],[Define to 1 if CUDA device properties include DomainID]),
 
1589
  , [[#include <cuda_runtime_api.h>]])
 
1590
 
 
1591
AC_CHECK_MEMBER([struct cudaDeviceProp.pciBusID],
 
1592
  AC_DEFINE([STARPU_HAVE_BUSID],[1],[Define to 1 if CUDA device properties include BusID]),
 
1593
  , [[#include <cuda_runtime_api.h>]])
 
1594
 
 
1595
# File configuration
 
1596
AC_CONFIG_COMMANDS([executable-scripts], [
 
1597
  chmod +x tests/regression/regression.sh
 
1598
  chmod +x gcc-plugin/tests/run-test
 
1599
  chmod +x tools/starpu_workers_activity
 
1600
])
 
1601
 
 
1602
AC_CONFIG_FILES(tests/regression/regression.sh tests/regression/profiles tests/regression/profiles.build.only)
 
1603
AC_CONFIG_HEADER(src/common/config.h include/starpu_config.h gcc-plugin/src/starpu-gcc-config.h starpu-top/config.h)
 
1604
 
 
1605
AC_OUTPUT([
 
1606
        Makefile
 
1607
        src/Makefile
 
1608
        tools/Makefile
 
1609
        tools/starpu_workers_activity
 
1610
        socl/Makefile
 
1611
        socl/src/Makefile
 
1612
        socl/examples/Makefile
 
1613
        socl/socl-1.0.pc
 
1614
        libstarpu.pc
 
1615
        starpu-1.0.pc
 
1616
        mpi/libstarpumpi.pc
 
1617
        mpi/starpumpi-1.0.pc
 
1618
        starpufft/Makefile
 
1619
        starpufft/libstarpufft.pc
 
1620
        starpufft/starpufft-1.0.pc
 
1621
        examples/Makefile
 
1622
        examples/stencil/Makefile
 
1623
        tests/Makefile
 
1624
        doc/Makefile
 
1625
        mpi/Makefile
 
1626
        starpu-top/StarPU-Top.pro
 
1627
        starpu-top/StarPU-Top-qwt-embed.pri
 
1628
        starpu-top/StarPU-Top-qwt-system.pri
 
1629
        gcc-plugin/Makefile
 
1630
        gcc-plugin/src/Makefile
 
1631
        gcc-plugin/tests/Makefile
 
1632
        gcc-plugin/tests/run-test
 
1633
        gcc-plugin/examples/Makefile
 
1634
])
 
1635
 
 
1636
AC_MSG_NOTICE([
 
1637
 
 
1638
        CPUs   enabled: $enable_cpu
 
1639
        CUDA   enabled: $enable_cuda
 
1640
        OpenCL enabled: $enable_opencl
 
1641
        Cell   enabled: $enable_gordon
 
1642
 
 
1643
        Compile-time limits
 
1644
        (change these with --enable-maxcpus, --enable-maxcudadev,
 
1645
        --enable-maxopencldev, --enable-maxbuffers)
 
1646
 
 
1647
        Maximum number of CPUs:           $maxcpus
 
1648
        Maximum number of CUDA devices:   $nmaxcudadev
 
1649
        Maximum number of OpenCL devices: $nmaxopencldev
 
1650
        Maximum number of memory nodes:   $maxnodes
 
1651
        Maximum number of task buffers:   $nmaxbuffers
 
1652
 
 
1653
        GPU-GPU transfers: $have_cuda_memcpy_peer
 
1654
        Allocation cache:  $enable_allocation_cache
 
1655
 
 
1656
        Magma enabled: $have_magma
 
1657
        BLAS library:  $blas_lib
 
1658
        hwloc:         $have_valid_hwloc
 
1659
        FxT trace enabled: $use_fxt
 
1660
        StarPU-Top:        $build_starpu_top
 
1661
 
 
1662
        StarPU Extensions:
 
1663
               MPI enabled:   $use_mpi
 
1664
               MPI test suite: $running_mpi_check
 
1665
               FFT Support: $fft_support
 
1666
               GCC plug-in: $build_gcc_plugin
 
1667
               GCC plug-in test suite (requires GNU Guile): $run_gcc_plugin_test_suite
 
1668
               SOCL enabled:  $build_socl
 
1669
])
 
1670
 
 
1671
if test x"$have_valid_hwloc" = xno
 
1672
then
 
1673
  AC_MSG_NOTICE([
 
1674
WARNING: hwloc was not enabled.  If the target machine is hyperthreaded the
 
1675
performance may be impacted a lot.  It is strongly recommended to install
 
1676
hwloc])
 
1677
fi