Skip to content

Commit

Permalink
Update: IO Function
Browse files Browse the repository at this point in the history
Update: IO Function and Fixbug: Function DAWN::Matrix::transpose_Weighted
  • Loading branch information
lxrzlyr authored Jun 20, 2024
2 parents 24e7b77 + 144be99 commit e4b5ebf
Show file tree
Hide file tree
Showing 27 changed files with 649 additions and 628 deletions.
29 changes: 6 additions & 23 deletions algorithm/cpu/apsp_cpu/apsp_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,19 @@
#include <dawn/algorithm/cpu/apsp.hxx>

int main(int argc, char* argv[]) {
DAWN::IO::parameters_t params = DAWN::IO::parameters(argc, argv);
DAWN::Graph::Graph_t graph;
std::string input_path = argv[1];
std::string output_path = argv[2];
std::string print = argv[3];
graph.source = atoi(argv[4]);
std::string weighted = argv[5];
graph.source = params.source;
graph.print = params.print;
graph.weighted = params.weighted;

graph.interval = 100;

if (print == "true") {
graph.print = true;
std::cout << "Print source " << graph.source << std::endl;
} else
graph.print = false;

if (weighted == "weighted") {
graph.weighted = true;
} else {
graph.weighted = false;
}

graph.source = atoi(argv[6]);
graph.thread = omp_get_num_threads();
DAWN::Graph::createGraph(input_path, graph);
float elapsed_time = DAWN::APSP_CPU::run(graph, output_path);
DAWN::Graph::createGraph(params.input_path, graph);
float elapsed_time = DAWN::APSP_CPU::run(graph, params.output_path);
printf("%-21s%3.5d\n", "Nodes:", graph.rows);
printf("%-21s%3.5ld\n", "Edges:", graph.nnz);
printf("%-21s%3.5lf\n", "Time:", elapsed_time);

return 0;
}

// ./apsp_cpu $GRAPH_DIR/XX.mtx ../output.txt false 0 unweighted//
10 changes: 4 additions & 6 deletions algorithm/cpu/bc_cpu/bc_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
#include <dawn/algorithm/cpu/bc.hxx>

