Doxygen 1.9.1
Toolkit for Adaptive Stochastic Modeling and Non-Intrusive ApproximatioN: Tasmanian v8.2 (development)
TasGrid::AccelerationContext Struct Reference

Wrapper class around GPU device ID, acceleration type and GpuEngine. More...

#include <tsgAcceleratedDataStructures.hpp>

Public Types

enum  AlgorithmPreference { algorithm_dense , algorithm_sparse , algorithm_autoselect }
 Defines the sparse-dense algorithm flavors, whenever applicable. More...
 
enum  ChangeType {
  change_none , change_gpu_device , change_gpu_enabled , change_cpu_blas ,
  change_sparse_dense
}
 Defines the types of acceleration context updates so they can be linked to acceleration cache updates. More...
 

Public Member Functions

 AccelerationContext ()
 Creates a default context, the device id is set to 0 and acceleration is BLAS (if available) or none.
 
ChangeType favorSparse (bool favor)
 Sets algorithm affinity in the direction of sparse.
 
bool blasCompatible () const
 Returns true if BLAS is enabled and the current mode is not none.
 
bool useKernels () const
 Returns true if the current mode implies the use of custom GPU kernels.
 
ChangeType testEnable (TypeAcceleration acc, int new_gpu_id) const
 Returns the ChangeType if enable() is called, but does not change the acceleration.
 
void enable (TypeAcceleration acc, int new_gpu_id)
 Accepts parameters directly from TasmanianSparseGrid::enableAcceleration()
 
void setDevice () const
 Set default device.
 
 operator GpuEngine * () const
 Custom convert to GpuEngine.
 
bool on_gpu () const
 Returns true if any of the GPU-based acceleration modes have been enabled.
 

Static Public Member Functions

static constexpr TypeAcceleration getDefaultAccMode ()
 Returns the default acceleration mode, cpu_blas if BLAS is enabled and none otherwise.
 
static constexpr int getDefaultAccDevice ()
 Returns the default acceleration device, CUDA/HIP use GPU 0, SYCL uses -1 which uses sycl::default_selector_v.
 

Public Attributes

TypeAcceleration mode
 The current active acceleration mode.
 
AlgorithmPreference algorithm_select
 The preference to use dense or sparse algorithms.
 
int device
 If using a GPU acceleration mode, holds the active device.
 
std::unique_ptr< GpuEngineengine
 Holds the context to the GPU TPL handles, e.g., MAGMA queue.
 

Detailed Description

Wrapper class around GPU device ID, acceleration type and GpuEngine.

Single acceleration context held by the TasmanianSparseGrid class and aliased into each of the sub-classes. The context is modified through the main class and is persistent on move, copy and read. The sub-classes hold only a const pointer and can read and use the associated variables and the engine.

Member Enumeration Documentation

◆ AlgorithmPreference

Defines the sparse-dense algorithm flavors, whenever applicable.

Enumerator
algorithm_dense 

Use dense algorithm.

algorithm_sparse 

Use sparse algorithm.

algorithm_autoselect 

Use automatically select based on heuristics.

◆ ChangeType

Defines the types of acceleration context updates so they can be linked to acceleration cache updates.

The update methods will generate a change event that may require an update of the acceleration cache. For example, switching to a different GPU device means that the cache from the old device must be cleared.

Enumerator
change_none 

No change, do nothing.

change_gpu_device 

Change the associated GPU device.

change_gpu_enabled 

Change from BLAS or none to a GPU acceleration mode.

change_cpu_blas 

Change BLAS to none or none to BLAS.

change_sparse_dense 

Change the sparse-dense AlgorithmPreference.


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