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