Skip to content

File MemManagement.h

FileList > src > MemManagement.h

Go to the source code of this file

  • #include "General.h"
  • #include "Param.h"
  • #include "Arrays.h"
  • #include "Setup_GPU.h"

Public Functions

Type Name
void AllocateCPU (int nx, int ny, T *& zb)
Allocate memory for a single array on the CPU.
void AllocateCPU (int nx, int ny, T *& zs, T *& h, T *& u, T *& v)
Allocate memory for multiple arrays (zs, h, u, v) on the CPU.
void AllocateCPU (int nx, int ny, T *& zs, T *& h, T *& u, T *& v, T *& U, T *& hU)
Allocate memory for extended arrays (zs, h, u, v, U, hU) on the CPU.
void AllocateCPU (int nx, int ny, GradientsP< T > & Grad)
Allocate memory for gradient arrays on the CPU.
void AllocateCPU (int nblk, int blksize, EvolvingP< T > & Ev)
Allocate memory for evolving variables on the CPU.
void AllocateCPU (int nblk, int blksize, EvolvingP_M< T > & Ev)
Allocate memory for extended evolving variables on the CPU.
void AllocateCPU (int nblk, int blksize, Param XParam, Model< T > & XModel)
Allocate all model arrays on the CPU.
void AllocateGPU (int nblk, int blksize, Param XParam, Model< T > & XModel)
Allocate all model arrays on the GPU.
void AllocateGPU (int nx, int ny, T *& z_g)
Allocate memory on the GPU for a single array.
void AllocateMappedMemCPU (int nx, int ny, int gpudevice, T *& z)
Allocate mapped memory on the CPU for CUDA interop.
void AllocateMappedMemGPU (int nx, int ny, int gpudevice, T *& z_g, T * z)
Get device pointer for mapped host memory.
__host__ void FillCPU (int nx, int ny, T fillval, T *& zb)
Fill a CPU array with a specified value.
void ReallocArray (int nblk, int blksize, T *& zb)
Reallocate memory for a single array.
void ReallocArray (int nblk, int blksize, T *& zs, T *& h, T *& u, T *& v)
Reallocate memory for multiple arrays (zs, h, u, v).
void ReallocArray (int nblk, int blksize, T *& zs, T *& h, T *& u, T *& v, T *& U, T *& hU)
Reallocate memory for extended arrays (zs, h, u, v, U, hU).
void ReallocArray (int nblk, int blksize, EvolvingP< T > & Ev)
Reallocate memory for evolving variables structure.
void ReallocArray (int nblk, int blksize, EvolvingP_M< T > & Ev)
Reallocate memory for extended evolving variables structure.
void ReallocArray (int nblk, int blksize, Param XParam, Model< T > & XModel)
Reallocate all model arrays.
int memloc (Param XParam, int i, int j, int ib)
Compute memory index for a cell in a block (using Param ).
__host__ __device__ int memloc (int halowidth, int blkmemwidth, int i, int j, int ib)
Compute memory index for a cell in a block (using explicit sizes).

Public Functions Documentation

function AllocateCPU

Allocate memory for a single array on the CPU.

template<class T>
void AllocateCPU (
    int nx,
    int ny,
    T *& zb
) 

Allocates memory for the given array and checks for allocation failure.

Template parameters:

  • T Data type (float or int)

Parameters:

  • nx Number of x elements
  • ny Number of y elements
  • zb Array to allocate

function AllocateCPU

Allocate memory for multiple arrays (zs, h, u, v) on the CPU.

template<class T>
void AllocateCPU (
    int nx,
    int ny,
    T *& zs,
    T *& h,
    T *& u,
    T *& v
) 

Allocates memory for the given arrays.

Template parameters:

  • T Data type (float, double, int)

Parameters:

  • nx Number of x elements
  • ny Number of y elements
  • zs Array to allocate
  • h Array to allocate
  • u Array to allocate
  • v Array to allocate

function AllocateCPU

Allocate memory for extended arrays (zs, h, u, v, U, hU) on the CPU.

