Array Class
The Array
class is the primary data structure class of the library.
It stores the pointer to the memory space in the Device
, along with the necessary information to access and manipulate it.
The class is intended to be used through smart pointers defined as Array::Pointer
and should not be accessed directly.
Hence, the creation of an Array
object is done through Array::create()
function.
The class provides a set of methods that describe the array, such as its size
, width
, dtype
, among others.
It also provides methods to write/read data to and from the host, and to perform operations on the array, such as fill
and copy
.
This object is the main input and output of the library functions.
-
class Array
Array class.
This is the main data structure of the library. It is used to store data on the device and to perform operations on it. The Array class is holding a device memory pointer (void *), its size and its type. An Array is not manipulated directly, but through a smart pointer (Array::Pointer).
Public Functions
-
auto allocate() -> void
Allocate memory space of the array on the device.
-
auto writeFrom(const void *host_data) -> void
Write host data into the Array.
- Parameters:
host_data – pointer to the host data
-
auto writeFrom(const void *host_data, const std::array<size_t, 3> ®ion, const std::array<size_t, 3> &buffer_origin) -> void
Write host data into the Array region.
- Parameters:
host_data – pointer to the host data
region – region of the array to write
buffer_origin – origin of the buffer to write
-
auto writeFrom(const void *host_data, size_t x_coord, size_t y_coord, size_t z_coord) -> void
Write host data into the Array at a specific position (x, y, z)
- Parameters:
host_data – pointer to the host data
x_coord – x coordinate
y_coord – y coordinate
z_coord – z coordinate
-
auto readTo(void *host_data) const -> void
Read the Array data into host memory.
- Parameters:
host_data – pointer to the host data
-
auto readTo(void *host_data, const std::array<size_t, 3> ®ion, const std::array<size_t, 3> &buffer_origin) const -> void
Read the Array region data into host memory.
- Parameters:
host_data – pointer to the host data
region – region of the array to read
buffer_origin – origin of the buffer to read
-
auto readTo(void *host_data, size_t x_coord, size_t y_coord, size_t z_coord) const -> void
Read the Array data at a specific position (x, y, z) into host memory.
- Parameters:
host_data – pointer to the host data
x_coord – x coordinate
y_coord – y coordinate
z_coord – z coordinate
-
auto copyTo(const Array::Pointer &dst) const -> void
Copy the Array data into another Array.
- Parameters:
dst – destination Array::Pointer
-
auto copyTo(const Array::Pointer &dst, const std::array<size_t, 3> ®ion, const std::array<size_t, 3> &src_origin, const std::array<size_t, 3> &dst_origin) const -> void
Copy the Array region data into another Array.
- Parameters:
dst – destination Array::Pointer
region – region of the array to copy
src_origin – origin of the source buffer
dst_origin – origin of the destination buffer
-
auto fill(float value) -> void
Fill the Array with a specific value.
- Parameters:
value – value to fill the array with
-
auto device() const -> Device::Pointer
Get the device pointer where the Array is stored.
- Returns:
Device::Pointer
-
auto dimension() const -> unsigned int
Get the dimension of the Array (1, 2 or 3)
- Returns:
unsigned int
-
auto c_get() const -> const void**
Get the const memory pointer of the Array.
- Returns:
const void **
-
~Array()
destructor
Public Static Functions
-
static auto create(size_t width, size_t height, size_t depth, size_t dimension, const dType &data_type, const mType &mem_type, const Device::Pointer &device_ptr) -> Array::Pointer
Create an empty new Array::Pointer object.
- Parameters:
width – width of the array
height – height of the array
depth – depth of the array
dimension – dimension of the array (1, 2 or 3)
data_type – data type of the array
mem_type – memory type of the array
device_ptr – device where the array is stored
- Returns:
Array::Pointer
-
static auto create(size_t width, size_t height, size_t depth, size_t dimension, const dType &data_type, const mType &mem_type, const void *host_data, const Device::Pointer &device_ptr) -> Array::Pointer
Create a new Array::Pointer object from host data pointer.
- Parameters:
width – width of the array
height – height of the array
depth – depth of the array
dimension – dimension of the array (1, 2 or 3)
data_type – data type of the array
mem_type – memory type of the array
host_data – pointer to the host data
device_ptr – device where the array is stored
- Returns:
Array::Pointer
-
auto allocate() -> void