]> AND Private Git Repository - book_gpu.git/blob - BookGPU/Chapters/chapter17/code/collem_launcher.java
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
new ch5 reread
[book_gpu.git] / BookGPU / Chapters / chapter17 / code / collem_launcher.java
1 public void run() {
2                 newArrivalsKernel.setArguments(worldMem, patchesPopulationsMem, patchesOwnersMem, plotsPopulationsMem, plotsSurfacesMem);
3                 reproduceKernel.setArguments(worldMem, patchesPopulationsMem, patchesOwnersMem, plotsPopulationsMem);
4                 diffuseKernel.setArguments(worldMem, patchesPopulationsMem, patchesOverflowsMem, newPopulationsMem);
5                 deathKernel.setArguments(worldMem, patchesPopulationsMem, patchesTypesMem);
6                 
7                 OCLEvent newArrivalFinished, reproduceFinished, diffuseFinished, copyFinished, deathFinished;
8                 
9                 int i = 1;
10                 
11                 OCLChrono totalTime = new OCLChrono("totalTime");
12                 totalTime.start();
13                 
14                 while (true) {
15                         newArrivalFinished = enqueueKernel(newArrivalsKernel);
16                         reproduceFinished = enqueueKernel(reproduceKernel, newArrivalFinished);
17                         diffuseFinished = enqueueKernel(diffuseKernel, reproduceFinished);
18                         copyFinished = queue.enqueueCopyBuffer(newPopulationsMem, patchesPopulationsMem, 0L, 0L, patchesPopulationsMem.getSize(), diffuseFinished);
19                         OCLEvent.waitFor(copyFinished);
20                         deathFinished = enqueueKernel(deathKernel, copyFinished);
21                         
22                         queue.blockingReadBuffer(plotsPopulationsMem, Pointer.to(plotsPopulations), 0, plotsPopulationsMem.getSize(), deathFinished);
23                         queue.blockingReadBuffer(patchesPopulationsMem, Pointer.to(patchesPopulations), 0, patchesPopulationsMem.getSize(), deathFinished);
24                         queue.blockingReadBuffer(patchesOverflowsMem, Pointer.to(patchesOverflows), 0, patchesOverflowsMem.getSize(), deathFinished);
25                         
26                         i++;
27                         
28                         if (i == 100) break;
29                 }
30