ALP User Documentation 0.7.0
Algebraic Programming User Documentation
|
Provides a mechanism to access ALP containers from outside of an ALP context. More...
#include <pinnedvector.hpp>
Public Member Functions | |
PinnedVector () | |
Base constructor for this class. More... | |
template<typename Coord > | |
PinnedVector (const Vector< IOType, implementation, Coord > &vector, const IOMode mode) | |
Pins the contents of a given vector. More... | |
~PinnedVector () | |
Destroys a grb::PinnedVector instance. More... | |
size_t | getNonzeroIndex (const size_t k) const noexcept |
Retrieves a nonzero index. More... | |
IOType | getNonzeroValue (const size_t k) const noexcept |
Direct access variation of the general getNonzeroValue function. More... | |
template<typename OutputType > | |
OutputType | getNonzeroValue (const size_t k, const OutputType one=OutputType()) const noexcept |
Returns a requested nonzero of the pinned vector. More... | |
size_t | nonzeroes () const noexcept |
size_t | size () const noexcept |
Provides a mechanism to access ALP containers from outside of an ALP context.
An instance of grb::PinnedVector caches a container's data and returns it to the user. The user can refer to the returned data until such time the instance of grb::PinnedVector is destroyed, regardless of whether a call to grb::finalize occurs, and regardless whether the ALP/GraphBLAS program executed through the grb::Launcher had already returned.
The original container may not be modified or any derived instance of PinnedVector shall become invalid.
The grb::PinnedVector abstracts a read-only container of nonzeroes. A nonzero is a pair of indices and values. One may query for the number of nonzeroes and use
An instance of grb::PinnedVector cannot modify the underlying nonzero structure nor can it modify its values.
|
inline |
Pins the contents of a given vector.
A successfully constructed grb::PinnedVector shall remain valid until it is destroyed, regardless of whether the ALP context in which the original vector appears has been destroyed.
Pinning may or may not require a memory copy, depending on the ALP implementation and backend. If it does not, then destroying this instance may result in memory deallocation. It only must result in deallocation if the pinned vector that did not require a memory copy happens to be the last remaining reference to the original vector.
If one user process calls this constructor, all user processes must do so and with the same arguments– this is a collective call.
All member functions of this class are not collective.
[in] | vector | The vector to pin the memory of. |
[in] | mode | The grb::IOMode. |
The mode argument is optional. The default is grb::PARALLEL.
|
inline |
Base constructor for this class.
This corresponds to pinning an empty vector of zero size in PARALLEL mode. A call to this function inherits the same performance semantics as described above.
Unlike the above, and exceptionally, calling this constructor need not be a collective operation.
|
inline |
Destroys a grb::PinnedVector instance.
Destroying a pinned vector will only remove the underlying vector data if and only if: 1) the original grb::Vector has been destroyed; 2) no other PinnedVector instance derived from the same source container exists.
|
inlinenoexcept |
Retrieves a nonzero index.
[in] | k | The nonzero ID to return the index of. |
A nonzero is a tuple of an index and nonzero value. A pinned vector holds nonzeroes nonzeroes. Therefore, k must be less than nonzeroes.
|
inlinenoexcept |
Direct access variation of the general getNonzeroValue function.
This variant is only defined when IOType is not void
.
void
, then robust code should use the general getNonzeroValue variant.For semantics, including performance semantics, see the general specification of getNonzeroValue.
|
inlinenoexcept |
Returns a requested nonzero of the pinned vector.
OutputType | The value type returned by this function. If this differs from IOType and IOType is not void , then nonzero values will be cast to OutputType. |
[in] | k | The nonzero ID to return the value of. |
[in] | one | (Optional.) In case IOType is void , which value should be returned in lieu of a vector element value. By default, this will be a default-constructed instance of OutputType. |
If OutputType cannot be default-constructed, then one no longer is optional.
A nonzero is a tuple of an index and nonzero value. A pinned vector holds nonzeroes nonzeroes. Therefore, k must be less than nonzeroes.
|
inlinenoexcept |
|
inlinenoexcept |