Skip to content

Commit 4314613

Browse files
author
Matt Balkwill
committed
Add CPU architecture optimizations and VOLK profiling support
- Add configurable CPU march targets (default x86-64-v3/AVX2) to srsRAN builds - Add VOLK profile pre-generation to fix SIMD dispatch on heterogeneous CPUs - Add libvolk2-bin to GRC container for VOLK support - Update build scripts to use consistent from environment - Apply JBPF 3p patches (ck, mimalloc, ebpf-verifier) during build - Update image tag to srsran25.10-2
1 parent 0c21655 commit 4314613

12 files changed

Lines changed: 71 additions & 42 deletions

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ export DOCKER_CMD="docker"
99
export USE_JRTC=1
1010

1111
# SRSRAN INAGE TAGS. Used for images in the variosu kubernetes yaml files, but also for building codelets
12-
export SRSRAN_IMAGE_TAG=srsran25.10-latest
12+
export SRSRAN_IMAGE_TAG=srsran25.10-2

containers/Docker/GRC.Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@ SHELL ["/bin/bash", "-c"]
55

66
# Install GNU Radio runtime (no GUI)
77
RUN apt-get clean -y && apt-get update -y
8-
RUN apt-get install -y gnuradio python3 python3-pip && \
8+
RUN apt-get install -y gnuradio python3 python3-pip libvolk2-bin && \
99
apt-get clean
1010

1111
# Create folders need for gnuradio
1212
RUN mkdir -p /root/.gnuradio /tmp/.gnuradio && chmod -R 777 /root/.gnuradio /tmp/.gnuradio
1313
RUN mkdir -p /root/.gnuradio/prefs
1414
RUN echo "DEFAULT" > /root/.gnuradio/prefs/vmcircbuf_default_factory
1515

16+
# Pre-generate VOLK profile for the generic (portable) kernels to avoid
17+
# SIMD dispatch issues on CPUs different from the image build machine.
18+
# If volk_profile fails (e.g. no CPU match), fall back to generic config.
19+
RUN volk_profile || true
20+
RUN mkdir -p /etc/volk
21+
ENV VOLK_CONFIGPATH=/root/.volk
22+
1623
# Copy your generated Python file
1724
COPY srs_grc/GRC_multi_ue_headless.py /app/GRC_multi_ue_headless.py
1825
COPY srs_grc/GRC_run.sh /app/GRC_run.sh

containers/Docker/SRS-jbpf-zmq.Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
ARG SRS_JBPF_IMAGE_TAG=latest
2+
ARG MARCH=x86-64-v3
23

34
# =============================
45
# Stage 1: Build libzmq + czmq
@@ -34,6 +35,8 @@ RUN git clone --depth 1 https://github.com/zeromq/czmq.git && \
3435
# =============================
3536
FROM ghcr.io/microsoft/jrtc-apps/srs-jbpf:${SRS_JBPF_IMAGE_TAG}
3637

38+
ARG MARCH
39+
3740
# Copy only installed libs/binaries from builder
3841
COPY --from=builder /usr/local /usr/local
3942

@@ -49,7 +52,7 @@ RUN ldconfig -p | grep zmq || true
4952

5053
WORKDIR /src/build
5154
RUN rm -rf * /out
52-
RUN cmake .. -DENABLE_ZEROMQ=ON -DENABLE_JBPF=ON -DINITIALIZE_SUBMODULES=OFF -DCMAKE_C_FLAGS="-Wno-error=unused-variable"
55+
RUN cmake .. -DENABLE_ZEROMQ=ON -DENABLE_JBPF=ON -DINITIALIZE_SUBMODULES=OFF -DMARCH=${MARCH} -DCMAKE_C_FLAGS="-Wno-error=unused-variable"
5356
RUN make -j VERBOSE=1
5457
RUN make install
5558

containers/Docker/SRS-jbpf.Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@
55

66
ARG LIB=dpdk
77
ARG LIB_VERSION=23.11
8+
ARG MARCH=x86-64-v3
89

