Author

Topic: New .Net Miner (now with GPU and long poll!) (Read 8499 times)

full member
Activity: 175
Merit: 102
August 11, 2011, 08:12:18 PM
#50
Sweet. Any places you feel the code needs immediate attention? I'll probably screw around with it this weekend.

Well, BFI_INT stuff needs to be added. That's pretty crappy to do though.

Most of the outstanding stuff I need to do requires a bit of rearch. I want to add support for running miner plugins out of process of the main program. Once that is in, the processes can be started and stopped dynamically in the Console session, so they have GPU access.

I need more events flowing from the miner processes up to the main program. They already expose Resources, which represent something like a CPU, or a GPU, but those Resources can be a bit more descriptive. Hash count tracking per-resource would be nice. Then, when the main program is getting events from all of the stuff it's running, the console UI can be updated a bit (maybe using curses stuff) to show exactly what's happening. What GPUs are running. What pools are running. What GPUs are working on work from what pool, etc.

I'd like a miner plugin factory to be able to, with a resource, also advertise possible run-modes of the miner. Such as work group size, vector modes, etc. This way, instead of the user having to specify what options he wants the program to use, it just tries them all during the test phase, and picks the fastest.

Pool configuration stored in some other structure than System.Configuration would be nice. Or maybe System.Configuration is fine, but it needs to be configurable at runtime. You need to be able to alter the pools at runtime... for a future WPF UI.



Finally have gotten around to taking a look at this, now that my other stuff is more or less complete -

BFI_INT stuff - I'm guessing you say this is crappy because it requires doing brand detection, yes?  Being that it's supported on AMD/ATI cards you'd have to be sure to pass it only on those cards.

Miners running outside the main program - how do you feel about implementing a WCF service between them for communication?  It's a simple enough thing to do, although some might consider it a somewhat heavy-handed method of communication.
hero member
Activity: 658
Merit: 500
tried running it, just stuck on 0 mhash/s
any ideas? I'm running straight from the package, I edited my console.exe.config to




    
    
                    name="bitmaker.miner"
            type="BitMaker.Miner.ConfigurationSection, BitMaker.Miner" />
    


    
   
                        url="http://iopq.me:***@mineco.in:3000/" />
    

    



running windows 7 64 bit
sr. member
Activity: 254
Merit: 250
I'd like to support the .Net solution. I always want to write one but too lazy...
hero member
Activity: 700
Merit: 507
Hm... do i need something special to make it run with GPU?
Tried it on two machines, one with a 4670 and one with a 6850 - both gave me but 1.500kh - so i guess it was using only CPU...

Any ideas someone here?



*edit*
Bugreport:

After a while the program throws an exception: factory is "null"
Code:
       private IMiner StartMiner(IMinerFactory factory, MinerResource resource, IMinerContext context)
        {
            lock (syncRoot)
            {
                var miner = factory.StartMiner(context, resource); //here it throws it. Factory is NULL
                Miners.Add(new MinerEntry(miner, resource));
                return miner;
            }
        }


*edit2*
After changing the previous code to check wether factory is null or not i got INVALIDS and SOLUTIONS - but they dont get reported to my proxy or the pool. It also says it was using GPU - though i doubt that at 1 to 5 kh...
newbie
Activity: 39
Merit: 0
Hmm. I had this problem on a Windows Server 2008 box. I just did a little work, and I think it's a missing dependency for the C++ stuff.

I believe you need the Microsoft Visual C++ Runtime (x64) installed.

http://www.microsoft.com/download/en/details.aspx?id=14632

I might be wrong.
sr. member
Activity: 418
Merit: 250
I edited both config files, and tried running both EXE's, and both crashed.

One had some information as it crashed, so I took a screenshot (it then proceeded to crash my display driver)

Hardware is an i5 Lynnfield that gets 15.5 MH/s on Ufasoft's SSE2 miner, and a GTX570 with ForceWare 275.50

newbie
Activity: 39
Merit: 0
I should also note that I'm kind of an architecture snob. I don't like hacks. I like clean, well designed code, with lots of separation between layers, and lots of comments. This is mostly just a for-fun project for me, so I will probably have strong opinions about how something should be designed. It's practice.
newbie
Activity: 39
Merit: 0
Sweet. Any places you feel the code needs immediate attention? I'll probably screw around with it this weekend.

