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

Encapsulates the Tasmanian Sparse Grid module. More...

Namespaces

 AccelerationMeta
 Common methods for manipulating acceleration options and reading CUDA environment properties.
 
 AccHandle
 Type tags for the different handle types.
 
 HierarchyManipulations
 Collection of algorithm to manipulate multi-indexes.
 
 IO
 Collection of I/O handling templates.
 
 Maths
 Math functions and constants.
 
 MultiIndexManipulations
 Collection of algorithm to manipulate multi-indexes.
 
 OneDimensionalMeta
 Metadata for one dimensional rules, number of points, exactness, I/O, etc.
 
 OneDimensionalNodes
 Contains algorithms for generating Gauss,Chebyshev, and Fourier nodes and weights.
 
 TasGpu
 Wrappers around custom CUDA kernels to handle domain transforms and basis evaluations, the kernels are instantiated in tsgCudaKernels.cu.
 
 TasmanianDenseSolver
 Methods for dense linear algebra.
 
 TasmanianFourierTransform
 Methods for Fast-Fourier-Transform.
 
 TasmanianTridiagonalSolver
 Methods for tridiagonal eigenvalue problems.
 
 TasSparse
 Methods for sparse linear algebra.
 
 Utils
 Miscellaneous utility templates (internal use).
 

Classes

class  TasmanianSparseGrid
 The master-class that represents an instance of a Tasmanian sparse grid. More...
 
class  Data2D
 Generic 2D data structure divided into contiguous strips of fixed length (similar to a matrix). More...
 
class  MultiIndexSet
 Class that stores multi-indexes in sorted (lexicographical) order. More...
 
class  StorageSet
 Class that stores values, i.e., model outputs, the order of the values is in sync with the order of some MultiIndexSet. More...
 
struct  HandleDeleter
 Deleter template for the GPU handles, e.g., cuBlas and rocBlas. More...
 
class  GpuVector
 Template class that wraps around a single GPU array, providing functionality that mimics std::vector. More...
 
struct  GpuEngine
 Wrapper class around calls GPU accelerated linear algebra libraries. More...
 
class  AccelerationDomainTransform
 Implements the domain transform algorithms in case the user data is provided on the GPU. More...
 
struct  AccelerationContext
 Wrapper class around GPU device ID, acceleration type and GpuEngine. More...
 
class  CacheLagrange
 Cache that holds the values of 1D Lagrange polynomials. More...
 
class  CacheLagrangeDerivative
 Cache that holds the derivatives of 1D Lagrange polynomials. Uses the same interface as CacheLagrange. . More...
 
class  CustomTabulated
 Class providing manipulation of custom tabulated rules, file I/O and structured access to the points, weights, and meta-data. More...
 
class  OneDimensionalWrapper
 A class to cache one dimensional rules, nodes, weight, meta-data, etc. More...
 
class  TableGaussPatterson
 Rule with hard-corded tabulated points and weights. More...
 
struct  NodeData
 Holds the pair of point index and model value, the struct is used in a std::forward_list. More...
 
struct  TensorData
 Holds the description of a single tensor candidate for inclusion into the grid. More...
 
class  DynamicConstructorDataGlobal
 Helper class that stores data from dynamic construction of a Global grid. More...
 
struct  SimpleConstructData
 Holds a std::forward_list of pairs of points indexes and values, and a MultiIndexSet of initial nodes. More...
 
class  CandidateManager
 Manages candidate points. More...
 
class  CompleteStorage
 Stores complete set of points before adding to the sparse grid. More...
 
class  VectorToStreamBuffer
 Coverts a vector to basic stream-buffer. More...
 

Typedefs

using int_gpu_lapack = int
 Defines the integer used by the LAPACK methods, usually int but DPC++ uses int64_t. More...
 
using ModelSignature = std::function< void(std::vector< double > const &x, std::vector< double > &y, size_t thread_id)>
 Signature of a model function to be used in the construction procedures. More...
 
using ModelSignatureMPI = std::function< void(std::vector< double > const &x, std::vector< double > &y)>
 Signature of a model function to be used in the MPI construction procedures. More...
 

Enumerations

enum  TypeIndexRelation { type_abeforeb , type_bbeforea , type_asameb }
 Describes the relation between two multi-indexes when compared during sorting. More...
 
