8.1. Why on earth does the code…?¶
8.1.1. Why does everything go through loopy
?¶
We don’t quite know what execution hardware we’ll target, and even if we did, the answer to that might change over time. As of this writing, it’s likely that at least GPUs by Nvidia, Intel, and AMD are in the mix. But large-vector ARM CPUs are not out of the question.
Loopy lets us generate code for all these
TargetBase
s (e.g. CUDA, OpenCL) with ease.Likely, the loop structure for efficient code will not look the same on each machine. (E.g. because of vectorization, or GPU threads/blocks, or…) So we need a tool that lets us write reasonably readable code while being able to rewrite/transform that code to suit the loop structure that the machine likes. That tool is
loopy
.If we allowed some code to sidestep
loopy
, then all of those functions would have to be performed separately, and likely by hand, for that piece of code, which is likely not feasible.
8.1.2. What’s the point of array contexts?¶
Arrays are the central large-scale data structure that mirgecom
operates on.
arraycontext.ArrayContext
allows us flexibility in how those are
created (and which ones we use) just by changing which array context we run with.
Some array types you might choose include pyopencl.array.Array
s on the GPU
through OpenCL, or lazily-evaluated pytato.Array
s.