Skip to content

Commit

Permalink
Merge pull request #68 from uramirez8707/MixedPrecision
Browse files Browse the repository at this point in the history
Adds an option to override the real precision to r4
  • Loading branch information
ceblanton authored Oct 10, 2024
2 parents e2328ac + ab81873 commit 9830f1a
Show file tree
Hide file tree
Showing 18 changed files with 180 additions and 18 deletions.
11 changes: 10 additions & 1 deletion templates/hpcme-intel21.mk
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ ISA =

COVERAGE = # Add the code coverage compile options.

USE_R4 = # If non-blank, use R4 for reals

# Need to use at least GNU Make version 3.81
need := 3.81
ok := $(filter $(need),$(firstword $(sort $(MAKE_VERSION) $(need))))
Expand All @@ -77,6 +79,13 @@ $(error Options DEBUG and TEST cannot be used together)
endif
endif

ifdef USE_R4
REAL_PRECISION := -real-size 32
CPPDEFS += -DOVERLOAD_R4
else
REAL_PRECISION := -real-size 64
endif

# Required Preprocessor Macros:
CPPDEFS += -Duse_netCDF

Expand All @@ -89,7 +98,7 @@ FPPFLAGS := -fpp -Wp,-w $(INCLUDES)
FPPFLAGS += $(shell nf-config --fflags)

# Base set of Fortran compiler flags
FFLAGS := -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -i4 -r8 -nowarn -sox -traceback
FFLAGS := -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -i4 $(REAL_PRECISION) -nowarn -sox -traceback

# Set the ISA (vectorization) as user defined or based on the target
ifdef ISA
Expand Down
11 changes: 10 additions & 1 deletion templates/hpcme-intel23.mk
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ ISA =

COVERAGE = # Add the code coverage compile options.

USE_R4 = # If non-blank, use R4 for reals

# Need to use at least GNU Make version 3.81
need := 3.81
ok := $(filter $(need),$(firstword $(sort $(MAKE_VERSION) $(need))))
Expand All @@ -79,6 +81,13 @@ $(error Options DEBUG and TEST cannot be used together)
endif
endif

ifdef USE_R4
REAL_PRECISION := -real-size 32
CPPDEFS += -DOVERLOAD_R4
else
REAL_PRECISION := -real-size 64
endif

# Required Preprocessor Macros:
CPPDEFS += -Duse_netCDF

Expand All @@ -91,7 +100,7 @@ FPPFLAGS := -fpp -Wp,-w $(INCLUDES)
FPPFLAGS += $(shell nf-config --fflags)

# Base set of Fortran compiler flags
FFLAGS := -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -i4 -r8 -nowarn -sox -traceback
FFLAGS := -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -i4 $(REAL_PRECISION) -nowarn -sox -traceback

# Set the ISA (vectorization) as user defined or based on the target
ifdef ISA
Expand Down
11 changes: 10 additions & 1 deletion templates/hpcme-intel24.mk
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ ISA =

COVERAGE = # Add the code coverage compile options.

USE_R4 = # If non-blank, use R4 for reals

# Need to use at least GNU Make version 3.81
need := 3.81
ok := $(filter $(need),$(firstword $(sort $(MAKE_VERSION) $(need))))
Expand All @@ -79,6 +81,13 @@ $(error Options DEBUG and TEST cannot be used together)
endif
endif

ifdef USE_R4
REAL_PRECISION := -real-size 32
CPPDEFS += -DOVERLOAD_R4
else
REAL_PRECISION := -real-size 64
endif

# Required Preprocessor Macros:
CPPDEFS += -Duse_netCDF

Expand All @@ -91,7 +100,7 @@ FPPFLAGS := -fpp -Wp,-w $(INCLUDES)
FPPFLAGS += $(shell nf-config --fflags)

# Base set of Fortran compiler flags
FFLAGS := -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -i4 -r8 -nowarn -sox -traceback
FFLAGS := -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -i4 $(REAL_PRECISION) -nowarn -sox -traceback

# Set the ISA (vectorization) as user defined or based on the target
ifdef ISA
Expand Down
11 changes: 10 additions & 1 deletion templates/linux-gnu.mk
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ SSE = # The SSE options to be used to compile. If blank,

COVERAGE = # Add the code coverage compile options.

USE_R4 = # If non-blank, use R4 for reals