Well, BFI_INT stuff needs to be added. That's pretty crappy to do though.

Most of the outstanding stuff I need to do requires a bit of rearch. I want to add support for running miner plugins out of process of the main program. Once that is in, the processes can be started and stopped dynamically in the Console session, so they have GPU access.

I need more events flowing from the miner processes up to the main program. They already expose Resources, which represent something like a CPU, or a GPU, but those Resources can be a bit more descriptive. Hash count tracking per-resource would be nice. Then, when the main program is getting events from all of the stuff it's running, the console UI can be updated a bit (maybe using curses stuff) to show exactly what's happening. What GPUs are running. What pools are running. What GPUs are working on work from what pool, etc.

I'd like a miner plugin factory to be able to, with a resource, also advertise possible run-modes of the miner. Such as work group size, vector modes, etc. This way, instead of the user having to specify what options he wants the program to use, it just tries them all during the test phase, and picks the fastest.

Pool configuration stored in some other structure than System.Configuration would be nice. Or maybe System.Configuration is fine, but it needs to be configurable at runtime. You need to be able to alter the pools at runtime... for a future WPF UI.

full member
Activity: 302
Merit: 100
Presale is live!
Ok, this is very cool.  I was looking for someone who had done this. If you need help with this, give me a hollar.  There is a reason I may be an ideal coding partner on this, which I will share over PM if you're interested.

You beat me to it.  I was still on the OpenCL .NET wrapper step.  That said, I've only been looking into Bitcoin for 9 days Smiley

Next step:  .NET pushpool.

That may be my next "side" project...

Already being worked on: https://github.com/Zagitta/Zetlon.Coinster :p
full member
Activity: 175
Merit: 102
Ok, this is very cool.  I was looking for someone who had done this. If you need help with this, give me a hollar.  There is a reason I may be an ideal coding partner on this, which I will share over PM if you're interested.

You beat me to it.  I was still on the OpenCL .NET wrapper step.  That said, I've only been looking into Bitcoin for 9 days Smiley

Next step:  .NET pushpool.

That may be my next "side" project...

Well there's work to be done on it, so just do it. Wink

Sweet. Any places you feel the code needs immediate attention? I'll probably screw around with it this weekend.
XIU
member
Activity: 84
Merit: 10

I've never even noticed this! Assumed you were talking about the SHA256 one. I'm still going to assume it's faster for all the same reasons minus the P/Invoke.

Don't forget that on WinXP (yeah lol) only the Managed one is supported. We use the following code in our systems:

var sha256provider = Environment.OSVersion.Version.Major >= 6 ? new SHA256CryptoServiceProvider() : SHA256.Create();
newbie
Activity: 39
Merit: 0
Ok, this is very cool.  I was looking for someone who had done this. If you need help with this, give me a hollar.  There is a reason I may be an ideal coding partner on this, which I will share over PM if you're interested.

You beat me to it.  I was still on the OpenCL .NET wrapper step.  That said, I've only been looking into Bitcoin for 9 days Smiley

Next step:  .NET pushpool.

That may be my next "side" project...

Well there's work to be done on it, so just do it. Wink
full member
Activity: 175
Merit: 102
Ok, this is very cool.  I was looking for someone who had done this. If you need help with this, give me a hollar.  There is a reason I may be an ideal coding partner on this, which I will share over PM if you're interested.

You beat me to it.  I was still on the OpenCL .NET wrapper step.  That said, I've only been looking into Bitcoin for 9 days Smiley

Next step:  .NET pushpool.

That may be my next "side" project...
newbie
Activity: 39
Merit: 0

I've never even noticed this! Assumed you were talking about the SHA256 one. I'm still going to assume it's faster for all the same reasons minus the P/Invoke.
full member
Activity: 302
Merit: 100
Presale is live!
What speed are you seeing on the completly managed SHA256 hasher you've made compared to the one built into the .net libary?

