Results 1 to 4 of 4

Thread: how to call two functions within a kernel

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    18

    how to call two functions within a kernel

    Hi!!
    I would like to know how to call a normal C function within another function in a kernel.
    this is de code!!

    float sinc(float x)
    {
    if(x==0.0f)
    {
    return 1.0f;
    }
    else
    {
    return sin(3.14159265358979323846f*x)/(3.14159265358979323846f*x);
    }
    }

    float* filter_design_direct_I(int M, float Beta, float wc1, float wc2, float* h,float* y, float* wn, float* hn,float* izero_var, float izero_beta)
    {
    int i;

    for (i=0; i<=M; i++){
    h[i]=(wc1/3.14159265358979323846f)*sinc(wc1/3.14159265358979323846f*(i-(M/2)))-((wc2/3.14159265358979323846f)*sinc(wc2/3.14159265358979323846f*(i-(M/2))));
    }
    .
    .
    .
    }


    I put this but it gives me error: CL_BUILD_PROGRAM_FAILURE
    __kernel void filter_final(float wc1_lpf_s, float wc2_bpf_s, float wc1_bpf_s, __global float *salida_bpf_s_rectif,__global float *salida_bpf_s, __global float * hn_lpf_s,__global float *hn_bpf_s, __global float* entrada, int length, int M_bpf, int M_lpf ,float Beta_bpf, float Beta_lpf, __global float *salida_lpf_X, float delta_w_bpf, float fm, float f0)
    {
    wc1_bpf_s = (f0*2*3.14159265358979323846f/fm)+delta_w_bpf;
    wc2_bpf_s = (f0*2*3.14159265358979323846f/fm)-delta_w_bpf;
    hn_bpf_s = filter_design_direct_I(M_bpf, Beta_bpf, wc1_bpf_s, wc2_bpf_s);
    .
    .
    .
    }

    please!! Help me!!!

  2. #2
    Senior Member
    Join Date
    Dec 2011
    Posts
    124
    You need to get the build output to find your error. Call clGetProgramBuildInfo with CL_PROGRAM_BUILD_LOG

    It will tell you what line has the error and what the error is.

  3. #3
    Senior Member
    Join Date
    Oct 2012
    Posts
    102
    All the pointers in the declaration of filter_design_direct_I() should have an address space qualifier matching the address space of the parameters of the caller.

  4. #4
    Junior Member
    Join Date
    Oct 2013
    Posts
    18
    ok, thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •