+/pykokkos

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

Joseph RyanImplement basic support for Debug ExecSpace1a80dfe

master
699 B31 linesraw
1import pykokkos
2from pykokkos.views import View1D
3from pykokkos.workload import KokkosWorkload, work_unit, ExecSpace
4
5import random
6
7
8class RandomSum(KokkosWorkload):
9    def __init__(self, n):
10        self.N = n
11        self.a = View1D(n)
12
13        for i in range(self.N):
14            self.a[i] = random.random()
15
16        print("Initialized view:", self.a)
17
18    def run_work_units(self):
19        self.total = pykokkos.parallel_reduce(self.N, self.my_reduction)
20
21    def use_results(self):
22        print("Sum:", self.total)
23
24    @work_unit
25    def my_reduction(self, i, accumulator):
26        accumulator += self.a[i]
27
28
29if __name__ == "__main__":
30    n = 10
31    RandomSum(n).execute(ExecSpace.OpenMP)