SpatialOps
SpatialOps::FieldInfo< T > Class Template Reference

Abstracts the internals of a field. More...

#include <FieldInfo.h>

Public Member Functions

 FieldInfo (const MemoryWindow &window, const BoundaryCellInfo &bc, const GhostData &ghosts, T *const fieldValues=NULL, const StorageMode mode=InternalStorage, const short int devIdx=CPU_INDEX)
 FieldInfo constructor. More...
 
 ~FieldInfo ()
 FieldInfo destructor. More...
 
const MemoryWindowwindow_with_ghost () const
 return the global memory window with valid ghost cells
 
const MemoryWindow window_without_ghost () const
 return the global memory window with no ghost cells
 
const MemoryWindow window_with_all_ghost () const
 return the global memory window with all possible ghost cells
 
const BoundaryCellInfoboundary_info () const
 return the boundary cell information
 
const GhostDataget_ghost_data () const
 return the number of total ghost cells
 
const GhostDataget_valid_ghost_data () const
 return the number of current valid ghost cells
 
void reset_valid_ghosts (const GhostData &ghosts)
 set the number of valid ghost cells to given ghosts More...
 
unsigned int allocated_bytes () const
 returns the number of allocated bytes (for copying memory)
 
void wait_for_synchronization ()
 wait until the current stream is done with all work
 
short int active_device_index () const
 return the index of the current active device
 
void add_device (short int deviceIndex)
 add device memory to this field for given device and populate it with values from current active device SYNCHRONOUS VERSION More...
 
void add_device_async (short int deviceIndex)
 add device memory to this field for given device and populate it with values from current active device ASYNCHRONOUS VERSION More...
 
void validate_device (short int deviceIndex)
 popluate the memory of the given device (deviceIndex) with values from the active device SYNCHRONOUS VERSION More...
 
void validate_device_async (short int deviceIndex)
 popluate the memory of the given device (deviceIndex) with values from the active device ASYNCHRONOUS VERSION More...
 
void set_device_as_active (short int deviceIndex)
 set given device (deviceIndex) as active SYNCHRONOUS VERSION More...
 
void set_device_as_active_async (short int deviceIndex)
 set given device (deviceIndex) as active ASYNCHRONOUS VERSION More...
 
bool is_valid (const short int deviceIndex) const
 check if the device (deviceIndex) is available and valid More...
 
bool is_available (const short int deviceIndex) const
 check if the device (deviceIndex) is available More...
 
T * field_values (const short int deviceIndex=CPU_INDEX)
 return a non-constant pointer to memory on the given device More...
 
const T * const_field_values (const short int deviceIndex=CPU_INDEX) const
 return a constant pointer to memory on the given device More...
 

Detailed Description

template<typename T = double>
class SpatialOps::FieldInfo< T >

Abstracts the internals of a field.

FieldInfo abstracts the low-level details of a field, mainly memory management and synchronization of memory between devices.

Template Parameters
T- the underlying data type (defaults to double)
Related classes:
Public Typedefs
  • value_type - the type of underlying data being stored in this SpatialField

Definition at line 92 of file FieldInfo.h.

Constructor & Destructor Documentation

◆ FieldInfo()

template<typename T >
SpatialOps::FieldInfo< T >::FieldInfo ( const MemoryWindow window,
const BoundaryCellInfo bc,
const GhostData ghosts,
T *const  fieldValues = NULL,
const StorageMode  mode = InternalStorage,
const short int  devIdx = CPU_INDEX 
)

FieldInfo constructor.

Parameters
windowMemoryWindow for the entire field (including ghost cells)
bcBoundaryConditionInfo for field
ghostsGhostData for entire field (all possible ghosts)
fieldValuespointer to memory for ExternalStorage mode (default: NULL)
modeeither InternalStorage or ExternalStorage (default: InternalStorage)
devIdxdevice index of originally active device (default: CPU_INDEX)

Definition at line 431 of file FieldInfo.h.

References SpatialOps::MemoryWindow::glob_npts(), and SpatialOps::MemoryWindow::local_npts().

Here is the call graph for this function:

◆ ~FieldInfo()

template<typename T >
SpatialOps::FieldInfo< T >::~FieldInfo ( )

FieldInfo destructor.

This functions free any memory allocated by the FieldInfo. Memory is allocated either in the constructor or when adding new devices.

Definition at line 495 of file FieldInfo.h.

References SpatialOps::Pool< T >::put().

Here is the call graph for this function:

Member Function Documentation

◆ add_device()

template<typename T >
void SpatialOps::FieldInfo< T >::add_device ( short int  deviceIndex)

add device memory to this field for given device and populate it with values from current active device SYNCHRONOUS VERSION

Parameters
deviceIndexthe index of the device to add

If device (deviceIndex) is already available for this field and valid, this fuction becomes a no op.

If device (deviceIndex) is already available for this field but not valid, this fuction becomes identical to validate_device().

Thus, regardless of the status of device (deviceIndex) for this field, this function does the bare minumum to make device available and valid for this field.

Note: This operation is guaranteed to be synchronous: The host thread waits until the task is completed (on the GPU).

Note: This operation is thread safe.

Definition at line 507 of file FieldInfo.h.

References SpatialOps::FieldInfo< T >::add_device_async(), and SpatialOps::FieldInfo< T >::wait_for_synchronization().

Referenced by SpatialOps::FieldInfo< T >::active_device_index().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_device_async()

template<typename T >
void SpatialOps::FieldInfo< T >::add_device_async ( short int  deviceIndex)

add device memory to this field for given device and populate it with values from current active device ASYNCHRONOUS VERSION

Parameters
deviceIndexthe index of the device to add

If device (deviceIndex) is already available for this field and valid, this fuction becomes a no op.

