From cfcba1c3dc9f08be1c757a1e2a569ad39b3da565 Mon Sep 17 00:00:00 2001 From: edoapra Date: Mon, 5 Dec 2022 14:23:59 -0800 Subject: [PATCH] MPI env variables are now ignored unless FORCE_MPI_ENV is set --- src/config/makefile.h | 92 +++++++++++++++++++++++++++++-------------- src/tools/GNUmakefile | 12 +++--- 2 files changed, 68 insertions(+), 36 deletions(-) diff --git a/src/config/makefile.h b/src/config/makefile.h index f99e34adf8..a4eeaff587 100644 --- a/src/config/makefile.h +++ b/src/config/makefile.h @@ -243,10 +243,10 @@ endif # specified below. Use of MPI requires substituting the tcgmsg-mpi # wrapper for the normal tcgmsg library. # the 2 following environmental variables are need for linking -# LIBMPI - represents the name of mpi library (with -l) -# MPI_LIB - represents the path to the mpi library -#LIBMPI = -lmpich -#MPI_LIB= /usr/local/lib +# NWLIBMPI - represents the name of mpi library (with -l) +# NWMPI_LIB - represents the path to the mpi library +#NWLIBMPI = -lmpich +#NWMPI_LIB= /usr/local/lib #JN: under the new structure, tools should be listed first as # their header files are needed for dependency analysis of @@ -320,10 +320,10 @@ endif ifdef BUILD_MPICH NW_CORE_SUBDIRS += libext PATH := $(NWCHEM_TOP)/src/libext/bin:$(PATH) - MPI_INCLUDE = $(shell PATH=$(NWCHEM_TOP)/src/libext/bin:$(PATH) $(NWCHEM_TOP)/src/tools/guess-mpidefs --mpi_include) - MPI_LIB = $(shell PATH=$(NWCHEM_TOP)/src/libext/bin:$(PATH) $(NWCHEM_TOP)/src/tools/guess-mpidefs --mpi_lib) - LIBMPI = $(shell PATH=$(NWCHEM_TOP)/src/libext/bin:$(PATH) $(NWCHEM_TOP)/src/tools/guess-mpidefs --libmpi) - LIBMPI += $(shell /usr/local/bin/pkg-config --libs-only-L hwloc 2> /dev/null) + NWMPI_INCLUDE = $(shell PATH=$(NWCHEM_TOP)/src/libext/bin:$(PATH) $(NWCHEM_TOP)/src/tools/guess-mpidefs --mpi_include) + NWMPI_LIB = $(shell PATH=$(NWCHEM_TOP)/src/libext/bin:$(PATH) $(NWCHEM_TOP)/src/tools/guess-mpidefs --mpi_lib) + NWLIBMPI = $(shell PATH=$(NWCHEM_TOP)/src/libext/bin:$(PATH) $(NWCHEM_TOP)/src/tools/guess-mpidefs --libmpi) + NWLIBMPI += $(shell /usr/local/bin/pkg-config --libs-only-L hwloc 2> /dev/null) endif @@ -3524,37 +3524,69 @@ endif ifdef USE_MPI #ifeq ($(FC),$(findstring $(FC),mpifrt mpfort mpif77 mpxlf mpif90 ftn scorep-ftn)) ifeq ($(FC),$(findstring $(FC), ftn scorep-ftn)) - LIBMPI = - MPI_INCLUDE = - MPI_LIB = - else + NWLIBMPI = + NWMPI_INCLUDE = + NWMPI_LIB = + else ifdef FORCE_MPI_ENV ifndef MPI_INCLUDE - # check if mpif90 is present - MPIF90YN = $(shell $(NWCHEM_TOP)/src/tools/guess-mpidefs --mpi_include) - ifeq ($(MPIF90YN),mpif90notfound) - errormpif90: - $(info ) - $(info mpif90 not found. Please add its location to PATH) - $(info e.g. export PATH=/usr/local/bin:/usr/lib64/openmpi/bin:...) - $(info ) - endif - MPI_INCLUDE = $(shell $(NWCHEM_TOP)/src/tools/guess-mpidefs --mpi_include) - endif + errormpi1: + $(error ) + $(error FORCE_MPI_ENV set but MPI_INCLUDE not set) + $(error ) + else + NWMPI_INCLUDE = $(MPI_INCLUDE) + endif ifndef MPI_LIB - MPI_LIB = $(shell $(NWCHEM_TOP)/src/tools/guess-mpidefs --mpi_lib) - endif + errormpi2: + $(error ) + $(error FORCE_MPI_ENV set but MPI_LIB not set) + $(error ) + else + NWMPI_LIB = $(MPI_LIB) + endif ifndef LIBMPI - LIBMPI = $(shell $(NWCHEM_TOP)/src/tools/guess-mpidefs --libmpi) + errormpi3: + $(error ) + $(error FORCE_MPI_ENV set but LIBMPI not set) + $(error ) + else + NWLIBMPI = $(LIBMPI) + endif + else + ifeq ($(shell pwd), $(NWCHEM_TOP)/src) + ifndef FORCE_MPI_ENV + ifdef LIBMPI +$(info ***warning LIBMPI ignored since FORCE_MPI_ENV not set***) + endif + ifdef MPI_LIB +$(info ***warning MPI_LIB ignored since FORCE_MPI_ENV not set***) + endif + ifdef MPI_INCLUDE +$(info ***warning MPI_INCLUDE ignored since FORCE_MPI_ENV not set***) + endif + endif + endif + # check if mpif90 is present + MPIF90YN = $(shell $(NWCHEM_TOP)/src/tools/guess-mpidefs --mpi_include) + ifeq ($(MPIF90YN),mpif90notfound) + errormpif90: + $(error ) + $(error mpif90 not found. Please add its location to PATH) + $(error e.g. export PATH=/usr/local/bin:/usr/lib64/openmpi/bin:...) + $(error ) endif + NWMPI_INCLUDE = $(shell $(NWCHEM_TOP)/src/tools/guess-mpidefs --mpi_include) + NWMPI_LIB = $(shell $(NWCHEM_TOP)/src/tools/guess-mpidefs --mpi_lib) + NWLIBMPI = $(shell $(NWCHEM_TOP)/src/tools/guess-mpidefs --libmpi) endif - ifdef MPI_LIB - CORE_LIBS += $(patsubst -L-L%,-L%,-L$(MPI_LIB)) + ifdef NWMPI_LIB + CORE_LIBS += $(patsubst -L-L%,-L%,-L$(NWMPI_LIB)) endif ifdef OLD_GA - CORE_LIBS += -ltcgmsg-mpi $(LIBMPI) + CORE_LIBS += -ltcgmsg-mpi $(NWLIBMPI) else - CORE_LIBS += $(LIBMPI) + CORE_LIBS += $(NWLIBMPI) endif else ifdef OLD_GA diff --git a/src/tools/GNUmakefile b/src/tools/GNUmakefile index 423f02a182..c32e79e500 100644 --- a/src/tools/GNUmakefile +++ b/src/tools/GNUmakefile @@ -318,14 +318,14 @@ endif # SOCKETS ifdef USE_MPI MPI_COMBINED = - ifneq ($(MPI_INCLUDE),) - MPI_COMBINED += $(patsubst -I-I%,-I%,-I${MPI_INCLUDE}) + ifneq ($(NWMPI_INCLUDE),) + MPI_COMBINED += $(patsubst -I-I%,-I%,-I${NWMPI_INCLUDE}) endif - ifneq ($(MPI_LIB),) - MPI_COMBINED += $(patsubst -L-L%,-L%,-L${MPI_LIB}) + ifneq ($(NWMPI_LIB),) + MPI_COMBINED += $(patsubst -L-L%,-L%,-L${NWMPI_LIB}) endif - ifneq ($(LIBMPI),) - MPI_COMBINED += $(LIBMPI) + ifneq ($(NWLIBMPI),) + MPI_COMBINED += $(NWLIBMPI) ifeq ($(ARMCI_NETWORK),ARMCI) MPI_COMBINED += -lpthread endif