Skip to content

Instantly share code, notes, and snippets.

@kekonn
Created November 7, 2009 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kekonn/228633 to your computer and use it in GitHub Desktop.
Save kekonn/228633 to your computer and use it in GitHub Desktop.
kernel void matrixTranspose( global float *a, global float *b, constant float *c, constant int size )
{
int idx = get_global_id(0);
int idy = get_global_id(1);
b[idx * size + idy] = a[idy * size + idx];
int BLOCKSIZE = 0;
int loops;
for (loops=0;loops<50;loops++)
{
b[idx * size + idy] += a[idy * size + idx] / 2;
b[idx * size + idy] += a[idx * size + idy] / 2;
b[idx * size + idy] += c[idx];
if( b[idx * size + idy] < 50 ){
b[idx * size + idy] = ( b[idx * size + idy] / 100 ) * ( c[idx] / 20 );
}
if(idx % 2 == 0){
b[idx * size + idy] = b[idx * size + idy] - 20 + c[size - idx];
}
}
if((idx % (size)) == size - 1){
int i;
float som = 0;
for (i=0; i<(size); i++) {
som += b[idx * size + i];
}
som = som / (size);
b[idx * size + idy] = som;
}
}
kernel void matrixTranspose( global float *a, global float *b, constant float *c, constant int size, global float *som )
{
int idx = get_global_id(0);
int idy = get_global_id(1);
int loops;
float cc = c[idx];
float c2 = cc / 20;
float cidx = c[size - idx];
float ayx = a[idy * size + idx];
b[idx * size + idy] = ayx;
float bxy = b[idx * size + idy];
float axy = a[idx * size + idy];
for (loops=0;loops<50;loops++)
{
/* bxy += ayx / 2 + axy / 2 + cc; */
bxy += native_divide(ayx,2.0f) + native_divide(axy,2.0f) + cc;
if( bxy < 50 ){
bxy = native_divide( bxy , 100.0f ) * c2;
}
if(idx % 2 == 0){
bxy = bxy - 20 + cidx;
}
}
b[idx * size + idy] = bxy;
if(idx == size - 1){
int i;
float som = 0;
for(i=0;i<size;i++)
{
float s = b[idx * size +i];
som += s;
}
b[idx * size + idy] = som;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment