Skip to content

Commit

Permalink
Merge pull request #65 from PRUNERS/issue_53-return-string
Browse files Browse the repository at this point in the history
Issue 53 return string
  • Loading branch information
mikebentley15 authored Jun 30, 2017
2 parents a5f4c56 + abfe5c4 commit 899b9ef
Show file tree
Hide file tree
Showing 64 changed files with 1,506 additions and 701 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,17 @@ DEPFLAGS += -MD -MF $(SRCDIR)/$*.d

SOURCE := $(wildcard $(SRCDIR)/*.cpp)
HEADERS += $(wildcard $(SRCDIR)/*.h)
HEADERS += $(wildcard $(SRCDIR)/*.hpp)

OBJ := $(SOURCE:.cpp=.o)
DEPS := $(SOURCE:.cpp=.d)

# Install variables

SCRIPT_DIR = scripts/flitcli
DATA_DIR = $(SCRIPT_DIR)/data
DATA_DIR = data
CONFIG_DIR = $(SCRIPT_DIR)/config
DOC_DIR = documentation
LITMUS_TESTS += $(wildcard litmus-tests/tests/*.cpp)
LITMUS_TESTS += $(wildcard litmus-tests/tests/*.hpp)
LITMUS_TESTS += $(wildcard litmus-tests/tests/*.h)

INSTALL_FLIT_CONFIG = $(PREFIX)/share/flit/scripts/flitconfig.py
Expand Down Expand Up @@ -92,6 +90,7 @@ install: $(TARGET)
mkdir -m 0755 -p $(PREFIX)/share/flit/scripts
mkdir -m 0755 -p $(PREFIX)/share/flit/doc
mkdir -m 0755 -p $(PREFIX)/share/flit/data/tests
mkdir -m 0755 -p $(PREFIX)/share/flit/data/db
mkdir -m 0755 -p $(PREFIX)/share/flit/config
mkdir -m 0755 -p $(PREFIX)/share/flit/litmus-tests
ln -sf ../share/flit/scripts/flit.py $(PREFIX)/bin/flit
Expand All @@ -105,6 +104,7 @@ install: $(TARGET)
install -m 0644 $(DATA_DIR)/custom.mk $(PREFIX)/share/flit/data/
install -m 0644 $(DATA_DIR)/main.cpp $(PREFIX)/share/flit/data/
install -m 0644 $(DATA_DIR)/tests/Empty.cpp $(PREFIX)/share/flit/data/tests/
install -m 0644 $(DATA_DIR)/db/tables-psql.sql $(PREFIX)/share/flit/data/db/
install -m 0644 $(CONFIG_DIR)/flit-default.toml.in $(PREFIX)/share/flit/config/
install -m 0644 $(LITMUS_TESTS) $(PREFIX)/share/flit/litmus-tests/
@echo "Generating $(INSTALL_FLIT_CONFIG)"
Expand Down
174 changes: 102 additions & 72 deletions scripts/flitcli/data/Makefile.in → data/Makefile.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Autogenerated Makefile using "flit update"

DEV_CC := {compiler}
FFLAGS ?=
DEV_TARGET ?= devrun
DEV_CUTARGET ?= cu_devrun
GT_TARGET ?= gtrun
GT_OUT := ground-truth.csv

UNAME_S := $(shell uname -s)

Expand All @@ -22,6 +23,14 @@ DEV_CFLAGS += -Wextra
DEV_CFLAGS += -Wuninitialized
DEV_CFLAGS += -Wno-shift-count-overflow

DEV_CC ?= {dev_compiler}
DEV_OPTL ?= {dev_optl}
DEV_SWITCHES ?= {dev_switches}

GT_CC := {ground_truth_compiler}
GT_OPTL := {ground_truth_optl}
GT_SWITCHES := {ground_truth_switches}

LD_REQUIRED += -lm
LD_REQUIRED += -lstdc++
ifeq ($(UNAME_S),Darwin) # If we are on a Mac OSX system
Expand All @@ -39,8 +48,10 @@ TESTS := $(wildcard tests/*.cpp)
SOURCE := $(wildcard *.cpp)
SOURCE += $(TESTS)

DEV_OBJ := $(SOURCE:%.cpp=%_dev.o)
DEV_DEPS := $(SOURCE:%.cpp=%_dev.d)
DEV_OBJ = $(SOURCE:%.cpp=%_dev.o)
DEV_DEPS = $(SOURCE:%.cpp=%_dev.d)
GT_OBJ = $(SOURCE:%.cpp=%_gt.o)
GT_DEPS = $(SOURCE:%.cpp=%_gt.d)

CLANG := clang++
INTEL := icpc
Expand Down Expand Up @@ -194,18 +205,21 @@ SWITCHES_INTEL += USEFASTM
TARGETS := $(foreach c, $(COMPILERS), \
$(foreach s, $(SWITCHES_$(strip $c)), \
$(foreach o, $(OPCODES), \
$c_$(HOSTNAME)_$(strip $(s))_$(strip $(o))_out \
$(RESULTS_DIR)/$c_$(HOSTNAME)_$(strip $s)_$(strip $o)_out.csv \
) \
) \
)
BIN := $(TARGETS:%_out=%)
OBJ = $(foreach b,$(BIN),$(SOURCE:%.cpp=%_$(strip $(b)).o))
BIN := $(TARGETS:%_out.csv=%)
OBJ = $(foreach b,$(BIN),$(SOURCE:%.cpp=%_$(notdir $b).o))

##################################################
#
# Now deal with CUDA stuff if it is even available
#
##################################################

# TODO: double check CUDA flags. Really? No optimization levels?

NVCC_BIN := nvcc
NVCC := $(shell which $(NVCC_BIN))
CUDA_DIR := $(dir $(NVCC))/..
Expand Down Expand Up @@ -272,13 +286,12 @@ CUSWITCHES += PRECSFC
CUSWITCHES += PRECSTC

CUTARGETS := $(foreach s, $(CUSWITCHES), \
NVCC_$(HOSTNAME)_$(strip $(s))_out)
CUBIN := $(CUTARGETS:%_out=%)
CUOBJ := $(foreach b,$(CUBIN),$(CUSOURCE:%.cpp=%_$b.o))
$(RESULTS_DIR)/NVCC_$(HOSTNAME)_$(strip $(s))_out.csv)
CUBIN := $(CUTARGETS:%_out.csv=%)
CUOBJ := $(foreach b,$(CUBIN),$(CUSOURCE:%.cpp=%_$(notdir $b).o))

endif # ifdef HAS_CUDA


.PHONY: help
help:
@echo 'You can run the Makefile directly, but it is recommended to use'
Expand All @@ -293,42 +306,50 @@ help:
@echo ' help Show this help and exit (default target)'
@echo ' dev Only run the devel compilation to test things out'
@echo ' devcuda Only run the devel CUDA compilation to test CUDA out'
@echo ' groundtruth Compile the ground-truth version and get its output'
@echo ' gt Same as groundtruth'
@echo ' run Run all combinations of compilation, results in results/'
@echo ' clean Clean intermediate files'
@echo ' veryclean Runs clean + removes targets and results'
@echo ' distclean Same as veryclean'
@echo

.PHONY: dev devcuda run
.PHONY: dev devcuda gt groundtruth run
dev: $(DEV_TARGET)
devcuda: $(DEV_CUTARGET)
run: $(TARGETS) $(CUTARGETS) cleanResults archive
gt: $(GT_TARGET) $(GT_OUT)
groundtruth: $(GT_TARGET) $(GT_OUT)

run: $(TARGETS) $(CUTARGETS)

.PHONY: clean
clean:
rm -f $(DEV_OBJ)
rm -f $(DEV_DEPS)
rm -f $(DEV_CUOBJ)
rm -f $(TARGETS)
rm -f $(CUTARGETS)
rm -f $(BIN)
rm -f $(OBJ)
rm -f $(CUBIN)
rm -f $(CUOBJ)
rm -f $(GT_OBJ)
rm -f $(GT_DEPS)

.PHONY: veryclean distclean
veryclean: distclean
distclean: clean
rm -f $(DEV_TARGET)
rm -f $(DEV_CUTARGET)
rm -f $(TARGETS:%=$(RESULTS_DIR)/%)
rm -f $(BIN:%=$(RESULTS_DIR)/%)
rm -f $(CUTARGETS:%=$(RESULTS_DIR)/%)
rm -f $(CUBIN:%=$(RESULTS_DIR)/%)
rm -f $(TARGETS)
rm -f $(addsuffix *.dat,$(TARGETS))
rm -f $(BIN)
rm -f $(CUTARGETS)
rm -f $(addsuffix *.dat,$(CUTARGETS))
rm -f $(CUBIN)
rm -f $(GT_TARGET)
rm -f $(GT_OUT)
rm -f $(addsuffix *.dat,$(GT_OUT))
-rmdir $(RESULTS_DIR)

.PRECIOUS: %.d
-include $(SOURCE:%.cpp=%.d)
-include $(SOURCE:%.cpp=%.d) $(DEV_DEPS) $(GT_DEPS)

Makefile: flit-config.toml $(dir $(FLIT_SCRIPT))/flit_update.py
$(FLIT_SCRIPT) update
Expand All @@ -345,6 +366,7 @@ cleanlibflit:
rm -rf lib

$(DEV_TARGET): lib/libflit.so
$(GT_TARGET): lib/libflit.so
$(BIN): lib/libflit.so
$(CUBIN): lib/libflit.so
endif # ifeq ($(UNAME_S),Darwin): meaning, we are on a mac
Expand All @@ -360,7 +382,12 @@ $(DEV_TARGET): $(DEV_OBJ) Makefile
-o $@ $(DEV_OBJ) $(LD_REQUIRED) $(DEV_LDFLAGS)

%_dev.o: %.cpp Makefile
$(DEV_CC) $(CC_REQUIRED) $(DEV_CFLAGS) $(DEPFLAGS) -c $< -o $@
$(DEV_CC) $(DEV_OPTL) $(DEV_SWITCHES) $(CC_REQUIRED) $(DEV_CFLAGS) $(DEPFLAGS) -c $< -o $@ \
-DFLIT_HOST='"$(HOSTNAME)"' \
-DFLIT_COMPILER='"$(DEV_CC)"' \
-DFLIT_OPTL='"$(DEV_OPTL)"' \
-DFLIT_SWITCHES='"$(DEV_SWITCHES)"' \
-DFLIT_FILENAME='"$(notdir $(DEV_TARGET))"'

ifdef HAS_CUDA
$(DEV_CUTARGET): $(DEV_CUOBJ) Makefile
Expand All @@ -370,10 +397,27 @@ $(DEV_CUTARGET): $(DEV_CUOBJ) Makefile
$(NVCC) -c $(NVCC_CFLAGS) $(DEV_NVCC_CC) $< -o $@
endif # ifdef HAS_CUDA

# Ground truth compilation rules
$(GT_OUT): $(GT_TARGET)
./$(GT_TARGET) --output $(GT_OUT)

$(GT_TARGET): $(GT_OBJ) Makefile
$(GT_CC) $(CC_REQUIRED) -o $@ $(GT_OBJ) $(LD_REQUIRED)

%_gt.o: %.cpp Makefile
$(GT_CC) $(GT_OPTL) $(GT_SWITCHES) $(CC_REQUIRED) $(DEPFLAGS) -c $< -o $@ \
-DFLIT_HOST='"$(HOSTNAME)"' \
-DFLIT_COMPILER='"$(GT_CC)"' \
-DFLIT_OPTL='"$(GT_OPTL)"' \
-DFLIT_SWITCHES='"$(GT_SWITCHES)"' \
-DFLIT_FILENAME='"$(notdir $(GT_TARGET))"'

# Now the true magic begins for the full run compilation rules
# very cool: recyclable target definitions! adapted from
# http://make.mad-scientist.net/the-eval-function/

# TODO: try without PERCENT variable
PERCENT := %

# Generates rules for
# 1. compiling
Expand All @@ -386,34 +430,34 @@ endif # ifdef HAS_CUDA
# @param $2: variable name containing the compiler to use (e.g. GCC)
# @param $3: variable name containing the optimization level (e.g. O2)
define TARGETS_RULE
#run test and collect results
$(strip $2)_$(HOSTNAME)_$(strip $1)_$(strip $3)_out : $2_$(HOSTNAME)_$(strip $1)_$(strip $3)
-./$$< --output $$@
-sed -i -e 's/HOST/$(HOSTNAME)/g' $$@
-sed -i -e 's/SWITCHES/$($(strip $1))/g' $$@
-sed -i -e 's/OPTL/$($(strip $3))/g' $$@
-sed -i -e 's/COMPILER/$($(strip $2))/g' $$@
-sed -i -e 's/FILENAME/$$</g' $$@
@# Remove backup files from older versions of sed
rm -f $$@-e

#link
$(strip $2)_$(HOSTNAME)_$(strip $1)_$(strip $3) : $(SOURCE:%.cpp=%_$(strip $2)_$(HOSTNAME)_$(strip $1)_$(strip $3).o)
-$($(strip $2)) $($(strip $1)) $($(strip $3)) $($(strip $2)_REQUIRED)\
$(CC_REQUIRED) $$^ -o $$@ $(LD_REQUIRED)
rm -f $(SOURCE:.cpp=_$(strip $2)_$(HOSTNAME)_$(strip $1)_$(strip $3).o)

#compile
%_$(strip $2)_$(HOSTNAME)_$(strip $1)_$(strip $3).o : %.cpp
-$($(strip $2)) -c $($(strip $1)) $($(strip $3)) $(CC_REQUIRED) \
$($(strip $2)_REQUIRED) $$< -o $$@
# run test and collect results
$$(RESULTS_DIR)/$(strip $2)_$$(HOSTNAME)_$(strip $1)_$(strip $3)_out.csv: $$(RESULTS_DIR)/$(strip $2)_$$(HOSTNAME)_$(strip $1)_$(strip $3) $$(GT_OUT)
-./$$< --output $$@ --ground-truth $$(GT_OUT)

# link
$$(RESULTS_DIR)/$(strip $2)_$$(HOSTNAME)_$(strip $1)_$(strip $3) : $$(SOURCE:$(PERCENT).cpp=$(PERCENT)_$(strip $2)_$$(HOSTNAME)_$(strip $1)_$(strip $3).o)
mkdir -p $$(RESULTS_DIR)
-$$($(strip $2)) $$($(strip $1)) $$($(strip $3)) $$($(strip $2)_REQUIRED) \
$$(CC_REQUIRED) $$^ -o $$@ $$(LD_REQUIRED)
rm -f $$(SOURCE:.cpp=_$(strip $2)_$$(HOSTNAME)_$(strip $1)_$(strip $3).o)

# TODO: set FLIT_COMPILER to the compiler name, not the executable used
# compile
%_$(strip $2)_$$(HOSTNAME)_$(strip $1)_$(strip $3).o : %.cpp
-$$($(strip $2)) -c $$($(strip $1)) $$($(strip $3)) $$(CC_REQUIRED) \
$$($(strip $2)_REQUIRED) $$< -o $$@ \
-DFLIT_HOST='"$$(HOSTNAME)"' \
-DFLIT_COMPILER='"$$($(strip $2))"' \
-DFLIT_OPTL='"$$($(strip $3))"' \
-DFLIT_SWITCHES='"$$($(strip $1))"' \
-DFLIT_FILENAME='"$(strip $2)_$$(HOSTNAME)_$(strip $1)_$(strip $3)"'
endef
# end of define TARGETS_RULE

# Define individual rules for all elements of $(TARGETS)
$(foreach c, $(COMPILERS), \
$(foreach s, $(SWITCHES_$(strip $c)), \
$(foreach o, $(OPCODES), \
$(foreach c, $(COMPILERS), \
$(foreach s, $(SWITCHES_$(strip $c)), \
$(foreach o, $(OPCODES), \
$(eval $(call TARGETS_RULE, $s, $c, $o)))))


Expand All @@ -427,40 +471,26 @@ $(foreach c, $(COMPILERS), \
# (e.g. UNSOPTS for --funsafe-math-optimizations)
define CUTARGETS_RULE
#run test
NVCC_$(HOSTNAME)_$(strip $1)_out : NVCC_$(HOSTNAME)_$(strip $1)
./$$< --output $$@
-sed -i -e 's/HOST/$(HOSTNAME)/g' $$@
-sed -i -e 's/SWITCHES/$($(strip $1))/g' $$@
-sed -i -e 's/OPTL//g' $$@
-sed -i -e 's/COMPILER/NVCC/g' $$@
-sed -i -e 's/FILENAME/$$</g' $$@
@# Remove backup files from older versions of sed
rm -f $$@-e
NVCC_$$(HOSTNAME)_$(strip $1)_out.csv : NVCC_$$(HOSTNAME)_$(strip $1) $$(GT_OUT)
./$$< --output $$@ --ground-truth $$(GT_OUT)

#link test
NVCC_$(HOSTNAME)_$(strip $1) : $(CUSOURCE:%.cpp=%_NVCC_$(HOSTNAME)_$(strip $1).o)
$(NVCC) $($(strip $1)) $(NVCC_LINK) $$^ -o $$@
rm -f $(CUSOURCE:%.cpp=%_NVCC_$(HOSTNAME)_$(strip $1).o)
NVCC_$$(HOSTNAME)_$(strip $1) : $$(CUSOURCE:$(PERCENT).cpp=$(PERCENT)_NVCC_$$(HOSTNAME)_$(strip $1).o)
$$(NVCC) $$($(strip $1)) $$(NVCC_LINK) $$^ -o $$@
rm -f $$(CUSOURCE:$(PERCENT).cpp=$(PERCENT)_NVCC_$$(HOSTNAME)_$(strip $1).o)

#compile test
%_NVCC_$(HOSTNAME)_$(strip $1).o : %.cpp
-$(NVCC) -c $($(strip $1)) $(NVCC_CFLAGS) $$< -o $$@
%_NVCC_$$(HOSTNAME)_$(strip $1).o : %.cpp
-$$(NVCC) -c $$($(strip $1)) $$(NVCC_CFLAGS) $$< -o $$@ \
-DFLIT_HOST='"$$(HOSTNAME)"' \
-DFLIT_COMPILER='"$$(NVCC)"' \
-DFLIT_OPTL='"$$($(strip $3))"' \
-DFLIT_SWITCHES='"$$($(strip $1))"' \
-DFLIT_FILENAME='"$$(strip $2)_$$(HOSTNAME)_$(strip $1)_$(strip $3)"'
endef
# end of def CUTARGETS_RULE

# define individual rules for all elements of $(CUTARGETS)
$(foreach s, $(CUSWITCHES), $(eval $(call CUTARGETS_RULE, $s)))

# strip excess info from Intel output (__file__) and remove emtpy outputs
.PHONY : cleanResults
cleanResults : $(TARGETS) $(CUTARGETS)
sed -i -e 's/FPTests:://' *_$(HOSTNAME)_*_out
@# Remove backup files from older versions of sed
rm -f *_$(HOSTNAME)_*_out-e

.PHONY : archive
archive : cleanResults
mkdir -p $(RESULTS_DIR)
mv *$(HOSTNAME)* $(RESULTS_DIR)

-include custom.mk
2 changes: 2 additions & 0 deletions scripts/flitcli/data/custom.mk → data/custom.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ CC_REQUIRED +=
LD_REQUIRED +=

# compiler and linker flags respectively - specifically for a dev build
# - DEV_CFLAGS: non-recorded compiler flags (such as includes)
# - DEV_LDFLAGS: linker flags (also not under test)
DEV_CFLAGS +=
DEV_LDFLAGS +=

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 899b9ef

Please sign in to comment.