1AC_DEFUN([ALBERTA_OPENMP], 2[AC_REQUIRE([AC_PROG_CC]) 3AC_CHECK_HEADERS([omp.h]) 4_alberta_save_cflags="${CFLAGS}" 5CFLAGS="${CFLAGS} ${OPENMP_CFLAGS}" 6AC_LANG_PUSH([C]) 7AC_MSG_CHECKING( 8 [for OpenMP availibility with "${CC} ${CFLAGS}"]) 9AC_LINK_IFELSE( 10 [AC_LANG_PROGRAM( 11[#ifdef HAVE_OMP_H 12# include <omp.h> 13#endif 14#include <stdio.h>], 15[int nthreads, tid; 16 17/* Fork a team of threads giving them their own copies of variables */ 18#pragma omp parallel private(tid) 19 { 20 21 /* Obtain and print thread id */ 22 tid = omp_get_thread_num(); 23 printf("Hello World from thread = %d\n", tid); 24 25 /* Only master thread does this */ 26 if (tid == 0) 27 { 28 nthreads = omp_get_num_threads(); 29 printf("Number of threads = %d\n", nthreads); 30 } 31 32 } /* All threads join master thread and terminate */])], 33[AC_MSG_RESULT([OpenMP seems to be available]) 34AC_DEFINE([HAVE_OPENMP], 1, [Define to 1 if OpenMP is available])], 35[AC_MSG_RESULT([OpenMP seems not to be available]) 36AC_DEFINE([HAVE_OPENMP], 0, [Define to 1 if OpenMP is available])]) 37AC_LANG_POP([C]) 38CFLAGS="${_alberta_save_cflags}" 39AC_ARG_VAR([OPENMP_CFLAGS], [C/C++ compiler flags to enable OpenMP]) 40]) 41