enum  TypeDepth {
  type_none , type_level , type_curved , type_hyperbolic ,
  type_iptotal , type_qptotal , type_ipcurved , type_qpcurved ,
  type_iphyperbolic , type_qphyperbolic , type_tensor , type_iptensor ,
  type_qptensor
}
 Used by Global Sequence and Fourier grids, indicates the selection criteria. More...
 
enum  TypeOneDRule {
  rule_none , rule_clenshawcurtis , rule_clenshawcurtis0 , rule_fejer2 ,
  rule_chebyshev , rule_chebyshevodd , rule_leja , rule_lejaodd ,
  rule_rleja , rule_rlejadouble2 , rule_rlejadouble4 , rule_rlejaodd ,
  rule_rlejashifted , rule_rlejashiftedeven , rule_rlejashifteddouble , rule_maxlebesgue ,
  rule_maxlebesgueodd , rule_minlebesgue , rule_minlebesgueodd , rule_mindelta ,
  rule_mindeltaodd , rule_gausslegendre , rule_gausslegendreodd , rule_gausspatterson ,
  rule_gausschebyshev1 , rule_gausschebyshev1odd , rule_gausschebyshev2 , rule_gausschebyshev2odd ,
  rule_gaussgegenbauer , rule_gaussgegenbauerodd , rule_gaussjacobi , rule_gaussjacobiodd ,
  rule_gausslaguerre , rule_gausslaguerreodd , rule_gausshermite , rule_gausshermiteodd ,
  rule_customtabulated , rule_localp , rule_localp0 , rule_semilocalp ,
  rule_localpb , rule_wavelet , rule_fourier
}
 Used to specify the one dimensional family of rules that induces the sparse grid. More...
 
enum  TypeRefinement {
  refine_classic , refine_parents_first , refine_direction_selective , refine_fds ,
  refine_stable , refine_none
}
 Refinement strategy for local polynomial and wavelet grids. More...
 
enum  TypeAcceleration {
  accel_none , accel_cpu_blas , accel_gpu_default , accel_gpu_cublas ,
  accel_gpu_cuda , accel_gpu_magma
}
 Modes of acceleration. More...
 

Functions

TasmanianSparseGrid makeEmpty ()
 Returns an empty sparse grid. More...
 
TasmanianSparseGrid makeGlobalGrid (int dimensions, int outputs, int depth, TypeDepth type, TypeOneDRule rule, std::vector< int > const &anisotropic_weights=std::vector< int >(), double alpha=0.0, double beta=0.0, const char *custom_filename=nullptr, std::vector< int > const &level_limits=std::vector< int >())
 Factory method, creates a new grid and calls TasmanianSparseGrid::makeGlobalGrid(). More...
 
TasmanianSparseGrid makeSequenceGrid (int dimensions, int outputs, int depth, TypeDepth type, TypeOneDRule rule, std::vector< int > const &anisotropic_weights=std::vector< int >(), std::vector< int > const &level_limits=std::vector< int >())
 Factory method, creates a new grid and calls TasmanianSparseGrid::makeSequenceGrid(). More...
 
TasmanianSparseGrid makeLocalPolynomialGrid (int dimensions, int outputs, int depth, int order=1, TypeOneDRule rule=rule_localp, std::vector< int > const &level_limits=std::vector< int >())
 Factory method, creates a new grid and calls TasmanianSparseGrid::makeLocalPolynomialGrid(). More...
 
TasmanianSparseGrid makeWaveletGrid (int dimensions, int outputs, int depth, int order=1, std::vector< int > const &level_limits=std::vector< int >())
 Factory method, creates a new grid and calls TasmanianSparseGrid::makeWaveletGrid(). More...
 
TasmanianSparseGrid makeFourierGrid (int dimensions, int outputs, int depth, TypeDepth type, std::vector< int > const &anisotropic_weights=std::vector< int >(), std::vector< int > const &level_limits=std::vector< int >())
 Factory method, creates a new grid and calls TasmanianSparseGrid::makeFourierGrid(). More...
 
TasmanianSparseGrid readGrid (const char *filename)
 Factory method, creates a new grid and calls TasmanianSparseGrid::read(). More...
 
TasmanianSparseGrid readGrid (std::string const &filename)
 Overload using std::string. More...
 
TasmanianSparseGrid copyGrid (TasmanianSparseGrid const &source, int outputs_begin=0, int outputs_end=-1)
 Returns a grid that is a copy of the source. More...
 
