/tomo/pyhst

To get this branch, use:
bzr branch http://darksoft.org/webbzr/tomo/pyhst

« back to all changes in this revision

Viewing changes to tools/gen.sh

  • Committer: Suren A. Chilingaryan
  • Date: 2012-05-10 15:06:33 UTC
  • Revision ID: csa@dside.dyndns.org-20120510150633-56gdy6t3tflz2gab
OpenCL clean-up

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function unroll {
 
2
    lines=`expr $1 - 1`
 
3
    text=$2
 
4
    
 
5
    for i in `seq 0 $lines`; do
 
6
        for j in `seq 0 $lines`; do
 
7
            echo "$text" | sed -e "s/res\[i\]\[j\]/res_${i}_${j}/g" -e "s/\([^a-zA-Z]\)i\([^a-zA-Z]\)/\1$i\2/g" -e "s/\([^a-zA-Z]\)j\([^a-zA-Z]\)/\1$j\2/g"
 
8
        done
 
9
    done
 
10
}
 
11
 
 
12
 
 
13
 
 
14
 
 
15
size=8
 
16
 
 
17
unroll $size 'float res[i][j] = 0;' 
 
18
#unroll $size 'res[i][j] += subh_cache(subh + (i * BLOCK_SIZE) * all.y + (j * BLOCK_SIZE) * all.x);'
 
19
#unroll $size 'slice[(idy + BLOCK_SIZE * i) * slice_width + idx + BLOCK_SIZE * j] = res[i][j];'
 
20
#unroll $size 'res[i][j] += read_imagef(sinogram, volumeSampler, (float2)(subh + i * BLOCK_SIZE * all.y + j * BLOCK_SIZE * all.x, proj + .5f)).x;'
 
21
unroll $size 'slice[(idy + get_local_size(1) * i) * slice_width +  idx + get_local_size(0) * j] = res[i][j];'
 
22
unroll $size 'res[i][j] += subh_cache(h + (i * get_local_size(0)) * all.y + (j * get_local_size(0)) * all.x);'
 
23
unroll $size 'subh = h + (i * get_local_size(0)) * all.y + (j * get_local_size(0)) * all.x; isubh = floor(subh); v = subh_cache(isubh); res[i][j] += v.x + (subh - isubh) * v.y;'