OldMiorKernel.java
3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package mior;
public class OldMiorKernel {
public final static String topographyKernel = "" +
"typedef struct { \n" +
" float x; \n" +
" float y; \n" +
" int carbone; \n" +
" int dormance; \n" +
"} MM; \n" +
"typedef struct { \n" +
" float x; \n" +
" float y; \n" +
" int carbone; \n" +
"} OM; \n" +
"typedef struct { \n" +
" int nbMM; \n" +
" int nbOM; \n" +
" int radius; \n" +
" float respirationRate; \n" +
" float growRate; \n" +
" float killRate; \n" +
" int width; \n" +
" int minSize; \n" +
"} MiorWorld; \n" +
"kernel void topography( \n" +
" global MM *mmList, \n" +
" global OM *omList, \n" +
" global int *topo, \n" +
" constant MiorWorld *world) { \n" +
" int iMM = get_global_id(0); \n" +
" int iOM = get_global_id(1); \n" +
" int index = iMM * world->nbOM + iOM; \n" +
" float dx = omList[iOM].x - mmList[iMM].x; " +
" float dy = omList[iOM].y - mmList[iMM].y; \n" +
" float distance = sqrt(dx * dx + dy * dy); \n" +
" if (distance <= world->radius) { \n" +
" topo[index] = distance; \n" +
" } else { \n" +
" topo[index] = 0; \n" +
" }; //topo[index] = distance;\n" +
" \n" +
"}\n";
}