# C# with GPU?

• Feb 5th, 2012, 12:03 PM
simon66
C# with GPU?
So I decided to upgrade my code from vb to C#, to see if I can get this to work.

My program generates random words. (Just a for loop on a array that changes A to H or any other letter) <---- This is on a fuction BTW.

Now running this on my CPU (i7 920) generates me about 200 words a sec. Now thats kinda fast, but not as fast as I want. I heard about GPU calculation and I'm wondering how can I do that on C#

Im using VS 2010 ona i7 920 with a ATI 5770 Sapphire Card. I know it supports OpenCL.

Any help would be great.

Thanks
• Feb 5th, 2012, 06:24 PM
Evil_Giraffe
Re: C# with GPU?
I don't think that sounds like the sort of thing that a GPU would be much help with.

200 words/sec doesn't sound very fast for what I'm understanding the function does. Can you post that code and we'll see if there are any obvious speed ups?
• Feb 5th, 2012, 09:31 PM
simon66
Re: C# with GPU?
Quote:

Originally Posted by Evil_Giraffe
I don't think that sounds like the sort of thing that a GPU would be much help with.

200 words/sec doesn't sound very fast for what I'm understanding the function does. Can you post that code and we'll see if there are any obvious speed ups?

Here it is

It's just a simple for loop with 4 if statements inside of it. I did the best solution I could think of.

So I really cant speed up the process with my GPU?

PS. Here is the code

Code:

Private Sub brain()
Dim _str() As Char = {" "}
Dim _len As Integer = _str.Length
Dim rHash As String

For i = 0 To 3
If (_str(_len - 1) >= Chr(127)) Then
For q = _len - 1 To 0 Step -1
If (AscW(_str(q)) >= 127) Then
If (q = 0) Then
ReDim _str(_len)
For p = _len To 0 Step -1
_str(p) = Chr(32)
Next
_len += 1
Else
_str(q) = Chr(32)
_str(q - 1) = Chr(AscW(_str(q - 1)) + 1)
End If
End If
Next
End If
// My Work is here, to save this
_str(_len - 1) = Chr(AscW(_str(_len - 1)) + 1)
i = 1 //Infinite loop!
Next
End Sub

Here is my vb.net code, the Syntax is the same except the { }.
• Feb 7th, 2012, 10:03 AM
TheBigB
Re: C# with GPU?
May I ask what you are using this for?
Judging by its output it's not just a word generator. I'd rather say it's a brute-forcer of some kind.