1 #include "hostdevice.hpp" 2 3 namespace Petsc { 4 5 namespace device { 6 7 namespace host { 8 9 PetscErrorCode Device::initialize(MPI_Comm comm, PetscInt *defaultDeviceId, PetscBool *defaultView, PetscDeviceInitType *defaultInitType) noexcept { 10 PetscFunctionBegin; 11 // the host is always id 0 12 *defaultDeviceId = 0; 13 // the host is always "lazily" initialized 14 *defaultInitType = PETSC_DEVICE_INIT_LAZY; 15 16 PetscOptionsBegin(comm, nullptr, "PetscDevice host Options", "Sys"); 17 PetscCall(base_type::PetscOptionDeviceView(PetscOptionsObject, defaultView, nullptr)); 18 PetscOptionsEnd(); 19 PetscFunctionReturn(0); 20 } 21 22 PetscErrorCode Device::get_attribute_(PetscInt, PetscDeviceAttribute attr, void *value) noexcept { 23 PetscFunctionBegin; 24 switch (attr) { 25 case PETSC_DEVICE_ATTR_SIZE_T_SHARED_MEM_PER_BLOCK: *static_cast<std::size_t *>(value) = 64000; break; 26 default: PetscUnreachable(); 27 } 28 PetscFunctionReturn(0); 29 } 30 31 } // namespace host 32 33 } // namespace device 34 35 } // namespace Petsc 36