Skip to content

Commit

Permalink
Merge pull request #251 from PRUNERS/issue119-user-flag-tests
Browse files Browse the repository at this point in the history
Generate compiler flags from toml file
  • Loading branch information
IanBriggs authored Jan 8, 2019
2 parents aedb52f + 2728341 commit f23a122
Show file tree
Hide file tree
Showing 24 changed files with 1,956 additions and 205 deletions.
141 changes: 15 additions & 126 deletions data/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,10 @@ DEV_TARGET ?= devrun
GT_TARGET ?= gtrun
GT_OUT := ground-truth.csv

UNAME_S := $(shell uname -s)
UNAME_S := {uname}

# will be None if not specified in flit-config.toml
CLANG := {clang_compiler}
INTEL := {intel_compiler}
GCC := {gcc_compiler}
{compiler_defs}
CLANG_TYPE := clang
INTEL_TYPE := intel
GCC_TYPE := gcc
Expand Down Expand Up @@ -227,7 +225,7 @@ GT_OBJ = $(addprefix $(OBJ_DIR)/,$(notdir $(SOURCE:%.cpp=%_gt.o)))
GT_DEPS = $(GT_OBJ:%.o=%.d)
GT_OBJ_FPIC = $(GT_OBJ:%.o=%_fPIC.o)

HOSTNAME := $(shell hostname)
HOSTNAME := {hostname}

RESULTS_DIR := results

Expand All @@ -245,128 +243,19 @@ endif
# more comp settings, taken from here:
# https://software.intel.com/sites/default/files/article/326703/fp-control-2012-08.pdf

#individual flags
# individual flags

## optls

O0 := -O0
O1 := -O1
O2 := -O2
O3 := -O3

#switches

ASSOCMATH := -fassociative-math
AVX := -mavx
COMPTRANS := -mp1
DEFFLAGS :=
DISFMA := -no-fma
ENAFMA := -fma
FASTEXPREC := -fexcess-precision=fast
FASTM := -ffast-math
FINMATH := -ffinite-math-only
FLUSHDEN := -ftz
FMAGCC := -mavx2 -mfma
FMAICC := -march=core-avx2
FORTRULES := -fcx-fortran-rules
FPCONT := -ffp-contract=on
FPMODDBL := -fp-model=double
FPMODEXC := -fp-model=except
FPMODEXT := -fp-model=extended
FPMODFST1 := -fp-model fast=1
FPMODFST2 := -fp-model fast=2
FPMODPRE := -fp-model=precise
FPMODSRC := -fp-model=source
FPMODSTR := -fp-model=strict
FPTRAP := -fp-trap=common
FSTORE := -ffloat-store
LIMITEDRANGE := -fcx-limited-range
MCONSTS := -fmerge-all-constants
NOFLUSHDEN := -no-ftz
NOPRECDIV := -no-prec-div
NOTRAP := -fno-trapping-math
PRECDIV := -prec-div
RECIPMATH := -freciprocal-math
ROUNDINGMATH := -frounding-math
ROUNDUSR := -fp-port
SIGNALNAN := -fsignaling-nans
SINGLEPRECCONST := -fsingle-precision-constant
SSE := -mfpmath=sse -mtune=native
STDEXPREC := -fexcess-precision=standard
UNSOPTS := -funsafe-math-optimizations
USEFASTM := --use_fast_math

# Collections

OPCODES := O0 O1 O2 O3

# NOTE: gcc disables ASSOCMATH @ O0
SWITCHES_GCC += ASSOCMATH
SWITCHES_GCC += AVX
SWITCHES_GCC += DEFFLAGS
SWITCHES_GCC += FASTEXPREC
SWITCHES_GCC += FINMATH
SWITCHES_GCC += FMAGCC
SWITCHES_GCC += FORTRULES
SWITCHES_GCC += FPCONT
SWITCHES_GCC += FSTORE
SWITCHES_GCC += LIMITEDRANGE
SWITCHES_GCC += MCONSTS
SWITCHES_GCC += NOTRAP
SWITCHES_GCC += RECIPMATH
SWITCHES_GCC += ROUNDINGMATH
SWITCHES_GCC += SIGNALNAN
SWITCHES_GCC += SSE
SWITCHES_GCC += UNSOPTS

#NOTE: Clang not honoring ASSOCMATH (issues warning with 3.9)
# see: https://llvm.org/bugs/show_bug.cgi?id=27372

