Skip to content

Commit

Permalink
Added default benchmarks to run without them
Browse files Browse the repository at this point in the history
  • Loading branch information
antmsbrito committed Aug 10, 2023
1 parent c6b7034 commit 13eb4ee
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/nanopyx/__agent__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,18 @@ def _get_ordered_run_types(self, fn, args, kwargs):
# What happens if there are no benchmarks for this runtype?
# Make it slow TODO
if best_repr_args is None:
print(f"run_type {run_type} has no benchmarks for the given args and kwargs.")
run_info = np.inf
run_info = [None]
else:
run_info = fn._benchmarks[run_type][best_repr_args][1:]

if len(run_info)<2:
# Fall back to default values
if 'OpenCL' in run_type:
rt = 'OpenCL'
else:
rt = run_type
run_info = fn._default_benchmarks[rt]

run_info = np.array(run_info)
if len(run_info)>50:
run_info = run_info[-50:]
Expand Down
2 changes: 1 addition & 1 deletion src/nanopyx/liquid/_le_DUMMY.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DUMMY(LiquidEngine):
opencl_=True, unthreaded_=True, threaded_=True, threaded_static_=True,
threaded_dynamic_=True, threaded_guided_=True)


self._default_benchmarks = {'OpenCL':[1,1,1],'Threaded':[2,2,2],'Threaded_static':[3,3,3],'Threaded_dynamic':[4,4,4],'Threaded_guided':[5,5,5],'Python':[6,6,6],'Numba':[7,7,7],'Unthreaded':[8,8,8]}

def run(self, run_type=None):
return self._run(run_type=run_type)
Expand Down
1 change: 1 addition & 0 deletions src/nanopyx/liquid/_le_convolution.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Convolution(LiquidEngine):
super().__init__(clear_benchmarks=clear_benchmarks, testing=testing,
opencl_=True, unthreaded_=True, threaded_=True, threaded_static_=True,
threaded_dynamic_=True, threaded_guided_=True)
self._default_benchmarks = {'OpenCL':[1,1,1],'Threaded':[2,2,2],'Threaded_static':[3,3,3],'Threaded_dynamic':[4,4,4],'Threaded_guided':[5,5,5],'Python':[6,6,6],'Numba':[7,7,7],'Unthreaded':[8,8,8]}

def run(self, image, kernel, run_type=None):
return self._run(image, kernel, run_type=run_type)
Expand Down
1 change: 1 addition & 0 deletions src/nanopyx/liquid/_le_esrrf.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class eSRRF(LiquidEngine):
super().__init__(clear_benchmarks=clear_benchmarks, testing=testing,
opencl_=True, unthreaded_=True, threaded_=True, threaded_static_=True,
threaded_dynamic_=True, threaded_guided_=True)
self._default_benchmarks = {'OpenCL':[1,1,1],'Threaded':[2,2,2],'Threaded_static':[3,3,3],'Threaded_dynamic':[4,4,4],'Threaded_guided':[5,5,5],'Python':[6,6,6],'Numba':[7,7,7],'Unthreaded':[8,8,8]}

def run(self, image, magnification: int = 5, radius: float = 1.5, sensitivity: float = 1, doIntensityWeighting: bool = True, run_type=None):
image = check_image(image)
Expand Down
3 changes: 2 additions & 1 deletion src/nanopyx/liquid/_le_interpolation_bicubic.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ShiftAndMagnify(LiquidEngine):
opencl_=True, unthreaded_=True, threaded_=True, threaded_static_=True,
threaded_dynamic_=True, threaded_guided_=True)

self._default_benchmarks = {'OpenCL':[1,1,1],'Threaded':[2,2,2],'Threaded_static':[3,3,3],'Threaded_dynamic':[4,4,4],'Threaded_guided':[5,5,5],'Python':[6,6,6],'Numba':[7,7,7],'Unthreaded':[8,8,8]}

# tag-copy: _le_interpolation_nearest_neighbor.ShiftAndMagnify.run; replace("Nearest-Neighbor", "Bicubic")
def run(self, image, shift_row, shift_col, float magnification_row, float magnification_col, run_type=None) -> np.ndarray:
Expand Down Expand Up @@ -266,7 +267,7 @@ class ShiftScaleRotate(LiquidEngine):
super().__init__(clear_benchmarks=clear_benchmarks, testing=testing,
opencl_=True, unthreaded_=True, threaded_=True, threaded_static_=True,
threaded_dynamic_=True, threaded_guided_=True)