template<typename T >
std::vector< T > spltVector2D (std::vector< T > const &x, size_t stride, int ibegin, int iend)
 Take a vector logically organized into stips and strides and extract a sub-strip from every strip. More...
 
template<typename >
void deleteHandle (int *)
 Deletes the handle, specialized for each TPL backend and tag in TasGrid::AccHandle namepace. More...
 
CustomTabulated getSubrules (CustomTabulated &ct, int start_index, int stride, std::string description)
 Generates a subset of rules as a CustomTabulated object. The subset has a short description string given by description and takes the levels of the input ct starting from level start_index with distance stride between consecutive levels. More...
 
template<class T >
std::vector< const T * > makeReverseReferenceVector (const std::forward_list< T > &list)
 Takes a list and creates a vector of references in reversed order, needed for I/O so that read can be followed by push_front. . More...
 
template<bool use_ascii>
void writeNodeDataList (const std::forward_list< NodeData > &data, std::ostream &os)
 Writes a NodeData std::forward_list to a file using either binary or ascii format. . More...
 
template<typename iomode >
std::forward_list< NodeDatareadNodeDataList (std::istream &is, size_t num_dimensions, size_t num_outputs)
 Reads a NodeData std::forward_list from a file using either binary or ascii format. . More...
 
template<typename iomode >
std::forward_list< TensorDatareadTensorDataList (std::istream &is, size_t num_dimensions)
 Reads a TensorData std::forward_list from a file using either binary or ascii format. More...
 
template<class RuleLike >
std::vector< double > listToNodes (std::forward_list< NodeData > const &node_list, size_t num_dimensions, RuleLike const &rule)
 Using MultiIndexManipulations::indexesToNodes() convert the node_list to actual points according to the rule. More...
 
template<typename callable_method >
std::vector< double > listToLocalNodes (std::forward_list< NodeData > const &node_list, size_t num_dimensions, callable_method rule)
 Using MultiIndexManipulations::indexesToNodes() convert the node_list to actual points according to the rule. More...
 
double poly_eval (const std::vector< double > &roots, double x)
 Evaluates a polynomial with roots given by roots at the point x. More...
 
double lagrange_eval (size_t idx, const std::vector< double > &roots, double x)
 Evaluates a Lagrange basis polynomial at a point x. More...
 
template<bool is_symmetric>
void getGaussNodesAndWeights (const int n, const std::vector< double > &ref_points, const std::vector< double > &ref_weights, std::vector< std::vector< double >> &points_cache, std::vector< std::vector< double >> &weights_cache)
 Generates n levels of points and weights using orthogonal polynomials with respect to ref_points and ref_weights. More...
 
TasGrid::CustomTabulated getShiftedExoticQuadrature (const int n, const double shift, const std::vector< double > &shifted_weights, const std::vector< double > &ref_points, const char *description, const bool is_symmetric=false)
 Generate the exotic quadrature points and weights and load them into a TasGrid::CustomTabulated object. More...
 
void shiftReferenceWeights (std::vector< double > const &vals, double shift, std::vector< double > &ref_weights)
 Multiplies the reference quadrature weights by the shifted values of the weight function. More...
 
TasGrid::CustomTabulated getExoticQuadrature (const int num_levels, const double shift, const TasGrid::TasmanianSparseGrid &grid, const char *description, const bool is_symmetric=false)
 Constructs an exotic quadrature from a sparse grid object. More...
 
TasGrid::CustomTabulated getExoticQuadrature (const int num_levels, const double shift, std::function< double(double)> weight_fn, const int num_ref_points, const char *description, const bool is_symmetric=false)
 Similar to getExoticQuadrature() but the weight function is defined by a lambda expression. More...
 
template<bool parallel_construction, bool use_initial_guess>
void constructCommon (ModelSignature model, size_t max_num_points, size_t num_parallel_jobs, size_t max_samples_per_job, TasmanianSparseGrid &grid, std::function< std::vector< double >(TasmanianSparseGrid &)> candidates, std::string const &checkpoint_filename)
 Construction algorithm using generic candidates procedure. More...
 
template<bool parallel_construction = TasGrid::mode_parallel, bool initial_guess = no_initial_guess>
void constructSurrogate (ModelSignature model, size_t max_num_points, size_t num_parallel_jobs, size_t max_samples_per_job, TasmanianSparseGrid &grid, double tolerance, TypeRefinement criteria, int output=-1, std::vector< int > const &level_limits=std::vector< int >(), std::string const &checkpoint_filename=std::string())
 Construct a sparse grid surrogate to the model defined by the lambda. More...
 
