1 # SPDX-FileCopyrightText: 2024 EfficiOS, Inc.
3 # SPDX-License-Identifier: MIT
6 ROCM_VERSION?
=6.1.0-1388
7 ROCM?
=/opt
/rocm-
$(ROCM_VERSION
)
10 builddir?
=$(CURDIR
)/build
15 HIPCC
=$(ROCM
)/bin
/hipcc
17 # This is used in some of the HIP headers.
18 PLATFORM
=__HIP_PLATFORM_
$(VENDOR
)__
21 LTTNG_UST_CFLAGS
=$(shell pkg-config
--cflags lttng-ust
)
22 LTTNG_UST_LIBS
=$(shell pkg-config
--libs lttng-ust
)
24 # Rocprofiler-sdk flags. There is not rocprofiler-sdk.pc for pkg-config.
25 ROCPROFILER_SDK_CFLAGS
=-I
$(ROCM
)/include -L
$(ROCM
)/lib
-Wl
,-rpath
=$(ROCM
)/lib
26 ROCPROFILER_SDK_LIBS
=-lrocprofiler-sdk
28 # Concat dependencies.
29 DEPS_CFLAGS
=$(LTTNG_UST_CFLAGS
) $(ROCPROFILER_SDK_CFLAGS
)
30 DEPS_LIBS
=$(LTTNG_UST_LIBS
) $(ROCPROFILER_SDK_LIBS
)
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
39 HIP_HEADER
=$(ROCM
)/include/hip
/hip_runtime.h
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
48 HSA_HEADER
=$(ROCM
)/include/hsa
/hsa.h
51 TARGET
=$(builddir
)/libexatracer.so
54 CFLAGS
=-I
$(builddir
) -D
$(PLATFORM
) -O2
-g
-fmax-errors
=1 -fvisibility
=hidden
-Wextra
-Wno-deprecated-declarations
57 all: $(builddir
) $(TARGET
)
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
)
66 src
/lttng-ust-exatracer.
cpp: $(builddir
)/lttng-ust-hsa-wrappers.
cpp $(builddir
)/lttng-ust-hip-wrappers.
cpp
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
$@
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
)
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
$@
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
)
87 $(builddir
)/hello
: tests
/hello.
cpp
88 $(HIPCC
) -lrocprofiler-sdk-roctx
-Wno-unused
-o
$@
$^
90 check: $(builddir
)/hello
91 scripts
/check $(TARGET
) $^
98 git archive
--prefix extracer
/ --format
=tar.gz
--output exatracer.
tar.gz HEAD
100 .PHONY
: all clean dist