In addition to loop parallelism, the oneAPI Threading Building Blocks library also supports graph parallelism. It’s possible to create graphs that are highly scalable, but it is also possible to create graphs that are completely sequential.
There are 3 types of components used to implement a graph:
Ports and edges
graph class instance is the owner of the tasks created on behalf of the flow graph. Users can wait
graph if they need to wait for the completion of all of the tasks related to the flow
graph execution. One can also register external interactions with the
graph and run tasks under
the ownership of the flow graph.
In order to be used as a graph node type, a class needs to inherit certain abstract types and implement the
graph_node is the base class for any other node type; its interfaces
always have to be implemented. If a node sends messages to other nodes, it has to implement the
interface, while with
receiver interface the node may accept messages. For nodes that have multiple
inputs and/or outputs, each input port is a
receiver and each output port is a
Functional nodes do computations in response to input messages (if any), and send the result or a signal to their successors.
Buffering nodes are designed to accumulate input messages and pass them to successors in a predefined order, depending on the node type.
These nodes are designed for advanced control of the message flow, such as combining messages from different paths in a graph or limiting the number of simultaneously processed messages, as well as for creating reusable custom nodes.
Ports and Edges¶
Flow Graph provides an API to manage connections between the nodes.
For nodes that have more than one input or output port (ex.
making a connection requires to specify a certain port by using special helper functions.
Special Messages Types¶
Flow Graph supports a set of specific message types.