Commit f0c55387cc2c52dea12904c44e23032c992ed8ad

Authored by kmazouzi
1 parent 7be5246f9f
Exists in master

fix mpi makefile

Showing 2 changed files with 3 additions and 3 deletions Inline Diff

lab1/Makefile View file @ f0c5538
GCC = gcc 1 1 GCC = gcc
MPI = mpicc 2 2 MPI = mpicc
CFLAGS = -O3 -fopenmp 3 3 CFLAGS = -O3 -fopenmp
OMP_FLAG = -fopenmp 4 4 OMP_FLAG = -fopenmp
RM = rm -rf 5 5 RM = rm -rf
6 6
7 7
EXE = pi_ser pi_omp pi_task pi_mpi 8 8 EXE = pi_ser pi_omp pi_task pi_mpi
9 9
all : $(EXE) 10 10 all : $(EXE)
11 11
#.PHONY: all clean purge 12 12 #.PHONY: all clean purge
13 13
14 14
pi_ser: pi_ser.o 15 15 pi_ser: pi_ser.o
$(GCC) $(CFLAGS) -o $@ $^ 16 16 $(GCC) $(CFLAGS) -o $@ $^
17 17
pi_task: pi_task.o 18 18 pi_task: pi_task.o
$(GCC) $(CFLAGS) -o $@ $^ 19 19 $(GCC) $(CFLAGS) -o $@ $^
20 20
pi_omp: pi_omp.o 21 21 pi_omp: pi_omp.o
$(GCC) $(CFLAGS) $(OMP_FLAG) -o $@ $^ 22 22 $(GCC) $(CFLAGS) $(OMP_FLAG) -o $@ $^
23 23
pi_mpi: pi_mpi.o 24 24 pi_mpi:
lab1/pi_mpi.c View file @ f0c5538
#include <stdio.h> 1 1 #include <stdio.h>
#include <string.h> 2 2 #include <string.h>
#include "mpi.h" 3 3 #include <mpi.h>
#define N 100000000 4 4 #define N 100000000
5 5
int main (int argc, char** argv) 6 6 int main (int argc, char** argv)
{ 7 7 {
int rank; 8 8 int rank;
int size; 9 9 int size;
long long int n; 10 10 long long int n;
long long int i; 11 11 long long int i;
12 12
double l_sum,total_sum, x, h; 13 13 double l_sum,total_sum, x, h;
14 14
MPI_Init(NULL, NULL); 15 15 MPI_Init(NULL, NULL);
16 16
MPI_Comm_size(MPI_COMM_WORLD, &size); 17 17 MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank); 18 18 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
19 19
n=N; 20 20 n=N;
21 21
if(rank==0) 22 22 if(rank==0)
{ 23 23 {
if(argc==2) 24 24 if(argc==2)
{ 25 25 {
n = atoll(argv[1]); 26 26 n = atoll(argv[1]);
} 27 27 }
28 28
printf("MPI version with process = %d\n", size); 29 29 printf("MPI version with process = %d\n", size);
printf("Number of intervals: %lld\n", n); 30 30 printf("Number of intervals: %lld\n", n);
} 31 31 }
32 32
33 33
MPI_Bcast(&n, 1, MPI_INT, 0, MPI_COMM_WORLD); 34 34 MPI_Bcast(&n, 1, MPI_INT, 0, MPI_COMM_WORLD);
35 35
36 36
h = 1.0/n; 37 37 h = 1.0/n;
38 38
l_sum = 0.0; 39 39 l_sum = 0.0;
40 40
for (i = rank; i < n; i += size) 41 41 for (i = rank; i < n; i += size)
{ 42 42 {