import pykokkos from pykokkos.views import View1D from pykokkos.workload import KokkosWorkload, work_unit, ExecSpace import random class RandomSum(KokkosWorkload): def __init__(self, n): self.N = n self.a = View1D(n) for i in range(self.N): self.a[i] = random.random() print("Initialized view:", self.a) def run_work_units(self): self.total = pykokkos.parallel_reduce(self.N, self.my_reduction) def use_results(self): print("Sum:", self.total) @work_unit def my_reduction(self, i, accumulator): accumulator += self.a[i] if __name__ == "__main__": n = 10 RandomSum(n).execute(ExecSpace.OpenMP)