@@ -277,7 +277,7 @@ namespace {
277277 }
278278 }
279279
280- TEST (ComputeThreshold, PIPELINE_TEST_GRADIENT_LIS_LEVELS_GpuProcessingTask ) {
280+ TEST (ComputeThreshold, FULL_PIPELINE_TEST_CPU_vs_GpuProcessingTask ) {
281281 APRTimer timer (true );
282282
283283 // TODO: This tets fails if dim of input image is smaller than ~8 (not sure in which direction yet)
@@ -288,11 +288,15 @@ namespace {
288288 // Generate random mesh of two sizes very small and reasonable large to catch all possible computation errors
289289 using ImageType = float ;
290290 constexpr PixelDataDim dim1{4 , 4 , 3 };
291- constexpr PixelDataDim dim2{163 , 123 , 555 };
291+ constexpr PixelDataDim dim2{1024 , 512 , 512 };
292292 for (int d = 0 ; d <= 3 ; d++) {
293293 auto &dim = (d % 2 == 0 ) ? dim1 : dim2;
294294 PixelData<ImageType> input_image = (d / 2 == 0 ) ? getRandInitializedMesh<ImageType>(dim, 13 ) :
295- getMeshWithBlobInMiddle<ImageType>(dim);
295+ getMeshWithBlobInMiddle<ImageType>(dim);
296+
297+ // constexpr PixelDataDim dim = dim1;
298+ // PixelData<ImageType> input_image = getRandInitializedMesh<ImageType>(dim, 13);
299+
296300 int maxLevel = ceil (std::log2 (dim.maxDimSize ()));
297301
298302 // Initialize CPU data structures
@@ -321,32 +325,52 @@ namespace {
321325 par.dz = 1 ;
322326 par.neighborhood_optimization = true ;
323327
328+ GenInfo aprInfo (input_image.getDimension ());
329+ GenInfo giGpu (input_image.getDimension ());
330+
331+ // Calculate pipeline on CPU
324332 // Calculate pipeline on CPU
325333 timer.start_timer (" >>>>>>>>>>>>>>>>> CPU PIPELINE" );
326334 ComputeGradient ().get_gradient (mCpuImage , grad_temp, local_scale_temp, par);
327335 LocalIntensityScale ().get_local_intensity_scale (local_scale_temp, local_scale_temp2, par);
328336 LocalParticleCellSet lpcs = LocalParticleCellSet ();
329337 lpcs.computeLevels (grad_temp, local_scale_temp, maxLevel, par.rel_error , par.dx , par.dy , par.dz );
338+ PullingScheme ps;
339+ ps.initialize_particle_cell_tree (aprInfo);
340+ lpcs.get_local_particle_cell_set (ps, local_scale_temp, local_scale_temp2, par);
341+ ps.pulling_scheme_main ();
342+ LinearAccess linearAccess;
343+ linearAccess.genInfo = &aprInfo;
344+ linearAccess.initialize_linear_structure (par, ps.getParticleCellTree ());
330345 timer.stop_timer ();
331346
332347
333348 // Calculate pipeline on GPU
334349 timer.start_timer (" >>>>>>>>>>>>>>>>> GPU PIPELINE" );
335- {
336- GpuProcessingTask<ImageType> gpt (mGpuImage , local_scale_temp_GPU, par, 0 , maxLevel);
337- gpt.doAll ();
338- }
350+ // {
351+ GpuProcessingTask<ImageType> gpt (mGpuImage , local_scale_temp_GPU, par, 0 , maxLevel);
352+ gpt.sendDataToGpu ();
353+ gpt.processOnGpu ();
354+ auto linearAccessGpu = gpt.getDataFromGpu ();
355+ giGpu.total_number_particles = linearAccessGpu.y_vec .size ();
356+
357+ // }
339358 timer.stop_timer ();
340359
341360 // Compare GPU vs CPU - expect exactly same result
342- EXPECT_EQ (compareMeshes (local_scale_temp, local_scale_temp_GPU, 0 ), 0 );
361+ EXPECT_EQ (compareParticles (linearAccessGpu.y_vec , linearAccess.y_vec ), 0 );
362+ EXPECT_EQ (compareParticles (linearAccessGpu.level_xz_vec , linearAccess.level_xz_vec ), 0 );
363+ EXPECT_EQ (compareParticles (linearAccessGpu.xz_end_vec , linearAccess.xz_end_vec ), 0 );
364+
365+ EXPECT_EQ (aprInfo.total_number_particles , giGpu.total_number_particles );
366+ EXPECT_EQ (linearAccessGpu.y_vec .size (), linearAccess.y_vec .size ());
343367
344368 }
345369 }
370+
346371#endif // APR_USE_CUDA
347372}
348373
349-
350374int main (int argc, char **argv) {
351375 testing::InitGoogleTest (&argc, argv);
352376 return RUN_ALL_TESTS ();
0 commit comments