diff --git a/dpbench/benchmarks/rambo/rambo_dpnp.py b/dpbench/benchmarks/rambo/rambo_dpnp.py new file mode 100644 index 00000000..542f95ca --- /dev/null +++ b/dpbench/benchmarks/rambo/rambo_dpnp.py @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 + +import dpnp as np + + +def rambo(nevts, nout, C1, F1, Q1, output): + C = 2.0 * C1 - 1.0 + S = np.sqrt(1 - np.square(C)) + F = 2.0 * np.pi * F1 + Q = -np.log(Q1) + + output[:, :, 0] = Q + output[:, :, 1] = Q * S * np.sin(F) + output[:, :, 2] = Q * S * np.cos(F) + output[:, :, 3] = Q * C diff --git a/dpbench/benchmarks/rambo/rambo_numba_np.py b/dpbench/benchmarks/rambo/rambo_numba_np.py new file mode 100644 index 00000000..4d00ee60 --- /dev/null +++ b/dpbench/benchmarks/rambo/rambo_numba_np.py @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 + +import numba as nb +import numpy as np + + +@nb.njit(parallel=True, fastmath=True) +def rambo(nevts, nout, C1, F1, Q1, output): + C = 2.0 * C1 - 1.0 + S = np.sqrt(1 - np.square(C)) + F = 2.0 * np.pi * F1 + Q = -np.log(Q1) + + output[:, :, 0] = Q + output[:, :, 1] = Q * S * np.sin(F) + output[:, :, 2] = Q * S * np.cos(F) + output[:, :, 3] = Q * C diff --git a/dpbench/benchmarks/rambo/rambo_numpy.py b/dpbench/benchmarks/rambo/rambo_numpy.py index e5616edd..6d1560ea 100644 --- a/dpbench/benchmarks/rambo/rambo_numpy.py +++ b/dpbench/benchmarks/rambo/rambo_numpy.py @@ -6,14 +6,12 @@ def rambo(nevts, nout, C1, F1, Q1, output): - for i in range(nevts): - for j in range(nout): - C = 2.0 * C1[i, j] - 1.0 - S = np.sqrt(1 - np.square(C)) - F = 2.0 * np.pi * F1[i, j] - Q = -np.log(Q1[i, j]) + C = 2.0 * C1 - 1.0 + S = np.sqrt(1 - np.square(C)) + F = 2.0 * np.pi * F1 + Q = -np.log(Q1) - output[i, j, 0] = Q - output[i, j, 1] = Q * S * np.sin(F) - output[i, j, 2] = Q * S * np.cos(F) - output[i, j, 3] = Q * C + output[:, :, 0] = Q + output[:, :, 1] = Q * S * np.sin(F) + output[:, :, 2] = Q * S * np.cos(F) + output[:, :, 3] = Q * C diff --git a/dpbench/benchmarks/rambo/rambo_python.py b/dpbench/benchmarks/rambo/rambo_python.py new file mode 100644 index 00000000..e5616edd --- /dev/null +++ b/dpbench/benchmarks/rambo/rambo_python.py @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np + + +def rambo(nevts, nout, C1, F1, Q1, output): + for i in range(nevts): + for j in range(nout): + C = 2.0 * C1[i, j] - 1.0 + S = np.sqrt(1 - np.square(C)) + F = 2.0 * np.pi * F1[i, j] + Q = -np.log(Q1[i, j]) + + output[i, j, 0] = Q + output[i, j, 1] = Q * S * np.sin(F) + output[i, j, 2] = Q * S * np.cos(F) + output[i, j, 3] = Q * C