customIntegratorPerDof.cl 1.99 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
28
29
__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,
        __global const mixed* restrict params, __global mixed* restrict sum, __global const float4* restrict gaussianValues,
        unsigned int randomIndex, __global const float4* restrict uniformValues, __global const real* restrict energy
30
        PARAMETER_ARGUMENTS) {
31
    mixed stepSize = dt[0].y;
32
33
34
    int index = get_global_id(0);
    randomIndex += index;
    while (index < NUM_ATOMS) {
35
#ifdef LOAD_POS_AS_DELTA
36
        mixed4 position = loadPos(posq, posqCorrection, index)+posDelta[index];
37
#else
38
        mixed4 position = loadPos(posq, posqCorrection, index);
39
#endif
40
41
42
        mixed4 velocity = velm[index];
        real4 f = force[index];
        mixed mass = 1/velocity.w;
43
44
45
46
47
        if (velocity.w != 0.0) {
            float4 gaussian = gaussianValues[randomIndex];
            float4 uniform = uniformValues[index];
            COMPUTE_STEP
        }
48
49
50
51
        randomIndex += get_global_size(0);
        index += get_global_size(0);
    }
}