COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
naga.context.Context Class Reference

Python class for wrapping a CarmaContext. More...

Collaboration diagram for naga.context.Context:

Public Member Functions

def __init__ (self, devices=None)
 Initializes a Context object. More...
 
def getActiveDevice (self)
 Return the index of the current active device. More...
 
def setActiveDevice (self, int index)
 Set the device index as the active device. More...
 
def enableTensorCores (self)
 Enable the tensor cores math mode. More...
 
def disableTensorCores (self)
 Disable the tensor cores math mode. More...
 

Public Attributes

 context
 
 devices
 

Detailed Description

Python class for wrapping a CarmaContext.

Definition at line 45 of file context.py.

Constructor & Destructor Documentation

◆ __init__()

def naga.context.Context.__init__ (   self,
  devices = None 
)

Initializes a Context object.

   Parameters
   ------------

devices (list): (optionnal) list of devices to use. Default is 0

Definition at line 53 of file context.py.

53  """
54  if devices is None:
55  self.context = context.get_instance_1gpu(0)
56  self.devices = 0
57  else:
58  if isinstance(devices, list):
59  devices = np.array(devices, dtype=np.int32)
60  else:
61  raise TypeError("Devices must be a list of integer")
62  self.devices = devices
63  self.context = context.get_instance_ngpu(devices)
64 

Member Function Documentation

◆ disableTensorCores()

def naga.context.Context.disableTensorCores (   self)

Disable the tensor cores math mode.

Definition at line 81 of file context.py.

81  """ Disable the tensor cores math mode """
82  self.context.activate_tensor_cores(True)

◆ enableTensorCores()

def naga.context.Context.enableTensorCores (   self)

Enable the tensor cores math mode.

Definition at line 77 of file context.py.

77  """ Enable the tensor cores math mode """
78  self.context.activate_tensor_cores(True)
79 

◆ getActiveDevice()

def naga.context.Context.getActiveDevice (   self)

Return the index of the current active device.

Definition at line 66 of file context.py.

66  """ Return the index of the current active device """
67  return self.context.active_device
68 

◆ setActiveDevice()

def naga.context.Context.setActiveDevice (   self,
int  index 
)

Set the device index as the active device.

Definition at line 70 of file context.py.

70  """ Set the device index as the active device """
71  if index in self.devices:
72  self.context.set_active_device(index)
73  else:
74  raise ValueError("Index given is not valid")
75 

Member Data Documentation

◆ context

naga.context.Context.context

Definition at line 55 of file context.py.

◆ devices

naga.context.Context.devices

Definition at line 56 of file context.py.


The documentation for this class was generated from the following file:
set_active_device
#define set_active_device(new_device, silent)
Definition: carma_context.h:97