1 #/******************************************************************************
3 #* Copyright (c) 2020 Intel.
5 #* Licensed under the Apache License, Version 2.0 (the "License");
6 #* you may not use this file except in compliance with the License.
7 #* You may obtain a copy of the License at
9 #* http://www.apache.org/licenses/LICENSE-2.0
11 #* Unless required by applicable law or agreed to in writing, software
12 #* distributed under the License is distributed on an "AS IS" BASIS,
13 #* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #* See the License for the specific language governing permissions and
15 #* limitations under the License.
17 #*******************************************************************************/
20 .SUFFIXES: .o .c .s .i .cpp
22 ##############################################################
24 ##############################################################
25 ifeq ($(WIRELESS_SDK_TOOLCHAIN),icc)
32 else ifeq ($(WIRELESS_SDK_TOOLCHAIN),icx)
40 $(error "Please define WIRELESS_SDK_TOOLCHAIN environment variable")
45 ifeq ($(SHELL),cmd.exe)
56 ifeq ($(WIRELESS_SDK_TOOLCHAIN),icx)
57 ifeq ($(WIRELESS_SDK_TARGET_ISA),sse)
58 TARGET_PROCESSOR := -xSSE4.2
59 else ifeq ($(WIRELESS_SDK_TARGET_ISA),avx2)
60 TARGET_PROCESSOR := -xCORE-AVX2
61 else ifeq ($(WIRELESS_SDK_TARGET_ISA),avx512)
62 TARGET_PROCESSOR := -xCORE-AVX512
63 else ifeq ($(WIRELESS_SDK_TARGET_ISA),snc)
64 TARGET_PROCESSOR := -xicelake-server
65 else ifeq ($(WIRELESS_SDK_TARGET_ISA),spr)
66 TARGET_PROCESSOR := -march=sapphirerapids
69 ifeq ($(TARGET_PROCESSOR),)
70 $(error "Please define valid WIRELESS_SDK_TARGET_ISA environment variable $(WIRELESS_SDK_TARGET_ISA)")
75 $(error "Please define RTE_SDK environment variable")
79 MLOG_DIR=$(XRAN_DIR)/../mlog
82 RTE_LIBS = $(shell PKG_CONFIG_PATH=/usr/lib64/pkgconfig:$(RTE_SDK)/build/meson-uninstalled pkgconf --static --libs libdpdk)
83 RTE_INC := $(shell PKG_CONFIG_PATH=/usr/lib64/pkgconfig:$(RTE_SDK)/build/meson-uninstalled pkgconf --cflags-only-I libdpdk)
85 # Where to find user code.
86 COMMON_TEST_DIR = $(XRAN_DIR)/test/common
87 USER_DIR = $(XRAN_DIR)/lib/src
88 USER_ETH = $(XRAN_DIR)/lib/ethernet
89 USER_API = $(XRAN_DIR)/lib/api
91 # Flags passed to the preprocessor.
92 # Set Google Test's header directory as a system directory, such that
93 # the compiler doesn't generate warnings in Google Test headers.
94 CPPFLAGS += -isystem $(GTEST_ROOT)/include -Wno-unused-variable
96 # Flags passed to the C++ compiler.
97 CXXFLAGS += -g -std=c++14 -pthread -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D_GNU_SOURCE -D_REENTRANT -pipe -mcmodel=large -Wno-unused-variable -fPIC \
98 -falign-functions=16 $(TARGET_PROCESSOR) -I$(USER_API) -I$(USER_DIR) -I$(USER_ETH) -I$(MLOG_DIR)/source -I $(COMMON_TEST_DIR) -I$(RTE_INC)
102 # All tests produced by this Makefile. Remember to add new tests you
103 # created to the list.
106 # All Google Test headers. Usually you shouldn't change this
108 GTEST_HEADERS = $(GTEST_ROOT)/include/gtest/*.h \
109 $(GTEST_ROOT)/include/gtest/internal/*.h
111 CFLAGS += -std=gnu11 -Wall -Wno-deprecated-declarations \
113 -ffunction-sections \
116 -Wimplicit-function-declaration \
118 -Wno-unused-variable \
119 -Wno-unused-parameter \
120 $(TARGET_PROCESSOR) \
121 -I$(USER_API) -I$(USER_DIR) -I$(USER_ETH) -I$(MLOG_DIR)/source -I$(RTE_INC)
123 ifeq ($(WIRELESS_SDK_TOOLCHAIN),icc)
124 CXXFLAGS += -Wall -Wextra
125 CFLAGS += -wd1786 -restrict
128 ifeq ($(WIRELESS_SDK_TOOLCHAIN),icx)
129 CFLAGS += -mintrinsic-promote -Wno-intrinsic-promote -Wno-error -Wno-unused-but-set-variable
134 $(USER_ETH)/ethdi.c \
135 $(USER_ETH)/ethernet.c \
136 $(USER_DIR)/xran_up_api.c \
137 $(USER_DIR)/xran_sync_api.c \
138 $(USER_DIR)/xran_timer.c \
139 $(USER_DIR)/xran_cp_api.c \
140 $(USER_DIR)/xran_transport.c \
141 $(USER_DIR)/xran_common.c \
142 $(USER_DIR)/xran_ul_tables.c \
143 $(USER_DIR)/xran_frame_struct.c \
144 $(USER_DIR)/xran_dev.c \
145 $(USER_DIR)/xran_rx_proc.c \
146 $(USER_DIR)/xran_tx_proc.c \
147 $(USER_DIR)/xran_cp_proc.c \
148 $(USER_DIR)/xran_cb_proc.c \
149 $(USER_DIR)/xran_mem_mgr.c \
150 $(USER_DIR)/xran_main.c \
151 $(USER_DIR)/xran_delay_measurement.c
154 $(COMMON_TEST_DIR)/xranlib_unit_test_main.cc \
157 prach_functional.cc \
158 prach_performance.cc \
159 u_plane_functional.cc \
160 u_plane_performance.cc \
161 init_sys_functional.cc \
162 compander_functional.cc \
163 mod_compression_unit_test.cc \
166 # u_plane_performance.cc \
168 CPP_SRC = $(COMMON_TEST_DIR)/common.cpp \
169 $(USER_DIR)/xran_compression.cpp \
170 $(USER_DIR)/xran_bfp_ref.cpp \
171 $(USER_DIR)/xran_bfp_cplane8.cpp \
172 $(USER_DIR)/xran_bfp_cplane16.cpp \
173 $(USER_DIR)/xran_bfp_cplane32.cpp \
174 $(USER_DIR)/xran_bfp_cplane64.cpp \
175 $(USER_DIR)/xran_bfp_uplane_9b16rb.cpp \
176 $(USER_DIR)/xran_bfp_uplane.cpp \
177 $(USER_DIR)/xran_mod_compression.cpp
179 CPP_SRC_SNC = $(USER_DIR)/xran_compression_snc.cpp \
180 $(USER_DIR)/xran_bfp_cplane8_snc.cpp \
181 $(USER_DIR)/xran_bfp_cplane16_snc.cpp \
182 $(USER_DIR)/xran_bfp_cplane32_snc.cpp \
183 $(USER_DIR)/xran_bfp_cplane64_snc.cpp \
184 $(USER_DIR)/xran_bfp_uplane_snc.cpp
187 C_OBJS := $(patsubst %.c,%.o,$(C_SRC))
188 CC_OBJS := $(patsubst %.cc,%.o,$(CC_SRC))
189 CPP_OBJS := $(patsubst %.cpp,%.o,$(CPP_SRC))
190 CPP_SNC_OBJS := $(patsubst %.cpp,%.o,$(CPP_SRC_SNC))
192 CPPFLAGS += -I$(USER_DIR) -I$(USER_API)
194 #-qopt-report=5 -qopt-matmul -qopt-report-phase=all
195 CPP_COMP := -O3 -DNDEBUG -xcore-avx512 -fPIE -fasm-blocks
196 CPP_COMP_SNC := -O3 -DNDEBUG -march=icelake-server -fPIE -fasm-blocks
198 ifeq ($(WIRELESS_SDK_TOOLCHAIN),icc)
199 CPP_COMP += -fp-model fast=2 -no-prec-div -no-prec-sqrt -fast-transcendentals -restrict
200 CPP_COMP_SNC += -fp-model fast=2 -no-prec-div -no-prec-sqrt -fast-transcendentals -restrict
203 ifeq ($(WIRELESS_SDK_TOOLCHAIN),icx)
204 CPP_COMP += -fp-model fast -mintrinsic-promote -Wno-intrinsic-promote -Wno-error -Wno-unused-variable
205 CPP_COMP_SNC += -fp-model fast -mintrinsic-promote -Wno-intrinsic-promote -Wno-error -Wno-unused-variable
208 CPP_COMP := $(CPP_COMP)
209 CPP_COMP_SNC := $(CPP_COMP_SNC)
212 CPP_ASMS := $(patsubst %.cpp,%.asm,$(CPP_SRC))
213 CPP_SNC_ASMS := $(patsubst %.cpp,%.asm,$(CPP_SRC_SNC))
214 CPP_COMP += -qopt-report=5 -qopt-matmul -qopt-report-phase=all
215 CPP_COMP_SNC += -qopt-report=5 -qopt-matmul -qopt-report-phase=all
218 PROJECT_DEP_FILE := $(TESTS).dep
220 ifeq ($(wildcard $(PROJECT_DEP_FILE)),$(PROJECT_DEP_FILE))
223 C_DEPS := $(addprefix __dep__,$(subst ../,__up__,$(C_SRC)))
224 CC_DEPS := $(addprefix __dep__,$(subst ../,__up__,$(CC_SRC)))
225 CPP_DEPS := $(addprefix __dep__,$(subst ../,__up__,$(CPP_SRC)))
226 CPP_SNC_DEPS := $(addprefix __dep__,$(subst ../,__up__,$(CPP_SRC_SNC)))
227 GENERATE_DEPS := generate_deps
231 # House-keeping build targets.
232 all : echo_start_build $(GENERATE_DEPS) $(TESTS)
236 @$(RM) -f $(TESTS) *.o $(COMMON_TEST_DIR)/*.o $(USER_DIR)/*.o $(USER_ETH)/*.o \
237 *.asm $(COMMON_TEST_DIR)/*.asm $(USER_DIR)/*.asm $(USER_ETH)/*.asm \
238 *.asm $(COMMON_TEST_DIR)/*.asm2 $(USER_DIR)/*.asm2 $(USER_ETH)/*.asm2 \
239 *.optrpt $(COMMON_TEST_DIR)/*.optrpt $(USER_DIR)/*.optrpt $(USER_ETH)/*.optrpt;\
240 $(RM) $(PROJECT_DEP_FILE)
247 @$(RM) $(PROJECT_DEP_FILE)
248 @echo [DEP] $(PROJECT_DEP_FILE)
251 @$(CC) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(patsubst %.c,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CFLAGS) >> $(PROJECT_DEP_FILE)
254 @$(CC) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(patsubst %.cc,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CPPFLAGS) $(CXXFLAGS) >> $(PROJECT_DEP_FILE)
257 @$(CPP) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(patsubst %.cpp,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP) >> $(PROJECT_DEP_FILE)
260 @$(CPP) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(patsubst %.cpp,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP_SNC) >> $(PROJECT_DEP_FILE)
262 .PHONY : generate_deps
263 generate_deps : clear_dep $(C_DEPS) $(CC_DEPS) $(CPP_DEPS) $(CPP_SNC_DEPS)
265 ifeq ($(wildcard $(PROJECT_DEP_FILE)),$(PROJECT_DEP_FILE))
267 include $(PROJECT_DEP_FILE)
271 .PHONY : echo_start_build
273 @echo Build Tests with
277 $(CC_OBJS) : $(CC_SRC)
279 @$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o"$@" $(patsubst %.o,%.cc,$@)
282 @echo "[CPP->ASM] $@"
283 @$(CXX) -S $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP) -fsource-asm -save-temps -o"$@" $(patsubst %.asm,%.cpp,$@)
284 @cat $@ | grep -v '^..LN' |grep -v ' .loc' > $@2
286 $(CPP_OBJS) : $(CPP_ASMS)
288 @$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP) -o"$@" $(patsubst %.o,%.cpp,$@)
291 @echo "[CPP-SNC->ASM] $@"
292 @$(CXX) -S $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP_SNC) -fsource-asm -save-temps -o"$@" $(patsubst %.asm,%.cpp,$@)
293 @cat $@ | grep -v '^..LN' |grep -v ' .loc' > $@2
295 $(CPP_SNC_OBJS) : $(CPP_SNC_ASMS)
297 @$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP_SNC) -o"$@" $(patsubst %.o,%.cpp,$@)
301 @$(CC) -c $(CFLAGS) -o"$@" $(patsubst %.o,%.c,$@)
303 $(TESTS) : $(CC_OBJS) $(CPP_OBJS) $(CPP_SNC_OBJS) $(C_OBJS) $(GTEST_ROOT)/libgtest.a
305 @$(CXX) $(CPPFLAGS) $(CXXFLAGS) -L$(MLOG_DIR)/bin -Wl, $(RTE_LIBS) -lpthread -lnuma -Wl,-lstdc++ $^ -o $@