Jump to: navigation, search

GPU610/Team AGC

1,557 bytes added, 17:32, 31 October 2014
lclRotateLeft(r[1], 2);
After struggling for a few hours I realized that I should be using Thrust instead:
// unsigned short* h_r = new unsigned short[LOOPSIZE * RT_SIZE];
// unsigned char* h_t = new unsigned char[LOOPSIZE * RT_SIZE];
// unsigned char* h_x = new unsigned char[LOOPSIZE];
thrust::host_vector<unsigned short> h_r(LOOPSIZE * RT_SIZE);
thrust::host_vector<unsigned short> h_hash(LOOPSIZE);
thrust::host_vector<unsigned char> h_t(LOOPSIZE * RT_SIZE);
thrust::host_vector<unsigned char> h_x(LOOPSIZE);
// unsigned short* d_r;
// unsigned char* d_t;
// unsigned char* d_x;
// cudaMalloc((void**)&d_r, LOOPSIZE * RT_SIZE);
// cudaMalloc((void**)&d_t, LOOPSIZE * RT_SIZE);
// cudaMalloc((void**)&d_x, LOOPSIZE);
The following transformation allows the computation of all XOR operations needed in this phase:
thrust::device_vector<unsigned short> d_r = h_r;
thrust::device_vector<unsigned short> d_hash = h_hash;
thrust::device_vector<unsigned char> d_t = h_t;
thrust::device_vector<unsigned char> d_x = h_x;
thrust::device_vector<unsigned short> xor_hash(LOOPSIZE); // XOR results
// For XOR operations with r[1]
// thrust::device_ptr<unsigned short> pHash = &d_hash[0];
// thrust::device_reference<unsigned short> rHash(pHash);
thrust::transform(d_hash.begin(), d_hash.end(), d_r.begin(),
xor_hash.begin(), thrust::bit_xor<int>());
Now to check each result with x and t[1] if the password has been found, otherwise combine the XOR results by XOR'ing them together for the next iteration to use.
=== Assignment 3 ===

Navigation menu