Skip to content

Commit d538d16

Browse files
jeremyltjrwrigh
andauthored
doc - improve internal API documentation (#1834)
* doc - improve internal API documentation * doc - clarify delegation * doc - update wording for clarity Co-authored-by: James Wright <[email protected]> * doc - clarify memcheck==valgrind * doc - clarify shared gpu backends * doc - clarify l/e/q-vecs * doc - clarify occa backend status * doc - more inheritance clarification * doc - minor claification to QF fields * minor - remove unneeded variables * doc - update inheritance language * doc - update shared description * doc - more gpu notes * doc - update fallback description * doc - clarify fallback is only for pc support * doc - minor updates to user facing GPU section * doc - minor reordering of major sections --------- Co-authored-by: James Wright <[email protected]>
1 parent 6d2aaf2 commit d538d16

File tree

7 files changed

+194
-112
lines changed

7 files changed

+194
-112
lines changed

backends/cuda-gen/ceed-cuda-gen.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
//------------------------------------------------------------------------------
1919
static int CeedInit_Cuda_gen(const char *resource, Ceed ceed) {
2020
char *resource_root;
21-
const char fallback_resource[] = "/gpu/cuda/ref";
2221
Ceed ceed_shared;
2322
Ceed_Cuda *data;
2423

@@ -35,7 +34,7 @@ static int CeedInit_Cuda_gen(const char *resource, Ceed ceed) {
3534
CeedCallBackend(CeedSetDelegate(ceed, ceed_shared));
3635
CeedCallBackend(CeedDestroy(&ceed_shared));
3736

38-
CeedCallBackend(CeedSetOperatorFallbackResource(ceed, fallback_resource));
37+
CeedCallBackend(CeedSetOperatorFallbackResource(ceed, "/gpu/cuda/ref"));
3938

4039
CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionCreate", CeedQFunctionCreate_Cuda_gen));
4140
CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "OperatorCreate", CeedOperatorCreate_Cuda_gen));

backends/hip-gen/ceed-hip-gen.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
// Backend init
1818
//------------------------------------------------------------------------------
1919
static int CeedInit_Hip_gen(const char *resource, Ceed ceed) {
20-
char *resource_root;
21-
const char fallback_resource[] = "/gpu/hip/ref";
22-
Ceed ceed_shared;
23-
Ceed_Hip *data;
20+
char *resource_root;
21+
Ceed ceed_shared;
22+
Ceed_Hip *data;
2423

2524
CeedCallBackend(CeedGetResourceRoot(ceed, resource, ":", &resource_root));
2625
CeedCheck(!strcmp(resource_root, "/gpu/hip") || !strcmp(resource_root, "/gpu/hip/gen"), ceed, CEED_ERROR_BACKEND,
@@ -35,7 +34,7 @@ static int CeedInit_Hip_gen(const char *resource, Ceed ceed) {
3534
CeedCallBackend(CeedSetDelegate(ceed, ceed_shared));
3635
CeedCallBackend(CeedDestroy(&ceed_shared));
3736

38-
CeedCallBackend(CeedSetOperatorFallbackResource(ceed, fallback_resource));
37+
CeedCallBackend(CeedSetOperatorFallbackResource(ceed, "/gpu/hip/ref"));
3938

4039
CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "QFunctionCreate", CeedQFunctionCreate_Hip_gen));
4140
CeedCallBackend(CeedSetBackendFunction(ceed, "Ceed", ceed, "OperatorCreate", CeedOperatorCreate_Hip_gen));

backends/sycl-gen/ceed-sycl-gen.sycl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ static int CeedInit_Sycl_gen(const char *resource, Ceed ceed) {
2121
Ceed ceed_shared;
2222
Ceed_Sycl *data;
2323
char *resource_root;
24-
const char fallback_resource[] = "/gpu/sycl/ref";
2524

2625
CeedCallBackend(CeedGetResourceRoot(ceed, resource, ":device_id=", &resource_root));
2726
CeedCheck(!strcmp(resource_root, "/gpu/sycl") || !strcmp(resource_root, "/gpu/sycl/gen"), ceed, CEED_ERROR_BACKEND,
@@ -37,7 +36,7 @@ static int CeedInit_Sycl_gen(const char *resource, Ceed ceed) {
3736
CeedCallBackend(CeedSetStream_Sycl(ceed_shared, &(data->sycl_queue)));
3837
CeedCallBackend(CeedDestroy(&ceed_shared));
3938

40-
CeedCallBackend(CeedSetOperatorFallbackResource(ceed, fallback_resource));
39+
CeedCallBackend(CeedSetOperatorFallbackResource(ceed, "/gpu/sycl/ref"));
4140

4241
Ceed ceed_fallback = NULL;
4342
CeedCallBackend(CeedGetOperatorFallbackCeed(ceed, &ceed_fallback));

doc/sphinx/source/gpu.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ Code that produces correct results with CPU backends will produce correct result
77

88
The filepath to the user source code is passed in {c:func}`CeedQFunctionCreateInterior` as the `source` argument.
99
This filepath should typically be an absolute path to ensure the JiT compilation can locate the source file.
10-
The filepath may also be relative to a root directory set with {c:func}`CeedAddJitSourceRoot`.
11-
The {c:macro}`CEED_QFUNCTION` macro automatically creates a string with the absolute path stored in the variable `user_loc` for a {c:type}`CeedQFunctionUser` called `user`.
10+
The filepath may also be a relative path with respect to a root directory set with {c:func}`CeedAddJitSourceRoot`.
11+
The {c:macro}`CEED_QFUNCTION` macro automatically creates a string with the absolute path, for example a {c:type}`CeedQFunctionUser` called `user` would have this string stored in the variable `user_loc`.
1212

13-
The entire contents of this file and all locally included files (`#include "foo.h"`) are used during JiT compilation for GPU backends.
14-
Installed 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>`.
13+
The entire contents of this source file and all included files are used during JiT compilation for GPU backends.
14+
Include statements for system headers that are required for CPU compilation but are not available in GPU compilation environments should be guarded with `#ifdef CEED_RUNNING_JIT_PASS`.
15+
Any function definitions in these system headers must still be available in the GPU compilation environments, such as the contents of `<math.h>`.
1516
These 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.).
1617

1718
All source files must be at the provided filepath at runtime for JiT to function.
@@ -20,10 +21,10 @@ All source files must be at the provided filepath at runtime for JiT to function
2021

2122
GPU backends require stricter adherence to memory access assumptions, but CPU backends may occasionally report correct results despite violations of memory access assumptions.
2223
Both `CeedVector` and `CeedQFunctionContext` have read-only and read-write accessors, and `CeedVector` allow write-only access.
23-
Read-only access of `CeedVector` and `CeedQFunctionContext` memory spaces must be respected for proper GPU behavior.
24+
Read-only access of `CeedVector` and `CeedQFunctionContext` memory spaces must be respected for to ensure proper GPU behavior.
2425
Write-only access of `CeedVector` memory spaces asserts that all data in the `CeedVector` is invalid until overwritten.
2526

26-
`CeedQFunction` assume that all input arrays are read-only and all output arrays are write-only and the {c:type}`CeedQFunctionUser` must adhere to these assumptions, only reading data in the input arrays and fully overwriting the output arrays.
27+
`CeedQFunction` assume that all input arrays are read-only and all output arrays are write-only and the {c:type}`CeedQFunctionUser` must adhere to these assumptions, only reading data in the input arrays and fully overwriting all entries in the output arrays.
2728
Additionally, {c:type}`CeedQFunctionUser` have read-write access for `CeedQFunctionContext` data, unless {c:func}`CeedQFunctionSetContextWritable` was used to indicate that read-only access is sufficient.
2829

2930
The `/cpu/self/memcheck` backends explicitly verify read-only and write-only memory access assumptions.

doc/sphinx/source/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ intro
88
gettingstarted
99
libCEEDapi
1010
examples/index
11+
api/index
1112
ffi
1213
gpu
13-
api/index
1414
precision
1515
libCEEDdev
1616
Contributing <CONTRIBUTING>

0 commit comments

Comments
 (0)