Skip to content

Commit

Permalink
[FIX] Build patched MediaSDK with MTL enabled
Browse files Browse the repository at this point in the history
[FIX] Build patched MediaSDK with MTL enabled:
- correct build script in ecosystem subpath
- add scripts/common.sh for common functionalities is bash
- remove proxy settings specific to one vendor
- minor other fixes/adjustments

Signed-off-by: Milosz Linkiewicz <milosz.linkiewicz@intel.com>
  • Loading branch information
Mionsz committed Feb 19, 2025
1 parent 0b6d41c commit 50f41b8
Show file tree
Hide file tree
Showing 10 changed files with 638 additions and 94 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ mtl_system_status_*
doc/_build

# Gpu direct files
ecosystem/msdk/_install
gpu_direct/tests/fff.h
gpu_direct/subprojects/*
!gpu_direct/subprojects/gtest.wrap
Expand Down
28 changes: 17 additions & 11 deletions app/sample/redundant_sample_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,30 @@

set -e

TEST_TIME_SEC=15
SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")"
REPOSITORY_DIR="$(readlink -f "${SCRIPT_DIR}/../..")"

TEST_BIN_PATH=../../build/app
# shellcheck source="script/common.sh"
. "${REPOSITORY_DIR}/script/common.sh"

print_logo_anim
TEST_TIME_SEC="${TEST_TIME_SEC:-15}"
TEST_BIN_PATH="${REPOSITORY_DIR}/build/app"
LOG_LEVEL=notice

name=RxSt20RedundantSample

${TEST_BIN_PATH}/TxSt20PipelineSample >/dev/null --log_level ${LOG_LEVEL} --p_port 0000:af:01.2 --r_port 0000:af:01.3 --p_sip 192.168.77.2 --r_sip 192.168.77.3 --p_tx_ip 239.168.77.20 --r_tx_ip 239.168.77.21 2>&1 &
"${TEST_BIN_PATH}/TxSt20PipelineSample" >/dev/null --log_level "${LOG_LEVEL}" --p_port 0000:af:01.2 --r_port 0000:af:01.3 --p_sip 192.168.77.2 --r_sip 192.168.77.3 --p_tx_ip 239.168.77.20 --r_tx_ip 239.168.77.21 2>&1 &
pid_tx=$!
${TEST_BIN_PATH}/RxSt20RedundantSample --log_level ${LOG_LEVEL} --p_port 0000:af:01.0 --r_port 0000:af:01.1 --p_sip 192.168.77.11 --r_sip 192.168.77.12 --p_rx_ip 239.168.77.20 --r_rx_ip 239.168.77.21 &
"${TEST_BIN_PATH}/RxSt20RedundantSample" --log_level "${LOG_LEVEL}" --p_port 0000:af:01.0 --r_port 0000:af:01.1 --p_sip 192.168.77.11 --r_sip 192.168.77.12 --p_rx_ip 239.168.77.20 --r_rx_ip 239.168.77.21 &
pid_rx=$!

echo "${name}: pid_tx ${pid_tx}, pid_rx ${pid_rx}, wait ${TEST_TIME_SEC}s"
sleep ${TEST_TIME_SEC}
kill -SIGINT ${pid_tx}
kill -SIGINT ${pid_rx}
log_info "${name}: pid_tx ${pid_tx}, pid_rx ${pid_rx}, wait ${TEST_TIME_SEC}s"
sleep "${TEST_TIME_SEC}"
kill -SIGINT "${pid_tx}"
kill -SIGINT "${pid_rx}"

echo "${name}: wait all thread ending"
log_info "${name}: wait all thread ending"
wait
echo "${name}: ****** Done ******"
echo ""
log_success "${name}: ****** Done ******"
log_info ""
98 changes: 53 additions & 45 deletions app/sample/sample_test.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
#!/bin/bash

# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2022 Intel Corporation
# Copyright 2022-2025 Intel Corporation

set -e
SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")"
REPOSITORY_DIR="$(readlink -f "${SCRIPT_DIR}/../..")"

ST_PORT_TX=0000:af:01.1
ST_PORT_RX=0000:af:01.0
ST_SIP_TX=192.168.87.80
ST_SIP_RX=192.168.87.81
ST_TX_IP=239.168.87.20
ST_RX_IP=239.168.87.20
TEST_TIME_SEC=15
# shellcheck source="script/common.sh"
. "${REPOSITORY_DIR}/script/common.sh"

TEST_BIN_PATH=../../build/app
LOG_LEVEL=notice
ST_PORT_TX="${ST_PORT_TX:-'0000:af:01.1'}"
ST_PORT_RX="${ST_PORT_RX:-'0000:af:01.0'}"
ST_SIP_TX="${ST_SIP_TX:-'192.168.87.80'}"
ST_SIP_RX="${ST_SIP_RX:-'192.168.87.81'}"
ST_TX_IP="${ST_TX_IP:-'239.168.87.20'}"
ST_RX_IP="${ST_RX_IP:-'239.168.87.20'}"
TEST_TIME_SEC="${TEST_TIME_SEC:-15}"

export KAHAWAI_CFG_PATH=../../kahawai.json
TEST_BIN_PATH="${TEST_BIN_PATH:-"${REPOSITORY_DIR}/build/app"}"
LOG_LEVEL="${LOG_LEVEL:-notice}"

test_tx_and_rx() {
local name=$1
Expand All @@ -30,53 +32,59 @@ test_tx_and_rx() {
if [ -n "$5" ]; then
height=$5
fi
echo "${name}: start ${tx_prog}, width:${width} height:${height}"
log_info "${name}: start ${tx_prog}, width:${width} height:${height}"
"${TEST_BIN_PATH}"/"${tx_prog}" --log_level "${LOG_LEVEL}" --p_port "${ST_PORT_TX}" --p_sip "${ST_SIP_TX}" --p_tx_ip "${ST_TX_IP}" --width "${width}" --height "${height}" &
#${TEST_BIN_PATH}/${tx_prog} > /dev/null --log_level ${LOG_LEVEL} --p_port ${ST_PORT_TX} --p_sip ${ST_SIP_TX} --p_tx_ip ${ST_TX_IP} --width ${width} --height ${height} 2>&1 &
pid_tx=$!
echo "${name}: start ${rx_prog}"
log_info "${name}: start ${rx_prog}"
"${TEST_BIN_PATH}"/"${rx_prog}" --log_level "${LOG_LEVEL}" --p_port "${ST_PORT_RX}" --p_sip "${ST_SIP_RX}" --p_rx_ip "${ST_RX_IP}" --width "${width}" --height "${height}" &
pid_rx=$!
echo "${name}: pid_tx ${pid_tx}, pid_rx ${pid_rx}, wait ${TEST_TIME_SEC}s"
sleep ${TEST_TIME_SEC}
log_info "${name}: pid_tx ${pid_tx}, pid_rx ${pid_rx}, wait ${TEST_TIME_SEC}s"
sleep "${TEST_TIME_SEC}"

echo "${name}: wait all thread ending"
log_info "${name}: wait all thread ending"
kill -SIGINT ${pid_tx}
kill -SIGINT ${pid_rx}
wait ${pid_tx}
echo "${name}: ${tx_prog} exit"
log_info "${name}: ${tx_prog} exit"
wait ${pid_rx}
echo "${name}: ${rx_prog} exit"
echo "${name}: ****** Done ******"
echo ""
log_info "${name}: ${rx_prog} exit"
log_success "${name}: ****** Done ******"
log_info ""
}

# test video
test_tx_and_rx st20 TxVideoSample RxVideoSample
# test st20p
test_tx_and_rx st20p TxSt20PipelineSample RxSt20PipelineSample
# test st22p
test_tx_and_rx st22p TxSt22PipelineSample RxSt22PipelineSample
# Allow sourcing of the script.
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
set -e -o pipefail
export KAHAWAI_CFG_PATH="${REPOSITORY_DIR}/kahawai.json"

# test rtp video
test_tx_and_rx st20_rtp TxRtpVideoSample RxRtpVideoSample
# test slice video
test_tx_and_rx st20_slice TxSliceVideoSample RxSliceVideoSample
# test st22
test_tx_and_rx st22 TxSt22VideoSample RxSt22VideoSample
print_logo_anim
# test video
test_tx_and_rx st20 TxVideoSample RxVideoSample
# test st20p
test_tx_and_rx st20p TxSt20PipelineSample RxSt20PipelineSample
# test st22p
test_tx_and_rx st22p TxSt22PipelineSample RxSt22PipelineSample

# test RxSt20TxSt20Fwd
test_tx_and_rx RxSt20TxSt20Fwd TxSt20PipelineSample RxSt20TxSt20Fwd
# test RxSt20pTxSt20pFwd
test_tx_and_rx RxSt20pTxSt20pFwd TxSt20PipelineSample RxSt20pTxSt20pFwd
# test RxSt20pTxSt22pFwd
test_tx_and_rx RxSt20pTxSt22pFwd TxSt20PipelineSample RxSt20pTxSt22pFwd
# test rtp video
test_tx_and_rx st20_rtp TxRtpVideoSample RxRtpVideoSample
# test slice video
test_tx_and_rx st20_slice TxSliceVideoSample RxSliceVideoSample
# test st22
test_tx_and_rx st22 TxSt22VideoSample RxSt22VideoSample

# test TxVideoSplitSample
test_tx_and_rx TxVideoSplitSample TxVideoSplitSample RxSt20PipelineSample
# test RxSt20TxSt20SplitFwd, not enable now
test_tx_and_rx RxSt20TxSt20SplitFwd TxSt20PipelineSample RxSt20TxSt20SplitFwd 3840 2160
# test RxSt20TxSt20Fwd
test_tx_and_rx RxSt20TxSt20Fwd TxSt20PipelineSample RxSt20TxSt20Fwd
# test RxSt20pTxSt20pFwd
test_tx_and_rx RxSt20pTxSt20pFwd TxSt20PipelineSample RxSt20pTxSt20pFwd
# test RxSt20pTxSt22pFwd
test_tx_and_rx RxSt20pTxSt22pFwd TxSt20PipelineSample RxSt20pTxSt22pFwd

echo "****** All test OK ******"
# test TxVideoSplitSample
test_tx_and_rx TxVideoSplitSample TxVideoSplitSample RxSt20PipelineSample
# test RxSt20TxSt20SplitFwd, not enable now
test_tx_and_rx RxSt20TxSt20SplitFwd TxSt20PipelineSample RxSt20TxSt20SplitFwd 3840 2160

unset KAHAWAI_CFG_PATH
log_success "****** All test OK ******"
unset KAHAWAI_CFG_PATH
fi
31 changes: 20 additions & 11 deletions ecosystem/msdk/build_msdk_mtl.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
#!/bin/bash

# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2022 Intel Corporation
# Copyright 2022-2025 Intel Corporation

# check out msdk code
git clone https://github.com/Intel-Media-SDK/MediaSDK.git
cd MediaSDK || exit
git checkout intel-mediasdk-22.6.4
git switch -c v22.6.4
SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")"
set -e -o pipefail

# apply the patches
git am ../*.patch
mkdir -p "${SCRIPT_DIR}/MediaSDK"
curl -Lf "https://github.com/Intel-Media-SDK/MediaSDK/archive/refs/tags/intel-mediasdk-23.2.2.tar.gz" -o "${SCRIPT_DIR}/intel-mediasdk-22.6.4.tar.gz"
tar -zx --strip-components=1 -C "${SCRIPT_DIR}/MediaSDK" -f "${SCRIPT_DIR}/intel-mediasdk-22.6.4.tar.gz"
rm -f "${SCRIPT_DIR}/intel-mediasdk-22.6.4.tar.gz"
patch -d "${SCRIPT_DIR}/MediaSDK" -p1 -i <(cat "${SCRIPT_DIR}/"*.patch)

# build now
cmake -S . -B build -G Ninja -DENABLE_IMTL=ON
cmake --build build
cmake \
-S "${SCRIPT_DIR}/MediaSDK" \
-B "${SCRIPT_DIR}/build" \
-G Ninja \
-DENABLE_IMTL=ON \
-DCMAKE_INSTALL_PREFIX="${SCRIPT_DIR}/_install"
ninja -C "${SCRIPT_DIR}/build"
ninja -C "${SCRIPT_DIR}/build" install

echo "Use sample applications, found under path:"
echo "LD_LIBRARY_PATH=\"${LD_LIBRARY_PATH}:${SCRIPT_DIR}/_install/lib\""
echo "APPLICATION_PATH=\"${SCRIPT_DIR}/_install/share/mfx/samples/sample_encode\""
2 changes: 1 addition & 1 deletion gpu_direct/gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-FileCopyrightText: Copyright (c) 2024 Intel Corporation
*/

#include "gpu.h"
#include "./gpu.h"

// Macros for error checking
#define ZE_CHECK_ERROR(fn_call) \
Expand Down
2 changes: 1 addition & 1 deletion gpu_direct/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ int gpu_memset(GpuContext* ctx, void* dst, char byte, size_t sz);
void gpu_free_buf(GpuContext* ctx, void* buf);
int free_gpu_context(GpuContext* ctx);

#endif /* GPU */
#endif /* GPU */
Loading

0 comments on commit 50f41b8

Please sign in to comment.