When I try to run a parallel loop using numba and print the index i,j – the result is random sequence of the index. I’m just wondering if there’s a way to implement this through their ascending index number such as when running with numba.cuda (all blocks and threads are done in ascending order).
Code:
from numba import njit, prange
import numpy as np
A = np.ones((3, 3))
@njit(parallel=True)
def sum(array):
s = 0
for i in prange(array.shape[0]):
for j in prange(array.shape[0]):
print(i, j)
s += array[i,j]
return s
Result:
01 0
1 1
1 2
0
0 1
0 2
2 0
2 1
2 2
Thanks!