Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
init MPI
Browse files Browse the repository at this point in the history
  • Loading branch information
ist187691 committed May 5, 2021
1 parent 2e497a2 commit 88364ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.o
ballAlg
ballAlg-omp
ballAlg-mpi
ballQuery
*.zip
*.tree
13 changes: 13 additions & 0 deletions src/ballAlg-mpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <omp.h>
#include <math.h>
#include <string.h>
#include <mpi.h>
#include "gen_points.h"
#include "point_operations.h"
#include "ball_tree.h"
Expand All @@ -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)

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 88364ea

Please sign in to comment.