Commit 26284f2f authored by David Goz's avatar David Goz 😴
Browse files

mpi overlapping computation and communication added

parent 997e7058
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
# put here the files which are not going to be committed
*.txt
*~
*.bin
 No newline at end of file
+57 −0
Original line number Diff line number Diff line
#######################################################################
# Author: David Goz (david.goz@inaf.it)                               #
# June  2024                                                          #
#######################################################################
#
# To see all the compilation options
# $ make info
#######################################################################

# make.def defines how the application is compiled
include make.def
include make_mpi_path
#######################################################################

.PHONY: info mpi valgrind_memcheck valgrind_callgrind valgrind_cachegrind clean

info:
	@echo ' '
	@echo '-----------------------------------------------------------------------------------------'
	@echo '$$ make                     ---> compile the mpi application                             '
	@echo '$$ make valgrind_memcheck   ---> run the mpi application using Valgrind under Memcheck   '
	@echo '$$ make valgrind_callgrind  ---> run the mpi application using Valgrind under Callgrind  '
	@echo '$$ make valgrind_cachegrind ---> run the mpi application using Valgrind under Cachegrind '
	@echo '$$ make clean               ---> clean up all                                            '
	@echo '$$ make info                ---> get make info                                           '
	@echo '-----------------------------------------------------------------------------------------'
	@echo ' '

mpi: $(PROG)

valgrind_memcheck: $(PROG_MEMCHECK)
	@echo 'oooOOO... valgrind_memcheck ...OOOooo'
	mpirun -n 4 valgrind --tool=memcheck -s --default-suppressions=yes --log-file=valgrind_memcheck_log_%p.txt ./$< 9 2
	@echo 'oooOOO... valgrind_memcheck ...OOOooo'

valgrind_callgrind: $(PROG_CALLGRIND)
	@echo 'oooOOO... valgrind_callgrind ...OOOooo'
	mpirun -n 4 valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes --log-file=valgrind_callgrind_log_.%p.txt ./$< 9 2
	@echo ' '
	@echo 'To generate a function-by-function summary from the profile data file:'
	@echo '$$ callgrind_annotate --auto=yes callgrind.out.<pid> | less'
	@echo '(kcachegrind is required in order to visualize the output using the GUI)'

valgrind_cachegrind: $(PROG_CACHEGRIND)
	@echo 'oooOOO... valgrind_cachegrind ...OOOooo'
	mpirun -n 4 valgrind --tool=cachegrind --log-file=valgrind_cachegrind_log_.%p.txt ./$< 9 2
	@echo '$$ cg_annotate --auto=yes cachegrind.out.<pid> | less'
	@echo '(kcachegrind is required in order to visualize the output using the GUI)'
	@echo 'oooOOO... valgrind_cachegrind ...OOOooo'

clean:
	rm -f *~ .*~ ./src/*~ ./src/*# ./include/*~ ./include/*# *~
	rm -f $(PROG) $(PROG_DEBUG) $(PROG_MEMCHECK) $(PROG_CALLGRIND) $(PROG_CACHEGRIND)
	rm -f valgrind_*.txt
	rm -f cachegrind.out.*
	rm -f callgrind.*
	rm -f *bin
+20 −0
Original line number Diff line number Diff line
#pragma once

#define NGHOST   1
#define NDIM     2 /* 2D */
#define X        0
#define Y        1
#define TOL      1.e-5

#include <mpi.h>

#define MASTER 0

#if defined(SINGLE_PRECISION)
typedef float MyData;
#define MPI_MyDatatype MPI_FLOAT_PRECISION
#else
/* double precision is assumed by default */
typedef double MyData;
#define MPI_MyDatatype MPI_DOUBLE_PRECISION
#endif /* SINGLE_PRECISION */
+18 −0
Original line number Diff line number Diff line
#pragma once

#include "allvars.h"
#include <assert.h>
#include <sys/time.h>
#include <time.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>

/* function prototypes */
MyData **Allocate_2DdblArray(const int nx, const int ny);
void Show_2DdblArray(const MyData **const A,
                     const int            nx,
                     const int            ny,
                     const char *const    string);

double seconds(void);
+45 −0
Original line number Diff line number Diff line
CC     ?= gcc
CFLAGS ?= -Wall -Wextra -march=native
LIBS   ?= -lm -lmpi

SYSTYPE = $(strip $(shell uname -n))

PROG           ?= jacobi_mpi_comp_comm_$(SYSTYPE)
PROG_DEBUG      = $(PROG)_DEBUG
PROG_MEMCHECK   = $(PROG)_MEMCHECK
PROG_CALLGRIND  = $(PROG)_CALLGRIND
PROG_CACHEGRIND = $(PROG)_CACHEGRIND

HEADERS       = $(wildcard ./include/*.h)
SOURCES       = $(wildcard ./src/*.c)
DEPENDENCIES  = $(SOURCES) $(HEADERS) Makefile

$(PROG): $(DEPENDENCIES)
	$(CC) $(CFLAGS) -O3 -I./include -I$(MPI_INC) $(SOURCES) -o $@ -L$(MPI_LIB) $(LIBS)
	@echo ' '
	@echo 'Program' $(PROG) 'compiled for' $(SYSTYPE) 'machine'
	@echo ' '

$(PROG_DEBUG): $(DEPENDENCIES)
	$(CC) $(CFLAGS) -Og -ggdb3 -fno-omit-frame-pointer -I./include I$(MPI_INC) $(SOURCES) -o $@ -L$(MPI_LIB) $(LIBS)
	@echo ' '
	@echo 'Program' $(PROG_DEBUG) 'compiled for' $(SYSTYPE) 'machine'
	@echo ' '

$(PROG_MEMCHECK): $(DEPENDENCIES)
	$(CC) $(CFLAGS) -Og -I./include -I$(MPI_INC) $(SOURCES) -o $@ -L$(MPI_LIB) $(LIBS)
	@echo ' '
	@echo 'Program' $(PROG_MEMCHECK) 'compiled for' $(SYSTYPE) 'machine'
	@echo ' '

$(PROG_CALLGRIND): $(DEPENDENCIES)
	$(CC) $(CFLAGS) -g -O3 -I./include -I$(MPI_INC) $(SOURCES) -o $@ -L$(MPI_LIB) $(LIBS)
	@echo ' '
	@echo 'Program' $(PROG_CALLGRIND) 'compiled for' $(SYSTYPE) 'machine'
	@echo ' '

$(PROG_CACHEGRIND): $(DEPENDENCIES)
	$(CC) $(CFLAGS) -g -O3 -I./include -I$(MPI_INC) $(SOURCES) -o $@ -L$(MPI_LIB) $(LIBS)
	@echo ' '
	@echo 'Program' $(PROG_CACHEGRIND) 'compiled for' $(SYSTYPE) 'machine'
	@echo ' '
Loading