Actual source code: ex5.c
1: static const char help[] = "Tests PetscDeviceGetAttribute().\n\n";
3: #include "petscdevicetestcommon.h"
4: #include <petscviewer.h>
6: int main(int argc, char *argv[])
7: {
8: PetscDevice device = NULL;
9: size_t shmem = 0;
12: PetscInitialize(&argc, &argv, NULL, help);
14: PetscDeviceCreate(PETSC_DEVICE_DEFAULT(), PETSC_DECIDE, &device);
15: PetscDeviceConfigure(device);
16: PetscDeviceGetAttribute(device, PETSC_DEVICE_ATTR_SIZE_T_SHARED_MEM_PER_BLOCK, &shmem);
17: if (PetscDefined(HAVE_CXX) && ((shmem == 0) || (shmem == (size_t)-1))) {
18: // if no C++ then PetscDeviceGetAttribute defaults to 0
19: PetscDeviceView(device, PETSC_VIEWER_STDOUT_SELF);
20: SETERRQ(PETSC_COMM_SELF, PETSC_ERR_LIB, "Maximum shared memory of %zu seems fishy", shmem);
21: }
22: PetscDeviceDestroy(&device);
24: PetscPrintf(PETSC_COMM_WORLD, "EXIT_SUCCESS\n");
25: PetscFinalize();
26: return 0;
27: }
29: /*TEST
31: build:
32: requires: defined(PETSC_HAVE_CXX)
34: testset:
35: output_file: ./output/ExitSuccess.out
36: args: -device_enable {{lazy eager}}
37: test:
38: requires: !device
39: suffix: host_no_device
40: test:
41: requires: device
42: args: -default_device_type host
43: suffix: host_with_device
44: test:
45: requires: cuda
46: args: -default_device_type cuda
47: suffix: cuda
48: test:
49: requires: hip
50: args: -default_device_type hip
51: suffix: hip
52: test:
53: requires: sycl
54: args: -default_device_type sycl
55: suffix: sycl
57: TEST*/