From 68f74b816c6f6e489a3d348cd34153c2cf240942 Mon Sep 17 00:00:00 2001
From: "Timothy A. Smith" <tasmith4@illinois.edu>
Date: Wed, 19 Jun 2019 22:08:12 -0500
Subject: [PATCH] move benchmark array generation to test-local functions

---
 benchmark.py | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/benchmark.py b/benchmark.py
index 444b689..b48c19c 100644
--- a/benchmark.py
+++ b/benchmark.py
@@ -17,15 +17,13 @@ from pyopencl.tools import (  # noqa
 from utilities import *
 
 
-def setup_random_array(*shape):
-    return np.random.random_sample(shape).astype(np.float32).copy(order="F")
-
-
-def setup_random_array_on_device(queue, *shape):
-    return cl.array.to_device(queue, setup_random_array(*shape))
-
-
 def benchmark_compute_flux_derivatives_gpu(ctx_factory):
+    def random_array_on_device(queue, *shape):
+        return cl.array.to_device(queue, random_array(*shape))
+    
+    def random_array(*shape):
+        return np.random.random_sample(shape).astype(np.float32).copy(order="F")
+
     logging.basicConfig(level="INFO")
 
     prg = get_weno_program()
@@ -41,10 +39,10 @@ def benchmark_compute_flux_derivatives_gpu(ctx_factory):
     nz = n
 
     print("ARRAY GEN")
-    states = setup_random_array_on_device(queue, nvars, nx+6, ny+6, nz+6)
-    fluxes = setup_random_array_on_device(queue, nvars, ndim, nx+6, ny+6, nz+6)
-    metrics = setup_random_array_on_device(queue, ndim, ndim, nx+6, ny+6, nz+6)
-    metric_jacobians = setup_random_array_on_device(queue, nx+6, ny+6, nz+6)
+    states = random_array_on_device(queue, nvars, nx+6, ny+6, nz+6)
+    fluxes = random_array_on_device(queue, nvars, ndim, nx+6, ny+6, nz+6)
+    metrics = random_array_on_device(queue, ndim, ndim, nx+6, ny+6, nz+6)
+    metric_jacobians = random_array_on_device(queue, nx+6, ny+6, nz+6)
     print("END ARRAY GEN")
 
     flux_derivatives_dev = cl.array.empty(queue, (nvars, ndim, nx+6, ny+6,
-- 
GitLab