As an Amazon Associate I earn money from qualifying purchases.

Tuesday, December 10, 2013

CGMiner Optimal Thread Concurrency for R9 290/290X

Continuing from my previous post, I've now created a batch file to help find the optimal Thread Concurrency setting for R9 290/290X systems. The difficulty with doing this stems from the fact that normally exiting CGMiner on Windows with the new GPUs will cause a BSOD on most (all?) systems, so you can't use my other batch files. They work great on HD 7970/R9 280X and earlier systems, though, and last night I managed to increase my HD 7950 test system by 20KHash/sec per GPU. So how do we deal with R9 290/290X? We tweak things a bit and end up with some new batch files, which you can download via my Dropbox.

Instructions:

Extract the contents of that Zip file to your CGMiner folder (Windows only right now). There are five files inside, including three EXE files, but nothing dangerous; here's the quick summary of the EXE files.

Sleep.exe is a program that can be used in batch files to pause for a set amount of time (e.g. 300 seconds = "sleep 300").

Grep.exe is a common Unix program that allows you to search through files for matching strings; you can use "find" on Windows, but the output of CGMiner messes find up because it includes special characters.

Tail.exe is the last executable and it's also a port from Unix; it allows you to output the last few lines from a file (or a command); so "tail -1" gives the last line from a file or command.

I use the above three files in the batch files to help with creating a useful summary of the mining results for each thread concurrency. The two batch files are similar to before, but with some tweaks. Here's what they contain if you don't want to download:

thread-concurrency-test-r9version.bat
@echo off
set threadconcurrency=18000
set gpuclock=900
set memclock=1400
set gpufan=50-75
set gpuvolt=1.100
set gpupowertune=50

if exist currenttc.txt (
  for /F %%x in (currenttc.txt) do set threadconcurrency=%%x
)

:startloop
echo Current TC is %threadconcurrency%
echo %threadconcurrency%> currenttc.txt
start "MinerThread" miner-tc-r9version.bat %threadconcurrency% %gpuclock% %memclock% %gpufan% %gpuvolt% %gpupowertune%
sleep 300
taskkill /im cgminer.exe /f
<nul set /p =%threadconcurrency%: >> AvgHashrateTC.txt
grep -i "(avg)" %threadconcurrency%.txt | tail -1 >> AvgHashrateTC.txt
set /a threadconcurrency=threadconcurrency+64

goto :startloop
miner-tc-r9version.bat
@echo off
set threadconcurrency=%1
set gpuclock=%2
set memclock=%3
set gpufan=%4
set gpuvolt=%5
set gpupowertune=%6
cgminer --scrypt -o stratum+tcp://coinotron.com:3334 -u trogdorjw73.tester -p tester -w 256 -v 1 -I 20 -g 1 -T --gpu-engine %gpuclock% --gpu-memclock %memclock% --gpu-fan %gpufan% --gpu-vddc %gpuvolt% -- --temp-target 80 --temp-overheat 95 --temp-cutoff 99 --thread-concurrency %threadconcurrency% > %threadconcurrency%.txt
exit
The first files starts with some variables you can modify for clock speeds, starting thread concurrency, voltage, fan speed, and powertune. It the calls the second file (passing the variables along), which actually starts CGMiner running. Because we can't let CGMiner exit gracefully without a BSOD, the first file waits 300 seconds after starting the second file and then kills the CGMiner.exe process, at which point it uses the output from the mining results and grabs the last average hash rate, which ends up in a text file called AvgHashrateTC.txt.

So to use this, you first need to delete (or at least rename) your cgminer.conf file in your CGMiner folder, then extract the Zip file to the directory and just run thread-concurrency-test-r9version.bat and walk away (though you might want to tweak the clocks or other settings first). Come back in a day or so and look at your averages and you'll see something like the following:
18000: (29s):1.398M (avg):1.569Mh/s | A:640   R:0    HW:627  WU:616.8/m
18064: (29s):1.368M (avg):1.565Mh/s | A:1600  R:0    HW:710  WU:610.6/m
18128: (29s):1.264M (avg):1.585Mh/s | A:1600  R:0    HW:537  WU:608.4/m
18192: (29s):1.330M (avg):1.536Mh/s | A:1600  R:0    HW:600  WU:685.5/m
18256: (29s):1.409M (avg):1.575Mh/s | A:1920  R:320  HW:347  WU:707.8/m
18320: (29s):1.339M (avg):1.544Mh/s | A:2240  R:0    HW:467  WU:626.2/m
18384: (29s):537.3K (avg):1.357Mh/s | A:640   R:0    HW:384  WU:681.4/m
....
If all goes well, you will have a lot more lines than the above, but it's possible your system will crash during the testing. To get around that, the currently tested TC is spit out to a file which gets read when the first batch file starts. If you create a shortcut to thread-concurrency-test-r9version.bat and put that in your Startup folder, even after a crash/reboot the testing will pick up where it left off.

