-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
105 lines (79 loc) · 2.4 KB
/
Makefile
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
99
100
101
102
103
104
105
# get platform name. Should be darwin (macOs) or linux (Linux)
PLATFORM=$(shell uname -s | awk '{print tolower($$0)}')
OPTFLAGS=-O3
DEBUG_FLAGS=
PYTHON=python
BUILD_DIR=build
LIBS_DIR=libs
SRC_DIR=src
PYTHON_SRC_DIR=python-src
ENTRYPOINT=native
INCLUDE_FLAGS=-Ipascal/include
LDFLAGS=-Llibs -lpascal
ifeq ($(PLATFORM), darwin)
CC=clang
INCLUDE_FLAGS+=-I/opt/homebrew/include/
LDFLAGS+=-L/opt/homebrew/lib -lgsl -lgslcblas
else ifeq ($(PLATFORM), linux)
CC=gcc
PYTHON=python3
LDFLAGS+=-lgsl -lm
else
$(error ERROR: PLATFORM $(PLATFORM) not supported. Should be `darwin` or `linux`)
endif
.PHONY: \
run \
run-bm \
clean
default: run
$(LIBS_DIR)/libpascal.a:
mkdir -p $(LIBS_DIR)
cd pascal; make CC=$(CC)
cp pascal/$(LIBS_DIR)/libpascal.a $(LIBS_DIR)/
$(BUILD_DIR)/$(ENTRYPOINT): Makefile $(LIBS_DIR)/libpascal.a $(SRC_DIR)/$(ENTRYPOINT).c
mkdir -p $(BUILD_DIR)
$(CC) $(OPTFLAGS) -o $(BUILD_DIR)/$(ENTRYPOINT) $(SRC_DIR)/$(ENTRYPOINT).c $(INCLUDE_FLAGS) $(LDFLAGS)
N_SAMPLES_SINGLE_RUN=10
run: Makefile $(BUILD_DIR)/$(ENTRYPOINT)
./$(BUILD_DIR)/$(ENTRYPOINT) $(N_SAMPLES_SINGLE_RUN)
SLEEP_FOR=0
N=1
N_SAMPLES := 4 16 32
ROOT_DIR=./
DATA_DIR=$(ROOT_DIR)/data
EXPERIMENT_RESULTS_DIR=experiment-results
EXPERIMENT_RESULTS_LOCATION=$(ROOT_DIR)/$(EXPERIMENT_RESULTS_DIR)/results.log
PROBLEM_NAME=gp
ifeq ($(PLATFORM), darwin)
run-bm: Makefile $(BUILD_DIR)/$(ENTRYPOINT)
mkdir -p $(DATA_DIR)
mkdir -p $(ROOT_DIR)/$(EXPERIMENT_RESULTS_DIR)
@for iterations in $(N_SAMPLES) ; do \
number=1 ; while [[ $$number -le $(N) ]] ; do \
./$(BUILD_DIR)/$(ENTRYPOINT) $$iterations; \
$(PYTHON) $(PYTHON_SRC_DIR)/main.py $(PROBLEM_NAME) $$iterations $$number $(DATA_DIR) $(EXPERIMENT_RESULTS_LOCATION); \
((number = number + 1)) ; \
sleep $(SLEEP_FOR); \
done \
done
rm data.out
else ifeq ($(PLATFORM), linux)
run-bm: Makefile $(BUILD_DIR)/$(ENTRYPOINT)
mkdir -p $(DATA_DIR)
mkdir -p $(ROOT_DIR)/$(EXPERIMENT_RESULTS_DIR)
@for iterations in $(N_SAMPLES) ; do \
number=1 ; while [ $$number -le $(N) ] ; do \
./$(BUILD_DIR)/$(ENTRYPOINT) $$iterations; \
$(PYTHON) $(PYTHON_SRC_DIR)/main.py $(PROBLEM_NAME) $$iterations $$number $(DATA_DIR) $(EXPERIMENT_RESULTS_LOCATION); \
number=`expr $$number + 1`; \
sleep $(SLEEP_FOR); \
done \
done
rm data.out
else
$(error ERROR: PLATFORM $(PLATFORM) not supported. Should be `darwin` or `linux`)
endif
clean:
rm -rf $(BUILD_DIR)
rm -rf $(LIBS_DIR)
cd pascal; make clean