Security note for users of the third-party Codecov tool: https://about.codecov.io/security-update/

configure.ac 10.7 KB
Newer Older
1
AC_PREREQ([2.69])
2
AC_INIT([elpa],[2013.11.006], elpa-library@rzg.mpg.de)
3
AC_CONFIG_SRCDIR([src/elpa1.F90])
4 5 6 7

AM_INIT_AUTOMAKE([foreign -Wall subdir-objects])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
8
AM_SILENT_RULES([yes])
9

Andreas Marek's avatar
Andreas Marek committed
10 11 12 13 14 15 16 17 18
AX_CHECK_GNU_MAKE()
if test x$_cv_gnu_make_command = x ; then
        AC_MSG_ERROR([Need GNU Make])
fi

AC_CHECK_PROG(CPP_FOUND,cpp,yes,no)
if test "x${CPP_FOUND}" = xno; then
  AC_MSG_ERROR([no cpp found])
fi
19

20 21 22 23
# gnu-make fortran module dependencies
m4_include([fdep/fortran_dependencies.m4])
FDEP_F90_GNU_MAKE_DEPS

24 25 26 27 28 29
AC_PROG_INSTALL
AM_PROG_CC_C_O
AM_PROG_AR
AM_PROG_AS
AC_PROG_CXX

30 31 32 33

dnl necessary for later checking
ELPA_KERNEL_SET=no

34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
dnl  macro for an --with-$2 switch that sets the
dnl  preprocessor define $1, with description $3, default $4, possible values $5
AC_DEFUN([DEFINE_OPTION],[
  AC_MSG_CHECKING(whether the $2 kernel is specified)
  AC_ARG_WITH([$2],
		AS_HELP_STRING([--with-$2],
			       [$3, default $4.]),
	      [with_option=yes],
	      [with_option=$4])
  AC_MSG_RESULT([${with_option}])
  AM_CONDITIONAL([$1],[test x"$with_option" = x"yes"])
  if test "x${with_option}" = xyes; then
	AC_DEFINE([$1], [1], [$3])
#  elif test "x${with_option}" = xno; then
#	AC_DEFINE([$1], [0], [$3])
49
        ELPA_KERNEL_SET=yes
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
  fi
])

DEFINE_OPTION([WITH_GENERIC], [generic],
	      [use generic kernel for all architectures (with some hand-coded optimizations)],
	      [no],[])

DEFINE_OPTION([WITH_GENERIC_SIMPLE], [generic-simple],
	      [use generic simple kernel for all architectures (without any hand-coded optimizations)],
	      [no],[])

DEFINE_OPTION([WITH_BGP], [bgp],
	      [use optimized kernel for IBM BG/P],
	      [no],[])

DEFINE_OPTION([WITH_BGQ], [bgq],
	      [use optimized kernel for IBM BG/Q],
	      [no],[])

DEFINE_OPTION([WITH_SSE_AS], [sse-assembler],
	      [use kernel tuned for SSE (written in gcc assembler)],
	      [no],[])

DEFINE_OPTION([WITH_AVX_SANDYBRIDGE], [avx-sandybridge],
	      [use kernel tuned for AVX on Intel Sandybridge (written in gcc assembler)],
	      [no],[])

DEFINE_OPTION([WITH_AMD_BULLDOZER], [amd-bulldozer],
	      [use kernel tuned for AVX on AMD Bulldozer (written in gcc assembler)],
	      [no],[])

DEFINE_OPTION([WITH_AVX_COMPLEX_BLOCK1], [avx-complex-block1],
	      [use AVX optimized complex kernel with blocking 1 (written in gcc assembler)],
	      [no],[])

DEFINE_OPTION([WITH_AVX_COMPLEX_BLOCK2], [avx-complex-block2],
	      [use AVX optimized complex kernel with blocking 2 (written in gcc assembler)],
	      [no],[])