template<class T>
void AllocateCPU (
    int nx,
    int ny,
    T *& zs,
    T *& h,
    T *& u,
    T *& v,
    T *& U,
    T *& hU
) 

Allocates memory for the given arrays.

Template parameters:

  • T Data type (float, double, int)

Parameters:

  • nx Number of x elements
  • ny Number of y elements
  • zs Array to allocate
  • h Array to allocate
  • u Array to allocate
  • v Array to allocate
  • U Array to allocate
  • hU Array to allocate

function AllocateCPU

Allocate memory for gradient arrays on the CPU.

template<class T>
void AllocateCPU (
    int nx,
    int ny,
    GradientsP < T > & Grad
) 

Allocates memory for all gradient arrays in GradientsP structure.

Template parameters:

  • T Data type (float or double)

Parameters:

  • nx Number of x elements
  • ny Number of y elements
  • Grad GradientsP structure to allocate

function AllocateCPU

Allocate memory for evolving variables on the CPU.

template<class T>
void AllocateCPU (
    int nblk,
    int blksize,
    EvolvingP < T > & Ev
) 

Allocates memory for h, zs, u, v arrays in EvolvingP structure.

Template parameters:

  • T Data type (float or double)

Parameters:

  • nblk Number of blocks
  • blksize Block size
  • Ev EvolvingP structure to allocate

function AllocateCPU

Allocate memory for extended evolving variables on the CPU.

template<class T>
void AllocateCPU (
    int nblk,
    int blksize,
    EvolvingP_M < T > & Ev
) 

Allocates memory for h, zs, u, v, U, hU arrays in EvolvingP_M structure.

Template parameters:

  • T Data type (float or double)

Parameters:

  • nblk Number of blocks
  • blksize Block size
  • Ev EvolvingP_M structure to allocate

function AllocateCPU

Allocate all model arrays on the CPU.

template<class T>
void AllocateCPU (
    int nblk,
    int blksize,
    Param XParam,
    Model < T > & XModel
) 

Allocates memory for all arrays in the Model structure, including blocks, gradients, fluxes, and output buffers.

Template parameters:

  • T Data type (float or double)

Parameters:

  • nblk Number of blocks
  • blksize Block size
  • XParam Model parameters
  • XModel Model structure to allocate

function AllocateGPU

Allocate all model arrays on the GPU.

template<class T>
void AllocateGPU (
    int nblk,
    int blksize,
    Param XParam,
    Model < T > & XModel
) 

Allocates device memory for all arrays in the Model structure, including blocks, gradients, fluxes, and output buffers.

Template parameters:

  • T Data type (float or double)

Parameters:

  • nblk Number of blocks
  • blksize Block size
  • XParam Model parameters
  • XModel Model structure to allocate

function AllocateGPU

Allocate memory on the GPU for a single array.

template<class T>
void AllocateGPU (
    int nx,
    int ny,
    T *& z_g
) 

Allocates device memory for the given array.

Template parameters:

  • T Data type (float or double)

Parameters:

  • nx Number of x elements
  • ny Number of y elements
  • z_g Device pointer output

function AllocateMappedMemCPU

Allocate mapped memory on the CPU for CUDA interop.

template<class T>
void AllocateMappedMemCPU (
    int nx,
    int ny,
    int gpudevice,
    T *& z
) 

Allocates pinned or mapped memory for CUDA host-device interoperation.

Template parameters:

  • T Data type (float or double)

Parameters:

  • nx Number of x elements
  • ny Number of y elements
  • gpudevice GPU device index
  • z Pointer to allocated memory

function AllocateMappedMemGPU

Get device pointer for mapped host memory.

template<class T>
void AllocateMappedMemGPU (
    int nx,
    int ny,
    int gpudevice,
    T *& z_g,
    T * z
) 

Retrieves the device pointer for host memory mapped for CUDA interop.

Template parameters:

  • T Data type (float or double)

Parameters:

  • nx Number of x elements
  • ny Number of y elements
  • gpudevice GPU device index
  • z_g Device pointer output
  • z Host pointer input