SWITCHES_CLANG += ASSOCMATH
SWITCHES_CLANG += AVX
SWITCHES_CLANG += DEFFLAGS
SWITCHES_CLANG += FASTEXPREC
SWITCHES_CLANG += FINMATH
SWITCHES_CLANG += FMAGCC
SWITCHES_CLANG += FMAICC
SWITCHES_CLANG += FPCONT
SWITCHES_CLANG += FSTORE
SWITCHES_CLANG += MCONSTS
SWITCHES_CLANG += NOTRAP
SWITCHES_CLANG += RECIPMATH
SWITCHES_CLANG += ROUNDINGMATH
SWITCHES_CLANG += SIGNALNAN
SWITCHES_CLANG += SINGLEPRECCONST
SWITCHES_CLANG += SSE
SWITCHES_CLANG += STDEXPREC
SWITCHES_CLANG += UNSOPTS

SWITCHES_INTEL += AVX
SWITCHES_INTEL += COMPTRANS
SWITCHES_INTEL += DEFFLAGS
SWITCHES_INTEL += DISFMA
SWITCHES_INTEL += ENAFMA
SWITCHES_INTEL += FLUSHDEN
SWITCHES_INTEL += FMAGCC
SWITCHES_INTEL += FMAICC
SWITCHES_INTEL += FPMODDBL
SWITCHES_INTEL += FPMODEXT
SWITCHES_INTEL += FPMODFST1
SWITCHES_INTEL += FPMODFST2
SWITCHES_INTEL += FPMODPRE
SWITCHES_INTEL += FPMODSRC
SWITCHES_INTEL += FPMODSTR
SWITCHES_INTEL += FSTORE
SWITCHES_INTEL += LIMITEDRANGE
SWITCHES_INTEL += MCONSTS
SWITCHES_INTEL += NOFLUSHDEN
SWITCHES_INTEL += NOPRECDIV
SWITCHES_INTEL += PRECDIV
SWITCHES_INTEL += ROUNDINGMATH
SWITCHES_INTEL += ROUNDUSR
SWITCHES_INTEL += SINGLEPRECCONST
SWITCHES_INTEL += SSE
SWITCHES_INTEL += USEFASTM
{opcodes_definitions}

## switches

{switches_definitions}

{compiler_opcodes}

{compiler_switches}

##########################################################
#
Expand Down Expand Up @@ -459,7 +348,7 @@ TARGET_OUTS :=

# @param 1: compiler variable name (e.g. CLANG)
# @param 2: optimization level variable name (e.g. O2)
# @param 3: switches variable name (e.g. USEFASTM)
# @param 3: switches variable name (e.g. USE_FAST_MATH)
define RECURSION_RULE
TARGETS += $$(RESULTS_DIR)/$(strip $1)_$$(HOSTNAME)_$(strip $3)_$(strip $2)

Expand All @@ -482,7 +371,7 @@ endef

$(foreach c, $(COMPILERS), \
$(foreach s, $(SWITCHES_$(strip $c)), \
$(foreach o, $(OPCODES), \
$(foreach o, $(OPCODES_$(strip $c)), \
$(eval $(call RECURSION_RULE, $c, $o, $s)))))
TARGET_OUTS := $(TARGETS:%=%-out)
TARGET_RESULTS := $(TARGET_OUTS:%=%-comparison.csv)
Expand Down
28 changes: 13 additions & 15 deletions documentation/available-compiler-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ Convenient TOML lists:
* [Clang](#clang)
* [Intel](#intel)

Currently, the configuration file does not specify the flags and optimization
levels to use. We plan to change this in future updates. Consider the
documentation below to relate to future desired features. See
[issue-119](https://github.com/PRUNERS/FLiT/issues/119).

The flags below are still useful to understand because they are the current
flags that are hard-coded into the autogenerated `Makefile`. Below is a
comprehensive list of switches used.


## All Flags

Expand Down Expand Up @@ -73,9 +64,15 @@ For your convenience, here are toml-style lists that can be copied into your

## GCC

**Note:** in some versions of python-toml, there is a parsing bug when a list
has an empty string in the middle. So simply put it at the end without a
comma. This has been fixed in the latest version of python-toml.

You will likely want the empty string in your search space as it represents the
absence of any switches.

```toml
switches = [
'',
switches_list = [
'-fassociative-math',
'-fcx-fortran-rules',
'-fcx-limited-range',
Expand All @@ -92,14 +89,14 @@ switches = [
'-mavx',
'-mavx2 -mfma',
'-mfpmath=sse -mtune=native',
''
]
```

## Clang

```toml
switches = [
'',
switches_list = [
'-fassociative-math',
'-fexcess-precision=fast',
'-fexcess-precision=standard',
Expand All @@ -117,14 +114,14 @@ switches = [
'-mavx',
'-mavx2 -mfma',
'-mfpmath=sse -mtune=native',
''
]
```

## Intel

```toml
switches = [
'',
switches_list = [
'--use_fast_math',
'-fcx-limited-range',
'-ffloat-store',
Expand All @@ -151,6 +148,7 @@ switches = [
'-no-ftz',
'-no-prec-div',
'-prec-div',
''
]
```

Expand Down
Loading

0 comments on commit f23a122

Please sign in to comment.