DEFINE_OPTION([WITH_AVX_REAL_BLOCK2], [avx-real-block2],
	      [use AVX optimized real kernel with blocking 2 (written in gcc assembler)],
	      [no],[])

DEFINE_OPTION([WITH_AVX_REAL_BLOCK4], [avx-real-block4],
	      [use AVX optimized real kernel with blocking 4 (written in gcc assembler)],
	      [no],[])

DEFINE_OPTION([WITH_AVX_REAL_BLOCK6], [avx-real-block6],
	      [use AVX optimized real kernel with blocking 6 (written in gcc assembler)],
	      [no],[])


102 103 104 105 106 107 108
dnl check whether any kernel was specified
AC_MSG_CHECKING(whether the user defined an ELPA kernel)
AC_MSG_RESULT([${with_option}])
if test "x${ELPA_KERNEL_SET}" = xno; then
   AC_MSG_ERROR(no ELPA kernel choosen by user! Please look at the manual! Aborting...)
fi

Andreas Marek's avatar
Andreas Marek committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
dnl check whether we better check if AVX compilation should work
if test "x${with_avx_sandybridge}" = xyes; then
  check_avx_compilation=yes
fi
if test "x${with_amd_bulldozer}" = xyes; then
  check_avx_compilation=yes
fi
if test "x${with_avx_complex_block1}" = xyes; then
  check_avx_compilation=yes
fi
if test "x${with_avx_complex_block2}" = xyes; then
  check_avx_compilation=yes
fi
if test "x${with_avx_real_block2}" = xyes; then
  check_avx_compilation=yes
fi
if test "x${with_avx_real_block4}" = xyes; then
  check_avx_compilation=yes
fi
if test "x${with_avx_real_block6}" = xyes; then
  check_avx_compilation=yes
fi

dnl if necessary do the check for avx compilation
if test "x${check_avx_compilation}" = xyes; then
 dnl check whether one can compile with avx - gcc intrinsics

 AC_MSG_CHECKING([whether we can compile a gcc intrinsic AVX program])

 dnl first pass: try with specified CFLAGS and CXXFLAGS
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([     
  #include <x86intrin.h> 
  void main(){
  double* q;
  __m256d a1_1 = _mm256_load_pd(q);
  }
  ])],
  [can_compile_avx_prog=yes],
  [can_compile_avx_prog=no]
 )
 dnl first test failed: try again after updating  CFLAGS and CXXFLAGS with -mavx
 if test "x${can_compile_avx_prog}" = xno; then
 CFLAGS="$CFLAGS -mavx"
 CXXFLAGS="$CXXFLAGS -mavx"
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([     
  #include <x86intrin.h> 
  void main(){
  double* q;
  __m256d a1_1 = _mm256_load_pd(q);
  }
  ])],
  [can_compile_avx_prog=yes],
  [can_compile_avx_prog=no]
 )
 fi

 AC_MSG_RESULT([${can_compile_avx_prog}])

 if test "x${can_compile_avx_prog}" = xno; then
   AC_MSG_ERROR([could not compile with gcc AVX intrinsic! Maybe choose another kernel])
 fi
fi


dnl set the AVX optimization flags if this option is specified
AC_MSG_CHECKING(whether AVX optimization flags should be set automatically)
AC_ARG_WITH([avx-optimization],
		AS_HELP_STRING([--with-avx-optimization],
			       [use AVX optimization, default no.]),
	      [with_avx_optimization=yes],
	      [with_avx_optimization=no])
  AC_MSG_RESULT([${with_avx_optimization}])
  if test "x${with_avx_optimization}" = xyes; then
    CFLAGS="$CFLAGS -funsafe-loop-optimizations -funsafe-math-optimizations -ftree-vect-loop-version -ftree-vectorize"
    CXXFLAGS="$CXXFLAGS -funsafe-loop-optimizations -funsafe-math-optimizations -ftree-vect-loop-version -ftree-vectorize"

  fi



