@@ -40,7 +40,7 @@ class TestSource1
4040{
4141public:
4242 static const ISAAC_IDX_TYPE featureDim = 3 ;
43- static const bool hasGuard = false ;
43+ static const ISAAC_IDX_TYPE guardSize = 0 ;
4444 static const bool persistent = true ;
4545
4646
@@ -78,7 +78,7 @@ class TestSource2
7878{
7979public:
8080 static const ISAAC_IDX_TYPE featureDim = 1 ;
81- static const bool hasGuard = false ;
81+ static const ISAAC_IDX_TYPE guardSize = 0 ;
8282 static const bool persistent = false ;
8383
8484
@@ -108,6 +108,40 @@ class TestSource2
108108 }
109109};
110110
111+ ISAAC_NO_HOST_DEVICE_WARNING
112+ class TestVectorFieldSource1
113+ {
114+ public:
115+ static const ISAAC_IDX_TYPE featureDim = 3 ;
116+ static const ISAAC_IDX_TYPE guardSize = 0 ;
117+ static const bool persistent = true ;
118+
119+
120+ ISAAC_NO_HOST_DEVICE_WARNING TestVectorFieldSource1 (isaac_float3* ptr) : ptr(ptr)
121+ {
122+ }
123+
124+
125+ ISAAC_HOST_INLINE static std::string getName ()
126+ {
127+ return std::string (" Test Vector Field Source" );
128+ }
129+
130+
131+ ISAAC_HOST_INLINE void update (bool enabled, void * pointer)
132+ {
133+ }
134+
135+
136+ isaac_float3* ptr;
137+
138+ ISAAC_NO_HOST_DEVICE_WARNING ISAAC_HOST_DEVICE_INLINE isaac_float3 operator [](const isaac_int3& nIndex) const
139+ {
140+ isaac_float3 value = ptr[nIndex.x + nIndex.y * VOLUME_X + nIndex.z * VOLUME_X * VOLUME_Y];
141+ return value;
142+ }
143+ };
144+
111145
112146// Particle Iterator
113147
@@ -250,10 +284,8 @@ int main(int argc, char** argv)
250284
251285 using Acc = alpaka::AccGpuCudaRt<AccDim, ISAAC_IDX_TYPE>;
252286
253- // using Acc = alpaka::AccCpuOmp2Blocks<
254- // AccDim,
255- // ISAAC_IDX_TYPE
256- // >;
287+ // using Acc = alpaka::AccCpuOmp2Blocks<AccDim, ISAAC_IDX_TYPE>;
288+
257289 using Stream = alpaka::Queue<Acc, alpaka::Blocking>;
258290
259291 using DevAcc = alpaka::Dev<Acc>;
@@ -265,14 +297,11 @@ int main(int argc, char** argv)
265297 DevHost devHost (alpaka::getDevByIdx<PltfHost>(0u ));
266298 Stream stream (devAcc);
267299
268- const isaac_size_dim<SimDim::value> globalSize (d[0 ] * VOLUME_X, d[1 ] * VOLUME_Y, d[2 ] * VOLUME_Z);
269- const isaac_size_dim<SimDim::value> localSize (
270- ISAAC_IDX_TYPE (VOLUME_X),
271- ISAAC_IDX_TYPE (VOLUME_Y),
272- ISAAC_IDX_TYPE (VOLUME_Z));
300+ const isaac_size3 globalSize (d[0 ] * VOLUME_X, d[1 ] * VOLUME_Y, d[2 ] * VOLUME_Z);
301+ const isaac_size3 localSize (ISAAC_IDX_TYPE (VOLUME_X), ISAAC_IDX_TYPE (VOLUME_Y), ISAAC_IDX_TYPE (VOLUME_Z));
302+ const isaac_size3 position (p[0 ] * VOLUME_X, p[1 ] * VOLUME_Y, p[2 ] * VOLUME_Z);
273303 const alpaka::Vec<DatDim, ISAAC_IDX_TYPE> dataSize (
274304 ISAAC_IDX_TYPE (VOLUME_X) * ISAAC_IDX_TYPE (VOLUME_Y) * ISAAC_IDX_TYPE (VOLUME_Z));
275- const isaac_size_dim<SimDim::value> position (p[0 ] * VOLUME_X, p[1 ] * VOLUME_Y, p[2 ] * VOLUME_Z);
276305 const alpaka::Vec<alpaka::DimInt<1 >, ISAAC_IDX_TYPE> particleCount (ISAAC_IDX_TYPE (PARTICLE_COUNT));
277306
278307 // The whole size of the rendered sub volumes
@@ -282,29 +311,39 @@ int main(int argc, char** argv)
282311
283312 auto hostBuffer1 = alpaka::allocBuf<isaac_float3, ISAAC_IDX_TYPE>(devHost, dataSize);
284313 auto deviceBuffer1 = alpaka::allocBuf<isaac_float3, ISAAC_IDX_TYPE>(devAcc, dataSize);
314+
285315 auto hostBuffer2 = alpaka::allocBuf<isaac_float, ISAAC_IDX_TYPE>(devHost, dataSize);
286316 auto deviceBuffer2 = alpaka::allocBuf<isaac_float, ISAAC_IDX_TYPE>(devAcc, dataSize);
287- auto hostBuffer3 = alpaka::allocBuf<isaac_float3, ISAAC_IDX_TYPE>(devHost, particleCount);
288- auto deviceBuffer3 = alpaka::allocBuf<isaac_float3, ISAAC_IDX_TYPE>(devAcc, particleCount);
317+
318+ auto hostBuffer3 = alpaka::allocBuf<isaac_float3, ISAAC_IDX_TYPE>(devHost, dataSize);
319+ auto deviceBuffer3 = alpaka::allocBuf<isaac_float3, ISAAC_IDX_TYPE>(devAcc, dataSize);
320+
321+ auto hostBuffer4 = alpaka::allocBuf<isaac_float3, ISAAC_IDX_TYPE>(devHost, particleCount);
322+ auto deviceBuffer4 = alpaka::allocBuf<isaac_float3, ISAAC_IDX_TYPE>(devAcc, particleCount);
289323
290324 // Creating source list
291325
292326 TestSource1 testSource1 (alpaka::getPtrNative (deviceBuffer1));
293327 TestSource2 testSource2 (alpaka::getPtrNative (deviceBuffer2));
294328
295- ParticleSource1 particleTestSource1 (alpaka::getPtrNative (deviceBuffer3), PARTICLE_COUNT);
329+ TestVectorFieldSource1 fieldSource (alpaka::getPtrNative (deviceBuffer3));
330+
331+ ParticleSource1 particleTestSource1 (alpaka::getPtrNative (deviceBuffer4), PARTICLE_COUNT);
296332
297- using SourceList = boost::fusion::list<TestSource1, TestSource2>;
333+ using VolumeSourceList = boost::fusion::list<TestSource1, TestSource2, TestVectorFieldSource1>;
334+
335+ using FieldSourceList = boost::fusion::list<TestVectorFieldSource1>;
298336
299337 using ParticleList = boost::fusion::list<ParticleSource1>;
300338
339+ VolumeSourceList volumeSources (testSource1, testSource2, fieldSource);
340+ FieldSourceList fieldSources (fieldSource);
301341 ParticleList particleSources (particleTestSource1);
302- SourceList sources (testSource1, testSource2);
303342
304343#if ISAAC_NO_SIMULATION == 1
305344 if (!filename)
306345 {
307- update_data (
346+ updateData (
308347 stream,
309348 hostBuffer1,
310349 deviceBuffer1,
@@ -317,7 +356,7 @@ int main(int argc, char** argv)
317356 globalSize);
318357 }
319358
320- update_particles (stream, hostBuffer3, deviceBuffer3 , particleCount, 0 .0f );
359+ updateParticles (stream, hostBuffer4, deviceBuffer4 , particleCount, 0 .0f );
321360
322361
323362#endif
@@ -349,8 +388,9 @@ int main(int argc, char** argv)
349388 Acc, // Alpaka specific Accelerator Dev Type
350389 Stream, // Alpaka specific Stream Type
351390 AccDim, // Alpaka specific Acceleration Dimension Type
391+ VolumeSourceList, // The boost::fusion list of Source Types
392+ FieldSourceList,
352393 ParticleList,
353- decltype (sources), // The boost::fusion list of Source Types
354394 1024 , // Size of the transfer functions
355395#if (ISAAC_STEREO == 0)
356396 isaac::DefaultController,
@@ -377,8 +417,9 @@ int main(int argc, char** argv)
377417 localSize, // Local size of the subvolume
378418 {PARTICLE_VOLUME_X, PARTICLE_VOLUME_Y, PARTICLE_VOLUME_Z},
379419 position, // Position of the subvolume in the globale volume
420+ volumeSources, // instances of the volumeSources to render
421+ fieldSources,
380422 particleSources,
381- sources, // instances of the sources to render
382423 scaling);
383424
384425 // Setting up the metadata description (only master, but however slaves could then add metadata, too, it would be
@@ -407,7 +448,7 @@ int main(int argc, char** argv)
407448 // Program flow and time mesaurment variables
408449 float a = 0 .0f ;
409450 volatile int forceExit = 0 ;
410- int start = visualization-> getTicksUs ();
451+ int start = getTicksUs ();
411452 int count = 0 ;
412453 int drawingTime = 0 ;
413454 int simulationTime = 0 ;
@@ -419,6 +460,9 @@ int main(int argc, char** argv)
419460 int copyTime = 0 ;
420461 int videoSendTime = 0 ;
421462 int bufferTime = 0 ;
463+ int advectionTime = 0 ;
464+ int advectionBorderTime = 0 ;
465+ int optimizationBufferTime = 0 ;
422466 bool pause = false ;
423467 // How often should the visualization be updated?
424468 int interval = 1 ;
@@ -427,19 +471,26 @@ int main(int argc, char** argv)
427471 {
428472 json_object_set_new (visualization->getJsonMetaRoot (), " interval" , json_integer (interval));
429473 }
474+ isaac::Neighbours<isaac_int> neighbourIds;
475+ for (int i = 0 ; i < 27 ; i++)
476+ {
477+ neighbourIds.array [i] = -1 ;
478+ }
430479
480+ visualization->updateNeighbours (neighbourIds);
481+ // pause = true;
431482 // Main loop
432483 while (!forceExit)
433484 {
434485 // "Simulation"
435486 if (!pause)
436487 {
437488 a += 0 .01f ;
438- int startSimulation = visualization-> getTicksUs ();
489+ int startSimulation = getTicksUs ();
439490#if ISAAC_NO_SIMULATION == 0
440491 if (!filename)
441492 {
442- update_data (
493+ updateData (
443494 stream,
444495 hostBuffer1,
445496 deviceBuffer1,
@@ -452,12 +503,14 @@ int main(int argc, char** argv)
452503 globalSize);
453504 }
454505
455- update_particles (stream, hostBuffer3, deviceBuffer3, particleCount, a);
506+ updateVectorField (stream, hostBuffer3, deviceBuffer3, a, localSize, position, globalSize);
507+
508+ updateParticles (stream, hostBuffer4, deviceBuffer4, particleCount, a);
456509
457510#endif
458511
459512
460- simulationTime += visualization-> getTicksUs () - startSimulation;
513+ simulationTime += getTicksUs () - startSimulation;
461514 }
462515 step++;
463516 if (step >= interval)
@@ -502,20 +555,17 @@ int main(int argc, char** argv)
502555 copyTime += visualization->copyTime ;
503556 videoSendTime += visualization->videoSendTime ;
504557 bufferTime += visualization->bufferTime ;
558+ advectionTime += visualization->advectionTime ;
559+ advectionBorderTime += visualization->advectionBorderTime ;
560+ optimizationBufferTime += visualization->optimizationBufferTime ;
505561 drawingTime = 0 ;
506562 simulationTime = 0 ;
507- visualization->sortingTime = 0 ;
508- visualization->mergeTime = 0 ;
509- visualization->kernelTime = 0 ;
510- visualization->copyTime = 0 ;
511- visualization->videoSendTime = 0 ;
512- visualization->bufferTime = 0 ;
513563 }
514564
515565 // Visualization
516- int start_drawing = visualization-> getTicksUs ();
566+ int start_drawing = getTicksUs ();
517567 json_t * meta = visualization->doVisualization (META_MASTER, NULL , !pause);
518- drawingTime += visualization-> getTicksUs () - start_drawing;
568+ drawingTime += getTicksUs () - start_drawing;
519569
520570 // Message check
521571 if (meta)
@@ -552,17 +602,17 @@ int main(int argc, char** argv)
552602 // Debug output
553603 if (rank == 0 )
554604 {
555- int end = visualization-> getTicksUs ();
605+ int end = getTicksUs ();
556606 int diff = end - start;
557607 if (diff >= 1000000 )
558608 {
559- mergeTime -= kernelTime + copyTime;
560609 printf (
561610 " FPS: %.1f \n\t Simulation: %.1f ms\n\t "
562611 " Drawing: %.1f ms\n\t\t Sorting: %.1f ms\n\t\t "
563612 " Merge: %.1f ms\n\t\t Kernel: %.1f ms\n\t\t "
564613 " Copy: %.1f ms\n\t\t Video: %.1f ms\n\t\t "
565- " Buffer: %.1f ms\n " ,
614+ " Buffer: %.1f ms\n\t\t Advection: %.1f ms\n\t\t "
615+ " Advection Border: %.1f ms\n\t\t Optimization Buffer: %.1f ms\n " ,
566616 (float ) count * 1000000 .0f / (float ) diff,
567617 (float ) fullSimulationTime / 1000 .0f / (float ) count,
568618 (float ) fullDrawingTime / 1000 .0f / (float ) count,
@@ -571,13 +621,19 @@ int main(int argc, char** argv)
571621 (float ) kernelTime / 1000 .0f / (float ) count,
572622 (float ) copyTime / 1000 .0f / (float ) count,
573623 (float ) videoSendTime / 1000 .0f / (float ) count,
574- (float ) bufferTime / 1000 .0f / (float ) count);
624+ (float ) bufferTime / 1000 .0f / (float ) count,
625+ (float ) advectionTime / 1000 .0f / (float ) count,
626+ (float ) advectionBorderTime / 1000 .0f / (float ) count,
627+ (float ) optimizationBufferTime / 1000 .0f / (float ) count);
575628 sortingTime = 0 ;
576629 mergeTime = 0 ;
577630 kernelTime = 0 ;
578631 copyTime = 0 ;
579632 videoSendTime = 0 ;
580633 bufferTime = 0 ;
634+ advectionTime = 0 ;
635+ advectionBorderTime = 0 ;
636+ optimizationBufferTime = 0 ;
581637 fullDrawingTime = 0 ;
582638 fullSimulationTime = 0 ;
583639 start = end;
0 commit comments