From bd030db5d12c3f93694d10e055a6585afc659d40 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Fri, 13 Jan 2017 15:16:49 +0100 Subject: [PATCH] xmr: vectors rewrite, now the phase2 is using only 40 regs no more constant memory used for aes. tested only on linux cuda 8 for now... wip --- crypto/cn_aes.cuh | 962 +++++++++++++++++++++++++++++++++++- crypto/cryptolight-core.cu | 19 +- crypto/cryptolight.cu | 4 +- crypto/cryptolight.h | 6 +- crypto/cryptonight-core.cu | 307 ++++-------- crypto/cryptonight-extra.cu | 26 +- crypto/cryptonight.cu | 4 +- crypto/cryptonight.h | 16 +- 8 files changed, 1089 insertions(+), 255 deletions(-) diff --git a/crypto/cn_aes.cuh b/crypto/cn_aes.cuh index 1ccec9e..abd0209 100644 --- a/crypto/cn_aes.cuh +++ b/crypto/cn_aes.cuh @@ -1,8 +1,8 @@ #define N_COLS 4 #define WPOLY 0x011b - -static __constant__ __align__(16) uint32_t d_t_fn[1024] = { +/* +static const __device__ __align__(16) uint32_t d_t_fn[1024] = { 0xa56363c6U, 0x847c7cf8U, 0x997777eeU, 0x8d7b7bf6U, 0x0df2f2ffU, 0xbd6b6bd6U, 0xb16f6fdeU, 0x54c5c591U, 0x50303060U, 0x03010102U, 0xa96767ceU, 0x7d2b2b56U, 0x19fefee7U, 0x62d7d7b5U, 0xe6abab4dU, 0x9a7676ecU, 0x45caca8fU, 0x9d82821fU, 0x40c9c989U, 0x877d7dfaU, 0x15fafaefU, 0xeb5959b2U, 0xc947478eU, 0x0bf0f0fbU, @@ -135,9 +135,13 @@ static __constant__ __align__(16) uint32_t d_t_fn[1024] = { 0x038f8c8cU, 0x59f8a1a1U, 0x09808989U, 0x1a170d0dU, 0x65dabfbfU, 0xd731e6e6U, 0x84c64242U, 0xd0b86868U, 0x82c34141U, 0x29b09999U, 0x5a772d2dU, 0x1e110f0fU, 0x7bcbb0b0U, 0xa8fc5454U, 0x6dd6bbbbU, 0x2c3a1616U }; +*/ +#define AS_U32(addr) *((uint32_t*)(addr)) #define AS_UINT2(addr) *((uint2*)(addr)) #define AS_UINT4(addr) *((uint4*)(addr)) +#define AS_UL2(addr) *((ulonglong2*)(addr)) +#define AS_UL4(addr) *((ulonglong4*)(addr)) #define t_fn0(x) (sharedMemory[x]) #define t_fn1(x) (sharedMemory[0x100U | (x)]) @@ -160,15 +164,15 @@ static __constant__ __align__(16) uint32_t d_t_fn[1024] = { #define __byte_perm(a,b,c) a #endif -#define OFF8_0(x) (x & 0xFFu) -#define OFF8_1(x) __byte_perm(x, 0x01, 0x5541) -#define OFF8_2(x) __byte_perm(x, 0x02, 0x5542) -#define OFF8_3(x) __byte_perm(x, 0x03, 0x5543) +#define OFF32_0(x) (x & 0xFFu) +#define OFF32_1(x) __byte_perm(x, 0x01, 0x5541) +#define OFF32_2(x) __byte_perm(x, 0x02, 0x5542) +#define OFF32_3(x) __byte_perm(x, 0x03, 0x5543) -#define SHARED_0(x) sharedMemory[OFF8_0(x)] -#define SHARED_1(x) sharedMemory[OFF8_1(x)] -#define SHARED_2(x) sharedMemory[OFF8_2(x)] -#define SHARED_3(x) sharedMemory[OFF8_3(x)] +#define SHARED_0(x) sharedMemory[OFF32_0(x)] +#define SHARED_1(x) sharedMemory[OFF32_1(x)] +#define SHARED_2(x) sharedMemory[OFF32_2(x)] +#define SHARED_3(x) sharedMemory[OFF32_3(x)] __device__ __forceinline__ void cn_aes_single_round(uint32_t * const sharedMemory, uint32_t * const in, uint32_t * out, uint32_t* expandedKey) @@ -180,6 +184,27 @@ void cn_aes_single_round(uint32_t * const sharedMemory, uint32_t * const in, uin out[3] = expandedKey[3] ^ SHARED_0(in[3]) ^ SHARED_1(in[0]) ^ SHARED_2(in[1]) ^ SHARED_3(in[2]); } +#define OFF8_0(x) (x & 0xFFu) << 2 +#define OFF8_1(x) __byte_perm(x, 0x01, 0x5541) << 2 +#define OFF8_2(x) __byte_perm(x, 0x02, 0x5542) << 2 +#define OFF8_3(x) __byte_perm(x, 0x03, 0x5543) << 2 + +#define SHAR8_0(x) AS_U32(&sharedMemory[OFF8_0(x)]) +#define SHAR8_1(x) AS_U32(&sharedMemory[OFF8_1(x)]) +#define SHAR8_2(x) AS_U32(&sharedMemory[OFF8_2(x)]) +#define SHAR8_3(x) AS_U32(&sharedMemory[OFF8_3(x)]) + +__device__ __forceinline__ +void cn_aes_single_round_b(uint8_t * const sharedMemory, void * const long_state, const uint4 key, uint4 *res) +{ + asm("// aes_single_round_b"); + uint4 in = AS_UINT4(long_state); + *res = key; + res->x ^= SHAR8_0(in.x) ^ SHAR8_1(in.y) ^ SHAR8_2(in.z) ^ SHAR8_3(in.w); + res->y ^= SHAR8_0(in.y) ^ SHAR8_1(in.z) ^ SHAR8_2(in.w) ^ SHAR8_3(in.x); + res->z ^= SHAR8_0(in.z) ^ SHAR8_1(in.w) ^ SHAR8_2(in.x) ^ SHAR8_3(in.y); + res->w ^= SHAR8_0(in.w) ^ SHAR8_1(in.x) ^ SHAR8_2(in.y) ^ SHAR8_3(in.z); +} #define round_perm(shared, out, in, k) \ out[0] = (k)[0] ^ SHARED_0(in[0]) ^ SHARED_1(in[1]) ^ SHARED_2(in[2]) ^ SHARED_3(in[3]); \ @@ -188,7 +213,7 @@ void cn_aes_single_round(uint32_t * const sharedMemory, uint32_t * const in, uin out[3] = (k)[3] ^ SHARED_0(in[3]) ^ SHARED_1(in[0]) ^ SHARED_2(in[1]) ^ SHARED_3(in[2]); __device__ __forceinline__ -void cn_aes_pseudo_round_mut(const uint32_t * sharedMemory, uint32_t * val, const uint32_t * expandedKey) +void cn_aes_pseudo_round_mut(const uint32_t * sharedMemory, uint32_t * val, uint32_t const * expandedKey) { asm("// aes_pseudo_round_mut"); #if 0 @@ -219,20 +244,33 @@ void cn_aes_pseudo_round_mut(const uint32_t * sharedMemory, uint32_t * val, cons #endif } +/* __device__ __forceinline__ -void cn_aes_gpu_init(uint32_t* sharedMemory) +void cn_aes_gpu_init2(uint32_t* sharedMemory) { - if(blockDim.x >= 32) +#if 0 + if(blockDim.x >= 64) { + if(threadIdx.x < 64) { + #define thrX (threadIdx.x << 2U) // ensure offsets aligned (16) to vector + #pragma unroll 4 + for (uint32_t i = 0; i < 1024U; i += 256U) // 32x32 = 1024, 4 * 256 also + AS_UINT4(&sharedMemory[i + thrX]) = AS_UINT4(&d_t_fn[i + thrX]); + } + + } else +#endif + if(blockDim.x >= 32) { + if(threadIdx.x < 32) { #if 0 #pragma unroll 32 for(uint32_t i = 0; i < 1024; i += 32) sharedMemory[threadIdx.x + i] = d_t_fn[threadIdx.x + i]; #else - #define thrX (threadIdx.x << 2) // ensure offsets aligned (16) to vector + #define thrX (threadIdx.x << 2U) // ensure offsets aligned (16) to vector #pragma unroll 8 - for (uint32_t i = 0; i < 1024; i += 128) // 32x32 = 1024, 8 * 128 also + for (uint32_t i = 0; i < 1024; i += 128U) // 32x32 = 1024, 8 * 128 also AS_UINT4(&sharedMemory[i + thrX]) = AS_UINT4(&d_t_fn[i + thrX]); #endif } @@ -244,11 +282,899 @@ void cn_aes_gpu_init(uint32_t* sharedMemory) for (uint32_t i = 0; i < 1024; i += 4) sharedMemory[threadIdx.x + i] = d_t_fn[threadIdx.x + i]; #else - #define thrX (threadIdx.x << 2) // ensure offsets aligned (16) to vector + #define thrX (threadIdx.x << 2U) // ensure offsets aligned (16) to vector #pragma unroll 64 - for (uint32_t i = 0; i < 1024; i += 16) + for (uint32_t i = 0; i < 1024; i += 16U) AS_UINT4(&sharedMemory[i + thrX]) = AS_UINT4(&d_t_fn[i + thrX]); #endif } } -} \ No newline at end of file +} +*/ + +__device__ __forceinline__ +void cn_aes_gpu_init(uint32_t* sharedMemory) +{ + // AES 0 + switch (threadIdx.x) { + case 0: + AS_UL4(&sharedMemory[0x000]) = make_ulonglong4(0x847c7cf8a56363c6, 0x8d7b7bf6997777ee, 0xbd6b6bd60df2f2ff, 0x54c5c591b16f6fde); + AS_UL4(&sharedMemory[0x008]) = make_ulonglong4(0x0301010250303060, 0x7d2b2b56a96767ce, 0x62d7d7b519fefee7, 0x9a7676ece6abab4d); + AS_UL4(&sharedMemory[0x010]) = make_ulonglong4(0x9d82821f45caca8f, 0x877d7dfa40c9c989, 0xeb5959b215fafaef, 0x0bf0f0fbc947478e); + AS_UL4(&sharedMemory[0x018]) = make_ulonglong4(0x67d4d4b3ecadad41, 0xeaafaf45fda2a25f, 0xf7a4a453bf9c9c23, 0x5bc0c09b967272e4); + break; + case 1: + AS_UL4(&sharedMemory[0x020]) = make_ulonglong4(0x1cfdfde1c2b7b775, 0x6a26264cae93933d, 0x413f3f7e5a36366c, 0x4fcccc8302f7f7f5); + AS_UL4(&sharedMemory[0x028]) = make_ulonglong4(0xf4a5a5515c343468, 0x08f1f1f934e5e5d1, 0x73d8d8ab937171e2, 0x3f15152a53313162); + AS_UL4(&sharedMemory[0x030]) = make_ulonglong4(0x52c7c7950c040408, 0x5ec3c39d65232346, 0xa196963728181830, 0xb59a9a2f0f05050a); + AS_UL4(&sharedMemory[0x038]) = make_ulonglong4(0x361212240907070e, 0x3de2e2df9b80801b, 0x6927274e26ebebcd, 0x9f7575eacdb2b27f); + break; + case 2: + AS_UL4(&sharedMemory[0x040]) = make_ulonglong4(0x9e83831d1b090912, 0x2e1a1a34742c2c58, 0xb26e6edc2d1b1b36, 0xfba0a05bee5a5ab4); + AS_UL4(&sharedMemory[0x048]) = make_ulonglong4(0x4d3b3b76f65252a4, 0xceb3b37d61d6d6b7, 0x3ee3e3dd7b292952, 0x97848413712f2f5e); + AS_UL4(&sharedMemory[0x050]) = make_ulonglong4(0x68d1d1b9f55353a6, 0x2cededc100000000, 0x1ffcfce360202040, 0xed5b5bb6c8b1b179); + AS_UL4(&sharedMemory[0x058]) = make_ulonglong4(0x46cbcb8dbe6a6ad4, 0x4b393972d9bebe67, 0xd44c4c98de4a4a94, 0x4acfcf85e85858b0); + break; + case 3: + AS_UL4(&sharedMemory[0x060]) = make_ulonglong4(0x2aefefc56bd0d0bb, 0x16fbfbede5aaaa4f, 0xd74d4d9ac5434386, 0x9485851155333366); + AS_UL4(&sharedMemory[0x068]) = make_ulonglong4(0x10f9f9e9cf45458a, 0x817f7ffe06020204, 0x443c3c78f05050a0, 0xe3a8a84bba9f9f25); + AS_UL4(&sharedMemory[0x070]) = make_ulonglong4(0xfea3a35df35151a2, 0x8a8f8f05c0404080, 0xbc9d9d21ad92923f, 0x04f5f5f148383870); + AS_UL4(&sharedMemory[0x078]) = make_ulonglong4(0xc1b6b677dfbcbc63, 0x6321214275dadaaf, 0x1affffe530101020, 0x6dd2d2bf0ef3f3fd); + break; + case 4: + AS_UL4(&sharedMemory[0x080]) = make_ulonglong4(0x140c0c184ccdcd81, 0x2fececc335131326, 0xa2979735e15f5fbe, 0x3917172ecc444488); + AS_UL4(&sharedMemory[0x088]) = make_ulonglong4(0xf2a7a75557c4c493, 0x473d3d7a827e7efc, 0xe75d5dbaac6464c8, 0x957373e62b191932); + AS_UL4(&sharedMemory[0x090]) = make_ulonglong4(0x98818119a06060c0, 0x7fdcdca3d14f4f9e, 0x7e2a2a5466222244, 0x8388880bab90903b); + AS_UL4(&sharedMemory[0x098]) = make_ulonglong4(0x29eeeec7ca46468c, 0x3c141428d3b8b86b, 0xe25e5ebc79dedea7, 0x76dbdbad1d0b0b16); + break; + case 5: + AS_UL4(&sharedMemory[0x0A0]) = make_ulonglong4(0x563232643be0e0db, 0x1e0a0a144e3a3a74, 0x0a06060cdb494992, 0xe45c5cb86c242448); + AS_UL4(&sharedMemory[0x0A8]) = make_ulonglong4(0x6ed3d3bd5dc2c29f, 0xa66262c4efacac43, 0xa4959531a8919139, 0x8b7979f237e4e4d3); + AS_UL4(&sharedMemory[0x0B0]) = make_ulonglong4(0x43c8c88b32e7e7d5, 0xb76d6dda5937376e, 0x64d5d5b18c8d8d01, 0xe0a9a949d24e4e9c); + AS_UL4(&sharedMemory[0x0B8]) = make_ulonglong4(0xfa5656acb46c6cd8, 0x25eaeacf07f4f4f3, 0x8e7a7af4af6565ca, 0x18080810e9aeae47); + break; + case 6: + AS_UL4(&sharedMemory[0x0C0]) = make_ulonglong4(0x887878f0d5baba6f, 0x722e2e5c6f25254a, 0xf1a6a657241c1c38, 0x51c6c697c7b4b473); + AS_UL4(&sharedMemory[0x0C8]) = make_ulonglong4(0x7cdddda123e8e8cb, 0x211f1f3e9c7474e8, 0xdcbdbd61dd4b4b96, 0x858a8a0f868b8b0d); + AS_UL4(&sharedMemory[0x0D0]) = make_ulonglong4(0x423e3e7c907070e0, 0xaa6666ccc4b5b571, 0x05030306d8484890, 0x120e0e1c01f6f6f7); + AS_UL4(&sharedMemory[0x0D8]) = make_ulonglong4(0x5f35356aa36161c2, 0xd0b9b969f95757ae, 0x58c1c19991868617, 0xb99e9e27271d1d3a); + break; + case 7: + AS_UL4(&sharedMemory[0x0E0]) = make_ulonglong4(0x13f8f8eb38e1e1d9, 0x33111122b398982b, 0x70d9d9a9bb6969d2, 0xa7949433898e8e07); + AS_UL4(&sharedMemory[0x0E8]) = make_ulonglong4(0x221e1e3cb69b9b2d, 0x20e9e9c992878715, 0xff5555aa49cece87, 0x7adfdfa578282850); + AS_UL4(&sharedMemory[0x0F0]) = make_ulonglong4(0xf8a1a1598f8c8c03, 0x170d0d1a80898909, 0x31e6e6d7dabfbf65, 0xb86868d0c6424284); + AS_UL4(&sharedMemory[0x0F8]) = make_ulonglong4(0xb0999929c3414182, 0x110f0f1e772d2d5a, 0xfc5454a8cbb0b07b, 0x3a16162cd6bbbb6d); + break; + } + // AES 1 + switch (threadIdx.x) { + case 0: + AS_UL4(&sharedMemory[0x100]) = make_ulonglong4(0x7c7cf8846363c6a5, 0x7b7bf68d7777ee99, 0x6b6bd6bdf2f2ff0d, 0xc5c591546f6fdeb1); + AS_UL4(&sharedMemory[0x108]) = make_ulonglong4(0x0101020330306050, 0x2b2b567d6767cea9, 0xd7d7b562fefee719, 0x7676ec9aabab4de6); + AS_UL4(&sharedMemory[0x110]) = make_ulonglong4(0x82821f9dcaca8f45, 0x7d7dfa87c9c98940, 0x5959b2ebfafaef15, 0xf0f0fb0b47478ec9); + AS_UL4(&sharedMemory[0x118]) = make_ulonglong4(0xd4d4b367adad41ec, 0xafaf45eaa2a25ffd, 0xa4a453f79c9c23bf, 0xc0c09b5b7272e496); + break; + case 1: + AS_UL4(&sharedMemory[0x120]) = make_ulonglong4(0xfdfde11cb7b775c2, 0x26264c6a93933dae, 0x3f3f7e4136366c5a, 0xcccc834ff7f7f502); + AS_UL4(&sharedMemory[0x128]) = make_ulonglong4(0xa5a551f43434685c, 0xf1f1f908e5e5d134, 0xd8d8ab737171e293, 0x15152a3f31316253); + AS_UL4(&sharedMemory[0x130]) = make_ulonglong4(0xc7c795520404080c, 0xc3c39d5e23234665, 0x969637a118183028, 0x9a9a2fb505050a0f); + AS_UL4(&sharedMemory[0x138]) = make_ulonglong4(0x1212243607070e09, 0xe2e2df3d80801b9b, 0x27274e69ebebcd26, 0x7575ea9fb2b27fcd); + break; + case 2: + AS_UL4(&sharedMemory[0x140]) = make_ulonglong4(0x83831d9e0909121b, 0x1a1a342e2c2c5874, 0x6e6edcb21b1b362d, 0xa0a05bfb5a5ab4ee); + AS_UL4(&sharedMemory[0x148]) = make_ulonglong4(0x3b3b764d5252a4f6, 0xb3b37dced6d6b761, 0xe3e3dd3e2929527b, 0x848413972f2f5e71); + AS_UL4(&sharedMemory[0x150]) = make_ulonglong4(0xd1d1b9685353a6f5, 0xededc12c00000000, 0xfcfce31f20204060, 0x5b5bb6edb1b179c8); + AS_UL4(&sharedMemory[0x158]) = make_ulonglong4(0xcbcb8d466a6ad4be, 0x3939724bbebe67d9, 0x4c4c98d44a4a94de, 0xcfcf854a5858b0e8); + break; + case 3: + AS_UL4(&sharedMemory[0x160]) = make_ulonglong4(0xefefc52ad0d0bb6b, 0xfbfbed16aaaa4fe5, 0x4d4d9ad7434386c5, 0x8585119433336655); + AS_UL4(&sharedMemory[0x168]) = make_ulonglong4(0xf9f9e91045458acf, 0x7f7ffe8102020406, 0x3c3c78445050a0f0, 0xa8a84be39f9f25ba); + AS_UL4(&sharedMemory[0x170]) = make_ulonglong4(0xa3a35dfe5151a2f3, 0x8f8f058a404080c0, 0x9d9d21bc92923fad, 0xf5f5f10438387048); + AS_UL4(&sharedMemory[0x178]) = make_ulonglong4(0xb6b677c1bcbc63df, 0x21214263dadaaf75, 0xffffe51a10102030, 0xd2d2bf6df3f3fd0e); + break; + case 4: + AS_UL4(&sharedMemory[0x180]) = make_ulonglong4(0x0c0c1814cdcd814c, 0xececc32f13132635, 0x979735a25f5fbee1, 0x17172e39444488cc); + AS_UL4(&sharedMemory[0x188]) = make_ulonglong4(0xa7a755f2c4c49357, 0x3d3d7a477e7efc82, 0x5d5dbae76464c8ac, 0x7373e6951919322b); + AS_UL4(&sharedMemory[0x190]) = make_ulonglong4(0x818119986060c0a0, 0xdcdca37f4f4f9ed1, 0x2a2a547e22224466, 0x88880b8390903bab); + AS_UL4(&sharedMemory[0x198]) = make_ulonglong4(0xeeeec72946468cca, 0x1414283cb8b86bd3, 0x5e5ebce2dedea779, 0xdbdbad760b0b161d); + break; + case 5: + AS_UL4(&sharedMemory[0x1A0]) = make_ulonglong4(0x32326456e0e0db3b, 0x0a0a141e3a3a744e, 0x06060c0a494992db, 0x5c5cb8e42424486c); + AS_UL4(&sharedMemory[0x1A8]) = make_ulonglong4(0xd3d3bd6ec2c29f5d, 0x6262c4a6acac43ef, 0x959531a4919139a8, 0x7979f28be4e4d337); + AS_UL4(&sharedMemory[0x1B0]) = make_ulonglong4(0xc8c88b43e7e7d532, 0x6d6ddab737376e59, 0xd5d5b1648d8d018c, 0xa9a949e04e4e9cd2); + AS_UL4(&sharedMemory[0x1B8]) = make_ulonglong4(0x5656acfa6c6cd8b4, 0xeaeacf25f4f4f307, 0x7a7af48e6565caaf, 0x08081018aeae47e9); + break; + case 6: + AS_UL4(&sharedMemory[0x1C0]) = make_ulonglong4(0x7878f088baba6fd5, 0x2e2e5c7225254a6f, 0xa6a657f11c1c3824, 0xc6c69751b4b473c7); + AS_UL4(&sharedMemory[0x1C8]) = make_ulonglong4(0xdddda17ce8e8cb23, 0x1f1f3e217474e89c, 0xbdbd61dc4b4b96dd, 0x8a8a0f858b8b0d86); + AS_UL4(&sharedMemory[0x1D0]) = make_ulonglong4(0x3e3e7c427070e090, 0x6666ccaab5b571c4, 0x03030605484890d8, 0x0e0e1c12f6f6f701); + AS_UL4(&sharedMemory[0x1D8]) = make_ulonglong4(0x35356a5f6161c2a3, 0xb9b969d05757aef9, 0xc1c1995886861791, 0x9e9e27b91d1d3a27); + break; + case 7: + AS_UL4(&sharedMemory[0x1E0]) = make_ulonglong4(0xf8f8eb13e1e1d938, 0x1111223398982bb3, 0xd9d9a9706969d2bb, 0x949433a78e8e0789); + AS_UL4(&sharedMemory[0x1E8]) = make_ulonglong4(0x1e1e3c229b9b2db6, 0xe9e9c92087871592, 0x5555aaffcece8749, 0xdfdfa57a28285078); + AS_UL4(&sharedMemory[0x1F0]) = make_ulonglong4(0xa1a159f88c8c038f, 0x0d0d1a1789890980, 0xe6e6d731bfbf65da, 0x6868d0b8424284c6); + AS_UL4(&sharedMemory[0x1F8]) = make_ulonglong4(0x999929b0414182c3, 0x0f0f1e112d2d5a77, 0x5454a8fcb0b07bcb, 0x16162c3abbbb6dd6); + break; + } + // AES 2 + switch (threadIdx.x) { + case 0: + AS_UL4(&sharedMemory[0x200]) = make_ulonglong4(0x7cf8847c63c6a563, 0x7bf68d7b77ee9977, 0x6bd6bd6bf2ff0df2, 0xc59154c56fdeb16f); + AS_UL4(&sharedMemory[0x208]) = make_ulonglong4(0x0102030130605030, 0x2b567d2b67cea967, 0xd7b562d7fee719fe, 0x76ec9a76ab4de6ab); + AS_UL4(&sharedMemory[0x210]) = make_ulonglong4(0x821f9d82ca8f45ca, 0x7dfa877dc98940c9, 0x59b2eb59faef15fa, 0xf0fb0bf0478ec947); + AS_UL4(&sharedMemory[0x218]) = make_ulonglong4(0xd4b367d4ad41ecad, 0xaf45eaafa25ffda2, 0xa453f7a49c23bf9c, 0xc09b5bc072e49672); + break; + case 1: + AS_UL4(&sharedMemory[0x220]) = make_ulonglong4(0xfde11cfdb775c2b7, 0x264c6a26933dae93, 0x3f7e413f366c5a36, 0xcc834fccf7f502f7); + AS_UL4(&sharedMemory[0x228]) = make_ulonglong4(0xa551f4a534685c34, 0xf1f908f1e5d134e5, 0xd8ab73d871e29371, 0x152a3f1531625331); + AS_UL4(&sharedMemory[0x230]) = make_ulonglong4(0xc79552c704080c04, 0xc39d5ec323466523, 0x9637a19618302818, 0x9a2fb59a050a0f05); + AS_UL4(&sharedMemory[0x238]) = make_ulonglong4(0x12243612070e0907, 0xe2df3de2801b9b80, 0x274e6927ebcd26eb, 0x75ea9f75b27fcdb2); + break; + case 2: + AS_UL4(&sharedMemory[0x240]) = make_ulonglong4(0x831d9e8309121b09, 0x1a342e1a2c58742c, 0x6edcb26e1b362d1b, 0xa05bfba05ab4ee5a); + AS_UL4(&sharedMemory[0x248]) = make_ulonglong4(0x3b764d3b52a4f652, 0xb37dceb3d6b761d6, 0xe3dd3ee329527b29, 0x841397842f5e712f); + AS_UL4(&sharedMemory[0x250]) = make_ulonglong4(0xd1b968d153a6f553, 0xedc12ced00000000, 0xfce31ffc20406020, 0x5bb6ed5bb179c8b1); + AS_UL4(&sharedMemory[0x258]) = make_ulonglong4(0xcb8d46cb6ad4be6a, 0x39724b39be67d9be, 0x4c98d44c4a94de4a, 0xcf854acf58b0e858); + break; + case 3: + AS_UL4(&sharedMemory[0x260]) = make_ulonglong4(0xefc52aefd0bb6bd0, 0xfbed16fbaa4fe5aa, 0x4d9ad74d4386c543, 0x8511948533665533); + AS_UL4(&sharedMemory[0x268]) = make_ulonglong4(0xf9e910f9458acf45, 0x7ffe817f02040602, 0x3c78443c50a0f050, 0xa84be3a89f25ba9f); + AS_UL4(&sharedMemory[0x270]) = make_ulonglong4(0xa35dfea351a2f351, 0x8f058a8f4080c040, 0x9d21bc9d923fad92, 0xf5f104f538704838); + AS_UL4(&sharedMemory[0x278]) = make_ulonglong4(0xb677c1b6bc63dfbc, 0x21426321daaf75da, 0xffe51aff10203010, 0xd2bf6dd2f3fd0ef3); + break; + case 4: + AS_UL4(&sharedMemory[0x280]) = make_ulonglong4(0x0c18140ccd814ccd, 0xecc32fec13263513, 0x9735a2975fbee15f, 0x172e39174488cc44); + AS_UL4(&sharedMemory[0x288]) = make_ulonglong4(0xa755f2a7c49357c4, 0x3d7a473d7efc827e, 0x5dbae75d64c8ac64, 0x73e6957319322b19); + AS_UL4(&sharedMemory[0x290]) = make_ulonglong4(0x8119988160c0a060, 0xdca37fdc4f9ed14f, 0x2a547e2a22446622, 0x880b8388903bab90); + AS_UL4(&sharedMemory[0x298]) = make_ulonglong4(0xeec729ee468cca46, 0x14283c14b86bd3b8, 0x5ebce25edea779de, 0xdbad76db0b161d0b); + break; + case 5: + AS_UL4(&sharedMemory[0x2A0]) = make_ulonglong4(0x32645632e0db3be0, 0x0a141e0a3a744e3a, 0x060c0a064992db49, 0x5cb8e45c24486c24); + AS_UL4(&sharedMemory[0x2A8]) = make_ulonglong4(0xd3bd6ed3c29f5dc2, 0x62c4a662ac43efac, 0x9531a4959139a891, 0x79f28b79e4d337e4); + AS_UL4(&sharedMemory[0x2B0]) = make_ulonglong4(0xc88b43c8e7d532e7, 0x6ddab76d376e5937, 0xd5b164d58d018c8d, 0xa949e0a94e9cd24e); + AS_UL4(&sharedMemory[0x2B8]) = make_ulonglong4(0x56acfa566cd8b46c, 0xeacf25eaf4f307f4, 0x7af48e7a65caaf65, 0x08101808ae47e9ae); + break; + case 6: + AS_UL4(&sharedMemory[0x2C0]) = make_ulonglong4(0x78f08878ba6fd5ba, 0x2e5c722e254a6f25, 0xa657f1a61c38241c, 0xc69751c6b473c7b4); + AS_UL4(&sharedMemory[0x2C8]) = make_ulonglong4(0xdda17cdde8cb23e8, 0x1f3e211f74e89c74, 0xbd61dcbd4b96dd4b, 0x8a0f858a8b0d868b); + AS_UL4(&sharedMemory[0x2D0]) = make_ulonglong4(0x3e7c423e70e09070, 0x66ccaa66b571c4b5, 0x030605034890d848, 0x0e1c120ef6f701f6); + AS_UL4(&sharedMemory[0x2D8]) = make_ulonglong4(0x356a5f3561c2a361, 0xb969d0b957aef957, 0xc19958c186179186, 0x9e27b99e1d3a271d); + break; + case 7: + AS_UL4(&sharedMemory[0x2E0]) = make_ulonglong4(0xf8eb13f8e1d938e1, 0x11223311982bb398, 0xd9a970d969d2bb69, 0x9433a7948e07898e); + AS_UL4(&sharedMemory[0x2E8]) = make_ulonglong4(0x1e3c221e9b2db69b, 0xe9c920e987159287, 0x55aaff55ce8749ce, 0xdfa57adf28507828); + AS_UL4(&sharedMemory[0x2F0]) = make_ulonglong4(0xa159f8a18c038f8c, 0x0d1a170d89098089, 0xe6d731e6bf65dabf, 0x68d0b8684284c642); + AS_UL4(&sharedMemory[0x2F8]) = make_ulonglong4(0x9929b0994182c341, 0x0f1e110f2d5a772d, 0x54a8fc54b07bcbb0, 0x162c3a16bb6dd6bb); + break; + } + // AES 3 + switch (threadIdx.x) { + case 0: + AS_UL4(&sharedMemory[0x300]) = make_ulonglong4(0xf8847c7cc6a56363, 0xf68d7b7bee997777, 0xd6bd6b6bff0df2f2, 0x9154c5c5deb16f6f); + AS_UL4(&sharedMemory[0x308]) = make_ulonglong4(0x0203010160503030, 0x567d2b2bcea96767, 0xb562d7d7e719fefe, 0xec9a76764de6abab); + AS_UL4(&sharedMemory[0x310]) = make_ulonglong4(0x1f9d82828f45caca, 0xfa877d7d8940c9c9, 0xb2eb5959ef15fafa, 0xfb0bf0f08ec94747); + AS_UL4(&sharedMemory[0x318]) = make_ulonglong4(0xb367d4d441ecadad, 0x45eaafaf5ffda2a2, 0x53f7a4a423bf9c9c, 0x9b5bc0c0e4967272); + break; + case 1: + AS_UL4(&sharedMemory[0x320]) = make_ulonglong4(0xe11cfdfd75c2b7b7, 0x4c6a26263dae9393, 0x7e413f3f6c5a3636, 0x834fccccf502f7f7); + AS_UL4(&sharedMemory[0x328]) = make_ulonglong4(0x51f4a5a5685c3434, 0xf908f1f1d134e5e5, 0xab73d8d8e2937171, 0x2a3f151562533131); + AS_UL4(&sharedMemory[0x330]) = make_ulonglong4(0x9552c7c7080c0404, 0x9d5ec3c346652323, 0x37a1969630281818, 0x2fb59a9a0a0f0505); + AS_UL4(&sharedMemory[0x338]) = make_ulonglong4(0x243612120e090707, 0xdf3de2e21b9b8080, 0x4e692727cd26ebeb, 0xea9f75757fcdb2b2); + break; + case 2: + AS_UL4(&sharedMemory[0x340]) = make_ulonglong4(0x1d9e8383121b0909, 0x342e1a1a58742c2c, 0xdcb26e6e362d1b1b, 0x5bfba0a0b4ee5a5a); + AS_UL4(&sharedMemory[0x348]) = make_ulonglong4(0x764d3b3ba4f65252, 0x7dceb3b3b761d6d6, 0xdd3ee3e3527b2929, 0x139784845e712f2f); + AS_UL4(&sharedMemory[0x350]) = make_ulonglong4(0xb968d1d1a6f55353, 0xc12ceded00000000, 0xe31ffcfc40602020, 0xb6ed5b5b79c8b1b1); + AS_UL4(&sharedMemory[0x358]) = make_ulonglong4(0x8d46cbcbd4be6a6a, 0x724b393967d9bebe, 0x98d44c4c94de4a4a, 0x854acfcfb0e85858); + break; + case 3: + AS_UL4(&sharedMemory[0x360]) = make_ulonglong4(0xc52aefefbb6bd0d0, 0xed16fbfb4fe5aaaa, 0x9ad74d4d86c54343, 0x1194858566553333); + AS_UL4(&sharedMemory[0x368]) = make_ulonglong4(0xe910f9f98acf4545, 0xfe817f7f04060202, 0x78443c3ca0f05050, 0x4be3a8a825ba9f9f); + AS_UL4(&sharedMemory[0x370]) = make_ulonglong4(0x5dfea3a3a2f35151, 0x058a8f8f80c04040, 0x21bc9d9d3fad9292, 0xf104f5f570483838); + AS_UL4(&sharedMemory[0x378]) = make_ulonglong4(0x77c1b6b663dfbcbc, 0x42632121af75dada, 0xe51affff20301010, 0xbf6dd2d2fd0ef3f3); + break; + case 4: + AS_UL4(&sharedMemory[0x380]) = make_ulonglong4(0x18140c0c814ccdcd, 0xc32fecec26351313, 0x35a29797bee15f5f, 0x2e39171788cc4444); + AS_UL4(&sharedMemory[0x388]) = make_ulonglong4(0x55f2a7a79357c4c4, 0x7a473d3dfc827e7e, 0xbae75d5dc8ac6464, 0xe6957373322b1919); + AS_UL4(&sharedMemory[0x390]) = make_ulonglong4(0x19988181c0a06060, 0xa37fdcdc9ed14f4f, 0x547e2a2a44662222, 0x0b8388883bab9090); + AS_UL4(&sharedMemory[0x398]) = make_ulonglong4(0xc729eeee8cca4646, 0x283c14146bd3b8b8, 0xbce25e5ea779dede, 0xad76dbdb161d0b0b); + break; + case 5: + AS_UL4(&sharedMemory[0x3A0]) = make_ulonglong4(0x64563232db3be0e0, 0x141e0a0a744e3a3a, 0x0c0a060692db4949, 0xb8e45c5c486c2424); + AS_UL4(&sharedMemory[0x3A8]) = make_ulonglong4(0xbd6ed3d39f5dc2c2, 0xc4a6626243efacac, 0x31a4959539a89191, 0xf28b7979d337e4e4); + AS_UL4(&sharedMemory[0x3B0]) = make_ulonglong4(0x8b43c8c8d532e7e7, 0xdab76d6d6e593737, 0xb164d5d5018c8d8d, 0x49e0a9a99cd24e4e); + AS_UL4(&sharedMemory[0x3B8]) = make_ulonglong4(0xacfa5656d8b46c6c, 0xcf25eaeaf307f4f4, 0xf48e7a7acaaf6565, 0x1018080847e9aeae); + break; + case 6: + AS_UL4(&sharedMemory[0x3C0]) = make_ulonglong4(0xf08878786fd5baba, 0x5c722e2e4a6f2525, 0x57f1a6a638241c1c, 0x9751c6c673c7b4b4); + AS_UL4(&sharedMemory[0x3C8]) = make_ulonglong4(0xa17cddddcb23e8e8, 0x3e211f1fe89c7474, 0x61dcbdbd96dd4b4b, 0x0f858a8a0d868b8b); + AS_UL4(&sharedMemory[0x3D0]) = make_ulonglong4(0x7c423e3ee0907070, 0xccaa666671c4b5b5, 0x0605030390d84848, 0x1c120e0ef701f6f6); + AS_UL4(&sharedMemory[0x3D8]) = make_ulonglong4(0x6a5f3535c2a36161, 0x69d0b9b9aef95757, 0x9958c1c117918686, 0x27b99e9e3a271d1d); + break; + case 7: + AS_UL4(&sharedMemory[0x3E0]) = make_ulonglong4(0xeb13f8f8d938e1e1, 0x223311112bb39898, 0xa970d9d9d2bb6969, 0x33a7949407898e8e); + AS_UL4(&sharedMemory[0x3E8]) = make_ulonglong4(0x3c221e1e2db69b9b, 0xc920e9e915928787, 0xaaff55558749cece, 0xa57adfdf50782828); + AS_UL4(&sharedMemory[0x3F0]) = make_ulonglong4(0x59f8a1a1038f8c8c, 0x1a170d0d09808989, 0xd731e6e665dabfbf, 0xd0b8686884c64242); + AS_UL4(&sharedMemory[0x3F8]) = make_ulonglong4(0x29b0999982c34141, 0x1e110f0f5a772d2d, 0xa8fc54547bcbb0b0, 0x2c3a16166dd6bbbb); + break; + } + //printf("%x\n", sharedMemory[0]); + //cn_aes_gpu_init2(sharedMemory); +} + +__device__ __forceinline__ +void cn_aes_gpu_init_ul2(uint32_t* sharedMemory) +{ + // AES 0 + switch (threadIdx.x) { + case 0: + AS_UL2(&sharedMemory[0x000]) = make_ulonglong2(0x847c7cf8a56363c6, 0x8d7b7bf6997777ee); + AS_UL2(&sharedMemory[0x004]) = make_ulonglong2(0xbd6b6bd60df2f2ff, 0x54c5c591b16f6fde); + AS_UL2(&sharedMemory[0x008]) = make_ulonglong2(0x0301010250303060, 0x7d2b2b56a96767ce); + AS_UL2(&sharedMemory[0x00C]) = make_ulonglong2(0x62d7d7b519fefee7, 0x9a7676ece6abab4d); + AS_UL2(&sharedMemory[0x010]) = make_ulonglong2(0x9d82821f45caca8f, 0x877d7dfa40c9c989); + AS_UL2(&sharedMemory[0x014]) = make_ulonglong2(0xeb5959b215fafaef, 0x0bf0f0fbc947478e); + AS_UL2(&sharedMemory[0x018]) = make_ulonglong2(0x67d4d4b3ecadad41, 0xeaafaf45fda2a25f); + AS_UL2(&sharedMemory[0x01C]) = make_ulonglong2(0xf7a4a453bf9c9c23, 0x5bc0c09b967272e4); + break; + case 1: + AS_UL2(&sharedMemory[0x020]) = make_ulonglong2(0x1cfdfde1c2b7b775, 0x6a26264cae93933d); + AS_UL2(&sharedMemory[0x024]) = make_ulonglong2(0x413f3f7e5a36366c, 0x4fcccc8302f7f7f5); + AS_UL2(&sharedMemory[0x028]) = make_ulonglong2(0xf4a5a5515c343468, 0x08f1f1f934e5e5d1); + AS_UL2(&sharedMemory[0x02C]) = make_ulonglong2(0x73d8d8ab937171e2, 0x3f15152a53313162); + AS_UL2(&sharedMemory[0x030]) = make_ulonglong2(0x52c7c7950c040408, 0x5ec3c39d65232346); + AS_UL2(&sharedMemory[0x034]) = make_ulonglong2(0xa196963728181830, 0xb59a9a2f0f05050a); + AS_UL2(&sharedMemory[0x038]) = make_ulonglong2(0x361212240907070e, 0x3de2e2df9b80801b); + AS_UL2(&sharedMemory[0x03C]) = make_ulonglong2(0x6927274e26ebebcd, 0x9f7575eacdb2b27f); + break; + case 2: + AS_UL2(&sharedMemory[0x040]) = make_ulonglong2(0x9e83831d1b090912, 0x2e1a1a34742c2c58); + AS_UL2(&sharedMemory[0x044]) = make_ulonglong2(0xb26e6edc2d1b1b36, 0xfba0a05bee5a5ab4); + AS_UL2(&sharedMemory[0x048]) = make_ulonglong2(0x4d3b3b76f65252a4, 0xceb3b37d61d6d6b7); + AS_UL2(&sharedMemory[0x04C]) = make_ulonglong2(0x3ee3e3dd7b292952, 0x97848413712f2f5e); + AS_UL2(&sharedMemory[0x050]) = make_ulonglong2(0x68d1d1b9f55353a6, 0x2cededc100000000); + AS_UL2(&sharedMemory[0x054]) = make_ulonglong2(0x1ffcfce360202040, 0xed5b5bb6c8b1b179); + AS_UL2(&sharedMemory[0x058]) = make_ulonglong2(0x46cbcb8dbe6a6ad4, 0x4b393972d9bebe67); + AS_UL2(&sharedMemory[0x05C]) = make_ulonglong2(0xd44c4c98de4a4a94, 0x4acfcf85e85858b0); + break; + case 3: + AS_UL2(&sharedMemory[0x060]) = make_ulonglong2(0x2aefefc56bd0d0bb, 0x16fbfbede5aaaa4f); + AS_UL2(&sharedMemory[0x064]) = make_ulonglong2(0xd74d4d9ac5434386, 0x9485851155333366); + AS_UL2(&sharedMemory[0x068]) = make_ulonglong2(0x10f9f9e9cf45458a, 0x817f7ffe06020204); + AS_UL2(&sharedMemory[0x06C]) = make_ulonglong2(0x443c3c78f05050a0, 0xe3a8a84bba9f9f25); + AS_UL2(&sharedMemory[0x070]) = make_ulonglong2(0xfea3a35df35151a2, 0x8a8f8f05c0404080); + AS_UL2(&sharedMemory[0x074]) = make_ulonglong2(0xbc9d9d21ad92923f, 0x04f5f5f148383870); + AS_UL2(&sharedMemory[0x078]) = make_ulonglong2(0xc1b6b677dfbcbc63, 0x6321214275dadaaf); + AS_UL2(&sharedMemory[0x07C]) = make_ulonglong2(0x1affffe530101020, 0x6dd2d2bf0ef3f3fd); + break; + case 4: + AS_UL2(&sharedMemory[0x080]) = make_ulonglong2(0x140c0c184ccdcd81, 0x2fececc335131326); + AS_UL2(&sharedMemory[0x084]) = make_ulonglong2(0xa2979735e15f5fbe, 0x3917172ecc444488); + AS_UL2(&sharedMemory[0x088]) = make_ulonglong2(0xf2a7a75557c4c493, 0x473d3d7a827e7efc); + AS_UL2(&sharedMemory[0x08C]) = make_ulonglong2(0xe75d5dbaac6464c8, 0x957373e62b191932); + AS_UL2(&sharedMemory[0x090]) = make_ulonglong2(0x98818119a06060c0, 0x7fdcdca3d14f4f9e); + AS_UL2(&sharedMemory[0x094]) = make_ulonglong2(0x7e2a2a5466222244, 0x8388880bab90903b); + AS_UL2(&sharedMemory[0x098]) = make_ulonglong2(0x29eeeec7ca46468c, 0x3c141428d3b8b86b); + AS_UL2(&sharedMemory[0x09C]) = make_ulonglong2(0xe25e5ebc79dedea7, 0x76dbdbad1d0b0b16); + break; + case 5: + AS_UL2(&sharedMemory[0x0A0]) = make_ulonglong2(0x563232643be0e0db, 0x1e0a0a144e3a3a74); + AS_UL2(&sharedMemory[0x0A4]) = make_ulonglong2(0x0a06060cdb494992, 0xe45c5cb86c242448); + AS_UL2(&sharedMemory[0x0A8]) = make_ulonglong2(0x6ed3d3bd5dc2c29f, 0xa66262c4efacac43); + AS_UL2(&sharedMemory[0x0AC]) = make_ulonglong2(0xa4959531a8919139, 0x8b7979f237e4e4d3); + AS_UL2(&sharedMemory[0x0B0]) = make_ulonglong2(0x43c8c88b32e7e7d5, 0xb76d6dda5937376e); + AS_UL2(&sharedMemory[0x0B4]) = make_ulonglong2(0x64d5d5b18c8d8d01, 0xe0a9a949d24e4e9c); + AS_UL2(&sharedMemory[0x0B8]) = make_ulonglong2(0xfa5656acb46c6cd8, 0x25eaeacf07f4f4f3); + AS_UL2(&sharedMemory[0x0BC]) = make_ulonglong2(0x8e7a7af4af6565ca, 0x18080810e9aeae47); + break; + case 6: + AS_UL2(&sharedMemory[0x0C0]) = make_ulonglong2(0x887878f0d5baba6f, 0x722e2e5c6f25254a); + AS_UL2(&sharedMemory[0x0C4]) = make_ulonglong2(0xf1a6a657241c1c38, 0x51c6c697c7b4b473); + AS_UL2(&sharedMemory[0x0C8]) = make_ulonglong2(0x7cdddda123e8e8cb, 0x211f1f3e9c7474e8); + AS_UL2(&sharedMemory[0x0CC]) = make_ulonglong2(0xdcbdbd61dd4b4b96, 0x858a8a0f868b8b0d); + AS_UL2(&sharedMemory[0x0D0]) = make_ulonglong2(0x423e3e7c907070e0, 0xaa6666ccc4b5b571); + AS_UL2(&sharedMemory[0x0D4]) = make_ulonglong2(0x05030306d8484890, 0x120e0e1c01f6f6f7); + AS_UL2(&sharedMemory[0x0D8]) = make_ulonglong2(0x5f35356aa36161c2, 0xd0b9b969f95757ae); + AS_UL2(&sharedMemory[0x0DC]) = make_ulonglong2(0x58c1c19991868617, 0xb99e9e27271d1d3a); + break; + case 7: + AS_UL2(&sharedMemory[0x0E0]) = make_ulonglong2(0x13f8f8eb38e1e1d9, 0x33111122b398982b); + AS_UL2(&sharedMemory[0x0E4]) = make_ulonglong2(0x70d9d9a9bb6969d2, 0xa7949433898e8e07); + AS_UL2(&sharedMemory[0x0E8]) = make_ulonglong2(0x221e1e3cb69b9b2d, 0x20e9e9c992878715); + AS_UL2(&sharedMemory[0x0EC]) = make_ulonglong2(0xff5555aa49cece87, 0x7adfdfa578282850); + AS_UL2(&sharedMemory[0x0F0]) = make_ulonglong2(0xf8a1a1598f8c8c03, 0x170d0d1a80898909); + AS_UL2(&sharedMemory[0x0F4]) = make_ulonglong2(0x31e6e6d7dabfbf65, 0xb86868d0c6424284); + AS_UL2(&sharedMemory[0x0F8]) = make_ulonglong2(0xb0999929c3414182, 0x110f0f1e772d2d5a); + AS_UL2(&sharedMemory[0x0FC]) = make_ulonglong2(0xfc5454a8cbb0b07b, 0x3a16162cd6bbbb6d); + break; + } + // AES 1 + switch (threadIdx.x) { + case 0: + AS_UL2(&sharedMemory[0x100]) = make_ulonglong2(0x7c7cf8846363c6a5, 0x7b7bf68d7777ee99); + AS_UL2(&sharedMemory[0x104]) = make_ulonglong2(0x6b6bd6bdf2f2ff0d, 0xc5c591546f6fdeb1); + AS_UL2(&sharedMemory[0x108]) = make_ulonglong2(0x0101020330306050, 0x2b2b567d6767cea9); + AS_UL2(&sharedMemory[0x10C]) = make_ulonglong2(0xd7d7b562fefee719, 0x7676ec9aabab4de6); + AS_UL2(&sharedMemory[0x110]) = make_ulonglong2(0x82821f9dcaca8f45, 0x7d7dfa87c9c98940); + AS_UL2(&sharedMemory[0x114]) = make_ulonglong2(0x5959b2ebfafaef15, 0xf0f0fb0b47478ec9); + AS_UL2(&sharedMemory[0x118]) = make_ulonglong2(0xd4d4b367adad41ec, 0xafaf45eaa2a25ffd); + AS_UL2(&sharedMemory[0x11C]) = make_ulonglong2(0xa4a453f79c9c23bf, 0xc0c09b5b7272e496); + break; + case 1: + AS_UL2(&sharedMemory[0x120]) = make_ulonglong2(0xfdfde11cb7b775c2, 0x26264c6a93933dae); + AS_UL2(&sharedMemory[0x124]) = make_ulonglong2(0x3f3f7e4136366c5a, 0xcccc834ff7f7f502); + AS_UL2(&sharedMemory[0x128]) = make_ulonglong2(0xa5a551f43434685c, 0xf1f1f908e5e5d134); + AS_UL2(&sharedMemory[0x12C]) = make_ulonglong2(0xd8d8ab737171e293, 0x15152a3f31316253); + AS_UL2(&sharedMemory[0x130]) = make_ulonglong2(0xc7c795520404080c, 0xc3c39d5e23234665); + AS_UL2(&sharedMemory[0x134]) = make_ulonglong2(0x969637a118183028, 0x9a9a2fb505050a0f); + AS_UL2(&sharedMemory[0x138]) = make_ulonglong2(0x1212243607070e09, 0xe2e2df3d80801b9b); + AS_UL2(&sharedMemory[0x13C]) = make_ulonglong2(0x27274e69ebebcd26, 0x7575ea9fb2b27fcd); + break; + case 2: + AS_UL2(&sharedMemory[0x140]) = make_ulonglong2(0x83831d9e0909121b, 0x1a1a342e2c2c5874); + AS_UL2(&sharedMemory[0x144]) = make_ulonglong2(0x6e6edcb21b1b362d, 0xa0a05bfb5a5ab4ee); + AS_UL2(&sharedMemory[0x148]) = make_ulonglong2(0x3b3b764d5252a4f6, 0xb3b37dced6d6b761); + AS_UL2(&sharedMemory[0x14C]) = make_ulonglong2(0xe3e3dd3e2929527b, 0x848413972f2f5e71); + AS_UL2(&sharedMemory[0x150]) = make_ulonglong2(0xd1d1b9685353a6f5, 0xededc12c00000000); + AS_UL2(&sharedMemory[0x154]) = make_ulonglong2(0xfcfce31f20204060, 0x5b5bb6edb1b179c8); + AS_UL2(&sharedMemory[0x158]) = make_ulonglong2(0xcbcb8d466a6ad4be, 0x3939724bbebe67d9); + AS_UL2(&sharedMemory[0x15C]) = make_ulonglong2(0x4c4c98d44a4a94de, 0xcfcf854a5858b0e8); + break; + case 3: + AS_UL2(&sharedMemory[0x160]) = make_ulonglong2(0xefefc52ad0d0bb6b, 0xfbfbed16aaaa4fe5); + AS_UL2(&sharedMemory[0x164]) = make_ulonglong2(0x4d4d9ad7434386c5, 0x8585119433336655); + AS_UL2(&sharedMemory[0x168]) = make_ulonglong2(0xf9f9e91045458acf, 0x7f7ffe8102020406); + AS_UL2(&sharedMemory[0x16C]) = make_ulonglong2(0x3c3c78445050a0f0, 0xa8a84be39f9f25ba); + AS_UL2(&sharedMemory[0x170]) = make_ulonglong2(0xa3a35dfe5151a2f3, 0x8f8f058a404080c0); + AS_UL2(&sharedMemory[0x174]) = make_ulonglong2(0x9d9d21bc92923fad, 0xf5f5f10438387048); + AS_UL2(&sharedMemory[0x178]) = make_ulonglong2(0xb6b677c1bcbc63df, 0x21214263dadaaf75); + AS_UL2(&sharedMemory[0x17C]) = make_ulonglong2(0xffffe51a10102030, 0xd2d2bf6df3f3fd0e); + break; + case 4: + AS_UL2(&sharedMemory[0x180]) = make_ulonglong2(0x0c0c1814cdcd814c, 0xececc32f13132635); + AS_UL2(&sharedMemory[0x184]) = make_ulonglong2(0x979735a25f5fbee1, 0x17172e39444488cc); + AS_UL2(&sharedMemory[0x188]) = make_ulonglong2(0xa7a755f2c4c49357, 0x3d3d7a477e7efc82); + AS_UL2(&sharedMemory[0x18C]) = make_ulonglong2(0x5d5dbae76464c8ac, 0x7373e6951919322b); + AS_UL2(&sharedMemory[0x190]) = make_ulonglong2(0x818119986060c0a0, 0xdcdca37f4f4f9ed1); + AS_UL2(&sharedMemory[0x194]) = make_ulonglong2(0x2a2a547e22224466, 0x88880b8390903bab); + AS_UL2(&sharedMemory[0x198]) = make_ulonglong2(0xeeeec72946468cca, 0x1414283cb8b86bd3); + AS_UL2(&sharedMemory[0x19C]) = make_ulonglong2(0x5e5ebce2dedea779, 0xdbdbad760b0b161d); + break; + case 5: + AS_UL2(&sharedMemory[0x1A0]) = make_ulonglong2(0x32326456e0e0db3b, 0x0a0a141e3a3a744e); + AS_UL2(&sharedMemory[0x1A4]) = make_ulonglong2(0x06060c0a494992db, 0x5c5cb8e42424486c); + AS_UL2(&sharedMemory[0x1A8]) = make_ulonglong2(0xd3d3bd6ec2c29f5d, 0x6262c4a6acac43ef); + AS_UL2(&sharedMemory[0x1AC]) = make_ulonglong2(0x959531a4919139a8, 0x7979f28be4e4d337); + AS_UL2(&sharedMemory[0x1B0]) = make_ulonglong2(0xc8c88b43e7e7d532, 0x6d6ddab737376e59); + AS_UL2(&sharedMemory[0x1B4]) = make_ulonglong2(0xd5d5b1648d8d018c, 0xa9a949e04e4e9cd2); + AS_UL2(&sharedMemory[0x1B8]) = make_ulonglong2(0x5656acfa6c6cd8b4, 0xeaeacf25f4f4f307); + AS_UL2(&sharedMemory[0x1BC]) = make_ulonglong2(0x7a7af48e6565caaf, 0x08081018aeae47e9); + break; + case 6: + AS_UL2(&sharedMemory[0x1C0]) = make_ulonglong2(0x7878f088baba6fd5, 0x2e2e5c7225254a6f); + AS_UL2(&sharedMemory[0x1C4]) = make_ulonglong2(0xa6a657f11c1c3824, 0xc6c69751b4b473c7); + AS_UL2(&sharedMemory[0x1C8]) = make_ulonglong2(0xdddda17ce8e8cb23, 0x1f1f3e217474e89c); + AS_UL2(&sharedMemory[0x1CC]) = make_ulonglong2(0xbdbd61dc4b4b96dd, 0x8a8a0f858b8b0d86); + AS_UL2(&sharedMemory[0x1D0]) = make_ulonglong2(0x3e3e7c427070e090, 0x6666ccaab5b571c4); + AS_UL2(&sharedMemory[0x1D4]) = make_ulonglong2(0x03030605484890d8, 0x0e0e1c12f6f6f701); + AS_UL2(&sharedMemory[0x1D8]) = make_ulonglong2(0x35356a5f6161c2a3, 0xb9b969d05757aef9); + AS_UL2(&sharedMemory[0x1DC]) = make_ulonglong2(0xc1c1995886861791, 0x9e9e27b91d1d3a27); + break; + case 7: + AS_UL2(&sharedMemory[0x1E0]) = make_ulonglong2(0xf8f8eb13e1e1d938, 0x1111223398982bb3); + AS_UL2(&sharedMemory[0x1E4]) = make_ulonglong2(0xd9d9a9706969d2bb, 0x949433a78e8e0789); + AS_UL2(&sharedMemory[0x1E8]) = make_ulonglong2(0x1e1e3c229b9b2db6, 0xe9e9c92087871592); + AS_UL2(&sharedMemory[0x1EC]) = make_ulonglong2(0x5555aaffcece8749, 0xdfdfa57a28285078); + AS_UL2(&sharedMemory[0x1F0]) = make_ulonglong2(0xa1a159f88c8c038f, 0x0d0d1a1789890980); + AS_UL2(&sharedMemory[0x1F4]) = make_ulonglong2(0xe6e6d731bfbf65da, 0x6868d0b8424284c6); + AS_UL2(&sharedMemory[0x1F8]) = make_ulonglong2(0x999929b0414182c3, 0x0f0f1e112d2d5a77); + AS_UL2(&sharedMemory[0x1FC]) = make_ulonglong2(0x5454a8fcb0b07bcb, 0x16162c3abbbb6dd6); + break; + } + // AES 2 + switch (threadIdx.x) { + case 0: + AS_UL2(&sharedMemory[0x200]) = make_ulonglong2(0x7cf8847c63c6a563, 0x7bf68d7b77ee9977); + AS_UL2(&sharedMemory[0x204]) = make_ulonglong2(0x6bd6bd6bf2ff0df2, 0xc59154c56fdeb16f); + AS_UL2(&sharedMemory[0x208]) = make_ulonglong2(0x0102030130605030, 0x2b567d2b67cea967); + AS_UL2(&sharedMemory[0x20C]) = make_ulonglong2(0xd7b562d7fee719fe, 0x76ec9a76ab4de6ab); + AS_UL2(&sharedMemory[0x210]) = make_ulonglong2(0x821f9d82ca8f45ca, 0x7dfa877dc98940c9); + AS_UL2(&sharedMemory[0x214]) = make_ulonglong2(0x59b2eb59faef15fa, 0xf0fb0bf0478ec947); + AS_UL2(&sharedMemory[0x218]) = make_ulonglong2(0xd4b367d4ad41ecad, 0xaf45eaafa25ffda2); + AS_UL2(&sharedMemory[0x21C]) = make_ulonglong2(0xa453f7a49c23bf9c, 0xc09b5bc072e49672); + break; + case 1: + AS_UL2(&sharedMemory[0x220]) = make_ulonglong2(0xfde11cfdb775c2b7, 0x264c6a26933dae93); + AS_UL2(&sharedMemory[0x224]) = make_ulonglong2(0x3f7e413f366c5a36, 0xcc834fccf7f502f7); + AS_UL2(&sharedMemory[0x228]) = make_ulonglong2(0xa551f4a534685c34, 0xf1f908f1e5d134e5); + AS_UL2(&sharedMemory[0x22C]) = make_ulonglong2(0xd8ab73d871e29371, 0x152a3f1531625331); + AS_UL2(&sharedMemory[0x230]) = make_ulonglong2(0xc79552c704080c04, 0xc39d5ec323466523); + AS_UL2(&sharedMemory[0x234]) = make_ulonglong2(0x9637a19618302818, 0x9a2fb59a050a0f05); + AS_UL2(&sharedMemory[0x238]) = make_ulonglong2(0x12243612070e0907, 0xe2df3de2801b9b80); + AS_UL2(&sharedMemory[0x23C]) = make_ulonglong2(0x274e6927ebcd26eb, 0x75ea9f75b27fcdb2); + break; + case 2: + AS_UL2(&sharedMemory[0x240]) = make_ulonglong2(0x831d9e8309121b09, 0x1a342e1a2c58742c); + AS_UL2(&sharedMemory[0x244]) = make_ulonglong2(0x6edcb26e1b362d1b, 0xa05bfba05ab4ee5a); + AS_UL2(&sharedMemory[0x248]) = make_ulonglong2(0x3b764d3b52a4f652, 0xb37dceb3d6b761d6); + AS_UL2(&sharedMemory[0x24C]) = make_ulonglong2(0xe3dd3ee329527b29, 0x841397842f5e712f); + AS_UL2(&sharedMemory[0x250]) = make_ulonglong2(0xd1b968d153a6f553, 0xedc12ced00000000); + AS_UL2(&sharedMemory[0x254]) = make_ulonglong2(0xfce31ffc20406020, 0x5bb6ed5bb179c8b1); + AS_UL2(&sharedMemory[0x258]) = make_ulonglong2(0xcb8d46cb6ad4be6a, 0x39724b39be67d9be); + AS_UL2(&sharedMemory[0x25C]) = make_ulonglong2(0x4c98d44c4a94de4a, 0xcf854acf58b0e858); + break; + case 3: + AS_UL2(&sharedMemory[0x260]) = make_ulonglong2(0xefc52aefd0bb6bd0, 0xfbed16fbaa4fe5aa); + AS_UL2(&sharedMemory[0x264]) = make_ulonglong2(0x4d9ad74d4386c543, 0x8511948533665533); + AS_UL2(&sharedMemory[0x268]) = make_ulonglong2(0xf9e910f9458acf45, 0x7ffe817f02040602); + AS_UL2(&sharedMemory[0x26C]) = make_ulonglong2(0x3c78443c50a0f050, 0xa84be3a89f25ba9f); + AS_UL2(&sharedMemory[0x270]) = make_ulonglong2(0xa35dfea351a2f351, 0x8f058a8f4080c040); + AS_UL2(&sharedMemory[0x274]) = make_ulonglong2(0x9d21bc9d923fad92, 0xf5f104f538704838); + AS_UL2(&sharedMemory[0x278]) = make_ulonglong2(0xb677c1b6bc63dfbc, 0x21426321daaf75da); + AS_UL2(&sharedMemory[0x27C]) = make_ulonglong2(0xffe51aff10203010, 0xd2bf6dd2f3fd0ef3); + break; + case 4: + AS_UL2(&sharedMemory[0x280]) = make_ulonglong2(0x0c18140ccd814ccd, 0xecc32fec13263513); + AS_UL2(&sharedMemory[0x284]) = make_ulonglong2(0x9735a2975fbee15f, 0x172e39174488cc44); + AS_UL2(&sharedMemory[0x288]) = make_ulonglong2(0xa755f2a7c49357c4, 0x3d7a473d7efc827e); + AS_UL2(&sharedMemory[0x28C]) = make_ulonglong2(0x5dbae75d64c8ac64, 0x73e6957319322b19); + AS_UL2(&sharedMemory[0x290]) = make_ulonglong2(0x8119988160c0a060, 0xdca37fdc4f9ed14f); + AS_UL2(&sharedMemory[0x294]) = make_ulonglong2(0x2a547e2a22446622, 0x880b8388903bab90); + AS_UL2(&sharedMemory[0x298]) = make_ulonglong2(0xeec729ee468cca46, 0x14283c14b86bd3b8); + AS_UL2(&sharedMemory[0x29C]) = make_ulonglong2(0x5ebce25edea779de, 0xdbad76db0b161d0b); + break; + case 5: + AS_UL2(&sharedMemory[0x2A0]) = make_ulonglong2(0x32645632e0db3be0, 0x0a141e0a3a744e3a); + AS_UL2(&sharedMemory[0x2A4]) = make_ulonglong2(0x060c0a064992db49, 0x5cb8e45c24486c24); + AS_UL2(&sharedMemory[0x2A8]) = make_ulonglong2(0xd3bd6ed3c29f5dc2, 0x62c4a662ac43efac); + AS_UL2(&sharedMemory[0x2AC]) = make_ulonglong2(0x9531a4959139a891, 0x79f28b79e4d337e4); + AS_UL2(&sharedMemory[0x2B0]) = make_ulonglong2(0xc88b43c8e7d532e7, 0x6ddab76d376e5937); + AS_UL2(&sharedMemory[0x2B4]) = make_ulonglong2(0xd5b164d58d018c8d, 0xa949e0a94e9cd24e); + AS_UL2(&sharedMemory[0x2B8]) = make_ulonglong2(0x56acfa566cd8b46c, 0xeacf25eaf4f307f4); + AS_UL2(&sharedMemory[0x2BC]) = make_ulonglong2(0x7af48e7a65caaf65, 0x08101808ae47e9ae); + break; + case 6: + AS_UL2(&sharedMemory[0x2C0]) = make_ulonglong2(0x78f08878ba6fd5ba, 0x2e5c722e254a6f25); + AS_UL2(&sharedMemory[0x2C4]) = make_ulonglong2(0xa657f1a61c38241c, 0xc69751c6b473c7b4); + AS_UL2(&sharedMemory[0x2C8]) = make_ulonglong2(0xdda17cdde8cb23e8, 0x1f3e211f74e89c74); + AS_UL2(&sharedMemory[0x2CC]) = make_ulonglong2(0xbd61dcbd4b96dd4b, 0x8a0f858a8b0d868b); + AS_UL2(&sharedMemory[0x2D0]) = make_ulonglong2(0x3e7c423e70e09070, 0x66ccaa66b571c4b5); + AS_UL2(&sharedMemory[0x2D4]) = make_ulonglong2(0x030605034890d848, 0x0e1c120ef6f701f6); + AS_UL2(&sharedMemory[0x2D8]) = make_ulonglong2(0x356a5f3561c2a361, 0xb969d0b957aef957); + AS_UL2(&sharedMemory[0x2DC]) = make_ulonglong2(0xc19958c186179186, 0x9e27b99e1d3a271d); + break; + case 7: + AS_UL2(&sharedMemory[0x2E0]) = make_ulonglong2(0xf8eb13f8e1d938e1, 0x11223311982bb398); + AS_UL2(&sharedMemory[0x2E4]) = make_ulonglong2(0xd9a970d969d2bb69, 0x9433a7948e07898e); + AS_UL2(&sharedMemory[0x2E8]) = make_ulonglong2(0x1e3c221e9b2db69b, 0xe9c920e987159287); + AS_UL2(&sharedMemory[0x2EC]) = make_ulonglong2(0x55aaff55ce8749ce, 0xdfa57adf28507828); + AS_UL2(&sharedMemory[0x2F0]) = make_ulonglong2(0xa159f8a18c038f8c, 0x0d1a170d89098089); + AS_UL2(&sharedMemory[0x2F4]) = make_ulonglong2(0xe6d731e6bf65dabf, 0x68d0b8684284c642); + AS_UL2(&sharedMemory[0x2F8]) = make_ulonglong2(0x9929b0994182c341, 0x0f1e110f2d5a772d); + AS_UL2(&sharedMemory[0x2FC]) = make_ulonglong2(0x54a8fc54b07bcbb0, 0x162c3a16bb6dd6bb); + break; + } + // AES 3 + switch (threadIdx.x) { + case 0: + AS_UL2(&sharedMemory[0x300]) = make_ulonglong2(0xf8847c7cc6a56363, 0xf68d7b7bee997777); + AS_UL2(&sharedMemory[0x304]) = make_ulonglong2(0xd6bd6b6bff0df2f2, 0x9154c5c5deb16f6f); + AS_UL2(&sharedMemory[0x308]) = make_ulonglong2(0x0203010160503030, 0x567d2b2bcea96767); + AS_UL2(&sharedMemory[0x30C]) = make_ulonglong2(0xb562d7d7e719fefe, 0xec9a76764de6abab); + AS_UL2(&sharedMemory[0x310]) = make_ulonglong2(0x1f9d82828f45caca, 0xfa877d7d8940c9c9); + AS_UL2(&sharedMemory[0x314]) = make_ulonglong2(0xb2eb5959ef15fafa, 0xfb0bf0f08ec94747); + AS_UL2(&sharedMemory[0x318]) = make_ulonglong2(0xb367d4d441ecadad, 0x45eaafaf5ffda2a2); + AS_UL2(&sharedMemory[0x31C]) = make_ulonglong2(0x53f7a4a423bf9c9c, 0x9b5bc0c0e4967272); + break; + case 1: + AS_UL2(&sharedMemory[0x320]) = make_ulonglong2(0xe11cfdfd75c2b7b7, 0x4c6a26263dae9393); + AS_UL2(&sharedMemory[0x324]) = make_ulonglong2(0x7e413f3f6c5a3636, 0x834fccccf502f7f7); + AS_UL2(&sharedMemory[0x328]) = make_ulonglong2(0x51f4a5a5685c3434, 0xf908f1f1d134e5e5); + AS_UL2(&sharedMemory[0x32C]) = make_ulonglong2(0xab73d8d8e2937171, 0x2a3f151562533131); + AS_UL2(&sharedMemory[0x330]) = make_ulonglong2(0x9552c7c7080c0404, 0x9d5ec3c346652323); + AS_UL2(&sharedMemory[0x334]) = make_ulonglong2(0x37a1969630281818, 0x2fb59a9a0a0f0505); + AS_UL2(&sharedMemory[0x338]) = make_ulonglong2(0x243612120e090707, 0xdf3de2e21b9b8080); + AS_UL2(&sharedMemory[0x33C]) = make_ulonglong2(0x4e692727cd26ebeb, 0xea9f75757fcdb2b2); + break; + case 2: + AS_UL2(&sharedMemory[0x340]) = make_ulonglong2(0x1d9e8383121b0909, 0x342e1a1a58742c2c); + AS_UL2(&sharedMemory[0x344]) = make_ulonglong2(0xdcb26e6e362d1b1b, 0x5bfba0a0b4ee5a5a); + AS_UL2(&sharedMemory[0x348]) = make_ulonglong2(0x764d3b3ba4f65252, 0x7dceb3b3b761d6d6); + AS_UL2(&sharedMemory[0x34C]) = make_ulonglong2(0xdd3ee3e3527b2929, 0x139784845e712f2f); + AS_UL2(&sharedMemory[0x350]) = make_ulonglong2(0xb968d1d1a6f55353, 0xc12ceded00000000); + AS_UL2(&sharedMemory[0x354]) = make_ulonglong2(0xe31ffcfc40602020, 0xb6ed5b5b79c8b1b1); + AS_UL2(&sharedMemory[0x358]) = make_ulonglong2(0x8d46cbcbd4be6a6a, 0x724b393967d9bebe); + AS_UL2(&sharedMemory[0x35C]) = make_ulonglong2(0x98d44c4c94de4a4a, 0x854acfcfb0e85858); + break; + case 3: + AS_UL2(&sharedMemory[0x360]) = make_ulonglong2(0xc52aefefbb6bd0d0, 0xed16fbfb4fe5aaaa); + AS_UL2(&sharedMemory[0x364]) = make_ulonglong2(0x9ad74d4d86c54343, 0x1194858566553333); + AS_UL2(&sharedMemory[0x368]) = make_ulonglong2(0xe910f9f98acf4545, 0xfe817f7f04060202); + AS_UL2(&sharedMemory[0x36C]) = make_ulonglong2(0x78443c3ca0f05050, 0x4be3a8a825ba9f9f); + AS_UL2(&sharedMemory[0x370]) = make_ulonglong2(0x5dfea3a3a2f35151, 0x058a8f8f80c04040); + AS_UL2(&sharedMemory[0x374]) = make_ulonglong2(0x21bc9d9d3fad9292, 0xf104f5f570483838); + AS_UL2(&sharedMemory[0x378]) = make_ulonglong2(0x77c1b6b663dfbcbc, 0x42632121af75dada); + AS_UL2(&sharedMemory[0x37C]) = make_ulonglong2(0xe51affff20301010, 0xbf6dd2d2fd0ef3f3); + break; + case 4: + AS_UL2(&sharedMemory[0x380]) = make_ulonglong2(0x18140c0c814ccdcd, 0xc32fecec26351313); + AS_UL2(&sharedMemory[0x384]) = make_ulonglong2(0x35a29797bee15f5f, 0x2e39171788cc4444); + AS_UL2(&sharedMemory[0x388]) = make_ulonglong2(0x55f2a7a79357c4c4, 0x7a473d3dfc827e7e); + AS_UL2(&sharedMemory[0x38C]) = make_ulonglong2(0xbae75d5dc8ac6464, 0xe6957373322b1919); + AS_UL2(&sharedMemory[0x390]) = make_ulonglong2(0x19988181c0a06060, 0xa37fdcdc9ed14f4f); + AS_UL2(&sharedMemory[0x394]) = make_ulonglong2(0x547e2a2a44662222, 0x0b8388883bab9090); + AS_UL2(&sharedMemory[0x398]) = make_ulonglong2(0xc729eeee8cca4646, 0x283c14146bd3b8b8); + AS_UL2(&sharedMemory[0x39C]) = make_ulonglong2(0xbce25e5ea779dede, 0xad76dbdb161d0b0b); + break; + case 5: + AS_UL2(&sharedMemory[0x3A0]) = make_ulonglong2(0x64563232db3be0e0, 0x141e0a0a744e3a3a); + AS_UL2(&sharedMemory[0x3A4]) = make_ulonglong2(0x0c0a060692db4949, 0xb8e45c5c486c2424); + AS_UL2(&sharedMemory[0x3A8]) = make_ulonglong2(0xbd6ed3d39f5dc2c2, 0xc4a6626243efacac); + AS_UL2(&sharedMemory[0x3AC]) = make_ulonglong2(0x31a4959539a89191, 0xf28b7979d337e4e4); + AS_UL2(&sharedMemory[0x3B0]) = make_ulonglong2(0x8b43c8c8d532e7e7, 0xdab76d6d6e593737); + AS_UL2(&sharedMemory[0x3B4]) = make_ulonglong2(0xb164d5d5018c8d8d, 0x49e0a9a99cd24e4e); + AS_UL2(&sharedMemory[0x3B8]) = make_ulonglong2(0xacfa5656d8b46c6c, 0xcf25eaeaf307f4f4); + AS_UL2(&sharedMemory[0x3BC]) = make_ulonglong2(0xf48e7a7acaaf6565, 0x1018080847e9aeae); + break; + case 6: + AS_UL2(&sharedMemory[0x3C0]) = make_ulonglong2(0xf08878786fd5baba, 0x5c722e2e4a6f2525); + AS_UL2(&sharedMemory[0x3C4]) = make_ulonglong2(0x57f1a6a638241c1c, 0x9751c6c673c7b4b4); + AS_UL2(&sharedMemory[0x3C8]) = make_ulonglong2(0xa17cddddcb23e8e8, 0x3e211f1fe89c7474); + AS_UL2(&sharedMemory[0x3CC]) = make_ulonglong2(0x61dcbdbd96dd4b4b, 0x0f858a8a0d868b8b); + AS_UL2(&sharedMemory[0x3D0]) = make_ulonglong2(0x7c423e3ee0907070, 0xccaa666671c4b5b5); + AS_UL2(&sharedMemory[0x3D4]) = make_ulonglong2(0x0605030390d84848, 0x1c120e0ef701f6f6); + AS_UL2(&sharedMemory[0x3D8]) = make_ulonglong2(0x6a5f3535c2a36161, 0x69d0b9b9aef95757); + AS_UL2(&sharedMemory[0x3DC]) = make_ulonglong2(0x9958c1c117918686, 0x27b99e9e3a271d1d); + break; + case 7: + AS_UL2(&sharedMemory[0x3E0]) = make_ulonglong2(0xeb13f8f8d938e1e1, 0x223311112bb39898); + AS_UL2(&sharedMemory[0x3E4]) = make_ulonglong2(0xa970d9d9d2bb6969, 0x33a7949407898e8e); + AS_UL2(&sharedMemory[0x3E8]) = make_ulonglong2(0x3c221e1e2db69b9b, 0xc920e9e915928787); + AS_UL2(&sharedMemory[0x3EC]) = make_ulonglong2(0xaaff55558749cece, 0xa57adfdf50782828); + AS_UL2(&sharedMemory[0x3F0]) = make_ulonglong2(0x59f8a1a1038f8c8c, 0x1a170d0d09808989); + AS_UL2(&sharedMemory[0x3F4]) = make_ulonglong2(0xd731e6e665dabfbf, 0xd0b8686884c64242); + AS_UL2(&sharedMemory[0x3F8]) = make_ulonglong2(0x29b0999982c34141, 0x1e110f0f5a772d2d); + AS_UL2(&sharedMemory[0x3FC]) = make_ulonglong2(0xa8fc54547bcbb0b0, 0x2c3a16166dd6bbbb); + break; + } + //printf("%x\n", sharedMemory[0]); + //cn_aes_gpu_init2(sharedMemory); +} + +__device__ __forceinline__ +void cn_aes_gpu_init_u4(uint32_t* sharedMemory) +{ + // AES 0 + switch (threadIdx.x) { + case 0: + AS_UINT4(&sharedMemory[0x000]) = make_uint4(0xa56363c6, 0x847c7cf8, 0x997777ee, 0x8d7b7bf6); + AS_UINT4(&sharedMemory[0x004]) = make_uint4(0x0df2f2ff, 0xbd6b6bd6, 0xb16f6fde, 0x54c5c591); + AS_UINT4(&sharedMemory[0x008]) = make_uint4(0x50303060, 0x03010102, 0xa96767ce, 0x7d2b2b56); + AS_UINT4(&sharedMemory[0x00C]) = make_uint4(0x19fefee7, 0x62d7d7b5, 0xe6abab4d, 0x9a7676ec); + AS_UINT4(&sharedMemory[0x010]) = make_uint4(0x45caca8f, 0x9d82821f, 0x40c9c989, 0x877d7dfa); + AS_UINT4(&sharedMemory[0x014]) = make_uint4(0x15fafaef, 0xeb5959b2, 0xc947478e, 0x0bf0f0fb); + AS_UINT4(&sharedMemory[0x018]) = make_uint4(0xecadad41, 0x67d4d4b3, 0xfda2a25f, 0xeaafaf45); + AS_UINT4(&sharedMemory[0x01C]) = make_uint4(0xbf9c9c23, 0xf7a4a453, 0x967272e4, 0x5bc0c09b); + break; + case 1: + AS_UINT4(&sharedMemory[0x020]) = make_uint4(0xc2b7b775, 0x1cfdfde1, 0xae93933d, 0x6a26264c); + AS_UINT4(&sharedMemory[0x024]) = make_uint4(0x5a36366c, 0x413f3f7e, 0x02f7f7f5, 0x4fcccc83); + AS_UINT4(&sharedMemory[0x028]) = make_uint4(0x5c343468, 0xf4a5a551, 0x34e5e5d1, 0x08f1f1f9); + AS_UINT4(&sharedMemory[0x02C]) = make_uint4(0x937171e2, 0x73d8d8ab, 0x53313162, 0x3f15152a); + AS_UINT4(&sharedMemory[0x030]) = make_uint4(0x0c040408, 0x52c7c795, 0x65232346, 0x5ec3c39d); + AS_UINT4(&sharedMemory[0x034]) = make_uint4(0x28181830, 0xa1969637, 0x0f05050a, 0xb59a9a2f); + AS_UINT4(&sharedMemory[0x038]) = make_uint4(0x0907070e, 0x36121224, 0x9b80801b, 0x3de2e2df); + AS_UINT4(&sharedMemory[0x03C]) = make_uint4(0x26ebebcd, 0x6927274e, 0xcdb2b27f, 0x9f7575ea); + break; + case 2: + AS_UINT4(&sharedMemory[0x040]) = make_uint4(0x1b090912, 0x9e83831d, 0x742c2c58, 0x2e1a1a34); + AS_UINT4(&sharedMemory[0x044]) = make_uint4(0x2d1b1b36, 0xb26e6edc, 0xee5a5ab4, 0xfba0a05b); + AS_UINT4(&sharedMemory[0x048]) = make_uint4(0xf65252a4, 0x4d3b3b76, 0x61d6d6b7, 0xceb3b37d); + AS_UINT4(&sharedMemory[0x04C]) = make_uint4(0x7b292952, 0x3ee3e3dd, 0x712f2f5e, 0x97848413); + AS_UINT4(&sharedMemory[0x050]) = make_uint4(0xf55353a6, 0x68d1d1b9, 0x00000000, 0x2cededc1); + AS_UINT4(&sharedMemory[0x054]) = make_uint4(0x60202040, 0x1ffcfce3, 0xc8b1b179, 0xed5b5bb6); + AS_UINT4(&sharedMemory[0x058]) = make_uint4(0xbe6a6ad4, 0x46cbcb8d, 0xd9bebe67, 0x4b393972); + AS_UINT4(&sharedMemory[0x05C]) = make_uint4(0xde4a4a94, 0xd44c4c98, 0xe85858b0, 0x4acfcf85); + break; + case 3: + AS_UINT4(&sharedMemory[0x060]) = make_uint4(0x6bd0d0bb, 0x2aefefc5, 0xe5aaaa4f, 0x16fbfbed); + AS_UINT4(&sharedMemory[0x064]) = make_uint4(0xc5434386, 0xd74d4d9a, 0x55333366, 0x94858511); + AS_UINT4(&sharedMemory[0x068]) = make_uint4(0xcf45458a, 0x10f9f9e9, 0x06020204, 0x817f7ffe); + AS_UINT4(&sharedMemory[0x06C]) = make_uint4(0xf05050a0, 0x443c3c78, 0xba9f9f25, 0xe3a8a84b); + AS_UINT4(&sharedMemory[0x070]) = make_uint4(0xf35151a2, 0xfea3a35d, 0xc0404080, 0x8a8f8f05); + AS_UINT4(&sharedMemory[0x074]) = make_uint4(0xad92923f, 0xbc9d9d21, 0x48383870, 0x04f5f5f1); + AS_UINT4(&sharedMemory[0x078]) = make_uint4(0xdfbcbc63, 0xc1b6b677, 0x75dadaaf, 0x63212142); + AS_UINT4(&sharedMemory[0x07C]) = make_uint4(0x30101020, 0x1affffe5, 0x0ef3f3fd, 0x6dd2d2bf); + break; + case 4: + AS_UINT4(&sharedMemory[0x080]) = make_uint4(0x4ccdcd81, 0x140c0c18, 0x35131326, 0x2fececc3); + AS_UINT4(&sharedMemory[0x084]) = make_uint4(0xe15f5fbe, 0xa2979735, 0xcc444488, 0x3917172e); + AS_UINT4(&sharedMemory[0x088]) = make_uint4(0x57c4c493, 0xf2a7a755, 0x827e7efc, 0x473d3d7a); + AS_UINT4(&sharedMemory[0x08C]) = make_uint4(0xac6464c8, 0xe75d5dba, 0x2b191932, 0x957373e6); + AS_UINT4(&sharedMemory[0x090]) = make_uint4(0xa06060c0, 0x98818119, 0xd14f4f9e, 0x7fdcdca3); + AS_UINT4(&sharedMemory[0x094]) = make_uint4(0x66222244, 0x7e2a2a54, 0xab90903b, 0x8388880b); + AS_UINT4(&sharedMemory[0x098]) = make_uint4(0xca46468c, 0x29eeeec7, 0xd3b8b86b, 0x3c141428); + AS_UINT4(&sharedMemory[0x09C]) = make_uint4(0x79dedea7, 0xe25e5ebc, 0x1d0b0b16, 0x76dbdbad); + break; + case 5: + AS_UINT4(&sharedMemory[0x0A0]) = make_uint4(0x3be0e0db, 0x56323264, 0x4e3a3a74, 0x1e0a0a14); + AS_UINT4(&sharedMemory[0x0A4]) = make_uint4(0xdb494992, 0x0a06060c, 0x6c242448, 0xe45c5cb8); + AS_UINT4(&sharedMemory[0x0A8]) = make_uint4(0x5dc2c29f, 0x6ed3d3bd, 0xefacac43, 0xa66262c4); + AS_UINT4(&sharedMemory[0x0AC]) = make_uint4(0xa8919139, 0xa4959531, 0x37e4e4d3, 0x8b7979f2); + AS_UINT4(&sharedMemory[0x0B0]) = make_uint4(0x32e7e7d5, 0x43c8c88b, 0x5937376e, 0xb76d6dda); + AS_UINT4(&sharedMemory[0x0B4]) = make_uint4(0x8c8d8d01, 0x64d5d5b1, 0xd24e4e9c, 0xe0a9a949); + AS_UINT4(&sharedMemory[0x0B8]) = make_uint4(0xb46c6cd8, 0xfa5656ac, 0x07f4f4f3, 0x25eaeacf); + AS_UINT4(&sharedMemory[0x0BC]) = make_uint4(0xaf6565ca, 0x8e7a7af4, 0xe9aeae47, 0x18080810); + break; + case 6: + AS_UINT4(&sharedMemory[0x0C0]) = make_uint4(0xd5baba6f, 0x887878f0, 0x6f25254a, 0x722e2e5c); + AS_UINT4(&sharedMemory[0x0C4]) = make_uint4(0x241c1c38, 0xf1a6a657, 0xc7b4b473, 0x51c6c697); + AS_UINT4(&sharedMemory[0x0C8]) = make_uint4(0x23e8e8cb, 0x7cdddda1, 0x9c7474e8, 0x211f1f3e); + AS_UINT4(&sharedMemory[0x0CC]) = make_uint4(0xdd4b4b96, 0xdcbdbd61, 0x868b8b0d, 0x858a8a0f); + AS_UINT4(&sharedMemory[0x0D0]) = make_uint4(0x907070e0, 0x423e3e7c, 0xc4b5b571, 0xaa6666cc); + AS_UINT4(&sharedMemory[0x0D4]) = make_uint4(0xd8484890, 0x05030306, 0x01f6f6f7, 0x120e0e1c); + AS_UINT4(&sharedMemory[0x0D8]) = make_uint4(0xa36161c2, 0x5f35356a, 0xf95757ae, 0xd0b9b969); + AS_UINT4(&sharedMemory[0x0DC]) = make_uint4(0x91868617, 0x58c1c199, 0x271d1d3a, 0xb99e9e27); + break; + case 7: + AS_UINT4(&sharedMemory[0x0E0]) = make_uint4(0x38e1e1d9, 0x13f8f8eb, 0xb398982b, 0x33111122); + AS_UINT4(&sharedMemory[0x0E4]) = make_uint4(0xbb6969d2, 0x70d9d9a9, 0x898e8e07, 0xa7949433); + AS_UINT4(&sharedMemory[0x0E8]) = make_uint4(0xb69b9b2d, 0x221e1e3c, 0x92878715, 0x20e9e9c9); + AS_UINT4(&sharedMemory[0x0EC]) = make_uint4(0x49cece87, 0xff5555aa, 0x78282850, 0x7adfdfa5); + AS_UINT4(&sharedMemory[0x0F0]) = make_uint4(0x8f8c8c03, 0xf8a1a159, 0x80898909, 0x170d0d1a); + AS_UINT4(&sharedMemory[0x0F4]) = make_uint4(0xdabfbf65, 0x31e6e6d7, 0xc6424284, 0xb86868d0); + AS_UINT4(&sharedMemory[0x0F8]) = make_uint4(0xc3414182, 0xb0999929, 0x772d2d5a, 0x110f0f1e); + AS_UINT4(&sharedMemory[0x0FC]) = make_uint4(0xcbb0b07b, 0xfc5454a8, 0xd6bbbb6d, 0x3a16162c); + break; + } + // AES 1 + switch (threadIdx.x) { + case 0: + AS_UINT4(&sharedMemory[0x100]) = make_uint4(0x6363c6a5, 0x7c7cf884, 0x7777ee99, 0x7b7bf68d); + AS_UINT4(&sharedMemory[0x104]) = make_uint4(0xf2f2ff0d, 0x6b6bd6bd, 0x6f6fdeb1, 0xc5c59154); + AS_UINT4(&sharedMemory[0x108]) = make_uint4(0x30306050, 0x01010203, 0x6767cea9, 0x2b2b567d); + AS_UINT4(&sharedMemory[0x10C]) = make_uint4(0xfefee719, 0xd7d7b562, 0xabab4de6, 0x7676ec9a); + AS_UINT4(&sharedMemory[0x110]) = make_uint4(0xcaca8f45, 0x82821f9d, 0xc9c98940, 0x7d7dfa87); + AS_UINT4(&sharedMemory[0x114]) = make_uint4(0xfafaef15, 0x5959b2eb, 0x47478ec9, 0xf0f0fb0b); + AS_UINT4(&sharedMemory[0x118]) = make_uint4(0xadad41ec, 0xd4d4b367, 0xa2a25ffd, 0xafaf45ea); + AS_UINT4(&sharedMemory[0x11C]) = make_uint4(0x9c9c23bf, 0xa4a453f7, 0x7272e496, 0xc0c09b5b); + break; + case 1: + AS_UINT4(&sharedMemory[0x120]) = make_uint4(0xb7b775c2, 0xfdfde11c, 0x93933dae, 0x26264c6a); + AS_UINT4(&sharedMemory[0x124]) = make_uint4(0x36366c5a, 0x3f3f7e41, 0xf7f7f502, 0xcccc834f); + AS_UINT4(&sharedMemory[0x128]) = make_uint4(0x3434685c, 0xa5a551f4, 0xe5e5d134, 0xf1f1f908); + AS_UINT4(&sharedMemory[0x12C]) = make_uint4(0x7171e293, 0xd8d8ab73, 0x31316253, 0x15152a3f); + AS_UINT4(&sharedMemory[0x130]) = make_uint4(0x0404080c, 0xc7c79552, 0x23234665, 0xc3c39d5e); + AS_UINT4(&sharedMemory[0x134]) = make_uint4(0x18183028, 0x969637a1, 0x05050a0f, 0x9a9a2fb5); + AS_UINT4(&sharedMemory[0x138]) = make_uint4(0x07070e09, 0x12122436, 0x80801b9b, 0xe2e2df3d); + AS_UINT4(&sharedMemory[0x13C]) = make_uint4(0xebebcd26, 0x27274e69, 0xb2b27fcd, 0x7575ea9f); + break; + case 2: + AS_UINT4(&sharedMemory[0x140]) = make_uint4(0x0909121b, 0x83831d9e, 0x2c2c5874, 0x1a1a342e); + AS_UINT4(&sharedMemory[0x144]) = make_uint4(0x1b1b362d, 0x6e6edcb2, 0x5a5ab4ee, 0xa0a05bfb); + AS_UINT4(&sharedMemory[0x148]) = make_uint4(0x5252a4f6, 0x3b3b764d, 0xd6d6b761, 0xb3b37dce); + AS_UINT4(&sharedMemory[0x14C]) = make_uint4(0x2929527b, 0xe3e3dd3e, 0x2f2f5e71, 0x84841397); + AS_UINT4(&sharedMemory[0x150]) = make_uint4(0x5353a6f5, 0xd1d1b968, 0x00000000, 0xededc12c); + AS_UINT4(&sharedMemory[0x154]) = make_uint4(0x20204060, 0xfcfce31f, 0xb1b179c8, 0x5b5bb6ed); + AS_UINT4(&sharedMemory[0x158]) = make_uint4(0x6a6ad4be, 0xcbcb8d46, 0xbebe67d9, 0x3939724b); + AS_UINT4(&sharedMemory[0x15C]) = make_uint4(0x4a4a94de, 0x4c4c98d4, 0x5858b0e8, 0xcfcf854a); + break; + case 3: + AS_UINT4(&sharedMemory[0x160]) = make_uint4(0xd0d0bb6b, 0xefefc52a, 0xaaaa4fe5, 0xfbfbed16); + AS_UINT4(&sharedMemory[0x164]) = make_uint4(0x434386c5, 0x4d4d9ad7, 0x33336655, 0x85851194); + AS_UINT4(&sharedMemory[0x168]) = make_uint4(0x45458acf, 0xf9f9e910, 0x02020406, 0x7f7ffe81); + AS_UINT4(&sharedMemory[0x16C]) = make_uint4(0x5050a0f0, 0x3c3c7844, 0x9f9f25ba, 0xa8a84be3); + AS_UINT4(&sharedMemory[0x170]) = make_uint4(0x5151a2f3, 0xa3a35dfe, 0x404080c0, 0x8f8f058a); + AS_UINT4(&sharedMemory[0x174]) = make_uint4(0x92923fad, 0x9d9d21bc, 0x38387048, 0xf5f5f104); + AS_UINT4(&sharedMemory[0x178]) = make_uint4(0xbcbc63df, 0xb6b677c1, 0xdadaaf75, 0x21214263); + AS_UINT4(&sharedMemory[0x17C]) = make_uint4(0x10102030, 0xffffe51a, 0xf3f3fd0e, 0xd2d2bf6d); + break; + case 4: + AS_UINT4(&sharedMemory[0x180]) = make_uint4(0xcdcd814c, 0x0c0c1814, 0x13132635, 0xececc32f); + AS_UINT4(&sharedMemory[0x184]) = make_uint4(0x5f5fbee1, 0x979735a2, 0x444488cc, 0x17172e39); + AS_UINT4(&sharedMemory[0x188]) = make_uint4(0xc4c49357, 0xa7a755f2, 0x7e7efc82, 0x3d3d7a47); + AS_UINT4(&sharedMemory[0x18C]) = make_uint4(0x6464c8ac, 0x5d5dbae7, 0x1919322b, 0x7373e695); + AS_UINT4(&sharedMemory[0x190]) = make_uint4(0x6060c0a0, 0x81811998, 0x4f4f9ed1, 0xdcdca37f); + AS_UINT4(&sharedMemory[0x194]) = make_uint4(0x22224466, 0x2a2a547e, 0x90903bab, 0x88880b83); + AS_UINT4(&sharedMemory[0x198]) = make_uint4(0x46468cca, 0xeeeec729, 0xb8b86bd3, 0x1414283c); + AS_UINT4(&sharedMemory[0x19C]) = make_uint4(0xdedea779, 0x5e5ebce2, 0x0b0b161d, 0xdbdbad76); + break; + case 5: + AS_UINT4(&sharedMemory[0x1A0]) = make_uint4(0xe0e0db3b, 0x32326456, 0x3a3a744e, 0x0a0a141e); + AS_UINT4(&sharedMemory[0x1A4]) = make_uint4(0x494992db, 0x06060c0a, 0x2424486c, 0x5c5cb8e4); + AS_UINT4(&sharedMemory[0x1A8]) = make_uint4(0xc2c29f5d, 0xd3d3bd6e, 0xacac43ef, 0x6262c4a6); + AS_UINT4(&sharedMemory[0x1AC]) = make_uint4(0x919139a8, 0x959531a4, 0xe4e4d337, 0x7979f28b); + AS_UINT4(&sharedMemory[0x1B0]) = make_uint4(0xe7e7d532, 0xc8c88b43, 0x37376e59, 0x6d6ddab7); + AS_UINT4(&sharedMemory[0x1B4]) = make_uint4(0x8d8d018c, 0xd5d5b164, 0x4e4e9cd2, 0xa9a949e0); + AS_UINT4(&sharedMemory[0x1B8]) = make_uint4(0x6c6cd8b4, 0x5656acfa, 0xf4f4f307, 0xeaeacf25); + AS_UINT4(&sharedMemory[0x1BC]) = make_uint4(0x6565caaf, 0x7a7af48e, 0xaeae47e9, 0x08081018); + break; + case 6: + AS_UINT4(&sharedMemory[0x1C0]) = make_uint4(0xbaba6fd5, 0x7878f088, 0x25254a6f, 0x2e2e5c72); + AS_UINT4(&sharedMemory[0x1C4]) = make_uint4(0x1c1c3824, 0xa6a657f1, 0xb4b473c7, 0xc6c69751); + AS_UINT4(&sharedMemory[0x1C8]) = make_uint4(0xe8e8cb23, 0xdddda17c, 0x7474e89c, 0x1f1f3e21); + AS_UINT4(&sharedMemory[0x1CC]) = make_uint4(0x4b4b96dd, 0xbdbd61dc, 0x8b8b0d86, 0x8a8a0f85); + AS_UINT4(&sharedMemory[0x1D0]) = make_uint4(0x7070e090, 0x3e3e7c42, 0xb5b571c4, 0x6666ccaa); + AS_UINT4(&sharedMemory[0x1D4]) = make_uint4(0x484890d8, 0x03030605, 0xf6f6f701, 0x0e0e1c12); + AS_UINT4(&sharedMemory[0x1D8]) = make_uint4(0x6161c2a3, 0x35356a5f, 0x5757aef9, 0xb9b969d0); + AS_UINT4(&sharedMemory[0x1DC]) = make_uint4(0x86861791, 0xc1c19958, 0x1d1d3a27, 0x9e9e27b9); + break; + case 7: + AS_UINT4(&sharedMemory[0x1E0]) = make_uint4(0xe1e1d938, 0xf8f8eb13, 0x98982bb3, 0x11112233); + AS_UINT4(&sharedMemory[0x1E4]) = make_uint4(0x6969d2bb, 0xd9d9a970, 0x8e8e0789, 0x949433a7); + AS_UINT4(&sharedMemory[0x1E8]) = make_uint4(0x9b9b2db6, 0x1e1e3c22, 0x87871592, 0xe9e9c920); + AS_UINT4(&sharedMemory[0x1EC]) = make_uint4(0xcece8749, 0x5555aaff, 0x28285078, 0xdfdfa57a); + AS_UINT4(&sharedMemory[0x1F0]) = make_uint4(0x8c8c038f, 0xa1a159f8, 0x89890980, 0x0d0d1a17); + AS_UINT4(&sharedMemory[0x1F4]) = make_uint4(0xbfbf65da, 0xe6e6d731, 0x424284c6, 0x6868d0b8); + AS_UINT4(&sharedMemory[0x1F8]) = make_uint4(0x414182c3, 0x999929b0, 0x2d2d5a77, 0x0f0f1e11); + AS_UINT4(&sharedMemory[0x1FC]) = make_uint4(0xb0b07bcb, 0x5454a8fc, 0xbbbb6dd6, 0x16162c3a); + break; + } + // AES 2 + switch (threadIdx.x) { + case 0: + AS_UINT4(&sharedMemory[0x200]) = make_uint4(0x63c6a563, 0x7cf8847c, 0x77ee9977, 0x7bf68d7b); + AS_UINT4(&sharedMemory[0x204]) = make_uint4(0xf2ff0df2, 0x6bd6bd6b, 0x6fdeb16f, 0xc59154c5); + AS_UINT4(&sharedMemory[0x208]) = make_uint4(0x30605030, 0x01020301, 0x67cea967, 0x2b567d2b); + AS_UINT4(&sharedMemory[0x20C]) = make_uint4(0xfee719fe, 0xd7b562d7, 0xab4de6ab, 0x76ec9a76); + AS_UINT4(&sharedMemory[0x210]) = make_uint4(0xca8f45ca, 0x821f9d82, 0xc98940c9, 0x7dfa877d); + AS_UINT4(&sharedMemory[0x214]) = make_uint4(0xfaef15fa, 0x59b2eb59, 0x478ec947, 0xf0fb0bf0); + AS_UINT4(&sharedMemory[0x218]) = make_uint4(0xad41ecad, 0xd4b367d4, 0xa25ffda2, 0xaf45eaaf); + AS_UINT4(&sharedMemory[0x21C]) = make_uint4(0x9c23bf9c, 0xa453f7a4, 0x72e49672, 0xc09b5bc0); + break; + case 1: + AS_UINT4(&sharedMemory[0x220]) = make_uint4(0xb775c2b7, 0xfde11cfd, 0x933dae93, 0x264c6a26); + AS_UINT4(&sharedMemory[0x224]) = make_uint4(0x366c5a36, 0x3f7e413f, 0xf7f502f7, 0xcc834fcc); + AS_UINT4(&sharedMemory[0x228]) = make_uint4(0x34685c34, 0xa551f4a5, 0xe5d134e5, 0xf1f908f1); + AS_UINT4(&sharedMemory[0x22C]) = make_uint4(0x71e29371, 0xd8ab73d8, 0x31625331, 0x152a3f15); + AS_UINT4(&sharedMemory[0x230]) = make_uint4(0x04080c04, 0xc79552c7, 0x23466523, 0xc39d5ec3); + AS_UINT4(&sharedMemory[0x234]) = make_uint4(0x18302818, 0x9637a196, 0x050a0f05, 0x9a2fb59a); + AS_UINT4(&sharedMemory[0x238]) = make_uint4(0x070e0907, 0x12243612, 0x801b9b80, 0xe2df3de2); + AS_UINT4(&sharedMemory[0x23C]) = make_uint4(0xebcd26eb, 0x274e6927, 0xb27fcdb2, 0x75ea9f75); + break; + case 2: + AS_UINT4(&sharedMemory[0x240]) = make_uint4(0x09121b09, 0x831d9e83, 0x2c58742c, 0x1a342e1a); + AS_UINT4(&sharedMemory[0x244]) = make_uint4(0x1b362d1b, 0x6edcb26e, 0x5ab4ee5a, 0xa05bfba0); + AS_UINT4(&sharedMemory[0x248]) = make_uint4(0x52a4f652, 0x3b764d3b, 0xd6b761d6, 0xb37dceb3); + AS_UINT4(&sharedMemory[0x24C]) = make_uint4(0x29527b29, 0xe3dd3ee3, 0x2f5e712f, 0x84139784); + AS_UINT4(&sharedMemory[0x250]) = make_uint4(0x53a6f553, 0xd1b968d1, 0x00000000, 0xedc12ced); + AS_UINT4(&sharedMemory[0x254]) = make_uint4(0x20406020, 0xfce31ffc, 0xb179c8b1, 0x5bb6ed5b); + AS_UINT4(&sharedMemory[0x258]) = make_uint4(0x6ad4be6a, 0xcb8d46cb, 0xbe67d9be, 0x39724b39); + AS_UINT4(&sharedMemory[0x25C]) = make_uint4(0x4a94de4a, 0x4c98d44c, 0x58b0e858, 0xcf854acf); + break; + case 3: + AS_UINT4(&sharedMemory[0x260]) = make_uint4(0xd0bb6bd0, 0xefc52aef, 0xaa4fe5aa, 0xfbed16fb); + AS_UINT4(&sharedMemory[0x264]) = make_uint4(0x4386c543, 0x4d9ad74d, 0x33665533, 0x85119485); + AS_UINT4(&sharedMemory[0x268]) = make_uint4(0x458acf45, 0xf9e910f9, 0x02040602, 0x7ffe817f); + AS_UINT4(&sharedMemory[0x26C]) = make_uint4(0x50a0f050, 0x3c78443c, 0x9f25ba9f, 0xa84be3a8); + AS_UINT4(&sharedMemory[0x270]) = make_uint4(0x51a2f351, 0xa35dfea3, 0x4080c040, 0x8f058a8f); + AS_UINT4(&sharedMemory[0x274]) = make_uint4(0x923fad92, 0x9d21bc9d, 0x38704838, 0xf5f104f5); + AS_UINT4(&sharedMemory[0x278]) = make_uint4(0xbc63dfbc, 0xb677c1b6, 0xdaaf75da, 0x21426321); + AS_UINT4(&sharedMemory[0x27C]) = make_uint4(0x10203010, 0xffe51aff, 0xf3fd0ef3, 0xd2bf6dd2); + break; + case 4: + AS_UINT4(&sharedMemory[0x280]) = make_uint4(0xcd814ccd, 0x0c18140c, 0x13263513, 0xecc32fec); + AS_UINT4(&sharedMemory[0x284]) = make_uint4(0x5fbee15f, 0x9735a297, 0x4488cc44, 0x172e3917); + AS_UINT4(&sharedMemory[0x288]) = make_uint4(0xc49357c4, 0xa755f2a7, 0x7efc827e, 0x3d7a473d); + AS_UINT4(&sharedMemory[0x28C]) = make_uint4(0x64c8ac64, 0x5dbae75d, 0x19322b19, 0x73e69573); + AS_UINT4(&sharedMemory[0x290]) = make_uint4(0x60c0a060, 0x81199881, 0x4f9ed14f, 0xdca37fdc); + AS_UINT4(&sharedMemory[0x294]) = make_uint4(0x22446622, 0x2a547e2a, 0x903bab90, 0x880b8388); + AS_UINT4(&sharedMemory[0x298]) = make_uint4(0x468cca46, 0xeec729ee, 0xb86bd3b8, 0x14283c14); + AS_UINT4(&sharedMemory[0x29C]) = make_uint4(0xdea779de, 0x5ebce25e, 0x0b161d0b, 0xdbad76db); + break; + case 5: + AS_UINT4(&sharedMemory[0x2A0]) = make_uint4(0xe0db3be0, 0x32645632, 0x3a744e3a, 0x0a141e0a); + AS_UINT4(&sharedMemory[0x2A4]) = make_uint4(0x4992db49, 0x060c0a06, 0x24486c24, 0x5cb8e45c); + AS_UINT4(&sharedMemory[0x2A8]) = make_uint4(0xc29f5dc2, 0xd3bd6ed3, 0xac43efac, 0x62c4a662); + AS_UINT4(&sharedMemory[0x2AC]) = make_uint4(0x9139a891, 0x9531a495, 0xe4d337e4, 0x79f28b79); + AS_UINT4(&sharedMemory[0x2B0]) = make_uint4(0xe7d532e7, 0xc88b43c8, 0x376e5937, 0x6ddab76d); + AS_UINT4(&sharedMemory[0x2B4]) = make_uint4(0x8d018c8d, 0xd5b164d5, 0x4e9cd24e, 0xa949e0a9); + AS_UINT4(&sharedMemory[0x2B8]) = make_uint4(0x6cd8b46c, 0x56acfa56, 0xf4f307f4, 0xeacf25ea); + AS_UINT4(&sharedMemory[0x2BC]) = make_uint4(0x65caaf65, 0x7af48e7a, 0xae47e9ae, 0x08101808); + break; + case 6: + AS_UINT4(&sharedMemory[0x2C0]) = make_uint4(0xba6fd5ba, 0x78f08878, 0x254a6f25, 0x2e5c722e); + AS_UINT4(&sharedMemory[0x2C4]) = make_uint4(0x1c38241c, 0xa657f1a6, 0xb473c7b4, 0xc69751c6); + AS_UINT4(&sharedMemory[0x2C8]) = make_uint4(0xe8cb23e8, 0xdda17cdd, 0x74e89c74, 0x1f3e211f); + AS_UINT4(&sharedMemory[0x2CC]) = make_uint4(0x4b96dd4b, 0xbd61dcbd, 0x8b0d868b, 0x8a0f858a); + AS_UINT4(&sharedMemory[0x2D0]) = make_uint4(0x70e09070, 0x3e7c423e, 0xb571c4b5, 0x66ccaa66); + AS_UINT4(&sharedMemory[0x2D4]) = make_uint4(0x4890d848, 0x03060503, 0xf6f701f6, 0x0e1c120e); + AS_UINT4(&sharedMemory[0x2D8]) = make_uint4(0x61c2a361, 0x356a5f35, 0x57aef957, 0xb969d0b9); + AS_UINT4(&sharedMemory[0x2DC]) = make_uint4(0x86179186, 0xc19958c1, 0x1d3a271d, 0x9e27b99e); + break; + case 7: + AS_UINT4(&sharedMemory[0x2E0]) = make_uint4(0xe1d938e1, 0xf8eb13f8, 0x982bb398, 0x11223311); + AS_UINT4(&sharedMemory[0x2E4]) = make_uint4(0x69d2bb69, 0xd9a970d9, 0x8e07898e, 0x9433a794); + AS_UINT4(&sharedMemory[0x2E8]) = make_uint4(0x9b2db69b, 0x1e3c221e, 0x87159287, 0xe9c920e9); + AS_UINT4(&sharedMemory[0x2EC]) = make_uint4(0xce8749ce, 0x55aaff55, 0x28507828, 0xdfa57adf); + AS_UINT4(&sharedMemory[0x2F0]) = make_uint4(0x8c038f8c, 0xa159f8a1, 0x89098089, 0x0d1a170d); + AS_UINT4(&sharedMemory[0x2F4]) = make_uint4(0xbf65dabf, 0xe6d731e6, 0x4284c642, 0x68d0b868); + AS_UINT4(&sharedMemory[0x2F8]) = make_uint4(0x4182c341, 0x9929b099, 0x2d5a772d, 0x0f1e110f); + AS_UINT4(&sharedMemory[0x2FC]) = make_uint4(0xb07bcbb0, 0x54a8fc54, 0xbb6dd6bb, 0x162c3a16); + break; + } + // AES 3 + switch (threadIdx.x) { + case 0: + AS_UINT4(&sharedMemory[0x300]) = make_uint4(0xc6a56363, 0xf8847c7c, 0xee997777, 0xf68d7b7b); + AS_UINT4(&sharedMemory[0x304]) = make_uint4(0xff0df2f2, 0xd6bd6b6b, 0xdeb16f6f, 0x9154c5c5); + AS_UINT4(&sharedMemory[0x308]) = make_uint4(0x60503030, 0x02030101, 0xcea96767, 0x567d2b2b); + AS_UINT4(&sharedMemory[0x30C]) = make_uint4(0xe719fefe, 0xb562d7d7, 0x4de6abab, 0xec9a7676); + AS_UINT4(&sharedMemory[0x310]) = make_uint4(0x8f45caca, 0x1f9d8282, 0x8940c9c9, 0xfa877d7d); + AS_UINT4(&sharedMemory[0x314]) = make_uint4(0xef15fafa, 0xb2eb5959, 0x8ec94747, 0xfb0bf0f0); + AS_UINT4(&sharedMemory[0x318]) = make_uint4(0x41ecadad, 0xb367d4d4, 0x5ffda2a2, 0x45eaafaf); + AS_UINT4(&sharedMemory[0x31C]) = make_uint4(0x23bf9c9c, 0x53f7a4a4, 0xe4967272, 0x9b5bc0c0); + break; + case 1: + AS_UINT4(&sharedMemory[0x320]) = make_uint4(0x75c2b7b7, 0xe11cfdfd, 0x3dae9393, 0x4c6a2626); + AS_UINT4(&sharedMemory[0x324]) = make_uint4(0x6c5a3636, 0x7e413f3f, 0xf502f7f7, 0x834fcccc); + AS_UINT4(&sharedMemory[0x328]) = make_uint4(0x685c3434, 0x51f4a5a5, 0xd134e5e5, 0xf908f1f1); + AS_UINT4(&sharedMemory[0x32C]) = make_uint4(0xe2937171, 0xab73d8d8, 0x62533131, 0x2a3f1515); + AS_UINT4(&sharedMemory[0x330]) = make_uint4(0x080c0404, 0x9552c7c7, 0x46652323, 0x9d5ec3c3); + AS_UINT4(&sharedMemory[0x334]) = make_uint4(0x30281818, 0x37a19696, 0x0a0f0505, 0x2fb59a9a); + AS_UINT4(&sharedMemory[0x338]) = make_uint4(0x0e090707, 0x24361212, 0x1b9b8080, 0xdf3de2e2); + AS_UINT4(&sharedMemory[0x33C]) = make_uint4(0xcd26ebeb, 0x4e692727, 0x7fcdb2b2, 0xea9f7575); + break; + case 2: + AS_UINT4(&sharedMemory[0x340]) = make_uint4(0x121b0909, 0x1d9e8383, 0x58742c2c, 0x342e1a1a); + AS_UINT4(&sharedMemory[0x344]) = make_uint4(0x362d1b1b, 0xdcb26e6e, 0xb4ee5a5a, 0x5bfba0a0); + AS_UINT4(&sharedMemory[0x348]) = make_uint4(0xa4f65252, 0x764d3b3b, 0xb761d6d6, 0x7dceb3b3); + AS_UINT4(&sharedMemory[0x34C]) = make_uint4(0x527b2929, 0xdd3ee3e3, 0x5e712f2f, 0x13978484); + AS_UINT4(&sharedMemory[0x350]) = make_uint4(0xa6f55353, 0xb968d1d1, 0x00000000, 0xc12ceded); + AS_UINT4(&sharedMemory[0x354]) = make_uint4(0x40602020, 0xe31ffcfc, 0x79c8b1b1, 0xb6ed5b5b); + AS_UINT4(&sharedMemory[0x358]) = make_uint4(0xd4be6a6a, 0x8d46cbcb, 0x67d9bebe, 0x724b3939); + AS_UINT4(&sharedMemory[0x35C]) = make_uint4(0x94de4a4a, 0x98d44c4c, 0xb0e85858, 0x854acfcf); + break; + case 3: + AS_UINT4(&sharedMemory[0x360]) = make_uint4(0xbb6bd0d0, 0xc52aefef, 0x4fe5aaaa, 0xed16fbfb); + AS_UINT4(&sharedMemory[0x364]) = make_uint4(0x86c54343, 0x9ad74d4d, 0x66553333, 0x11948585); + AS_UINT4(&sharedMemory[0x368]) = make_uint4(0x8acf4545, 0xe910f9f9, 0x04060202, 0xfe817f7f); + AS_UINT4(&sharedMemory[0x36C]) = make_uint4(0xa0f05050, 0x78443c3c, 0x25ba9f9f, 0x4be3a8a8); + AS_UINT4(&sharedMemory[0x370]) = make_uint4(0xa2f35151, 0x5dfea3a3, 0x80c04040, 0x058a8f8f); + AS_UINT4(&sharedMemory[0x374]) = make_uint4(0x3fad9292, 0x21bc9d9d, 0x70483838, 0xf104f5f5); + AS_UINT4(&sharedMemory[0x378]) = make_uint4(0x63dfbcbc, 0x77c1b6b6, 0xaf75dada, 0x42632121); + AS_UINT4(&sharedMemory[0x37C]) = make_uint4(0x20301010, 0xe51affff, 0xfd0ef3f3, 0xbf6dd2d2); + break; + case 4: + AS_UINT4(&sharedMemory[0x380]) = make_uint4(0x814ccdcd, 0x18140c0c, 0x26351313, 0xc32fecec); + AS_UINT4(&sharedMemory[0x384]) = make_uint4(0xbee15f5f, 0x35a29797, 0x88cc4444, 0x2e391717); + AS_UINT4(&sharedMemory[0x388]) = make_uint4(0x9357c4c4, 0x55f2a7a7, 0xfc827e7e, 0x7a473d3d); + AS_UINT4(&sharedMemory[0x38C]) = make_uint4(0xc8ac6464, 0xbae75d5d, 0x322b1919, 0xe6957373); + AS_UINT4(&sharedMemory[0x390]) = make_uint4(0xc0a06060, 0x19988181, 0x9ed14f4f, 0xa37fdcdc); + AS_UINT4(&sharedMemory[0x394]) = make_uint4(0x44662222, 0x547e2a2a, 0x3bab9090, 0x0b838888); + AS_UINT4(&sharedMemory[0x398]) = make_uint4(0x8cca4646, 0xc729eeee, 0x6bd3b8b8, 0x283c1414); + AS_UINT4(&sharedMemory[0x39C]) = make_uint4(0xa779dede, 0xbce25e5e, 0x161d0b0b, 0xad76dbdb); + break; + case 5: + AS_UINT4(&sharedMemory[0x3A0]) = make_uint4(0xdb3be0e0, 0x64563232, 0x744e3a3a, 0x141e0a0a); + AS_UINT4(&sharedMemory[0x3A4]) = make_uint4(0x92db4949, 0x0c0a0606, 0x486c2424, 0xb8e45c5c); + AS_UINT4(&sharedMemory[0x3A8]) = make_uint4(0x9f5dc2c2, 0xbd6ed3d3, 0x43efacac, 0xc4a66262); + AS_UINT4(&sharedMemory[0x3AC]) = make_uint4(0x39a89191, 0x31a49595, 0xd337e4e4, 0xf28b7979); + AS_UINT4(&sharedMemory[0x3B0]) = make_uint4(0xd532e7e7, 0x8b43c8c8, 0x6e593737, 0xdab76d6d); + AS_UINT4(&sharedMemory[0x3B4]) = make_uint4(0x018c8d8d, 0xb164d5d5, 0x9cd24e4e, 0x49e0a9a9); + AS_UINT4(&sharedMemory[0x3B8]) = make_uint4(0xd8b46c6c, 0xacfa5656, 0xf307f4f4, 0xcf25eaea); + AS_UINT4(&sharedMemory[0x3BC]) = make_uint4(0xcaaf6565, 0xf48e7a7a, 0x47e9aeae, 0x10180808); + break; + case 6: + AS_UINT4(&sharedMemory[0x3C0]) = make_uint4(0x6fd5baba, 0xf0887878, 0x4a6f2525, 0x5c722e2e); + AS_UINT4(&sharedMemory[0x3C4]) = make_uint4(0x38241c1c, 0x57f1a6a6, 0x73c7b4b4, 0x9751c6c6); + AS_UINT4(&sharedMemory[0x3C8]) = make_uint4(0xcb23e8e8, 0xa17cdddd, 0xe89c7474, 0x3e211f1f); + AS_UINT4(&sharedMemory[0x3CC]) = make_uint4(0x96dd4b4b, 0x61dcbdbd, 0x0d868b8b, 0x0f858a8a); + AS_UINT4(&sharedMemory[0x3D0]) = make_uint4(0xe0907070, 0x7c423e3e, 0x71c4b5b5, 0xccaa6666); + AS_UINT4(&sharedMemory[0x3D4]) = make_uint4(0x90d84848, 0x06050303, 0xf701f6f6, 0x1c120e0e); + AS_UINT4(&sharedMemory[0x3D8]) = make_uint4(0xc2a36161, 0x6a5f3535, 0xaef95757, 0x69d0b9b9); + AS_UINT4(&sharedMemory[0x3DC]) = make_uint4(0x17918686, 0x9958c1c1, 0x3a271d1d, 0x27b99e9e); + break; + case 7: + AS_UINT4(&sharedMemory[0x3E0]) = make_uint4(0xd938e1e1, 0xeb13f8f8, 0x2bb39898, 0x22331111); + AS_UINT4(&sharedMemory[0x3E4]) = make_uint4(0xd2bb6969, 0xa970d9d9, 0x07898e8e, 0x33a79494); + AS_UINT4(&sharedMemory[0x3E8]) = make_uint4(0x2db69b9b, 0x3c221e1e, 0x15928787, 0xc920e9e9); + AS_UINT4(&sharedMemory[0x3EC]) = make_uint4(0x8749cece, 0xaaff5555, 0x50782828, 0xa57adfdf); + AS_UINT4(&sharedMemory[0x3F0]) = make_uint4(0x038f8c8c, 0x59f8a1a1, 0x09808989, 0x1a170d0d); + AS_UINT4(&sharedMemory[0x3F4]) = make_uint4(0x65dabfbf, 0xd731e6e6, 0x84c64242, 0xd0b86868); + AS_UINT4(&sharedMemory[0x3F8]) = make_uint4(0x82c34141, 0x29b09999, 0x5a772d2d, 0x1e110f0f); + AS_UINT4(&sharedMemory[0x3FC]) = make_uint4(0x7bcbb0b0, 0xa8fc5454, 0x6dd6bbbb, 0x2c3a1616); + break; + } +} diff --git a/crypto/cryptolight-core.cu b/crypto/cryptolight-core.cu index b381e30..3891768 100644 --- a/crypto/cryptolight-core.cu +++ b/crypto/cryptolight-core.cu @@ -8,8 +8,6 @@ #define LONG_SHL_IDX 18 #define LONG_LOOPS32 0x40000 -extern int device_backoff[MAX_GPUS]; - #include "cn_aes.cuh" #define MUL_SUM_XOR_DST(a,c,dst) { \ @@ -27,7 +25,7 @@ __device__ __forceinline__ uint64_t cuda_mul128(uint64_t multiplier, uint64_t mu } __global__ -void cryptolight_core_gpu_phase1(int threads, uint32_t * __restrict__ long_state, uint32_t * __restrict__ ctx_state, uint32_t * __restrict__ ctx_key1) +void cryptolight_core_gpu_phase1(int threads, uint32_t * long_state, uint32_t * ctx_state, uint32_t * ctx_key1) { __shared__ uint32_t __align__(16) sharedMemory[1024]; @@ -38,7 +36,7 @@ void cryptolight_core_gpu_phase1(int threads, uint32_t * __restrict__ long_state if(thread < threads) { - const int oft = thread * 50 + sub + 16; // not aligned 16! + const int oft = thread * 52 + sub + 16; // not aligned 16! const int long_oft = (thread << LONG_SHL_IDX) + sub; uint32_t __align__(16) key[40]; uint32_t __align__(16) text[4]; @@ -212,7 +210,7 @@ void cryptolight_core_gpu_phase2(const int threads, const int bfactor, const int } __global__ -void cryptolight_core_gpu_phase3(int threads, const uint32_t * __restrict__ long_state, uint32_t * __restrict__ ctx_state, uint32_t * __restrict__ ctx_key2) +void cryptolight_core_gpu_phase3(int threads, const uint32_t * long_state, uint32_t * ctx_state, uint32_t * ctx_key2) { __shared__ uint32_t __align__(16) sharedMemory[1024]; @@ -224,9 +222,9 @@ void cryptolight_core_gpu_phase3(int threads, const uint32_t * __restrict__ long if(thread < threads) { const int long_oft = (thread << LONG_SHL_IDX) + sub; - const int oft = thread * 50 + sub + 16; + const int oft = thread * 52 + sub + 16; uint32_t __align__(16) key[40]; - uint32_t __align__(8) text[4]; + uint32_t __align__(16) text[4]; #pragma unroll for (int i = 0; i < 40; i += 4) @@ -253,7 +251,8 @@ void cryptolight_core_gpu_phase3(int threads, const uint32_t * __restrict__ long extern int device_bfactor[MAX_GPUS]; __host__ -void cryptolight_core_cpu_hash(int thr_id, int blocks, int threads, uint32_t *d_long_state, uint32_t *d_ctx_state, uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2) +void cryptolight_core_cpu_hash(int thr_id, int blocks, int threads, uint32_t *d_long_state, uint64_t *d_ctx_state, + uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2) { dim3 grid(blocks); dim3 block(threads); @@ -266,7 +265,7 @@ void cryptolight_core_cpu_hash(int thr_id, int blocks, int threads, uint32_t *d_ int i, partcount = 1 << bfactor; int dev_id = device_map[thr_id]; - cryptolight_core_gpu_phase1 <<>>(blocks*threads, d_long_state, d_ctx_state, d_ctx_key1); + cryptolight_core_gpu_phase1 <<>>(blocks*threads, d_long_state, (uint32_t*)d_ctx_state, d_ctx_key1); exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__); if(partcount > 1) usleep(bsleep); @@ -277,6 +276,6 @@ void cryptolight_core_cpu_hash(int thr_id, int blocks, int threads, uint32_t *d_ if(partcount > 1) usleep(bsleep); } - cryptolight_core_gpu_phase3 <<>>(blocks*threads, d_long_state, d_ctx_state, d_ctx_key2); + cryptolight_core_gpu_phase3 <<>>(blocks*threads, d_long_state, (uint32_t*)d_ctx_state, d_ctx_key2); exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__); } diff --git a/crypto/cryptolight.cu b/crypto/cryptolight.cu index cb1008a..07b02db 100644 --- a/crypto/cryptolight.cu +++ b/crypto/cryptolight.cu @@ -7,7 +7,7 @@ static __thread uint32_t cn_blocks = 32; static __thread uint32_t cn_threads = 16; static uint32_t *d_long_state[MAX_GPUS]; -static uint32_t *d_ctx_state[MAX_GPUS]; +static uint64_t *d_ctx_state[MAX_GPUS]; static uint32_t *d_ctx_key1[MAX_GPUS]; static uint32_t *d_ctx_key2[MAX_GPUS]; static uint32_t *d_ctx_text[MAX_GPUS]; @@ -67,7 +67,7 @@ extern "C" int scanhash_cryptolight(int thr_id, struct work* work, uint32_t max_ cudaMalloc(&d_long_state[thr_id], alloc); exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__); - cudaMalloc(&d_ctx_state[thr_id], 50 * sizeof(uint32_t) * throughput); + cudaMalloc(&d_ctx_state[thr_id], 26 * sizeof(uint64_t) * throughput); exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__); cudaMalloc(&d_ctx_key1[thr_id], 40 * sizeof(uint32_t) * throughput); exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__); diff --git a/crypto/cryptolight.h b/crypto/cryptolight.h index 830c66b..9ede001 100644 --- a/crypto/cryptolight.h +++ b/crypto/cryptolight.h @@ -133,10 +133,10 @@ static inline void exit_if_cudaerror(int thr_id, const char *src, int line) exit(1); } } -void cryptolight_core_cpu_hash(int thr_id, int blocks, int threads, uint32_t *d_long_state, uint32_t *d_ctx_state, uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2); +void cryptolight_core_cpu_hash(int thr_id, int blocks, int threads, uint32_t *d_long_state, uint64_t *d_ctx_state, uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2); void cryptonight_extra_cpu_setData(int thr_id, const void *data, const void *pTargetIn); void cryptonight_extra_cpu_init(int thr_id, uint32_t threads); void cryptonight_extra_cpu_free(int thr_id); -void cryptonight_extra_cpu_prepare(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *d_ctx_state, uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2); -void cryptonight_extra_cpu_final(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *nonce, uint32_t *d_ctx_state); +void cryptonight_extra_cpu_prepare(int thr_id, uint32_t threads, uint32_t startNonce, uint64_t *d_ctx_state, uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2); +void cryptonight_extra_cpu_final(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *nonce, uint64_t *d_ctx_state); diff --git a/crypto/cryptonight-core.cu b/crypto/cryptonight-core.cu index 42c1f09..e91fd84 100644 --- a/crypto/cryptonight-core.cu +++ b/crypto/cryptonight-core.cu @@ -5,280 +5,189 @@ #include #include "cryptonight.h" -#define LONG_SHL_IDX 19 -#define LONG_LOOPS32 0x80000 +#define LONG_SHL_IDX 19U +#define LONG_LOOPS32 0x80000U #include "cn_aes.cuh" -#define MUL_SUM_XOR_DST(a,c,dst) { \ - uint64_t hi, lo = cuda_mul128(((uint64_t *)a)[0], ((uint64_t *)dst)[0], &hi) + ((uint64_t *)c)[1]; \ - hi += ((uint64_t *)c)[0]; \ - ((uint64_t *)c)[0] = ((uint64_t *)dst)[0] ^ hi; \ - ((uint64_t *)c)[1] = ((uint64_t *)dst)[1] ^ lo; \ - ((uint64_t *)dst)[0] = hi; \ - ((uint64_t *)dst)[1] = lo; } - -__device__ __forceinline__ uint64_t cuda_mul128(uint64_t multiplier, uint64_t multiplicand, uint64_t* product_hi) -{ - *product_hi = __umul64hi(multiplier, multiplicand); - return(multiplier * multiplicand); -} - __global__ -void cryptonight_core_gpu_phase1(int threads, uint32_t * __restrict__ long_state, uint32_t * __restrict__ ctx_state, uint32_t * __restrict__ ctx_key1) +//__launch_bounds__(128, 9) // 56 registers +void cryptonight_core_gpu_phase1(const uint32_t threads, uint32_t * long_state, uint32_t * const ctx_state, uint32_t * ctx_key1) { - __shared__ uint32_t __align__(16) sharedMemory[1024]; + __shared__ __align__(16) uint32_t sharedMemory[1024]; cn_aes_gpu_init(sharedMemory); - const int thread = (blockDim.x * blockIdx.x + threadIdx.x) >> 3; - const int sub = (threadIdx.x & 7) << 2; // 0 4 8 ... 28 + const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x) >> 3; + const uint32_t sub = (threadIdx.x & 7) << 2; // 0 4 8 ... 28 if(thread < threads) { - const int oft = thread * 50 + sub + 16; // not aligned 16! - const int long_oft = (thread << LONG_SHL_IDX) + sub; - uint32_t __align__(16) key[40]; - uint32_t __align__(16) text[4]; + const uint32_t long_oft = (thread << LONG_SHL_IDX) + sub; + ulonglong2 text = AS_UL2(&ctx_state[thread * 52U + sub + 16U]); - AS_UINT2(&text[0]) = AS_UINT2(&ctx_state[oft]); - AS_UINT2(&text[2]) = AS_UINT2(&ctx_state[oft + 2]); + const uint32_t* ctx_key = &ctx_key1[thread * 40U]; + uint32_t key[40]; + #pragma unroll 10 // copy 160 bytes + for (uint32_t i = 0; i < 40U; i += 4U) + AS_UINT4(&key[i]) = AS_UINT4(&ctx_key[i]); - // copy 160 bytes - #pragma unroll - for (int i = 0; i < 40; i += 4) - AS_UINT4(&key[i]) = AS_UINT4(ctx_key1 + thread * 40 + i); - - __syncthreads(); - for(int i = 0; i < LONG_LOOPS32; i += 32) { - cn_aes_pseudo_round_mut(sharedMemory, text, key); - AS_UINT4(&long_state[long_oft + i]) = AS_UINT4(text); + __threadfence_block(); + + for(uint32_t i = 0; i < LONG_LOOPS32; i += 32U) { + cn_aes_pseudo_round_mut(sharedMemory, (uint32_t*) &text, key); + AS_UL2(&long_state[long_oft + i]) = text; } } } -__global__ -void cryptonight_core_gpu_phase2(const int threads, const int bfactor, const int partidx, uint32_t * d_long_state, uint32_t * d_ctx_a, uint32_t * d_ctx_b) -{ - __shared__ uint32_t __align__(16) sharedMemory[1024]; - - cn_aes_gpu_init(sharedMemory); - - __syncthreads(); +static __forceinline__ __device__ ulonglong2 operator ^ (const ulonglong2 &a, const ulonglong2 &b) { + return make_ulonglong2(a.x ^ b.x, a.y ^ b.y); +} +static __forceinline__ __device__ uint4 operator ^ (const uint4 &a, const uint4 &b) { + return make_uint4(a.x ^ b.x, a.y ^ b.y, a.z ^ b.z, a.w ^ b.w); +} -#if 0 && __CUDA_ARCH__ >= 300 +__device__ __forceinline__ ulonglong2 cuda_mul128(const uint64_t multiplier, const uint64_t multiplicand) +{ + ulonglong2 product; + product.x = __umul64hi(multiplier, multiplicand); + product.y = multiplier * multiplicand; + return product; +} - const int thread = (blockDim.x * blockIdx.x + threadIdx.x) >> 2; - const int sub = threadIdx.x & 3; +static __forceinline__ __device__ void operator += (ulonglong2 &a, const ulonglong2 b) { + a.x += b.x; a.y += b.y; +} - if(thread < threads) - { - const int batchsize = ITER >> (2 + bfactor); - const int start = partidx * batchsize; - const int end = start + batchsize; - uint32_t * __restrict__ long_state = &d_long_state[thread << 19]; - uint32_t * __restrict__ ctx_a = d_ctx_a + thread * 4; - uint32_t * __restrict__ ctx_b = d_ctx_b + thread * 4; - uint32_t a, b, c, x[4]; - uint32_t t1[4], t2[4], res; - uint64_t reshi, reslo; - int j; - - a = ctx_a[sub]; - b = ctx_b[sub]; - - #pragma unroll 8 - for(int i = start; i < end; ++i) - { - //j = ((uint32_t *)a)[0] & 0x1FFFF0; - j = (__shfl((int)a, 0, 4) & E2I_MASK1) >> 2; - - //cn_aes_single_round(sharedMemory, &long_state[j], c, a); - x[0] = long_state[j + sub]; - x[1] = __shfl((int)x[0], sub + 1, 4); - x[2] = __shfl((int)x[0], sub + 2, 4); - x[3] = __shfl((int)x[0], sub + 3, 4); - c = a ^ - t_fn0(x[0] & 0xff) ^ - t_fn1((x[1] >> 8) & 0xff) ^ - t_fn2((x[2] >> 16) & 0xff) ^ - t_fn3((x[3] >> 24) & 0xff); - - //XOR_BLOCKS_DST(c, b, &long_state[j]); - long_state[j + sub] = c ^ b; - - //MUL_SUM_XOR_DST(c, a, &long_state[((uint32_t *)c)[0] & 0x1FFFF0]); - j = (__shfl((int)c, 0, 4) & E2I_MASK1) >> 2; - #pragma unroll - for(int k = 0; k < 2; k++) - t1[k] = __shfl((int)c, k, 4); - #pragma unroll - for(int k = 0; k < 4; k++) - t2[k] = __shfl((int)a, k, 4); - asm( - "mad.lo.u64 %0, %2, %3, %4;\n\t" - "mad.hi.u64 %1, %2, %3, %5;\n\t" - : "=l"(reslo), "=l"(reshi) - : "l"(((uint64_t *)t1)[0]), "l"(((uint64_t *)long_state)[j >> 1]), "l"(((uint64_t *)t2)[1]), "l"(((uint64_t *)t2)[0])); - res = (sub & 2 ? reslo : reshi) >> (sub & 1 ? 32 : 0); - a = long_state[j + sub] ^ res; - long_state[j + sub] = res; - - //j = ((uint32_t *)a)[0] & 0x1FFFF0; - j = (__shfl((int)a, 0, 4) & E2I_MASK1) >> 2; - - //cn_aes_single_round(sharedMemory, &long_state[j], b, a); - x[0] = long_state[j + sub]; - x[1] = __shfl((int)x[0], sub + 1, 4); - x[2] = __shfl((int)x[0], sub + 2, 4); - x[3] = __shfl((int)x[0], sub + 3, 4); - b = a ^ - t_fn0(x[0] & 0xff) ^ - t_fn1((x[1] >> 8) & 0xff) ^ - t_fn2((x[2] >> 16) & 0xff) ^ - t_fn3((x[3] >> 24) & 0xff); - - //XOR_BLOCKS_DST(b, c, &long_state[j]); - long_state[j + sub] = c ^ b; - - //MUL_SUM_XOR_DST(b, a, &long_state[((uint32_t *)b)[0] & 0x1FFFF0]); - j = (__shfl((int)b, 0, 4) & E2I_MASK1) >> 2; - - #pragma unroll - for(int k = 0; k < 2; k++) - t1[k] = __shfl((int)b, k, 4); - - #pragma unroll - for(int k = 0; k < 4; k++) - t2[k] = __shfl((int)a, k, 4); - asm( - "mad.lo.u64 %0, %2, %3, %4;\n\t" - "mad.hi.u64 %1, %2, %3, %5;\n\t" - : "=l"(reslo), "=l"(reshi) - : "l"(((uint64_t *)t1)[0]), "l"(((uint64_t *)long_state)[j >> 1]), "l"(((uint64_t *)t2)[1]), "l"(((uint64_t *)t2)[0])); - res = (sub & 2 ? reslo : reshi) >> (sub & 1 ? 32 : 0); - a = long_state[j + sub] ^ res; - long_state[j + sub] = res; - } +#undef MUL_SUM_XOR_DST +__device__ __forceinline__ void MUL_SUM_XOR_DST(const uint64_t m, uint4 &a, void* far_dst) +{ + ulonglong2 d = AS_UL2(far_dst); + ulonglong2 p = cuda_mul128(m, d.x); + p += AS_UL2(&a); + AS_UL2(&a) = p ^ d; + AS_UL2(far_dst) = p; +} - if(bfactor > 0) { - ctx_a[sub] = a; - ctx_b[sub] = b; - } - } +__global__ +#if __CUDA_ARCH__ >= 500 +//__launch_bounds__(128,12) /* force 40 regs to allow -l ...x32 */ +#endif +void cryptonight_core_gpu_phase2(const uint32_t threads, const uint32_t bfactor, const uint32_t partidx, + uint32_t * d_long_state, uint32_t * d_ctx_a, uint32_t * d_ctx_b) +{ + __shared__ __align__(16) uint32_t sharedMemory[1024]; -#else +// cn_aes_gpu_init(sharedMemory); +// __syncthreads(); - const int thread = blockDim.x * blockIdx.x + threadIdx.x; + const uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x; if (thread < threads) { - const int batchsize = ITER >> (2 + bfactor); - const int start = partidx * batchsize; - const int end = start + batchsize; - const off_t longptr = (off_t)thread << LONG_SHL_IDX; + const uint32_t batchsize = ITER >> (2U + bfactor); + const uint32_t start = partidx * batchsize; + const uint32_t end = start + batchsize; + const uint32_t longptr = thread << LONG_SHL_IDX; + uint32_t * long_state = &d_long_state[longptr]; - uint64_t * ctx_a = (uint64_t*)(&d_ctx_a[thread * 4]); - uint64_t * ctx_b = (uint64_t*)(&d_ctx_b[thread * 4]); - uint4 A = AS_UINT4(ctx_a); + void * ctx_a = (void*)(&d_ctx_a[thread << 2U]); + void * ctx_b = (void*)(&d_ctx_b[thread << 2U]); + uint4 A = AS_UINT4(ctx_a); // ld.global.u32.v4 uint4 B = AS_UINT4(ctx_b); - uint32_t* a = (uint32_t*)&A; - uint32_t* b = (uint32_t*)&B; for (int i = start; i < end; i++) // end = 262144 { - uint32_t c[4]; - uint32_t j = (a[0] >> 2) & E2I_MASK2; - cn_aes_single_round(sharedMemory, &long_state[j], c, a); - XOR_BLOCKS_DST(c, b, &long_state[j]); - MUL_SUM_XOR_DST(c, a, &long_state[(c[0] >> 2) & E2I_MASK2]); - - j = (a[0] >> 2) & E2I_MASK2; - cn_aes_single_round(sharedMemory, &long_state[j], b, a); - XOR_BLOCKS_DST(b, c, &long_state[j]); - MUL_SUM_XOR_DST(b, a, &long_state[(b[0] >> 2) & E2I_MASK2]); + uint4 C; + + uint32_t j = (A.x >> 2) & E2I_MASK2; + cn_aes_single_round_b((uint8_t*)sharedMemory, &long_state[j], A, &C); + AS_UINT4(&long_state[j]) = C ^ B; // // st.global.u32.v4 + MUL_SUM_XOR_DST((AS_UL2(&C)).x, A, &long_state[(C.x >> 2U) & E2I_MASK2]); + + j = (A.x >> 2) & E2I_MASK2; + cn_aes_single_round_b((uint8_t*)sharedMemory, &long_state[j], A, &B); + AS_UINT4(&long_state[j]) = C ^ B; + MUL_SUM_XOR_DST((AS_UL2(&B)).x, A, &long_state[(B.x >> 2U) & E2I_MASK2]); } - if (bfactor > 0) { + if (bfactor) { AS_UINT4(ctx_a) = A; AS_UINT4(ctx_b) = B; } } -#endif // __CUDA_ARCH__ >= 300 } __global__ -void cryptonight_core_gpu_phase3(int threads, const uint32_t * __restrict__ long_state, uint32_t * ctx_state, uint32_t * __restrict__ ctx_key2) +void cryptonight_core_gpu_phase3(const uint32_t threads, const uint32_t * __restrict__ long_state, uint32_t * ctx_state, uint32_t * __restrict__ ctx_key2) { - __shared__ uint32_t __align__(16) sharedMemory[1024]; + __shared__ __align__(16) uint32_t sharedMemory[1024]; - cn_aes_gpu_init(sharedMemory); + //cn_aes_gpu_init(sharedMemory); - const int thread = (blockDim.x * blockIdx.x + threadIdx.x) >> 3; - const int sub = (threadIdx.x & 7) << 2; + const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x) >> 3U; + const uint32_t sub = (threadIdx.x & 7U) << 2U; if(thread < threads) { - const int long_oft = (thread << LONG_SHL_IDX) + sub; - const int oft = thread * 50 + sub + 16; + const uint32_t long_oft = (thread << LONG_SHL_IDX) + sub; + const uint32_t st_oft = thread * 52U + sub + 16U; - uint32_t __align__(16) key[40]; - uint32_t __align__(8) text[4]; + ulonglong2 text = AS_UL2(&ctx_state[st_oft]); // copy 160 bytes - #pragma unroll - for (int i = 0; i < 40; i += 4) - AS_UINT4(&key[i]) = AS_UINT4(ctx_key2 + thread * 40 + i); - - AS_UINT2(&text[0]) = AS_UINT2(&ctx_state[oft+0]); - AS_UINT2(&text[2]) = AS_UINT2(&ctx_state[oft+2]); - - __syncthreads(); - for(int i = 0; i < LONG_LOOPS32; i += 32) + uint32_t key[40]; + const uint32_t* ctx_key = &ctx_key2[thread * 40U]; + #pragma unroll 10 + for (uint32_t i = 0; i < 40U; i += 4U) + AS_UL2(&key[i]) = AS_UL2(&ctx_key[i]); + + //__syncthreads(); + for(uint32_t i = 0; i < LONG_LOOPS32; i += 32U) { - uint32_t __align__(16) st[4]; - AS_UINT4(st) = AS_UINT4(&long_state[long_oft + i]); - - #pragma unroll - for(int j = 0; j < 4; j++) - text[j] ^= st[j]; - - cn_aes_pseudo_round_mut(sharedMemory, text, key); + ulonglong2 st = AS_UL2(&long_state[long_oft + i]); + text = text ^ st; + cn_aes_pseudo_round_mut(sharedMemory, (uint32_t*) (&text), key); } - AS_UINT2(&ctx_state[oft+0]) = AS_UINT2(&text[0]); - AS_UINT2(&ctx_state[oft+2]) = AS_UINT2(&text[2]); + AS_UL2(&ctx_state[st_oft]) = text; } } extern int device_bfactor[MAX_GPUS]; __host__ -void cryptonight_core_cpu_hash(int thr_id, int blocks, int threads, uint32_t *d_long_state, uint32_t *d_ctx_state, uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2) +void cryptonight_core_cpu_hash(int thr_id, int blocks, int threads, uint32_t *d_long_state, uint64_t *d_ctx_state, + uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2) { dim3 grid(blocks); dim3 block(threads); + dim3 block2(threads << 1); dim3 block4(threads << 2); dim3 block8(threads << 3); - const int bfactor = device_bfactor[thr_id]; - const int bsleep = bfactor ? 100 : 0; + const uint32_t bfactor = (uint32_t) device_bfactor[thr_id]; + const uint32_t partcount = 1 << bfactor; + const uint32_t throughput = (uint32_t) (blocks*threads); - int i, partcount = 1 << bfactor; - int dev_id = device_map[thr_id]; + const int bsleep = bfactor ? 100 : 0; + const int dev_id = device_map[thr_id]; + int i; - cryptonight_core_gpu_phase1 <<>>(blocks*threads, d_long_state, d_ctx_state, d_ctx_key1); + cryptonight_core_gpu_phase1 <<>> (throughput, d_long_state, (uint32_t*)d_ctx_state, d_ctx_key1); exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__); if(partcount > 1) usleep(bsleep); for(i = 0; i < partcount; i++) { - cryptonight_core_gpu_phase2 <<= 300 ? block4 : block)>>>(blocks*threads, bfactor, i, d_long_state, d_ctx_a, d_ctx_b); + dim3 b = device_sm[dev_id] >= 300 ? block4 : block; + cryptonight_core_gpu_phase2 <<>> (throughput, bfactor, i, d_long_state, d_ctx_a, d_ctx_b); exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__); if(partcount > 1) usleep(bsleep); } - cryptonight_core_gpu_phase3 <<>>(blocks*threads, d_long_state, d_ctx_state, d_ctx_key2); + cryptonight_core_gpu_phase3 <<>> (throughput, d_long_state, (uint32_t*)d_ctx_state, d_ctx_key2); exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__); } diff --git a/crypto/cryptonight-extra.cu b/crypto/cryptonight-extra.cu index 21aee47..6d3c131 100644 --- a/crypto/cryptonight-extra.cu +++ b/crypto/cryptonight-extra.cu @@ -75,7 +75,7 @@ void cryptonight_aes_set_key(uint32_t * __restrict__ key, const uint32_t * __res __global__ void cryptonight_extra_gpu_prepare(const uint32_t threads, uint32_t * __restrict__ d_input, uint32_t startNonce, - uint32_t * __restrict__ d_ctx_state, uint32_t * __restrict__ d_ctx_a, uint32_t * __restrict__ d_ctx_b, + uint64_t * d_ctx_state, uint32_t * __restrict__ d_ctx_a, uint32_t * __restrict__ d_ctx_b, uint32_t * __restrict__ d_ctx_key1, uint32_t * __restrict__ d_ctx_key2) { const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x); @@ -98,21 +98,21 @@ void cryptonight_extra_gpu_prepare(const uint32_t threads, uint32_t * __restrict XOR_BLOCKS_DST(ctx_state, ctx_state + 8, ctx_a); XOR_BLOCKS_DST(ctx_state + 4, ctx_state + 12, ctx_b); - memcpy(d_ctx_state + thread * 50, ctx_state, 50 * 4); - memcpy(d_ctx_a + thread * 4, ctx_a, 4 * 4); - memcpy(d_ctx_b + thread * 4, ctx_b, 4 * 4); - memcpy(d_ctx_key1 + thread * 40, ctx_key1, 40 * 4); - memcpy(d_ctx_key2 + thread * 40, ctx_key2, 40 * 4); + MEMCPY8(&d_ctx_state[thread * 26], ctx_state, 25); + MEMCPY4(d_ctx_a + thread * 4, ctx_a, 4); + MEMCPY4(d_ctx_b + thread * 4, ctx_b, 4); + MEMCPY4(d_ctx_key1 + thread * 40, ctx_key1, 40); + MEMCPY4(d_ctx_key2 + thread * 40, ctx_key2, 40); } } __global__ -void cryptonight_extra_gpu_keccak(uint32_t threads, uint32_t * __restrict__ d_ctx_state) +void cryptonight_extra_gpu_keccak(uint32_t threads, uint32_t * d_ctx_state) { const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x); if(thread < threads) { - uint64_t*ctx_state = (uint64_t*) (&d_ctx_state[thread * 50]); + uint64_t* ctx_state = (uint64_t*) (&d_ctx_state[thread * 52U]); uint64_t state[25]; #pragma unroll for(int i = 0; i < 25; i++) @@ -156,7 +156,7 @@ void cryptonight_extra_gpu_final(uint32_t threads, const uint32_t startNonce, ui const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x); if(thread < threads) { - uint64_t* const state = &d_ctx_state[thread * 25]; + uint64_t* const state = &d_ctx_state[thread * 26U]; uint32_t hash[8]; switch(((uint8_t *)state)[0] & 0x03) @@ -206,7 +206,7 @@ void cryptonight_extra_cpu_init(int thr_id, uint32_t threads) } __host__ -void cryptonight_extra_cpu_prepare(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *d_ctx_state, uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2) +void cryptonight_extra_cpu_prepare(int thr_id, uint32_t threads, uint32_t startNonce, uint64_t *d_ctx_state, uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2) { uint32_t threadsperblock = 128; @@ -218,7 +218,7 @@ void cryptonight_extra_cpu_prepare(int thr_id, uint32_t threads, uint32_t startN } __host__ -void cryptonight_extra_cpu_final(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *resnonce, uint32_t *d_ctx_state) +void cryptonight_extra_cpu_final(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *resnonce, uint64_t *d_ctx_state) { uint32_t threadsperblock = 128; @@ -227,9 +227,9 @@ void cryptonight_extra_cpu_final(int thr_id, uint32_t threads, uint32_t startNon cudaMemset(d_result[thr_id], 0xFF, 2*sizeof(uint32_t)); exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__); - cryptonight_extra_gpu_keccak <<>> (threads, d_ctx_state); + cryptonight_extra_gpu_keccak <<>> (threads, (uint32_t*)d_ctx_state); exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__); - cryptonight_extra_gpu_final <<>> (threads, startNonce, (uint64_t*)d_ctx_state, d_target[thr_id], d_result[thr_id]); + cryptonight_extra_gpu_final <<>> (threads, startNonce, d_ctx_state, d_target[thr_id], d_result[thr_id]); exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__); cudaMemcpy(resnonce, d_result[thr_id], 2 * sizeof(uint32_t), cudaMemcpyDeviceToHost); exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__); diff --git a/crypto/cryptonight.cu b/crypto/cryptonight.cu index 97249fe..af6f58b 100644 --- a/crypto/cryptonight.cu +++ b/crypto/cryptonight.cu @@ -7,7 +7,7 @@ static __thread uint32_t cn_blocks = 32; static __thread uint32_t cn_threads = 16; static uint32_t *d_long_state[MAX_GPUS]; -static uint32_t *d_ctx_state[MAX_GPUS]; +static uint64_t *d_ctx_state[MAX_GPUS]; static uint32_t *d_ctx_key1[MAX_GPUS]; static uint32_t *d_ctx_key2[MAX_GPUS]; static uint32_t *d_ctx_text[MAX_GPUS]; @@ -67,7 +67,7 @@ extern "C" int scanhash_cryptonight(int thr_id, struct work* work, uint32_t max_ cudaMalloc(&d_long_state[thr_id], alloc); exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__); - cudaMalloc(&d_ctx_state[thr_id], 25 * sizeof(uint64_t) * throughput); // 200 is aligned 8, not 16 + cudaMalloc(&d_ctx_state[thr_id], 208 * throughput); // 200 is aligned 8, not 16 exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__); cudaMalloc(&d_ctx_key1[thr_id], 40 * sizeof(uint32_t) * throughput); exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__); diff --git a/crypto/cryptonight.h b/crypto/cryptonight.h index 5a4c0cf..7d10f20 100644 --- a/crypto/cryptonight.h +++ b/crypto/cryptonight.h @@ -20,12 +20,12 @@ struct uint3 blockDim; #endif -#define MEMORY (1 << 21) // 2 MiB / 2097152 B -#define ITER (1 << 20) // 1048576 -#define E2I_MASK1 0x1FFFF0 -#define E2I_MASK2 (0x1FFFF0 >> 2) +#define MEMORY (1U << 21) // 2 MiB / 2097152 B +#define ITER (1U << 20) // 1048576 +#define E2I_MASK1 0x1FFFF0u +#define E2I_MASK2 (0x1FFFF0u >> 2u) -#define AES_BLOCK_SIZE 16 +#define AES_BLOCK_SIZE 16U #define AES_KEY_SIZE 32 #define INIT_SIZE_BLK 8 #define INIT_SIZE_BYTE (INIT_SIZE_BLK * AES_BLOCK_SIZE) // 128 B @@ -136,10 +136,10 @@ static inline void exit_if_cudaerror(int thr_id, const char *src, int line) exit(1); } } -void cryptonight_core_cpu_hash(int thr_id, int blocks, int threads, uint32_t *d_long_state, uint32_t *d_ctx_state, uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2); +void cryptonight_core_cpu_hash(int thr_id, int blocks, int threads, uint32_t *d_long_state, uint64_t *d_ctx_state, uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2); void cryptonight_extra_cpu_setData(int thr_id, const void *data, const void *pTargetIn); void cryptonight_extra_cpu_init(int thr_id, uint32_t threads); void cryptonight_extra_cpu_free(int thr_id); -void cryptonight_extra_cpu_prepare(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *d_ctx_state, uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2); -void cryptonight_extra_cpu_final(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *nonce, uint32_t *d_ctx_state); +void cryptonight_extra_cpu_prepare(int thr_id, uint32_t threads, uint32_t startNonce, uint64_t *d_ctx_state, uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2); +void cryptonight_extra_cpu_final(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *nonce, uint64_t *d_ctx_state);