Skip to content

Commit 08c5468

Browse files
authored
added docu to concepts files (#61)
1 parent 0c4ee15 commit 08c5468

File tree

7 files changed

+453
-68
lines changed

7 files changed

+453
-68
lines changed

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/constructable_computational_dag_concept.hpp

Lines changed: 88 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,32 @@ limitations under the License.
2222

2323
#include "computational_dag_concept.hpp"
2424

25+
/**
26+
* @file constructable_computational_dag_concept.hpp
27+
* @brief Concepts for Constructable and Modifiable Computational DAGs.
28+
*
29+
* This file defines concepts that validate whether a graph type supports dynamic construction
30+
* and modification of its structure and properties. This includes adding vertices and edges,
31+
* as well as setting weights and types for existing elements.
32+
*
33+
* These concepts are useful for algorithms that need to build or transform graphs,
34+
* such as graph generators or coarsening algorithms.
35+
*/
2536

2637
namespace osp {
2738

28-
// modify vertices
39+
/**
40+
* @brief Concept to check if vertex weights are modifiable.
41+
*
42+
* Requires:
43+
* - `set_vertex_work_weight(v, w)`
44+
* - `set_vertex_comm_weight(v, w)`
45+
* - `set_vertex_mem_weight(v, w)`
46+
*
47+
* Also requires the graph to be default constructible, copy/move constructible, and assignable.
48+
*
49+
* @tparam T The graph type.
50+
*/
2951
template<typename T, typename = void>
3052
struct is_modifiable_cdag_vertex : std::false_type {};
3153

@@ -36,54 +58,83 @@ struct is_modifiable_cdag_vertex<
3658
decltype(std::declval<T>().set_vertex_mem_weight(std::declval<vertex_idx_t<T>>(), std::declval<v_memw_t<T>>()))>>
3759
: std::conjunction<is_computational_dag<T>,
3860
std::is_default_constructible<T>,
39-
std::is_copy_constructible<T>,
40-
std::is_move_constructible<T>,
61+
std::is_copy_constructible<T>,
62+
std::is_move_constructible<T>,
4163
std::is_copy_assignable<T>,
4264
std::is_move_assignable<T>> {};
4365

4466
template<typename T>
4567
inline constexpr bool is_modifiable_cdag_vertex_v = is_modifiable_cdag_vertex<T>::value;
4668

47-
// add vertices
69+
/**
70+
* @brief Concept to check if vertices can be added to the graph.
71+
*
72+
* Requires:
73+
* - `add_vertex(work_weight, comm_weight, mem_weight)`
74+
* - Constructibility from `vertex_idx_t` (for reserving size).
75+
*
76+
* @tparam T The graph type.
77+
*/
4878
template<typename T, typename = void>
4979
struct is_constructable_cdag_vertex : std::false_type {};
5080

5181
template<typename T>
5282
struct is_constructable_cdag_vertex<
5383
T, std::void_t<decltype(std::declval<T>().add_vertex(std::declval<v_workw_t<T>>(), std::declval<v_commw_t<T>>(), std::declval<v_memw_t<T>>()))>>
54-
: std::conjunction<is_modifiable_cdag_vertex<T>,
84+
: std::conjunction<is_modifiable_cdag_vertex<T>,
5585
std::is_constructible<T, vertex_idx_t<T>>> {};
5686

5787
template<typename T>
5888
inline constexpr bool is_constructable_cdag_vertex_v = is_constructable_cdag_vertex<T>::value;
5989

60-
// modify vertices types
90+
/**
91+
* @brief Concept to check if vertex types are modifiable.
92+
*
93+
* Requires:
94+
* - `set_vertex_type(v, type)`
95+
*
96+
* @tparam T The graph type.
97+
*/
6198
template<typename T, typename = void>
6299
struct is_modifiable_cdag_typed_vertex : std::false_type {};
63100

64101
template<typename T>
65102
struct is_modifiable_cdag_typed_vertex<
66103
T, std::void_t<decltype(std::declval<T>().set_vertex_type(std::declval<vertex_idx_t<T>>(), std::declval<v_type_t<T>>()))>>
67-
: std::conjunction<is_modifiable_cdag_vertex<T>,
104+
: std::conjunction<is_modifiable_cdag_vertex<T>,
68105
is_computational_dag_typed_vertices<T>> {}; // for default node type
69106

70107
template<typename T>
71108
inline constexpr bool is_modifiable_cdag_typed_vertex_v = is_modifiable_cdag_typed_vertex<T>::value;
72109

73-
// add vertices with types
110+
/**
111+
* @brief Concept to check if typed vertices can be added.
112+
*
113+
* Requires:
114+
* - `add_vertex(work, comm, mem, type)`
115+
*
116+
* @tparam T The graph type.
117+
*/
74118
template<typename T, typename = void>
75119
struct is_constructable_cdag_typed_vertex : std::false_type {};
76120

77121
template<typename T>
78122
struct is_constructable_cdag_typed_vertex<
79123
T, std::void_t<decltype(std::declval<T>().add_vertex(std::declval<v_workw_t<T>>(), std::declval<v_commw_t<T>>(), std::declval<v_memw_t<T>>(), std::declval<v_type_t<T>>()))>>
80-
: std::conjunction<is_constructable_cdag_vertex<T>,
124+
: std::conjunction<is_constructable_cdag_vertex<T>,
81125
is_modifiable_cdag_typed_vertex<T>> {}; // for default node type
82126

83127
template<typename T>
84128
inline constexpr bool is_constructable_cdag_typed_vertex_v = is_constructable_cdag_typed_vertex<T>::value;
85129

86-
// add edges
130+
/**
131+
* @brief Concept to check if edges can be added (unweighted).
132+
*
133+
* Requires:
134+
* - `add_edge(source, target)`
135+
*
136+
* @tparam T The graph type.
137+
*/
87138
template<typename T, typename = void>
88139
struct is_constructable_cdag_edge : std::false_type {};
89140

@@ -95,7 +146,14 @@ struct is_constructable_cdag_edge<T, std::void_t<decltype(std::declval<T>().add_
95146
template<typename T>
96147
inline constexpr bool is_constructable_cdag_edge_v = is_constructable_cdag_edge<T>::value;
97148

98-
// modify edges with comm costs
149+
/**
150+
* @brief Concept to check if edge communication weights are modifiable.
151+
*
152+
* Requires:
153+
* - `set_edge_comm_weight(edge, weight)`
154+
*
155+
* @tparam T The graph type.
156+
*/
99157
template<typename T, typename = void>
100158
struct is_modifiable_cdag_comm_edge : std::false_type {};
101159

@@ -107,20 +165,34 @@ struct is_modifiable_cdag_comm_edge<
107165
template<typename T>
108166
inline constexpr bool is_modifiable_cdag_comm_edge_v = is_modifiable_cdag_comm_edge<T>::value;
109167

110-
// add edges with comm costs
168+
/**
169+
* @brief Concept to check if weighted edges can be added.
170+
*
171+
* Requires:
172+
* - `add_edge(source, target, weight)`
173+
*
174+
* @tparam T The graph type.
175+
*/
111176
template<typename T, typename = void>
112177
struct is_constructable_cdag_comm_edge : std::false_type {};
113178

114179
template<typename T>
115180
struct is_constructable_cdag_comm_edge<
116181
T, std::void_t<decltype(std::declval<T>().add_edge(std::declval<vertex_idx_t<T>>(), std::declval<vertex_idx_t<T>>(), std::declval<e_commw_t<T>>()))>>
117-
: std::conjunction<is_constructable_cdag_edge<T>,
182+
: std::conjunction<is_constructable_cdag_edge<T>,
118183
is_computational_dag_edge_desc<T>,
119184
is_modifiable_cdag_comm_edge<T>> {}; // for default edge weight
120185

121186
template<typename T>
122187
inline constexpr bool is_constructable_cdag_comm_edge_v = is_constructable_cdag_comm_edge<T>::value;
123188

189+
/**
190+
* @brief Concept for a fully constructable computational DAG.
191+
*
192+
* Combines `is_constructable_cdag_vertex` and `is_constructable_cdag_edge`.
193+
*
194+
* @tparam T The graph type.
195+
*/
124196
template<typename T, typename = void>
125197
struct is_constructable_cdag : std::false_type {};
126198

@@ -131,6 +203,9 @@ struct is_constructable_cdag<T, std::void_t<>>
131203
template<typename T>
132204
inline constexpr bool is_constructable_cdag_v = is_constructable_cdag<T>::value;
133205

206+
/**
207+
* @brief Helper trait to check if a graph can be directly constructed from a vertex count and a set of edges.
208+
*/
134209
template<typename T>
135210
inline constexpr bool is_direct_constructable_cdag_v = std::is_constructible<T, vertex_idx_t<T>, std::set<std::pair<vertex_idx_t<T>, vertex_idx_t<T>>>>::value;
136211

0 commit comments

Comments
 (0)