diff --git a/tools/stream/tst-build.sh b/tools/stream/tst-build.sh index 3a5b725c5e484b6747046a14a338c3cbdb1d3be4..a5e207a0b9c0c5c7de6b04440b26602a978f81ca 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 }