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