In the meantime, based on more experience with the GPUs, I'm recommending the Radeon R9 290 over the R9 290X for Windows users -- you can probably get closer to 1000KHash/sec on the 290X with Linux, but on Windows it can be rather difficult. Also, the default voltage used on your GPU will affect your ability to hit higher clocks and hash rates -- lower voltages being better.

Donations gladly accepted if this helps you out:
LTC: LXpEZcNJtikd263z7Ha3vrdYDcLU7hiKWv
Go win some LTC!

21 comments:

  1. Hi Jarred,

    Thank you for the tools. All worked well (clock test and memtest). However, the TC test keeps giving errors.

    All goes well with the first calculation at 20000 TC. Succesfully terminated PID 2368... The data also appears in avghashratetc .. but then I get the following errors:

    ''Error: the process ''cgminer.exe'' not found.
    Grep: 20064.txt: no such file or directory. Also with 20128 etc etc.

    And the data is not stored in the AvghashrateTC.txt

    Starting from 20128 TC I get ''succes: the process ''cgminer.exe'' with PID 2368 has been terminated... followed by the same errors.

    ReplyDelete
    Replies
    1. This should be fixed with the updated version. If not, let me know!

      Delete
  2. I've tried changed my voltages, I've tweaked the memory and clockrates myself, and I've honed in on my thread concurrency, yet all three cards (2 Asus 290x, 1 XFX 290x) are about 875 Khash.

    I don't know what kind of magic you're working to get over 900, but I'd love to see you're actually values. I know they very from card to card and platform to platform, but I just can't seem to reach those levels.

    Also, using GPU-Z, my VDDC is always around 1.063 - 1.070 no matter what I set the VDDC in my .conf file. Does the "set gpuvolt=1.100" do something different than the VDDC line in the .conf file?

    ReplyDelete
    Replies
    1. Put a big fan on top of your rig (or next to it) and see if that helps. :-)

      Delete
  3. I have the r9 290x and it was working great around 890 khs and higher, but now for some reason the engine clock wont stay where i put it! i set it to 990 and it drops down to 831, i have tried multiple cg miners and i dont have any overclocking setting software running while its running, i have trixx installed and i couldnt find the setting you were talking about speciially for the r9 290x i have the saphire if that helps. Thanks for all the work you have done it has helped alot.

    ReplyDelete
  4. Hi Jarrad should I disconnect the other cards before I run the test for one single card or just used the "device " command after "cgminer" ,say device 0 for one test then change to device 1 for the second .
    Also I just ran with device 0 while all other cards are connectd and when I checked out the AvgEnginrClock.txt , it showed the total speed of 6 cards. So how should I find out which one is the best engine clock for device 0? Is it the one with fastest

    ReplyDelete
    Replies
    1. Use the device [number] along with "--remove-disabled" and you should only see results for the one GPU (or however many GPUs are enabled).

      Delete
    2. Hi Jarrad. Before i saw your reply i left my rig running to find out the memclock (no "--remove-disabled, so for 6 cards") then my wife told me the rig stopped working. Black screen. Hence i came back home after work and reboot the rig then it jumped in Windows however it went Black Screen again in 1 min after it loaded on.
      I use Ghost to recover the system to what it was 3 day ago(it was mining so it will be all good) Then i started mining using my previous setting and it says

      Maximum buffer memory device 0 support says 536870912
      Your scrypt settings come to 2004877312
      Error -61cICreateBuffer(padbuffer 8), decrease TC or increase LG
      Failed to init GPU thread 0, disabling device 0


      Then i tried to remove everything just leave i-20 and it worked however when I tried to add any TC it showed the same error message. Looks like the TC setting has been disabled? It was mining all good at this setting TC 24450 then after I used your programmes now I couldn't set any TC. Any ideas? Urgent~

      Delete
    3. The "maximum buffer memory..." error comes up if you haven't run:

      setx GPU_MAX_ALLOC_PERCENT 100

      from a command prompt at least once. If you use system restore, it will roll things back so that environment variables get cleared.

      Note that if you're overclocking, sometimes the OC will "stick" at unstable values. If this has happened and you're getting the black screen, using MSI Afterburner or even AMD's Catalyst Control Center to restore the original clocks can clear the error.

      Delete
  5. Hi Jarred,

    Thank you for the tools, helps a lot.

    I have 2 x XFX R9 290, and I get bad results with TC+64, max avg.hash 1.55-1.65 MH/s, max accepted shares 4096-8192 in test.
    When I put tc+68, results comes with max avg hash 1.73-1.81 MH/s, max accepted shares 6144-13824. With tc+72 avg.hash drops to 1.65-1.75 MH/s max accepted shares 4096-12800.

    There's still slight difference in accept shares between cards with same TC in both cards, other card gets accepted shares half faster than other.

    Question is, how do I get individual stats for both cards in avgHash.txt? so I could pick the best TC for both card.
    What changes need to be made in concurrency-test batch file or r9 miner batch file?

    Thank you for you help!

    ReplyDelete
    Replies
    1. You can look at the [TC setting].txt files for the specific results of the two cards. It might not be a bad idea to run the tests for longer than 300 seconds on each iteration as well. As noted above, you can also add "-d 0 --remove-disabled" to only test device 0, or "-d 1 --remove-disabled" to only test device 1, etc.

      Delete
  6. Jarred, thank you for this helpful tool. One of my R9 came out with an optimum TC of 20544 @ 890Kh/s. Who would have thought? With TC 22400 it goes all the way to 930Kh/s but eventually comes back down to 830Kh/s stable.
    Also, I'm experiencing more stable runs using cgminer 3.1.1 and 3.3.1. I think 3.7.2 might be good for R9s only, and when combined with older cards, 3.7.2 has been very unstable for me.

    I need to tweak a 7770, 7850 and 7950. Do you know anyone who has a script like yours for these cards? I'm about to attempt modifying yours to suit these cards but maybe there is already a script out there.

    Best and happy new year!

    ReplyDelete
    Replies
    1. It's pretty easy to edit the scripts to worth with other cards. Basically, if you're going to run it on an HD 7770, 7850, 7950, etc. just go look up the "stock" clocks for the cards as well as running something like MSI Afterburner to see if you can find the voltage. Then edit the first six or so lines of the thread-concurrency-test.bat, engine-clock-test-r9version.bat, and/or miner-ram-r9version.bat files to adjust those values as appropriate. You can also tweak the TC step from 64 to 32 or 16 or whatever as well if you want to really try to fine-tune things.

      Delete
    2. Thanks. That's what I tried and at first it worked for about 5 different TCs but then cgminer started crashing. I rebooted but now it won't even start as cgminer closes immediately.
      I discovered TC 22456 @ 610Khz, the highest yet for me. AMD website says this 7950 has 28 procesing units, not 32. It seems to me that the best TCs are the lowest ones as soon as I start hitting HW:0. I still can't get close to the 700Khz mark on this PowerColor Radeon HD7950 880 MHz 3GB DDR5 PCI-Express 3.0 x16 Graphics Cards AX7950 3GBD5-2DHPP.

      Delete
    3. The TC testing does store the last value in a fill called "currenttc.txt", so if you're crashing try deleting that file and start over. It's possible your rig just doesn't like higher TC, or perhaps there's some other issue in one of the batch files. It might help to run directly at a command prompt so you can read any error messages:

      Start->Run (Windows+R) "cmd"
      cd [cgminer folder]
      thread-concurrency-test-r9version.bat

      As far as hashing rates, 7950 should do 600-640KHash max while 7970 (280X) can get 700-730KHash max. The 7950 has 28 CUs compared to 32 CUs on the 7970. Hope that helps.

      Delete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Jared, dumb question, but you didn't say what you're looking for in the results. Is it the result with the highest hash rate? or the lowest err count? which stat do we look for when picking a line to use for TC?

    Thanks!

    ReplyDelete
  9. Hi Jarred
    Please help, I just set up my rig with 3 Sapphire R9 290x. I installed AMD Catalyst 13.11 AMD-APP-SDK V2.7 and drivers for the Sapphire video cards. I tried to us GUIMiner-Scrypt alpha and CGMiner 3.7.2. I keep on having my GPU fail.2014-01-15 22:11:04: Listener for "Default": [2014-01-15 22:11:00] Started cgminer 3.7.2

    2014-01-15 22:11:04: Listener for "Default": [2014-01-15 22:11:01] Probing for an alive pool
    2014-01-15 22:11:04: Listener for "Default": [2014-01-15 22:11:01] Pool 0 difficulty changed to 320
    2014-01-15 22:11:04: Listener for "Default": [2014-01-15 22:11:02] Network diff set to 3.93K
    2014-01-15 22:11:04: Listener for "Default": [2014-01-15 22:11:02] Error -4: Enqueueing kernel onto command queue. (clEnqueueNDRangeKernel)
    2014-01-15 22:11:04: Listener for "Default": [2014-01-15 22:11:02] GPU 0 failure, disabling!
    2014-01-15 22:11:04: Listener for "Default": (1s):0.000 (avg):0.000h/s | A:0 R:0 HW:0 WU:0.0/m

    ReplyDelete
  10. Hi

    Lots of people started to get this kerneşl error. Some says its because of power , some says its because of SDK. Today I saw in a forum , one of the guy is saying he removed the SDK and it solved. I have the same problem and will test tonight. Hope this helps

    Murat

    ReplyDelete
  11. Hi again,

    My friend solved the kernel issue replacing the downloaded driver from AMD with the driver comes with HW.


    BR
    Murat

    ReplyDelete