910
ARG BASE_IMAGE_TAG=latest
1011
FROM ghcr.io/microsoft/jrtc-apps/base/srs:${BASE_IMAGE_TAG}
1112

13+
ARG MARCH
14+
1215
LABEL org.opencontainers.image.source="https://github.com/microsoft/jrtc-apps"
1316
LABEL org.opencontainers.image.authors="Microsoft Corporation"
1417
LABEL org.opencontainers.image.licenses="MIT"
1518
LABEL org.opencontainers.image.description="SRSRAN with JBPF support"
1619

17-
ADD srsRAN_Project /src
20+
ADD srsRAN_Project /src
1821

1922
ENV PKG_CONFIG_PATH=/opt/dpdk-23.11/build/meson-private:/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH
2023

@@ -26,7 +29,7 @@ RUN mkdir build
2629
WORKDIR /src/build
2730
# Temporary fix for failing jbpf tests in RELEASE mode. To be removed when jbpf tests are fixed.
2831
#RUN cmake .. -DENABLE_DPDK=True -DENABLE_JBPF=ON -DINITIALIZE_SUBMODULES=OFF
29-
RUN cmake .. -DENABLE_DPDK=True -DENABLE_JBPF=ON -DINITIALIZE_SUBMODULES=OFF -DCMAKE_C_FLAGS="-Wno-error=unused-variable"
32+
RUN cmake .. -DENABLE_DPDK=True -DENABLE_JBPF=ON -DINITIALIZE_SUBMODULES=OFF -DMARCH=${MARCH} -DCMAKE_C_FLAGS="-Wno-error=unused-variable"
3033
RUN make -j VERBOSE=1
3134
RUN make install
3235

containers/Docker/SRS-ue.Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
ARG SRSRAN_IMAGE_TAG=latest
2+
ARG GCC_ARCH=x86-64-v3
23

34
FROM ghcr.io/microsoft/jrtc-apps/srs-ue-base:${SRSRAN_IMAGE_TAG}
45

6+
ARG GCC_ARCH
7+
58
LABEL org.opencontainers.image.source="https://github.com/microsoft/jrtc-apps"
69
LABEL org.opencontainers.image.authors="Microsoft Corporation"
710
LABEL org.opencontainers.image.licenses="MIT"
@@ -11,7 +14,7 @@ LABEL org.opencontainers.image.description="SDK for SRSRAN with JBPF, built in Z
1114
WORKDIR /
1215
ADD srsRAN_4G /srsRAN_4G
1316
WORKDIR /srsRAN_4G/build
14-
RUN cmake ../ -DENABLE_RF_PLUGINS=OFF -DCMAKE_C_COMPILER=/usr/local/gcc-11/bin/gcc -DCMAKE_CXX_COMPILER=/usr/local/gcc-11/bin/g++ -DBOOST_ROOT=/usr/local
17+
RUN cmake ../ -DENABLE_RF_PLUGINS=OFF -DGCC_ARCH=${GCC_ARCH} -DCMAKE_C_COMPILER=/usr/local/gcc-11/bin/gcc -DCMAKE_CXX_COMPILER=/usr/local/gcc-11/bin/g++ -DBOOST_ROOT=/usr/local
1518
RUN make -j`nproc`
1619
RUN make install
1720

containers/Docker/base.Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
FROM mcr.microsoft.com/azurelinux/base/core:3.0
77

8+
ARG DPDK_MACHINE=default
9+
810
COPY Scripts/mariner-extras.repo /etc/yum.repos.d
911
RUN tdnf makecache
1012

@@ -50,7 +52,7 @@ WORKDIR /opt
5052
RUN wget https://fast.dpdk.org/rel/dpdk-23.11.tar.xz
5153
RUN tar xvf dpdk-23.11.tar.xz dpdk-23.11
5254
WORKDIR /opt/dpdk-23.11
53-
RUN meson setup build
55+
RUN meson setup build -Dmachine=${DPDK_MACHINE}
5456
WORKDIR /opt/dpdk-23.11/build
5557
RUN ninja
5658
RUN meson install

