From 7250af83c340a46dbef5c14bee5875891fca7111 Mon Sep 17 00:00:00 2001 From: Jean-Matthieu Etancelin <jean-matthieu.etancelin@imag.fr> Date: Fri, 14 Sep 2012 09:10:47 +0000 Subject: [PATCH] Add other timings printings --- HySoP/hysop/operator/continuous.py | 5 ++++- HySoP/hysop/operator/discrete.py | 6 ++++-- HySoP/hysop/operator/remeshing.py | 5 ++++- HySoP/hysop/operator/splitting.py | 4 ++++ HySoP/hysop/operator/transport_d.py | 12 ++++++++---- HySoP/hysop/particular_solvers/gpu.py | 7 +++++++ HySoP/hysop/particular_solvers/gpu_src.cl | 2 +- HySoP/hysop/problem/problem.py | 9 ++++++++- 8 files changed, 40 insertions(+), 10 deletions(-) diff --git a/HySoP/hysop/operator/continuous.py b/HySoP/hysop/operator/continuous.py index f3500bb2a..89a6871ce 100644 --- a/HySoP/hysop/operator/continuous.py +++ b/HySoP/hysop/operator/continuous.py @@ -24,6 +24,8 @@ class ContinuousOperator: self.discreteOperator = None ## Is need to split operator self.needSplitting = False + ## Timings informations + self.timings_info = ["", ""] def addVariable(self, cVariable): """ @@ -58,6 +60,7 @@ class ContinuousOperator: """Displays compute time for operator.""" if self.discreteOperator is not None: self.discreteOperator.printComputeTime() + self.timings_info = self.discreteOperator.timings_info else: raise ValueError("Cannot print compute time of a non discretized operator") @@ -69,7 +72,7 @@ class ContinuousOperator: @param *spec : discretization specifications. """ - raise NotImplementedError("Need to override method in a subclass of " + providedClass) + raise NotImplementedError("Need to override method in a subclass of ContinuousOperator") if __name__ == "__main__": print __doc__ diff --git a/HySoP/hysop/operator/discrete.py b/HySoP/hysop/operator/discrete.py index bcdeb809b..3160a4a27 100644 --- a/HySoP/hysop/operator/discrete.py +++ b/HySoP/hysop/operator/discrete.py @@ -32,6 +32,8 @@ class DiscreteOperator: self.total_time = 0. ## Operator name self.name = "?" + ## Timings informations + self.timings_info = ["", ""] def setMethod(self, method): """ @@ -54,7 +56,7 @@ class DiscreteOperator: @abstractmethod def printComputeTime(self): """Print total computing time.""" - raise NotImplementedError("Need to override method in a subclass of " + providedClass) + raise NotImplementedError("Need to override method in a subclass of DiscreteOperator") @abstractmethod def apply(self): @@ -62,7 +64,7 @@ class DiscreteOperator: Abstract method, apply operaton on a variable. Must be implemented by sub-class. """ - raise NotImplementedError("Need to override method in a subclass of " + providedClass) + raise NotImplementedError("Need to override method in a subclass of DiscreteOperator") def __str__(self): """ToString method""" diff --git a/HySoP/hysop/operator/remeshing.py b/HySoP/hysop/operator/remeshing.py index af65a1516..d8afc7ee2 100644 --- a/HySoP/hysop/operator/remeshing.py +++ b/HySoP/hysop/operator/remeshing.py @@ -62,13 +62,16 @@ class Remeshing(DiscreteOperator): for df in self.output: df.contains_data = False # Get timpings from OpenCL events - self.numMethod.queue.finish() + self.numMethod.finish() c_time += (evt.profile.end - evt.profile.start) * 1e-9 self.compute_time[splittingDirection] += c_time self.total_time += c_time return c_time def printComputeTime(self): + self.timings_info[0] = "\"Remeshing total\" \"Remeshing x\" \"Remeshing y\" \"Remeshing z\" " + self.timings_info[1] = str(self.total_time) + " " + str(self.compute_time[0]) + " " + self.timings_info[1] += str(self.compute_time[1]) + " " + str(self.compute_time[2]) + " " print "Remeshing total time : ", self.total_time print "\t Remeshing: ", self.compute_time diff --git a/HySoP/hysop/operator/splitting.py b/HySoP/hysop/operator/splitting.py index 21908dff6..50fe86aba 100644 --- a/HySoP/hysop/operator/splitting.py +++ b/HySoP/hysop/operator/splitting.py @@ -70,9 +70,13 @@ class Splitting(DiscreteOperator): def printComputeTime(self): print "Splitting total time : ", self.total_time + self.timings_info[0] = "\"Splitting total\" " + self.timings_info[1] = str(self.total_time) + " " for op in self.operators: print " ", op.printComputeTime() + self.timings_info[0] += op.timings_info[0] + self.timings_info[1] += op.timings_info[1] def __str__(self): s = "Splitting (DiscreteOperator). Splitting steps : \n" diff --git a/HySoP/hysop/operator/transport_d.py b/HySoP/hysop/operator/transport_d.py index 1ae5de69a..658d94cd7 100644 --- a/HySoP/hysop/operator/transport_d.py +++ b/HySoP/hysop/operator/transport_d.py @@ -46,7 +46,7 @@ class Transport_d(DiscreteOperator): ## Compute time for copy detailed per directions self.compute_time_copy = [0., 0., 0.] ## Compute time for transposition detailed per directions - self.compute_time_transpose = [0., 0., 0.] + self.compute_time_swap = [0., 0., 0.] self.name = "advection" def apply(self, t, dt, splittingDirection): @@ -93,22 +93,26 @@ class Transport_d(DiscreteOperator): for df in self.output: df.contains_data = False # Get timpings from OpenCL events - self.numMethod.queue.finish() + self.numMethod.finish() c_time_init = (evt_init.profile.end - evt_init.profile.start) * 1e-9 c_time = (evt.profile.end - evt.profile.start) * 1e-9 self.compute_time[splittingDirection] += c_time if (self.old_splitting_direction == splittingDirection) or self.old_splitting_direction is None: self.compute_time_copy[splittingDirection] += c_time_init else: - self.compute_time_transpose[min(self.old_splitting_direction, splittingDirection)] += c_time_init + self.compute_time_swap[min(self.old_splitting_direction, splittingDirection)] += c_time_init self.total_time += (c_time + c_time_init) self.old_splitting_direction = splittingDirection return (c_time + c_time_init) def printComputeTime(self): + self.timings_info[0] = "\"Advection total\" \"copy\" \"swap xy\" \"swap xz\" \"Advection x\" \"Advection y\" \"Advection z\" " + self.timings_info[1] = str(self.total_time) + " " + str(self.compute_time_copy[0]) + " " + self.timings_info[1] += str(self.compute_time_swap[0]) + " " + str(self.compute_time_swap[1]) + " " + self.timings_info[1] += str(self.compute_time[0]) + " " + str(self.compute_time[1]) + " " + str(self.compute_time[2]) + " " print "Advection total time : ", self.total_time print "\t Advection init copy :", self.compute_time_copy - print "\t Advection init transpose :", self.compute_time_transpose + print "\t Advection init swap :", self.compute_time_swap print "\t Advection :", self.compute_time def __str__(self): diff --git a/HySoP/hysop/particular_solvers/gpu.py b/HySoP/hysop/particular_solvers/gpu.py index f35c66ede..a81553e6e 100644 --- a/HySoP/hysop/particular_solvers/gpu.py +++ b/HySoP/hysop/particular_solvers/gpu.py @@ -363,6 +363,9 @@ class KernelListLauncher: evt = self.kernel[d](self.queue, *args) return evt + def finish(self): + self.queue.finish() + def function_name(self, d=None): """Prints OpenCL Kernels function names informations""" if d is not None: @@ -401,6 +404,10 @@ class KernelLauncher(KernelListLauncher): """ return KernelListLauncher.launch_sizes_in_args(self, 0, *args) + def finish(self): + """Wrapping OpenCL queue.finish() method.""" + self.queue.finish() + def launch(self, *args): """ Launch the kernel. diff --git a/HySoP/hysop/particular_solvers/gpu_src.cl b/HySoP/hysop/particular_solvers/gpu_src.cl index 6cc51af57..e1a8e9c8d 100644 --- a/HySoP/hysop/particular_solvers/gpu_src.cl +++ b/HySoP/hysop/particular_solvers/gpu_src.cl @@ -147,7 +147,7 @@ __kernel void advec_init_transpose_3D_02(__global const float* input, int input_index = local_x + block_x*GROUP_DIMX + block_y*WIDTH + (local_z+block_z*GROUP_DIMX)*WIDTH*WIDTH; int local_input = local_x + local_z*(GROUP_DIMX+1); int local_input_stride = GROUP_DIMY*(GROUP_DIMX+1); - int global_input_stride = GROUP_DIMY*WIDTH*WIDTH; + int global_input_stride = GROUP_DIMY*WIDTH*WIDTH; int output_index = local_x + block_z*GROUP_DIMX + block_y*(WIDTH + PADDING) + (local_z+block_x*GROUP_DIMX)*(WIDTH + PADDING)*(WIDTH + PADDING); int local_output = local_z + local_x*(GROUP_DIMX+1); diff --git a/HySoP/hysop/problem/problem.py b/HySoP/hysop/problem/problem.py index c6a0c659f..bceb93e69 100644 --- a/HySoP/hysop/problem/problem.py +++ b/HySoP/hysop/problem/problem.py @@ -39,6 +39,8 @@ class Problem(): self.timer = None ## IO manager self.io = None + ## Timings informations + self.timings_info = ["", ""] for op in self.operators: self.addVariable(op.variables) for v in self.variables: @@ -98,9 +100,14 @@ class Problem(): self.io.step() print "\n\n End solving\n" print "=== Timings ===" + print "IO total", self.io.compute_time + self.timings_info[0] += "\"IO\" " + self.timings_info[1] += str(self.io.compute_time) + " " for op in self.operators: op.printComputeTime() - print "IO time :", self.io.compute_time + self.timings_info[0] += op.timings_info[0] + self.timings_info[1] += op.timings_info[1] + print "\n" print "===\n" def addVariable(self, cVariable): -- GitLab