Bitcoin Mining with Open Source Drivers

* Update all the code necessary to run bfgminer has been pushed upstream

On Monday, I started to work on getting one of the many bitcoin mining applications, bfgminer, to work with clover and r600g.  Since then, I have uncovered and fixed a number of bugs in the compute stack and now with some final bug fixes from R600 backend developer Vincent Lejeune, I have bfgminer working with the Open Source drivers! (Also, thanks to Aaron Watry for implementing the rotate builtin for libclc!)

If anyone is interested in testing, you can follow the installation instructions for gallium compute here, and instead of the standard branches listed in the instructions checkout r179204 from the clang tree, and use the bfgminer branch from the following repos:


Additionally, you will need to invoke bfgminer using the command line options in this script (you will need to modify the script to add your preferred bitcoin address). Currently, bfgminer will only work on Evergreen and non-Cayman Northern Islands GPUs.

There is still one bug that will occasionally cause a hash value to be miscalculated.  When this happens, bfgminer will report a hw error, but this is not serious and the program will continue to run.

The compiled kernel code for bfgminer is not very well optimized yet and there are still a lot of things that can be done to improve performance.  For now, I’m going to work on getting these patches upstream and writing some piglit tests for the bugs, but maybe in the future I’ll have some time take a closer look at the kernel performance.  I have a few ideas for things to do to improve performance, so if anyone is interested in playing around with the code, just ping me on irc.  My nick is tstellar, and I’m usually in #radeon and #dri-devel on  There may even be a few things that would make good Google Summer of Code projects for any students out there interested in GPU performance and/or bitcoin.

* Update: bfgminer now autodetects the Mesa platform, so the bfgminer patch is no longer required.

5 thoughts on “Bitcoin Mining with Open Source Drivers

  1. Should this work with clang’s trunk? I tried that for my 6850 but my GPU always locks up. The following happens about once every 14 seconds when I run your bfgminer script.

    94.140564] radeon 0000:01:00.0: GPU lockup CP stall for more than 10000msec
    94.140569] radeon 0000:01:00.0: GPU lockup (waiting for 0x000000000000079b last fence id 0x000000000000079a)
    94.141649] radeon 0000:01:00.0: Saved 503 dwords of commands on ring 0.
    94.141654] radeon 0000:01:00.0: GPU softreset: 0x00000003
    94.149060] radeon 0000:01:00.0: GRBM_STATUS = 0xB0633828
    94.149063] radeon 0000:01:00.0: GRBM_STATUS_SE0 = 0x18000007
    94.149066] radeon 0000:01:00.0: GRBM_STATUS_SE1 = 0x18000007
    94.149069] radeon 0000:01:00.0: SRBM_STATUS = 0x200000C0
    94.149072] radeon 0000:01:00.0: R_008674_CP_STALLED_STAT1 = 0x00000000
    94.149075] radeon 0000:01:00.0: R_008678_CP_STALLED_STAT2 = 0x400C0000
    94.149078] radeon 0000:01:00.0: R_00867C_CP_BUSY_STAT = 0x00058006
    94.149081] radeon 0000:01:00.0: R_008680_CP_STAT = 0x80268647
    94.149083] radeon 0000:01:00.0: GRBM_SOFT_RESET=0x00007F6B
    94.149138] radeon 0000:01:00.0: GRBM_STATUS = 0x00003828
    94.149141] radeon 0000:01:00.0: GRBM_STATUS_SE0 = 0x00000007
    94.149144] radeon 0000:01:00.0: GRBM_STATUS_SE1 = 0x00000007
    94.149146] radeon 0000:01:00.0: SRBM_STATUS = 0x200000C0
    94.149149] radeon 0000:01:00.0: R_008674_CP_STALLED_STAT1 = 0x00000000
    94.149152] radeon 0000:01:00.0: R_008678_CP_STALLED_STAT2 = 0x00000000
    94.149155] radeon 0000:01:00.0: R_00867C_CP_BUSY_STAT = 0x00000000
    94.149158] radeon 0000:01:00.0: R_008680_CP_STAT = 0x00000000
    94.166612] radeon 0000:01:00.0: GPU reset succeeded, trying to resume
    94.189141] [drm] probing gen 2 caps for device 8086:101 = 2/0
    94.189146] [drm] PCIE gen 2 link speeds already enabled
    94.191198] [drm] PCIE GART of 512M enabled (table at 0x0000000000040000).
    94.191293] radeon 0000:01:00.0: WB enabled
    94.191295] radeon 0000:01:00.0: fence driver on ring 0 use gpu addr 0x0000000040000c00 and cpu addr 0xffff88041c7adc00
    94.191296] radeon 0000:01:00.0: fence driver on ring 3 use gpu addr 0x0000000040000c0c and cpu addr 0xffff88041c7adc0c
    94.207595] [drm] ring test on 0 succeeded in 3 usecs
    94.207658] [drm] ring test on 3 succeeded in 1 usecs
    94.219587] [drm] ib test on ring 0 succeeded in 0 usecs
    94.219639] [drm] ib test on ring 3 succeeded in 1 usecs

    • Are you using the bfgminer branch from my LLVM tree? If not, then that would explain why you are seeing a GPU reset.

Comments are closed.