Alsvinn  0.5.3
The fast FVM simulator with UQ support
Classes | Functions
alsfvm::cuda Namespace Reference

Classes

class  CudaMemory
 

Functions

dim3 calculateBlockDimensions (size_t numberOfXCells, size_t numberOfYCells, size_t numberOfZCells)
 
dim3 calculateGridDimensions (size_t numberOfXCells, size_t numberOfYCells, size_t numberOfZCells, dim3 blockDimensions)
 
ivec3 __device__ getCoordinates (dim3 threadIdx, dim3 blockIdx, dim3 blockDim, size_t numberOfXCells, size_t numberOfYCells, size_t numberOfZCells, ivec3 directionVector)
 
std::tuple< int, ivec3makeKernelLaunchParameters (ivec3 start, ivec3 end, size_t blockSize)
 Gets teh kernel launch paramemters. More...
 
template<class T >
void add (T *result, const T *a, const T *b, size_t size)
 
template<class T >
void multiply (T *result, const T *a, const T *b, size_t size)
 
template<class T >
void subtract (T *result, const T *a, const T *b, size_t size)
 
template<class T >
void divide (T *result, const T *a, const T *b, size_t size)
 
template<class T >
void add (T *result, const T *a, T scalar, size_t size)
 
template<class T >
void multiply (T *result, const T *a, T scalar, size_t size)
 
template<class T >
void subtract (T *result, const T *a, T scalar, size_t size)
 
template<class T >
void divide (T *result, const T *a, T scalar, size_t size)
 
template<class T >
void add_linear_combination (T a1, T *v1, T a2, const T *v2, T a3, const T *v3, T a4, const T *v4, T a5, const T *v5, size_t size)
 
template<class T >
void add_power (T *a, const T *b, double power, size_t size)
 
template<class T >
void add_power (T *a, const T *b, double power, double factor, size_t size)
 
template<class T >
void subtract_power (T *a, const T *b, double power, size_t size)
 
template<class T >
compute_total_variation (const T *a, size_t nx, size_t ny, size_t nz, int p, const ivec3 &start, const ivec3 &end)
 
template<class T >
compute_total_variation (const T *a, size_t nx, size_t ny, size_t nz, size_t direction, int p, const ivec3 &start, const ivec3 &end)
 

Function Documentation

◆ add() [1/2]

template<class T >
void alsfvm::cuda::add ( T *  result,
const T *  a,
const T *  b,
size_t  size 
)

Adds a and b and stores the result to result

Parameters
resultthe device memory to write to (can be the same as a or b). Must have length size (in T)
amust have length size (in T)
bmust have length size (in T)
sizethe size of the memory (in T)

◆ add() [2/2]

template<class T >
void alsfvm::cuda::add ( T *  result,
const T *  a,
scalar,
size_t  size 
)

Adds scalar to each component of b and stores the result to result

Parameters
resultthe device memory to write to (can be the same as a ). Must have length size (in T)
amust have length size (in T)
scalarthe scalar
sizethe size of the memory (in T)

◆ add_linear_combination()

template<class T >
void alsfvm::cuda::add_linear_combination ( a1,
T *  v1,
a2,
const T *  v2,
a3,
const T *  v3,
a4,
const T *  v4,
a5,
const T *  v5,
size_t  size 
)

Adds the memory with coefficients to this memory area Here we compute the sum

\[ v_1^{\mathrm{new}}=a_1v_1+a_2v_2+a_3v_3+a_4v_4+a_5v_5+a_6v_6\]

where $v_1$ is the volume being operated on.

◆ add_power() [1/2]

template<class T >
void alsfvm::cuda::add_power ( T *  a,
const T *  b,
double  power,
size_t  size 
)

Basically runs

\[a += pow(b,power)\]

◆ add_power() [2/2]

template<class T >
void alsfvm::cuda::add_power ( T *  a,
const T *  b,
double  power,
double  factor,
size_t  size 
)

Basically runs

\[a += factor*pow(b,power)\]

◆ calculateBlockDimensions()

