Skip to content

Commit b1fbd2a

Browse files
authored
Merge pull request #247 from Hardcode84/numba-mlir-ranbo
Add numba-mlir rambo workloads
2 parents feb13b2 + 8a186ba commit b1fbd2a

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
from math import cos, log, pi, sin, sqrt
6+
7+
import numba_mlir.kernel as nb
8+
9+
10+
@nb.kernel
11+
def _rambo(C1, F1, Q1, nout, output):
12+
i = nb.get_global_id(0)
13+
for j in range(nout):
14+
C = 2.0 * C1[i, j] - 1.0
15+
S = sqrt(1 - C * C)
16+
F = 2.0 * pi * F1[i, j]
17+
Q = -log(Q1[i, j])
18+
19+
output[i, j, 0] = Q
20+
output[i, j, 1] = Q * S * sin(F)
21+
output[i, j, 2] = Q * S * cos(F)
22+
output[i, j, 3] = Q * C
23+
24+
25+
def rambo(nevts, nout, C1, F1, Q1, output):
26+
_rambo[nevts, ()](
27+
C1,
28+
F1,
29+
Q1,
30+
nout,
31+
output,
32+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
import numba_mlir as nb
6+
import numpy as np
7+
8+
9+
@nb.njit
10+
def rambo(nevts, nout, C1, F1, Q1, output):
11+
C = 2.0 * C1 - 1.0
12+
S = np.sqrt(1 - np.square(C))
13+
F = 2.0 * np.pi * F1
14+
Q = -np.log(Q1)
15+
16+
output[:, :, 0] = Q
17+
output[:, :, 1] = Q * S * np.sin(F)
18+
output[:, :, 2] = Q * S * np.cos(F)
19+
output[:, :, 3] = Q * C
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
import numba
6+
import numba_mlir as nb
7+
import numpy as np
8+
9+
10+
@nb.njit
11+
def rambo(nevts, nout, C1, F1, Q1, output):
12+
for i in numba.prange(nevts):
13+
for j in numba.prange(nout):
14+
C = 2.0 * C1[i, j] - 1.0
15+
S = np.sqrt(1 - np.square(C))
16+
F = 2.0 * np.pi * F1[i, j]
17+
Q = -np.log(Q1[i, j])
18+
19+
output[i, j, 0] = Q
20+
output[i, j, 1] = Q * S * np.sin(F)
21+
output[i, j, 2] = Q * S * np.cos(F)
22+
output[i, j, 3] = Q * C

0 commit comments

Comments
 (0)