xref: /libCEED/doc/sphinx/source/gpu.md (revision b94bfe40b009cf15c75d3afd8990a257ba3d552b)
1*b94bfe40SJeremy L Thompson# GPU Development
2*b94bfe40SJeremy L Thompson
3*b94bfe40SJeremy L ThompsonRuntime selection of libCEED backends allows users to use CPU backends for easier debugging.
4*b94bfe40SJeremy L ThompsonCode that produces correct results with CPU backends will produce correct results on GPU backends, provided that JiT and memory access assumptions of the libCEED API are respected.
5*b94bfe40SJeremy L Thompson
6*b94bfe40SJeremy L Thompson## JiT Compilation
7*b94bfe40SJeremy L Thompson
8*b94bfe40SJeremy L ThompsonThe filepath to the user source code is passed in {c:func}`CeedQFunctionCreateInterior` as the `source` argument.
9*b94bfe40SJeremy L ThompsonThis filepath should typically be an absolute path to ensure the JiT compilation can locate the source file.
10*b94bfe40SJeremy L ThompsonThe filepath may also be relative to a root directory set with {c:func}`CeedAddJitSourceRoot`.
11*b94bfe40SJeremy L Thompson
12*b94bfe40SJeremy L ThompsonThe entire contents of this file and all locally included files (`#include "foo.h"`) are used during JiT compilation for GPU backends.
13*b94bfe40SJeremy L ThompsonInstalled headers (`#include <bar.h>`) are omitted in the source code passed to JiT, but the compilation environment may supply common headers such as `<math.h>`.
14*b94bfe40SJeremy L ThompsonThese source file must only contain syntax constructs supported by C99 and all targeted backends (i.e. CUDA for `/gpu/cuda`, OpenCL/SYCL for `/gpu/sycl`, etc.).
15*b94bfe40SJeremy L Thompson
16*b94bfe40SJeremy L ThompsonAll source files must be at the provided filepath at runtime for JiT to function.
17*b94bfe40SJeremy L Thompson
18*b94bfe40SJeremy L Thompson## Memory Access
19*b94bfe40SJeremy L Thompson
20*b94bfe40SJeremy L ThompsonGPU backends require stricter adherence to memory access assumptions, but CPU backends may occasionally report correct results despite violations of memory access assumptions.
21*b94bfe40SJeremy L ThompsonThe `/cpu/self/memcheck` backends explicitly verify read-only and write-only memory access assumptions.
22*b94bfe40SJeremy L Thompson
23