From 53e2c5cac1d960b866628adf973dd3e332f2c6fd Mon Sep 17 00:00:00 2001
From: Bram Veenboer <bram.veenboer@gmail.com>
Date: Thu, 1 Apr 2021 08:02:53 +0200
Subject: [PATCH] Create a plan only once in benchmarking

This prevents duplicate memory initialization and more closely resembles
how the library is used in practice.
---
 bin/benchmark/bench.hpp | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/bin/benchmark/bench.hpp b/bin/benchmark/bench.hpp
index 3b882f2..db5af69 100644
--- a/bin/benchmark/bench.hpp
+++ b/bin/benchmark/bench.hpp
@@ -346,17 +346,17 @@ int run(BenchParameters & benchParameter)
   }
   tinit->Pause();
 
+  if(benchParameter.verbose) printf("Create plan and init GPU\n");
+  // Create a dedispersion plan
+  tplan->Start();
+  PlanType plan(nchans, dt, f0, df, device_idx);
+  tplan->Pause();
+
   for(int iPlan = 0; iPlan < benchParameter.niterations; iPlan++)
   {
-    tplan->Start();
-
     printf("\n");
     printf("------------------------- ITERATION %d out of %d  -------------------------\n", iPlan+1, benchParameter.niterations);
 
-    if(benchParameter.verbose) printf("Create plan and init GPU\n");
-    // Create a dedispersion plan
-    PlanType plan(nchans, dt, f0, df, device_idx);
-
     if(benchParameter.verbose) printf("Gen DM list\n");
     // Generate a list of dispersion measures for the plan
     if (dm_count==0)
@@ -391,7 +391,6 @@ int run(BenchParameters & benchParameter)
       printf("\n");
     }
 
-    tplan->Pause();
     texecute->Start();
 
     printf("\n");
-- 
GitLab