Skip to content

Commit

Permalink
Update Makefile to create faster binaries.
Browse files Browse the repository at this point in the history
Update Makefile to create faster binaries:
  - cbust_static:
      Compile a static binary with a recent version of gcc and glibc
      to run on an old distribution as CentOS7. Resulting binary can
      be twice as fast.
  - cbust_amd_libm_aocc:
      Compile a static binary with AMD math library (compiled with AOCC)
      for a slightly faster binary than cbust, or cbust_static.
  - cbust_amd_libm_gcc:
      Compile a static binary with AMD math library (compiled with GCC)
      for a slightly faster binary than cbust, or cbust_static.
  • Loading branch information
ghuls committed Apr 21, 2022
1 parent 942a29b commit 5911cd6
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,43 @@ GIT_COMMIT_INFO = $(shell git log -1 --format='%ci commit: %h')
CXX = g++
ICPC = icpc

CXXFLAGS = -Wall -std=c++0x -O3 -march=native -D NDEBUG
CXXFLAGS = -Wall -std=c++0x -O3 -march=x86-64 -D NDEBUG
CXXFLAGS_INTEL = -Wall -std=c++0x -O3 -march=native -D NDEBUG -static
CXXFLAGS_GIT_COMMIT_INFO = -D GIT_COMMIT_INFO="\"$(GIT_COMMIT_INFO)\""

# Optionally compile with AMD Math Library (LibM) for a slightly faster binary:
# https://developer.amd.com/amd-aocl/amd-math-library-libm/
#
# mkdir ../aocl-libm
# cd ../aocl-libm
#
# AMD_LIB_VERSION=3.1.0
#
# tar xzf aocl-libm-linux-aocc-${AMD_LIB_VERSION}.tar.gz
# mv amd-libm amd-libm-aocc
#
# tar xzf aocl-libm-linux-gcc-${AMD_LIB_VERSION}.tar.gz
# mv amd-libm amd-libm-gcc
AMD_LIBM_AOCC = ../aocl-libm/amd-libm-aocc
AMD_LIBM_GCC = ../aocl-libm/amd-libm-gcc


all: cbust

cbust: *.cpp *.hpp
$(CXX) $(CXXFLAGS) $(CXXFLAGS_GIT_COMMIT_INFO) -o cbust *.cpp

cbust_static: *.cpp *.hpp
$(CXX) $(CXXFLAGS) $(CXXFLAGS_GIT_COMMIT_INFO) -o cbust_static *.cpp -static

cbust_amd_libm_aocc: *.cpp *.hpp
$(CXX) $(CXXFLAGS) $(CXXFLAGS_GIT_COMMIT_INFO) -I $(AMD_LIBM_AOCC)/include -o cbust_amd_libm_aocc *.cpp -L $(AMD_LIBM_AOCC)/lib -static -lalm -lm

cbust_amd_libm_gcc: *.cpp *.hpp
$(CXX) $(CXXFLAGS) $(CXXFLAGS_GIT_COMMIT_INFO) -I $(AMD_LIBM_GCC)/include -o cbust_amd_libm_gcc *.cpp -L $(AMD_LIBM_GCC)/lib -static -lalm -lm

cbust_intel: *.cpp *.hpp
$(ICPC) $(CXXFLAGS_INTEL) $(CXXFLAGS_GIT_COMMIT_INFO) -o cbust_intel *.cpp

clean:
rm -f cbust cbust_intel
rm -f cbust cbust_static cbust_amd_libm_aocc cbust_amd_libm_gcc cbust_intel

0 comments on commit 5911cd6

Please sign in to comment.