programming help needed

i want to implement BWT in openCL my host code is givin no error but the output is giveing some junk values. I think the problem is in kernel code. I want to implement it data parallel that is each thread will do bwt on individual string . please help…my kernel code is attached


#include<stdlib.h>
#define BWT_SIZE=1024;
_kernel void bwt(_global uchar *bwt_buf, _global uchar *bwt_out_buf, _global uint nread, _global index_of_origin){
uint i, last_index=BWT_SIZE, index_table[BWT_SIZE]
//get the index of the current element

        int id = get_global_id(0);
        for(i=0;i<nread;i++)
                {
                        index_table[i]=i;
                }
                qsort(index_table,nread,sizeof(int),(int(*)(const void *,const void *))bwt_comp);
                last_index=nread;
                for(i=0;i<nread;i++)
                        {
                                if(index_table[i]==0){
                                bwt_out_buf[i]=bwt_buf[nread-1];        
                                last_index=i;
                                }
                                bwt_out_buf[id]=bwt_buf[index_table[i]-1];
                        }
                index_of_origin=last_index;                     
int bwt_comp(uint *a, uint *b)
{
        register int a1=*a,b1=*b,tmp=a1;
        if ( bwt_buf[a1] != bwt_buf[b1] ) {
                if ( bwt_buf[a1] > bwt_buf[b1] )
                return 1;}
                else return -1;
        else {
                do {
                        if ( bwt_buf[++a1 == nread? a1 = 0 : a1]
                                        != bwt_buf[++b1 == nread? b1 = 0 : b1] ) {
                                if ( bwt_buf[a1] > bwt_buf[b1] ) return 1;
                                else return -1;
                        }
                } while ( a1 != tmp );


Did you have an OpenCL question, or are you just looking for help with debugging your serial C code? If it’s the latter you might find more help on a more general forum e.g. Stack Exchange.