0

I am writing to use the pipe feature of opencl 2.0. I have a kernel which filters the input and writes into a pipe. But the issue is that when i use pipe related functions i get the error "function declared implicitly". When i checked online i found that this error usualy appears in c code if the function is not declared before its used. But this is an openCL library function.

My kernel code is:

__kernel void filter1_kernel(__global int *input, const unsigned int rLen, const unsigned int lower, const unsigned int upper, __global int *pipe1){

unsigned int bitmap = 0;
int count = 0;
//reserve_id_t rid;

uint numWorkItems = get_global_size(0);
uint tid          = get_global_id(0);
uint num_packets = get_local_size(0);

while(tid < rLen){
    if(input[tid] >= lower && input[tid] <= upper){
        bitmap = bitmap | (1 << count);
        printf((__constant char *)"\nfilter1 %u %u %d %u", tid, bitmap, input[tid], count);
    }
    tid += numWorkItems;
    count++;
}

reserve_id_t rid = work_group_reserve_write_pipe(pipe1, num_packets);
while(is_valid_reserve_id(rid) == false) {
    rid = work_group_reserve_write_pipe(pipe1, num_packets);
}
//write to pipe

}

The errors that i got are:

Build Log Buffer length : 1048 --- Build log --- "C:\Users\pdca\AppData\Local\Temp\OCLFB5E.tmp.cl", line 40: error: function "work_group_reserve_write_pipe" declared implicitly reserve_id_t rid = work_group_reserve_write_pipe(pipe1, num_packets); ^

"C:\Users\pdca\AppData\Local\Temp\OCLFB5E.tmp.cl", line 40: warning: a value of type "int" cannot be used to initialize an entity of type "reserve_id_t" reserve_id_t rid = work_group_reserve_write_pipe(pipe1, num_packets); ^

"C:\Users\pdca\AppData\Local\Temp\OCLFB5E.tmp.cl", line 41: error: function "is_valid_reserve_id" declared implicitly while(is_valid_reserve_id(rid) == false) { ^

"C:\Users\pdca\AppData\Local\Temp\OCLFB5E.tmp.cl", line 42: warning: a value of type "int" cannot be assigned to an entity of type "reserve_id_t" rid = work_group_reserve_write_pipe(pipe1, num_packets); ^

2 errors detected in the compilation of "C:\Users\pdca\AppData\Local\Temp\OCLFB5 E.tmp.cl". Frontend phase failed compilation.

                            --- Build log ---

ERROR: clBuildProgram (CL_BUILD_PROGRAM_FAILURE)

1 Answer 1

2

From the CL-specs (https://www.khronos.org/registry/cl/specs/opencl-2.0.pdf), page 203:

If the cl-std build option is not specified, the highest OpenCL C 1.x language version supported by each device is used when compiling the program for each device. Applications are required to specify the –cl-std=CL2.0 option if they want to compile or build their programs with OpenCL C 2.0.

So if you did not include this option to your clBuildProgram() call, the CL-compiler will not recognize any 2.0 language-features. Thus, your call should look sth like this:

clBuildProgram (program, num_devices, device_list, "–cl-std=CL2.0", NULL, NULL);

In addition, I think your kernel-parameter is not correct. You cannot use a __global int *pipe1 as an argument for the pipe functions. It should probably be declared as __write_only pipe int pipe1.

Sign up to request clarification or add additional context in comments.

10 Comments

Thanks a lot. But after i adding the option -cl-std=CL2.0 and changing the parameter as you said the clBuildProgram fails with the message "flex scanner jammed".
The build command i used is: cl_err = clBuildProgram(program[Q6_PROGRAM_ID], 1, &device[A10_GPU], "-I ./ -cl-std=CL2.0", NULL, NULL); And the parameter was changed as: __kernel void filter1_kernel(__global int *input, const unsigned int rLen, const unsigned int lower, const unsigned int upper, __write_only pipe int pipe1){
Whoa, "flex scanner jammed" sounds like "internal compiler error". Don't know WTH is going on there...
Wait! Did you copy&paste the cl-std option from my post? Because I copy&pasted it from the PDF-document. AND looking at the screen closely, I notice that the first hyphen looks different than the other! I think it may be a different character! Try typing the option manually please!
I am using AMD OpenCL SDK 3.0.0-Beta. Could the issue be withe the SDK?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.