+/pykokkos

git clone https://git.julia.blue/+/pykokkos

Joseph RyanRework function call translation3b7b538

master
477 B22 linesraw
1import pykokkos
2from pykokkos.views import View1D
3from pykokkos.workload import KokkosWorkload, work_unit
4
5
6class SquareSum(KokkosWorkload):
7    def __init__(self, n):
8        self.N = n
9
10    def run_work_units(self):
11        self.total = pykokkos.parallel_reduce(self.N, self.squaresum)
12
13    def use_results(self):
14        print("Sum:", self.total)
15
16    @work_unit
17    def squaresum(self, i, acc):
18        acc += i * i
19
20
21if __name__ == "__main__":
22    SquareSum(10).execute()