1#ifndef _TPF_OPENCL_UTILS_HPP
2#define _TPF_OPENCL_UTILS_HPP
30#ifndef CL_TARGET_OPENCL_VERSION
31#define CL_TARGET_OPENCL_VERSION 220
45#pragma warning( push )
46#pragma warning( disable : 4996 )
48template<
typename =
int>
56 vfprintf(stdout, str, args);
62template<
typename =
int>
70 vfprintf(stderr, str, args);
79template<
typename =
int>
82 int errorCode = CL_SUCCESS;
85 fopen_s(&fp, fileName,
"rb");
88 LogError(
"Error: Couldn't find program source file '%s'.\n", fileName);
89 errorCode = CL_INVALID_VALUE;
92 fseek(fp, 0, SEEK_END);
93 *sourceSize = ftell(fp);
94 fseek(fp, 0, SEEK_SET);
96 *source =
new char[*sourceSize];
99 LogError(
"Error: Couldn't allocate %d bytes for program source from file '%s'.\n", *sourceSize, fileName);
100 errorCode = CL_OUT_OF_HOST_MEMORY;
103 fread(*source, 1, *sourceSize, fp);
108#pragma warning( pop )
int ReadSourceFromFile(const char *fileName, char **source, size_t *sourceSize)
void LogError(const char *str,...)
void LogInfo(const char *str,...)