how can i optimized my program. who can help me.

Moderator: BarsMonster

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
LEDAEX
Posts: 15
Joined: Sat Aug 08, 2009 3:37 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

how can i optimized my program. who can help me.

Post by LEDAEX » Mon Sep 14, 2009 1:57 pm

i have write a md5 crack used cuda to test how to used it.and i know if optimization as good as possible it maight much better than even .but i do not know how to optimized it nearly. who can help me !plz.

my code is like this

Code: Select all

template <unsigned char length> __global__ void GetHashes(int* Ret, uint4 HashToCrack, float CharsetLength,unsigned char *basechar,unsigned char *charset){
	const float id = (blockIdx.y * gridDim.x + blockIdx.x) * blockDim.x + threadIdx.x;
	float  counter = id;
	unsigned int x1=0,x2=0,x3=0,x4=0,x5=0,x15=0,x16=0; //used to get str and it will be 0x61616161=="aaaa";
	int oc;
	int a = 0, carry = 0;
	if (length >= 1)
	{
		oc = counter / CharsetLength;
		a= basechar[0]+ counter-__mul24(oc,CharsetLength);
		if (a >= CharsetLength) { a -= CharsetLength; carry = 1; }
		else carry = 0;
		x1= charset[a];
		counter = oc;
	}
	if (length >= 2)
	{ 
		oc = counter / CharsetLength;
		a= basechar[1]+ counter-__mul24(oc,CharsetLength)+carry;
		if (a >= CharsetLength) { a -= CharsetLength; carry = 1; }
		else carry = 0;
		x1 |= charset[a]<<8;
		counter = oc;
	}
	if (length >= 3)
	{
		oc = counter / CharsetLength;
		a= basechar[2]+ counter-__mul24(oc,CharsetLength)+carry;
		if (a >= CharsetLength) { a -= CharsetLength; carry = 1; }
		else carry = 0;
		x1 |= charset[a] << 16;

		counter = oc;
	}
.........
there is 16 if-part in my progam and because of stl .the complie optimized the code which will not be used in some part.
and now i can get aboat 420mhash/s in gtx295 but who can help me to make it much faster.
thx .

LEDAEX
Posts: 15
Joined: Sat Aug 08, 2009 3:37 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: how can i optimized my program. who can help me.

Post by LEDAEX » Tue Sep 15, 2009 6:43 am

is there any one can help me ?

User avatar
BarsMonster
Site Admin
Posts: 1118
Joined: Wed Oct 01, 2008 7:58 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: how can i optimized my program. who can help me.

Post by BarsMonster » Tue Sep 15, 2009 6:52 am

LEDAEX wrote:is there any one can help me ?
Could you show your thread launch code? Do you handle dual GPU?

LEDAEX
Posts: 15
Joined: Sat Aug 08, 2009 3:37 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: how can i optimized my program. who can help me.

Post by LEDAEX » Tue Sep 15, 2009 1:06 pm

er. there is 4 gpu in my computer, and i used mutil-threads to control all the device.my algorithm is descript in http://3.14.by/forum/viewtopic.php?f=8&t=1023 .

LEDAEX
Posts: 15
Joined: Sat Aug 08, 2009 3:37 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: how can i optimized my program. who can help me.

Post by LEDAEX » Wed Sep 16, 2009 1:21 am

er .there is my lanched code .

Code: Select all

CUDA_SAFE_CALL(cudaEventRecord(start,0));

	cudaMemcpy(d_base,base,sizeof(unsigned char)*16,cudaMemcpyHostToDevice);
	switch (pswlength){
			case 1:GetHashes< 1><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
			case 2:GetHashes< 2><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
			case 3:GetHashes< 3><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
			case 4:GetHashes< 4><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
			case 5:GetHashes< 5><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
			case 6:GetHashes< 6><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
			case 7:GetHashes< 7><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
			case 8:GetHashes< 8><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
			case 9:GetHashes< 9><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
			case 10:GetHashes< 10><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
			case 11:GetHashes< 11><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
			case 12:GetHashes< 12><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
			case 13:GetHashes< 13><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
			case 14:GetHashes< 14><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
			case 15:GetHashes< 15><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
			case 16:GetHashes< 16><<<blocks, threads>>>(d_ret, htc, charsetlen,d_base); break;
	}
	CUDA_SAFE_CALL(cudaEventSynchronize(stop));
	int1 ret;
	CUDA_SAFE_CALL(cudaMemcpy(&ret,d_ret,sizeof(int1),cudaMemcpyDeviceToHost));

	CUDA_SAFE_CALL(cudaEventRecord(stop,0));

	while(cudaEventQuery(stop)==cudaErrorNotReady);
	CUDA_SAFE_CALL(cudaEventElapsedTime(&timer,start,stop));
	return ret.x;
}
the d_ret,d_base are used cudamalloc to malloc memory on device .

