gpu.c: compute_copy_in_and_out: take gpu_prog
[ppcg.git] / m4 / ax_check_opencl.m4
blob814bbb6ce2a879a119a3131afd07d9c72fd88e75
1 # Check if OpenCL is available and that it supports a CPU device.
2 # The check for a CPU device is the same check that is performed
3 # by opencl_create_device in ocl_utilities.c
4 AC_DEFUN([AX_CHECK_OPENCL], [
5         AC_SUBST(HAVE_OPENCL)
6         HAVE_OPENCL=no
7         AC_CHECK_HEADER([CL/opencl.h], [
8                 AC_CHECK_LIB([OpenCL], [clGetPlatformIDs], [
9                         SAVE_LIBS=$LIBS
10                         LIBS="$LIBS -lOpenCL"
11                         AC_MSG_CHECKING([for OpenCL CPU device])
12                         AC_RUN_IFELSE([AC_LANG_PROGRAM(
13                                 [[#include <CL/opencl.h>]], [[
14         cl_platform_id platform;
15         cl_device_id dev;
17         if (clGetPlatformIDs(1, &platform, NULL) < 0)
18                 return 1;
19         if (clGetDeviceIDs(platform, CL_DEVICE_TYPE_CPU, 1, &dev, NULL) < 0)
20                 return 1;
21                                 ]])], [HAVE_OPENCL=yes])
22                         AC_MSG_RESULT($HAVE_OPENCL)
23                         LIBS=$SAVE_LIBS
24                         ])])