-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmakefile
More file actions
82 lines (64 loc) · 2.64 KB
/
Copy pathmakefile
File metadata and controls
82 lines (64 loc) · 2.64 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
# =========================== Paths & tools ===========================
CMPUT429DIR ?= /cshome/cmput429
HIP_PATH ?= $(CMPUT429DIR)/TheRock/build
HIPCC ?= $(HIP_PATH)/bin/hipcc
A5GEM_PATH ?= $(CMPUT429DIR)/429-resources/gem5
GEM5GPU ?= $(A5GEM_PATH)/build/VEGA_X86/gem5.fast
# =========================== Sim config ==============================
PYTHON_CONFIG = $(A5GEM_PATH)/configs/example/gpufs/mi200.py
#DISK_IMAGE = $(CMPUT429DIR)/gem5-resources/src/x86-ubuntu-gpu-ml/disk-image/x86-ubuntu-gpu-ml
#KERNEL = $(CMPUT429DIR)/gem5-resources/src/x86-ubuntu-gpu-ml/vmlinux-gpu-ml
DISK_IMAGE = $(CMPUT429DIR)/x86-ubuntu-gpu.gz
KERNEL = $(CMPUT429DIR)/linux-vm-kernel-gpu.gz
#KERNEL = $(CMPUT429DIR)/429-resources/benchmarks/429bin/gpufs-kernel
COMMON_OPTS = --disk-image $(DISK_IMAGE) --kernel $(KERNEL)
# =========================== Dirs & discovery ========================
SRC_DIRS ?= thread-divergence memory-coalesing
BIN_DIR ?= bin
SIMS_DIR ?= sims
SRCS := $(foreach d,$(SRC_DIRS),$(wildcard $(d)/*.hip))
APPS := $(basename $(notdir $(SRCS)))
BINS := $(addprefix $(BIN_DIR)/,$(APPS))
SIMS_DONE := $(addprefix $(SIMS_DIR)/,$(addsuffix /.done,$(APPS)))
VPATH := $(SRC_DIRS)
# =========================== Architecture ===========================
OFFLOAD_ARCHS ?= gfx942 gfx90a
OFFLOAD_FLAGS := $(foreach a,$(OFFLOAD_ARCHS),--offload-arch=$(a))
# =========================== Build flags =============================
CXXFLAGS := -x hip \
-I$(A5GEM_PATH)/include \
-I$(A5GEM_PATH)/util/m5/src \
-I$(A5GEM_PATH) \
$(OFFLOAD_FLAGS) \
-fno-unroll-loops \
-DGPUFS \
-O1
# Avoid PIE when linking with non-PIC libm5.a
LDFLAGS := -L$(A5GEM_PATH)/util/m5/build/x86/out -lm5 -Wl,-no-pie
# =========================== Phony ==============================
.PHONY: all build run clean clean_bins clean_sims run-%
# Default: build & simulate everything
all: $(SIMS_DONE)
# Build only
build: $(BINS)
# Simulate everything (alias)
run: $(SIMS_DONE)
# =========================== Compile =============================
$(BIN_DIR)/%: %.hip | $(BIN_DIR)
$(HIPCC) $(CXXFLAGS) $< -o $@ $(LDFLAGS)
$(BIN_DIR):
mkdir -p $@
# =========================== Simulate ============================
# sims/<app>/.done depends on bin/<app>
$(SIMS_DIR)/%/.done: $(BIN_DIR)/%
mkdir -p $(@D)
$(GEM5GPU) -d $(@D) $(PYTHON_CONFIG) $(COMMON_OPTS) --app $<
@touch $@
# Run a single app: make run-<app>
run-%: $(SIMS_DIR)/%/.done
# =========================== Clean ===============================
clean: clean_bins clean_sims
clean_bins:
rm -rf $(BIN_DIR)
clean_sims:
rm -rf $(SIMS_DIR)