# Need to use at least GNU Make version 3.81
need := 3.81
ok := $(filter $(need),$(firstword $(sort $(MAKE_VERSION) $(need))))
Expand All @@ -76,6 +78,13 @@ $(error Options DEBUG and TEST cannot be used together)
endif
endif

ifdef USE_R4
REAL_PRECISION := -fdefault-real-4
CPPDEFS += -DOVERLOAD_R4
else
REAL_PRECISION := -fdefault-real-8
endif

# Required Preprocessor Macros:
CPPDEFS += -Duse_netCDF

Expand All @@ -90,7 +99,7 @@ FPPFLAGS += $(shell nf-config --fflags)
FPPFLAGS += $(shell pkg-config --cflags-only-I mpich2)

# Base set of Fortran compiler flags
FFLAGS := -fcray-pointer -fdefault-double-8 -fdefault-real-8 -Waliasing -ffree-line-length-none -fno-range-check
FFLAGS := -fcray-pointer -fdefault-double-8 $(REAL_PRECISION) -Waliasing -ffree-line-length-none -fno-range-check

# Flags based on perforance target (production (OPT), reproduction (REPRO), or debug (DEBUG)
FFLAGS_OPT = -O3
Expand Down
11 changes: 10 additions & 1 deletion templates/linux-intel.mk
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ SSE = -xsse2 # The SSE options to be used to compile. If blank,

COVERAGE = # Add the code coverage compile options.

USE_R4 = # If non-blank, use R4 for reals

# Need to use at least GNU Make version 3.81
need := 3.81
ok := $(filter $(need),$(firstword $(sort $(MAKE_VERSION) $(need))))
Expand All @@ -76,6 +78,13 @@ $(error Options DEBUG and TEST cannot be used together)
endif
endif

ifdef USE_R4
REAL_PRECISION := -real-size 32
CPPDEFS += -DOVERLOAD_R4
else
REAL_PRECISION := -real-size 64
endif

# Required Preprocessor Macros:
CPPDEFS += -Duse_netCDF

Expand All @@ -90,7 +99,7 @@ FFPPLAGS += $(shell nf-config --fflags)
FFPPLAGS += $(shell pkg-config --cflags-only-I mpich2-c)

# Base set of Fortran compiler flags
FFLAGS := -fno-alias -stack_temps -safe_cray_ptr -ftz -assume byterecl -i4 -r8 -nowarn -g -sox -traceback
FFLAGS := -fno-alias -stack_temps -safe_cray_ptr -ftz -assume byterecl -i4 $(REAL_PRECISION) -nowarn -g -sox -traceback

# Flags based on perforance target (production (OPT), reproduction (REPRO), or debug (DEBUG)
FFLAGS_OPT = -O2
Expand Down
11 changes: 10 additions & 1 deletion templates/linux-ubuntu-trusty-gnu.mk
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ SSE = # The SSE options to be used to compile. If blank,

COVERAGE = # Add the code coverage compile options.

USE_R4 = # If non-blank, use R4 for reals

# Need to use at least GNU Make version 3.81
need := 3.81
ok := $(filter $(need),$(firstword $(sort $(MAKE_VERSION) $(need))))
Expand All @@ -75,6 +77,13 @@ $(error Options DEBUG and TEST cannot be used together)
endif
endif

ifdef USE_R4
REAL_PRECISION := -fdefault-real-4
CPPDEFS += -DOVERLOAD_R4
else
REAL_PRECISION := -fdefault-real-8
endif

# Required Preprocessor Macros:
CPPDEFS += -Duse_netCDF

Expand All @@ -87,7 +96,7 @@ FPPFLAGS := $(INCLUDES)
FPPFLAGS += $(shell nc-config --fflags)

# Base set of Fortran compiler flags
FFLAGS := -fcray-pointer -fdefault-double-8 -fdefault-real-8 -Waliasing -ffree-line-length-none -fno-range-check
FFLAGS := -fcray-pointer -fdefault-double-8 $(REAL_PRECISION) -Waliasing -ffree-line-length-none -fno-range-check

# Flags based on perforance target (production (OPT), reproduction (REPRO), or debug (DEBUG)
FFLAGS_OPT = -O3
Expand Down
11 changes: 10 additions & 1 deletion templates/linux-ubuntu-xenial-gnu.mk
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ SSE = # The SSE options to be used to compile. If blank,

COVERAGE = # Add the code coverage compile options.

