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:   PetscFunctionBegin;
 11:   /* test stdout world */
 12:   PetscCall(PetscDeviceContextView(dctx, NULL));
 14:   /* test creating our own viewer */
 15:   PetscCall(PetscViewerCreate(PETSC_COMM_WORLD, &viewer));
 16:   PetscCall(PetscViewerSetType(viewer, PETSCVIEWERASCII));
 17:   PetscCall(PetscDeviceContextView(dctx, viewer));
 18:   PetscCall(PetscViewerDestroy(&viewer));
 19:   PetscFunctionReturn(PETSC_SUCCESS);
 20: }
 22: int main(int argc, char *argv[])
 23: {
 24:   PetscDeviceContext dctx, dup;
 26:   PetscFunctionBeginUser;
 27:   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
 29:   PetscCall(PetscDeviceContextGetCurrentContext(&dctx));
 30:   PetscCall(TestView(dctx));
 32:   PetscCall(PetscDeviceContextDuplicate(dctx, &dup));
 33:   PetscCall(TestView(dup));
 34:   PetscCall(PetscDeviceContextDestroy(&dup));
 36:   PetscCall(TestView(NULL));
 38:   PetscCall(PetscPrintf(PETSC_COMM_WORLD, "EXIT_SUCCESS\n"));
 39:   PetscCall(PetscFinalize());
 40:   return 0;
 41: }
 43: /*TEST
 45:   testset:
 46:     requires: cxx
 47:     args: -root_device_context_stream_type \
 48:       {{default default_with_barrier nonblocking}separate output}
 49:     filter: grep -ve "ex6 on a" -ve "\[0\] "
 50:     test:
 51:       requires: !device
 52:       suffix: host_no_device
 53:     test:
 54:       requires: device
 55:       args: -root_device_context_device_type host
 56:       suffix: host_with_device
 57:     test:
 58:       requires: cuda
 59:       args: -root_device_context_device_type cuda
 60:       suffix: cuda
 61:     test:
 62:       requires: hip
 63:       args: -root_device_context_device_type hip
 64:       suffix: hip
 65:     test:
 66:       requires: sycl
 67:       args: -root_device_context_device_type sycl
 68:       suffix: sycl
 70:   testset:
 71:     requires: !cxx
 72:     output_file: ./output/ExitSuccess.out
 73:     suffix: no_cxx
 75: TEST*/