|
rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
|
Tracks the commands that access a piece of memory. More...
#include <rexlib/core/ndarray/access_hazard_tracker.hpp>
Public Member Functions | |
| access_hazard_tracker () | |
| Construct a tracker with no command recorded. | |
| access_hazard_tracker (const access_hazard_tracker &other)=delete | |
| access_hazard_tracker (access_hazard_tracker &&other)=delete | |
| access_hazard_tracker & | operator= (const access_hazard_tracker &other)=delete |
| access_hazard_tracker & | operator= (access_hazard_tracker &&other)=delete |
| void | add (command_token token, access_flags access) |
| Record a command that accesses the memory. | |
| void | collect (access_flags access, std::vector< command_token > &tokens) const |
| Get the tokens that an access has to wait for. | |
| void | wait (access_flags access) const |
| Block the calling thread until an access can take place. | |
Tracks the commands that access a piece of memory.
The tracker holds the token of the last command that writes the memory and the tokens of the commands that read it since. It tells an access which of them it has to wait for: a read waits for the write, and a write waits for the write and for every read.
An access that includes a write is a write.
| void rexlib::access_hazard_tracker::add | ( | command_token | token, |
| access_flags | access | ||
| ) |
Record a command that accesses the memory.
A read is added to the reads recorded since the last write. A write replaces everything recorded before it, so the command has to wait for the tokens that collect gives a write.
| token | The token of the command. An empty token is not kept. |
| access | How the command accesses the memory. |
| std::invalid_argument | If access is empty. |
| void rexlib::access_hazard_tracker::collect | ( | access_flags | access, |
| std::vector< command_token > & | tokens | ||
| ) | const |
Get the tokens that an access has to wait for.
| access | How the memory is going to be accessed. |
| tokens | Output parameter where the tokens are appended. |
| std::invalid_argument | If access is empty. |
| void rexlib::access_hazard_tracker::wait | ( | access_flags | access | ) | const |
Block the calling thread until an access can take place.
Waits for the tokens that collect gives access.
| access | How the memory is going to be accessed. |
| std::invalid_argument | If access is empty. |