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

5
KERNEL void computePerParticleValues(GLOBAL real4* posq,
6
#ifdef SUPPORTS_64_BIT_ATOMICS
7
        GLOBAL mm_long* valueBuffers
8
#else
9
        GLOBAL real* valueBuffers, int bufferSize, int numBuffers
10
#endif
11
        PARAMETER_ARGUMENTS) {
12
    for (int index = GLOBAL_ID; index < NUM_ATOMS; index += GLOBAL_SIZE) {
13
14
        // Reduce the pairwise value

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

27
        real4 pos = posq[index];
28
29
30
        COMPUTE_VALUES
    }
}