USE_R4 = # If non-blank, use R4 for reals

# Need to use at least GNU Make version 3.81
need := 3.81
ok := $(filter $(need),$(firstword $(sort $(MAKE_VERSION) $(need))))
Expand All @@ -75,6 +77,13 @@ $(error Options DEBUG and TEST cannot be used together)
endif
endif

ifdef USE_R4
REAL_PRECISION := -fdefault-real-4
CPPDEFS += -DOVERLOAD_R4
else
REAL_PRECISION := -fdefault-real-8
endif

# Required Preprocessor Macros:
CPPDEFS += -Duse_netCDF

Expand All @@ -87,7 +96,7 @@ FPPFLAGS := $(INCLUDES)
FPPFLAGS += $(shell nf-config --fflags)

# Base set of Fortran compiler flags
FFLAGS := -fcray-pointer -fdefault-double-8 -fdefault-real-8 -Waliasing -ffree-line-length-none -fno-range-check
FFLAGS := -fcray-pointer -fdefault-double-8 $(REAL_PRECISION) -Waliasing -ffree-line-length-none -fno-range-check

# Flags based on perforance target (production (OPT), reproduction (REPRO), or debug (DEBUG)
FFLAGS_OPT = -O3
Expand Down
11 changes: 10 additions & 1 deletion templates/macOS-gnu8-mpich3.mk
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ SSE = # The SSE options to be used to compile. If blank,

COVERAGE = # Add the code coverage compile options.

USE_R4 = # If non-blank, use R4 for reals

# Need to use at least GNU Make version 3.81
need := 3.81
ok := $(filter $(need),$(firstword $(sort $(MAKE_VERSION) $(need))))
Expand All @@ -81,6 +83,13 @@ $(error Options DEBUG and TEST cannot be used together)
endif
endif

ifdef USE_R4
REAL_PRECISION := -fdefault-real-4
CPPDEFS += -DOVERLOAD_R4
else
REAL_PRECISION := -fdefault-real-8
endif

# Required Preprocessor Macros:
CPPDEFS += -Duse_netCDF

Expand All @@ -98,7 +107,7 @@ FPPFLAGS += $(shell nf-config --fflags)
FPPFLAGS += $(shell pkg-config --cflags-only-I mpich)

# Base set of Fortran compiler flags
FFLAGS := -fcray-pointer -fdefault-double-8 -fdefault-real-8 -Waliasing -ffree-line-length-none -fno-range-check
FFLAGS := -fcray-pointer -fdefault-double-8 $(REAL_PRECISION) -Waliasing -ffree-line-length-none -fno-range-check

# Flags based on perforance target (production (OPT), reproduction (REPRO), or debug (DEBUG)
FFLAGS_OPT = -O3
Expand Down
11 changes: 10 additions & 1 deletion templates/nccs-intel.mk
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ SSE = -march=core-avx2 # The SSE options to be used to compile. If blank,

COVERAGE = # Add the code coverage compile options.

USE_R4 = # If non-blank, use R4 for reals

# Need to use at least GNU Make version 3.81
need := 3.81
ok := $(filter $(need),$(firstword $(sort $(MAKE_VERSION) $(need))))
Expand All @@ -76,6 +78,13 @@ $(error Options DEBUG and TEST cannot be used together)
endif
endif

ifdef USE_R4
REAL_PRECISION := -real-size 32
CPPDEFS += -DOVERLOAD_R4
else
REAL_PRECISION := -real-size 64
endif

# Required Preprocessor Macros:
CPPDEFS += -Duse_netCDF

Expand All @@ -88,7 +97,7 @@ FPPFLAGS = -fpp -Wp,-w $(INCLUDES)
FPPFLAGS += $(shell nf-config --fflags)

# Base set of Fortran compiler flags
FFLAGS := -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -i4 -r8 -nowarn -sox -traceback
FFLAGS := -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -i4 $(REAL_PRECISION) -nowarn -sox -traceback

# Flags based on perforance target (production (OPT), reproduction (REPRO), or debug (DEBUG)
FFLAGS_OPT = -O3 -debug minimal -fp-model source
Expand Down
11 changes: 10 additions & 1 deletion templates/ncrc-nvhpc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ INCLUDES := $(shell pkg-config --cflags yaml-0.1)

COVERAGE = # Add the code coverage compile options.

USE_R4 = # If non-blank, use R4 for reals

