Results 1 to 2 of 2

Thread: reg kernel function(linear search)

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    13

    reg kernel function(linear search)

    __kernel void lin_search (__global const float *a,float c,int pos)
    {
    int tid = get_global_id(0);
    if(c==a[tid])
    pos=(tid+1)
    };

    Is this function is right for searching an element using linear search?

    praveenraj

  2. #2

    Re: reg kernel function(linear search)

    Almost! You need to get the output through a buffer, however. Actually, I'm not sure if this is the only way, but definitely the standard:

    Code :
    __kernel void lin_search (__global const float *a,float c,__global unsigned int *pos)
    {
    	int tid = get_global_id(0);
    	if(c==a[tid])
    		pos[0]=(tid+1);
    };

    EDIT: if the search returns true for more than one element, you have a data-racing issue, however...

Similar Threads

  1. reg kernel function
    By paviraj_1989 in forum OpenCL
    Replies: 0
    Last Post: 03-19-2011, 10:44 AM

Posting Permissions

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