rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
Loading...
Searching...
No Matches
access_hazard_tracker.hpp
1// SPDX-License-Identifier: GPL-3.0-only
2
3#pragma once
4
5#include "../hardware/command_token.hpp"
6#include "../platform/dynamic_shared_object.h"
7#include "../system/access_flags.hpp"
8
9#include <mutex>
10#include <vector>
11
12namespace rexlib
13{
14
29{
30public:
40
42 operator=(const access_hazard_tracker &other) = delete;
44 operator=(access_hazard_tracker &&other) = delete;
45
60
70 void collect(
72 std::vector<command_token> &tokens
73 ) const;
74
86
87private:
88 mutable std::mutex m_mutex;
89 command_token m_write;
90 std::vector<command_token> m_reads;
91
92 void drop_complete_reads();
93};
94
95} // namespace rexlib
Tracks the commands that access a piece of memory.
Definition access_hazard_tracker.hpp:29
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.
access_hazard_tracker()
Construct a tracker with no command recorded.
void wait(access_flags access) const
Block the calling thread until an access can take place.
Container for multidimensional numeric data.
Definition array.hpp:31
Identifies a command submitted to a command_queue.
Definition command_token.hpp:27
Arrays, the operations on them and the devices that run those operations.
Definition cpu_device.hpp:10