Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
328 changes: 264 additions & 64 deletions .clang-format

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Checks: '-*,readability-identifier-naming'

CheckOptions:
# 1. Member Variables: camelBack with a trailing underscore (e.g., memberVariableTest_)
- key: readability-identifier-naming.MemberCase
value: camelBack
- key: readability-identifier-naming.MemberSuffix
value: _

# 2. Functions: CamelCase (e.g., CalculateTotal)
- key: readability-identifier-naming.FunctionCase
value: CamelCase

# 3. Local Variables/Parameters: camelBack (e.g., totalValue)
- key: readability-identifier-naming.VariableCase
value: camelBack
- key: readability-identifier-naming.ParameterCase
value: camelBack

# 4. Classes/Structs: CamelCase (e.g., MyClass)
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.StructCase
value: CamelCase
1 change: 0 additions & 1 deletion apps/bsp_test_suite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ limitations under the License.
using graph_t = osp::computational_dag_edge_idx_vector_impl_def_int_t;

int main(int argc, char *argv[]) {

osp::BspScheduleRecompTestSuiteRunner<graph_t> runner;
return runner.run(argc, argv);

Expand Down
15 changes: 6 additions & 9 deletions apps/coarser_plotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ int main(int argc, char *argv[]) {
}

std::string graph_file = argv[1];
std::string graph_name = graph_file.substr(graph_file.rfind("/") + 1,
graph_file.rfind(".") - graph_file.rfind("/") - 1);

std::string graph_name = graph_file.substr(graph_file.rfind("/") + 1, graph_file.rfind(".") - graph_file.rfind("/") - 1);

Graph_t graph;
bool status = file_reader::readGraph(graph_file, graph);
Expand All @@ -46,8 +44,7 @@ int main(int argc, char *argv[]) {
return 1;
}


SarkarParams::MulParameters< v_workw_t<Graph_t> > params;
SarkarParams::MulParameters<v_workw_t<Graph_t>> params;
params.commCostVec = std::vector<v_workw_t<Graph_t>>({1, 2, 5, 10, 20, 50, 100, 200, 500, 1000});
params.max_num_iteration_without_changes = 3;
params.leniency = 0.005;
Expand All @@ -63,7 +60,7 @@ int main(int argc, char *argv[]) {

Graph_t graph_copy = graph;
bool ignore_vertex_types = false;

if (ignore_vertex_types) {
for (const auto &vert : graph_copy.vertices()) {
graph_copy.set_vertex_type(vert, 0);
Expand All @@ -74,7 +71,7 @@ int main(int argc, char *argv[]) {

std::vector<unsigned> colours(contraction_map.size());
for (std::size_t i = 0; i < contraction_map.size(); ++i) {
colours[i] = static_cast<unsigned>( contraction_map[i] );
colours[i] = static_cast<unsigned>(contraction_map[i]);
}

std::ofstream out_dot(argv[2]);
Expand All @@ -86,7 +83,7 @@ int main(int argc, char *argv[]) {
DotFileWriter writer;
writer.write_colored_graph(out_dot, graph, colours);

if (argc >=4 ) {
if (argc >= 4) {
std::ofstream coarse_out_dot(argv[3]);
if (!coarse_out_dot.is_open()) {
std::cout << "Unable to write/open output file.\n";
Expand All @@ -100,4 +97,4 @@ int main(int argc, char *argv[]) {
}

return 0;
}
}
16 changes: 9 additions & 7 deletions apps/graph_analyser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ limitations under the License.
#include <string>
#include <vector>

#include "osp/auxiliary/io/bsp_schedule_file_writer.hpp"
#include "osp/auxiliary/io/general_file_reader.hpp"
#include "osp/auxiliary/misc.hpp"
#include "osp/graph_algorithms/directed_graph_path_util.hpp"
#include "osp/graph_implementations/adj_list_impl/computational_dag_edge_idx_vector_impl.hpp"
#include "osp/auxiliary/io/bsp_schedule_file_writer.hpp"
#include "osp/auxiliary/io/general_file_reader.hpp"

using namespace osp;

Expand Down Expand Up @@ -151,22 +151,24 @@ int main(int argc, char *argv[]) {
<< std::endl;

for (const auto &dirEntry : std::filesystem::recursive_directory_iterator(graph_dir)) {
if (std::filesystem::is_directory(dirEntry))
if (std::filesystem::is_directory(dirEntry)) {
continue;
}

std::cout << "Processing: " << dirEntry << std::endl;

std::string path_str = dirEntry.path();

ComputationalDag graph;
bool status = file_reader::readGraph(dirEntry.path(), graph);
if (!status) {
std::cout << "Failed to read graph\n";
return 1;
}
}

if (!status)
if (!status) {
continue;
}

std::string graph_name = path_str.substr(path_str.rfind("/") + 1);
graph_name = graph_name.substr(0, graph_name.rfind("."));
Expand All @@ -177,4 +179,4 @@ int main(int argc, char *argv[]) {
}

return 0;
}
}
18 changes: 7 additions & 11 deletions apps/graph_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,19 @@ void print_usage(const char *prog_name) {
std::cerr << "Graph Format Converter" << std::endl;
std::cerr << "----------------------" << std::endl;
std::cerr << "This tool converts a directed graph from one file format to another. The desired output" << std::endl;
std::cerr << "format is determined by the file extension of the output file." << std::endl
<< std::endl;
std::cerr << "format is determined by the file extension of the output file." << std::endl << std::endl;
std::cerr << "Usage: " << prog_name << " <input_file> <output_file>" << std::endl << std::endl;
std::cerr << "Arguments:" << std::endl;
std::cerr << " <input_file> Path to the input graph file." << std::endl
<< std::endl;
std::cerr << " <input_file> Path to the input graph file." << std::endl << std::endl;
std::cerr << " <output_file> Path for the output graph file. Special values of '.dot' or '.hdag' can be" << std::endl;
std::cerr << " used to automatically generate the output filename by replacing the input" << std::endl;
std::cerr << " file's extension with the specified one." << std::endl;
std::cerr << std::endl;
std::cerr << "Supported Formats:" << std::endl;
std::cerr << " Input (by extension): .hdag, .mtx, .dot" << std::endl;
std::cerr << " Output (by extension): .hdag, .dot" << std::endl
<< std::endl;
std::cerr << " Output (by extension): .hdag, .dot" << std::endl << std::endl;
std::cerr << "The .hdag format is the HyperdagDB format. A detailed description can be found at:" << std::endl;
std::cerr << "https://github.com/Algebraic-Programming/HyperDAG_DB" << std::endl
<< std::endl;
std::cerr << "https://github.com/Algebraic-Programming/HyperDAG_DB" << std::endl << std::endl;
std::cerr << "Examples:" << std::endl;
std::cerr << " " << prog_name << " my_graph.mtx my_graph.hdag" << std::endl;
std::cerr << " " << prog_name << " my_graph.hdag my_graph.dot" << std::endl;
Expand Down Expand Up @@ -98,8 +94,8 @@ int main(int argc, char *argv[]) {
return 1;
}

std::cout << "Successfully read graph with " << graph.num_vertices() << " vertices and " << graph.num_edges()
<< " edges." << std::endl;
std::cout << "Successfully read graph with " << graph.num_vertices() << " vertices and " << graph.num_edges() << " edges."
<< std::endl;

std::filesystem::path output_path(output_filename);
std::string output_ext = output_path.extension().string();
Expand All @@ -118,4 +114,4 @@ int main(int argc, char *argv[]) {
std::cout << "Successfully wrote graph to " << output_filename << std::endl;

return 0;
}
}
20 changes: 9 additions & 11 deletions apps/graph_generator/gen_Erdos-Renyi_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,23 @@ limitations under the License.
@author Toni Boehnlein, Benjamin Lozes, Pal Andras Papp, Raphael S. Steiner
*/

#include "osp/auxiliary/misc.hpp"
#include "osp/auxiliary/random_graph_generator/Erdos_Renyi_graph.hpp"
#include "osp/graph_implementations/adj_list_impl/computational_dag_vector_impl.hpp"

#include <fstream>
#include <iostream>
#include <random>
#include <string>

#include "osp/auxiliary/misc.hpp"
#include "osp/auxiliary/random_graph_generator/Erdos_Renyi_graph.hpp"
#include "osp/graph_implementations/adj_list_impl/computational_dag_vector_impl.hpp"

using namespace osp;

using ComputationalDag = computational_dag_vector_impl_def_int_t;
using VertexType = vertex_idx_t<ComputationalDag>;

int main(int argc, char *argv[]) {
if (argc < 3) {
std::cerr << "Usage: " << argv[0]
<< " <number of vertices> <expected outdegree> (optional:) <number of graphs>\n"
std::cerr << "Usage: " << argv[0] << " <number of vertices> <expected outdegree> (optional:) <number of graphs>\n"
<< std::endl;
return 1;
}
Expand Down Expand Up @@ -97,19 +96,18 @@ int main(int argc, char *argv[]) {
std::ofstream graph_write;
graph_write.open(graph_name);
graph_write << header;
graph_write << std::to_string(graph.num_vertices()) + " " + std::to_string(graph.num_vertices()) + " " +
std::to_string(graph.num_edges() + graph.num_vertices()) + "\n";
graph_write << std::to_string(graph.num_vertices()) + " " + std::to_string(graph.num_vertices()) + " "
+ std::to_string(graph.num_edges() + graph.num_vertices()) + "\n";
for (VertexType i = 0; i < num_vert; i++) {
double val = (1 - 2 * randInt(2)) * std::exp(unif_log(re));
graph_write << std::to_string(i + 1) + " " + std::to_string(i + 1) + " " + std::to_string(val) + "\n";
for (const auto &chld : graph.children(i)) {
val = unif(re);
graph_write << std::to_string(chld + 1) + " " + std::to_string(i + 1) + " " + std::to_string(val) +
"\n";
graph_write << std::to_string(chld + 1) + " " + std::to_string(i + 1) + " " + std::to_string(val) + "\n";
}
}
graph_write.close();
}

return 0;
}
}
20 changes: 9 additions & 11 deletions apps/graph_generator/gen_near_diag_random_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,23 @@ limitations under the License.
@author Toni Boehnlein, Benjamin Lozes, Pal Andras Papp, Raphael S. Steiner
*/

#include "osp/auxiliary/misc.hpp"
#include "osp/auxiliary/random_graph_generator/near_diagonal_random_graph.hpp"
#include "osp/graph_implementations/adj_list_impl/computational_dag_vector_impl.hpp"

#include <fstream>
#include <iostream>
#include <random>
#include <string>

#include "osp/auxiliary/misc.hpp"
#include "osp/auxiliary/random_graph_generator/near_diagonal_random_graph.hpp"
#include "osp/graph_implementations/adj_list_impl/computational_dag_vector_impl.hpp"

using namespace osp;

using ComputationalDag = computational_dag_vector_impl_def_int_t;
using VertexType = vertex_idx_t<ComputationalDag>;

int main(int argc, char *argv[]) {
if (argc < 4) {
std::cerr << "Usage: " << argv[0]
<< " <number of vertices> <probability> <bandwidth> (optional:) <number of graphs>\n"
std::cerr << "Usage: " << argv[0] << " <number of vertices> <probability> <bandwidth> (optional:) <number of graphs>\n"
<< std::endl;
return 1;
}
Expand Down Expand Up @@ -103,19 +102,18 @@ int main(int argc, char *argv[]) {
std::ofstream graph_write;
graph_write.open(graph_name);
graph_write << header;
graph_write << std::to_string(graph.num_vertices()) + " " + std::to_string(graph.num_vertices()) + " " +
std::to_string(graph.num_edges() + graph.num_vertices()) + "\n";
graph_write << std::to_string(graph.num_vertices()) + " " + std::to_string(graph.num_vertices()) + " "
+ std::to_string(graph.num_edges() + graph.num_vertices()) + "\n";
for (VertexType j = 0; j < num_vert; j++) {
double val = (1 - 2 * randInt(2)) * std::exp(unif_log(re));
graph_write << std::to_string(j + 1) + " " + std::to_string(j + 1) + " " + std::to_string(val) + "\n";
for (const auto &chld : graph.children(j)) {
val = unif(re);
graph_write << std::to_string(chld + 1) + " " + std::to_string(j + 1) + " " + std::to_string(val) +
"\n";
graph_write << std::to_string(chld + 1) + " " + std::to_string(j + 1) + " " + std::to_string(val) + "\n";
}
}
graph_write.close();
}

return 0;
}
}
28 changes: 14 additions & 14 deletions apps/graph_generator/post_incomplete_cholesky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ limitations under the License.

@author Christos Matzoros, Toni Boehnlein, Pal Andras Papp, Raphael S. Steiner
*/
#include <Eigen/Core>
#include <Eigen/Dense>
#include <Eigen/IterativeLinearSolvers>
#include <Eigen/OrderingMethods>
#include <Eigen/SparseCore>
#include <filesystem>
#include <string>
#include <vector>

#include <Eigen/SparseCore>
#include <Eigen/IterativeLinearSolvers>
#include <unsupported/Eigen/SparseExtra>
#include <Eigen/Dense>
#include <Eigen/Core>
#include <Eigen/OrderingMethods>
#include <vector>

int main(int argc, char *argv[]) {
if (argc < 2) {
Expand All @@ -38,21 +37,22 @@ int main(int argc, char *argv[]) {
name_graph = name_graph.substr(0, name_graph.find_last_of("."));

std::cout << "Graph: " << name_graph << std::endl;

using SM_csc = Eigen::SparseMatrix<double, Eigen::ColMajor, int32_t>; // Compressed Sparse Column format
using SM_csr = Eigen::SparseMatrix<double, Eigen::RowMajor, int32_t>; // Compressed Sparse Row format

SM_csc L_csc; // Initialize a sparse matrix in CSC format
using SM_csc = Eigen::SparseMatrix<double, Eigen::ColMajor, int32_t>; // Compressed Sparse Column format
using SM_csr = Eigen::SparseMatrix<double, Eigen::RowMajor, int32_t>; // Compressed Sparse Row format

SM_csc L_csc; // Initialize a sparse matrix in CSC format

Eigen::loadMarket(L_csc, filename_graph);

SM_csr L_csr = L_csc; // Reformat the sparse matrix from CSC to CSR format
SM_csr L_csr = L_csc; // Reformat the sparse matrix from CSC to CSR format

Eigen::IncompleteCholesky<double, Eigen::Lower, Eigen::AMDOrdering<int>> ichol(L_csc);

SM_csc LChol_csc = ichol.matrixL();

Eigen::saveMarket(LChol_csc, filename_graph.substr(0, filename_graph.find_last_of(".")) + "_postChol.mtx", Eigen::UpLoType::Symmetric);
Eigen::saveMarket(
LChol_csc, filename_graph.substr(0, filename_graph.find_last_of(".")) + "_postChol.mtx", Eigen::UpLoType::Symmetric);

return 0;
}
}
Loading