If device (deviceIndex) is already available for this field but not valid, this fuction becomes identical to validate_device_async().

Thus, regardless of the status of device (deviceIndex) for this field, this function does the bare minumum to make device available and valid for this field.

Note: This operation is asynchronous: The host thread returns immediately after it launches on the GPU.

Note: This operation is thread safe.

Definition at line 521 of file FieldInfo.h.

References SpatialOps::FieldInfo< T >::allocated_bytes(), and SpatialOps::FieldInfo< T >::validate_device_async().

Referenced by SpatialOps::FieldInfo< T >::active_device_index(), SpatialOps::FieldInfo< T >::add_device(), and SpatialOps::FieldInfo< T >::set_device_as_active_async().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ const_field_values()

template<typename T >
const T * SpatialOps::FieldInfo< T >::const_field_values ( const short int  deviceIndex = CPU_INDEX) const
inline

return a constant pointer to memory on the given device

NOTE: no check is performed to determine if the memory returned is valid. See the is_valid() method to perform that check.

Parameters
deviceIndexdevice index for device memory to return (defaults to CPU_INDEX)

Definition at line 773 of file FieldInfo.h.

Referenced by SpatialOps::FieldInfo< T >::active_device_index().

Here is the caller graph for this function:

◆ field_values()

template<typename T >
T * SpatialOps::FieldInfo< T >::field_values ( const short int  deviceIndex = CPU_INDEX)
inline

return a non-constant pointer to memory on the given device

Note: This method will invalidate all the other devices apart from the deviceIndex.

Parameters
deviceIndexindex of device for device memory to return (defaults to CPU_INDEX)

Definition at line 739 of file FieldInfo.h.

References SpatialOps::FieldInfo< T >::active_device_index().

Referenced by SpatialOps::FieldInfo< T >::active_device_index().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_available()

template<typename T >
bool SpatialOps::FieldInfo< T >::is_available ( const short int  deviceIndex) const

check if the device (deviceIndex) is available

Parameters
deviceIndexindex of device to check

Definition at line 718 of file FieldInfo.h.

Referenced by SpatialOps::FieldInfo< T >::active_device_index().

Here is the caller graph for this function:

◆ is_valid()

template<typename T >
bool SpatialOps::FieldInfo< T >::is_valid ( const short int  deviceIndex) const

check if the device (deviceIndex) is available and valid

Parameters
deviceIndexindex of device to check

Definition at line 694 of file FieldInfo.h.

Referenced by SpatialOps::FieldInfo< T >::active_device_index().

Here is the caller graph for this function:

◆ reset_valid_ghosts()

template<typename T = double>
void SpatialOps::FieldInfo< T >::reset_valid_ghosts ( const GhostData ghosts)
inline

set the number of valid ghost cells to given ghosts

Parameters
ghostsghost cells to be made valid

Definition at line 234 of file FieldInfo.h.

References SpatialOps::MemoryWindow::reset_ghosts().

Here is the call graph for this function:

◆ set_device_as_active()

template<typename T >
void SpatialOps::FieldInfo< T >::set_device_as_active ( short int  deviceIndex)

set given device (deviceIndex) as active SYNCHRONOUS VERSION

Given device must exist and be valid, otherwise an exception is thrown.

Parameters
deviceIndexindex to device to be made active

Note: This operation is guaranteed to be synchronous: The host thread waits until the task is completed (on the GPU).

Definition at line 660 of file FieldInfo.h.

References SpatialOps::FieldInfo< T >::set_device_as_active_async(), and SpatialOps::FieldInfo< T >::wait_for_synchronization().

Referenced by SpatialOps::FieldInfo< T >::active_device_index().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_device_as_active_async()

template<typename T >
void SpatialOps::FieldInfo< T >::set_device_as_active_async ( short int  deviceIndex)

set given device (deviceIndex) as active ASYNCHRONOUS VERSION

Given device must exist and be valid, otherwise an exception is thrown.

Parameters
deviceIndexindex to device to be made active

Note: This operation is asynchronous: The host thread returns immediately after it launches on the GPU.

Definition at line 674 of file FieldInfo.h.

References SpatialOps::FieldInfo< T >::add_device_async().

Referenced by SpatialOps::FieldInfo< T >::active_device_index(), and SpatialOps::FieldInfo< T >::set_device_as_active().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_device()

template<typename T >
void SpatialOps::FieldInfo< T >::validate_device ( short int  deviceIndex)

popluate the memory of the given device (deviceIndex) with values from the active device SYNCHRONOUS VERSION

This function performs data-transfers when needed and only when needed.

Parameters
deviceIndexindex for device to synchronize

Note: This operation is guaranteed to be synchronous: The host thread waits until the task is completed (on the GPU).

Definition at line 551 of file FieldInfo.h.

References SpatialOps::FieldInfo< T >::validate_device_async(), and SpatialOps::FieldInfo< T >::wait_for_synchronization().

Referenced by SpatialOps::FieldInfo< T >::active_device_index().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_device_async()

template<typename T >
void SpatialOps::FieldInfo< T >::validate_device_async ( short int  deviceIndex)

popluate the memory of the given device (deviceIndex) with values from the active device ASYNCHRONOUS VERSION

This function performs data-transfers when needed and only when needed.

Parameters
deviceIndexindex for device to synchronize

Note: This operation is asynchronous: The host thread returns immediately after it launches on the GPU.

Definition at line 565 of file FieldInfo.h.

References SpatialOps::FieldInfo< T >::active_device_index(), and SpatialOps::FieldInfo< T >::allocated_bytes().

Referenced by SpatialOps::FieldInfo< T >::active_device_index(), SpatialOps::FieldInfo< T >::add_device_async(), and SpatialOps::FieldInfo< T >::validate_device().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: