nnlib
GPU-accelerated, C/C++ neural network library.
Functions
allocation_gpu.cuh File Reference

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

#include "../../include/allocation.h"

Functions

float * allocate1DArrayDevice (size_t n)
 Allocate a 1D array. More...
 
void copy1DFromDeviceToDevice (float *oldLoc, float *newLoc, size_t n)
 Copy a 1D array within device memory. More...
 
void copy1DFromHostToDevice (float *host, float *device, size_t n)
 Copy a 1D array from host memory to device memory. More...
 
void copy2DFromHostToDevice (float **host, float *device, size_t n, size_t m)
 Copy a 2D array from host memory to device memory. More...
 
void copy1DFromDeviceToHost (float *device, float *host, size_t n)
 Copy a 1D array from device memory to host memory. More...
 
void copy2DFromDeviceToHost (float *device, float **host, size_t n, size_t m)
 Copy a 2D array from device memory to host memory. More...
 
float * copy1DArrayDevice (size_t n, float *old)
 Copy the provided 1D array to a new location. More...
 
void copy1DArrayDevice (size_t n, float *old, float *copy)
 
void free1DArrayDevice (float *device)
 Free a 1D array from device memory. More...
 

Detailed Description

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

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

Author
Jan Warchocki
Date
10 March 2022

Function Documentation

◆ allocate1DArrayDevice()

float* allocate1DArrayDevice ( size_t  n)

Allocate a 1D array.

Parameters
nThe size of the array to allocate.
Returns
The allocated array.

◆ copy1DArrayDevice()

float* copy1DArrayDevice ( size_t  n,
float *  old 
)

Copy the provided 1D array to a new location.

As opposed to copy1DFromDeviceToDevice(), this returns the new location, rather than expecting it as an argument.

Parameters
nThe size of the array to copy.
oldThe array to copy.
Returns
The new array.

◆ copy1DFromDeviceToDevice()

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

Copy a 1D array within device memory.

Parameters
oldLocThe old location of the array.
newLocThe new location of the array.
nThe size of the array.

◆ copy1DFromDeviceToHost()

void copy1DFromDeviceToHost ( float *  device,
float *  host,
size_t  n 
)

Copy a 1D array from device memory to host memory.

Parameters
deviceThe location of the device array.
hostThe host location where the array should be copied.
nThe size of the array.

◆ copy1DFromHostToDevice()

void copy1DFromHostToDevice ( float *  host,
float *  device,
size_t  n 
)

Copy a 1D array from host memory to device memory.

Parameters
hostThe location of the host array.
deviceThe device location where the array should be copied.
nThe size of the array.

◆ copy2DFromDeviceToHost()

void copy2DFromDeviceToHost ( float *  device,
float **  host,
size_t  n,
size_t  m 
)

Copy a 2D array from device memory to host memory.

Parameters
deviceThe location of the device array.
hostThe host location where the array should be copied.
nThe number of rows of the array.
mThe number of columns of the array.

◆ copy2DFromHostToDevice()

void copy2DFromHostToDevice ( float **  host,
float *  device,
size_t  n,
size_t  m 
)

Copy a 2D array from host memory to device memory.

Parameters
hostThe location of the host array.
deviceThe device location where the array should be copied.
nThe number of rows of the array.
mThe number of columns of the array.

◆ free1DArrayDevice()

void free1DArrayDevice ( float *  device)

Free a 1D array from device memory.

Parameters
deviceThe array to free.