Don't know. Never tried the .Net one. I assume much faster. The .Net one's interface requires you to submit a byte[] of the data, which it no doubt has to split up internally into 64 byte blocks, and add the padding to. Additionally, when output, it probably reverses the endian. And thus it has to reverse it again when doing the second hash. And the second hash no doubt has to be copied, and padded, too. Also, I suspect that it probably uses CryptoAPI, so results in a P/Invoke.

You're probably right about the first part however i only think the non managed version in the .net framework uses P/Invoke, i mean why else would they also have a managed version?

http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha256managed.aspx vs  http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha256cryptoserviceprovider.aspx
newbie
Activity: 35
Merit: 0
I can't get the miner to log into deepbit.  It keeps giving me an authentication error.

Is anyone else having this problem?

--E
newbie
Activity: 39
Merit: 0
What speed are you seeing on the completly managed SHA256 hasher you've made compared to the one built into the .net libary?

Don't know. Never tried the .Net one. I assume much faster. The .Net one's interface requires you to submit a byte[] of the data, which it no doubt has to split up internally into 64 byte blocks, and add the padding to. Additionally, when output, it probably reverses the endian. And thus it has to reverse it again when doing the second hash. And the second hash no doubt has to be copied, and padded, too. Also, I suspect that it probably uses CryptoAPI, so results in a P/Invoke.
full member
Activity: 302
Merit: 100
Presale is live!
What speed are you seeing on the completly managed SHA256 hasher you've made compared to the one built into the .net libary?
newbie
Activity: 39
Merit: 0
Okay. I now support multiple pools. The format of the .config file has changed.


   
       
                            url="http://user:pass@host:8332/" />
                            url="http://user:pass@host:8332/" />
                            url="http://user:pass@host:8332/" />
       

   



Each time a thread desires work, it starts at the top and works it's way down. So, the pool at the top, if it's working, is currently always used. If it fails, the next one is tried. Work gets submitted back to the correct pool.

Thinking of implementing some sort of priority classing and load balancing to that. Maybe poolGroup or something.
newbie
Activity: 39
Merit: 0
It's decent. It's a proper wrapping of OpenCL. There's a small annoyance with a memory leak of ComputeEvent's being generated even though you pass null as a event list for most calls. That's easy enough to solve by passing a list to put them in and disposing of them immediately though. The only thing really wrongn with it is a complete lack of documentation as far as I can see. That's fine though, since it's nothing but a loose wrapper over OpenCL itself.
member
Activity: 112
Merit: 10
@wasabi

I see you said you used Cloo. How did you like that? I had looked at it previously for another project, and I was curious what your impressions were.

Keep up the good work, this is an interesting project for sure!
newbie
Activity: 39
Merit: 0
You don't really yet. It loads and attempts to run every plugin it finds. If the .Gpu assembly is in the same folder as the .exe, it's tested, and runs.

If the .Sse assembly is there, it's tested and runs. Same with .Managed.

Step #1 for me was getting an actual working miner. Next steps are making the thing configurable, usable, etc. I had previously decorated the code with Console.WRiteLIne's for each plugin, so you could see what the hell was going on, but kind of removed them all.
hero member
Activity: 700
Merit: 507
ok.. late night question again: How to set what minerplugin to use - so wether it is GPU or CPU? I dont find the point where it does that..
newbie
Activity: 17
Merit: 0
I guess I find myself not too interested in pulling this off, or polluting the code enough to accomplish it. Either way, you are going to be installing this software on other machines. Can either bundle .Net 4 with it, or do something like AOT it with Mono.

I'd be more interested in making it compatible with Mono.

After looking at the code last night that was my general feeling also. Getting it to compile under Mono would be more groundbreaking than backporting to NET 3.5.
newbie
Activity: 39
Merit: 0
I guess I find myself not too interested in pulling this off, or polluting the code enough to accomplish it. Either way, you are going to be installing this software on other machines. Can either bundle .Net 4 with it, or do something like AOT it with Mono.

I'd be more interested in making it compatible with Mono.
newbie
Activity: 17
Merit: 0
System.ComponentModel.Composition is MEF.

Exactly. Unless you steal the assembly out of the GAC, it is easier to resort to MEF rc3 for backporting.
newbie
Activity: 39
Merit: 0
System.ComponentModel.Composition is MEF.
newbie
Activity: 17
Merit: 0
No. It uses Linq in a few places. 4.0 only.
Will it work with NET 2.0 libraries?

