Skip to content
Snippets Groups Projects
Commit fa3c496c authored by Damian Alvarez's avatar Damian Alvarez
Browse files

Sync with upstream and drop the PGO options that are not necessary in

current processors
parent 5dcd46e9
No related branches found
No related tags found
No related merge requests found
......@@ -19,9 +19,16 @@ Overview of the custom EasyBlocks.
## PSMPI
- __*added by*__ d.alvarez
- __*needed because*__ PGO options needed to build in JURECA booster. CUDA support
- __*difference compared to upstream*__ all the supporting code to enable the 2 things mentioned above
- __*can not be removed*__ at least until the PGO options are dropped (when JURECA booster is decomissioned) and the CUDA options are pushed upstream
- __*needed because*__ CUDA support
- __*difference compared to upstream*__ the supporting code to enable CUDA support
- __*can not be removed*__ until the CUDA options are pushed upstream
## OPENMPI
- __*added by*__ d.alvarez
- __*needed because*__ the check for `mpirun` should be optional
- __*difference compared to upstream*__ making that check optional
- __*can not be removed*__ until the check is made optional upstream
## CODE_SATURNE
......
##
# Copyright 2009-2019 Ghent University, Forschungszentrum Juelich
# Copyright 2009-2022 Ghent University, Forschungszentrum Juelich
#
# This file is part of EasyBuild,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
......
##
# Copyright 2016-2018 Ghent University, Forschungszentrum Juelich
# Copyright 2016-2022 Ghent University, Forschungszentrum Juelich
#
# This file is part of EasyBuild,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
......@@ -30,96 +30,12 @@ EasyBuild support for building and installing the ParaStationMPI library, implem
import easybuild.tools.environment as env
import easybuild.tools.toolchain as toolchain
import os
import re
from distutils.version import LooseVersion
from easybuild.easyblocks.mpich import EB_MPICH
from easybuild.framework.easyconfig import CUSTOM
from easybuild.tools.build_log import EasyBuildError, print_msg
from easybuild.tools.filetools import mkdir, remove_dir, write_file
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.modules import get_software_root
from easybuild.tools.run import run_cmd
PINGPONG_PGO_TEST = """
/****************************************
* Potentially buggy, ugly and extremely simple MPI ping pong.
* The goal is to trigger pscom internal routines to generate
* profiles to be used by PGO-enabled compilers.
*
* Nothing more, nothing less.
*
* We try small and large messages to walk the path for eager
* and rendezvous protocols
*
* author: Damian Alvarez (d.alvarez@fz-juelich.de)
****************************************/
#include "mpi.h"
#define MAX_LENGTH 1048576
#define ITERATIONS 1000
int main(int argc, char *argv[]){
int myid, vlength, i, err, eslength;
MPI_Request requests[2];
char error_string[MPI_MAX_ERROR_STRING];
double v0[MAX_LENGTH], v1[MAX_LENGTH];
MPI_Status stat;
MPI_Init(&argc,&argv);
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
// Test blocking point to point
for (vlength=1; vlength<=MAX_LENGTH; vlength*=2){
for (i=0; i<ITERATIONS; i++){
MPI_Barrier(MPI_COMM_WORLD);
// Not really needed, but it might be interesting to PGO this for benchmarking?
MPI_Wtime();
if (myid == 0){
err = MPI_Send(v0, vlength*sizeof(double), MPI_BYTE, 1, 0, MPI_COMM_WORLD);
MPI_Error_string(err, error_string, &eslength);
err = MPI_Recv(v1, vlength*sizeof(double), MPI_BYTE, 1, 0, MPI_COMM_WORLD, &stat);
MPI_Error_string(err, error_string, &eslength);
}
else{
err = MPI_Recv(v1, vlength*sizeof(double), MPI_BYTE, 0, 0, MPI_COMM_WORLD, &stat);
MPI_Error_string(err, error_string, &eslength);
err = MPI_Send(v0, vlength*sizeof(double), MPI_BYTE, 0, 0, MPI_COMM_WORLD);
MPI_Error_string(err, error_string, &eslength);
}
MPI_Wtime();
}
}
// Test non-blocking point to point
for (vlength=1; vlength<=MAX_LENGTH; vlength*=2){
for (i=0; i<ITERATIONS; i++){
if (myid == 0){
err = MPI_Isend(v0, vlength*sizeof(double), MPI_BYTE, 1, 0, MPI_COMM_WORLD, &requests[0]);
MPI_Error_string(err, error_string, &eslength);
err = MPI_Irecv(v1, vlength*sizeof(double), MPI_BYTE, 1, 0, MPI_COMM_WORLD, &requests[1]);
MPI_Error_string(err, error_string, &eslength);
}
else{
err = MPI_Irecv(v1, vlength*sizeof(double), MPI_BYTE, 0, 0, MPI_COMM_WORLD, &requests[1]);
MPI_Error_string(err, error_string, &eslength);
err = MPI_Isend(v0, vlength*sizeof(double), MPI_BYTE, 0, 0, MPI_COMM_WORLD, &requests[0]);
MPI_Error_string(err, error_string, &eslength);
}
MPI_Waitall(2, &requests[0], MPI_STATUSES_IGNORE);
}
}
MPI_Finalize();
}
"""
class EB_psmpi(EB_MPICH):
......@@ -128,13 +44,8 @@ class EB_psmpi(EB_MPICH):
* Determines the compiler to be used based on the toolchain
* Enables threading if required by the easyconfig
* Sets extra MPICH options if required by the easyconfig
* Generates a PGO profile and uses it if required
"""
def __init__(self, *args, **kwargs):
super(EB_psmpi, self).__init__(*args, **kwargs)
self.profdir = os.path.join(self.builddir, 'profile')
@staticmethod
def extra_options(extra_vars=None):
"""Define custom easyconfig parameters specific to ParaStationMPI."""
......@@ -148,60 +59,10 @@ class EB_psmpi(EB_MPICH):
'mpich_opts': [None, "Optional options to configure MPICH", CUSTOM],
'threaded': [False, "Enable multithreaded build (which is slower)", CUSTOM],
'pscom_allin_path': [None, "Enable pscom integration by giving its source path", CUSTOM],
'pgo': [False, "Enable profiling guided optimizations", CUSTOM],
'mpiexec_cmd': ['srun -n ', "Command to run benchmarks to generate PGO profile. With -n switch", CUSTOM],
'cuda': [False, "Enable CUDA awareness", CUSTOM],
})
return extra_vars
def pgo_steps(self):
"""
Set of steps to be performed after the initial installation, if PGO were enabled
"""
self.log.info("Running PGO steps...")
# Remove old profiles
remove_dir(self.profdir)
mkdir(self.profdir)
# Clean the old build
run_cmd('make distclean')
# Compile and run example to generate profile
print_msg("generating PGO profile...")
(out, _) = run_cmd('%s 2 hostname' % self.cfg['mpiexec_cmd'])
nodes = out.split()
if nodes[0] == nodes[1]:
raise EasyBuildError("The profile is generated with 1 node! Use 2 nodes to generate a proper profile!")
write_file('pingpong.c', PINGPONG_PGO_TEST)
run_cmd('%s/bin/mpicc pingpong.c -o pingpong' % self.installdir)
run_cmd('PSP_SHM=0 %s 2 pingpong' % self.cfg['mpiexec_cmd'])
# Check that the profiles are there
new_profs = os.listdir(self.profdir)
if not new_profs:
raise EasyBuildError("The PGO profiles where not found in the expected directory (%s)" % self.profdir)
# Change PGO related options
self.cfg['pgo'] = False
self.cfg['configopts'] = re.sub('--with-profile=gen', '--with-profile=use', self.cfg['configopts'])
# Reconfigure
print_msg("configuring with PGO...")
self.log.info("Running configure_step with PGO...")
self.configure_step()
# Rebuild
print_msg("building with PGO...")
self.log.info("Running build_step with PGO...")
self.build_step()
# Reinstall
print_msg("installing with PGO...")
self.log.info("Running install_step with PGO...")
self.install_step()
# MPICH configure script complains when F90 or F90FLAGS are set,
def configure_step(self):
"""
......@@ -230,9 +91,6 @@ class EB_psmpi(EB_MPICH):
# Set confset
comp_fam = self.toolchain.comp_family()
if comp_fam in comp_opts:
if comp_opts[comp_fam] is comp_opts[toolchain.NVHPC]:
self.cfg.update('configopts', ' --with-confset=%s' % comp_opts[toolchain.PGI])
else:
self.cfg.update('configopts', ' --with-confset=%s' % comp_opts[comp_fam])
else:
raise EasyBuildError("Compiler %s not supported. Valid options are: %s",
......@@ -246,10 +104,6 @@ class EB_psmpi(EB_MPICH):
if self.cfg['mpich_opts'] is not None:
self.cfg.update('configopts', ' --with-mpichconf="%s"' % self.cfg['mpich_opts'])
# Add PGO related options, if enabled
if self.cfg['pgo']:
self.cfg.update('configopts', ' --with-profile=gen --with-profdir=%s' % self.profdir)
# Lastly, set pscom related variables
if self.cfg['pscom_allin_path'] is None:
pscom_path = get_software_root('pscom')
......@@ -263,16 +117,7 @@ class EB_psmpi(EB_MPICH):
super(EB_psmpi, self).configure_step(add_mpich_configopts=False)
# If PGO is enabled, install, generate a profile, and start over
def install_step(self):
"""
Custom installation procedure for ParaStationMPI.
* If PGO is requested, installs, generate a profile, and start over
"""
super(EB_psmpi, self).install_step()
if self.cfg['pgo']:
self.pgo_steps()
# make and make install are default
def sanity_check_step(self):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment