Title: Utility to find the best GPU / MEM clock combination Post by: mzahor on November 10, 2013, 01:31:46 PM Hi guys, I've created little PHP script that will walk through GPU / MEM freq. combinations and log
hashrate to text file. It will use aticonfig for GPU/MEM freq. modification and cgminer's API to chech hash rate. Usage php ./findOptimalFreq.php gpu_id gpu_from gpu_to memory_from memory_to freq_increment delay_sec GPU_ID - it's ID under which aticonfig sees the card [ you can list cards with aticonfig --lsa ] [ cgminer must see it under same number ] gpu_from - testing freq. from [ example 900 ] gpu_to - testing to memory_from - testing memory from memory_to - testing memory to freq_increment - step size [ example 2 ] delay_sec - delay between changing freq. and measuring hash rate [ 10-15 seems to be good ] Output goes to ./testGPU'datetime'.txt If you find it useful consider donation: BTC: 12XEVHYjYzhpNmoZmGgrWVsnzZPe25ceY3 LTC: LTaUDmmBVvRkZ7XzpMznV5WNvjgD15GDJv save it as findOptimalFreq.php ------ <?php # # Sample Socket I/O to CGMiner API # function getsock($addr, $port) { $socket = null; $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket === false || $socket === null) { $error = socket_strerror(socket_last_error()); $msg = "socket create(TCP) failed"; echo "ERR: $msg '$error'\n"; return null; } $res = socket_connect($socket, $addr, $port); if ($res === false) { $error = socket_strerror(socket_last_error()); $msg = "socket connect($addr,$port) failed"; echo "ERR: $msg '$error'\n"; socket_close($socket); return null; } return $socket; } # # Slow ... function readsockline($socket) { $line = ''; while (true) { $byte = socket_read($socket, 1); if ($byte === false || $byte === '') break; if ($byte === "\0") break; $line .= $byte; } return $line; } # function request($cmd) { $socket = getsock('127.0.0.1', 4028); if ($socket != null) { socket_write($socket, $cmd, strlen($cmd)); $line = readsockline($socket); socket_close($socket); if (strlen($line) == 0) { echo "WARN: '$cmd' returned nothing\n"; return $line; } print "$cmd returned '$line'\n"; if (substr($line,0,1) == '{') return json_decode($line, true); $data = array(); $objs = explode('|', $line); foreach ($objs as $obj) { if (strlen($obj) > 0) { $items = explode(',', $obj); $item = $items[0]; $id = explode('=', $items[0], 2); if (count($id) == 1 or !ctype_digit($id[1])) $name = $id[0]; else $name = $id[0].$id[1]; if (strlen($name) == 0) $name = 'null'; if (isset($data[$name])) { $num = 1; while (isset($data[$name.$num])) $num++; $name .= $num; } $counter = 0; foreach ($items as $item) { $id = explode('=', $item, 2); if (count($id) == 2) $data[$name][$id[0]] = $id[1]; else $data[$name][$counter] = $id[0]; $counter++; } } } return $data; } return null; } # if (isset($argv) and count($argv) > 1) { // $r = request($argv[1]); $gpu_id = $argv[1]; $engine_from = $argv[2]; $engine_to = $argv[3]; $memory_from = $argv[4]; $memory_to = $argv[5]; $increment = $argv[6]; $delay_sec = $argv[7]; } else { // $r = request('summary'); # //echo print_r($r, true)."\n"; echo "Usage: php ./findOptimalFreq.php gpu_id gpu_from gpu_to memory_from memory_to freq_increment delay_sec\n"; return 0; } # $myFile = "./testGPU".date("Y-m-d H:i:s").".txt"; $fh = fopen($myFile, 'w'); $output = ""; for ($engine = $engine_from ; $engine <= $engine_to ; $engine += $increment ) { for ( $memory = $memory_from ; $memory <= $memory_to ; $memory += $increment ) { echo "ENGINE: $engine , MEMORY: $memory\n"; $output = "$engine,$memory,"; system("aticonfig --adapter=$gpu_id --od-setclocks=$engine,$memory"); sleep($delay_sec); $r = request("{\"command\":\"gpu\",\"parameter\":\"$gpu_id\"}"); echo $r['GPU'][0]['MHS 5s']; $output .= $r['GPU'][0]['MHS 5s']; $output .= "\n"; fwrite($fh, $output); } } fclose($fh); ?> Title: Re: Utility to find the best GPU / MEM clock combination Post by: rampalija on November 11, 2013, 11:43:18 PM you should explain it a little more details
|