不是原生的英特尔OpenCL运行时期望有大量速度损失
创始人
2025-01-07 04:30:15
0

如果您遇到这个问题,可能需要使用 Intel 的 OpenCL 运行时。以下是一个代码示例,用于在 Linux 系统上使用 Intel 运行时启动 OpenCL 程序:

#include 
#include 

#define MAX_SOURCE_SIZE (0x100000)

int main() {
   cl_platform_id platform_id = NULL;
   cl_device_id device_id = NULL;
   cl_context context = NULL;
   cl_command_queue command_queue = NULL;
   cl_mem memobj = NULL;
   cl_program program = NULL;
   cl_kernel kernel = NULL;
   cl_uint ret_num_devices;
   cl_uint ret_num_platforms;
   cl_int ret;

   char string[MEM_SIZE];
   FILE *fp;
   char fileName[] = "./hello.cl";
   char *source_str;
   size_t source_size;

   /* Load the source code containing the kernel*/
   fp = fopen(fileName, "r");
   if (!fp) {
      fprintf(stderr, "Failed to load kernel.\n");
      exit(1);
   }
   source_str = (char*)malloc(MAX_SOURCE_SIZE);
   source_size = fread(source_str, 1, MAX_SOURCE_SIZE, fp);
   fclose(fp);

   /* Get Platform and Device Info */
   ret = clGetPlatformIDs(1, &platform_id, &ret_num_platforms);
   ret = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_DEFAULT, 1, &device_id, &ret_num_devices);

   /* Create OpenCL context */
   context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &ret);

   /* Create Command Queue */
   command_queue = clCreateCommandQueue(context, device_id, 0, &ret);

   /* Create Memory Buffer */
   memobj = clCreateBuffer(context, CL_MEM_READ_WRITE,MEM_SIZE * sizeof(char), NULL, &ret);

   /* Create Kernel Program from the source */
   program = clCreateProgramWithSource(context, 1, (const char **)&source_str,
   (const size_t *)&source_size, &ret);

   /* Build Kernel Program */
   ret = clBuildProgram(program, 1,

相关内容

热门资讯

透视透视!wpk模拟器,如何下... 透视透视!wpk模拟器,如何下载wpk透视版,攻略教程(有挂方法)1、构建自己的如何下载wpk透视版...
透视黑科技!hhpoker买挂... 透视黑科技!hhpoker买挂,hhpkoer辅助器,切实教程(有挂教程)1)hhpkoer辅助器辅...
透视科技!wpk透视是真的吗,... 透视科技!wpk透视是真的吗,wpk刷入池率脚本,2025教程(有挂详情);1、wpk透视是真的吗系...
透视黑科技!hhpoker软件... 透视黑科技!hhpoker软件靠谱吗,德州局hhpoker,透明教程(有挂工具)1、起透看视 hhp...
透视透视挂!wpk透视插件,w... 透视透视挂!wpk透视插件,wpk俱乐部有没有辅助,解说技巧(有挂规律)1.wpk俱乐部有没有辅助 ...
透视攻略!hhpoker开挂教... 透视攻略!hhpoker开挂教程,hhpoker辅助软件下载,规律教程(有挂工具);1、玩家可以在h...
透视讲解!微扑克微乐辅助,wp... 透视讲解!微扑克微乐辅助,wpk安卓下载辅助,wpk教程(有挂揭秘)1、超多福利:超高返利,海量正版...
透视新版!hhpoker辅助器... 透视新版!hhpoker辅助器,HH平台挂,切实教程(有挂介绍);1、进入到hhpoker辅助器黑科...
透视美元局!wpk透视辅助下载... 透视美元局!wpk透视辅助下载,wpk真的有透视嘛,必赢教程(有挂脚本);所有人都在同一条线上,像星...
透视有挂!hh poker辅助... 透视有挂!hh poker辅助器先试用,hhpoker辅助器,技巧教程(有挂脚本);1.hh pok...