From c777055c0886df858371a4aba9659d7189baf3f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=AD=E5=A4=A7=E6=B7=98=E6=B2=99?= Date: Fri, 3 Apr 2026 16:24:09 +0800 Subject: [PATCH] modify stream/tst-build.sh to avoid compilation errors --- tools/stream/tst-build.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/stream/tst-build.sh b/tools/stream/tst-build.sh index 3a5b725..a5e207a 100755 --- a/tools/stream/tst-build.sh +++ b/tools/stream/tst-build.sh @@ -23,16 +23,29 @@ build_tool() { nr_node="$(grep "^physical id" /proc/cpuinfo | sort | uniq | wc -l)" [ -z "$nr_node" ] && nr_node=2 [ "$nr_node" -lt 1 ] && nr_node=2 + local cache_size_kb cache_size_kb="$(cat /sys/devices/system/cpu/cpu0/cache/index*/size | grep -o "[0-9]\+" | sort -n | tail -n 1)" [ -z "$cache_size_kb" ] && cache_size_kb=$((32 * 1024)) [ "$cache_size_kb" -lt $((32 * 1024)) ] && cache_size_kb=$((32 * 1024)) + local STREAM_ARRAY_SIZE=$((cache_size_kb * 1024 * 5 * nr_node / 8)) echo "nr_node=$nr_node, cache_size_kb=$cache_size_kb, STREAM_ARRAY_SIZE=$STREAM_ARRAY_SIZE" + # 判断3个double数组总大小是否超过2GB,超过则需要 -mcmodel=large + # 3 arrays × STREAM_ARRAY_SIZE × 8 bytes > 2GB => STREAM_ARRAY_SIZE > 89478485 + local mcmodel_flag="" + if [ "$STREAM_ARRAY_SIZE" -gt 89478485 ]; then + mcmodel_flag="-mcmodel=large" + echo "STREAM_ARRAY_SIZE exceeds 2GB limit, add $mcmodel_flag" + fi + cp -r "$g_tool_dir" "$g_install_dir/build" || return 1 cd "$g_install_dir/build" \ && sed -i "s|STREAM_ARRAY_SIZE=50000000|STREAM_ARRAY_SIZE=${STREAM_ARRAY_SIZE}|g" ./Makefile \ + && if [ -n "$mcmodel_flag" ]; then + sed -i "s|-O3|-O3 ${mcmodel_flag}|g" ./Makefile + fi \ && make -j } -- Gitee