AC_LANG(Fortran)
m4_include([m4/ax_prog_fc_mpi.m4])
dnl check whether an mpi compiler is available;
dnl if not abort since it is mandatory
AX_PROG_FC_MPI([],[have_mpi=yes],[have_mpi=no
		 if test "x${have_mpi}" = xno; then
  		  AC_MSG_ERROR([no mpi found])
		  fi])


199
AC_SUBST([ELPA_LIB_VERSION], [2013.11.006])
Andreas Marek's avatar
Andreas Marek committed
200 201 202 203 204 205 206 207 208 209 210
# this is the version of the API, should be changed in the major revision
# if and only if the actual API changes
AC_SUBST([ELPA_SO_VERSION], [0:0:0])

AC_FC_FREEFORM
AC_FC_MODULE_FLAG
AC_FC_MODULE_OUTPUT_FLAG




211 212 213 214 215 216 217
AC_MSG_CHECKING(whether OpenMP usage is specified)
AC_ARG_WITH([openmp],
		AS_HELP_STRING([--with-openmp],
			       [use OpenMP threading, default no.]),
	      [with_openmp=yes],
	      [with_openmp=no])
  AC_MSG_RESULT([${with_openmp}])
Andreas Marek's avatar
Andreas Marek committed
218 219 220 221 222
  if test "x${enable_openmp}" = xyes; then
     with_openmp=yes
     AC_MSG_CHECKING(whether --enable-openmp is specified)
     AC_MSG_RESULT([${enable_openmp}])
  fi
223 224 225
  AM_CONDITIONAL([WITH_OPENMP],[test x"$with_openmp" = x"yes"])
  if test "x${with_openmp}" = xyes; then
	AC_DEFINE([WITH_OPENMP], [1], [use OpenMP threading])
226
        AX_ELPA_OPENMP
227 228 229 230 231
  fi

FCFLAGS="$FCFLAGS $OPENMP_FCFLAGS $OPENMP_FFFLAGS"
#LDFLAGS="$LDFLAGS $OPENMP_FCFLAGS $OPENMP_FFFLAGS"

232 233 234 235 236 237 238 239 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 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360

save_FCFLAGS=$FCFLAGS
save_LDFLAGS=$LDFLAGS

FCFLAGS="$FCFLAGS $BLACS_FCFLAGS"
LDFLAGS="$LDFLAGS $BLACS_LDFLAGS"
dnl check whether one can link with specified MKL (desired method)
AC_MSG_CHECKING([whether we can compile a Fortran program using MKL])


AC_COMPILE_IFELSE([AC_LANG_SOURCE([     
  program test_mkl
    use mkl_service	
    character*198 :: string
    call mkl_get_version_string(string)
    write(*,'(a)') string
  end program
])],
  [can_compile_with_mkl=yes],
  [can_compile_with_mkl=no]
)
AC_MSG_RESULT([${can_compile_with_mkl}])

if test x"$can_compile_with_mkl" = x"yes" ; then
  AC_MSG_CHECKING([whether we can link a Fortran program with MKL])
  AC_LINK_IFELSE([AC_LANG_SOURCE([     
    program test_mkl
      use mkl_service	
      character*198 :: string
      call mkl_get_version_string(string)
      write(*,'(a)') string
    end program
  ])],
    [can_link_with_mkl=yes],
    [can_link_with_mkl=no]
  )
  AC_MSG_RESULT([${can_link_with_mkl}])
fi

dnl if not mkl, check all the necessary individually
if test "x${can_link_with_mkl}" = "xyes" ; then
  WITH_MKL=1
