From 88364ea0ff4cd76d30d9e734be9ca269dd61a40a Mon Sep 17 00:00:00 2001 From: ist187691 Date: Wed, 5 May 2021 20:36:14 +0100 Subject: [PATCH] init MPI --- .gitignore | 1 + src/ballAlg-mpi.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/.gitignore b/.gitignore index fc16d51..fedc144 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.o ballAlg ballAlg-omp +ballAlg-mpi ballQuery *.zip *.tree diff --git a/src/ballAlg-mpi.c b/src/ballAlg-mpi.c index c5bf41a..ce95666 100644 --- a/src/ballAlg-mpi.c +++ b/src/ballAlg-mpi.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "gen_points.h" #include "point_operations.h" #include "ball_tree.h" @@ -26,6 +27,9 @@ long n_nodes; // number of nodes of the ball tree long node_id; // id of the current node of the algorithm long node_counter; // number of nodes generated by the program +int rank; //rank of the current process +int n_procs; //total number of processes + #define LEFT_PARTITION_SIZE(N) ((N) % 2 ? ((N) - 1) / 2 : (N) / 2) #define RIGHT_PARTITION_SIZE(N) ((N) % 2 ? ((N) + 1) / 2 : (N) / 2) @@ -189,9 +193,18 @@ void alloc_memory() { int main(int argc, char** argv) { double exec_time; exec_time = -omp_get_wtime(); + + MPI_Init (&argc, &argv); + + MPI_Comm_rank (MPI_COMM_WORLD, &rank); + MPI_Comm_size (MPI_COMM_WORLD, &n_procs); + + /* pts = get_points(argc, argv, &n_dims, &n_points); alloc_memory(); build_tree(); + */ + exec_time += omp_get_wtime(); fprintf(stderr, "%.1lf\n", exec_time); printf("%d %ld\n", n_dims, n_nodes);