template<bool parallel_construction = TasGrid::mode_parallel, bool initial_guess = no_initial_guess>
void constructSurrogate (ModelSignature model, size_t max_num_points, size_t num_parallel_jobs, size_t max_samples_per_job, TasmanianSparseGrid &grid, TypeDepth type, std::vector< int > const &anisotropic_weights=std::vector< int >(), std::vector< int > const &level_limits=std::vector< int >(), std::string const &checkpoint_filename=std::string())
 Construct a sparse grid surrogate to the model defined by the lambda. More...
 
template<bool parallel_construction = TasGrid::mode_parallel, bool initial_guess = no_initial_guess>
void constructSurrogate (ModelSignature model, size_t max_num_points, size_t num_parallel_jobs, size_t max_samples_per_job, TasmanianSparseGrid &grid, TypeDepth type, int output, std::vector< int > const &level_limits=std::vector< int >(), std::string const &checkpoint_filename=std::string())
 Construct a sparse grid surrogate to the model defined by the lambda. More...
 
bool hasGPUBasis (TasmanianSparseGrid const &grid)
 Returns true if the grid has a GPU algorithm for computing the hierarchical basis. More...
 
template<typename scalar_type >
void generateCoefficientsGPU (double const data_points[], int num_data, scalar_type model_values[], double tolerance, TasmanianSparseGrid &grid)
 Generates the coefficients and solves the least-squares problem. More...
 
template<typename scalar_type >
Data2D< scalar_type > generateCoefficients (double const data_points[], int num_data, double const model_values[], double tolerance, TasmanianSparseGrid &grid)
 Generates the coefficients and solves the least-squares problem. More...
 
template<typename scalar_type >
void loadUnstructuredDataL2tmpl (double const data_points[], int num_data, double const model_values[], double tolerance, TasmanianSparseGrid &grid)
 Template implementation that handles the case of Fourier grids vs. all other types. More...
 
void loadUnstructuredDataL2 (double const data_points[], int num_data, double const model_values[], double tolerance, TasmanianSparseGrid &grid)
 Construct a sparse grid surrogate using a least-squares fit. More...
 
void loadUnstructuredDataL2 (std::vector< double > const &data_points, std::vector< double > const &model_values, double tolerance, TasmanianSparseGrid &grid)
 Overload that used vectors and infers the number of data points from the size of the vectors. More...
 
template<bool use_initial_guess>
void mpiConstructCommon (ModelSignatureMPI model, int num_dimensions, int num_outputs, size_t max_num_points, size_t max_samples_per_job, size_t max_num_ranks, int tagx, int tagy, int root, MPI_Comm comm, TasmanianSparseGrid &grid, std::function< std::vector< double >(TasmanianSparseGrid &)> candidates, std::string const &checkpoint_filename)
 MPI construction algorithm using generic candidates procedure. More...
 
template<bool use_initial_guess = no_initial_guess>
void mpiConstructSurrogate (ModelSignatureMPI model, int num_dimensions, int num_outputs, size_t max_num_points, size_t max_samples_per_job, size_t max_num_ranks, int tagx, int tagy, int root, MPI_Comm comm, TasmanianSparseGrid &grid, double tolerance, TypeRefinement criteria, int output=-1, std::vector< int > const &level_limits=std::vector< int >(), std::vector< double > const &scale_correction=std::vector< double >(), std::string const &checkpoint_filename=std::string())
 Construct a sparse grid surrogate to the model defined by the lambda, MPI version. More...
 
template<bool use_initial_guess = no_initial_guess>
void mpiConstructSurrogate (ModelSignatureMPI model, int num_dimensions, int num_outputs, size_t max_num_points, size_t max_samples_per_job, size_t max_num_ranks, int tagx, int tagy, int root, MPI_Comm comm, TasmanianSparseGrid &grid, TypeDepth type, std::vector< int > const &anisotropic_weights=std::vector< int >(), std::vector< int > const &level_limits=std::vector< int >(), std::string const &checkpoint_filename=std::string())
 Construct a sparse grid surrogate to the model defined by the lambda, MPI version. More...
 
