Skip to content
Snippets Groups Projects
Commit 26284f2f authored by David Goz's avatar David Goz :sleeping:
Browse files

mpi overlapping computation and communication added

parent 997e7058
No related branches found
No related tags found
No related merge requests found
# put here the files which are not going to be committed # put here the files which are not going to be committed
*.txt *.txt
*~ *~
*.bin
\ No newline at end of file
#######################################################################
# 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
#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 */
#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);
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 ' '
# set the MPI install path
MPI_INSTALL_PATH = /home/gozzilla/software/openmpi/openmpi-5.0.3
MPI = $(MPI_INSTALL_PATH)
MPI_INC = $(MPI)/include
MPI_LIB = $(MPI)/lib
\ No newline at end of file
This diff is collapsed.
/* ///////////////////////////////////////////////////////////////////// */
/* Authors: A. Mignone (mignone@to.infn.it) */
/* V. Cesare (valentina.cesare@inaf.it) */
/* D. Goz (david.goz@inaf.it) */
/* */
/* Date : June 2024 */
/* */
/* ///////////////////////////////////////////////////////////////////// */
#include "tools.h"
/* ********************************************************************* */
MyData **Allocate_2DdblArray(const int nx, const int ny)
/*
* Allocate memory for a double precision array with
* nx rows and ny columns
*********************************************************************** */
{
MyData **buf = malloc(nx * sizeof(MyData *));
assert(buf != NULL);
buf[0] = (MyData *) malloc(nx * ny * sizeof(MyData));
assert(buf[0] != NULL);
for (int j=1 ; j<nx ; j++)
buf[j] = buf[j-1] + ny;
return buf;
}
/* ********************************************************************* */
void Show_2DdblArray(const MyData **const A,
const int nx,
const int ny,
const char *const string)
/* *********************************************************************** */
{
printf ("%s\n",string);
printf ("------------------------------\n");
for (int i=0 ; i<nx ; i++)
{
for (int j=0 ; j<ny ; j++)
{
printf ("%8.2f ", A[i][j]);
}
printf ("\n");
}
printf ("------------------------------\n");
}
/* ********************************************************************* */
double seconds()
{
struct timeval tmp;
gettimeofday(&tmp, (struct timezone *)0);
double sec = tmp.tv_sec + ((double)tmp.tv_usec)/1000000.0;
return sec;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment