aboutsummaryrefslogtreecommitdiff
path: root/bestflags/examples/omnetpp/build_omnetpp
blob: 35e9ec13a43d9d88d2efbb6087f6cfbd49cb0d18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash -x

cd examples/omnetpp/cpu2006-redhat-ia32

# Contains the optimization flags.
flags=''

# The index of the parameter.
i=1

# Indicate whether it is parsing the gcc param.
in_gcc_param=false

for parameter in "$@"
  do
    #  The last parameter is the file name.
    if [ "$i" == "$#" ]; then
      file=$parameter
      break
    fi

    # The param is not a flag, it combines with the flag that comes right after.
    # For example, --param max-inline-insns-single 
    if [ "$parameter" == "-param" ]; then
      in_gcc_param=true
      flags+=-$parameter' '
      let i++
      continue
    fi

    # In in_gcc_param section, this flag follows the key word '--param'.
    if [ $in_gcc_param == true ]; then
      flags+=$parameter' '
      let i++
      in_gcc_param=false
      continue
    fi

    # Normal flags.
    flags+=-$parameter' '
    let i++
  done

# Change the configuration file.
content=$(sed s/amd64-m64-gcc41-kk/test$file/ config/linux64-amd64-pgi.cfg)
echo "$content" | sed s/-O2/-O1\ "$flags"/ >config/linux64-amd64-pgi$file.cfg
. ./shrc
/usr/bin/time -o temp$file runspec --config linux64-amd64-pgi$file -D --action=build  471.omnetpp

state=$?

outfile="./benchspec/CPU2006/471.omnetpp/run/build_base_test$file.0000/omnetpp"

if [ $state -eq 0 ];then
  user_time=$(cat build_timer$file | grep "user" | cut -d "u" -f 1)
  output_file="$file"

  checksum=$(readelf -x .text $outfile | md5sum | cut -d " " -f 1)
  file_size=$(ls -l $outfile | cut -d " " -f 5)
  text_section=$(readelf -SW $outfile | grep ".text")
  size_hex=$(echo $text_section | sed "s/\s\{1,\}/\ /g" | cut -d ' ' -f 6)
  size=$(echo $size_hex | ( echo "ibase=16" ; tr '[:lower:]' '[:upper:]') | bc)

  echo $checksum $user_time $output_file $file_size $size
else
  echo "error" "error" "error" "error" "error"
fi

return $state