template<bool use_initial_guess = no_initial_guess>
void mpiConstructSurrogate (ModelSignatureMPI model, int num_dimensions, int num_outputs, size_t max_num_points, size_t max_samples_per_job, size_t max_num_ranks, int tagx, int tagy, int root, MPI_Comm comm, TasmanianSparseGrid &grid, TypeDepth type, int output, std::vector< int > const &level_limits=std::vector< int >(), std::string const &checkpoint_filename=std::string())
 Construct a sparse grid surrogate to the model defined by the lambda, MPI version. More...
 
template<bool use_initial_guess = no_initial_guess>
void mpiConstructWorker (ModelSignatureMPI model, int num_dimensions, int num_outputs, size_t max_samples_per_job, size_t max_num_ranks, int tagx, int tagy, int root, MPI_Comm comm)
 Executes the worker (i.e., non-root) portion of the MPI sampling. More...
 
int getMPIRank (MPI_Comm comm)
 Utility to return the rank within the given comm. More...
 
template<bool binary = TasGrid::mode_binary>
int MPIGridSend (TasmanianSparseGrid const &grid, int destination, int tag, MPI_Comm comm)
 Send a grid to another process in the MPI comm. More...
 
template<bool binary = TasGrid::mode_binary>
int MPIGridRecv (TasmanianSparseGrid &grid, int source, int tag, MPI_Comm comm, MPI_Status *status=MPI_STATUS_IGNORE)
 Receive a grid from another process in the MPI comm. More...
 
template<bool binary = TasGrid::mode_binary>
int MPIGridBcast (TasmanianSparseGrid &grid, int root, MPI_Comm comm)
 Broadcast a grid to all processes in an MPI comm. More...
 
template<bool binary = TasGrid::mode_binary>
int MPIGridScatterOutputs (TasmanianSparseGrid const &source, TasmanianSparseGrid &destination, int root, int tag, MPI_Comm comm)
 Split the grid across the comm where each rank receives an equal portion of the total outputs. More...
 
template<bool parallel_construction = true, bool overwrite_loaded = false>
void loadNeededValues (std::function< void(double const x[], double y[], size_t thread_id)> model, TasmanianSparseGrid &grid, size_t num_threads)
 Loads the current grid with model values, does not perform any refinement. More...
 
template<bool parallel_construction = true, bool overwrite_loaded = false>
void loadNeededValues (std::function< void(std::vector< double > const &x, std::vector< double > &y, size_t thread_id)> model, TasmanianSparseGrid &grid, size_t num_threads)
 Overload that uses vectors for the model inputs and outputs. More...
 
template<bool parallel_construction = true, bool overwrite_loaded = false>
void loadNeededPoints (std::function< void(double const x[], double y[], size_t thread_id)> model, TasmanianSparseGrid &grid, size_t num_threads)
 Alias to loadNeededValues(), array variant.
 
template<bool parallel_construction = true, bool overwrite_loaded = false>
void loadNeededPoints (std::function< void(std::vector< double > const &x, std::vector< double > &y, size_t thread_id)> model, TasmanianSparseGrid &grid, size_t num_threads)
 Alias to loadNeededValues(), vector variant.
 

Variables

constexpr TypeAcceleration accel_gpu_hip = accel_gpu_cuda
 At the front API, the HIP and CUDA options are equivalent, see TasGrid::TypeAcceleration.
 
constexpr TypeAcceleration accel_gpu_rocblas = accel_gpu_cublas
 At the front API, the HIP and CUDA options are equivalent, see TasGrid::TypeAcceleration.
 
constexpr bool mode_ascii = false
 Constant allowing for more expressive selection of ascii and binary mode in IO methods.
 
constexpr bool mode_binary = true
 Constant allowing for more expressive selection of ascii and binary mode in IO methods.
 
constexpr bool mode_parallel = true
 Allows for expressive calls to TasGrid::constructSurrogate().
 
constexpr bool mode_sequential = false
 Allows for expressive calls to TasGrid::constructSurrogate().
 
constexpr bool with_initial_guess = true
 Allows for expressive calls to TasGrid::constructSurrogate().
 
constexpr bool no_initial_guess = false
 Allows for expressive calls to TasGrid::constructSurrogate().
 

Detailed Description

Encapsulates the Tasmanian Sparse Grid module.

Typedef Documentation

◆ int_gpu_lapack

using TasGrid::int_gpu_lapack = typedef int

Defines the integer used by the LAPACK methods, usually int but DPC++ uses int64_t.