int main(int argc, char* argv[]) {
DAWN::IO::parameters_t params = DAWN::IO::parameters(argc, argv);
DAWN::Graph::Graph_t graph;
std::string input_path = argv[1];
std::string output_path = argv[2];
// std::string weighted = argv[3];

graph.thread = omp_get_num_threads();
graph.print = true;
Expand All @@ -27,13 +25,13 @@ int main(int argc, char* argv[]) {
// printf("%-21s%3.5lf\n", "Time:", elapsed_time);
// } else {
graph.weighted = false;
DAWN::Graph::createGraph(input_path, graph);
DAWN::Graph::createGraph(params.input_path, graph);
printf("%-21s%3.5d\n", "Nodes:", graph.rows);
printf("%-21s%3.5ld\n", "Edges:", graph.nnz);
float elapsed_time = DAWN::BC_CPU::Betweenness_Centrality(graph, output_path);
float elapsed_time =
DAWN::BC_CPU::Betweenness_Centrality(graph, params.output_path);
printf("%-21s%3.5lf\n", "Time:", elapsed_time);
// }

return 0;
}
// ./bc_cpu $GRAPH_DIR/XX.mtx ./output.txt weighted
22 changes: 6 additions & 16 deletions algorithm/cpu/bfs_cpu/bfs_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,19 @@
#include <dawn/algorithm/cpu/bfs.hxx>

int main(int argc, char* argv[]) {
DAWN::IO::parameters_t params = DAWN::IO::parameters(argc, argv);
DAWN::Graph::Graph_t graph;
std::string input_path = argv[1];
std::string output_path = argv[2];
std::string print = argv[3];
graph.source = atoi(argv[4]);

if (print == "true") {
graph.print = true;
std::cout << "Print source " << graph.source << std::endl;
} else {
graph.print = false;
}
graph.thread = omp_get_num_threads();
graph.source = params.source;
graph.print = params.print;
graph.weighted = false;
graph.thread = omp_get_num_threads();

DAWN::Graph::createGraph(input_path, graph);

float elapsed_time = DAWN::BFS_CPU::run(graph, output_path);
DAWN::Graph::createGraph(params.input_path, graph);
float elapsed_time = DAWN::BFS_CPU::run(graph, params.output_path);

printf("%-21s%3.5d\n", "Nodes:", graph.rows);
printf("%-21s%3.5ld\n", "Edges:", graph.nnz);
printf("%-21s%3.5lf\n", "Time:", elapsed_time);

return 0;
}
// ./bfs_cpu $GRAPH_DIR/XX.mtx ../output.txt false 0
16 changes: 6 additions & 10 deletions algorithm/cpu/cc_cpu/cc_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
#include <dawn/algorithm/cpu/cc.hxx>

int main(int argc, char* argv[]) {
DAWN::IO::parameters_t params = DAWN::IO::parameters(argc, argv);
DAWN::Graph::Graph_t graph;
std::string input_path = argv[1];
graph.source = atoi(argv[2]);
std::string weighted = argv[3];
graph.source = params.source;
graph.print = params.print;
graph.weighted = params.weighted;

graph.thread = omp_get_num_threads();
DAWN::Graph::createGraph(input_path, graph);
DAWN::Graph::createGraph(params.input_path, graph);

float elapsed_time = 0.0f;
if (weighted == "weighted") {
graph.weighted = true;

if (params.weighted) {
float closeness_centrality =
DAWN::CC_CPU::run_Weighted(graph, graph.source, elapsed_time);

Expand All @@ -28,8 +27,6 @@ int main(int argc, char* argv[]) {
printf("%-21s%3.5ld\n", "Edges:", graph.nnz);
printf("%-21s%3.5lf\n", "Time:", elapsed_time);
} else {
graph.weighted = false;

float closeness_centrality =
DAWN::CC_CPU::run(graph, graph.source, elapsed_time);

Expand All @@ -42,4 +39,3 @@ int main(int argc, char* argv[]) {

return 0;
}
// ./cc_cpu $GRAPH_DIR/XX.mtx 0 weighted
35 changes: 12 additions & 23 deletions algorithm/cpu/mssp_cpu/mssp_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,24 @@
#include <dawn/algorithm/cpu/mssp.hxx>

int main(int argc, char* argv[]) {
DAWN::IO::parameters_t params = DAWN::IO::parameters(argc, argv);
DAWN::Graph::Graph_t graph;
std::string input_path = argv[1];
std::string output_path = argv[2];
std::string print = argv[3];
std::string sourceList = argv[4];
std::string weighted = argv[5];
graph.source = params.source;
graph.print = params.print;
graph.weighted = params.weighted;
graph.interval = 100;
if (print == "true") {
graph.print = true;
std::cout << "Print source " << graph.source << std::endl;
} else {
graph.print = false;
}
if (weighted == "weighted") {
graph.weighted = true;
} else {
graph.weighted = false;
}
graph.thread = omp_get_num_threads();
DAWN::Graph::createGraph(input_path, graph);
DAWN::Graph::readList(sourceList, graph);
float elapsed_time = DAWN::MSSP_CPU::run(graph, output_path);
if (params.sourceList_path.empty()) {
std::cerr << "Invalid value for sourceList_path option.\n";
exit(EXIT_FAILURE);
}

DAWN::Graph::createGraph(params.input_path, graph);
DAWN::IO::readList(params.sourceList_path, graph);
float elapsed_time = DAWN::MSSP_CPU::run(graph, params.output_path);
printf("%-21s%3.5d\n", "Nodes:", graph.rows);
printf("%-21s%3.5ld\n", "Edges:", graph.nnz);
printf("%-21s%3.5lf\n", "Time:", elapsed_time);

return 0;
}
// ./mssp_cpu $GRAPH_DIR/XX.mtx ../output.txt false ./sourceList.txt
// unweighted

// ./mssp_cpu $GRAPH_DIR/XX.mtx ../output.txt false ./sourceList.txt weighted
16 changes: 5 additions & 11 deletions algorithm/cpu/sssp_cpu/sssp_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,18 @@
#include <dawn/algorithm/cpu/sssp.hxx>

int main(int argc, char* argv[]) {
DAWN::IO::parameters_t params = DAWN::IO::parameters(argc, argv);
DAWN::Graph::Graph_t graph;
std::string input_path = argv[1];
std::string output_path = argv[2];
std::string print = argv[3];
graph.source = params.source;
graph.print = params.print;
graph.source = atoi(argv[4]);

if (print == "true") {
graph.print = true;
std::cout << "Print source " << graph.source << std::endl;
} else {
graph.print = false;
}
graph.thread = omp_get_num_threads();
graph.weighted = true;

DAWN::Graph::createGraph(input_path, graph);
DAWN::Graph::createGraph(params.input_path, graph);

float elapsed_time = DAWN::SSSP_CPU::run(graph, output_path);
float elapsed_time = DAWN::SSSP_CPU::run(graph, params.output_path);

printf("%-21s%3.5d\n", "Nodes:", graph.rows);
printf("%-21s%3.5ld\n", "Edges:", graph.nnz);
Expand Down
42 changes: 13 additions & 29 deletions algorithm/gpu/apsp_gpu/apsp_gpu.cu
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,30 @@
*/
#include <dawn/algorithm/gpu/apsp.cuh>
int main(int argc, char* argv[]) {
DAWN::IO::parameters_t params = DAWN::IO::parameters(argc, argv);
DAWN::Graph::Graph_t graph;

std::string input_path = argv[1];
std::string output_path = argv[2];
graph.stream = atoi(argv[3]);
graph.block_size = atoi(argv[4]);
std::string print = argv[5];
graph.source = atoi(argv[6]);
std::string weighted = argv[7];

graph.source = params.source;
graph.print = params.print;
graph.weighted = params.weighted;
graph.thread = 1;
graph.stream = 4;
graph.block_size = 1024;
graph.interval = 100;

if (print == "true") {
graph.print = true;
std::cout << "Print source " << graph.source << std::endl;
} else {
graph.print = false;
}

DAWN::Graph::createGraph(input_path, graph);

if (weighted == "weighted") {
graph.weighted = true;

float elapsed_time = DAWN::APSP_GPU::run_Weighted(graph, output_path);
DAWN::Graph::createGraph(params.input_path, graph);

if (graph.weighted) {
float elapsed_time =
DAWN::APSP_GPU::run_Weighted(graph, params.output_path);
printf("%-21s%3.5d\n", "Nodes:", graph.rows);
printf("%-21s%3.5ld\n", "Edges:", graph.nnz);
printf("%-21s%3.5lf\n", "Time:", elapsed_time);
} else {
graph.weighted = false;

float elapsed_time = DAWN::APSP_GPU::run(graph, output_path);

float elapsed_time = DAWN::APSP_GPU::run(graph, params.output_path);
printf("%-21s%3.5d\n", "Nodes:", graph.rows);
printf("%-21s%3.5ld\n", "Edges:", graph.nnz);
printf("%-21s%3.5lf\n", "Time:", elapsed_time);
}

return 0;
}
//./apsp_gpu $GRAPH_DIR/XXX.mtx ../output.txt 8 1024 false 0 unweighted
//./apsp_gpu $GRAPH_DIR/XXX.mtx ../output.txt 8 1024 false 0 weighted
}
22 changes: 6 additions & 16 deletions algorithm/gpu/bfs_gpu/bfs_gpu.cu
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,18 @@
#include <dawn/algorithm/gpu/bfs.cuh>

int main(int argc, char* argv[]) {
DAWN::IO::parameters_t params = DAWN::IO::parameters(argc, argv);
DAWN::Graph::Graph_t graph;

std::string input_path = argv[1];
std::string output_path = argv[2];
graph.block_size = atoi(argv[3]);
std::string print = argv[4];
graph.source = atoi(argv[5]);

graph.source = params.source;
graph.print = params.print;
graph.thread = 1;
graph.stream = 1;
graph.block_size = 1024;
graph.weighted = false;

if (print == "true") {
graph.print = true;
std::cout << "Print source " << graph.source << std::endl;
} else {
graph.print = false;
}

DAWN::Graph::createGraph(input_path, graph);
DAWN::Graph::createGraph(params.input_path, graph);

float elapsed_time = DAWN::BFS_GPU::run(graph, output_path);
float elapsed_time = DAWN::BFS_GPU::run(graph, params.output_path);

printf("%-21s%3.5d\n", "Nodes:", graph.rows);
printf("%-21s%3.5ld\n", "Edges:", graph.nnz);
Expand Down
21 changes: 7 additions & 14 deletions algorithm/gpu/cc_gpu/cc_gpu.cu
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,24 @@
#include <dawn/algorithm/gpu/cc.cuh>

int main(int argc, char* argv[]) {
DAWN::IO::parameters_t params = DAWN::IO::parameters(argc, argv);
DAWN::Graph::Graph_t graph;

std::string input_path = argv[1];
graph.block_size = atoi(argv[2]);
graph.source = atoi(argv[3]);
std::string weighted = argv[4];

graph.source = params.source;
graph.print = params.print;
graph.weighted = params.weighted;
graph.thread = 1;
graph.stream = 1;
graph.block_size = 1024;

DAWN::Graph::createGraph(input_path, graph);

if (weighted == "true") {
graph.weighted = true;
DAWN::Graph::createGraph(params.input_path, graph);

if (graph.weighted) {
float closeness_centrality =
DAWN::CC_GPU::run_Weighted(graph, graph.source);

printf("%-21s%3.5d\n", "Source:", graph.source);
printf("%-21s%3.5lf\n", "Closeness Centrality:", closeness_centrality);
} else {
graph.weighted = false;

float closeness_centrality = DAWN::CC_GPU::run(graph, graph.source);

printf("%-21s%3.5d\n", "Source:", graph.source);
printf("%-21s%3.5lf\n", "Closeness Centrality:", closeness_centrality);
}
Expand Down
Loading

0 comments on commit e4b5ebf

Please sign in to comment.