else

  dnl first check blas
  AC_SEARCH_LIBS([dgemm],[blas],[can_link_with_blas=yes],[can_link_with_blas=no])
  AC_MSG_CHECKING([whether we can link a program with a blas lib])
  AC_MSG_RESULT([${can_link_with_blas}])

  if test "x${can_link_with_blas}" = "xno" ; then
    AC_MSG_ERROR([could not link with blas: specify path]) 
  fi	
  dnl now lapack
  AC_SEARCH_LIBS([dlarrv],[lapack],[can_link_with_lapack=yes],[can_link_with_lapack=no])
  AC_MSG_CHECKING([whether we can link a program with a lapack lib])
  AC_MSG_RESULT([${can_link_with_lapack}])

  if test "x${can_link_with_lapack}" = "xno" ; then
    AC_MSG_ERROR([could not link with lapack: specify path]) 
  fi
	
  dnl now blacs
  AC_SEARCH_LIBS([blacs_gridinit],[mpiblacs],[can_link_with_blacs=yes],[can_link_with_blacs=no])
  AC_MSG_CHECKING([whether we can link a program with a blacs lib])
  AC_MSG_RESULT([${can_link_with_blacs}])

  if test "x${can_link_with_blacs}" = "xno" ; then
    AC_MSG_ERROR([could not link with blacs: specify path]) 
  fi
	
  dnl now scalapack
  AC_SEARCH_LIBS([pdtran],[mpiscalapack],[can_link_with_scalapack=yes],[can_link_with_scalapack=no])
  AC_MSG_CHECKING([whether we can link a program with a scalapack lib])
  AC_MSG_RESULT([${can_link_with_scalapack}])

  if test "x${can_link_with_scalapack}" = "xno" ; then
    AC_MSG_ERROR([could not link with scalapack: specify path]) 
  fi

  dnl check whether we can link alltogehter

  AC_MSG_CHECKING([whether we can link a Fortran program with all blacs/scalapack])
  AC_LINK_IFELSE([AC_LANG_SOURCE([     
    program dgemm_test

      integer , parameter:: n_cols=3,l_cols=3
      real :: hvm(n_cols,l_cols)

      call dgemm('T','N',n_cols,n_cols,l_cols,1.,hvm,ubound(hvm,1), &
      hvm(1,n_cols+1),ubound(hvm,1),0.,hvm,ubound(hvm,1))


     end program dgemm_test
     ])],
     [can_link_with_blacs_scalapack=yes],
     [can_link_with_blacs_scalapack=no]
   )
   AC_MSG_RESULT([${can_link_with_blacs_scalapack}])

   if test "x${can_link_with_blacs_scalapack}" = "xyes" ; then
     WITH_BLACS=1
   else
   AC_MSG_ERROR([We can neither link with MKL or another Scalpack. Please specify BLACS_LDFLAGS and BLACS_FCFLAGS!])
   fi
fi

dnl important: reset them again!
FCFLAGS=$save_FCFLAGS
LDFLAGS=$save_LDFLAGS



LT_INIT

AC_SUBST([AM_FCFLAGS])
AC_SUBST([AM_LDFLAGS])
AC_SUBST([WITH_MKL])
AC_SUBST([WITH_BLACS])
AC_SUBST([with_amd_bulldozer_kernel])
AC_SUBST([CFLAGS])
AC_SUBST([FCFLAGS])
AC_SUBST([CPPFLAGS])
AC_SUBST([LDFLAGS])
AC_SUBST([RANLIB])
AC_SUBST([FC_MODINC])
AC_SUBST([FC_MODOUT])
AC_SUBST(BLACS_LDFLAGS)
AC_SUBST(BLACS_FCFLAGS)

361 362
#AC_SUBST(OPT_FCFLAGS)

363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
mkdir modules

#gl_VISIBILITY
#AH_BOTTOM([#if HAVE_VISIBILITY
#define EXPORTED __attribute__((__visibility__("default")))
#define HIDDEN   __attribute__((__visibility__("hidden")))
#else
#define EXPORTED
#define HIDDEN
#endif])

AC_CONFIG_FILES([
  Makefile
  elpa.pc:elpa.pc.in
])
AC_OUTPUT
grep "^#define" config.h > config-f90.h