DQCsim
|
Wrapper class for a running simulation. More...
Public Member Functions | |
Simulation (HandleIndex handle) noexcept | |
Wraps the given simulation handle. More... | |
Simulation (const Simulation &)=delete | |
void | operator= (const Simulation &)=delete |
Simulation (Simulation &&)=default | |
Default move constructor. | |
Simulation & | operator= (Simulation &&)=default |
Default move assignment. | |
void | start () |
Starts a program on the simulated accelerator without an argument. More... | |
void | start (ArbData &&data) |
Starts a program on the simulated accelerator using the given ArbData object as an argument (passed by move). More... | |
void | start (const ArbData &data) |
Starts a program on the simulated accelerator using the given ArbData object as an argument (passed by copy). More... | |
ArbData | wait () |
Waits for the simulated accelerator to finish its current program. More... | |
ArbData | run () |
Runs a program on the simulated accelerator without an argument. More... | |
ArbData | run (ArbData &&data) |
Runs a program on the simulated accelerator using the given ArbData object as an argument (passed by move). More... | |
ArbData | run (const ArbData &data) |
Runs a program on the simulated accelerator using the given ArbData object as an argument (passed by copy). More... | |
void | send () |
Sends an empty message to the simulated accelerator. More... | |
void | send (ArbData &&data) |
Sends the given ArbData message to the simulated accelerator (passed by move). More... | |
void | send (const ArbData &data) |
Sends the given ArbData message to the simulated accelerator (passed by copy). More... | |
ArbData | recv () |
Waits for the simulated accelerator to send a message to us. More... | |
void | yield () |
Yields to the simulator. More... | |
ArbData | arb (const std::string &name, ArbCmd &&cmd) |
Sends an ArbCmd (passed by move) to the given plugin (referenced by instance name). More... | |
ArbData | arb (const std::string &name, const ArbCmd &cmd) |
Sends an ArbCmd (passed by copy) to the given plugin (referenced by instance name). More... | |
ArbData | arb (ssize_t index, ArbCmd &&cmd) |
Sends an ArbCmd (passed by move) to the given plugin (referenced by index). More... | |
ArbData | arb (ssize_t index, const ArbCmd &cmd) |
Sends an ArbCmd (passed by copy) to the given plugin (referenced by index). More... | |
std::string | get_name (const std::string &name) |
Queries the class name of a plugin, referenced by instance name. More... | |
std::string | get_name (ssize_t index) |
Queries the class name of a plugin, referenced by index. More... | |
std::string | get_author (const std::string &name) |
Queries the author of a plugin, referenced by instance name. More... | |
std::string | get_author (ssize_t index) |
Queries the author of a plugin, referenced by index. More... | |
std::string | get_version (const std::string &name) |
Queries the version of a plugin, referenced by instance name. More... | |
std::string | get_version (ssize_t index) |
Queries the version of a plugin, referenced by index. More... | |
void | write_reproduction_file (const std::string &filename) |
Writes a reproduction file for the simulation so far. More... | |
Public Member Functions inherited from dqcsim::wrap::Handle | |
Handle () noexcept | |
Constructs an empty wrapper. More... | |
Handle (HandleIndex handle) noexcept | |
Wraps the given raw handle. More... | |
virtual | ~Handle () noexcept |
Delete the handle and its wrapper. | |
void | free () |
Explicitly delete the handle, allowing errors to be caught. More... | |
bool | is_valid () const noexcept |
Returns whether this wrapper (still) contains a valid handle. More... | |
HandleIndex | get_handle () const noexcept |
Returns the raw handle without relinquishing ownership. More... | |
HandleIndex | take_handle () noexcept |
Returns the raw handle and relinquishes ownership. More... | |
Handle (const Handle &)=delete | |
void | operator= (const Handle &)=delete |
Handle (Handle &&src) | |
Move constructor; simply moves ownership of the handle from the source object to the constructed object. More... | |
Handle & | operator= (Handle &&src) |
Move constructor; simply moves ownership of the handle from the source object to the assignment target. More... | |
std::string | dump () const |
Returns a string containing a debug dump of the handle. More... | |
HandleType | type () const |
Returns the type of this handle. More... | |
Additional Inherited Members | |
Protected Attributes inherited from dqcsim::wrap::Handle | |
HandleIndex | handle |
The wrapped handle. | |
|
inlinenoexcept |
|
inline |
Starts a program on the simulated accelerator without an argument.
What constitutes "running a program" depends on the frontend plugin.
yield()
, recv()
, wait()
, or run()
is called.std::runtime_error | When the simulation is in an invalid state. |
|
inline |
Starts a program on the simulated accelerator using the given ArbData
object as an argument (passed by move).
What constitutes "running a program" depends on the frontend plugin.
yield()
, recv()
, wait()
, or run()
is called.data | An ArbData object to pass to the plugin's run callback. |
std::runtime_error | When the simulation is in an invalid state. |
|
inline |
Starts a program on the simulated accelerator using the given ArbData
object as an argument (passed by copy).
What constitutes "running a program" depends on the frontend plugin.
yield()
, recv()
, wait()
, or run()
is called.data | An ArbData object to pass to the plugin's run callback. |
std::runtime_error | When the simulation is in an invalid state. |
|
inline |
Waits for the simulated accelerator to finish its current program.
ArbData
object that was returned by the frontend plugin's implementation of the run
callback. std::runtime_error | When the simulation is in an invalid state or a deadlock occurs because the frontend is waiting for a call to send() . |
|
inline |
Runs a program on the simulated accelerator without an argument.
This is just a shorthand for start()
followed by wait()
.
ArbData
object that was returned by the frontend plugin's implementation of the run
callback. std::runtime_error | When the simulation is in an invalid state or a deadlock occurs because the frontend is waiting for a call to send() . |
Runs a program on the simulated accelerator using the given ArbData
object as an argument (passed by move).
This is just a shorthand for start()
followed by wait()
.
data | An ArbData object to pass to the plugin's run callback. |
ArbData
object that was returned by the frontend plugin's implementation of the run
callback. std::runtime_error | When the simulation is in an invalid state or a deadlock occurs because the frontend is waiting for a call to send() . |
Runs a program on the simulated accelerator using the given ArbData
object as an argument (passed by copy).
This is just a shorthand for start()
followed by wait()
.
data | An ArbData object to pass to the plugin's run callback. |
ArbData
object that was returned by the frontend plugin's implementation of the run
callback. std::runtime_error | When the simulation is in an invalid state or a deadlock occurs because the frontend is waiting for a call to send() . |
|
inline |
|
inline |
Sends the given ArbData
message to the simulated accelerator (passed by move).
yield()
, recv()
, wait()
, or run()
is called.data | The ArbData object to send to the plugin. |
std::runtime_error | When the simulation is in an invalid state. |
|
inline |
Sends the given ArbData
message to the simulated accelerator (passed by copy).
yield()
, recv()
, wait()
, or run()
is called.data | The ArbData object to send to the plugin. |
std::runtime_error | When the simulation is in an invalid state. |
|
inline |
|
inline |
Yields to the simulator.
The simulation runs until it blocks again. This is useful if you want an immediate response to an otherwise asynchronous call through the logging system or some communication channel outside of DQCsim's control.
This function silently returns immediately if no asynchronous data was pending or if the simulator is waiting for something that has not been sent yet.
std::runtime_error | When the simulation is in an invalid state. |
Sends an ArbCmd
(passed by move) to the given plugin (referenced by instance name).
ArbCmd
s are executed immediately after yielding to the simulator, so all pending asynchronous calls are flushed and executed before the ArbCmd
.
name | The instance name of the plugin to send the command to. |
cmd | The command to send. |
ArbData
object returned by the command. std::runtime_error | When the given name does not identify a plugin, the command failed, or the simulation is in an invalid state. |
Sends an ArbCmd
(passed by copy) to the given plugin (referenced by instance name).
ArbCmd
s are executed immediately after yielding to the simulator, so all pending asynchronous calls are flushed and executed before the ArbCmd
.
name | The instance name of the plugin to send the command to. |
cmd | The command to send. |
ArbData
object returned by the command. std::runtime_error | When the given name does not identify a plugin, the command failed, or the simulation is in an invalid state. |
Sends an ArbCmd
(passed by move) to the given plugin (referenced by index).
ArbCmd
s are executed immediately after yielding to the simulator, so all pending asynchronous calls are flushed and executed before the ArbCmd
.
index | The index of the plugin to send the command to. The frontend always has index 0. 1 through N are used for the operators in front to back order (where N is the number of operators). The backend is at index N+1. Python-style negative indices are also supported. That is, -1 can be used to refer to the backend, -2 to the last operator, and so on. |
cmd | The command to send. |
ArbData
object returned by the command. std::runtime_error | When the given index is out of range, the command failed, or the simulation is in an invalid state. |
Sends an ArbCmd
(passed by copy) to the given plugin (referenced by index).
ArbCmd
s are executed immediately after yielding to the simulator, so all pending asynchronous calls are flushed and executed before the ArbCmd
.
index | The index of the plugin to send the command to. The frontend always has index 0. 1 through N are used for the operators in front to back order (where N is the number of operators). The backend is at index N+1. Python-style negative indices are also supported. That is, -1 can be used to refer to the backend, -2 to the last operator, and so on. |
cmd | The command to send. |
ArbData
object returned by the command. std::runtime_error | When the given index is out of range, the command failed, or the simulation is in an invalid state. |
|
inline |
Queries the class name of a plugin, referenced by instance name.
name | The instance name of the plugin to query. |
std::runtime_error | When the given name does not identify a plugin, or when the simulation is in an invalid state. |
|
inline |
Queries the class name of a plugin, referenced by index.
index | The index of the plugin to query. The frontend always has index 0. 1 through N are used for the operators in front to back order (where N is the number of operators). The backend is at index N+1. Python-style negative indices are also supported. That is, -1 can be used to refer to the backend, -2 to the last operator, and so on. |
std::runtime_error | When the given index is out of range, or when the simulation is in an invalid state. |
|
inline |
Queries the author of a plugin, referenced by instance name.
name | The instance name of the plugin to query. |
std::runtime_error | When the given name does not identify a plugin, or when the simulation is in an invalid state. |
|
inline |
Queries the author of a plugin, referenced by index.
index | The index of the plugin to query. The frontend always has index 0. 1 through N are used for the operators in front to back order (where N is the number of operators). The backend is at index N+1. Python-style negative indices are also supported. That is, -1 can be used to refer to the backend, -2 to the last operator, and so on. |
std::runtime_error | When the given index is out of range, or when the simulation is in an invalid state. |
|
inline |
Queries the version of a plugin, referenced by instance name.
name | The instance name of the plugin to query. |
std::runtime_error | When the given name does not identify a plugin, or when the simulation is in an invalid state. |
|
inline |
Queries the version of a plugin, referenced by index.
index | The index of the plugin to query. The frontend always has index 0. 1 through N are used for the operators in front to back order (where N is the number of operators). The backend is at index N+1. Python-style negative indices are also supported. That is, -1 can be used to refer to the backend, -2 to the last operator, and so on. |
std::runtime_error | When the given index is out of range, or when the simulation is in an invalid state. |
|
inline |