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