-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile.run
More file actions
100 lines (82 loc) · 3.12 KB
/
Makefile.run
File metadata and controls
100 lines (82 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
TIMESTAMP ?= $(shell date +%Y%m%d_%H%M%S)
RUN_SH ?= $(abspath run-$(TYPE).sh)
FULL_WORK_DIR = $(shell dirname $(RUN_SH))
WORKLOAD_NAME = $(shell basename $(FULL_WORK_DIR))
SIZE := $(patsubst run-%.sh,%,$(shell basename $(RUN_SH)))
SOURCE_ALL_INPUT := $(CURDIR)/data/all/input
SOURCE_SIZE_INPUT := $(CURDIR)/data/$(SIZE)/input
SOURCE_EXTRA_INPUT := $(CURDIR)/extra-data
RUN_DIR := $(CURDIR)/run$(RUN_TAG)
TIME_LOG := $(RUN_DIR)/run-$(SIZE).sh.timelog
HOST_ARCH := $(shell uname -m)
ARCH ?= $(HOST_ARCH)
ifeq ($(ARCH),$(HOST_ARCH))
LOADER ?=
else
LOADER ?= qemu-$(ARCH)
endif
DIFF = diff
SPECDIFF_FILE = $(SPEC)/bin/specdiff
SPECDIFF = cd $(dir $(SPECDIFF_FILE)) && ./specdiff -m -l 10 $(1) $(abspath $(2)) $(abspath $(3))
.PHONY: copy_run_data
copy_run_data:
-@rm -rf $(RUN_DIR)
@mkdir -p $(RUN_DIR)
@if [ -d $(SOURCE_ALL_INPUT) ]; then \
cp -r $(SOURCE_ALL_INPUT)/* $(RUN_DIR)/ ; \
fi
@if [ -d $(SOURCE_SIZE_INPUT) ]; then \
cp -r $(SOURCE_SIZE_INPUT)/* $(RUN_DIR)/ ; \
fi
@if [ -d $(SOURCE_EXTRA_INPUT) ]; then \
echo "Prepare extra data..." >> $(TIME_LOG); \
sh $(SOURCE_EXTRA_INPUT)/$(SIZE).sh $(RUN_DIR); \
fi
.PHONY: prepare_data
prepare_data: copy_run_data
@date >> $(TIME_LOG)
@echo "Using command: ${LOADER} to execute" >> $(TIME_LOG)
@echo "@@@@@ Running $(WORKLOAD_NAME) [$(SIZE)]..." >> $(TIME_LOG)
.PHONY: run
run: prepare_data
cd $(RUN_DIR) && \
export TIME="%U user %S system %E elapsed %P CPU (%X text + %D data %M max)k\n%I inputs + %O outputs (%F major + %R minor)pagefaults %W swaps\n%e # elapsed in second" && \
APP='/usr/bin/time -a -o $(TIME_LOG) $(LOADER) $(CURDIR)/build$(TAG)/$(WORKLOAD_NAME)' \
$(PROFILER) sh $(RUN_SH) && \
cd $(CURDIR)
.PHONY: run_result_backup
run_result_backup:
@if [ -d $(RUN_DIR) ]; then \
cp -r $(RUN_DIR) $(RUN_DIR)_$(TYPE)_$(TIMESTAMP)_backup; \
fi
@echo "Already backup into $(RUN_DIR)_$(TYPE)_$(TIMESTAMP)_backup"
# this function executes the command provided as an argument within a for loop, and the loop variable is f, the command is formed using the variable f.
define check_single_result_in_for
total=$$((total + 1)); \
if $(1) > /dev/null 2>&1; then \
success=$$((success + 1)); \
else \
echo "$(NAME) $(TYPE) $$f [ FAIL ]"; \
failed=$$((failed + 1)); \
fi;
endef
# this function executes a single command that is not controlled by a for loop, the parameters passed to it include the command to be executed and the name of the workload parameter. the workload parameter name is used to determine which command is executed
define check_single_result
total=$$((total + 1)); \
if $(1) > /dev/null 2>&1; then \
success=$$((success + 1)); \
else \
echo "$(NAME) $(TYPE) $(2) [ FAIL ]"; \
failed=$$((failed + 1)); \
fi;
endef
# this function is used to count the total number of executed commands, as well as the number of successful and failed commands, after all commands have been executed.
define check_all_result
if [ $${failed} -eq 0 ]; then \
echo "SUCCESS: All $${success}/$${total} $(NAME) $(TYPE) testcase SUCCESS/ALL"; \
exit 0; \
else \
echo "ERROR: $${success}/$${total} $(NAME) $(TYPE) testcase SUCCESS/ALL"; \
exit 1; \
fi;
endef