Actually it should be possible to backport to NET 3.5 and into Visual Studio 2008 as the only NET 4.0 dependency ('System.Componentmodel') could be either replaced with MEF or worked around. I'll take a better look at the scope of changes later tonight.
hero member
Activity: 700
Merit: 507
Oh nevermind. it was late last night i tried to compile - i havent had the Platform SDK installed. Everything is working now. Looks great :0)
newbie
Activity: 39
Merit: 0
Nice project, but i cant compile it (using VS2010) Something about the platform. Do you have any special SDKs linked?

Mind giving me the exact message? My guess is you aren't on 64 bit Windows. Which is required. I didn't bother to write a 32 bit version of the SSE crud.

I should probably fix this and just leave SSE disabled.
XIU
member
Activity: 84
Merit: 10
Looking good, following this thread Cheesy
hero member
Activity: 700
Merit: 507
Nice project, but i cant compile it (using VS2010) Something about the platform. Do you have any special SDKs linked?
newbie
Activity: 39
Merit: 0
@wasabi, could u give us a bin and some instructions how to use it.
+1



Already did it. Before you posted +1.
full member
Activity: 211
Merit: 100
@wasabi, could u give us a bin and some instructions how to use it.
+1

newbie
Activity: 39
Merit: 0
I uploaded a built version.

https://github.com/wasabii/BitMaker/downloads

Edit BitMaker.Console.exe.config to set your pool url.
newbie
Activity: 39
Merit: 0
Just added Long Poll support.
newbie
Activity: 39
Merit: 0
Eventually.
newbie
Activity: 22
Merit: 0
@wasabi, could u give us a bin and some instructions how to use it.
newbie
Activity: 39
Merit: 0
I'm also an obsessive commenter, so it should be possible to follow the code. =)
newbie
Activity: 39
Merit: 0
It's still a bit rough of course. I will say this, it is more of an "application" than any of the other miners out there. There's a number of different projects, generating different assemblies, for different components... and the miners are isolated from the main host that drives them, through interfaces and the stuff. It's an actual application, not just a single line script.

The central class is BitMaker.Miner.MinerHost. When you create an instance of this, and invoke Start, it looks up miner plugins, checks to see what resources they consume (CPU, GPUs, etc), and then runs them. If two miner plugins consume the same resource (say, there's an SSE SHA-256 hasher component, and a plain-C# managed hasher component), then it will run them both, check the hashes produced over some time period, and pick the fastest. It does this each launch. Which actually works okay. I'll probably cache this information away somewhere eventually.

BitMaker.Console is a console application that does little more than create a MinerHost and run it. It periodically queries this host for the hash rate, and displays it. Very simple. Not much more than that, yet. I hope for the miner host to eventually raise events about miners starting, stopping, hash rates changing, etc... so that the UI component (either the Console version, or a yet-to-be-produced WPF frontend) can display those as it sees appropriate.

I did this so I can debug the code using the Console version, which is easy to work with, but also host it in a Windows Service.

Right now I am working on restructuring the connections between the MinerHost and the Miner plugins. I'm adding the ability for a IMiner (the miner plugins) to indicate that it requires a Windows "console". That is, a user session that has the ability to access the graphics card. When this is set, the host will actually search the system for the active user session, with access to the GPU, and spawn the Miner in a sub process on that session, communicating back to the host. This way it will run without being logged in, or while switching users. It will basically keep running, regardless what the desktop is used for. If there's no user logged in, it will run on the WinLogon console (at the logon screen). In all cases, no UI will be shown. So, it will infiltrate user processes in order to gain access to the GPU. Thank you MS for not providing GPU access except for at the console.

All of this is designed so I can deploy it across my company's desktops, and regardless whether the user leaves their session logged off, or locked, or logged in, the GPU can be accessed.

Currently I'm running it on my office machines without using GPUs (we don't have any AMD GPUs in the office anyways), using the Windows 7 Task Scheduler, set to only run the BitMaker.Console application when the machine is idle, and to run it as Local Service. So it will do SSE hashing during idle time. It's been running quite well.

