0
votes

Hello when I used Mac OS + OpenCL Framework this code worked properly, but when OS was changed to openSUSE 11.4 + (OpenCL implementation from AMD) the code become throw such error. It seems typedef float clfft_complex[2]; makes this error. What you can say about that?

Error:

Err: "/tmp/OCLRS2tPp.cl", line 4: error: kernel pointer arguments must point to
      addrSpace global, local, or constant
__kernel void linear_interp(__global clfft_complex *input,
                                                  ^

1 error detected in the compilation of "/tmp/OCLRS2tPp.cl".

Internal error: clc compiler invocation failed.

Kernel code:

typedef float clfft_complex[2];

__kernel void linear_interp(__global clfft_complex *input,
                        __global clfft_complex *output)
{
    int global_id = get_global_id(0);
    input[global_id][0] = 1.5f;
    input[global_id][1] = 5.5f;
}

Host code:

//////////////////////////////////
/* Preparing OpenCL Environment */
//////////////////////////////////

cl_uint cl_platformsN = 0;
cl_platform_id *cl_platformIDs = NULL;

clGetPlatformIDs (0, NULL, &cl_platformsN);

cl_platformIDs = (cl_platform_id*)malloc( cl_platformsN * sizeof(cl_platform_id));
clGetPlatformIDs(cl_platformsN, cl_platformIDs, NULL);

cl_int status = CL_SUCCESS;
cl_device_id device;    // Compute device
cl_context context;     // Compute context

CL_CHECK_ERROR(clGetDeviceIDs(cl_platformIDs[0], DEVICE_TYPE, 1, &device, NULL));
context = clCreateContext(NULL, 1, &device, NULL, NULL, &status);

////////////
/* Device */
////////////
cl_uint wavefronts_per_SIMD = 7;
cl_int device_max_cu;

size_t wg_count;
size_t global_work_size;

#if DEVICE_TYPE == CL_DEVICE_TYPE_GPU
    size_t local_work_size = 64;
#else
    size_t local_work_size = 1;
#endif

// Get info about the compute units on the device
CL_CHECK_ERROR(clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(cl_uint), &device_max_cu, NULL));
wg_count = device_max_cu * wavefronts_per_SIMD;


global_work_size = wg_count * local_work_size;

/////////////////////
/* Input Data Part */
/////////////////////

/* Input a slice properties */
int bits_per_sample;
int samples_per_pixel;
int theta_size;
int slice_size;

/* Read the slice */
clfft_complex *data_tiff = tiff_read_complex(tiff_input,
                                             &bits_per_sample,
                                             &samples_per_pixel,
                                             &slice_size,
                                             &theta_size);


////////////////////////
/* OpenCL - DFI Part */
////////////////////////

/* Sync events */
const int events_num = 5;
cl_event event_list[events_num];

/* Command Queue */
cl_command_queue command_queue = clCreateCommandQueue(context, device, 0, &status);

/* Program */
const char* programSource = load_program_source(KERNELS_FILE_PATH);
if(programSource == NULL) {
    fprintf(stderr, "Programm '%s' can not be created. File was not found.", KERNELS_FILE_PATH);
    return;
}

cl_program program = clCreateProgramWithSource(context, 1,
                                               (const char**)&programSource, NULL,
                                               &status);

status = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);

size_t paramValueSize = 1024 * 1024, param_value_size_ret;
char *paramValue;
paramValue = (char*)calloc(paramValueSize, sizeof(char));
    status = clGetProgramBuildInfo( program,
                                device,
                                CL_PROGRAM_BUILD_LOG,
                                paramValueSize,
                                paramValue,
                                &param_value_size_ret);
printf("Err: %s", paramValue);

char buf[0x10000];
clGetProgramBuildInfo(program,
                      device,
                      CL_PROGRAM_BUILD_LOG,
                      0x10000,
                      buf,
                      NULL);

if(status != CL_SUCCESS) {
    fprintf(stderr, "Programm '%s' can not be build. (%s)", KERNELS_FILE_PATH, opencl_map_error(status));
    return;
}



/* Kernels */
cl_kernel kernel_linear_interp = clCreateKernel(program, "linear_interp", &status);
1

1 Answers

1
votes

First, I don't know why this code worked, but assuming that your input is a kernel pointer argument (cl_mem) with a specific memory space in global, then i think you cannot just force it to have another dimensional array of size 2, giving __global *input[2] as the argument, because you've already set the type of argument before calling the kernel. (btw where is your clSetKernelArg()?)

Second, why are you doing this to your input?

input[global_id][0] = 1.5f;
input[global_id][1] = 5.5f;

Because input memory space often should only be read-only.. or perhaps that kernel is just a piece of your kernel?

Anyway, i'm not sure what you're doing with that kernel, so:

  1. If it means you just want a constant float[2] variable which applies to all inputs, then you can just declare

    __constant float var[2] = {1.5f, 5.5f};

  2. If what you meant by input is actually your output, and you want to write two floating points in a single workitem, then you can change the type to float2, or by doing:

    vstore2((float2)(1.5f,5.5f), 0, input[global_id]);

    but don't forget to divide the local workitems by 2..