customIntegratorPerDof.cl 1.57 KB
Newer Older
1
2
3
4
#ifdef SUPPORTS_DOUBLE_PRECISION
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
#endif

5
6
__kernel void computePerDof(__global float4* restrict posq, __global float4* restrict posDelta, __global float4* restrict velm,
        __global const float4* restrict force, __global const float2* restrict dt, __global const float* restrict globals,
7
8
        __global const float* restrict params, __global float* restrict sum, __global const float4* restrict gaussianValues,
        unsigned int randomIndex, __global const float4* restrict uniformValues, __global const float* restrict energy
9
10
11
12
13
        PARAMETER_ARGUMENTS) {
    float stepSize = dt[0].y;
    int index = get_global_id(0);
    randomIndex += index;
    while (index < NUM_ATOMS) {
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifdef SUPPORTS_DOUBLE_PRECISION
#ifdef LOAD_POS_AS_DELTA
        double4 position = convert_double4(posq[index]+posDelta[index]);
#else
        double4 position = convert_double4(posq[index]);
#endif
        double4 velocity = convert_double4(velm[index]);
        double4 f = convert_double4(force[index]);
        double mass = 1.0/velocity.w;
#else
#ifdef LOAD_POS_AS_DELTA
        float4 position = posq[index]+posDelta[index];
#else
27
        float4 position = posq[index];
28
#endif
29
30
31
        float4 velocity = velm[index];
        float4 f = force[index];
        float mass = 1.0f/velocity.w;
32
#endif
33
34
35
36
37
        if (velocity.w != 0.0) {
            float4 gaussian = gaussianValues[randomIndex];
            float4 uniform = uniformValues[index];
            COMPUTE_STEP
        }
38
39
40
41
        randomIndex += get_global_size(0);
        index += get_global_size(0);
    }
}