ax_elpa_specific_kernels.m4 10.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

dnl macro for testing whether the user wanted to compile only with one
dnl specific real kernel

dnl usage: DEFINE_OPTION([real-generic-kernel-only],[generic-kernel],[with_real_generic_kernel],[install_real_generic])

AC_DEFUN([DEFINE_OPTION_SPECIFIC_REAL_KERNEL],[
  AC_ARG_WITH([$1],
               AS_HELP_STRING([--with-$1],
                              [only compile $2 for real case]),
              [with_option=yes],[with_option=no])

   if test x"${with_option}" = x"yes" ; then
    if test x"${use_specific_real_kernel}" = x"no" ; then

    dnl make sure that all the other kernels are unset
    install_real_generic=no
    install_real_generic_simple=no
19
    install_real_sse_assembly=no
20 21
    install_real_bgp=no
    install_real_bgq=no
22 23 24
    install_real_sse_block2=no
    install_real_sse_block4=no
    install_real_sse_block6=no
25 26 27
    install_real_avx_block2=no
    install_real_avx_block4=no
    install_real_avx_block6=no
28 29 30 31 32 33 34
    install_real_avx2_block2=no
    install_real_avx2_block4=no
    install_real_avx2_block6=no
    install_real_avx512_block2=no
    install_real_avx512_block4=no
    install_real_avx512_block6=no

35
    want_sse=no
Andreas Marek's avatar
Andreas Marek committed
36
    want_avx=no
37
    want_avx2=no
38
    want_avx512=no
39 40 41 42 43
    install_gpu=no

    use_specific_real_kernel=yes
    dnl now set the specific kernel
    $3=yes
44 45
    dnl take care of some dependencies
    if test x"${install_real_sse_block4}" = x"yes" ; then
Andreas Marek's avatar
Andreas Marek committed
46
      AC_MSG_NOTICE([$1 set. Also sse_block2 is needed])
47 48 49
      install_real_sse_block2=yes
    fi
    if test x"${install_real_avx_block4}" = x"yes" ; then
Andreas Marek's avatar
Andreas Marek committed
50
      AC_MSG_NOTICE([$1 set. Also avx_block2 is needed])
51 52
      install_real_avx_block2=yes
    fi
53 54 55 56 57 58 59 60 61
    if test x"${install_real_avx2_block4}" = x"yes" ; then
      AC_MSG_NOTICE([$1 set. Also avx2_block2 is needed])
      install_real_avx2_block2=yes
    fi
    if test x"${install_real_avx512_block4}" = x"yes" ; then
      AC_MSG_NOTICE([$1 set. Also avx512_block2 is needed])
      install_real_avx512_block2=yes
    fi

62
    if test x"${install_real_sse_block6}" = x"yes" ; then
Andreas Marek's avatar
Andreas Marek committed
63 64
      AC_MSG_NOTICE([$1 set. Also sse_block2 is needed])
      AC_MSG_NOTICE([$1 set. Also sse_block4 is needed])
65 66 67 68
      install_real_sse_block4=yes
      install_real_sse_block2=yes
    fi
    if test x"${install_real_avx_block6}" = x"yes" ; then
Andreas Marek's avatar
Andreas Marek committed
69 70
      AC_MSG_NOTICE([$1 set. Also avx_block2 is needed])
      AC_MSG_NOTICE([$1 set. Also avx_block4 is needed])
71 72 73
      install_real_avx_block4=yes
      install_real_avx_block2=yes
    fi
74 75 76 77 78 79 80 81 82 83 84 85 86
    if test x"${install_real_avx2_block6}" = x"yes" ; then
      AC_MSG_NOTICE([$1 set. Also avx2_block2 is needed])
      AC_MSG_NOTICE([$1 set. Also avx2_block4 is needed])
      install_real_avx2_block4=yes
      install_real_avx2_block2=yes
    fi
    if test x"${install_real_avx512_block6}" = x"yes" ; then
      AC_MSG_NOTICE([$1 set. Also avx512_block2 is needed])
      AC_MSG_NOTICE([$1 set. Also avx512_block4 is needed])
      install_real_avx512_block4=yes
      install_real_avx512_block2=yes
    fi

87 88

    dnl in case of SSE or AVX make sure that we can compile the choosen kernel
89 90
    if test x"${install_real_sse_assembly}" = x"yes" ; then
     if test x"${can_compile_sse_assembly}" = x"no" ; then
91 92 93 94
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     fi
    fi

95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
    if test x"${install_real_sse_block2}" = x"yes" ; then
     if test x"${can_compile_sse_intrinsics}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_sse=yes
     fi
    fi

    if test x"${install_real_sse_block4}" = x"yes" ; then
     if test x"${can_compile_sse_intrinsics}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_sse=yes
     fi
    fi

    if test x"${install_real_sse_block6}" = x"yes" ; then
     if test x"${can_compile_sse_inrinsics}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_sse=yes
     fi
    fi

119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
    if test x"${install_real_sse_block2}" = x"yes" ; then
     if test x"${can_compile_sse_intrinsics}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_sse=yes
     fi
    fi

    if test x"${install_real_sse_block4}" = x"yes" ; then
     if test x"${can_compile_sse_intrinsics}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_sse=yes
     fi
    fi

    if test x"${install_real_sse_block6}" = x"yes" ; then
     if test x"${can_compile_sse_inrinsics}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_sse=yes
     fi
    fi

143 144 145
    if test x"${install_real_avx_block2}" = x"yes" ; then
     if test x"${can_compile_avx}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
Andreas Marek's avatar
Andreas Marek committed
146 147
     else
       want_avx=yes
148 149 150
     fi
    fi

151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
    if test x"${install_real_avx2_block2}" = x"yes" ; then
     if test x"${can_compile_avx2}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_avx2=yes
     fi
    fi

    if test x"${install_real_avx512_block2}" = x"yes" ; then
     if test x"${can_compile_avx512}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_avx512=yes
     fi
    fi

167 168 169
    if test x"${install_real_avx_block4}" = x"yes" ; then
     if test x"${can_compile_avx}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
Andreas Marek's avatar
Andreas Marek committed
170 171
     else
       want_avx=yes
172 173 174
     fi
    fi

175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
    if test x"${install_real_avx2_block4}" = x"yes" ; then
     if test x"${can_compile_avx2}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_avx2=yes
     fi
    fi

    if test x"${install_real_avx512_block4}" = x"yes" ; then
     if test x"${can_compile_avx512}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_avx512=yes
     fi
    fi

191 192 193
    if test x"${install_real_avx_block6}" = x"yes" ; then
     if test x"${can_compile_avx}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
Andreas Marek's avatar
Andreas Marek committed
194 195
     else
       want_avx=yes
196 197 198
     fi
    fi

199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
    if test x"${install_real_avx2_block6}" = x"yes" ; then
     if test x"${can_compile_avx2}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_avx2=yes
     fi
    fi

    if test x"${install_real_avx512_block6}" = x"yes" ; then
     if test x"${can_compile_avx512}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_avx512=yes
     fi
    fi

215
    AC_MSG_NOTICE([$1 will be the only compiled kernel for real case])
216 217 218 219
#    if test x"${want_gpu}" = x"yes" ; then
#      AC_MSG_WARN([At the moment this disables GPU support!])
#      AC_MSG_WARN([IF GPU support is wanted do NOT specify a specific real kernel])
#    fi
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
   else
    AC_MSG_FAILURE([$1 failed; A specific kernel for real case has already been defined before!])
   fi
  fi
])


