OpenCL总结

    cl_int error;
    cl_platform_id platforms;
    cl_device_id devices;
    cl_context context;
    FILE* program_handle;
    size_t program_size;
    char* program_buffer;
    cl_program program;
    size_t log_size;
    char* program_log;

    char BlendKernel_name[] = "Darkenhance_blend";
    char RGB2GrayKernel_name[] = "RGB2Gray";
    char Gauss_filterKernel_name[] = "Gauss_filter";

    cl_kernel BlendKernel;
    cl_kernel RGB2GrayKernel;
    cl_kernel Gauss_filterKernel;

    cl_command_queue queue;

// 获取平台
error = clGetPlatformIDs(1, &platforms, NULL);

// 获取设备
error = clGetDeviceIDs(platforms, CL_DEVICE_TYPE_GPU, 1, &devices, NULL);

// 创建上下文
context = clCreateContext(NULL, 1, &devices, NULL, NULL, &error);

// 创建程序
program = clCreateProgramWithSource(context, 1, (const char**)&program_buffer, &program_size, &error);

// 编译程序
error = clBuildProgram(program, 1, &devices, NULL, NULL, NULL);

// 创建命令队列
queue = clCreateCommandQueue(context, devices, CL_QUEUE_PROFILING_ENABLE, &error);

// 创建内核
RGB2GrayKernel = clCreateKernel(program, RGB2GrayKernel_name, &error);
Gauss_filterKernel = clCreateKernel(program, Gauss_filterKernel_name, &error);
BlendKernel = clCreateKernel(program, BlendKernel_name, &error);

你可能感兴趣的:(java,前端,linux)