Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 28th, 2012  |  syntax: Bash  |  size: 3.66 KB  |  views: 34  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. #######
  4. #config
  5. #######
  6.  
  7.  
  8. cgminer_config_path="/home/bigmsi/.cgminer/"
  9. #filename for config files should be "test0.conf",
  10. #"test1.conf", "testX.conf" where X is device number
  11.  
  12. #intencity will not change during tests
  13. Intencity=9
  14.  
  15. #each iteration test time in seconds
  16. duration=180
  17.  
  18. #directory where to save result files
  19. results="test"
  20. #result files prefix
  21. prefix="test"
  22.  
  23.  
  24.  
  25. #ranges to test in
  26. kernel="diakgcn phatk diablo poclbm"
  27. worksize="64 128 256"
  28. vectors="1 2 4"
  29.  
  30. engine_clock_from=930
  31. engine_clock_to=930
  32. engine_clock_step=5
  33.  
  34. memclock_from=150
  35. memclock_to=300
  36. memclock_step=5
  37.  
  38.  
  39. #######
  40. #end config
  41. #######
  42.  
  43.  
  44. d=0
  45. if [ $# -ge 1 ]
  46. then
  47.   d=$1
  48. fi
  49.  
  50. cards=`./cgminer -n | grep "devices:" | sed 's/.*devices: //'`
  51.  
  52. if [ $d -ge $cards ]
  53. then
  54.   echo "Device number out of available range! Dev found: $cards"
  55.   exit 1
  56. fi
  57.  
  58.  
  59. makeParams()
  60. {
  61.   if [[ $d -eq 0 ]]
  62.   then
  63.     str="$1"
  64.   else
  65.     str="0"
  66.   fi
  67.  
  68.   if [[ $cards -gt 1 ]]
  69.   then
  70.     for i in $(seq 1 1 $(($cards - 1)))
  71.     do
  72.       if [[ $i -eq $d ]]
  73.       then
  74.         str="$str,$1"
  75.       else
  76.         str="$str,0"
  77.       fi
  78.     done
  79.   fi
  80.  
  81.   echo "$str"
  82. }
  83.  
  84.  
  85. engine=$(seq $engine_clock_from $engine_clock_step $engine_clock_to)
  86. meclock=$(seq $memclock_from $memclock_step $memclock_to)
  87.  
  88. sec_left=0
  89. tmp=`echo $kernel | wc -w`
  90. let "sec_left += tmp"
  91.  
  92. tmp=`echo $worksize | wc -w`
  93. let "sec_left *= tmp"
  94.  
  95. tmp=`echo $vectors | wc -w`
  96. let "sec_left *= tmp"
  97.  
  98. let "tmp = engine_clock_to - engine_clock_from"
  99. let "tmp /= engine_clock_step"
  100. if [ $tmp -eq 0 ]
  101. then
  102.   tmp=1
  103. fi
  104. let "sec_left *= tmp"
  105.  
  106.  
  107.  
  108. let "tmp = memclock_to-memclock_from"
  109. let "tmp /= memclock_step"
  110. if [ $tmp -eq 0 ]
  111. then
  112.   tmp=1
  113. fi
  114. let "sec_left *= tmp"
  115.  
  116. let "tmp = duration + 35"
  117. let "sec_left *= tmp"
  118.  
  119. mkdir $results
  120. mkdir $results/$prefix
  121.  
  122. #kernels
  123. for k in $kernel
  124. do
  125.   mkdir $results/$prefix/$k
  126.  
  127.   for w in $worksize
  128.   do
  129.     mkdir $results/$prefix/$k/w$w
  130.  
  131.         for v in $vectors
  132.     do
  133.       mkdir $results/$prefix/$k/w$w/v$v
  134.       for m in $meclock
  135.       do
  136.         mkdir $results/$prefix/$k/w$w/v$v/m$m
  137.         for e in $engine
  138.         do
  139.  
  140.                   let sec_left=sec_left-duration-35
  141.           echo "-v$v -w$w -k$k --gpu-memclock=$m --gpu-engine=$e"
  142.           etamin=$(( $sec_left / 60 ))
  143.           etasec=$(( $sec_left % 60 ))
  144.  
  145.  
  146.           printf "ETA:   %02d:%02d" $etamin $etasec
  147.           echo ""
  148.  
  149.           if [ -f $results/$prefix/$k/w$w/v$v/m$m/e$e.json ]
  150.           then
  151.             echo "File exist"
  152.             continue
  153.           fi
  154.                  
  155.           touch $results/$prefix/$k/w$w/v$v/m$m/e$e.json
  156.  
  157.           screen -dmS minertester$d ./cgminer -d$d --remove-disabled -c $cgminer_config_path/test$d.conf -v$v -w$w -k$k --gpu-memclock=$(makeParams $m) --gpu-engine=$(makeParams $e) -I$(makeParams $Intencity) --api-allow=W:127.0.0.1 --api-port=$((4029+$d))
  158.  
  159.           for sec in $(seq 0 5 $duration)
  160.           do
  161.             echo -ne " = Time left: $((180-$sec))           \r"
  162.             sleep 5
  163.           done
  164.  
  165.           echo '{"command":"summary","parameter":""}' | nc localhost -w1 $((4029+$d)) > $results/$prefix/$k/w$w/v$v/m$m/e$e.json
  166.           echo '{"command":"quit","parameter":""}' | nc localhost -w1 $((4029+$d)) >/dev/null
  167.           sleep 30
  168.  
  169.           if screen -ls | grep minertester$d
  170.           then
  171.             rm $results/$prefix/$k/w$w/v$v/m$m/e$e.json
  172.             touch reboot_required
  173.             echo $'X server hang. reboot required\a'
  174.             exit 1
  175.           fi
  176.         done
  177.         #done eng
  178.       done
  179.       #mem done
  180.     done
  181.     #done vectors
  182.   done
  183.   #done worksize
  184. done
  185. #done kernels
  186. echo "Done"
  187. exit 0