"Python/train.py" did not exist on "7e0b0e35e16dc777270a3d5597d553d2d1921cbb"
rules.mk 8.88 KB
Newer Older
Antoine Kaufmann's avatar
Antoine Kaufmann committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Copyright 2021 Max Planck Institute for Software Systems, and
# National University of Singapore
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

23
24
include mk/subdir_pre.mk

25
PACKER_VERSION := 1.7.0
Hejing Li's avatar
Hejing Li committed
26
KERNEL_VERSION := 5.17.7
27
28

BASE_IMAGE := $(d)output-base/base
29
MEMCACHED_IMAGE := $(d)output-memcached/memcached
30
31
32
NOPAXOS_IMAGE := $(d)output-nopaxos/nopaxos
MTCP_IMAGE := $(d)output-mtcp/mtcp
TAS_IMAGE := $(d)output-tas/tas
Hejing Li's avatar
Hejing Li committed
33
HOMA_IMAGE := $(d)output-homa/homa
Antoine Kaufmann's avatar
Antoine Kaufmann committed
34
TIMESYNC_IMAGE := $(d)output-timesync/timesync
Hejing Li's avatar
Hejing Li committed
35
HOMA_IMAGE := $(d)output-homa/homa
36
COMPRESSED_IMAGES ?= false
37

Hejing Li's avatar
Hejing Li committed
38
39
IMAGES := $(BASE_IMAGE) $(NOPAXOS_IMAGE) $(MEMCACHED_IMAGE) $(TIMESYNC_IMAGE) \
  $(HOMA_IMAGE)
40
41
RAW_IMAGES := $(addsuffix .raw,$(IMAGES))

42
IMAGES_MIN := $(BASE_IMAGE)
43
44
RAW_IMAGES_MIN := $(addsuffix .raw,$(IMAGES_MIN))

45
46
47
48
49
50
51
img_dir := $(d)
packer := $(d)packer

bz_image := $(d)bzImage
vmlinux := $(d)vmlinux
kernel_pardir := $(d)kernel
kernel_dir := $(kernel_pardir)/linux-$(KERNEL_VERSION)
52
kernel_config := $(kernel_pardir)/config-$(KERNEL_VERSION)
53
kheader_dir := $(d)kernel/kheaders
54
kheader_tar := $(d)kheaders.tar.bz2
55
56
mqnic_dir := $(d)mqnic
mqnic_mod := $(mqnic_dir)/mqnic.ko
57
58
farmem_dir := $(d)farmem
farmem_mod := $(farmem_dir)/farmem.ko
59
60
m5_bin := $(d)m5
guest_init := $(d)/scripts/guestinit.sh
Hejing Li's avatar
Hejing Li committed
61
62
homa_dir := $(d)homa
homa_mod := $(homa_dir)/homa.ko
63

64
65
build-images: $(IMAGES) $(RAW_IMAGES) $(vmlinux) $(bz_image) $(mqnic_mod) \
  $(farmem_mod)
66

67
build-images-min: $(IMAGES_MIN) $(RAW_IMAGES_MIN) $(vmlinux) $(bz_image) \
68
    $(mqnic_mod) $(farmem_mod)
69

70
71
72
73
74
75
# only converts existing images to raw
convert-images-raw:
	for i in $(IMAGES); do \
	    [ -f $$i ] || continue; \
	    $(QEMU_IMG) convert -f qcow2 -O raw $$i $${i}.raw ; done

76
77
78
79
80
81
################################################
# Disk image

%.raw: %
	$(QEMU_IMG) convert -f qcow2 -O raw $< $@

82
83
$(BASE_IMAGE): $(packer) $(QEMU) $(bz_image) $(m5_bin) $(kheader_tar) \
    $(guest_init) $(kernel_config) \
84
85
    $(addprefix $(d), extended-image.pkr.hcl scripts/install-base.sh \
      scripts/cleanup.sh)
86
	rm -rf $(dir $@)
87
88
89
	mkdir -p $(img_dir)/input-base
	cp $(m5_bin) $(kheader_tar) $(guest_init) $(bz_image) $(kernel_config) \
	    $(img_dir)/input-base/
90
	cd $(img_dir) && ./packer-wrap.sh base base base.pkr.hcl \
91
	    $(COMPRESSED_IMAGES)
92
	rm -rf $(img_dir)/input-base
93
94
	touch $@

95
96
97
98
$(MEMCACHED_IMAGE): $(packer) $(QEMU) $(BASE_IMAGE) \
    $(addprefix $(d), extended-image.pkr.hcl scripts/install-memcached.sh \
      scripts/cleanup.sh)
	rm -rf $(dir $@)
