Skip to content

Commit

Permalink
spization updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Pietro Max Marsella committed Dec 19, 2024
1 parent f4b54ce commit 16131bd
Show file tree
Hide file tree
Showing 48 changed files with 1,209 additions and 1,112 deletions.
4 changes: 2 additions & 2 deletions bin/sp_ization_benchmarking/nasnet_bench_graph_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "utils/graph/digraph/algorithms/transitive_reduction.h"
#include "utils/graph/instances/adjacency_digraph.h"
#include "utils/graph/node/algorithms.h"
#include "utils/graph/serial_parallel/digraph_generation.h"
#include "utils/graph/series_parallel/digraph_generation.h"
#include <optional>
#include <vector>

Expand Down Expand Up @@ -118,7 +118,7 @@ DiGraph generate_nasnet_bench_cell() {
}

DiGraph generate_nasnet_bench_network() {
DiGraph g = serial_composition(
DiGraph g = series_composition(
transform(repeat(NUM_CELLS, generate_nasnet_bench_cell),
[](auto const cell) -> DiGraphView { return cell; }));
return g;
Expand Down
2 changes: 1 addition & 1 deletion bin/sp_ization_benchmarking/sample_graphs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "utils/graph/digraph/algorithms/is_acyclic.h"
#include "utils/graph/digraph/digraph.h"
#include "utils/graph/instances/adjacency_digraph.h"
#include "utils/graph/serial_parallel/digraph_generation.h"
#include "utils/graph/series_parallel/digraph_generation.h"
#include <tuple>

namespace FlexFlow {
Expand Down
20 changes: 10 additions & 10 deletions bin/sp_ization_benchmarking/sp_ization_benchmarking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
#include "utils/graph/digraph/algorithms/transitive_reduction.h"
#include "utils/graph/digraph/digraph_view.h"
#include "utils/graph/node/algorithms.h"
#include "utils/graph/serial_parallel/serial_parallel_decomposition.dtg.h"
#include "utils/graph/serial_parallel/serial_parallel_metrics.h"
#include "utils/graph/serial_parallel/sp_ization/critical_path_preserving_sp_ization.h"
#include "utils/graph/serial_parallel/sp_ization/work_preserving_sp_ization.h"
#include "utils/graph/series_parallel/series_parallel_decomposition.dtg.h"
#include "utils/graph/series_parallel/series_parallel_metrics.h"
#include "utils/graph/series_parallel/sp_ization/critical_path_preserving_sp_ization.h"
#include "utils/graph/series_parallel/sp_ization/work_preserving_sp_ization.h"
#include <iomanip>
#include <iostream>
#include <string>
Expand All @@ -56,10 +56,10 @@ CombinedResult perform_benchmark_given_graph(DiGraphView const &g,
for (int i = 0; i < repeat; i++) {
auto cost_map = make_cost_map(get_nodes(g), Dist);

SerialParallelDecomposition sp1 =
SeriesParallelDecomposition sp1 =
critical_path_preserving_sp_ization_with_coalescing(g);
SerialParallelDecomposition sp2 = stratum_sync_sp_ization(g);
SerialParallelDecomposition sp3 =
SeriesParallelDecomposition sp2 = stratum_sync_sp_ization(g);
SeriesParallelDecomposition sp3 =
cost_aware_stratum_sync_sp_ization(g, cost_map);

auto noisy_cost_map = add_noise_to_cost_map(cost_map, Noise);
Expand Down Expand Up @@ -108,10 +108,10 @@ CombinedResult
DiGraphView g = graph_generator();
auto cost_map = make_cost_map(get_nodes(g), Dist);

SerialParallelDecomposition sp1 =
SeriesParallelDecomposition sp1 =
critical_path_preserving_sp_ization_with_coalescing(g);
SerialParallelDecomposition sp2 = stratum_sync_sp_ization(g);
SerialParallelDecomposition sp3 =
SeriesParallelDecomposition sp2 = stratum_sync_sp_ization(g);
SeriesParallelDecomposition sp3 =
cost_aware_stratum_sync_sp_ization(g, cost_map);

auto noisy_cost_map = add_noise_to_cost_map(cost_map, Noise);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _FLEXFLOW_LIB_UTILS_INCLUDE_UTILS_GRAPH_DIGRAPH_ALGORITHMS_TRANSITIVE_REDUCTION_H
#define _FLEXFLOW_LIB_UTILS_INCLUDE_UTILS_GRAPH_DIGRAPH_ALGORITHMS_TRANSITIVE_REDUCTION_H

#include "utils/graph/digraph/digraph.h"
#include "utils/graph/digraph/digraph_view.h"

namespace FlexFlow {
Expand All @@ -21,7 +22,7 @@ struct DirectedEdgeMaskView final : public IDiGraphView {
std::unordered_set<DirectedEdge> edge_mask;
};

DiGraphView transitive_reduction(DiGraphView const &);
DiGraph transitive_reduction(DiGraphView const &);

} // namespace FlexFlow

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
#define _FLEXFLOW_LIB_UTILS_INCLUDE_UTILS_GRAPH_SERIAL_PARALLEL_DIGRAPH_GENERATION_H

#include "utils/graph/digraph/digraph.h"
#include "utils/graph/serial_parallel/serial_parallel_decomposition.dtg.h"
#include "utils/graph/series_parallel/series_parallel_decomposition.dtg.h"

namespace FlexFlow {

std::unordered_map<Node, Node> parallel_extend(DiGraph &g,
DiGraphView const &ext);
std::unordered_map<Node, Node> serial_extend(DiGraph &g,
DiGraphView const &ext);
DiGraph serial_composition(DiGraphView const &g1, DiGraphView const &g2);
DiGraph series_composition(DiGraphView const &g1, DiGraphView const &g2);
DiGraph parallel_composition(DiGraphView const &g1, DiGraphView const &g2);
DiGraph serial_composition(std::vector<DiGraphView> const &graphs);
DiGraph series_composition(std::vector<DiGraphView> const &graphs);
DiGraph parallel_composition(std::vector<DiGraphView> const &graphs);

DiGraph digraph_from_sp_decomposition(SerialParallelDecomposition const &sp);
DiGraph digraph_from_sp_decomposition(SeriesParallelDecomposition const &sp);

} // namespace FlexFlow

Expand Down
4 changes: 2 additions & 2 deletions lib/utils/include/utils/graph/series_parallel/get_ancestors.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef _FLEXFLOW_LIB_UTILS_INCLUDE_UTILS_GRAPH_SERIAL_PARALLLEL_GET_ANCESTORS_H
#define _FLEXFLOW_LIB_UTILS_INCLUDE_UTILS_GRAPH_SERIAL_PARALLLEL_GET_ANCESTORS_H

#include "utils/graph/serial_parallel/serial_parallel_decomposition.h"
#include "utils/graph/series_parallel/series_parallel_decomposition.dtg.h"

namespace FlexFlow {

std::unordered_set<Node> get_ancestors(SerialParallelDecomposition const &sp,
std::unordered_set<Node> get_ancestors(SeriesParallelDecomposition const &sp,
Node const &starting_node);

} // namespace FlexFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ namespace FlexFlow {
std::optional<SeriesParallelDecomposition>
get_series_parallel_decomposition(DiGraphView const &);

std::optional<SeriesParallelDecomposition>
get_series_parallel_decomposition_with_sync_nodes(
DiGraphView const &, std::unordered_set<Node> const &);

} // namespace FlexFlow

#endif
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#ifndef _FLEXFLOW_LIB_UTILS_INCLUDE_UTILS_GRAPH_normalize_sp_decomposition_H
#define _FLEXFLOW_LIB_UTILS_INCLUDE_UTILS_GRAPH_normalize_sp_decomposition_H

#include "utils/graph/serial_parallel/serial_parallel_decomposition.dtg.h"
#include "utils/graph/series_parallel/series_parallel_decomposition.dtg.h"

namespace FlexFlow {

/**
* @brief Recursively normalizes a SerialParallelDecomposition.
* @brief Recursively normalizes a SeriesParallelDecomposition.
*
* @details This function performs the following semantic substitutions:
* - Deletes every empty SerialSplit and ParallelSplit item, e.g.,
* - Deletes every empty SeriesSplit and ParallelSplit item, e.g.,
* <tt>S(P(S()), Node(1), Node(2)) -> S(Node(1), Node(2))</tt>
*
* - Replaces SerialSplit and ParallelSplit of size 1 with their content, e.g.,
* - Replaces SeriesSplit and ParallelSplit of size 1 with their content, e.g.,
* <tt>S(S(Node(1)), P(Node(2))) -> S(Node(1), Node(2))</tt>)
*
*/
SerialParallelDecomposition
normalize_sp_decomposition(SerialParallelDecomposition const &sp);
SeriesParallelDecomposition
normalize_sp_decomposition(SeriesParallelDecomposition const &sp);

} // namespace FlexFlow

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@ std::unordered_multiset<Node> get_nodes(SeriesSplit const &);
std::unordered_multiset<Node> get_nodes(ParallelSplit const &);
std::unordered_multiset<Node> get_nodes(Node const &);

bool is_empty(Node const &node);
bool is_empty(SeriesSplit const &serial);
bool is_empty(ParallelSplit const &parallel);
bool is_empty(SeriesParallelDecomposition const &sp);

bool has_no_duplicate_nodes(SeriesParallelDecomposition const &sp);

SeriesParallelDecomposition delete_node(SeriesParallelDecomposition sp,
Node const &node);

// duplicate nodes within `sp` are counted multiple times
size_t num_nodes(SeriesParallelDecomposition const &sp);

SeriesParallelDecomposition series_composition(
std::vector<SeriesParallelDecomposition> const &sp_compositions);
SeriesParallelDecomposition parallel_composition(
std::unordered_multiset<SeriesParallelDecomposition> const
&sp_compositions);

} // namespace FlexFlow

#endif
Loading

0 comments on commit 16131bd

Please sign in to comment.