Ben Beazley
Ben Beazley

Reputation: 37

error -11 OpenCL

i'm getting error -11 on this line

checkerror(clBuildProgram(program, deviceidcount, deviceids.data(), nullptr, nullptr, nullptr));

my kernel is

__kernel void render(double playerx,double playery,double playerz,double yaw,double pitch,double x1,double y1,double z1,double x2,double y2,double z2,double x3,double y3,double z3,__global int* texture){
    //const int i = get_global_id(0);
    //x[i] = a*x[i];
    //x[i] = cos(a);
    x1 = x1-playerx;
    y1 = y1-playery;
    z1 = z1-playerz;
    x2 = x2-playerx;
    y2 = y2-playery;
    z2 = z2-playerz;
    x3 = x3-playerx;
    y3 = y3-playery;
    z3 = z3-playerz;

    double smallyaw = yaw - M_PI_2;
    double bigpitch = pitch + M_PI_2;

    double screenx1 = cos(smallyaw)*cos(pitch)*x1 + sin(smallyaw)*cos(pitch)*y1 + sin(pitch)*z1;
    double screeny1 = cos(yaw)*cos(bigpitch)*x1 + sin(yaw)*cos(bigpitch)*y1 + sin(bigpitch)*z1;
    double screenz1 = cos(yaw)*cos(pitch)*x1 + sin(yaw)*cos(pitch)*y1 + sin(pitch)*z1;
    printf(screenx1);
    printf(screeny1);
    printf(screenz1);
}

i can't see anything wrong with it in the terms of syntax. and i also tried replacing all the doubles with floats.

this is stupid after looking at this for the longest time i commented out the printf lines and it worked. how am i supposed to check what these variables are equal to. can someone tell me how to properly print things?

Upvotes: 1

Views: 179

Answers (3)

Jovasa
Jovasa

Reputation: 445

i can't see anything wrong with it in the terms of syntax.

Well try looking harder because that's not how you use printf.

If you want to print doubles use

printf("%f", value);

If this doesn't make sense would recommend reading documentation for both generic C printf and OpenCL printf.

Also since -11 is CL_BUILD_PROGRAM _FAILURE you can use clGetProgramBuildInfo to retrieve the build log and check where the compilation went wrong.

Upvotes: 0

huseyin tugrul buyukisik
huseyin tugrul buyukisik

Reputation: 11910

printf("value = %#g\n", 3.012);

prints 3.012 to console.

Printing to console should be done in a thread-safe way so your cl thread should be same as console flushing thread.

Upvotes: 1

mfa
mfa

Reputation: 5087

Printing output from many cores can give unexpected results. Timings are off, prints don't come back in any particular order etc. Try to print from only one work item.

if i == 0{
    printf(...)
}

You can also put a barrier above that and loop through multiple values from work item 0 if you need to.

Upvotes: 0

Related Questions