+/pykokkos

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

Joseph RyanImplement basic support for Debug ExecSpace1a80dfe

master
664 B28 linesraw
1import pykokkos
2from pykokkos.views import View1D
3from pykokkos.workload import KokkosWorkload, work_unit, ExecSpace
4
5
6class AddOne(KokkosWorkload):
7    def __init__(self, n):
8        self.N = n
9        self.a = View1D(n)
10
11        for i in range(self.N):
12            self.a[i] = 2
13        print(f"Initialized view: [{self.a[0]}, ... repeats {n-1} times]")
14
15    def run_work_units(self):
16        pykokkos.parallel_for(self.N, self.add1)
17
18    def use_results(self):
19        print(f"Results: [{self.a[0]}, ... repeats {n-1} times]")
20
21    @work_unit
22    def add1(self, i):
23        self.a[i] += 1
24
25
26if __name__ == "__main__":
27    n = 100 * 1000
28    AddOne(n).execute()