function FillCPU

Fill a CPU array with a specified value.

template<class T>
__host__ void FillCPU (
    int nx,
    int ny,
    T fillval,
    T *& zb
) 

Sets all elements of the array to the given fill value.

Template parameters:

  • T Data type (float, double, int)

Parameters:

  • nx Number of x elements
  • ny Number of y elements
  • fillval Value to fill
  • zb Array to fill

function ReallocArray

Reallocate memory for a single array.

template<class T>
void ReallocArray (
    int nblk,
    int blksize,
    T *& zb
) 

Reallocates memory for the given array to match the new block and size.

Template parameters:

  • T Data type (float or double)

Parameters:

  • nblk Number of blocks
  • blksize Block size
  • zb Array to reallocate

function ReallocArray

Reallocate memory for multiple arrays (zs, h, u, v).

template<class T>
void ReallocArray (
    int nblk,
    int blksize,
    T *& zs,
    T *& h,
    T *& u,
    T *& v
) 

Reallocates memory for the given arrays to match the new block and size.

Template parameters:

  • T Data type (float or double)

Parameters:

  • nblk Number of blocks
  • blksize Block size
  • zs Array to reallocate
  • h Array to reallocate
  • u Array to reallocate
  • v Array to reallocate

function ReallocArray

Reallocate memory for extended arrays (zs, h, u, v, U, hU).

template<class T>
void ReallocArray (
    int nblk,
    int blksize,
    T *& zs,
    T *& h,
    T *& u,
    T *& v,
    T *& U,
    T *& hU
) 

Reallocates memory for the given arrays to match the new block and size.

Template parameters:

  • T Data type (float or double)

Parameters:

  • nblk Number of blocks
  • blksize Block size
  • zs Array to reallocate
  • h Array to reallocate
  • u Array to reallocate
  • v Array to reallocate
  • U Array to reallocate
  • hU Array to reallocate

function ReallocArray

Reallocate memory for evolving variables structure.

template<class T>
void ReallocArray (
    int nblk,
    int blksize,
    EvolvingP < T > & Ev
) 

Reallocates memory for all arrays in EvolvingP structure.

Template parameters:

  • T Data type (float or double)

Parameters:

  • nblk Number of blocks
  • blksize Block size
  • Ev EvolvingP structure to reallocate

function ReallocArray

Reallocate memory for extended evolving variables structure.

template<class T>
void ReallocArray (
    int nblk,
    int blksize,
    EvolvingP_M < T > & Ev
) 

Reallocates memory for all arrays in EvolvingP_M structure.

Template parameters:

  • T Data type (float or double)

Parameters:

  • nblk Number of blocks
  • blksize Block size
  • Ev EvolvingP_M structure to reallocate

function ReallocArray

Reallocate all model arrays.

template<class T>
void ReallocArray (
    int nblk,
    int blksize,
    Param XParam,
    Model < T > & XModel
) 

Reallocates memory for all arrays in the Model structure, including blocks, gradients, fluxes, and output buffers.

Template parameters:

  • T Data type (float or double)

Parameters:

  • nblk Number of blocks
  • blksize Block size
  • XParam Model parameters
  • XModel Model structure to reallocate

function memloc

Compute memory index for a cell in a block (using Param ).

int memloc (
    Param XParam,
    int i,
    int j,
    int ib
) 

Calculates the linear memory index for a cell in a block using model parameters.

Parameters:

  • XParam Model parameters
  • i Cell x-index
  • j Cell y-index
  • ib Block index

Returns:

Linear memory index


function memloc

Compute memory index for a cell in a block (using explicit sizes).

__host__ __device__ int memloc (
    int halowidth,
    int blkmemwidth,
    int i,
    int j,
    int ib
) 

Calculates the linear memory index for a cell in a block using explicit halo and block sizes.

Parameters:

  • halowidth Halo width
  • blkmemwidth Block memory width
  • i Cell x-index
  • j Cell y-index
  • ib Block index

Returns:

Linear memory index



The documentation for this class was generated from the following file src/MemManagement.h