O-RAN E Maintenance Release contribution for ODULOW
[o-du/phy.git] / fhi_lib / test / test_xran / Makefile
1 #/******************************************************************************
2 #*
3 #*   Copyright (c) 2020 Intel.
4 #*
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
8 #*
9 #*       http://www.apache.org/licenses/LICENSE-2.0
10 #*
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.
16 #*
17 #*******************************************************************************/
18
19
20 .SUFFIXES: .o .c .s .i .cpp
21
22 ##############################################################
23 #  Tools configuration
24 ##############################################################
25 CC  := icc
26 CXX := icpc
27 CPP := icpc
28 AS := as
29 AR := ar
30 LD := icc
31 OBJDUMP := objdump
32
33 ifeq ($(SHELL),cmd.exe)
34 MD := mkdir.exe -p
35 CP := cp.exe -f
36 RM := rm.exe -rf
37 else
38 MD := mkdir -p
39 CP := cp -f
40 RM := rm -rf
41 endif
42
43 ifeq ($(RTE_SDK),)
44     $(error "Please define RTE_SDK environment variable")
45 endif
46
47 ifeq ($(MLOG_DIR),)
48     MLOG_DIR=$(XRAN_DIR)/../mlog
49 endif
50
51 RTE_TARGET ?= x86_64-native-linuxapp-icc
52
53 RTE_LIBS = $(shell PKG_CONFIG_PATH=/usr/lib64/pkgconfig:$(RTE_SDK)/build/meson-uninstalled pkgconf --static --libs libdpdk)
54 RTE_INC := $(shell PKG_CONFIG_PATH=/usr/lib64/pkgconfig:$(RTE_SDK)/build/meson-uninstalled pkgconf --cflags-only-I libdpdk)
55
56
57 # Where to find user code.
58 COMMON_TEST_DIR = $(XRAN_DIR)/test/common
59 USER_DIR = $(XRAN_DIR)/lib/src
60 USER_ETH = $(XRAN_DIR)/lib/ethernet
61 USER_API = $(XRAN_DIR)/lib/api
62
63 # Flags passed to the preprocessor.
64 # Set Google Test's header directory as a system directory, such that
65 # the compiler doesn't generate warnings in Google Test headers.
66 CPPFLAGS += -isystem $(GTEST_ROOT)/include
67
68 # Flags passed to the C++ compiler.
69 CXXFLAGS += -g -std=c++14 -Wall -Wextra -pthread -mcmodel=large -I$(USER_API) -I$(USER_DIR) -I$(USER_ETH) -I$(MLOG_DIR)/source -I $(COMMON_TEST_DIR) -I$(RTE_INC)
70
71 # All tests produced by this Makefile.  Remember to add new tests you
72 # created to the list.
73 TESTS = unittests
74
75 # All Google Test headers.  Usually you shouldn't change this
76 # definition.
77 GTEST_HEADERS = $(GTEST_ROOT)/include/gtest/*.h \
78                 $(GTEST_ROOT)/include/gtest/internal/*.h
79
80 CFLAGS += -std=gnu11 -Wall -Wno-deprecated-declarations \
81         -fdata-sections \
82         -ffunction-sections \
83         -g \
84         -Wall \
85         -Wimplicit-function-declaration  \
86         -wd1786 \
87         -mcmodel=large \
88         -I$(USER_API) -I$(USER_DIR) -I$(USER_ETH) -I$(MLOG_DIR)/source -I$(RTE_INC)
89
90 C_SRC = \
91         $(USER_ETH)/ethdi.c \
92         $(USER_ETH)/ethernet.c \
93         $(USER_DIR)/xran_up_api.c \
94         $(USER_DIR)/xran_sync_api.c \
95         $(USER_DIR)/xran_timer.c \
96         $(USER_DIR)/xran_cp_api.c \
97         $(USER_DIR)/xran_transport.c \
98         $(USER_DIR)/xran_common.c \
99         $(USER_DIR)/xran_ul_tables.c \
100         $(USER_DIR)/xran_frame_struct.c \
101         $(USER_DIR)/xran_app_frag.c \
102         $(USER_DIR)/xran_dev.c \
103         $(USER_DIR)/xran_rx_proc.c      \
104         $(USER_DIR)/xran_tx_proc.c      \
105         $(USER_DIR)/xran_cp_proc.c      \
106         $(USER_DIR)/xran_cb_proc.c      \
107         $(USER_DIR)/xran_mem_mgr.c      \
108         $(USER_DIR)/xran_main.c \
109     $(USER_DIR)/xran_delay_measurement.c
110
111 CC_SRC = \
112         $(COMMON_TEST_DIR)/xranlib_unit_test_main.cc \
113         c_plane_tests.cc \
114         chain_tests.cc \
115         prach_functional.cc \
116         prach_performance.cc \
117         u_plane_functional.cc \
118         u_plane_performance.cc \
119         init_sys_functional.cc \
120         compander_functional.cc \
121         mod_compression_unit_test.cc \
122         unittests.cc
123
124 #       u_plane_performance.cc \
125
126 CPP_SRC = $(COMMON_TEST_DIR)/common.cpp \
127         $(USER_DIR)/xran_compression.cpp \
128         $(USER_DIR)/xran_bfp_ref.cpp \
129         $(USER_DIR)/xran_bfp_cplane8.cpp \
130         $(USER_DIR)/xran_bfp_cplane16.cpp \
131         $(USER_DIR)/xran_bfp_cplane32.cpp \
132         $(USER_DIR)/xran_bfp_cplane64.cpp \
133         $(USER_DIR)/xran_bfp_uplane_9b16rb.cpp \
134         $(USER_DIR)/xran_bfp_uplane.cpp \
135         $(USER_DIR)/xran_mod_compression.cpp
136
137 CPP_SRC_SNC = $(USER_DIR)/xran_compression_snc.cpp \
138         $(USER_DIR)/xran_bfp_cplane8_snc.cpp \
139         $(USER_DIR)/xran_bfp_cplane16_snc.cpp \
140         $(USER_DIR)/xran_bfp_cplane32_snc.cpp \
141         $(USER_DIR)/xran_bfp_cplane64_snc.cpp \
142         $(USER_DIR)/xran_bfp_uplane_snc.cpp
143
144
145 C_OBJS := $(patsubst %.c,%.o,$(C_SRC))
146 CC_OBJS := $(patsubst %.cc,%.o,$(CC_SRC))
147 CPP_OBJS := $(patsubst %.cpp,%.o,$(CPP_SRC))
148 CPP_SNC_OBJS := $(patsubst %.cpp,%.o,$(CPP_SRC_SNC))
149
150 CPPFLAGS += -I$(USER_DIR) -I$(USER_API)
151
152 #-qopt-report=5 -qopt-matmul -qopt-report-phase=all
153 CPP_COMP := -O3 -DNDEBUG  -xcore-avx512 -fPIE -restrict -fasm-blocks
154 CPP_COMP_SNC := -O3 -DNDEBUG -march=icelake-server -fPIE -restrict -fasm-blocks
155
156 CPP_COMP := $(CPP_COMP)
157 CPP_COMP_SNC := $(CPP_COMP_SNC)
158
159 ifeq ($(GEN_ASM), 1)
160 CPP_ASMS := $(patsubst %.cpp,%.asm,$(CPP_SRC))
161 CPP_SNC_ASMS := $(patsubst %.cpp,%.asm,$(CPP_SRC_SNC))
162 CPP_COMP += -qopt-report=5 -qopt-matmul -qopt-report-phase=all
163 CPP_COMP_SNC += -qopt-report=5 -qopt-matmul -qopt-report-phase=all
164 endif
165
166 PROJECT_DEP_FILE := $(TESTS).dep
167
168 ifeq ($(wildcard $(PROJECT_DEP_FILE)),$(PROJECT_DEP_FILE))
169 GENERATE_DEPS :=
170 else
171 C_DEPS  := $(addprefix __dep__,$(subst ../,__up__,$(C_SRC)))
172 CC_DEPS  := $(addprefix __dep__,$(subst ../,__up__,$(CC_SRC)))
173 CPP_DEPS  := $(addprefix __dep__,$(subst ../,__up__,$(CPP_SRC)))
174 CPP_SNC_DEPS  := $(addprefix __dep__,$(subst ../,__up__,$(CPP_SRC_SNC)))
175 GENERATE_DEPS := generate_deps
176 endif
177
178
179 # House-keeping build targets.
180 all : echo_start_build $(GENERATE_DEPS) $(TESTS)
181
182 clean :
183         @echo [CLEAN]
184         @$(RM) -f $(TESTS) *.o $(COMMON_TEST_DIR)/*.o $(USER_DIR)/*.o $(USER_ETH)/*.o \
185         *.asm $(COMMON_TEST_DIR)/*.asm $(USER_DIR)/*.asm $(USER_ETH)/*.asm \
186         *.asm $(COMMON_TEST_DIR)/*.asm2 $(USER_DIR)/*.asm2 $(USER_ETH)/*.asm2 \
187         *.optrpt $(COMMON_TEST_DIR)/*.optrpt $(USER_DIR)/*.optrpt $(USER_ETH)/*.optrpt;\
188         $(RM) $(PROJECT_DEP_FILE)
189
190 .PHONY: xclean
191 xclean: clean
192
193 .PHONY : clear_dep
194 clear_dep:
195         @$(RM) $(PROJECT_DEP_FILE)
196         @echo [DEP] $(PROJECT_DEP_FILE)
197
198 $(C_DEPS) :
199         @$(CC) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(patsubst %.c,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CFLAGS)  >> $(PROJECT_DEP_FILE)
200
201 $(CC_DEPS) :
202         @$(CC) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(patsubst %.cc,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CPPFLAGS) $(CXXFLAGS) >> $(PROJECT_DEP_FILE)
203
204 $(CPP_DEPS) :
205         @$(CPP) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(patsubst %.cpp,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP) >> $(PROJECT_DEP_FILE)
206
207 $(CPP_SNC_DEPS) :
208         @$(CPP) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(patsubst %.cpp,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP_SNC) >> $(PROJECT_DEP_FILE)
209
210 .PHONY : generate_deps
211 generate_deps : clear_dep $(C_DEPS) $(CC_DEPS) $(CPP_DEPS) $(CPP_SNC_DEPS)
212
213 ifeq ($(wildcard $(PROJECT_DEP_FILE)),$(PROJECT_DEP_FILE))
214
215 include $(PROJECT_DEP_FILE)
216
217 endif
218
219 .PHONY : echo_start_build
220 echo_start_build :
221         @echo Build Tests with
222         @echo $(USER_DIR)
223         @echo $(USER_API)
224
225 $(CC_OBJS) : $(CC_SRC)
226         @echo "[CC] $@"
227         @$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o"$@" $(patsubst %.o,%.cc,$@)
228
229 $(CPP_ASMS) :
230         @echo "[CPP->ASM] $@"
231         @$(CXX) -S $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP) -fsource-asm -save-temps -o"$@" $(patsubst %.asm,%.cpp,$@)
232         @cat $@ | grep -v '^..LN' |grep -v '    .loc' > $@2
233
234 $(CPP_OBJS) : $(CPP_ASMS)
235         @echo "[CPP] $@"
236         @$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP) -o"$@" $(patsubst %.o,%.cpp,$@)
237
238 $(CPP_SNC_ASMS) :
239         @echo "[CPP-SNC->ASM] $@"
240         @$(CXX) -S $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP_SNC) -fsource-asm -save-temps -o"$@" $(patsubst %.asm,%.cpp,$@)
241         @cat $@ | grep -v '^..LN' |grep -v '    .loc' > $@2
242
243 $(CPP_SNC_OBJS) : $(CPP_SNC_ASMS)
244         @echo "[CPP-SNC] $@"
245         @$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP_SNC) -o"$@" $(patsubst %.o,%.cpp,$@)
246
247 $(C_OBJS) :
248         @echo "[C] $@"
249         @$(CC) -c $(CFLAGS) -o"$@" $(patsubst %.o,%.c,$@)
250
251 $(TESTS) : $(CC_OBJS) $(CPP_OBJS) $(CPP_SNC_OBJS) $(C_OBJS) $(GTEST_ROOT)/libgtest.a
252         @echo "[LD] $@"
253         $(CXX) $(CPPFLAGS) $(CXXFLAGS) -L$(MLOG_DIR)/bin -Wl, $(RTE_LIBS) -lpthread -lnuma $^ -o $@