99
	cd $(img_dir) && ./packer-wrap.sh base memcached \
100
	    extended-image.pkr.hcl $(COMPRESSED_IMAGES)
101
	rm -rf $(img_dir)/input-base
102
103
	touch $@

104
105
106
$(NOPAXOS_IMAGE): $(packer) $(QEMU) $(BASE_IMAGE) \
    $(addprefix $(d), extended-image.pkr.hcl scripts/install-nopaxos.sh \
      scripts/cleanup.sh nopaxos.config)
107
	rm -rf $(dir $@)
108
109
	mkdir -p $(img_dir)/input-nopaxos
	cp $(img_dir)/nopaxos.config $(img_dir)/input-nopaxos/
110
	cd $(img_dir) && ./packer-wrap.sh base nopaxos extended-image.pkr.hcl \
111
	    $(COMPRESSED_IMAGES)
112
113
	touch $@

114
115
116
$(MTCP_IMAGE): $(packer) $(QEMU) $(BASE_IMAGE) \
    $(addprefix $(d), extended-image.pkr.hcl scripts/install-mtcp.sh \
      scripts/cleanup.sh)
117
	rm -rf $(dir $@)
118
	cd $(img_dir) && ./packer-wrap.sh base mtcp extended-image.pkr.hcl \
119
	    $(COMPRESSED_IMAGES)
120
121
	touch $@

122
123
124
$(TAS_IMAGE): $(packer) $(QEMU) $(BASE_IMAGE) \
    $(addprefix $(d), extended-image.pkr.hcl scripts/install-tas.sh \
      scripts/cleanup.sh)
125
	rm -rf $(dir $@)
126
	cd $(img_dir) && ./packer-wrap.sh base tas extended-image.pkr.hcl \
127
	    $(COMPRESSED_IMAGES)
128
129
	touch $@

Hejing Li's avatar
Hejing Li committed
130
131
132
133
134
135
136
137
138
139
$(HOMA_IMAGE): $(packer) $(QEMU) $(BASE_IMAGE) \
    $(addprefix $(d), extended-image.pkr.hcl scripts/install-homa.sh \
      scripts/cleanup.sh)
	rm -rf $(dir $@)
	mkdir -p $(img_dir)/input-homa
	cp -r $(homa_dir) \
	    $(img_dir)/input-homa
	cd $(img_dir) && ./packer-wrap.sh base homa extended-image.pkr.hcl \
	$(COMPRESSED_IMAGES)
	rm -rf $(img_dir)/input-homa
Antoine Kaufmann's avatar
Antoine Kaufmann committed
140
141
142
143
144
145
$(TIMESYNC_IMAGE): $(packer) $(QEMU) $(BASE_IMAGE) \
    $(addprefix $(d), extended-image.pkr.hcl scripts/install-timesync.sh \
      scripts/cleanup.sh)
	rm -rf $(dir $@)
	cd $(img_dir) && ./packer-wrap.sh base timesync extended-image.pkr.hcl \
	    $(COMPRESSED_IMAGES)
Hejing Li's avatar
Hejing Li committed
146
147
	touch $@

Hejing Li's avatar
Hejing Li committed
148
149
150
151
152
153
154
155
156
157
158
159
$(HOMA_IMAGE): $(packer) $(QEMU) $(BASE_IMAGE) \
    $(addprefix $(d), extended-image.pkr.hcl scripts/install-homa.sh \
      scripts/cleanup.sh)
	rm -rf $(dir $@)
	mkdir -p $(img_dir)/input-homa
	cp -r $(homa_dir) \
	    $(img_dir)/input-homa
	cd $(img_dir) && ./packer-wrap.sh base homa extended-image.pkr.hcl \
	$(COMPRESSED_IMAGES)
	rm -rf $(img_dir)/input-homa
	touch $@

160
$(packer):
161
162
	wget -O $(img_dir)packer_$(PACKER_VERSION)_linux_amd64.zip \
	    https://releases.hashicorp.com/packer/$(PACKER_VERSION)/packer_$(PACKER_VERSION)_linux_amd64.zip
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
	cd $(img_dir) && unzip packer_$(PACKER_VERSION)_linux_amd64.zip
	rm -f $(img_dir)packer_$(PACKER_VERSION)_linux_amd64.zip


################################################
# Kernel

$(kernel_dir)/vmlinux: $(kernel_dir)/.config
	$(MAKE) -C $(kernel_dir)
	touch $@

$(vmlinux): $(kernel_dir)/vmlinux
	cp $< $@
	touch $@

