Skip to main content
`Ctrl`+`K`

# petsc4py.PETSc.Device

class petsc4py.PETSc.Device

  Bases: `object`

  The device object.

  Represents a handle to an accelerator (which may be the host).

  See also

  `DeviceContext`, `PetscDevice`

  Enumerations

  `Type` | The type of device.

  Methods Summary

  `configure`() | Configure and setup a device object.
  `create`([dtype, device_id]) | Create a device object.
  `destroy`() | Destroy a device object.
  `getDeviceId`() | Return the device id.
  `getDeviceType`() | Return the type of the device.
  `setDefaultType`(device_type) | Set the device type to be used as the default in subsequent calls to `create`.
  `view`([viewer]) | View a device object.

  Attributes Summary

  `device_id` | The device id.
  `type` | The device type.

  Methods Documentation

  configure()

    Configure and setup a device object.

    Not collective.

    See also

    `create`, `PetscDeviceConfigure`

    Source code at petsc4py/PETSc/Device.pyx:132

    Return type:

      None

  classmethod create(dtype=None, device_id=DECIDE)

    Create a device object.

    Not collective.

    Parameters:

      - dtype (Type | None) – The type of device to create (or `None` for the default).

      - device_id (int) – The numeric id of the device to create.

    Return type:

      Device

    See also

    `destroy`, `PetscDeviceCreate`

    Source code at petsc4py/PETSc/Device.pyx:94

  destroy()

    Destroy a device object.

    Not collective.

    See also

    `create`, `PetscDeviceDestroy`

    Source code at petsc4py/PETSc/Device.pyx:120

    Return type:

      None

  getDeviceId()

    Return the device id.

    Not collective.

    See also

    `create`, `PetscDeviceGetDeviceId`

    Source code at petsc4py/PETSc/Device.pyx:180

    Return type:

      int

  getDeviceType()

    Return the type of the device.

    Not collective.

    See also

    `type`, `PetscDeviceGetType`

    Source code at petsc4py/PETSc/Device.pyx:165

    Return type:

      str

  static setDefaultType(device_type)

    Set the device type to be used as the default in subsequent calls to `create`.

    Not collective.

    See also

    `create`, `PetscDeviceSetDefaultDeviceType`

    Source code at petsc4py/PETSc/Device.pyx:195

    Parameters:

      device_type (Type | str)

    Return type:

      None

  view(viewer=None)

    View a device object.

    Collective.

    Parameters:

      viewer (Viewer | None) – A `Viewer` instance or `None` for the default viewer.

    Return type:

      None

    See also

    `PetscDeviceView`

    Source code at petsc4py/PETSc/Device.pyx:144

  Attributes Documentation

  device_id

    The device id.

    Source code at petsc4py/PETSc/Device.pyx:215

  type

    The device type.

    Source code at petsc4py/PETSc/Device.pyx:210

  __init__()
  classmethod __new__(*args, **kwargs)