Skip to content

Commit eceb700

Browse files
committed
more docu
1 parent 5f039b5 commit eceb700

2 files changed

Lines changed: 151 additions & 16 deletions

File tree

include/osp/concepts/computational_dag_concept.hpp

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,36 @@ limitations under the License.
2222

2323
#include "directed_graph_edge_desc_concept.hpp"
2424

25+
/**
26+
* @file computational_dag_concept.hpp
27+
* @brief Concepts for Computational Directed Acyclic Graphs (cDAGs).
28+
*
29+
* This file defines concepts that validate whether a graph type satisfies the requirements
30+
* of a computational DAG.
31+
*
32+
* A Computational DAG combines:
33+
* - The `directed_graph_concept`.
34+
* - Mandatory vertex weights: work, communication, and memory.
35+
*
36+
* Optional extensions include:
37+
* - Vertex types (for heterogeneous systems).
38+
* - Edge weights (communication).
39+
*
40+
* A computational DAG serves as an input to scheduling algorithms.
41+
*/
42+
2543
namespace osp {
2644

27-
// weighted vertices
45+
/**
46+
* @brief Concept to check if a graph has vertex weights.
47+
*
48+
* Requires validation of:
49+
* - `vertex_work_weight(v)`: Returns arithmetic type.
50+
* - `vertex_comm_weight(v)`: Returns arithmetic type.
51+
* - `vertex_mem_weight(v)`: Returns arithmetic type.
52+
*
53+
* @tparam T The graph type.
54+
*/
2855
template<typename T, typename = void>
2956
struct has_vertex_weights : std::false_type {};
3057

@@ -41,7 +68,18 @@ struct has_vertex_weights<T,
4168
template<typename T>
4269
inline constexpr bool has_vertex_weights_v = has_vertex_weights<T>::value;
4370

44-
// typed vertices concept
71+
/**
72+
* @brief Concept to check if a graph has typed vertices.
73+
*
74+
* Requires validation of:
75+
* - `vertex_type(v)`: Returns an integral type representing the type of vertex `v`.
76+
* - `num_vertex_types()`: Returns the total number of distinct vertex types.
77+
*
78+
* This is useful for scheduling on heterogeneous resources where tasks (vertices)
79+
* may be compatible only with certain processor types.
80+
*
81+
* @tparam T The graph type.
82+
*/
4583
template<typename T, typename = void>
4684
struct has_typed_vertices : std::false_type {};
4785

@@ -54,7 +92,15 @@ struct has_typed_vertices<T, std::void_t<decltype(std::declval<T>().vertex_type(
5492
template<typename T>
5593
inline constexpr bool has_typed_vertices_v = has_typed_vertices<T>::value;
5694

57-
// weighted edges concept
95+
/**
96+
* @brief Concept to check if edges have communication weights.
97+
*
98+
* Requires:
99+
* - The graph must satisfy `is_directed_graph_edge_desc` (supports edge descriptors).
100+
* - `edge_comm_weight(e)`: Returns an arithmetic type for a given edge descriptor `e`.
101+
*
102+
* @tparam T The graph type.
103+
*/
58104
template<typename T, typename = void>
59105
struct has_edge_weights : std::false_type {};
60106

@@ -69,7 +115,15 @@ struct has_edge_weights<T,
69115
template<typename T>
70116
inline constexpr bool has_edge_weights_v = has_edge_weights<T>::value;
71117

72-
// computational dag concept without explicit edges
118+
/**
119+
* @brief Concept for a basic computational DAG.
120+
*
121+
* A computational DAG must:
122+
* - Be a directed graph (`is_directed_graph`).
123+
* - Have mandatory vertex weights (`has_vertex_weights`): work, communication, and memory.
124+
*
125+
* @tparam T The graph type.
126+
*/
73127
template<typename T, typename = void>
74128
struct is_computational_dag : std::false_type {};
75129

@@ -79,8 +133,13 @@ struct is_computational_dag<T, std::void_t<>> : std::conjunction<is_directed_gra
79133
template<typename T>
80134
inline constexpr bool is_computational_dag_v = is_computational_dag<T>::value;
81135

82-
83-
// computational dag with typed vertices concept
136+
/**
137+
* @brief Concept for a computational DAG with typed vertices.
138+
*
139+
* Extends `is_computational_dag` by also requiring `has_typed_vertices`.
140+
*
141+
* @tparam T The graph type.
142+
*/
84143
template<typename T, typename = void>
85144
struct is_computational_dag_typed_vertices : std::false_type {};
86145

@@ -91,9 +150,14 @@ struct is_computational_dag_typed_vertices<T, std::void_t<>>
91150
template<typename T>
92151
inline constexpr bool is_computational_dag_typed_vertices_v = is_computational_dag_typed_vertices<T>::value;
93152

94-
95-
96-
// computational dag with explicit edges concept
153+
/**
154+
* @brief Concept for a computational DAG that supports explicit edge descriptors.
155+
*
156+
* Extends `is_computational_dag` by requiring `is_directed_graph_edge_desc`,
157+
* allowing iteration over edges using explicit descriptors.
158+
*
159+
* @tparam T The graph type.
160+
*/
97161
template<typename T, typename = void>
98162
struct is_computational_dag_edge_desc : std::false_type {};
99163

@@ -104,7 +168,13 @@ struct is_computational_dag_edge_desc<T, std::void_t<>>
104168
template<typename T>
105169
inline constexpr bool is_computational_dag_edge_desc_v = is_computational_dag_edge_desc<T>::value;
106170

107-
// computational_dag_typed_vertices_edge_idx concept
171+
/**
172+
* @brief Concept for a computational DAG with both typed vertices and edge descriptors.
173+
*
174+
* Combines `is_directed_graph_edge_desc` and `is_computational_dag_typed_vertices`.
175+
*
176+
* @tparam T The graph type.
177+
*/
108178
template<typename T, typename = void>
109179
struct is_computational_dag_typed_vertices_edge_desc : std::false_type {};
110180

include/osp/concepts/directed_graph_edge_desc_concept.hpp

Lines changed: 71 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,99 @@ limitations under the License.
1919
#pragma once
2020

2121
#include "directed_graph_concept.hpp"
22-
#include "osp/graph_algorithms/directed_graph_edge_view.hpp"
2322
#include "graph_traits.hpp"
23+
#include "osp/graph_algorithms/directed_graph_edge_view.hpp"
24+
25+
/**
26+
* @file directed_graph_edge_desc_concept.hpp
27+
* @brief Concepts and default implementations for edge descriptors in directed graphs.
28+
*
29+
* This file extends the basic directed graph concepts to support edge descriptors.
30+
* It provides default implementations for accessing source/target vertices from edges
31+
* and defines the `is_directed_graph_edge_desc` concept to check if a graph type
32+
* properly supports edge descriptors and edge iteration.
33+
*
34+
* Note: If a graph implementation satisfies `directed_graph_concept`, OSP automatically
35+
* adds the edge descriptor API on top using `directed_edge` as the default edge descriptor.
36+
* The mechanics for this are implemented in `directed_graph_edge_view.hpp`.
37+
*/
2438

2539
namespace osp {
2640

27-
// default implementation to get the source of an edge
41+
/**
42+
* @brief Default implementation to get the source vertex of an edge.
43+
*
44+
* @tparam Graph_t The graph type.
45+
* @param edge The edge descriptor.
46+
* @return The source vertex index.
47+
*/
2848
template<typename Graph_t>
2949
inline vertex_idx_t<Graph_t> source(const directed_edge<Graph_t> &edge, const Graph_t &) {
3050
return edge.source;
3151
}
3252

33-
// default implementation to get the target of an edge
53+
/**
54+
* @brief Default implementation to get the target vertex of an edge.
55+
*
56+
* @tparam Graph_t The graph type.
57+
* @param edge The edge descriptor.
58+
* @return The target vertex index.
59+
*/
3460
template<typename Graph_t>
3561
inline vertex_idx_t<Graph_t> target(const directed_edge<Graph_t> &edge, const Graph_t &) {
3662
return edge.target;
3763
}
3864

65+
/**
66+
* @brief Get a view of all edges in the graph.
67+
*
68+
* @tparam Graph_t The graph type.
69+
* @param graph The graph instance.
70+
* @return An `edge_view` allowing iteration over all edges.
71+
*/
3972
template<typename Graph_t>
4073
inline edge_view<Graph_t> edges(const Graph_t &graph) {
4174
return edge_view(graph);
4275
}
4376

77+
/**
78+
* @brief Get a view of outgoing edges from a vertex.
79+
*
80+
* @tparam Graph_t The graph type.
81+
* @param u The source vertex index.
82+
* @param graph The graph instance.
83+
* @return An `out_edge_view` allowing iteration over outgoing edges from `u`.
84+
*/
4485
template<typename Graph_t>
4586
inline out_edge_view<Graph_t> out_edges(vertex_idx_t<Graph_t> u, const Graph_t &graph) {
4687
return out_edge_view(graph, u);
4788
}
4889

90+
/**
91+
* @brief Get a view of incoming edges to a vertex.
92+
*
93+
* @tparam Graph_t The graph type.
94+
* @param v The target vertex index.
95+
* @param graph The graph instance.
96+
* @return An `in_edge_view` allowing iteration over incoming edges to `v`.
97+
*/
4998
template<typename Graph_t>
5099
inline in_edge_view<Graph_t> in_edges(vertex_idx_t<Graph_t> v, const Graph_t &graph) {
51100
return in_edge_view(graph, v);
52101
}
53102

103+
/**
104+
* @brief Concept check for a directed graph with edge descriptors.
105+
*
106+
* Checks if a type `T` satisfies the requirements of a directed graph that also
107+
* supports edge descriptors, including:
108+
* - Validity of `directed_graph_edge_desc_traits`.
109+
* - Existence of `edges()`, `out_edges()`, and `in_edges()` functions returning input ranges of edge descriptors.
110+
* - Existence of `source()` and `target()` functions mapping edge descriptors to vertex indices.
111+
* - Default and copy constructibility of the edge descriptor type.
112+
*
113+
* @tparam T The graph type to check.
114+
*/
54115
template<typename T, typename = void>
55116
struct is_directed_graph_edge_desc : std::false_type {};
56117

@@ -74,8 +135,13 @@ struct is_directed_graph_edge_desc<T,
74135
template<typename T>
75136
inline constexpr bool is_directed_graph_edge_desc_v = is_directed_graph_edge_desc<T>::value;
76137

77-
// Specialization for graphs that define a directed_edge_descriptor that can be used as a key in a hash table.
78-
// Compatible with STL hash tables.
138+
/**
139+
* @brief Specialization for graphs that define a directed_edge_descriptor that can be used as a key in a hash table.
140+
*
141+
* Compatible with STL hash tables (requires `std::hash` specialization and equality operator).
142+
*
143+
* @tparam T The graph type.
144+
*/
79145
template<typename T, typename = void>
80146
struct has_hashable_edge_desc : std::false_type {};
81147

@@ -87,7 +153,6 @@ struct has_hashable_edge_desc<T,
87153
: std::conjunction<is_directed_graph_edge_desc<T>, std::is_default_constructible<edge_desc_t<T>>,
88154
std::is_copy_constructible<edge_desc_t<T>>> {};
89155

90-
91156
template<typename T>
92157
inline constexpr bool has_hashable_edge_desc_v = has_hashable_edge_desc<T>::value;
93158

0 commit comments

Comments
 (0)