containers/Docker/build_base.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
# Copyright (c) Microsoft Corporation.
44
# Licensed under the MIT license.
55

6-
BASE_IMAGE_TAG=latest
6+
CURRENT_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
7+
source $(dirname $(dirname "$CURRENT_DIR"))/set_vars.sh
8+
9+
BASE_IMAGE_TAG=$SRSRAN_IMAGE_TAG
710

811
Usage()
912
{
1013
# Display Help
1114
echo "Build srsRan base image"
1215
echo "options:"
13-
echo "[-b] Optional base image tag. Default='latest'"
16+
echo "[-b] Optional base image tag. Default='$SRSRAN_IMAGE_TAG'"
1417
echo
1518
}
1619

containers/Docker/build_srs_jbpf.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,35 @@
33
# Copyright (c) Microsoft Corporation.
44
# Licensed under the MIT license.
55

6-
BASE_IMAGE_TAG=latest
6+
MARCH=x86-64-v3
77
CACHE_FLAG=
88

99
CURRENT_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
1010
source $(dirname $(dirname "$CURRENT_DIR"))/set_vars.sh
1111

12+
BASE_IMAGE_TAG=$SRSRAN_IMAGE_TAG
13+
1214
Usage()
1315
{
1416
# Display Help
1517
echo "Build srsRan image"
1618
echo "options:"
17-
echo "[-b] Optional base image tag. Default='latest'"
19+
echo "[-b] Optional base image tag. Default='$SRSRAN_IMAGE_TAG'"
1820
echo "[-s] Optional image tag. Default='$SRSRAN_IMAGE_TAG'"
21+
echo "[-m] Optional CPU march target. Default='x86-64-v3' (AVX2)"
1922
echo "[-c] Optional. If included, '--no-cache- is added to the Docker build"
2023
echo
2124
}
2225

2326
# Get the options
24-
while getopts "b:s:c" option; do
27+
while getopts "b:s:m:c" option; do
2528
case $option in
2629
b) # Set image tag
2730
BASE_IMAGE_TAG="$OPTARG";;
2831
s) # Set image tag
2932
SRSRAN_IMAGE_TAG="$OPTARG";;
33+
m) # Set CPU march target
34+
MARCH="$OPTARG";;
3035
c) # Set image tag
3136
CACHE_FLAG="--no-cache";;
3237
\?) # Invalid option
@@ -38,9 +43,24 @@ done
3843

3944
echo BASE_IMAGE_TAG $BASE_IMAGE_TAG
4045
echo SRSRAN_IMAGE_TAG $SRSRAN_IMAGE_TAG
46+
echo MARCH $MARCH
47+
48+
# Apply jbpf 3p patches (ck, mimalloc, ebpf-verifier) since INITIALIZE_SUBMODULES=OFF
49+
# skips init_and_patch_submodules.sh which requires git inside the container.
50+
JBPF_DIR=srsRAN_Project/external/jbpf
51+
if [ -f "$JBPF_DIR/patches/ck.patch" ]; then
52+
echo "Applying jbpf 3p patches..."
53+
cd "$JBPF_DIR/3p/ck" && patch -p1 --forward -r- < ../../patches/ck.patch || true
54+
cd "$CURRENT_DIR"
55+
cd "$JBPF_DIR/3p/mimalloc" && patch -p1 --forward -r- < ../../patches/mimalloc.patch || true
56+
cd "$CURRENT_DIR"
57+
cd "$JBPF_DIR/3p/ebpf-verifier" && patch -p1 --forward -r- < ../../patches/ebpf_verifier.patch || true
58+
cd "$CURRENT_DIR"
59+
fi
4160

4261
docker build $CACHE_FLAG \
4362
--build-arg BASE_IMAGE_TAG=${BASE_IMAGE_TAG} \
63+
--build-arg MARCH=${MARCH} \
4464
-t ghcr.io/microsoft/jrtc-apps/srs-jbpf:${SRSRAN_IMAGE_TAG} -f SRS-jbpf.Dockerfile .
4565