dim3 alsfvm::cuda::calculateBlockDimensions ( size_t  numberOfXCells,
size_t  numberOfYCells,
size_t  numberOfZCells 
)
inline

◆ calculateGridDimensions()

dim3 alsfvm::cuda::calculateGridDimensions ( size_t  numberOfXCells,
size_t  numberOfYCells,
size_t  numberOfZCells,
dim3  blockDimensions 
)
inline

◆ compute_total_variation() [1/2]

template<class T >
T alsfvm::cuda::compute_total_variation ( const T *  a,
size_t  nx,
size_t  ny,
size_t  nz,
int  p,
const ivec3 start,
const ivec3 end 
)

◆ compute_total_variation() [2/2]

template<class T >
T alsfvm::cuda::compute_total_variation ( const T *  a,
size_t  nx,
size_t  ny,
size_t  nz,
size_t  direction,
int  p,
const ivec3 start,
const ivec3 end 
)

◆ divide() [1/2]

template<class T >
void alsfvm::cuda::divide ( T *  result,
const T *  a,
const T *  b,
size_t  size 
)

Divides a by b and stores the result to result

Parameters
resultthe device memory to write to (can be the same as a or b). Must have length size (in T)
amust have length size (in T)
bmust have length size (in T)
sizethe size of the memory (in T)

◆ divide() [2/2]

template<class T >
void alsfvm::cuda::divide ( T *  result,
const T *  a,
scalar,
size_t  size 
)

Divides scalar from each component of b and stores the result to result

Parameters
resultthe device memory to write to (can be the same as a ). Must have length size (in T)
amust have length size (in T)
scalarthe scalar
sizethe size of the memory (in T)

◆ getCoordinates()

ivec3 __device__ alsfvm::cuda::getCoordinates ( dim3  threadIdx,
dim3  blockIdx,
dim3  blockDim,
size_t  numberOfXCells,
size_t  numberOfYCells,
size_t  numberOfZCells,
ivec3  directionVector 
)
inline

Gets the spatial (in grid cell integer coordinates) coordinates

This is typically useful when launching a CUDA kernel that needs neighbouring cells

◆ makeKernelLaunchParameters()

std::tuple<int, ivec3> alsfvm::cuda::makeKernelLaunchParameters ( ivec3  start,
ivec3  end,
size_t  blockSize 
)
inline

Gets teh kernel launch paramemters.

◆ multiply() [1/2]

template<class T >
void alsfvm::cuda::multiply ( T *  result,
const T *  a,
const T *  b,
size_t  size 
)

Multiplies a and b and stores the result to result

Parameters
resultthe device memory to write to (can be the same as a or b). Must have length size (in T)
amust have length size (in T)
bmust have length size (in T)
sizethe size of the memory (in T)

◆ multiply() [2/2]

template<class T >
void alsfvm::cuda::multiply ( T *  result,
const T *  a,
scalar,
size_t  size 
)

Multiplies scalar to each component of b and stores the result to result

Parameters
resultthe device memory to write to (can be the same as a ). Must have length size (in T)
amust have length size (in T)
sizethe size of the memory (in T)
scalarthe scalar

◆ subtract() [1/2]

template<class T >
void alsfvm::cuda::subtract ( T *  result,
const T *  a,
const T *  b,
size_t  size 
)

Subtracts a from b and stores the result to result

Parameters
resultthe device memory to write to (can be the same as a or b). Must have length size (in T)
amust have length size (in T)
bmust have length size (in T)
sizethe size of the memory (in T)

◆ subtract() [2/2]

template<class T >
void alsfvm::cuda::subtract ( T *  result,
const T *  a,
scalar,
size_t  size 
)

Subtracts scalar from each component of b and stores the result to result

Parameters
resultthe device memory to write to (can be the same as a ). Must have length size (in T)
amust have length size (in T)
scalarthe scalar
sizethe size of the memory (in T)

◆ subtract_power()

template<class T >
void alsfvm::cuda::subtract_power ( T *  a,
const T *  b,
double  power,
size_t  size 
)

Basically runs

\[a += pow(b,power)\]