titanius

Need help converting to a brook+ kernel

Discussion created by titanius on Jul 15, 2009
Latest reply on Jul 16, 2009 by titanius
output stream does not have a fixed indices but at random

I have some trouble converting simple code to brook+. The problem is that the output stream is not incrementing from say 1 to 100 but at different indices. Is there a type of kernel that i can directly use?

 

idmove, idmove_mapped and jdex_index are all 1D arrays

CODE:

 for (j = ndstart; j<=ndend; ++j){
        if(idmove[j]==1){
            idmove_mapped[jdex_index[j]]++;
        }
    }
 for (j = ndstart; j<=ndend; ++j){
        if(idmove[j]==0){
            idmove_mapped[jdex_index[j]]--;
        }
    }

 

I have the above code and i guess i can convert it to

PROBABLE KERNEL:

kernel void idmove_mapped_jdex(int jdex_index<>, int idmove<>, out int idmove_mapped[])
{
   
    if(idmove == 1)
        idmove_mapped[jdex_index] = idmove_mapped[jdex_index] + 1 ;
   
    if(idmove == 0)
        idmove_mapped[jdex_index] = idmove_mapped[jdex_index] - 1 ;
   
}

 

And use domain execution to get it working

    idmove_mapped_jdex.domainOffset(ndstart);
    idmove_mapped_jdex.domainSize(ndend-ndstart+1);
    idmove_mapped_jdex(s_jdex_index, s_idmove, s_idmove_mapped);

Is this right? as it doesn't seem to work.

 

Thanks for reading!

 

 

 

 

Outcomes