提交 bba2072c 编写于 作者: H hanxinke

atune:add the gcc compilation example

上级 58d2b0c1
1. Prepare the environment
sh prepare.sh
2. download stream.c
wget http://www.cs.virginia.edu/stream/FTP/Code/stream.c
3. Start to tuning
atune-adm tuning --project gcc_compile --detail gcc_compile_client.yaml
4. Restore the environment
atune-adm tuning --restore --project gcc_compile
#!/bin/sh
# Copyright (c) 2020 Huawei Technologies Co., Ltd.
# A-Tune is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Create: 2020-09-01
path=$(
cd "$(dirname "$0")"
pwd
)
echo "current run path is $path"
tune=generic
option=O0
array_size=20000000
times=10
offset=1024
isarch=no
if [[ $isarch == "yes" ]]; then
arch="-march=native"
fi
isopenmp=no
if [[ $isopenmp == "yes" ]]; then
openmp="-fopenmp"
fi
gcc -mtune=$tune $arch -$option $openmp -DSTREAM_ARRAY_SIZE=$array_size -DNTIMES=$times -DOFFSET=$offset $path/stream.c -o $path/stream.o
$path/stream.o
echo "file size: `wc -c $path/stream.o`"
rm -rf $path/stream.o
project: "gcc_compile"
engine : "bayes"
iterations : 50
random_starts : 10
benchmark : "sh gcc_compile/gcc_compile.sh"
evaluations :
-
name: "bandwidth"
info:
get: "echo '$out' | grep 'Triad:' | awk '{print $2}'"
type: "negative"
weight: 80
-
name: "size"
info:
get: "echo '$out' | grep 'file size:' | awk '{print $3}'"
type: "positive"
weight: 20
project: "gcc_compile"
maxiterations: 500
startworkload: ""
stopworkload: ""
object :
-
name : "option"
info :
desc : "The gcc compilation options"
get : "cat gcc_compile/gcc_compile.sh | grep -i '^option=' | awk -F '=' '{print $2}'"
set : "sed -i 's/^option=.*/option=$value/g' gcc_compile/gcc_compile.sh"
needrestart : "false"
type : "discrete"
options :
- "O0"
- "O1"
- "O2"
- "O3"
- "Os"
- "Ofast"
dtype : "string"
-
name : "mtune"
info :
desc : "Tune to cpu-type everything applicable about the generated code"
get : "cat gcc_compile/gcc_compile.sh | grep -i '^tune=' | awk -F '=' '{print $2}'"
set : "sed -i 's/^tune=.*/tune=$value/g' gcc_compile/gcc_compile.sh"
needrestart : "false"
type : "discrete"
options :
- "generic"
- "native"
dtype : "string"
-
name : "march"
info :
desc : "Generate instructions for the machine type cpu-type"
get : "cat gcc_compile/gcc_compile.sh | grep -i '^isarch=' | awk -F '=' '{print $2}'"
set : "sed -i 's/^isarch=.*/isarch=$value/g' gcc_compile/gcc_compile.sh"
needrestart : "false"
type : "discrete"
options :
- "yes"
- "no"
dtype : "string"
-
name : "openmp"
info :
desc : "Adapts to multi-processor env, the defalut number of threads is the number of CPU threads after the function is enabled."
get : "cat gcc_compile/gcc_compile.sh | grep -i '^isopenmp=' | awk -F '=' '{print $2}'"
set : "sed -i 's/^isopenmp=.*/isopenmp=$value/g' gcc_compile/gcc_compile.sh"
needrestart : "false"
type : "discrete"
options :
- "yes"
- "no"
dtype : "string"
-
name : "offset"
info :
desc : "the array offset"
get : "cat gcc_compile/gcc_compile.sh | grep -i '^offset=' | awk -F '=' '{print $2}'"
set : "sed -i 's/^offset=.*/offset=$value/g' gcc_compile/gcc_compile.sh"
needrestart: "false"
type : "continuous"
scope :
- 1024
- 61440
dtype : "int"
#!/bin/sh
# Copyright (c) 2020 Huawei Technologies Co., Ltd.
# A-Tune is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Create: 2020-09-01
path=$(
cd "$(dirname "$0")"
pwd
)
echo "update the client and server yaml files"
sed -i "s#sh .*/gcc_compile.sh#sh $path/gcc_compile.sh#g" $path/gcc_compile_client.yaml
sed -i "s#-c .*/stream.o#-c $path/stream.o#g" $path/gcc_compile_client.yaml
sed -i "s#cat .*/gcc_compile.sh#cat $path/gcc_compile.sh#g" $path/gcc_compile_server.yaml
sed -i "s#' .*/gcc_compile.sh#' $path/gcc_compile.sh#g" $path/gcc_compile_server.yaml
echo "copy the server yaml file to /etc/atuned/tuning/"
cp $path/gcc_compile_server.yaml /etc/atuned/tuning/
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册