Documentation 6b54b78464
Loading...
Searching...
No Matches
CSysVector.hpp File Reference

Declararion and inlines of the vector class used in the solution of large, distributed, sparse linear systems. More...

Go to the source code of this file.

Classes

class  VecExpr::CVectorView< Scalar >
 How a CSysVector is captured inside an expression: a bare pointer to whichever storage the expression is going to be evaluated from. More...
 
struct  VecExpr::store_type< CSysVector< Scalar > >
 
struct  VecExpr::store_type< const CSysVector< Scalar > >
 
class  CSysVector< ScalarType >
 Class for holding and manipulating vectors needed by linear solvers. More...
 

Namespaces

namespace  VecExpr
 

Macros

#define CSYSVEC_PARFOR   SU2_OMP_SIMD
 OpenMP worksharing construct used in CSysVector for loops.
 
#define END_CSYSVEC_PARFOR
 
#define SU2_DEVICE_REGION(...)   SU2_OMP_SAFE_GLOBAL_ACCESS(__VA_ARGS__)
 Brackets device work so that it is issued by a single thread with the whole team synchronized before and after.
 
#define BEGIN_SU2_DEVICE_REGION   BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS
 
#define END_SU2_DEVICE_REGION   END_SU2_OMP_SAFE_GLOBAL_ACCESS
 
#define MAKE_COMPOUND(OP, ASSIGN_OP)
 Compound assignement operations with scalars and expressions.
 

Enumerations

enum class  VecExpr::DeviceAssignOp {
  VecExpr::Assign , VecExpr::Add , VecExpr::Subtract , VecExpr::Multiply ,
  VecExpr::Divide
}
 

Functions

bool VecExpr::UseDeviceExpressions ()
 Whether vector expressions are currently evaluated on the device.
 
void VecExpr::SetUseDeviceExpressions (bool)
 
template<DeviceAssignOp Op, class Scalar , class T >
void VecExpr::AssignDeviceExpression (Scalar *data, unsigned long size, const CVecExpr< T, Scalar > &expr)
 

Variables

template<class ScalarType >
constexpr bool su2_gpu_capable_v = false
 True for the plain floating-point scalar types the GPU vector kernels (CSysVectorGPU.cu) are instantiated for, in builds where those kernels exist at all. AD active types are never dispatched to the device: the tape/expression machinery those types pull in is not compatible with nvcc's device-code compilation, and device-resident autodiff is not supported by this GPU path.
 

Detailed Description

Declararion and inlines of the vector class used in the solution of large, distributed, sparse linear systems.

Author
P. Gomes, F. Palacios, J. Hicken, T. Economon
Version
8.5.0 "Harrier"

SU2 Project Website: https://su2code.github.io

The SU2 Project is maintained by the SU2 Foundation (http://su2foundation.org)

Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md)

SU2 is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

SU2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with SU2. If not, see http://www.gnu.org/licenses/.

Macro Definition Documentation

◆ BEGIN_SU2_DEVICE_REGION

#define BEGIN_SU2_DEVICE_REGION   BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS

◆ CSYSVEC_PARFOR

#define CSYSVEC_PARFOR   SU2_OMP_SIMD

OpenMP worksharing construct used in CSysVector for loops.

Note
The loop will only run in parallel if methods are called from a parallel region (if not the results will still be correct). Static schedule to reduce overhead, chunk size determined at initialization. "nowait" clause is safe when calling CSysVector methods after each other as the loop size is the same. Methods of other classes that operate on a CSysVector and do not have the same work scheduling must use a SU2_OMP_BARRIER before using the vector.

◆ END_CSYSVEC_PARFOR

#define END_CSYSVEC_PARFOR

◆ END_SU2_DEVICE_REGION

#define END_SU2_DEVICE_REGION   END_SU2_OMP_SAFE_GLOBAL_ACCESS

◆ MAKE_COMPOUND

#define MAKE_COMPOUND (   OP,
  ASSIGN_OP 
)
Value:
CSysVector& operator OP(ScalarType val) { \
if constexpr (su2_gpu_capable_v<ScalarType>) { \
if (VecExpr::UseDeviceExpressions()) return AssignDevice<ASSIGN_OP>(val); \
} \
for (auto i = 0ul; i < nElm; ++i) vec_val[i] OP val; \
return *this; \
} \
template <class T> \
CSysVector& operator OP(const VecExpr::CVecExpr<T, ScalarType>& expr) { \
if constexpr (su2_gpu_capable_v<ScalarType>) { \
if (VecExpr::UseDeviceExpressions()) return AssignDevice<ASSIGN_OP>(expr); \
} \
for (auto i = 0ul; i < nElm; ++i) vec_val[i] OP expr.derived()[i]; \
return *this; \
}
#define END_CSYSVEC_PARFOR
Definition CSysVector.hpp:86
#define CSYSVEC_PARFOR
OpenMP worksharing construct used in CSysVector for loops.
Definition CSysVector.hpp:85
Class for holding and manipulating vectors needed by linear solvers.
Definition CSysVector.hpp:195
Definition CSysVector.hpp:104
bool UseDeviceExpressions()
Whether vector expressions are currently evaluated on the device.
Definition CSysVector.hpp:119

Compound assignement operations with scalars and expressions.

Parameters
[in]val/expr- Scalar value or expression.

◆ SU2_DEVICE_REGION

#define SU2_DEVICE_REGION (   ...)    SU2_OMP_SAFE_GLOBAL_ACCESS(__VA_ARGS__)

Brackets device work so that it is issued by a single thread with the whole team synchronized before and after.

Note
The GPU is one shared resource and the device path does not use OpenMP worksharing. Issuing from one thread keeps kernel launches ordered on the default stream and, above all, stops part of a team from entering a worksharing construct that the rest skipped. Correctness relies on all threads reaching the same vector operations in the same order, which is the assumption the "nowait" clause on CSYSVEC_PARFOR already makes. These regions must not be nested; they are used by the operations of this class and by the matrix-vector product and preconditioner wrappers, and by nothing above those.

Variable Documentation

◆ su2_gpu_capable_v

template<class ScalarType >
constexpr bool su2_gpu_capable_v = false
inlineconstexpr

True for the plain floating-point scalar types the GPU vector kernels (CSysVectorGPU.cu) are instantiated for, in builds where those kernels exist at all. AD active types are never dispatched to the device: the tape/expression machinery those types pull in is not compatible with nvcc's device-code compilation, and device-resident autodiff is not supported by this GPU path.

Note
In an AD build this is false even for su2mixedfloat, because the .cu translation units are not linked into the AD libraries (see SU2_ENABLE_CUDA_KERNELS in code_config.hpp).