0

clCreateImage を使用して cl_mem を作成しようとしていますが、プログラムがクラッシュし続けます。私は自分の本をできる限り忠実にたどっていますが、これまでのところかなりでこぼこ道でした。

#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 the next line with -- Unhandled exception at 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;
}
4

2 に答える 2