51793d36创建于 2024年4月22日历史提交
#--------- Label --------------------------------------------------------------
# Arbitrary string to tag binaries (no spaces allowed)
#                  Two Suggestions: # (1) EDIT this label as you try new ideas.
#                                   # (2)      Use a label meaningful to *you*.
%ifndef %{label}
%   define label "gcc-11.3.0-opti"
%endif


#--------- Preprocessor -------------------------------------------------------
%ifndef %{bits}                # EDIT to control 32 or 64 bit compilation.  Or,
%   define  bits        64     #      you can set it on the command line using:
%endif                         #      'runcpu --define bits=nn'

%ifndef %{build_ncpus}         # EDIT to adjust number of simultaneous compiles.
%   define  build_ncpus  64     #      Or, you can set it on the command line:
%endif                         #      'runcpu --define build_ncpus=nn'

# Don't change this part.
%ifdef %{GCC4}
%   define model        ""    # mabi not present in older GCC 4
%elif %{bits} == 64
%   define model        -mabi=lp64
%elif %{bits} == 32
%   define model        -mabi=ilp32
%else
%   error Please define number of bits - see instructions in config file
%endif
%if %{label} =~ m/ /
%   error Your label "%{label}" contains spaces.  Please try underscores instead.
%endif
%if %{label} !~ m/^[a-zA-Z0-9._-]+$/
%   error Illegal character in label "%{label}".  Please use only alphanumerics, underscore, hyphen, and period.
%endif


#--------- Global Settings ----------------------------------------------------
# For info, see:
#            https://www.spec.org/cpu2017/Docs/config.html#fieldname
#   Example: https://www.spec.org/cpu2017/Docs/config.html#tune

command_add_redirect = 1
flagsurl        = %{top}/config/flags/gcc.xml
ignore_errors        = 1
iterations           = 1
label                = %{label}-%{bits}
line_width           = 1020
log_line_width       = 1020
makeflags            = --jobs=%{build_ncpus}
mean_anyway          = 1
output_format        = txt,html,cfg,pdf,csv
preenv               = 1
reportable           = 0
tune                 = base  # EDIT if needed: set to "base" for old GCC.
                                  #      See note "Older GCC" above.
intrate,fprate:
   copies           = 128   # EDIT to change number of copies (see above)
intspeed,fpspeed:
   threads          = 128   # EDIT to change number of OpenMP threads (see above)


# Affinitization
default:
submit = numactl --localalloc --physcpubind=$SPECCOPYNUM $command
#------- Compilers ------------------------------------------------------------
default:
#
%ifndef %{gcc_dir}
% define  gcc_dir  /usr
%endif

# EDIT: If your compiler version is GCC 4 (not recommended; see section "Older
#       GCC" above), enable the next line to avoid errors with -mabi
#
#%define GCC4     # EDIT: remove the '#' from column 1 if using GCC 4

# EDIT: If your compiler version is 10 or greater, you must enable the next
#       line to avoid compile errors for several FP benchmarks
#
%define GCCge10  # EDIT: remove the '#' from column 1 if using GCC 10 or later

%ifndef %{jemalloc_dir}
%   define  jemalloc_dir    "/usr/local/jemalloc-5.3.0"
%endif

# EDIT if needed: the preENV line adds library directories to the runtime
#      path.  You can adjust it, or add lines for other environment variables.
#      See: https://www.spec.org/cpu2017/Docs/config.html#preenv
#      and: https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html
   preENV_LD_LIBRARY_PATH  = %{jemalloc_dir}/lib/:%{gcc_dir}/lib64/:%{gcc_dir}/lib/:%{ENV_LD_LIBRARY_PATH}
   SPECLANG                = %{gcc_dir}/bin/
   CC                      = $(SPECLANG)gcc     -std=c99   %{model}
   CXX                     = $(SPECLANG)g++     -std=c++03 %{model}
   FC                      = $(SPECLANG)gfortran           %{model}
   # How to say "Show me your version, please"
   CC_VERSION_OPTION       = --version
   CXX_VERSION_OPTION      = --version
   FC_VERSION_OPTION       = --version

   EXTRA_CFLAGS     = -w
   EXTRA_LDFLAGS    = -L%{gcc_dir}/lib64 -L%{gcc_dir}/lib -L%{jemalloc_dir}/lib
   EXTRA_LIBS       = -ljemalloc -Wl,-Map,mapfile

