Skip to content

Commit 3ea2e9c

Browse files
authored
Merge branch 'main' into get-max-node-depth
2 parents c3e78d5 + bb5689f commit 3ea2e9c

18 files changed

+423
-373
lines changed

doc/distributed.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Support for Distributed-Memory/Message Passing
2-
==============================================
1+
Distributed-Memory/Message Passing
2+
==================================
33

44
.. automodule:: pytato.distributed
55

examples/demo.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,31 @@
1111
result = pt.DictOfNamedArrays({"a2a": a2a, "aat": aat})
1212

1313

14-
# {{{ execute
14+
# {{{ execute with loopy/pyopencl
1515

1616
import pyopencl as cl
17+
import pyopencl.array as cla
1718
ctx = cl.create_some_context()
1819
queue = cl.CommandQueue(ctx)
19-
prg = pt.generate_loopy(result, cl_device=queue.device)
20+
21+
# simple interface
22+
prg = pt.generate_loopy(result)
2023
a = np.random.randn(20, 20)
2124
_, out = prg(queue, a=a)
2225
assert np.allclose(out["a2a"], a@(2*a))
2326
assert np.allclose(out["aat"], a@a.T)
2427

28+
# interface for efficient execution
29+
import loopy as lp
30+
prg = pt.generate_loopy(
31+
result, options=lp.Options(no_numpy=True, return_dict=True)
32+
).bind_to_context(ctx)
33+
a = np.random.randn(20, 20)
34+
a_dev = cla.to_device(queue, a)
35+
_, out = prg(queue, a=a_dev)
36+
assert np.allclose(out["a2a"].get(), a@(2*a))
37+
assert np.allclose(out["aat"].get(), a@a.T)
38+
2539
# }}}
2640

2741
# {{{ print generated Loopy and OpenCL code

0 commit comments

Comments
 (0)