## UfoTaskGraph

UfoTaskGraph — Hold task nodes

## Functions

UfoGraph * | ufo_task_graph_new ()
void | ufo_task_graph_read_from_file ()
void | ufo_task_graph_read_from_data ()
void | ufo_task_graph_save_to_json ()
gchar * | ufo_task_graph_get_json_data ()
gboolean | ufo_task_graph_is_alright ()
void | ufo_task_graph_map ()
void | ufo_task_graph_expand ()
void | ufo_task_graph_connect_nodes ()
void | ufo_task_graph_connect_nodes_full ()
void | ufo_task_graph_fuse ()
void | ufo_task_graph_set_partition ()
void | ufo_task_graph_get_partition ()
GQuark | ufo_task_graph_error_quark ()

## Types and Values

#define | UFO_TASK_GRAPH_ERROR
enum | UfoTaskGraphError
struct | UfoTaskGraph
struct | UfoTaskGraphClass

## Object Hierarchy

        GObject
        ╰── UfoGraph
            ╰── UfoTaskGraph

## Description

The task graph is the central data structure that connects UfoTaskNode objects to form computational pipelines and graphs. To execute a task graph, it has to be passed to a UfoBaseScheduler.

## Functions

### ufo_task_graph_new ()

    UfoGraph *
    ufo_task_graph_new (void);

Create a new task graph without any nodes.

#### Returns

A UfoGraph that can be upcast to a UfoTaskGraph.

### ufo_task_graph_read_from_file ()

    void
    ufo_task_graph_read_from_file (UfoTaskGraph *graph,
                                   UfoPluginManager *manager,
                                   const gchar *filename,
                                   GError **error);

Read a JSON configuration file to fill the structure of `graph` .

#### Parameters

graph | A UfoTaskGraph. |
manager | A UfoPluginManager used to load the filters |
filename | Path and filename to the JSON file |
error | Indicates error in case of failed file loading or parsing |

### ufo_task_graph_read_from_data ()

    void
    ufo_task_graph_read_from_data (UfoTaskGraph *graph,
                                   UfoPluginManager *manager,
                                   const gchar *json,
                                   GError **error);

Read a JSON configuration file to fill the structure of `graph` .

#### Parameters

graph | A UfoTaskGraph. |
manager | A UfoPluginManager used to load the filters |
json | `NULL`-terminated string with JSON data |
error | Indicates error in case of failed file loading or parsing |

### ufo_task_graph_save_to_json ()

    void
    ufo_task_graph_save_to_json (UfoTaskGraph *graph,
                                 const gchar *filename,
                                 GError **error);

Save a JSON configuration file with the filter structure of `graph` .

#### Parameters

graph | A UfoTaskGraph |
filename | Path and filename to the JSON file |
error | Indicates error in case of failed file saving |

### ufo_task_graph_get_json_data ()

    gchar *
    ufo_task_graph_get_json_data (UfoTaskGraph *graph,
                                  GError **error);

Serialize `graph` to a JSON string.

#### Parameters

graph | A UfoTaskGraph |
error | Indicates error in case of failed serialization |

#### Returns

A JSON string describing `graph` .

[transfer full]

### ufo_task_graph_is_alright ()

    gboolean
    ufo_task_graph_is_alright (UfoTaskGraph *graph,
                               GError **error);

Check if nodes int the task graph are properly connected.

#### Parameters

graph | A UfoTaskGraph |
error | Location for a GError or `NULL` |

#### Returns

`TRUE` if everything is alright, `FALSE` else.

### ufo_task_graph_map ()

    void
    ufo_task_graph_map (UfoTaskGraph *graph,
                        GList *gpu_nodes);

Map task nodes of `graph` to the list of `gpu_nodes` .

#### Parameters

graph | A UfoTaskGraph |
gpu_nodes | List of UfoGpuNode objects. | [transfer none][element-type Ufo.GpuNode]

### ufo_task_graph_expand ()

    void
    ufo_task_graph_expand (UfoTaskGraph *graph,
                           UfoResources *resources,
                           guint n_gpus,
                           GError **error);

Expands `graph` in a way that most of the resources in `graph` can be occupied. In the simple pipeline case, the longest possible GPU paths are duplicated as much as there are GPUs in `arch_graph` .

#### Parameters

graph | A UfoTaskGraph |
resources | A UfoResources objects |
n_gpus | Number of GPUs to expand the graph for |
error | error to pass on |

### ufo_task_graph_connect_nodes ()

    void
    ufo_task_graph_connect_nodes (UfoTaskGraph *graph,
                                  UfoTaskNode *n1,
                                  UfoTaskNode *n2);

Connect `n1` with `n2` using `n2` 's default input port. To specify any other port, use `ufo_task_graph_connect_nodes_full()`.

#### Parameters

graph | A UfoTaskGraph |
n1 | A source node |
n2 | A destination node |

### ufo_task_graph_connect_nodes_full ()

    void
    ufo_task_graph_connect_nodes_full (UfoTaskGraph *graph,
                                       UfoTaskNode *n1,
                                       UfoTaskNode *n2,
                                       guint input);

Connect `n1` with `n2` using `n2` 's `input` port.

#### Parameters

graph | A UfoTaskGraph |
n1 | A source node |
n2 | A destination node |
input | Input port of `n2` |

### ufo_task_graph_fuse ()

    void
    ufo_task_graph_fuse (UfoTaskGraph *graph);

Fuses task nodes to increase data locality.

Note: This is not implemented and a no-op right now.

#### Parameters

graph | A UfoTaskGraph |

### ufo_task_graph_set_partition ()

    void
    ufo_task_graph_set_partition (UfoTaskGraph *graph,
                                  guint index,
                                  guint total);

Set the partition of this task graph.

#### Parameters

graph | A UfoTaskGraph |
index | index of `total` partitions - 1 |
total | total number of partitions |

### ufo_task_graph_get_partition ()

    void
    ufo_task_graph_get_partition (UfoTaskGraph *graph,
                                  guint *index,
                                  guint *total);

Get the partition structure of `graph` .

#### Parameters

graph | A UfoTaskGraph |
index | Location to store index |
total | Location to store the total number of partitions |

### ufo_task_graph_error_quark ()

    GQuark
    ufo_task_graph_error_quark (void);

## Types and Values

### UFO_TASK_GRAPH_ERROR

    #define UFO_TASK_GRAPH_ERROR            ufo_task_graph_error_quark()

### enum UfoTaskGraphError

Task graph errors

#### Members

UFO_TASK_GRAPH_ERROR_JSON_KEY | Key is not found in JSON |
UFO_TASK_GRAPH_ERROR_BAD_INPUTS | Inputs of a task do not play well with each other. |

### struct UfoTaskGraph

    struct UfoTaskGraph;

Main object for organizing filters. The contents of the UfoTaskGraph structure are private and should only be accessed via the provided API.

### struct UfoTaskGraphClass

    struct UfoTaskGraphClass {
    };

UfoTaskGraph class