User avatar
BarsMonster
Site Admin
Posts: 1118
Joined: Wed Oct 01, 2008 7:58 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: how can i optimized my program. who can help me.

Post by BarsMonster » Wed Sep 16, 2009 3:57 pm

Did you profiled your code to understand how much your CPU part takes? (which prepares your data for GPU)
Hmm... Just realized that your password generation idea might be better than mine :-)

LEDAEX
Posts: 15
Joined: Sat Aug 08, 2009 3:37 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: how can i optimized my program. who can help me.

Post by LEDAEX » Thu Sep 17, 2009 2:31 am

hmm. there because i want to make all the device run,and if used my algorithm i do not know how much there can be run in gpu thread . so i do not use cpu to run gpu at all.
but can you give some suggestion aboat the kernel funciton for how can i optimize it. thx.

Sc00bz
Posts: 136
Joined: Fri Oct 03, 2008 8:28 am
Contact:

Re: how can i optimized my program. who can help me.

Post by Sc00bz » Thu Sep 17, 2009 5:27 am

BarsMonster wrote:Hmm... Just realized that your password generation idea might be better than mine :-)
Are you talking about his first post?

User avatar
BarsMonster
Site Admin
Posts: 1118
Joined: Wed Oct 01, 2008 7:58 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: how can i optimized my program. who can help me.

Post by BarsMonster » Thu Sep 17, 2009 12:24 pm

Sc00bz wrote:
BarsMonster wrote:Hmm... Just realized that your password generation idea might be better than mine :-)
Are you talking about his first post?
Yes.

User avatar
BarsMonster
Site Admin
Posts: 1118
Joined: Wed Oct 01, 2008 7:58 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: how can i optimized my program. who can help me.

Post by BarsMonster » Thu Sep 17, 2009 12:25 pm

LEDAEX wrote:is there any one can help me ?
I think your problem should be in your MD5 code, as everything else looks pretty fine.

Sc00bz
Posts: 136
Joined: Fri Oct 03, 2008 8:28 am
Contact:

Re: how can i optimized my program. who can help me.

Post by Sc00bz » Thu Sep 17, 2009 8:50 pm

BarsMonster wrote:
Sc00bz wrote:
BarsMonster wrote:Hmm... Just realized that your password generation idea might be better than mine :-)
Are you talking about his first post?
Yes.
:o maybe I need to write a brute forcer. Well... how are you generating the next pw, the same way?

Just letting you know that you need to test which one is faster __mul24 or normal 32 bit multiply because future architectures will do __mul24 slower than normal 32 bit multiply. Does anyone know what "future architectures" mean in NVIDIA_CUDA_Programming_Guide_2.3.pdf page 87 "page 79"
On future architectures however, __mul24 will be slower than 32-bit integer multiplication, so we recommend to provide two kernels, one using __mul24 and the other using generic 32-bit integer multiplication, to be called appropriately by the application.

LEDAEX
Posts: 15
Joined: Sat Aug 08, 2009 3:37 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: how can i optimized my program. who can help me.

Post by LEDAEX » Fri Sep 18, 2009 1:06 am

NVIDIA_CUDA_Programming_Guide_2.3.pdf page 87 "page 79"
maybe I need to write a brute forcer. Well... how are you generating the next pw, the same way?

