1 static const char help[] = "Tests PetscDeviceGetAttribute().\n\n"; 2 3 #include "petscdevicetestcommon.h" 4 #include <petscviewer.h> 5 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(HAVE_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 build: 32 requires: defined(PETSC_HAVE_CXX) 33 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 56 57 TEST*/ 58