Build error when using pipe related functions in openCL code -
i writing use pipe feature of opencl 2.0. have kernel filters input , writes pipe. issue when use pipe related functions error "function declared implicitly". when checked online found error usualy appears in c code if function not declared before used. 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 pipe
}
the errors 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: value of type "int" cannot used initialize 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: value of type "int" cannot assigned entity of type "reserve_id_t" rid = work_group_reserve_write_pipe(pipe1, num_packets); ^
2 errors detected in compilation of "c:\users\pdca\appdata\local\temp\oclfb5 e.tmp.cl". frontend phase failed compilation.
--- build log ---
error: clbuildprogram (cl_build_program_failure)
from cl-specs (https://www.khronos.org/registry/cl/specs/opencl-2.0.pdf), page 203:
if cl-std build option not specified, highest opencl c 1.x language version supported each device used when compiling program each device. applications required specify –cl-std=cl2.0 option if want compile or build programs opencl c 2.0.
so if did not include option clbuildprogram()
call, cl-compiler not recognize 2.0 language-features. thus, call should sth this:
clbuildprogram (program, num_devices, device_list, "–cl-std=cl2.0", null, null);
in addition, think kernel-parameter not correct. cannot use __global int *pipe1
argument pipe functions. should declared __write_only pipe int pipe1
.
Comments
Post a Comment