2011-06-14 21:32:50 +08:00
|
|
|
#ifndef OCL_MACROS_H
|
|
|
|
#define OCL_MACROS_H
|
|
|
|
|
2018-05-08 12:25:10 +08:00
|
|
|
#include <cstdio>
|
2011-06-14 21:32:50 +08:00
|
|
|
#include <cassert>
|
2012-01-25 23:31:54 +08:00
|
|
|
|
2020-01-07 06:34:26 +08:00
|
|
|
/* We default to OpenCL 1.2 as target version for now as
|
|
|
|
* there are known issues with OpenCL 2.0 and later.
|
|
|
|
* This is also to silence warnings from generic OpenCL headers */
|
|
|
|
|
|
|
|
#if !defined(CL_TARGET_OPENCL_VERSION)
|
|
|
|
#define CL_TARGET_OPENCL_VERSION 120
|
|
|
|
#endif
|
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <OpenCL/cl.h>
|
|
|
|
#else
|
|
|
|
#include <CL/cl.h>
|
|
|
|
#endif
|
2011-06-14 21:32:50 +08:00
|
|
|
|
|
|
|
#ifdef MPI_GERYON
|
|
|
|
#include "mpi.h"
|
2014-10-22 00:33:32 +08:00
|
|
|
#define OCL_GERYON_EXIT do { \
|
|
|
|
int is_final; \
|
|
|
|
MPI_Finalized(&is_final); \
|
|
|
|
if (!is_final) \
|
|
|
|
MPI_Abort(MPI_COMM_WORLD,-1); \
|
|
|
|
} while(0)
|
2011-06-14 21:32:50 +08:00
|
|
|
#else
|
|
|
|
#define OCL_GERYON_EXIT assert(0==1)
|
|
|
|
#endif
|
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
#ifndef UCL_GERYON_EXIT
|
|
|
|
#define UCL_GERYON_EXIT OCL_GERYON_EXIT
|
|
|
|
#endif
|
|
|
|
|
2011-06-14 21:32:50 +08:00
|
|
|
#ifdef UCL_DEBUG
|
|
|
|
#define UCL_SYNC_DEBUG
|
|
|
|
#define UCL_DESTRUCT_CHECK
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef UCL_NO_API_CHECK
|
|
|
|
|
|
|
|
# define CL_SAFE_CALL( call) do { \
|
|
|
|
cl_int err = call; \
|
|
|
|
if( err != CL_SUCCESS) { \
|
|
|
|
fprintf(stderr, "OpenCL error in file '%s' in line %i : %d.\n", \
|
|
|
|
__FILE__, __LINE__, err ); \
|
|
|
|
OCL_GERYON_EXIT; \
|
|
|
|
} } while (0)
|
|
|
|
|
|
|
|
# define CL_CHECK_ERR( val) do { \
|
|
|
|
if( val != CL_SUCCESS) { \
|
|
|
|
fprintf(stderr, "OpenCL error in file '%s' in line %i : %d.\n", \
|
|
|
|
__FILE__, __LINE__, val ); \
|
|
|
|
OCL_GERYON_EXIT; \
|
|
|
|
} } while (0)
|
|
|
|
|
|
|
|
#else // not DEBUG
|
|
|
|
|
|
|
|
// void macros for performance reasons
|
|
|
|
# define CL_SAFE_CALL( call) call
|
|
|
|
# define CL_CHECK_ERR( val)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef UCL_DESTRUCT_CHECK
|
|
|
|
|
|
|
|
#define CL_DESTRUCT_CALL( call) CL_SAFE_CALL( call)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define CL_DESTRUCT_CALL( call) call
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|