AnsweredAssumed Answered

error while building a program due to kernel structure use

Question asked by t-man on Aug 25, 2012
Latest reply on Aug 27, 2012 by Wenju

So this is my kernel:

const char *KernelSource =

" typedef struct\n" \

"{ \n"\

" int nv;            // number of vertices\n"\

" int ne;            // number of edges \n"\

" int *nbr;          // array of neighbors of all vertices \n" \

" int *firstnbr;     // index in nbr[] of first neighbor of each vtx\n" \

"} graph; \n" \

" \n" \

"__kernel void square(                                                       \n" \

"   __global int* input,                                              \n" \

"   __global int* output,                                             \n" \

"   const unsigned int count,                                           \n" \

"   __global graph* graf) \n" \

"{                                                                      \n" \

"   int i = get_global_id(0);                                           \n" \

"   if(i < count)                                                       \n" \

"       output[i] = input[i]*input[i];                                \n" \

"}                                                                      \n" \

"\n";

 

This is the host code:

program = clCreateProgramWithSource(context, 1, (const char **) & KernelSource, NULL, &err);

    if (!program)

    {

        printf("Error: Failed to create compute program!\n");

        return EXIT_FAILURE;

    }

 

    // Build the program executable

    //

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

    if (err != CL_SUCCESS)

    {

        size_t len;

        printf("%s", KernelSource);

        char buffer[2048];

 

        printf("Error: Failed to build program executable!\n");

        clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, &len);

        printf("%s\n", buffer);

        exit(1);

    }

 

And the error I get is :

Error: Failed to build program executable!

"/tmp/OCLuQgTS9.cl", line 13: error: kernel pointer arguments must point to

          addrSpace global, local, or constant

     __global graph* graf)

                     ^

 

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

 

Internal error: clc compiler invocation failed.

 

Any suggestions? Thank you in advance

Outcomes