NSIMD documentation
Index | Tutorial | FAQ | Contribute | API overview | API reference | Wrapped intrinsics | Modules
Memory management module documentation

Overview

This module provides C-style memory managmenent functions. Its purpose is not to become a fully feature container library. It is to provide portable malloc, memcpy and free functions with a little helpers to copy data from and to the devices.

API reference

Equivalents of malloc, calloc, memcpy and free for devices

Note that the below functions simply wraps the corresponding C functions when targeting a CPU.

Pairs of pointers

It is often useful to allocate a pair of data buffers: one on the host and one on the devices to perform data transfers. The below functions provides quick ways to malloc, calloc, free and memcpy pointers on host and devices at once. Note that when targeting CPUs the pair of pointers is reduced to one pointer that ponit the a single data buffer in which case memcpy's are not performed. Note also that there is no implicit synchronization of data between both data buffers. It is up to the programmer to triggers memcpy's.

template <typename T>
struct paired_pointers_t {
  T *device_ptr, *host_ptr;
  size_t sz;
};

Members of the above structure are not to be modified but can be passed as arguments for reading/writing data from/to memory they point to.