self._default_benchmarks = {'OpenCL':[1,1,1],'Threaded':[2,2,2],'Threaded_static':[3,3,3],'Threaded_dynamic':[4,4,4],'Threaded_guided':[5,5,5],'Python':[6,6,6],'Numba':[7,7,7],'Unthreaded':[8,8,8]}

# tag-copy: _le_interpolation_nearest_neighbor.ShiftScaleRotate.run; replace("Nearest-Neighbor", "Bicubic")
def run(self, image, shift_row, shift_col, float scale_row, float scale_col, float angle, run_type=None) -> np.ndarray:
Expand Down
3 changes: 3 additions & 0 deletions src/nanopyx/liquid/_le_interpolation_catmull_rom.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class ShiftAndMagnify(LiquidEngine):
opencl_=True, unthreaded_=True, threaded_=True, threaded_static_=True,
threaded_dynamic_=True, threaded_guided_=True, python_=True, njit_=True)

self._default_benchmarks = {'OpenCL':[1,1,1],'Threaded':[2,2,2],'Threaded_static':[3,3,3],'Threaded_dynamic':[4,4,4],'Threaded_guided':[5,5,5],'Python':[6,6,6],'Numba':[7,7,7],'Unthreaded':[8,8,8]}

# tag-copy: _le_interpolation_nearest_neighbor.ShiftAndMagnify.run; replace("Nearest-Neighbor", "Catmull-Rom")
def run(self, image, shift_row, shift_col, float magnification_row, float magnification_col, run_type=None) -> np.ndarray:
"""
Expand Down Expand Up @@ -277,6 +279,7 @@ class ShiftScaleRotate(LiquidEngine):
super().__init__(clear_benchmarks=clear_benchmarks, testing=testing,
opencl_=True, unthreaded_=True, threaded_=True, threaded_static_=True,
threaded_dynamic_=True, threaded_guided_=True)
self._default_benchmarks = {'OpenCL':[1,1,1],'Threaded':[2,2,2],'Threaded_static':[3,3,3],'Threaded_dynamic':[4,4,4],'Threaded_guided':[5,5,5],'Python':[6,6,6],'Numba':[7,7,7],'Unthreaded':[8,8,8]}

# tag-copy: _le_interpolation_nearest_neighbor.ShiftScaleRotate.run; replace("Nearest-Neighbor", "Catmull-Rom")
def run(self, image, shift_row, shift_col, float scale_row, float scale_col, float angle, run_type=None) -> np.ndarray:
Expand Down
2 changes: 2 additions & 0 deletions src/nanopyx/liquid/_le_interpolation_lanczos.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ShiftAndMagnify(LiquidEngine):
super().__init__(clear_benchmarks=clear_benchmarks, testing=testing,
opencl_=True, unthreaded_=True, threaded_=True, threaded_static_=True,
threaded_dynamic_=True, threaded_guided_=True)
self._default_benchmarks = {'OpenCL':[1,1,1],'Threaded':[2,2,2],'Threaded_static':[3,3,3],'Threaded_dynamic':[4,4,4],'Threaded_guided':[5,5,5],'Python':[6,6,6],'Numba':[7,7,7],'Unthreaded':[8,8,8]}

# tag-copy: _le_interpolation_nearest_neighbor.ShiftAndMagnify.run; replace("Nearest-Neighbor", "Lanczos")
def run(self, image, shift_row, shift_col, float magnification_row, float magnification_col, run_type=None) -> np.ndarray:
Expand Down Expand Up @@ -265,6 +266,7 @@ class ShiftScaleRotate(LiquidEngine):
super().__init__(clear_benchmarks=clear_benchmarks, testing=testing,
opencl_=True, unthreaded_=True, threaded_=True, threaded_static_=True,
threaded_dynamic_=True, threaded_guided_=True)
self._default_benchmarks = {'OpenCL':[1,1,1],'Threaded':[2,2,2],'Threaded_static':[3,3,3],'Threaded_dynamic':[4,4,4],'Threaded_guided':[5,5,5],'Python':[6,6,6],'Numba':[7,7,7],'Unthreaded':[8,8,8]}

# tag-copy: _le_interpolation_nearest_neighbor.ShiftScaleRotate.run; replace("Nearest-Neighbor", "Lanczos")
def run(self, image, shift_row, shift_col, float scale_row, float scale_col, float angle, run_type=None) -> np.ndarray:
Expand Down
4 changes: 3 additions & 1 deletion src/nanopyx/liquid/_le_interpolation_nearest_neighbor.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ShiftAndMagnify(LiquidEngine):
opencl_=True, unthreaded_=True, threaded_=True, threaded_static_=True,
threaded_dynamic_=True, threaded_guided_=True, python_=True, njit_=True)

self._default_benchmarks = {'OpenCL':[1,1,1],'Threaded':[2,2,2],'Threaded_static':[3,3,3],'Threaded_dynamic':[4,4,4],'Threaded_guided':[5,5,5],'Python':[6,6,6],'Numba':[7,7,7],'Unthreaded':[8,8,8]}

# tag-start: _le_interpolation_nearest_neighbor.ShiftAndMagnify.run
def run(self, image, shift_row, shift_col, float magnification_row, float magnification_col, run_type=None) -> np.ndarray:
Expand Down Expand Up @@ -300,7 +301,8 @@ class ShiftScaleRotate(LiquidEngine):
opencl_=True, unthreaded_=True, threaded_=True, threaded_static_=True,
threaded_dynamic_=True, threaded_guided_=True, python_=True, njit_=True)


self._default_benchmarks = {'OpenCL':[1,1,1],'Threaded':[2,2,2],'Threaded_static':[3,3,3],'Threaded_dynamic':[4,4,4],'Threaded_guided':[5,5,5],'Python':[6,6,6],'Numba':[7,7,7],'Unthreaded':[8,8,8]}

# tag-start: _le_interpolation_nearest_neighbor.ShiftScaleRotate.run
def run(self, image, shift_row, shift_col, float scale_row, float scale_col, float angle, run_type=None) -> np.ndarray:
"""
Expand Down
2 changes: 2 additions & 0 deletions src/nanopyx/liquid/_le_mandelbrot_benchmark.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class MandelbrotBenchmark(LiquidEngine):
opencl_=True, unthreaded_=True, threaded_=True, threaded_static_=True,
threaded_dynamic_=True, threaded_guided_=True, python_=True, njit_=True)

