Skip to content
Snippets Groups Projects
Commit 3b2eb1db authored by Timothy's avatar Timothy
Browse files

final commit

parent 578374c7
No related merge requests found
compile:
gcc -g -Wall -o src/djikstra_serial src/djikstra_serial.c -fopenmp
gcc -g -Wall -o src/djikstra_paralel src/djikstra_paralel.c -fopenmp
No preview for this file type
No preview for this file type
make: djikstra_serial.c
gcc djikstra_serial.c -o djikstra_serial
\ No newline at end of file
#include <limits.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <math.h>
#include <mpi.h>
#include <assert.h>
int main(int argc, char** argv) {
int rank;
int buf;
const int root=0;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == root) {
buf = 777;
}
printf("[%d]: Before Bcast, buf is %d\n", rank, buf);
/* everyone calls bcast, data is taken from root and ends up in everyone's buf */
MPI_Bcast(&buf, 1, MPI_INT, root, MPI_COMM_WORLD);
printf("[%d]: After Bcast, buf is %d\n", rank, buf);
MPI_Finalize();
return 0;
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment