Actual source code: ex6.c
1: static const char help[] = "Tests PetscDeviceContextView().\n\n";
3: #include "petscdevicetestcommon.h"
4: #include <petscviewer.h>
6: static PetscErrorCode TestView(PetscDeviceContext dctx)
7: {
8: PetscViewer viewer;
10: /* test stdout world */
11: PetscDeviceContextView(dctx, NULL);
13: /* test creating our own viewer */
14: PetscViewerCreate(PETSC_COMM_WORLD, &viewer);
15: PetscViewerSetType(viewer, PETSCVIEWERASCII);
16: PetscDeviceContextView(dctx, viewer);
17: PetscViewerDestroy(&viewer);
18: return 0;
19: }
21: int main(int argc, char *argv[])
22: {
23: MPI_Comm comm;
24: PetscDeviceContext dctx, dup;
27: PetscInitialize(&argc, &argv, NULL, help);
28: comm = PETSC_COMM_WORLD;
30: PetscDeviceContextGetCurrentContext(&dctx);
31: TestView(dctx);
33: PetscDeviceContextDuplicate(dctx, &dup);
34: TestView(dup);
35: PetscDeviceContextDestroy(&dup);
37: PetscPrintf(comm, "EXIT_SUCCESS\n");
38: PetscFinalize();
39: return 0;
40: }
42: /*TEST
44: build:
45: requires: defined(PETSC_HAVE_CXX)
47: testset:
48: args: -root_device_context_stream_type \
49: {{global_blocking default_blocking global_nonblocking}separate output}
50: filter: grep -ve "ex6 on a" -ve "\[0\] "
51: test:
52: requires: !device
53: suffix: host_no_device
54: test:
55: requires: device
56: args: -root_device_context_device_type host
57: suffix: host_with_device
58: test:
59: requires: cuda
60: args: -root_device_context_device_type cuda
61: suffix: cuda
62: test:
63: requires: hip
64: args: -root_device_context_device_type hip
65: suffix: hip
66: test:
67: requires: sycl
68: args: -root_device_context_device_type sycl
69: suffix: sycl
71: TEST*/