default:
%if %{bits} == 64
   sw_base_ptrsize = 64-bit
   sw_peak_ptrsize = Not Applicable
%else
   sw_base_ptrsize = 32-bit
   sw_peak_ptrsize = 32-bit
%endif


#--------- Portability --------------------------------------------------------
default:   # data model applies to all benchmarks
%if %{bits} == 32
    # Strongly recommended because at run-time, operations using modern file
    # systems may fail spectacularly and frequently (or, worse, quietly and
    # randomly) if a program does not accommodate 64-bit metadata.
    EXTRA_PORTABILITY = -D_FILE_OFFSET_BITS=64
%else
    EXTRA_PORTABILITY = -DSPEC_LP64
%endif

# Benchmark-specific portability (ordered by last 2 digits of bmark number)

500.perlbench_r,600.perlbench_s:  #lang='C'
%if %{bits} == 32
%   define suffix AARCH32
%else
%   define suffix AARCH64
%endif
   PORTABILITY    = -DSPEC_LINUX_%{suffix}

521.wrf_r,621.wrf_s:  #lang='F,C'
   CPORTABILITY  = -DSPEC_CASE_FLAG
   FPORTABILITY  = -fconvert=big-endian

523.xalancbmk_r,623.xalancbmk_s:  #lang='CXX'
   PORTABILITY   = -DSPEC_LINUX

526.blender_r:  #lang='CXX,C'
   PORTABILITY   = -funsigned-char -DSPEC_LINUX

527.cam4_r,627.cam4_s:  #lang='F,C'
   PORTABILITY   = -DSPEC_CASE_FLAG

628.pop2_s:  #lang='F,C'
   CPORTABILITY   = -DSPEC_CASE_FLAG
   FPORTABILITY  = -fconvert=big-endian

#----------------------------------------------------------------------
#       GCC workarounds that do not count as PORTABILITY
#----------------------------------------------------------------------
# The workarounds in this section would not qualify under the SPEC CPU
# PORTABILITY rule.
#   - In peak, they can be set as needed for individual benchmarks.
#   - In base, individual settings are not allowed; set for whole suite.
# See:
#     https://www.spec.org/cpu2017/Docs/runrules.html#portability
#     https://www.spec.org/cpu2017/Docs/runrules.html#BaseFlags
#
# Integer workarounds - peak
#
   500.perlbench_r,600.perlbench_s=peak:    # https://www.spec.org/cpu2017/Docs/benchmarks/500.perlbench_r.html
      EXTRA_CFLAGS = -fno-strict-aliasing -fno-unsafe-math-optimizations -fno-finite-math-only
   502.gcc_r,602.gcc_s=peak:                # https://www.spec.org/cpu2017/Docs/benchmarks/502.gcc_r.html
      EXTRA_CFLAGS = -fno-strict-aliasing -fgnu89-inline
   505.mcf_r,605.mcf_s=peak:                # https://www.spec.org/cpu2017/Docs/benchmarks/505.mcf_r.html
      EXTRA_CFLAGS = -fno-strict-aliasing
   525.x264_r,625.x264_s=peak:              # https://www.spec.org/cpu2017/Docs/benchmarks/525.x264_r.html
      EXTRA_CFLAGS = -fcommon
#
# Integer workarounds - base - combine the above - https://www.spec.org/cpu2017/Docs/runrules.html#BaseFlags
#
   intrate,intspeed=base:
      EXTRA_CFLAGS = -fgnu89-inline -fcommon
#
# Floating Point workarounds - peak
#
   511.povray_r=peak:                       # https://www.spec.org/cpu2017/Docs/benchmarks/511.povray_r.html
      EXTRA_CFLAGS = -fno-strict-aliasing
   521.wrf_r,621.wrf_s=peak:                # https://www.spec.org/cpu2017/Docs/benchmarks/521.wrf_r.html