Just letting you know that you need to test which one is faster __mul24 or normal 32 bit multiply because future architectures will do __mul24 slower than normal 32 bit multiply. Does anyone know what "future architectures" mean in NVIDIA_CUDA_Programming_Guide_2.3.pdf page 87 "page 79"
[/quote]

er. you are read the guide so Seriously and i nearly never saw the guide 2.3 . thx . i would check if it is better than __mul24 .

LEDAEX
Posts: 15
Joined: Sat Aug 08, 2009 3:37 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: how can i optimized my program. who can help me.

Post by LEDAEX » Fri Sep 18, 2009 1:29 am

BarsMonster wrote:
LEDAEX wrote:is there any one can help me ?
I think your problem should be in your MD5 code, as everything else looks pretty fine.
i know there is one posts in this bbs shows how can reverse the md5 code. but there is some other problem . in the last md5 part.there needs some x which would need the input data. how can i cut it and reverse these parts.

er the last part is like this

Code: Select all

#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))

#define P(a,b,c,d,k,s,t)                                \
	{														\
	a += F(b,c,d) + k + t; a = S(a,s) + b;			\
	}			
#define F(x,y,z) (y ^ (x | ~z))

	P( A, B, C, D,  x1,  6, 0xF4292244 );
	P( D, A, B, C,  0, 10, 0x432AFF97 );
	P( C, D, A, B, x15, 15, 0xAB9423A7 );
	P( B, C, D, A, 0, 21, 0xFC93A039 );
	P( A, B, C, D, 0,  6, 0x655B59C3 );
	P( D, A, B, C,  x4, 10, 0x8F0CCC92 );
	P( C, D, A, B, 0, 15, 0xFFEFF47D );
	P( B, C, D, A,  x2, 21, 0x85845DD1 );
	P( A, B, C, D,  0,  6, 0x6FA87E4F );
	P( D, A, B, C, x16, 10, 0xFE2CE6E0 );
	P( C, D, A, B,  0, 15, 0xA3014314 );
	P( B, C, D, A, 0, 21, 0x4E0811A1 );
	P( A, B, C, D,  x5,  6, 0xF7537E82 );
	P( D, A, B, C, 0, 10, 0xBD3AF235 );
	P( C, D, A, B,  x3, 15, 0x2AD7D2BB );
	P( B, C, D, A,  0, 21, 0xEB86D391 );

#undef F
so on this code like P( C, D, A, B, x3, 15, 0x2AD7D2BB ); i don't know the x3 before the psw has been generate. so can you give me some suggestion .
or you can add my msn anexled@hotmail.com for we can discuss how we can optimized our code.

neinbrucke
Posts: 82
Joined: Sun Nov 02, 2008 8:53 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: how can i optimized my program. who can help me.

Post by neinbrucke » Fri Sep 18, 2009 6:38 am

http://www.freerainbowtables.com/phpBB3 ... =715#p5763
http://3.14.by/forum/viewtopic.php?f=8&t=47

the idea is that you keep part of your plaintext 'fixed' for a while, until you have tried all combinations in the flexible part (like [aaaa-zzzz]aaaa). then do the reversal steps again for the new fixed part (like [aaaa-zzzz]aaab).
(so x3 is a 'fixed' value for a while)

LEDAEX
Posts: 15
Joined: Sat Aug 08, 2009 3:37 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: how can i optimized my program. who can help me.

Post by LEDAEX » Sat Sep 19, 2009 2:30 am

neinbrucke wrote:http://www.freerainbowtables.com/phpBB3 ... =715#p5763
http://3.14.by/forum/viewtopic.php?f=8&t=47

the idea is that you keep part of your plaintext 'fixed' for a while, until you have tried all combinations in the flexible part (like [aaaa-zzzz]aaaa). then do the reversal steps again for the new fixed part (like [aaaa-zzzz]aaab).
(so x3 is a 'fixed' value for a while)
thx . i would like study it.... now i need some to understand the algorithm。

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 1 guest