Actual source code: hostdevice.cxx
1: #include "hostdevice.hpp"
3: namespace Petsc
4: {
6: namespace device
7: {
9: namespace host
10: {
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;
20: PetscOptionsBegin(comm, nullptr, "PetscDevice host Options", "Sys");
21: PetscCall(base_type::PetscOptionDeviceView(PetscOptionsObject, defaultView, nullptr));
22: PetscOptionsEnd();
23: PetscFunctionReturn(PETSC_SUCCESS);
24: }
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: }
39: } // namespace host
41: } // namespace device
43: } // namespace Petsc