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

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

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

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