# Need to use at least GNU Make version 3.81
need := 3.81
ok := $(filter $(need),$(firstword $(sort $(MAKE_VERSION) $(need))))
Expand All @@ -69,6 +71,13 @@ $(error Options DEBUG and TEST cannot be used together)
endif
endif

ifdef USE_R4
REAL_PRECISION := -r4
CPPDEFS += -DOVERLOAD_R4
else
REAL_PRECISION := -r8
endif

# Check version of PGI for use of -nofma option
has_nofma := $(shell $(FC) -dryrun -nofma foo.f90 > /dev/null 2>&1; echo $$?)
ifneq ($(has_nofma),0)
Expand All @@ -89,7 +98,7 @@ FPPFLAGS := $(INCLUDES)
FPPFLAGS += $(shell nf-config --fflags)

# Base set of Fortran compiler flags
FFLAGS = -i4 -r8 -byteswapio -Mcray=pointer -Mcray=pointer -Mflushz -Mdaz -D_F2000
FFLAGS = -i4 $(REAL_PRECISION) -byteswapio -Mcray=pointer -Mcray=pointer -Mflushz -Mdaz -D_F2000

# Flags based on perforance target (production (OPT), reproduction (REPRO), or debug (DEBUG)
FFLAGS_OPT = -O3 -Mvect=nosse -Mnoscalarsse -Mallocatable=95
Expand Down
11 changes: 10 additions & 1 deletion templates/ncrc5-cce.mk
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ INCLUDES := $(shell pkg-config --cflags yaml-0.1)

COVERAGE = # Add the code coverage compile options.

USE_R4 = # If non-blank, use R4 for reals

# Need to use at least GNU Make version 3.81
need := 3.81
ok := $(filter $(need),$(firstword $(sort $(MAKE_VERSION) $(need))))
Expand All @@ -69,6 +71,13 @@ $(error Options DEBUG and TEST cannot be used together)
endif
endif

ifdef USE_R4
REAL_PRECISION := real32
CPPDEFS += -DOVERLOAD_R4
else
REAL_PRECISION := real64
endif

# Required Preprocessor Macros:
CPPDEFS += -Duse_netCDF

Expand All @@ -81,7 +90,7 @@ FPPFLAGS := $(INCLUDES)
FPPFLAGS += $(shell nf-config --fflags)

# Base set of Fortran compiler flags
FFLAGS = -s real64 -s integer32 -h byteswapio -e m -h keepfiles -e0 -ez -N1023
FFLAGS = -s $(REAL_PRECISION) -s integer32 -h byteswapio -e m -h keepfiles -e0 -ez -N1023

# Flags based on perforance target (production (OPT), reproduction (REPRO), or debug (DEBUG)
FFLAGS_OPT = -O3 -O fp2 -G2
Expand Down
11 changes: 10 additions & 1 deletion templates/ncrc5-gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ INCLUDES := $(shell pkg-config --cflags yaml-0.1)

COVERAGE = # Add the code coverage compile options.

USE_R4 = # If non-blank, use R4 for reals

# Need to use at least GNU Make version 3.81
need := 3.81
ok := $(filter $(need),$(firstword $(sort $(MAKE_VERSION) $(need))))
Expand All @@ -69,6 +71,13 @@ $(error Options DEBUG and TEST cannot be used together)
endif
endif

ifdef USE_R4
REAL_PRECISION := -fdefault-real-4
CPPDEFS += -DOVERLOAD_R4
else
REAL_PRECISION := -fdefault-real-8
endif

# Required Preprocessor Macros:
CPPDEFS += -Duse_netCDF

Expand All @@ -81,7 +90,7 @@ FPPFLAGS := $(INCLUDES)
FPPFLAGS += $(shell nf-config --fflags)

# Base set of Fortran compiler flags
FFLAGS := -fcray-pointer -fdefault-real-8 -fdefault-double-8 -Waliasing -ffree-line-length-none -fno-range-check -fallow-argument-mismatch
FFLAGS := -fcray-pointer $(REAL_PRECISION) -fdefault-double-8 -Waliasing -ffree-line-length-none -fno-range-check -fallow-argument-mismatch

# Flags based on perforance target (production (OPT), reproduction (REPRO), or debug (DEBUG)
FFLAGS_OPT = -O2 -fno-expensive-optimizations
Expand Down
Loading

0 comments on commit 9830f1a

Please sign in to comment.