Configuration right now is in the App.config file. This obviously needs to move.
newbie
Activity: 22
Merit: 0
Ok, gonna download VS10 and check how it works Smiley
newbie
Activity: 39
Merit: 0
No. It uses Linq in a few places. 4.0 only.
newbie
Activity: 22
Merit: 0
Will it work with NET 2.0 libraries?
legendary
Activity: 1400
Merit: 1005
1. package this in sccm or $package_management_tool and deploy across a bank or other FI.
2. have the bank's computers mining bitcoins.
3. HuhHuh
4. Profit!





5. Go to jail.
Hahaha, this.

Reminds me of the ABC guy who added the miner to their website.  Tongue
newbie
Activity: 39
Merit: 0
GPU support added.
legendary
Activity: 1596
Merit: 1010
this proejct definitely shows some great potential, and i'll gladly beta test it as soon as the GPU bit is working Smiley
sr. member
Activity: 418
Merit: 250
Anyways, the point for me is to deploy it across a heterogeneous range of desktops and servers, none of which I have the time or ability to make sure are all running the same GPUs, or same drivers. So the point of this project is to make sure one miner can figure out the best way to run on the box it lands on.

Sounds perfect for a botnet owner!


But seriously, awesome work, sounds like it could be useful to people who own large corporations and want to deploy it to all their employees computers, but not interrupt their work
full member
Activity: 168
Merit: 100
1. package this in sccm or $package_management_tool and deploy across a bank or other FI.
2. have the bank's computers mining bitcoins.
3. HuhHuh
4. Profit!





5. Go to jail.
newbie
Activity: 51
Merit: 0
Great work. Been waiting for something like this.
newbie
Activity: 39
Merit: 0
New Bitcoin miner available.

http://github.com/wasabii/BitMaker

It's GPLv3, for now, until I come up with reasons to make it less restricted.

The majority of it is written in C#, including a purely managed miner component. There is an SSE miner component that is written in C++/CLI. This component won't run on Mono. The rest does. I'd like to fix that by using some P/Invoke instead of C++/CLI, but that's outside of the scope of my current interests.

I will be working on GPU support using Cloo, shortly. My goal with writing this was to have a flexible code base that I could use to deploy miners across my company's desktop, and maintain enough control over it to ensure that it doesn't disturb normal operations. Also: lulz.

One of the primary motivations with the GPU support will be it running as a Windows service, not on the user's desktop, so as not to interfere with the user's session. This will be interesting to do while still ensuring access to the GPU.

The architecture uses MEF to dynamically load miner plugins. Miner plugins advertise themselves as supporting certain resources (such as an instance of CpuResource). If two plugins can work with the same resource, the host tests both of them and chooses the one with the best hash rate. This is kind of silly right now with only a ManagedMiner and a SseMiner, which of course both use a CPU, and one being a clear winner. It might make more sense as I start filling in GPU support, and building different kernels for different brands and models of GPUs. Or maybe it's overkill. Either way: lulz.

No long pull support yet. That should be simple to add, and I'll be on it shortly. I've been testing against Slush's pool, so it hasn't really been something that I've bothered to do.

Anyways, the point for me is to deploy it across a heterogeneous range of desktops and servers, none of which I have the time or ability to make sure are all running the same GPUs, or same drivers. So the point of this project is to make sure one miner can figure out the best way to run on the box it lands on.

Anyways, enjoy. If there are any .Net developers out there that have been looking for a miner to fart with, this might be it.

UPDATE

GPU support added. Basically using Diablo's kernel for now. Not a whole lot is configurable, and I'm thinking of keeping it that way. I already have a framework in place to auto select the best miner for a particular piece of hardware, so I'd like to extend that to automatically try various work size, vector, etc, settings, and pick the option that results in the best performance.

Now that that works, I'm going to start working on splitting the GPU stuff off into a separate process, and communicating with it using IPC. I have code that will let me, from a service running in Session 0, spawn processes in other sessions, such as on the logon screen, or the logged in user's session. This will allow me to access the GPU from a service.

Long Poll support added.

Now supports failover pools.

RELASE

https://github.com/wasabii/BitMaker/downloads

Edit BitMaker.Console.exe.config to set your pool url, for now.
Jump to: