opencl - How to use clCreateImage -


i trying create cl_mem using clcreateimage program keeps crashing. following book close possible it's been pretty bump road far.

#include "stdafx.h" #include <iostream> #include <cl\cl.h>  using namespace std;  int _tmain(int argc, _tchar* argv[]) {     cl_int status;      cl_platform_id platform;     status = clgetplatformids(1, &platform, null);     cl_device_id device;     clgetdeviceids(platform, cl_device_type_all, 1, &device, null);     cl_context_properties props[3] = { cl_context_platform, (cl_context_properties) (platform), 0 };     cl_context context = clcreatecontext(props, 1, &device, null, null, &status);      cl_image_desc desc;     desc.image_type = cl_mem_object_image2d;     desc.image_width = 100;     desc.image_height = 100;     desc.image_depth = 0;     desc.image_array_size = 0;     desc.image_row_pitch = 0;     desc.image_slice_pitch = 0;     desc.num_mip_levels = 0;     desc.num_samples = 0;     desc.buffer = null;      cl_image_format format;     format.image_channel_order = cl_r;     format.image_channel_data_type = cl_float;      // crashes on next line -- unhandled exception @ 0x72bcc9f1 in convolution.exe: 0xc0000005: access violation executing location 0x00000000.     cl_mem d_inputimage = clcreateimage(context, cl_mem_read_only, &format, &desc, null, &status);     // never gets here      cout << "--->"; int exit; cin >> exit;     return 0; } 

clcreateimage has following parameters:

 cl_mem clcreateimage (     cl_context context,                            cl_mem_flags flags,                            const cl_image_format *image_format,                            const cl_image_desc *image_desc,                            void *host_ptr,                            cl_int *errcode_ret) 

in doc page there no mention "host_ptr" may null. try valid pointer there. different clcratebuffer null pointer allowed. in createbuffer there no mention case, know works. may driver/library bug.

since clear opencl library trying access null pointer location error code states :access violation executing location 0x00000000 recomend first try that.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -