1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2010-2019 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 Contributed by Ken Werner <ken.werner@de.ibm.com> */
20 /* Utility macros and functions for OpenCL applications. */
30 #include <OpenCL/opencl.h>
36 /* Executes the given OpenCL function and checks its return value.
37 In case of failure (rc != CL_SUCCESS) an error string will be
38 printed to stderr and the program will be terminated. This Macro
39 is only intended for OpenCL routines which return cl_int. */
47 /* Macro that checks an OpenCL error code. In case of failure
48 (err != CL_SUCCESS) an error string will be printed to stderr
49 including the prefix and the program will be terminated. This
50 Macro is only intended to use in conjunction with OpenCL routines
51 which take a pointer to a cl_int as an argument to place their
54 #define CHK_ERR(prefix, err)\
55 if (err != CL_SUCCESS)\
57 fprintf (stderr, "CHK_ERR (%s, %d)\n", prefix, err);\
58 fprintf (stderr, "%s:%d error: %s\n", __FILE__, __LINE__,\
59 get_clerror_string (err));\
63 /* Return a pointer to a string that describes the error code specified
64 by the errcode argument. */
66 extern const char *get_clerror_string (int errcode
);
68 /* Prints OpenCL information to stdout. */
70 extern void print_clinfo ();
72 /* Reads a given file into the memory and returns a pointer to the data or NULL
73 if the file does not exist. FILENAME specifies the location of the file to
74 be read. SIZE is an output parameter that returns the size of the file in
77 extern const char *read_file (const char * const filename
, size_t *size
);
79 /* Saves all program binaries of the given OpenCL PROGRAM. The file
80 names are extracted from the devices. */
82 extern void save_program_binaries (cl_program program
);
88 #endif /* CL_UTIL_H */