# SPDX-FileCopyrightText: 2024 EfficiOS, Inc. # # SPDX-License-Identifier: MIT # Configure this. ROCM_VERSION?=6.1.0-1388 ROCM?=/opt/rocm-$(ROCM_VERSION) VENDOR?=AMD CXX?=g++ builddir?=$(CURDIR)/build # Do not touch below. # HIP C compiler. HIPCC=$(ROCM)/bin/hipcc # This is used in some of the HIP headers. PLATFORM=__HIP_PLATFORM_$(VENDOR)__ # LTTng-UST flags. LTTNG_UST_CFLAGS=$(shell pkg-config --cflags lttng-ust) LTTNG_UST_LIBS=$(shell pkg-config --libs lttng-ust) # Rocprofiler-sdk flags. There is not rocprofiler-sdk.pc for pkg-config. ROCPROFILER_SDK_CFLAGS=-I $(ROCM)/include -L $(ROCM)/lib -Wl,-rpath=$(ROCM)/lib ROCPROFILER_SDK_LIBS=-lrocprofiler-sdk # Concat dependencies. DEPS_CFLAGS=$(LTTNG_UST_CFLAGS) $(ROCPROFILER_SDK_CFLAGS) DEPS_LIBS=$(LTTNG_UST_LIBS) $(ROCPROFILER_SDK_LIBS) # HIP stuff. AUTOGEN_HIP_API=$(builddir)/lttng-ust-hip-defs.h \ $(builddir)/lttng-ust-hip.h \ $(builddir)/lttng-ust-hip-classes.h \ $(builddir)/lttng-ust-hip-impl.c \ $(builddir)/lttng-ust-hip-states.h HIP_HEADER=$(ROCM)/include/hip/hip_runtime.h # HSA stuff. AUTOGEN_HSA_API=$(builddir)/lttng-ust-hsa-defs.h \ $(builddir)/lttng-ust-hsa.h \ $(builddir)/lttng-ust-hsa-classes.h \ $(builddir)/lttng-ust-hsa-impl.c \ $(builddir)/lttng-ust-hsa-states.h HSA_HEADER=$(ROCM)/include/hsa/hsa.h # Final target. TARGET=$(builddir)/libexatracer.so # Toolchain flags. CFLAGS=-I $(builddir) -D $(PLATFORM) -O2 -g -fmax-errors=1 -fvisibility=hidden -Wextra -Wno-deprecated-declarations LDFLAGS=-shared -fPIC all: $(builddir) $(TARGET) $(builddir): mkdir -p $@ # Do not add *-wrappers.cpp to toolchain inputs. $(TARGET): src/lttng-ust-exatracer.cpp src/lttng-ust-roctx-impl.c $(builddir)/lttng-ust-hsa-impl.c $(builddir)/lttng-ust-hip-impl.c $(CXX) -I src $(CFLAGS) $(DEPS_CFLAGS) $(LDFLAGS) -o $@ $^ $(DEPS_LIBS) src/lttng-ust-exatracer.cpp: $(builddir)/lttng-ust-hsa-wrappers.cpp $(builddir)/lttng-ust-hip-wrappers.cpp # HIP rules. $(builddir)/lttng-ust-hip-wrappers.cpp: $(AUTOGEN_HIP_API) scripts/gen-hip-wrappers scripts/gen-hip-wrappers -D $(PLATFORM) -I $(ROCM)/include --ignore=src/hip-ignores.txt $(HIP_HEADER) $@ sed -i -f scripts/lttng-ust-hip-post-processing.sed $@ $(AUTOGEN_HIP_API) &: $(HIP_HEADER) scripts/lttng-ust-auto-api 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) sed -i -f scripts/lttng-ust-hip-post-processing.sed $(AUTOGEN_HIP_API) # HSA rules. $(builddir)/lttng-ust-hsa-wrappers.cpp: $(AUTOGEN_HSA_API) scripts/gen-hsa-wrappers scripts/gen-hsa-wrappers -D $(PLATFORM) -I $(ROCM)/include --ignore=src/hsa-ignores.txt $(HSA_HEADER) $@ sed -i -f scripts/lttng-ust-hsa-post-processing.sed $@ $(AUTOGEN_HSA_API) &: $(HSA_HEADER) scripts/lttng-ust-auto-api 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) sed -i -f scripts/lttng-ust-hsa-post-processing.sed $(AUTOGEN_HSA_API) # Testing. $(builddir)/hello: tests/hello.cpp $(HIPCC) -lrocprofiler-sdk-roctx -Wno-unused -o $@ $^ check: $(builddir)/hello scripts/check $(TARGET) $^ clean: rm -rf $(builddir) rm -rf ./traces dist: git archive --prefix extracer/ --format=tar.gz --output exatracer.tar.gz HEAD .PHONY: all clean dist