nnlib
GPU-accelerated, C/C++ neural network library.
Functions
allocation.h File Reference

Header file to declare common functions regarding memory allocation on host. More...

#include <cstddef>

Go to the source code of this file.

Functions

float * allocate1DArray (size_t n)
 Allocate 1D array. More...
 
float * allocate1DArray (size_t n, float defaultValue)
 Allocate 1D array with a default value. More...
 
float ** allocate2DArray (size_t n, size_t m)
 Allocate 2D array. More...
 
float ** allocate2DArray (size_t n, size_t m, float defaultValue)
 Allocate 2D array with a default value. More...
 
void copy1DFromHostToHost (float *oldLoc, float *newLoc, size_t n)
 Copy a 1D array between two locations on host. More...
 
float * copy1DArray (size_t n, float *original)
 Copy 1D array to a new location. More...
 
void copy1DArray (size_t n, float *original, float *copy)
 
float ** copy2DArray (size_t n, size_t m, float **original)
 Copy 2D array to a new location. More...
 

Detailed Description

Header file to declare common functions regarding memory allocation on host.

All functions in the file only allocate/copy float memory.

Author
Jan Warchocki
Date
03 March 2022

Function Documentation

◆ allocate1DArray() [1/2]

float* allocate1DArray ( size_t  n)

Allocate 1D array.

Parameters
nThe size of the array to allocate.
Returns
Allocated array of size n.

◆ allocate1DArray() [2/2]

float* allocate1DArray ( size_t  n,
float  defaultValue 
)

Allocate 1D array with a default value.

Parameters
nThe size of the array to allocate.
defaultValueThe default value to fill the array with.
Returns
Allocated array of size n.

◆ allocate2DArray() [1/2]

float** allocate2DArray ( size_t  n,
size_t  m 
)

Allocate 2D array.

The storage of the array is row-wise.

Parameters
nThe number of rows of the array.
mThe number of columns of the array.
Returns
Allocated array of size n x m.

◆ allocate2DArray() [2/2]

float** allocate2DArray ( size_t  n,
size_t  m,
float  defaultValue 
)

Allocate 2D array with a default value.

The storage of the array is row-wise.

Parameters
nThe number of rows of the array.
mThe number of columns of the array.
defaultValueThe default value to fill the array with.
Returns
Allocated array of size n x m.

◆ copy1DArray()

float* copy1DArray ( size_t  n,
float *  original 
)

Copy 1D array to a new location.

Parameters
nThe size of the array to copy.
originalThe array to be copied.
Returns
Copied array.

◆ copy1DFromHostToHost()

void copy1DFromHostToHost ( float *  oldLoc,
float *  newLoc,
size_t  n 
)

Copy a 1D array between two locations on host.

Parameters
oldLocThe data to copy.
newLocWhere to copy the data to.
nThe number of elements of the data to copy.

◆ copy2DArray()

float** copy2DArray ( size_t  n,
size_t  m,
float **  original 
)

Copy 2D array to a new location.

Parameters
nThe number of rows of the original array.
mThe number of columns of the original array.
originalThe array to be copied.
Returns
Copied array.