4666
exit 0

containers/Docker/build_srs_jbpf_sdk.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
# Copyright (c) Microsoft Corporation.
44
# Licensed under the MIT license.
55

6-
BASE_IMAGE_TAG=latest
76

87
CURRENT_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
98
source $(dirname $(dirname "$CURRENT_DIR"))/set_vars.sh
109

10+
BASE_IMAGE_TAG=$SRSRAN_IMAGE_TAG
1111

1212
Usage()
1313
{

containers/Docker/build_srs_jbpf_zmq.sh

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,27 @@
66
CURRENT_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
77
source $(dirname $(dirname "$CURRENT_DIR"))/set_vars.sh
88

9+
MARCH=x86-64-v3
910

1011
Usage()
1112
{
1213
# Display Help
13-
echo "Build srsRan=Jbpf base image"
14+
echo "Build srsRan=Jbpf zmq image"
1415
echo "options:"
15-
echo "[-b] Optional base image tag. Default='latest'"
1616
echo "[-s] Optional srsRan image tag. Default='$SRSRAN_IMAGE_TAG'"
17+
echo "[-m] Optional CPU march target. Default='x86-64-v3' (AVX2)"
1718
echo
1819
}
1920

2021
# Get the options
2122
#while getopts "b:s:c" option; do
22-
while getopts "s:c" option; do
23+
while getopts "s:m:c" option; do
2324
case $option in
2425

2526
s) # Set image tag
2627
SRSRAN_IMAGE_TAG="$OPTARG";;
28+
m) # Set CPU march target
29+
MARCH="$OPTARG";;
2730
c) # Set image tag
2831
CACHE_FLAG="--no-cache";;
2932
\?) # Invalid option
@@ -35,34 +38,12 @@ done
3538

3639
#echo BASE_IMAGE_TAG $BASE_IMAGE_TAG
3740
echo SRSRAN_IMAGE_TAG $SRSRAN_IMAGE_TAG
41+
echo MARCH $MARCH
3842

3943
docker build $CACHE_FLAG \
4044
--build-arg SRS_JBPF_IMAGE_TAG=${SRSRAN_IMAGE_TAG} \
45+
--build-arg MARCH=${MARCH} \
4146
-t ghcr.io/microsoft/jrtc-apps/srs-jbpf-zmq:${SRSRAN_IMAGE_TAG} -f SRS-jbpf-zmq.Dockerfile .
4247

4348

44-
45-
# First build the jbpf_protobuf image
46-
47-
# pushd . > /dev/null
48-
# cd ../../jbpf_protobuf/
49-
50-
# # To build for a particular OS, run:
51-
# OS=azurelinux
52-
# docker build -t jbpfp-$OS:latest -f deploy/$OS.Dockerfile .
53-
54-
# # And to create a jbpf_protobuf_cli image from that container, run:
55-
# docker build --build-arg builder_image=jbpfp-$OS --build-arg builder_image_tag=latest -t jbpf_protobuf_cli:latest - < deploy/jbpf_protobuf_cli.Dockerfile
56-
57-
# popd > /dev/null
58-
59-
60-
61-
# docker build $CACHE_FLAG \
62-
# --build-arg BASE_IMAGE_TAG=${BASE_IMAGE_TAG} \
63-
# --build-arg SRS_JBPF_IMAGE_TAG=${SRSRAN_IMAGE_TAG} \
64-
# --build-arg JBPF_PROTOBUF_BUILDER_IMAGE=jbpf_protobuf_cli \
65-
# --build-arg JBPF_PROTOBUF_BUILDER_IMAGE_TAG=latest \
66-
# -t ghcr.io/microsoft/jrtc-apps/srs-jbpf-sdk:${SRSRAN_IMAGE_TAG} -f SRS-jbpf-sdk.Dockerfile .
67-
6849
exit 0

0 commit comments

Comments
 (0)