This project is read-only.

Cudafy operators problem? - Solved

Nov 24, 2013 at 9:00 PM
I want to implement MD5 algorithm that uses GPGPU and I have these codes:

From a normal C# function:
        a = unchecked(b + ((a + (((b & c) | ((b ^ 0xFFFFFFFF) & d)) + temp[0] + 0xd76aa478) << 7) | (a + ((b & c) | ((b ^ 0xFFFFFFFF) & d)) + temp[0] + 0xd76aa478) >> (32 - 7)));
        d = unchecked(a + ((d + (((a & b) | ((a ^ 0xFFFFFFFF) & c)) + temp[1] + 0xe8c7b756) << 12) | (d + ((a & b) | ((a ^ 0xFFFFFFFF) & c)) + temp[1] + 0xe8c7b756) >> (32 - 12)));
        c = unchecked(d + ((c + (((d & a) | ((d ^ 0xFFFFFFFF) & b)) + temp[2] + 0x242070db) << 17) | (c + ((d & a) | ((d ^ 0xFFFFFFFF) & b)) + temp[2] + 0x242070db) >> (32 - 17)));
        b = unchecked(c + ((b + (((c & d) | ((c ^ 0xFFFFFFFF) & a)) + temp[3] + 0xc1bdceee) << 22) | (b + ((c & d) | ((c ^ 0xFFFFFFFF) & a)) + temp[3] + 0xc1bdceee) >> (32 - 22)));
And one from a Cuda kernel:
        a = unchecked(b + ((a + (((b & c) | ((b ^ 0xFFFFFFFF) & d)) + temp[tIndex, 0] + 0xd76aa478) << 7) | (a + ((b & c) | ((b ^ 0xFFFFFFFF) & d)) + temp[tIndex, 0] + 0xd76aa478) >> (32 - 7)));
        d = unchecked(a + ((d + (((a & b) | ((a ^ 0xFFFFFFFF) & c)) + temp[tIndex, 1] + 0xe8c7b756) << 12) | (d + ((a & b) | ((a ^ 0xFFFFFFFF) & c)) + temp[tIndex, 1] + 0xe8c7b756) >> (32 - 12)));
        c = unchecked(d + ((c + (((d & a) | ((d ^ 0xFFFFFFFF) & b)) + temp[tIndex, 2] + 0x242070db) << 17) | (c + ((d & a) | ((d ^ 0xFFFFFFFF) & b)) + temp[tIndex, 2] + 0x242070db) >> (32 - 17)));
        b = unchecked(c + ((b + (((c & d) | ((c ^ 0xFFFFFFFF) & a)) + temp[tIndex, 3] + 0xc1bdceee) << 22) | (b + ((c & d) | ((c ^ 0xFFFFFFFF) & a)) + temp[tIndex, 3] + 0xc1bdceee) >> (32 - 22)));
where temp is:
uint[,] temp = thread.AllocateShared<uint>("temp", GPUManager.threadsPerBlock, 16);
These codes are have to be equal, but the Cuda kernel one is produces wrong results. Is it possible, that Cudafy is generating wrong C code?
Nov 24, 2013 at 10:56 PM
There was another problem, sorry for opening a discussion for this. This can be deleted.