%     ifdef %{GCCge10}                      # workaround for GCC v10 (and presumably later)
         EXTRA_FFLAGS = -fallow-argument-mismatch
%     endif
   527.cam4_r,627.cam4_s=peak:              # https://www.spec.org/cpu2017/Docs/benchmarks/527.cam4_r.html
      EXTRA_CFLAGS = -fno-strict-aliasing
%     ifdef %{GCCge10}                      # workaround for GCC v10 (and presumably later)
         EXTRA_FFLAGS = -fallow-argument-mismatch
%     endif
   # See also topic "628.pop2_s basepeak" below
   628.pop2_s=peak:                         # https://www.spec.org/cpu2017/Docs/benchmarks/628.pop2_s.html
%     ifdef %{GCCge10}                      # workaround for GCC v10 (and presumably later)
         EXTRA_FFLAGS = -fallow-argument-mismatch
%     endif
#
# FP workarounds - base - combine the above - https://www.spec.org/cpu2017/Docs/runrules.html#BaseFlags
#
   fprate,fpspeed=base:
      EXTRA_CFLAGS = -fno-strict-aliasing
%     ifdef %{GCCge10}                      # workaround for GCC v10 (and presumably later)
         EXTRA_FFLAGS = -fallow-argument-mismatch
%     endif


#-------- Tuning Flags common to Base and Peak --------------------------------
#
# Speed (OpenMP and Autopar allowed)
#
%if %{bits} == 32
   intspeed,fpspeed:
   #
   # Many of the speed benchmarks (6nn.benchmark_s) do not fit in 32 bits
   # If you wish to run SPECint2017_speed or SPECfp2017_speed, please use
   #
   #     runcpu --define bits=64
   #
   fail_build = 1
%else
   intspeed,fpspeed:
      EXTRA_OPTIMIZE = -fopenmp -DSPEC_OPENMP
   fpspeed:
      #
      # 627.cam4 needs a big stack; the preENV will apply it to all
      # benchmarks in the set, as required by the rules.
      #
      preENV_OMP_STACKSIZE = 1G
%endif

#--------  Base Tuning Flags ----------------------------------------------
# EDIT if needed -- If you run into errors, you may need to adjust the
#                   optimization - for example you may need to remove
#                   the -march=native.   See topic "Older GCC" above.
#
intrate,intspeed=base:
   OPTIMIZE         = -O3 -funroll-loops -flto=32 -mcpu=cortex-a72+crypto+crc -march=armv8-a+crypto+crc
   COPTIMIZE        = --param early-inlining-insns=96  --param max-inline-insns-auto=64  --param inline-unit-growth=96
   CXXOPTIMIZE      = --param early-inlining-insns=256 --param max-inline-insns-auto=128 --param inline-unit-growth=256 -ffinite-loops
   FOPTIMIZE        = --param ipa-cp-eval-threshold=1  --param ipa-cp-unit-growth=80     --param ipa-cp-max-recursive-depth=8 -fno-inline-functions-called-once -fstack-arrays -flto-partition=one

%if %{bits} == 32
    EXTRA_COPTIMIZE = -fgnu89-inline -fno-strict-aliasing
%else
    EXTRA_COPTIMIZE = -fno-strict-aliasing
    LDCFLAGS        = -z muldefs
%endif

fprate,fpspeed=base:
   OPTIMIZE          = -Ofast -march=armv8.2-a -ffinite-math-only -fprefetch-loop-arrays -flto=32
   COPTIMIZE         = -I%{gcc_dir}/include -g
   CXXOPTIMIZE       = -ffinite-loops
   FOPTIMIZE         = -I%{gcc_dir}/include -ffast-math  -funroll-loops -fallow-argument-mismatch -fno-stack-arrays
   EXTRA_CLIBS       = -lm -lpthread -Wl,--no-as-needed -ldl
   EXTRA_FLIBS       = -lgfortran -lm -lpthread -Wl,--no-as-needed -ldl