# this dependency is a bit stupid, but not sure how to better do this
$(bz_image): $(kernel_dir)/vmlinux
	cp $(kernel_dir)/arch/x86_64/boot/bzImage $@
	touch $@

183
$(kheader_tar): $(kernel_dir)/vmlinux
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
	rm -rf $(kheader_dir)
	mkdir -p $(kheader_dir)
	$(MAKE) -C $(kernel_dir) headers_install INSTALL_HDR_PATH=$(abspath $(kheader_dir)/usr)
	$(MAKE) -C $(kernel_dir) modules_install INSTALL_MOD_PATH=$(abspath $(kheader_dir))
	rm -f $(kheader_dir)/lib/modules/$(KERNEL_VERSION)/build
	ln -s /usr/src/linux-headers-$(KERNEL_VERSION) \
	    $(kheader_dir)/lib/modules/$(KERNEL_VERSION)/build
	rm -f $(kheader_dir)/lib/modules/$(KERNEL_VERSION)/source
	mkdir -p $(kheader_dir)/usr/src/linux-headers-$(KERNEL_VERSION)
	cp -r $(kernel_dir)/.config $(kernel_dir)/Makefile \
	    $(kernel_dir)/Module.symvers $(kernel_dir)/scripts \
	    $(kernel_dir)/include \
	    $(kheader_dir)/usr/src/linux-headers-$(KERNEL_VERSION)/
	mkdir -p $(kheader_dir)/usr/src/linux-headers-$(KERNEL_VERSION)/tools/objtool/
	cp $(kernel_dir)/tools/objtool/objtool \
	    $(kheader_dir)/usr/src/linux-headers-$(KERNEL_VERSION)/tools/objtool/
	mkdir -p $(kheader_dir)/usr/src/linux-headers-$(KERNEL_VERSION)/arch/x86/
	cp -r $(kernel_dir)/arch/x86/Makefile \
	    $(kernel_dir)/arch/x86/Makefile_32.cpu \
	    $(kernel_dir)/arch/x86/Makefile.um \
	    $(kernel_dir)/arch/x86/include \
	    $(kheader_dir)/usr/src/linux-headers-$(KERNEL_VERSION)/arch/x86
	cd $(kheader_dir) && tar cjf $(abspath $@) .

$(kernel_dir)/.config: $(kernel_pardir)/config-$(KERNEL_VERSION)
	rm -rf $(kernel_dir)
	wget -O - https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-$(KERNEL_VERSION).tar.xz | \
	    tar xJf - -C $(kernel_pardir)
	cd $(kernel_dir) && patch -p1 < ../linux-$(KERNEL_VERSION)-timers-gem5.patch
	cp $< $@

################################################
# mqnic kernel module

$(mqnic_mod): $(vmlinux)
	$(MAKE) -C $(kernel_dir) M=$(abspath $(mqnic_dir)) modules
	touch $@

Hejing Li's avatar
Hejing Li committed
222
223
224
225
226
# HOMA kernel module
$(homa_mod): $(vmlinux)
	$(MAKE) -C $(kernel_dir) M=$(abspath $(homa_dir)) modules
	touch $@

Hejing Li's avatar
Hejing Li committed
227
228
229
230
231
232
233
234
235
236
237
238
################################################
# homa kernel module

$(homa_dir):
	git clone https://github.com/PlatformLab/HomaModule \
	    -b linux_$(KERNEL_VERSION) $@

# HOMA kernel module
$(homa_mod): $(vmlinux) $(homa_dir)
	$(MAKE) -C $(kernel_dir) M=$(abspath $(homa_dir)) modules
	touch $@

239
240
################################################
# farmem kernel module
241

242
243
244
$(farmem_mod): $(vmlinux)
	$(MAKE) -C $(kernel_dir) M=$(abspath $(farmem_dir)) modules
	touch $@
245

246
247
248
249
CLEAN := $(addprefix $(d), mqnic/mqnic.ko mqnic/*.o mqnic/.*.cmd mqnic/*.mod \
    mqnic/mqnic.mod.c mqnic/Module.symvers mqnic/modules.order \
    farmem/farmem.ko farmem/*.o farmem/.*.cmd farmem/*.mod \
    farmem/farmem.mod.c farmem/Module.symvers farmem/modules.order)
250
DISTCLEAN := $(kernel_dir) $(packer) $(bz_image) $(vmlinux) $(kheader_dir) \
251
    $(foreach i,$(IMAGES),$(dir $(i)) $(subst output-,input-,$(dir $(i)))) \
252
253
254
    $(d)packer_cache $(d)kheaders.tar.bz2

include mk/subdir_post.mk