customIntegratorPerDof.cl 1.84 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/**
 * Load the position of a particle.
 */
mixed4 loadPos(__global const real4* restrict posq, __global const real4* restrict posqCorrection, int index) {
#ifdef USE_MIXED_PRECISION
    real4 pos1 = posq[index];
    real4 pos2 = posqCorrection[index];
    return (mixed4) (pos1.x+(mixed)pos2.x, pos1.y+(mixed)pos2.y, pos1.z+(mixed)pos2.z, pos1.w);
#else
    return posq[index];
#endif
}

/**
 * Store the position of a particle.
 */
void storePos(__global real4* restrict posq, __global real4* restrict posqCorrection, int index, mixed4 pos) {
#ifdef USE_MIXED_PRECISION
    posq[index] = (real4) ((real) pos.x, (real) pos.y, (real) pos.z, (real) pos.w);
    posqCorrection[index] = (real4) (pos.x-(real) pos.x, pos.y-(real) pos.y, pos.z-(real) pos.z, 0);
#else
    posq[index] = pos;
23
#endif
24
}
25

26
27
__kernel void computePerDof(__global real4* restrict posq, __global real4* restrict posqCorrection, __global mixed4* restrict posDelta,
        __global mixed4* restrict velm, __global const real4* restrict force, __global const mixed2* restrict dt, __global const mixed* restrict globals,
28
        __global mixed* restrict sum, __global const float4* restrict gaussianValues, unsigned int gaussianBaseIndex, __global const float4* restrict uniformValues, const real energy
29
        PARAMETER_ARGUMENTS) {
30
    mixed stepSize = dt[0].y;
31
32
    int index = get_global_id(0);
    while (index < NUM_ATOMS) {
33
#ifdef LOAD_POS_AS_DELTA
34
        mixed4 position = loadPos(posq, posqCorrection, index)+posDelta[index];
35
#else
36
        mixed4 position = loadPos(posq, posqCorrection, index);
37
#endif
38
39
40
        mixed4 velocity = velm[index];
        real4 f = force[index];
        mixed mass = 1/velocity.w;
41
        if (velocity.w != 0.0) {
42
43
            int gaussianIndex = gaussianBaseIndex;
            int uniformIndex = 0;
44
45
            COMPUTE_STEP
        }
46
47
48
        index += get_global_size(0);
    }
}