self._default_benchmarks = {'OpenCL':[1,1,1],'Threaded':[2,2,2],'Threaded_static':[3,3,3],'Threaded_dynamic':[4,4,4],'Threaded_guided':[5,5,5],'Python':[6,6,6],'Numba':[7,7,7],'Unthreaded':[8,8,8]}

def run(self, int size=1000, float r_start=-1.5, float r_end=0.5, float c_start=-1, float c_end=1) -> np.ndarray:
"""
Run the mandelbrot benchmark
Expand Down
3 changes: 3 additions & 0 deletions src/nanopyx/liquid/_le_radial_gradient_convergence.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class RadialGradientConvergence(LiquidEngine):
unthreaded_=True, threaded_=True, threaded_static_=True,
threaded_dynamic_=True, threaded_guided_=True, opencl_=True)


self._default_benchmarks = {'OpenCL':[1,1,1],'Threaded':[2,2,2],'Threaded_static':[3,3,3],'Threaded_dynamic':[4,4,4],'Threaded_guided':[5,5,5],'Python':[6,6,6],'Numba':[7,7,7],'Unthreaded':[8,8,8]}


def run(self, gradient_col_interp, gradient_row_interp, image_interp, magnification: int = 5, radius: float = 1.5, sensitivity: float = 1 , doIntensityWeighting: bool = True, run_type = None):
gradient_col_interp = check_image(gradient_col_interp)
Expand Down
2 changes: 2 additions & 0 deletions src/nanopyx/liquid/_le_radiality.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class Radiality(LiquidEngine):
unthreaded_=False, threaded_=True, threaded_static_=True,
threaded_dynamic_=True, threaded_guided_=True, opencl_=True)

self._default_benchmarks = {'OpenCL':[1,1,1],'Threaded':[2,2,2],'Threaded_static':[3,3,3],'Threaded_dynamic':[4,4,4],'Threaded_guided':[5,5,5],'Python':[6,6,6],'Numba':[7,7,7],'Unthreaded':[8,8,8]}

def run(self, image, image_interp, magnification: int = 5, ringRadius: float = 0.5, border: int = 0, radialityPositivityConstraint: bool = True, doIntensityWeighting: bool = True, run_type = None):
image = check_image(image)
image_interp = check_image(image_interp)
Expand Down

0 comments on commit 13eb4ee

Please sign in to comment.