"...amoeba/platforms/cuda-old/src/kernels/amoebaCudaKernels.h" did not exist on "80c4976e8b1905689ebac718a6b255e0c6827ad5"
gbsaObcReductions.cc 2.88 KB
Newer Older
1
2
#define DIELECTRIC_OFFSET 0.009f
#define PROBE_RADIUS 0.14f
3
4
5
6
7

/**
 * Reduce the Born sums to compute the Born radii.
 */

8
KERNEL void reduceBornSum(float alpha, float beta, float gamma,
9
#ifdef SUPPORTS_64_BIT_ATOMICS
10
            GLOBAL const mm_long* RESTRICT bornSum,
11
#else
12
            GLOBAL const real* RESTRICT bornSum, int bufferSize, int numBuffers,
13
#endif
14
15
            GLOBAL const float2* RESTRICT params, GLOBAL real* RESTRICT bornRadii, GLOBAL real* RESTRICT obcChain) {
    for (unsigned int index = GLOBAL_ID; index < NUM_ATOMS; index += GLOBAL_SIZE) {
16
17
        // Get summed Born data

18
#ifdef SUPPORTS_64_BIT_ATOMICS
19
        real sum = RECIP((real) 0x100000000)*bornSum[index];
20
#else
21
        real sum = bornSum[index];
22
        int totalSize = bufferSize*numBuffers;
23
24
        for (int i = index+bufferSize; i < totalSize; i += bufferSize)
            sum += bornSum[i];
25
#endif
26
27
28
29
30

        // Now calculate Born radius and OBC term.

        float offsetRadius = params[index].x;
        sum *= 0.5f*offsetRadius;
31
32
33
34
        real sum2 = sum*sum;
        real sum3 = sum*sum2;
        real tanhSum = tanh(alpha*sum - beta*sum2 + gamma*sum3);
        real nonOffsetRadius = offsetRadius + DIELECTRIC_OFFSET;
35
        real radius = RECIP(RECIP(offsetRadius) - tanhSum/nonOffsetRadius);
36
37
        real chain = offsetRadius*(alpha - 2*beta*sum + 3*gamma*sum2);
        chain = (1-tanhSum*tanhSum)*chain / nonOffsetRadius;
38
39
40
41
42
43
44
45
46
        bornRadii[index] = radius;
        obcChain[index] = chain;
    }
}

/**
 * Reduce the Born force.
 */

47
KERNEL void reduceBornForce(
48
#ifdef SUPPORTS_64_BIT_ATOMICS
49
50
51
            GLOBAL mm_long* RESTRICT bornForce,
#else
            GLOBAL real* bornForce, int bufferSize, int numBuffers,
52
#endif
53
            GLOBAL mixed* RESTRICT energyBuffer, GLOBAL const float2* RESTRICT params, GLOBAL const real* RESTRICT bornRadii, GLOBAL const real* RESTRICT obcChain) {
54
    mixed energy = 0;
55
56
    for (unsigned int index = GLOBAL_ID; index < NUM_ATOMS; index += GLOBAL_SIZE) {
        // Get summed Born force
57

58
#ifdef SUPPORTS_64_BIT_ATOMICS
59
        real force = RECIP((real) 0x100000000)*bornForce[index];
60
#else
61
        real force = bornForce[index];
62
        int totalSize = bufferSize*numBuffers;
63
64
        for (int i = index+bufferSize; i < totalSize; i += bufferSize)
            force += bornForce[i];
65
#endif
66
67
68
        // Now calculate the actual force

        float offsetRadius = params[index].x;
69
70
        real bornRadius = bornRadii[index];
        real r = offsetRadius+DIELECTRIC_OFFSET+PROBE_RADIUS;
71
        real ratio6 = POW((offsetRadius+DIELECTRIC_OFFSET)/bornRadius, (real) 6);
72
        real saTerm = SURFACE_AREA_FACTOR*r*r*ratio6;
73
74
75
        force += saTerm/bornRadius;
        energy += saTerm;
        force *= bornRadius*bornRadius*obcChain[index];
76
#ifdef SUPPORTS_64_BIT_ATOMICS
77
        bornForce[index] = realToFixedPoint(force);
78
#else
79
        bornForce[index] = force;
80
#endif
81
    }
82
    energyBuffer[GLOBAL_ID] += energy/-6;
83
}