AC_DEFUN([DEFINE_OPTION_SPECIFIC_COMPLEX_KERNEL],[
  AC_ARG_WITH([$1],
                 AS_HELP_STRING([--with-$1],
                                [only compile $2 for complex case]),
              [with_option=yes],[with_option=no])

   if test x"${with_option}" = x"yes" ; then
    if test x"${use_specific_complex_kernel}" = x"no" ; then

    dnl make sure that all the other kernels are unset
    install_complex_generic=no
    install_complex_generic_simple=no
239
    install_complex_sse_assembly=no
240 241
    install_complex_bgp=no
    install_complex_bgq=no
242 243
    install_complex_sse_block1=no
    install_complex_sse_block2=no
244 245
    install_complex_avx_block1=no
    install_complex_avx_block2=no
246 247 248 249 250
    install_complex_avx2_block1=no
    install_complex_avx2_block2=no
    install_complex_avx512_block1=no
    install_complex_avx512_block2=no

251
    want_sse=no
Andreas Marek's avatar
Andreas Marek committed
252
    want_avx=no
253
    want_avx2=no
254
    want_avx512=no
255

256
#    install_gpu=no
257 258 259
    use_specific_complex_kernel=yes
    dnl now set the specific kernel
    $3=yes
260 261 262 263 264 265 266
    dnl take care of some dependencies
    if test x"${install_complex_sse_block2}" = x"yes" ; then
      install_complex_sse_block1=yes
    fi
    if test x"${install_complex_avx_block2}" = x"yes" ; then
      install_complex_avx_block1=yes
    fi
267 268 269 270 271 272
    if test x"${install_complex_avx2_block2}" = x"yes" ; then
      install_complex_avx2_block1=yes
    fi
    if test x"${install_complex_avx512_block2}" = x"yes" ; then
      install_complex_avx512_block1=yes
    fi
273 274

    dnl in case of SSE or AVX make sure that we can compile the choosen kernel
275 276 277
    if test x"${install_complex_sse_assembly}" = x"yes" ; then
     if test x"${can_compile_sse_assembly}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
278 279
     else
       want_sse=yes
280 281 282 283 284
     fi
    fi

    if test x"${install_complex_sse_block1}" = x"yes" ; then
     if test x"${can_compile_sse_intrinsics}" = x"no" ; then
285
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
286 287
     else
       want_sse=yes
288 289 290
     fi
    fi

291 292 293 294 295 296 297
    if test x"${install_complex_sse_block2}" = x"yes" ; then
     if test x"${can_compile_sse_intrinsics}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_sse=yes
     fi
    fi
298 299 300
    if test x"${install_complex_avx_block1}" = x"yes" ; then
     if test x"${can_compile_avx}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
Andreas Marek's avatar
Andreas Marek committed
301 302
     else
       want_avx=yes
303 304
     fi
    fi
305 306 307 308 309 310 311 312 313 314 315 316 317 318
    if test x"${install_complex_avx2_block1}" = x"yes" ; then
     if test x"${can_compile_avx2}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_avx2=yes
     fi
    fi
    if test x"${install_complex_avx512_block1}" = x"yes" ; then
     if test x"${can_compile_avx512}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_avx512=yes
     fi
    fi
319 320 321 322

    if test x"${install_complex_avx_block2}" = x"yes" ; then
     if test x"${can_compile_avx}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
Andreas Marek's avatar
Andreas Marek committed
323 324
     else
       want_avx=yes
325 326 327
     fi
    fi

328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
    if test x"${install_complex_avx2_block2}" = x"yes" ; then
     if test x"${can_compile_avx2}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_avx2=yes
     fi
    fi

    if test x"${install_complex_avx512_block2}" = x"yes" ; then
     if test x"${can_compile_avx512}" = x"no" ; then
       AC_MSG_ERROR([$2 kernel was set, but cannot be compiled!])
     else
       want_avx512=yes
     fi
    fi

Andreas Marek's avatar
Andreas Marek committed
344
    AC_MSG_NOTICE([$1 will be the only compiled kernel for complex case])
345 346 347 348 349
    if test x"${want_gpu}" = x"yes" ; then
      AC_MSG_WARN([At the moment this disables GPU support!])
      AC_MSG_WARN([IF GPU support is wanted do NOT specify a specific complex kernel])
    fi
   else
Andreas Marek's avatar
Andreas Marek committed
350
    AC_MSG_FAILURE([$1 failed; A specific kernel for complex case has already been defined before!])
351 352 353 354
   fi
  fi
])