You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
3.2 KiB

  1. #!/bin/bash
  2. # ./run.sh gemm
  3. # ./run.sh lazy_gemm
  4. # Examples of environment variables to be set:
  5. # PREFIX="haswell-fma-"
  6. # CXX_FLAGS="-mfma"
  7. # Options:
  8. # -up : enforce the recomputation of existing data, and keep best results as a merging strategy
  9. # -s : recompute selected changesets only and keep bests
  10. bench=$1
  11. if echo "$*" | grep '\-up' > /dev/null; then
  12. update=true
  13. else
  14. update=false
  15. fi
  16. if echo "$*" | grep '\-s' > /dev/null; then
  17. selected=true
  18. else
  19. selected=false
  20. fi
  21. global_args="$*"
  22. if [ $selected == true ]; then
  23. echo "Recompute selected changesets only and keep bests"
  24. elif [ $update == true ]; then
  25. echo "(Re-)Compute all changesets and keep bests"
  26. else
  27. echo "Skip previously computed changesets"
  28. fi
  29. if [ ! -d "eigen_src" ]; then
  30. hg clone https://bitbucket.org/eigen/eigen eigen_src
  31. else
  32. cd eigen_src
  33. hg pull -u
  34. cd ..
  35. fi
  36. if [ ! -z '$CXX' ]; then
  37. CXX=g++
  38. fi
  39. function make_backup
  40. {
  41. if [ -f "$1.out" ]; then
  42. mv "$1.out" "$1.backup"
  43. fi
  44. }
  45. function merge
  46. {
  47. count1=`echo $1 | wc -w`
  48. count2=`echo $2 | wc -w`
  49. if [ $count1 == $count2 ]; then
  50. a=( $1 ); b=( $2 )
  51. res=""
  52. for (( i=0 ; i<$count1 ; i++ )); do
  53. ai=${a[$i]}; bi=${b[$i]}
  54. tmp=`echo "if ($ai > $bi) $ai else $bi " | bc -l`
  55. res="$res $tmp"
  56. done
  57. echo $res
  58. else
  59. echo $1
  60. fi
  61. }
  62. function test_current
  63. {
  64. rev=$1
  65. scalar=$2
  66. name=$3
  67. prev=""
  68. if [ -e "$name.backup" ]; then
  69. prev=`grep $rev "$name.backup" | cut -c 14-`
  70. fi
  71. res=$prev
  72. count_rev=`echo $prev | wc -w`
  73. count_ref=`cat $bench"_settings.txt" | wc -l`
  74. if echo "$global_args" | grep "$rev" > /dev/null; then
  75. rev_found=true
  76. else
  77. rev_found=false
  78. fi
  79. # echo $update et $selected et $rev_found because $rev et "$global_args"
  80. # echo $count_rev et $count_ref
  81. if [ $update == true ] || [ $count_rev != $count_ref ] || ([ $selected == true ] && [ $rev_found == true ]); then
  82. if $CXX -O2 -DNDEBUG -march=native $CXX_FLAGS -I eigen_src $bench.cpp -DSCALAR=$scalar -o $name; then
  83. curr=`./$name`
  84. if [ $count_rev == $count_ref ]; then
  85. echo "merge previous $prev"
  86. echo "with new $curr"
  87. else
  88. echo "got $curr"
  89. fi
  90. res=`merge "$curr" "$prev"`
  91. # echo $res
  92. echo "$rev $res" >> $name.out
  93. else
  94. echo "Compilation failed, skip rev $rev"
  95. fi
  96. else
  97. echo "Skip existing results for $rev / $name"
  98. echo "$rev $res" >> $name.out
  99. fi
  100. }
  101. make_backup $PREFIX"s"$bench
  102. make_backup $PREFIX"d"$bench
  103. make_backup $PREFIX"c"$bench
  104. cut -f1 -d"#" < changesets.txt | grep -E '[[:alnum:]]' | while read rev
  105. do
  106. if [ ! -z '$rev' ]; then
  107. echo "Testing rev $rev"
  108. cd eigen_src
  109. hg up -C $rev > /dev/null
  110. actual_rev=`hg identify | cut -f1 -d' '`
  111. cd ..
  112. test_current $actual_rev float $PREFIX"s"$bench
  113. test_current $actual_rev double $PREFIX"d"$bench
  114. test_current $actual_rev "std::complex<double>" $PREFIX"c"$bench
  115. fi
  116. done
  117. echo "Float:"
  118. cat $PREFIX"s"$bench.out"
  119. echo ""
  120. echo "Double:"
  121. cat $PREFIX"d"$bench.out"
  122. echo ""
  123. echo "Complex:"
  124. cat $PREFIX"c"$bench.out"
  125. echo ""
  126. ./make_plot.sh $PREFIX"s"$bench $bench
  127. ./make_plot.sh $PREFIX"d"$bench $bench
  128. ./make_plot.sh $PREFIX"c"$bench $bench