granularity.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2008, 2009, 2010 Université de Bordeaux 1
  5. # Copyright (C) 2010 Centre National de la Recherche Scientifique
  6. #
  7. # StarPU is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU Lesser General Public License as published by
  9. # the Free Software Foundation; either version 2.1 of the License, or (at
  10. # your option) any later version.
  11. #
  12. # StarPU is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. #
  16. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. DIR=$PWD
  18. ROOTDIR=$DIR/../..
  19. SAMPLINGDIR=$DIR/sampling/
  20. TIMINGDIR=$DIR/timing/
  21. maxiter=5
  22. MINSIZE=$((30*1024))
  23. MAXSIZE=$((31*1024))
  24. trace_granularity()
  25. {
  26. grain=$1
  27. echo "GRAIN $grain"
  28. #minblocks=1
  29. minblocks=$(($MINSIZE/$grain))
  30. #maxblocks=2
  31. maxblocks=$(($MAXSIZE/$grain))
  32. if test $maxblocks -ge 128; then
  33. maxblocks=128
  34. fi
  35. #step=2
  36. # step=$((2048/$grain))
  37. step=$((4096/$grain))
  38. for blocks in `seq $minblocks $step $maxblocks`
  39. do
  40. size=$(($blocks*$grain))
  41. echo "size : $size (grain $grain nblocks $blocks)"
  42. calibrate_grain $grain $size
  43. OPTIONS="-pin -nblocks $blocks -size $size -v3"
  44. filename=$TIMINGDIR/granularity.$grain.$size
  45. #rm -f $filename
  46. for iter in `seq 1 $maxiter`
  47. do
  48. echo "$iter / $maxiter"
  49. val=`STARPU_NCPUS=8 STARPU_NCUDA=3 STARPU_SCHED="dmda" STARPU_PREFETCH=1 STARPU_CALIBRATE=1 $ROOTDIR/examples/heat/heat $OPTIONS 2> /dev/null`
  50. echo "$val"
  51. echo "$val" >> $filename
  52. done
  53. done
  54. }
  55. trace_granularity_hybrid()
  56. {
  57. grain=$1
  58. echo "GRAIN $grain"
  59. #minblocks=1
  60. minblocks=$(($MINSIZE/$grain))
  61. #maxblocks=2
  62. maxblocks=$(($MAXSIZE/$grain))
  63. if test $maxblocks -ge 64; then
  64. maxblocks=64
  65. fi
  66. #step=2
  67. step=$((2048/$grain))
  68. for blocks in `seq $minblocks $step $maxblocks`
  69. do
  70. size=$(($blocks*$grain))
  71. ntheta=$(( $(($size/32)) + 2))
  72. echo "size : $size (grain $grain nblocks $blocks)"
  73. OPTIONS="-pin -nblocks $blocks -ntheta $ntheta -nthick 34 -v4"
  74. filename=$TIMINGDIR/hybrid.$grain.$size
  75. #rm -f $filename
  76. for iter in `seq 1 $maxiter`
  77. do
  78. echo "$iter / $maxiter"
  79. val=`STARPU_SCHED="dmda" STARPU_PREFETCH=1 STARPU_CALIBRATE=1 $ROOTDIR/examples/heat/heat $OPTIONS 2> /dev/null`
  80. echo "$val"
  81. echo "$val" >> $filename
  82. done
  83. done
  84. }
  85. calibrate_grain()
  86. {
  87. grain=$1
  88. size=$2
  89. echo "Calibrating grain $grain size $size ($blocks blocks)"
  90. rm -f $SAMPLINGDIR/*
  91. OPTIONS="-pin -nblocks $blocks -size $size -v3"
  92. STARPU_NCUDA=3 STARPU_NCPUS=8 STARPU_CALIBRATE=1 STARPU_SCHED="dm" $ROOTDIR/examples/heat/heat $OPTIONS 2> /dev/null
  93. STARPU_NCUDA=3 STARPU_NCPUS=8 STARPU_CALIBRATE=1 STARPU_PREFETCH=1 STARPU_SCHED="dmda" $ROOTDIR/examples/heat/heat $OPTIONS 2> /dev/null
  94. STARPU_NCUDA=3 STARPU_NCPUS=8 STARPU_CALIBRATE=1 STARPU_PREFETCH=1 STARPU_SCHED="dmda" $ROOTDIR/examples/heat/heat $OPTIONS 2> /dev/null
  95. STARPU_NCUDA=3 STARPU_NCPUS=8 STARPU_CALIBRATE=1 STARPU_PREFETCH=1 STARPU_SCHED="dmda" $ROOTDIR/examples/heat/heat $OPTIONS 2> /dev/null
  96. STARPU_NCUDA=3 STARPU_NCPUS=8 STARPU_CALIBRATE=1 STARPU_PREFETCH=1 STARPU_SCHED="dmda" $ROOTDIR/examples/heat/heat $OPTIONS 2> /dev/null
  97. STARPU_NCUDA=3 STARPU_NCPUS=8 STARPU_CALIBRATE=1 STARPU_PREFETCH=1 STARPU_SCHED="dmda" $ROOTDIR/examples/heat/heat $OPTIONS 2> /dev/null
  98. }
  99. mkdir -p $TIMINGDIR
  100. mkdir -p $SAMPLINGDIR
  101. #rm -f $SAMPLINGDIR/*
  102. #grainlist="64 128 256 512 768 1024 1536 2048"
  103. #grainlist="1024 2048 1024 512 256"
  104. grainlist="256 32 64 128 256 512 1024 2048 4096"
  105. export STARPU_PERF_MODEL_DIR=$SAMPLINGDIR
  106. cd $ROOTDIR
  107. cd $DIR
  108. # calibrate (sampling)
  109. # for grain in $grainlist
  110. # do
  111. # calibrate_grain $grain;
  112. # # calibrate_grain $(( $grain / 2));
  113. # done
  114. # perform the actual benchmarking now
  115. for grain in $grainlist
  116. do
  117. # trace_granularity_hybrid $grain;
  118. trace_granularity $grain;
  119. # trace_granularity_nomodel $grain;
  120. done