customGBValuePerParticle.cl 877 Bytes
Newer Older
1
2
3
4
/**
 * Reduce a pairwise computed value, and compute per-particle values.
 */

5
__kernel void computePerParticleValues(int bufferSize, int numBuffers, __global real4* posq,
6
7
8
#ifdef SUPPORTS_64_BIT_ATOMICS
        __global long* valueBuffers
#else
9
        __global real* valueBuffers
10
#endif
11
12
13
14
15
        PARAMETER_ARGUMENTS) {
    unsigned int index = get_global_id(0);
    while (index < NUM_ATOMS) {
        // Reduce the pairwise value

16
#ifdef SUPPORTS_64_BIT_ATOMICS
17
        real sum = (1.0f/0xFFFFFFFF)*valueBuffers[index];
18
#else
19
        int totalSize = bufferSize*numBuffers;
20
        real sum = valueBuffers[index];
21
22
        for (int i = index+bufferSize; i < totalSize; i += bufferSize)
            sum += valueBuffers[i];
23
24
#endif
        
25
26
        // Now calculate other values

27
        real4 pos = posq[index];
28
29
30
31
        COMPUTE_VALUES
        index += get_global_size(0);
    }
}