rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
Loading...
Searching...
No Matches
command.hpp
1// SPDX-License-Identifier: GPL-3.0-only
2
3#pragma once
4
5#include "buffer.hpp"
6#include "command_token.hpp"
7#include "program.hpp"
8
9#include <rexlib/core/platform/dynamic_shared_object.h>
10#include <rexlib/core/span.hpp>
11
12#include <memory>
13#include <vector>
14
15namespace rexlib
16{
17
31{
32public:
36 REXLIB_API
37 command() noexcept;
38
49 REXLIB_API
50 explicit command(std::shared_ptr<const program> program) noexcept;
51
52 REXLIB_API
53 command(const command &other);
54 REXLIB_API
55 command(command &&other) noexcept;
56 REXLIB_API
57 ~command();
58
59 REXLIB_API
60 command& operator=(const command &other);
61 REXLIB_API
62 command& operator=(command &&other) noexcept;
63
72 REXLIB_API
73 command&
74 bind_outputs(std::vector<std::shared_ptr<buffer>> outputs) noexcept;
75
84 REXLIB_API
85 command&
86 bind_inputs(std::vector<std::shared_ptr<const buffer>> inputs) noexcept;
87
101 REXLIB_API
102 command&
103 bind_scratch(std::vector<std::shared_ptr<buffer>> scratch) noexcept;
104
114 REXLIB_API
115 command&
116 bind_dependencies(std::vector<command_token> dependencies) noexcept;
117
123 REXLIB_API
124 const std::shared_ptr<const program>& get_program() const noexcept;
125
133 REXLIB_API
134 span<const std::shared_ptr<buffer>> get_outputs() const noexcept;
135
143 REXLIB_API
144 span<const std::shared_ptr<const buffer>> get_inputs() const noexcept;
145
153 REXLIB_API
154 span<const std::shared_ptr<buffer>> get_scratch() const noexcept;
155
163 REXLIB_API
164 span<const command_token> get_dependencies() const noexcept;
165
166private:
167 std::shared_ptr<const program> m_program;
168 std::vector<std::shared_ptr<buffer>> m_outputs;
169 std::vector<std::shared_ptr<const buffer>> m_inputs;
170 std::vector<std::shared_ptr<buffer>> m_scratch;
171 std::vector<command_token> m_dependencies;
172};
173
174} // namespace rexlib
Represents an untyped memory allocation at a given memory resource.
Definition buffer.hpp:25
Identifies a command submitted to a command_queue.
Definition command_token.hpp:27
Specification of work to be executed on a command_queue.
Definition command.hpp:31
span< const std::shared_ptr< buffer > > get_scratch() const noexcept
Get the bound scratch buffers.
command & bind_outputs(std::vector< std::shared_ptr< buffer > > outputs) noexcept
Bind the output buffers for this command.
command & bind_inputs(std::vector< std::shared_ptr< const buffer > > inputs) noexcept
Bind the input buffers for this command.
span< const std::shared_ptr< const buffer > > get_inputs() const noexcept
Get the bound input buffers.
command & bind_scratch(std::vector< std::shared_ptr< buffer > > scratch) noexcept
Bind the scratch buffers for this command.
command() noexcept
Construct a command with no program and empty bindings.
command & bind_dependencies(std::vector< command_token > dependencies) noexcept
Bind the commands this command has to run after.
span< const command_token > get_dependencies() const noexcept
Get the bound dependencies.
const std::shared_ptr< const program > & get_program() const noexcept
Get the program associated with this command.
span< const std::shared_ptr< buffer > > get_outputs() const noexcept
Get the bound output buffers.
Abstract representation of an executable program.
Definition program.hpp:27
Represents a non-owning area of contiguous memory.
Definition span.hpp:99
Arrays, the operations on them and the devices that run those operations.
Definition cpu_device.hpp:10
@ inputs
Bound by the input axes that name the variable.