Commit | Line | Data |
---|---|---|
c38914e1 MJ |
1 | # SPDX-FileCopyrightText: 2024 EfficiOS, Inc. |
2 | # | |
3 | # SPDX-License-Identifier: MIT | |
4 | ||
74c0b9b3 OD |
5 | # Configure this. |
6 | ROCM_VERSION?=6.1.0-1388 | |
7 | ROCM?=/opt/rocm-$(ROCM_VERSION) | |
8 | VENDOR?=AMD | |
9 | CXX?=g++ | |
10 | builddir?=$(CURDIR)/build | |
11 | ||
12 | # Do not touch below. | |
c75d6f3f OD |
13 | |
14 | # HIP C compiler. | |
74c0b9b3 | 15 | HIPCC=$(ROCM)/bin/hipcc |
c75d6f3f OD |
16 | |
17 | # This is used in some of the HIP headers. | |
74c0b9b3 OD |
18 | PLATFORM=__HIP_PLATFORM_$(VENDOR)__ |
19 | ||
c75d6f3f | 20 | # LTTng-UST flags. |
74c0b9b3 OD |
21 | LTTNG_UST_CFLAGS=$(shell pkg-config --cflags lttng-ust) |
22 | LTTNG_UST_LIBS=$(shell pkg-config --libs lttng-ust) | |
23 | ||
c75d6f3f | 24 | # Rocprofiler-sdk flags. There is not rocprofiler-sdk.pc for pkg-config. |
74c0b9b3 OD |
25 | ROCPROFILER_SDK_CFLAGS=-I $(ROCM)/include -L $(ROCM)/lib -Wl,-rpath=$(ROCM)/lib |
26 | ROCPROFILER_SDK_LIBS=-lrocprofiler-sdk | |
27 | ||
28 | # Concat dependencies. | |
29 | DEPS_CFLAGS=$(LTTNG_UST_CFLAGS) $(ROCPROFILER_SDK_CFLAGS) | |
30 | DEPS_LIBS=$(LTTNG_UST_LIBS) $(ROCPROFILER_SDK_LIBS) | |
31 | ||
74c0b9b3 OD |
32 | # HIP stuff. |
33 | AUTOGEN_HIP_API=$(builddir)/lttng-ust-hip-defs.h \ | |
34 | $(builddir)/lttng-ust-hip.h \ | |
35 | $(builddir)/lttng-ust-hip-classes.h \ | |
36 | $(builddir)/lttng-ust-hip-impl.c \ | |
37 | $(builddir)/lttng-ust-hip-states.h | |
38 | ||
39 | HIP_HEADER=$(ROCM)/include/hip/hip_runtime.h | |
40 | ||
41 | # HSA stuff. | |
42 | AUTOGEN_HSA_API=$(builddir)/lttng-ust-hsa-defs.h \ | |
43 | $(builddir)/lttng-ust-hsa.h \ | |
44 | $(builddir)/lttng-ust-hsa-classes.h \ | |
45 | $(builddir)/lttng-ust-hsa-impl.c \ | |
46 | $(builddir)/lttng-ust-hsa-states.h | |
47 | ||
48 | HSA_HEADER=$(ROCM)/include/hsa/hsa.h | |
49 | ||
50 | # Final target. | |
51 | TARGET=$(builddir)/libexatracer.so | |
52 | ||
53 | # Toolchain flags. | |
54 | CFLAGS=-I $(builddir) -D $(PLATFORM) -O2 -g -fmax-errors=1 -fvisibility=hidden -Wextra -Wno-deprecated-declarations | |
55 | LDFLAGS=-shared -fPIC | |
56 | ||
57 | all: $(builddir) $(TARGET) | |
58 | ||
59 | $(builddir): | |
60 | mkdir -p $@ | |
61 | ||
62 | # Do not add *-wrappers.cpp to toolchain inputs. | |
63 | $(TARGET): src/lttng-ust-exatracer.cpp src/lttng-ust-roctx-impl.c $(builddir)/lttng-ust-hsa-impl.c $(builddir)/lttng-ust-hip-impl.c | |
64 | $(CXX) -I src $(CFLAGS) $(DEPS_CFLAGS) $(LDFLAGS) -o $@ $^ $(DEPS_LIBS) | |
65 | ||
66 | src/lttng-ust-exatracer.cpp: $(builddir)/lttng-ust-hsa-wrappers.cpp $(builddir)/lttng-ust-hip-wrappers.cpp | |
67 | ||
68 | # HIP rules. | |
69 | $(builddir)/lttng-ust-hip-wrappers.cpp: $(AUTOGEN_HIP_API) scripts/gen-hip-wrappers | |
70 | scripts/gen-hip-wrappers -D $(PLATFORM) -I $(ROCM)/include --ignore=src/hip-ignores.txt $(HIP_HEADER) $@ | |
71 | sed -i -f scripts/lttng-ust-hip-post-processing.sed $@ | |
72 | ||
73 | $(AUTOGEN_HIP_API) &: $(HIP_HEADER) scripts/lttng-ust-auto-api | |
74 | scripts/lttng-ust-auto-api --ignores=src/hip-ignores.txt -D $(PLATFORM) -I $(ROCM)/include --namespace=lttng_hip --provider=hip --common-prefix=hip --classes-guard=LTTNG_HIP_TRACEPOINT_CLASSES_HPP --tp-guard=LTTNG_HIP_TRACEPOINT_DEF_H $< $(AUTOGEN_HIP_API) | |
75 | sed -i -f scripts/lttng-ust-hip-post-processing.sed $(AUTOGEN_HIP_API) | |
76 | ||
77 | # HSA rules. | |
78 | $(builddir)/lttng-ust-hsa-wrappers.cpp: $(AUTOGEN_HSA_API) scripts/gen-hsa-wrappers | |
79 | scripts/gen-hsa-wrappers -D $(PLATFORM) -I $(ROCM)/include --ignore=src/hsa-ignores.txt $(HSA_HEADER) $@ | |
80 | sed -i -f scripts/lttng-ust-hsa-post-processing.sed $@ | |
81 | ||
82 | $(AUTOGEN_HSA_API) &: $(HSA_HEADER) scripts/lttng-ust-auto-api | |
83 | scripts/lttng-ust-auto-api --ignores=src/hsa-ignores.txt -D $(PLATFORM) -I $(ROCM)/include --namespace=lttng_hsa --provider=hsa --common-prefix=hsa --classes-guard=LTTNG_HSA_TRACEPOINT_CLASSES_HPP --tp-guard=LTTNG_HSA_TRACEPOINT_DEF_H $< $(AUTOGEN_HSA_API) | |
84 | sed -i -f scripts/lttng-ust-hsa-post-processing.sed $(AUTOGEN_HSA_API) | |
85 | ||
86 | # Testing. | |
87 | $(builddir)/hello: tests/hello.cpp | |
88 | $(HIPCC) -lrocprofiler-sdk-roctx -Wno-unused -o $@ $^ | |
89 | ||
90 | check: $(builddir)/hello | |
91 | scripts/check $(TARGET) $^ | |
92 | ||
93 | clean: | |
c75d6f3f | 94 | rm -rf $(builddir) |
74c0b9b3 OD |
95 | rm -rf ./traces |
96 | ||
97 | dist: | |
98 | git archive --prefix extracer/ --format=tar.gz --output exatracer.tar.gz HEAD | |
99 | ||
100 | .PHONY: all clean dist |