run.sh 1.3 KB
Newer Older
J
jiakai 已提交
1 2
#!/bin/bash -e
# $File: run.sh
王博文 已提交
3 4 5 6 7 8 9
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
J
jiakai 已提交
10 11 12 13 14

cd $(dirname $0)

MAKE="make -f Makefile.impl"

15 16 17 18 19
if [ "$1" = "--clean" ]; then
    rm -rf build main*
    echo "clean finished"
    exit 0
fi
J
jiakai 已提交
20

J
jiakai 已提交
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
$MAKE TARGET=main_prof CXXFLAGS=-DMIDOUT_PROFILING BUILD_DIR=build/prof

rm -rf output
mkdir -p output
cd output
ln -sv ../main_prof main

if [ "$1" = "-i" ]; then
    cat <<EOF
--------------------------------------------------------------------------------
You would be dropped into a shell now; you can run ./main with some opr mode,
and unused modes would be stripped in the next build.
EOF
    bash
else
36
    ./main 1 1 p
J
jiakai 已提交
37 38 39 40 41 42 43
fi

cd ..

./gen_header.py -o output/midout_gen.h output/midout_trace.*

$MAKE V= TARGET=main_midout \
J
jiakai 已提交
44
    CXXFLAGS='-include output/midout_gen.h' BUILD_DIR=build/run
J
jiakai 已提交
45 46 47 48 49 50 51 52 53 54 55 56

$MAKE TARGET=main_vanilla BUILD_DIR=build/vanilla

function print_stat {
    echo "$1: $(stat -c '%s' $2)"
    nm $2 | c++filt | grep calc | sed -e 's/^/  /'
}


echo "-----------------"
print_stat vanilla main_vanilla
print_stat midout main_midout