Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fd8c32b4e | ||
|
|
94a04aea96 | ||
|
|
8ce8961e06 | ||
|
|
34c04cfb80 | ||
|
|
6c101af7a2 | ||
|
|
e606887e7a | ||
|
|
d4191d3188 | ||
|
|
a20dc6a658 | ||
|
|
69852a2874 | ||
|
|
ee9c821525 | ||
|
|
6fd935c369 | ||
|
|
2d6b3fddf6 | ||
|
|
0e6168ed52 | ||
|
|
a9d3c1ffdb | ||
|
|
a63f0024f3 | ||
|
|
adda14b22e | ||
|
|
e1a0274b01 | ||
|
|
1a30450ad2 | ||
|
|
e3922c7a33 | ||
|
|
312bd90541 | ||
|
|
d4a9428fef | ||
|
|
d840d683ec | ||
|
|
d6c29b1f7f |
No files matched your search
+2
-18
@@ -15,7 +15,7 @@ depcomp
|
||||
missing
|
||||
install-sh
|
||||
stamp-h1
|
||||
ccminer-config.h*
|
||||
cpuminer-config.h*
|
||||
compile
|
||||
config.log
|
||||
config.status
|
||||
@@ -25,7 +25,7 @@ config.sub
|
||||
|
||||
mingw32-config.cache
|
||||
|
||||
.dirstamp
|
||||
*/.dirstamp
|
||||
.DS_Store
|
||||
Desktop.ini
|
||||
Thumbs.db
|
||||
@@ -41,8 +41,6 @@ x64/Release/
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.pdb
|
||||
*.VC.opendb
|
||||
*.VC.db
|
||||
|
||||
.settings/
|
||||
.project
|
||||
@@ -54,17 +52,3 @@ x64/Release/
|
||||
|
||||
compat/curl-for-windows/
|
||||
|
||||
*.ptx
|
||||
*.i
|
||||
*.ii
|
||||
*.gpu
|
||||
*.cubin
|
||||
*.stub.c
|
||||
*.module_id
|
||||
*.hash
|
||||
*.fatbin.c
|
||||
*.fatbin
|
||||
*.cudafe1.cpp
|
||||
*.cudafe1.c
|
||||
*.cudafe2.c
|
||||
|
||||
+292
-401
@@ -1,20 +1,24 @@
|
||||
/**
|
||||
* Blake-256 Cuda Kernel (Tested on SM 5/5.2)
|
||||
* Blake-256 Cuda Kernel (Tested on SM 5.0)
|
||||
*
|
||||
* Tanguy Pruvot / SP - Jan 2016
|
||||
* Tanguy Pruvot - Nov. 2014
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <memory.h>
|
||||
#define PRECALC64 1
|
||||
|
||||
#include "miner.h"
|
||||
|
||||
extern "C" {
|
||||
#include "sph/sph_blake.h"
|
||||
#include <stdint.h>
|
||||
#include <memory.h>
|
||||
}
|
||||
|
||||
/* threads per block */
|
||||
#define TPB 512
|
||||
/* threads per block and throughput (intensity) */
|
||||
#define TPB 128
|
||||
|
||||
/* added in sph_blake.c */
|
||||
extern "C" int blake256_rounds = 14;
|
||||
|
||||
/* hash by cpu with blake 256 */
|
||||
extern "C" void blake256hash(void *output, const void *input, int8_t rounds = 14)
|
||||
@@ -22,7 +26,7 @@ extern "C" void blake256hash(void *output, const void *input, int8_t rounds = 14
|
||||
uchar hash[64];
|
||||
sph_blake256_context ctx;
|
||||
|
||||
sph_blake256_set_rounds(rounds);
|
||||
blake256_rounds = rounds;
|
||||
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, input, 80);
|
||||
@@ -33,11 +37,16 @@ extern "C" void blake256hash(void *output, const void *input, int8_t rounds = 14
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
#define __byte_perm(x, y, b) x
|
||||
#endif
|
||||
|
||||
#if PRECALC64
|
||||
__constant__ uint32_t _ALIGN(32) d_data[12];
|
||||
#else
|
||||
__constant__ static uint32_t _ALIGN(32) c_data[20];
|
||||
/* midstate hash cache, this algo is run on 2 parts */
|
||||
__device__ static uint32_t cache[8];
|
||||
__device__ static uint32_t prevsum = 0;
|
||||
/* crc32.c */
|
||||
extern "C" uint32_t crc32_u32t(const uint32_t *buf, size_t size);
|
||||
#endif
|
||||
|
||||
/* 8 adapters max */
|
||||
static uint32_t *d_resNonce[MAX_GPUS];
|
||||
@@ -45,21 +54,76 @@ static uint32_t *h_resNonce[MAX_GPUS];
|
||||
|
||||
/* max count of found nonces in one call */
|
||||
#define NBN 2
|
||||
static __thread uint32_t extra_results[NBN] = { UINT32_MAX };
|
||||
static uint32_t extra_results[NBN] = { UINT32_MAX };
|
||||
|
||||
#define GSPREC(a,b,c,d,x,y) { \
|
||||
v[a] += (m[x] ^ c_u256[y]) + v[b]; \
|
||||
v[d] = __byte_perm(v[d] ^ v[a],0, 0x1032); \
|
||||
/* prefer uint32_t to prevent size conversions = speed +5/10 % */
|
||||
__constant__
|
||||
static uint32_t _ALIGN(32) c_sigma[16][16] = {
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
{14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
{11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
|
||||
{12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
|
||||
{13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
|
||||
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
|
||||
{10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 },
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
{14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
{11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 }
|
||||
};
|
||||
|
||||
#if !PRECALC64
|
||||
__device__ __constant__
|
||||
static const uint32_t __align__(32) c_IV256[8] = {
|
||||
SPH_C32(0x6A09E667), SPH_C32(0xBB67AE85),
|
||||
SPH_C32(0x3C6EF372), SPH_C32(0xA54FF53A),
|
||||
SPH_C32(0x510E527F), SPH_C32(0x9B05688C),
|
||||
SPH_C32(0x1F83D9AB), SPH_C32(0x5BE0CD19)
|
||||
};
|
||||
#endif
|
||||
|
||||
__device__ __constant__
|
||||
static const uint32_t __align__(32) c_u256[16] = {
|
||||
SPH_C32(0x243F6A88), SPH_C32(0x85A308D3),
|
||||
SPH_C32(0x13198A2E), SPH_C32(0x03707344),
|
||||
SPH_C32(0xA4093822), SPH_C32(0x299F31D0),
|
||||
SPH_C32(0x082EFA98), SPH_C32(0xEC4E6C89),
|
||||
SPH_C32(0x452821E6), SPH_C32(0x38D01377),
|
||||
SPH_C32(0xBE5466CF), SPH_C32(0x34E90C6C),
|
||||
SPH_C32(0xC0AC29B7), SPH_C32(0xC97C50DD),
|
||||
SPH_C32(0x3F84D5B5), SPH_C32(0xB5470917)
|
||||
};
|
||||
|
||||
#define GS(a,b,c,d,x) { \
|
||||
const uint32_t idx1 = c_sigma[r][x]; \
|
||||
const uint32_t idx2 = c_sigma[r][x+1]; \
|
||||
v[a] += (m[idx1] ^ c_u256[idx2]) + v[b]; \
|
||||
v[d] = SPH_ROTL32(v[d] ^ v[a], 16); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = SPH_ROTR32(v[b] ^ v[c], 12); \
|
||||
v[a] += (m[y] ^ c_u256[x]) + v[b]; \
|
||||
v[d] = __byte_perm(v[d] ^ v[a],0, 0x0321); \
|
||||
\
|
||||
v[a] += (m[idx2] ^ c_u256[idx1]) + v[b]; \
|
||||
v[d] = SPH_ROTR32(v[d] ^ v[a], 8); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = SPH_ROTR32(v[b] ^ v[c], 7); \
|
||||
}
|
||||
}
|
||||
|
||||
__device__ __forceinline__
|
||||
void blake256_compress_14(uint32_t *h, const uint32_t *block, const uint32_t T0)
|
||||
/* Second part (64-80) msg never change, store it */
|
||||
__device__ __constant__
|
||||
static const uint32_t __align__(32) c_Padding[16] = {
|
||||
0, 0, 0, 0,
|
||||
0x80000000UL, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 1, 0, 640,
|
||||
};
|
||||
|
||||
__device__ static
|
||||
void blake256_compress(uint32_t *h, const uint32_t *block, const uint32_t T0, const int rounds)
|
||||
{
|
||||
uint32_t /*_ALIGN(8)*/ m[16];
|
||||
uint32_t v[16];
|
||||
@@ -69,22 +133,12 @@ void blake256_compress_14(uint32_t *h, const uint32_t *block, const uint32_t T0)
|
||||
m[2] = block[2];
|
||||
m[3] = block[3];
|
||||
|
||||
const uint32_t c_u256[16] = {
|
||||
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
|
||||
0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
|
||||
0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
|
||||
0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917
|
||||
};
|
||||
|
||||
const uint32_t c_Padding[12] = {
|
||||
0x80000000UL, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 1, 0, 640,
|
||||
};
|
||||
|
||||
#pragma unroll
|
||||
for (uint32_t i = 0; i < 12; i++) {
|
||||
m[i+4] = c_Padding[i];
|
||||
for (uint32_t i = 4; i < 16; i++) {
|
||||
#if PRECALC64
|
||||
m[i] = c_Padding[i];
|
||||
#else
|
||||
m[i] = (T0 == 0x200) ? block[i] : c_Padding[i];
|
||||
#endif
|
||||
}
|
||||
|
||||
//#pragma unroll 8
|
||||
@@ -101,143 +155,132 @@ void blake256_compress_14(uint32_t *h, const uint32_t *block, const uint32_t T0)
|
||||
v[14] = c_u256[6];
|
||||
v[15] = c_u256[7];
|
||||
|
||||
// { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
GSPREC(0, 4, 0x8, 0xC,0,1);
|
||||
GSPREC(1, 5, 0x9, 0xD,2,3);
|
||||
GSPREC(2, 6, 0xA, 0xE, 4,5);
|
||||
GSPREC(3, 7, 0xB, 0xF, 6,7);
|
||||
GSPREC(0, 5, 0xA, 0xF, 8,9);
|
||||
GSPREC(1, 6, 0xB, 0xC, 10,11);
|
||||
GSPREC(2, 7, 0x8, 0xD, 12,13);
|
||||
GSPREC(3, 4, 0x9, 0xE, 14,15);
|
||||
// { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 14, 10);
|
||||
GSPREC(1, 5, 0x9, 0xD, 4, 8);
|
||||
GSPREC(2, 6, 0xA, 0xE, 9, 15);
|
||||
GSPREC(3, 7, 0xB, 0xF, 13, 6);
|
||||
GSPREC(0, 5, 0xA, 0xF, 1, 12);
|
||||
GSPREC(1, 6, 0xB, 0xC, 0, 2);
|
||||
GSPREC(2, 7, 0x8, 0xD, 11, 7);
|
||||
GSPREC(3, 4, 0x9, 0xE, 5, 3);
|
||||
// { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 11, 8);
|
||||
GSPREC(1, 5, 0x9, 0xD, 12, 0);
|
||||
GSPREC(2, 6, 0xA, 0xE, 5, 2);
|
||||
GSPREC(3, 7, 0xB, 0xF, 15, 13);
|
||||
GSPREC(0, 5, 0xA, 0xF, 10, 14);
|
||||
GSPREC(1, 6, 0xB, 0xC, 3, 6);
|
||||
GSPREC(2, 7, 0x8, 0xD, 7, 1);
|
||||
GSPREC(3, 4, 0x9, 0xE, 9, 4);
|
||||
// { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 7, 9);
|
||||
GSPREC(1, 5, 0x9, 0xD, 3, 1);
|
||||
GSPREC(2, 6, 0xA, 0xE, 13, 12);
|
||||
GSPREC(3, 7, 0xB, 0xF, 11, 14);
|
||||
GSPREC(0, 5, 0xA, 0xF, 2, 6);
|
||||
GSPREC(1, 6, 0xB, 0xC, 5, 10);
|
||||
GSPREC(2, 7, 0x8, 0xD, 4, 0);
|
||||
GSPREC(3, 4, 0x9, 0xE, 15, 8);
|
||||
// { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 9, 0);
|
||||
GSPREC(1, 5, 0x9, 0xD, 5, 7);
|
||||
GSPREC(2, 6, 0xA, 0xE, 2, 4);
|
||||
GSPREC(3, 7, 0xB, 0xF, 10, 15);
|
||||
GSPREC(0, 5, 0xA, 0xF, 14, 1);
|
||||
GSPREC(1, 6, 0xB, 0xC, 11, 12);
|
||||
GSPREC(2, 7, 0x8, 0xD, 6, 8);
|
||||
GSPREC(3, 4, 0x9, 0xE, 3, 13);
|
||||
// { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 2, 12);
|
||||
GSPREC(1, 5, 0x9, 0xD, 6, 10);
|
||||
GSPREC(2, 6, 0xA, 0xE, 0, 11);
|
||||
GSPREC(3, 7, 0xB, 0xF, 8, 3);
|
||||
GSPREC(0, 5, 0xA, 0xF, 4, 13);
|
||||
GSPREC(1, 6, 0xB, 0xC, 7, 5);
|
||||
GSPREC(2, 7, 0x8, 0xD, 15, 14);
|
||||
GSPREC(3, 4, 0x9, 0xE, 1, 9);
|
||||
// { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 12, 5);
|
||||
GSPREC(1, 5, 0x9, 0xD, 1, 15);
|
||||
GSPREC(2, 6, 0xA, 0xE, 14, 13);
|
||||
GSPREC(3, 7, 0xB, 0xF, 4, 10);
|
||||
GSPREC(0, 5, 0xA, 0xF, 0, 7);
|
||||
GSPREC(1, 6, 0xB, 0xC, 6, 3);
|
||||
GSPREC(2, 7, 0x8, 0xD, 9, 2);
|
||||
GSPREC(3, 4, 0x9, 0xE, 8, 11);
|
||||
// { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 13, 11);
|
||||
GSPREC(1, 5, 0x9, 0xD, 7, 14);
|
||||
GSPREC(2, 6, 0xA, 0xE, 12, 1);
|
||||
GSPREC(3, 7, 0xB, 0xF, 3, 9);
|
||||
GSPREC(0, 5, 0xA, 0xF, 5, 0);
|
||||
GSPREC(1, 6, 0xB, 0xC, 15, 4);
|
||||
GSPREC(2, 7, 0x8, 0xD, 8, 6);
|
||||
GSPREC(3, 4, 0x9, 0xE, 2, 10);
|
||||
// { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 6, 15);
|
||||
GSPREC(1, 5, 0x9, 0xD, 14, 9);
|
||||
GSPREC(2, 6, 0xA, 0xE, 11, 3);
|
||||
GSPREC(3, 7, 0xB, 0xF, 0, 8);
|
||||
GSPREC(0, 5, 0xA, 0xF, 12, 2);
|
||||
GSPREC(1, 6, 0xB, 0xC, 13, 7);
|
||||
GSPREC(2, 7, 0x8, 0xD, 1, 4);
|
||||
GSPREC(3, 4, 0x9, 0xE, 10, 5);
|
||||
// { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 10, 2);
|
||||
GSPREC(1, 5, 0x9, 0xD, 8, 4);
|
||||
GSPREC(2, 6, 0xA, 0xE, 7, 6);
|
||||
GSPREC(3, 7, 0xB, 0xF, 1, 5);
|
||||
GSPREC(0, 5, 0xA, 0xF, 15, 11);
|
||||
GSPREC(1, 6, 0xB, 0xC, 9, 14);
|
||||
GSPREC(2, 7, 0x8, 0xD, 3, 12);
|
||||
GSPREC(3, 4, 0x9, 0xE, 13, 0);
|
||||
// { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 0, 1);
|
||||
GSPREC(1, 5, 0x9, 0xD, 2, 3);
|
||||
GSPREC(2, 6, 0xA, 0xE, 4, 5);
|
||||
GSPREC(3, 7, 0xB, 0xF, 6, 7);
|
||||
GSPREC(0, 5, 0xA, 0xF, 8, 9);
|
||||
GSPREC(1, 6, 0xB, 0xC, 10, 11);
|
||||
GSPREC(2, 7, 0x8, 0xD, 12, 13);
|
||||
GSPREC(3, 4, 0x9, 0xE, 14, 15);
|
||||
// { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 14, 10);
|
||||
GSPREC(1, 5, 0x9, 0xD, 4, 8);
|
||||
GSPREC(2, 6, 0xA, 0xE, 9, 15);
|
||||
GSPREC(3, 7, 0xB, 0xF, 13, 6);
|
||||
GSPREC(0, 5, 0xA, 0xF, 1, 12);
|
||||
GSPREC(1, 6, 0xB, 0xC, 0, 2);
|
||||
GSPREC(2, 7, 0x8, 0xD, 11, 7);
|
||||
GSPREC(3, 4, 0x9, 0xE, 5, 3);
|
||||
// { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 11, 8);
|
||||
GSPREC(1, 5, 0x9, 0xD, 12, 0);
|
||||
GSPREC(2, 6, 0xA, 0xE, 5, 2);
|
||||
GSPREC(3, 7, 0xB, 0xF, 15, 13);
|
||||
GSPREC(0, 5, 0xA, 0xF, 10, 14);
|
||||
GSPREC(1, 6, 0xB, 0xC, 3, 6);
|
||||
GSPREC(2, 7, 0x8, 0xD, 7, 1);
|
||||
GSPREC(3, 4, 0x9, 0xE, 9, 4);
|
||||
// { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 7, 9);
|
||||
GSPREC(1, 5, 0x9, 0xD, 3, 1);
|
||||
GSPREC(2, 6, 0xA, 0xE, 13, 12);
|
||||
GSPREC(3, 7, 0xB, 0xF, 11, 14);
|
||||
GSPREC(0, 5, 0xA, 0xF, 2, 6);
|
||||
GSPREC(1, 6, 0xB, 0xC, 5, 10);
|
||||
GSPREC(2, 7, 0x8, 0xD, 4, 0);
|
||||
GSPREC(3, 4, 0x9, 0xE, 15, 8);
|
||||
|
||||
for (int r = 0; r < rounds; r++) {
|
||||
/* column step */
|
||||
GS(0, 4, 0x8, 0xC, 0x0);
|
||||
GS(1, 5, 0x9, 0xD, 0x2);
|
||||
GS(2, 6, 0xA, 0xE, 0x4);
|
||||
GS(3, 7, 0xB, 0xF, 0x6);
|
||||
/* diagonal step */
|
||||
GS(0, 5, 0xA, 0xF, 0x8);
|
||||
GS(1, 6, 0xB, 0xC, 0xA);
|
||||
GS(2, 7, 0x8, 0xD, 0xC);
|
||||
GS(3, 4, 0x9, 0xE, 0xE);
|
||||
}
|
||||
#if PRECALC64
|
||||
// only compute h6 & 7
|
||||
h[6U] ^= v[6U] ^ v[14U];
|
||||
h[7U] ^= v[7U] ^ v[15U];
|
||||
#else
|
||||
//#pragma unroll 16
|
||||
for (uint32_t i = 0; i < 16; i++) {
|
||||
uint32_t j = i % 8U;
|
||||
h[j] ^= v[i];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !PRECALC64 /* original method */
|
||||
__global__
|
||||
void blake256_gpu_hash_80(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce,
|
||||
const uint64_t highTarget, const int crcsum, const int rounds)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
const uint32_t nonce = startNonce + thread;
|
||||
uint32_t h[8];
|
||||
|
||||
#pragma unroll
|
||||
for(int i=0; i<8; i++) {
|
||||
h[i] = c_IV256[i];
|
||||
}
|
||||
|
||||
if (crcsum != prevsum) {
|
||||
prevsum = crcsum;
|
||||
blake256_compress(h, c_data, 512, rounds);
|
||||
#pragma unroll
|
||||
for(int i=0; i<8; i++) {
|
||||
cache[i] = h[i];
|
||||
}
|
||||
} else {
|
||||
#pragma unroll
|
||||
for(int i=0; i<8; i++) {
|
||||
h[i] = cache[i];
|
||||
}
|
||||
}
|
||||
|
||||
// ------ Close: Bytes 64 to 80 ------
|
||||
|
||||
uint32_t ending[4];
|
||||
ending[0] = c_data[16];
|
||||
ending[1] = c_data[17];
|
||||
ending[2] = c_data[18];
|
||||
ending[3] = nonce; /* our tested value */
|
||||
|
||||
blake256_compress(h, ending, 640, rounds);
|
||||
|
||||
// not sure why, h[7] is ok
|
||||
h[6] = cuda_swab32(h[6]);
|
||||
|
||||
// compare count of leading zeros h[6] + h[7]
|
||||
uint64_t high64 = ((uint64_t*)h)[3];
|
||||
if (high64 <= highTarget)
|
||||
#if NBN == 2
|
||||
/* keep the smallest nonce, + extra one if found */
|
||||
if (resNonce[0] > nonce) {
|
||||
// printf("%llx %llx \n", high64, highTarget);
|
||||
resNonce[1] = resNonce[0];
|
||||
resNonce[0] = nonce;
|
||||
}
|
||||
else
|
||||
resNonce[1] = nonce;
|
||||
#else
|
||||
resNonce[0] = nonce;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
uint32_t blake256_cpu_hash_80(const int thr_id, const uint32_t threads, const uint32_t startNonce, const uint64_t highTarget,
|
||||
const uint32_t crcsum, const int8_t rounds)
|
||||
{
|
||||
const uint32_t threadsperblock = TPB;
|
||||
uint32_t result = UINT32_MAX;
|
||||
|
||||
dim3 grid((threads + threadsperblock-1)/threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
size_t shared_size = 0;
|
||||
|
||||
/* Check error on Ctrl+C or kill to prevent segfaults on exit */
|
||||
if (cudaMemset(d_resNonce[thr_id], 0xff, NBN*sizeof(uint32_t)) != cudaSuccess)
|
||||
return result;
|
||||
|
||||
blake256_gpu_hash_80<<<grid, block, shared_size>>>(threads, startNonce, d_resNonce[thr_id], highTarget, crcsum, (int) rounds);
|
||||
MyStreamSynchronize(NULL, 0, thr_id);
|
||||
if (cudaSuccess == cudaMemcpy(h_resNonce[thr_id], d_resNonce[thr_id], NBN*sizeof(uint32_t), cudaMemcpyDeviceToHost)) {
|
||||
result = h_resNonce[thr_id][0];
|
||||
for (int n=0; n < (NBN-1); n++)
|
||||
extra_results[n] = h_resNonce[thr_id][n+1];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__host__
|
||||
void blake256_cpu_setBlock_80(uint32_t *pdata, const uint32_t *ptarget)
|
||||
{
|
||||
uint32_t data[20];
|
||||
memcpy(data, pdata, 80);
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_data, data, sizeof(data), 0, cudaMemcpyHostToDevice));
|
||||
}
|
||||
#else
|
||||
|
||||
/* ############################################################################################################################### */
|
||||
/* Precalculated 1st 64-bytes block (midstate) method */
|
||||
|
||||
__global__ __launch_bounds__(1024,1)
|
||||
void blake256_gpu_hash_16(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce, const uint64_t highTarget)
|
||||
__global__
|
||||
void blake256_gpu_hash_16(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce,
|
||||
const uint64_t highTarget, const int rounds, const bool trace)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
@@ -258,161 +301,28 @@ void blake256_gpu_hash_16(const uint32_t threads, const uint32_t startNonce, uin
|
||||
ending[2] = d_data[10];
|
||||
ending[3] = nonce; /* our tested value */
|
||||
|
||||
blake256_compress_14(h, ending, 640);
|
||||
blake256_compress(h, ending, 640, rounds);
|
||||
|
||||
if (h[7] == 0 && cuda_swab32(h[6]) <= highTarget) {
|
||||
#if NBN == 2
|
||||
if (resNonce[0] != UINT32_MAX)
|
||||
resNonce[1] = nonce;
|
||||
else
|
||||
/* keep the smallest nonce, + extra one if found */
|
||||
if (resNonce[0] > nonce) {
|
||||
resNonce[1] = resNonce[0];
|
||||
resNonce[0] = nonce;
|
||||
}
|
||||
else
|
||||
resNonce[1] = nonce;
|
||||
#else
|
||||
resNonce[0] = nonce;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__global__
|
||||
#if __CUDA_ARCH__ >= 500
|
||||
__launch_bounds__(512, 3) /* 40 regs */
|
||||
#endif
|
||||
void blake256_gpu_hash_16_8(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce, const uint64_t highTarget)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
uint32_t h[8];
|
||||
const uint32_t nonce = startNonce + thread;
|
||||
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 8; i++) {
|
||||
h[i] = d_data[i];
|
||||
}
|
||||
|
||||
// ------ Close: Bytes 64 to 80 ------
|
||||
|
||||
uint32_t m[16] = {
|
||||
d_data[8], d_data[9], d_data[10], nonce,
|
||||
0x80000000UL, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 1, 0, 640,
|
||||
};
|
||||
|
||||
const uint32_t c_u256[16] = {
|
||||
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
|
||||
0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
|
||||
0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
|
||||
0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917
|
||||
};
|
||||
|
||||
uint32_t v[16];
|
||||
|
||||
#pragma unroll
|
||||
for (uint32_t i = 0; i < 8; i++)
|
||||
v[i] = h[i];
|
||||
|
||||
v[8] = c_u256[0];
|
||||
v[9] = c_u256[1];
|
||||
v[10] = c_u256[2];
|
||||
v[11] = c_u256[3];
|
||||
|
||||
v[12] = c_u256[4] ^ 640U;
|
||||
v[13] = c_u256[5] ^ 640U;
|
||||
v[14] = c_u256[6];
|
||||
v[15] = c_u256[7];
|
||||
|
||||
// { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 0, 1);
|
||||
GSPREC(1, 5, 0x9, 0xD, 2, 3);
|
||||
GSPREC(2, 6, 0xA, 0xE, 4, 5);
|
||||
GSPREC(3, 7, 0xB, 0xF, 6, 7);
|
||||
GSPREC(0, 5, 0xA, 0xF, 8, 9);
|
||||
GSPREC(1, 6, 0xB, 0xC, 10, 11);
|
||||
GSPREC(2, 7, 0x8, 0xD, 12, 13);
|
||||
GSPREC(3, 4, 0x9, 0xE, 14, 15);
|
||||
// { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 14, 10);
|
||||
GSPREC(1, 5, 0x9, 0xD, 4, 8);
|
||||
GSPREC(2, 6, 0xA, 0xE, 9, 15);
|
||||
GSPREC(3, 7, 0xB, 0xF, 13, 6);
|
||||
GSPREC(0, 5, 0xA, 0xF, 1, 12);
|
||||
GSPREC(1, 6, 0xB, 0xC, 0, 2);
|
||||
GSPREC(2, 7, 0x8, 0xD, 11, 7);
|
||||
GSPREC(3, 4, 0x9, 0xE, 5, 3);
|
||||
// { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 11, 8);
|
||||
GSPREC(1, 5, 0x9, 0xD, 12, 0);
|
||||
GSPREC(2, 6, 0xA, 0xE, 5, 2);
|
||||
GSPREC(3, 7, 0xB, 0xF, 15, 13);
|
||||
GSPREC(0, 5, 0xA, 0xF, 10, 14);
|
||||
GSPREC(1, 6, 0xB, 0xC, 3, 6);
|
||||
GSPREC(2, 7, 0x8, 0xD, 7, 1);
|
||||
GSPREC(3, 4, 0x9, 0xE, 9, 4);
|
||||
// { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 7, 9);
|
||||
GSPREC(1, 5, 0x9, 0xD, 3, 1);
|
||||
GSPREC(2, 6, 0xA, 0xE, 13, 12);
|
||||
GSPREC(3, 7, 0xB, 0xF, 11, 14);
|
||||
GSPREC(0, 5, 0xA, 0xF, 2, 6);
|
||||
GSPREC(1, 6, 0xB, 0xC, 5, 10);
|
||||
GSPREC(2, 7, 0x8, 0xD, 4, 0);
|
||||
GSPREC(3, 4, 0x9, 0xE, 15, 8);
|
||||
// { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 9, 0);
|
||||
GSPREC(1, 5, 0x9, 0xD, 5, 7);
|
||||
GSPREC(2, 6, 0xA, 0xE, 2, 4);
|
||||
GSPREC(3, 7, 0xB, 0xF, 10, 15);
|
||||
GSPREC(0, 5, 0xA, 0xF, 14, 1);
|
||||
GSPREC(1, 6, 0xB, 0xC, 11, 12);
|
||||
GSPREC(2, 7, 0x8, 0xD, 6, 8);
|
||||
GSPREC(3, 4, 0x9, 0xE, 3, 13);
|
||||
// { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 2, 12);
|
||||
GSPREC(1, 5, 0x9, 0xD, 6, 10);
|
||||
GSPREC(2, 6, 0xA, 0xE, 0, 11);
|
||||
GSPREC(3, 7, 0xB, 0xF, 8, 3);
|
||||
GSPREC(0, 5, 0xA, 0xF, 4, 13);
|
||||
GSPREC(1, 6, 0xB, 0xC, 7, 5);
|
||||
GSPREC(2, 7, 0x8, 0xD, 15, 14);
|
||||
GSPREC(3, 4, 0x9, 0xE, 1, 9);
|
||||
// { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 12, 5);
|
||||
GSPREC(1, 5, 0x9, 0xD, 1, 15);
|
||||
GSPREC(2, 6, 0xA, 0xE, 14, 13);
|
||||
GSPREC(3, 7, 0xB, 0xF, 4, 10);
|
||||
GSPREC(0, 5, 0xA, 0xF, 0, 7);
|
||||
GSPREC(1, 6, 0xB, 0xC, 6, 3);
|
||||
GSPREC(2, 7, 0x8, 0xD, 9, 2);
|
||||
GSPREC(3, 4, 0x9, 0xE, 8, 11);
|
||||
// { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 13, 11);
|
||||
GSPREC(1, 5, 0x9, 0xD, 7, 14);
|
||||
GSPREC(2, 6, 0xA, 0xE, 12, 1);
|
||||
GSPREC(3, 7, 0xB, 0xF, 3, 9);
|
||||
GSPREC(0, 5, 0xA, 0xF, 5, 0);
|
||||
GSPREC(1, 6, 0xB, 0xC, 15, 4);
|
||||
GSPREC(2, 7, 0x8, 0xD, 8, 6);
|
||||
//GSPREC(3, 4, 0x9, 0xE, 2, 10);
|
||||
// { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
|
||||
|
||||
// only compute h6 & 7
|
||||
//h[6] ^= v[6] ^ v[14];
|
||||
//h[7] ^= v[7] ^ v[15];
|
||||
|
||||
if ((h[7]^v[7]^v[15]) == 0) // h7
|
||||
{
|
||||
GSPREC(3, 4, 0x9, 0xE, 2, 10);
|
||||
if (cuda_swab32(h[6]^v[6]^v[14]) <= highTarget) {
|
||||
#if NBN == 2
|
||||
if (resNonce[0] != UINT32_MAX)
|
||||
resNonce[1] = nonce;
|
||||
else
|
||||
resNonce[0] = nonce;
|
||||
#else
|
||||
resNonce[0] = nonce;
|
||||
#endif
|
||||
#ifdef _DEBUG
|
||||
if (trace) {
|
||||
uint64_t high64 = ((uint64_t*)h)[3];
|
||||
printf("gpu: %16llx\n", high64);
|
||||
printf("gpu: %08x.%08x\n", h[7], h[6]);
|
||||
printf("tgt: %16llx\n", highTarget);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -421,20 +331,18 @@ __host__
|
||||
static uint32_t blake256_cpu_hash_16(const int thr_id, const uint32_t threads, const uint32_t startNonce, const uint64_t highTarget,
|
||||
const int8_t rounds)
|
||||
{
|
||||
const uint32_t threadsperblock = TPB;
|
||||
uint32_t result = UINT32_MAX;
|
||||
|
||||
dim3 grid((threads + TPB-1)/TPB);
|
||||
dim3 block(TPB);
|
||||
dim3 grid((threads + threadsperblock-1)/threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
/* Check error on Ctrl+C or kill to prevent segfaults on exit */
|
||||
if (cudaMemset(d_resNonce[thr_id], 0xff, NBN*sizeof(uint32_t)) != cudaSuccess)
|
||||
return result;
|
||||
|
||||
if (rounds == 8)
|
||||
blake256_gpu_hash_16_8 <<<grid, block>>> (threads, startNonce, d_resNonce[thr_id], highTarget);
|
||||
else
|
||||
blake256_gpu_hash_16 <<<grid, block>>> (threads, startNonce, d_resNonce[thr_id], highTarget);
|
||||
|
||||
blake256_gpu_hash_16 <<<grid, block>>> (threads, startNonce, d_resNonce[thr_id], highTarget, (int) rounds, opt_tracegpu);
|
||||
MyStreamSynchronize(NULL, 0, thr_id);
|
||||
if (cudaSuccess == cudaMemcpy(h_resNonce[thr_id], d_resNonce[thr_id], NBN*sizeof(uint32_t), cudaMemcpyDeviceToHost)) {
|
||||
result = h_resNonce[thr_id][0];
|
||||
for (int n=0; n < (NBN-1); n++)
|
||||
@@ -448,7 +356,8 @@ static void blake256mid(uint32_t *output, const uint32_t *input, int8_t rounds =
|
||||
{
|
||||
sph_blake256_context ctx;
|
||||
|
||||
sph_blake256_set_rounds(rounds);
|
||||
/* in sph_blake.c */
|
||||
blake256_rounds = rounds;
|
||||
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, input, 64);
|
||||
@@ -466,134 +375,116 @@ void blake256_cpu_setBlock_16(uint32_t *penddata, const uint32_t *midstate, cons
|
||||
data[10]= penddata[2];
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(d_data, data, 32 + 12, 0, cudaMemcpyHostToDevice));
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_blake256(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done, int8_t blakerounds=14)
|
||||
extern "C" int scanhash_blake256(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
|
||||
uint32_t max_nonce, unsigned long *hashes_done, int8_t blakerounds=14)
|
||||
{
|
||||
uint32_t _ALIGN(64) endiandata[20];
|
||||
uint32_t _ALIGN(64) midstate[8];
|
||||
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
uint64_t targetHigh = ((uint64_t*)ptarget)[3];
|
||||
|
||||
int dev_id = device_map[thr_id];
|
||||
int intensity = (device_sm[dev_id] > 500 && !is_windows()) ? 30 : 26;
|
||||
if (device_sm[dev_id] < 350) intensity = 22;
|
||||
|
||||
uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
uint32_t _ALIGN(64) endiandata[20];
|
||||
#if PRECALC64
|
||||
uint32_t _ALIGN(64) midstate[8];
|
||||
#else
|
||||
uint32_t crcsum;
|
||||
#endif
|
||||
int intensity = (device_sm[device_map[thr_id]] > 500) ? 22 : 20;
|
||||
uint32_t throughput = device_intensity(thr_id, __func__, 1U << intensity);
|
||||
throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
int rc = 0;
|
||||
|
||||
if (opt_benchmark) {
|
||||
targetHigh = 0x1ULL << 32;
|
||||
ptarget[6] = swab32(0xff);
|
||||
((uint32_t*)ptarget)[6] = swab32(0xff);
|
||||
}
|
||||
|
||||
if (!init[thr_id])
|
||||
{
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage (linux)
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
cudaDeviceSetCacheConfig(cudaFuncCachePreferL1);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
if (opt_tracegpu) {
|
||||
/* test call from util.c */
|
||||
throughput = 1;
|
||||
for (int k = 0; k < 20; k++)
|
||||
pdata[k] = swab32(pdata[k]);
|
||||
}
|
||||
|
||||
cuda_get_arch(thr_id);
|
||||
|
||||
CUDA_CALL_OR_RET_X(cudaMalloc(&d_resNonce[thr_id], NBN * sizeof(uint32_t)), -1);
|
||||
CUDA_CALL_OR_RET_X(cudaMallocHost(&h_resNonce[thr_id], NBN * sizeof(uint32_t)), -1);
|
||||
if (!init[thr_id]) {
|
||||
if (active_gpus > 1)
|
||||
cudaSetDevice(device_map[thr_id]);
|
||||
CUDA_CALL_OR_RET_X(cudaMallocHost(&h_resNonce[thr_id], NBN * sizeof(uint32_t)), 0);
|
||||
CUDA_CALL_OR_RET_X(cudaMalloc(&d_resNonce[thr_id], NBN * sizeof(uint32_t)), 0);
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
#if PRECALC64
|
||||
for (int k = 0; k < 16; k++)
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
|
||||
blake256mid(midstate, endiandata, blakerounds);
|
||||
blake256_cpu_setBlock_16(&pdata[16], midstate, ptarget);
|
||||
#else
|
||||
blake256_cpu_setBlock_80(pdata, ptarget);
|
||||
crcsum = crc32_u32t(pdata, 64);
|
||||
#endif /* PRECALC64 */
|
||||
|
||||
do {
|
||||
uint32_t foundNonce =
|
||||
#if PRECALC64
|
||||
// GPU HASH (second block only, first is midstate)
|
||||
work->nonces[0] = blake256_cpu_hash_16(thr_id, throughput, pdata[19], targetHigh, blakerounds);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce + throughput;
|
||||
|
||||
if (work->nonces[0] != UINT32_MAX)
|
||||
blake256_cpu_hash_16(thr_id, throughput, pdata[19], targetHigh, blakerounds);
|
||||
#else
|
||||
// GPU FULL HASH
|
||||
blake256_cpu_hash_80(thr_id, throughput, pdata[19], targetHigh, crcsum, blakerounds);
|
||||
#endif
|
||||
if (foundNonce != UINT32_MAX)
|
||||
{
|
||||
uint32_t _ALIGN(64) vhashcpu[8];
|
||||
const uint32_t Htarg = ptarget[6];
|
||||
uint32_t vhashcpu[8];
|
||||
uint32_t Htarg = (uint32_t)targetHigh;
|
||||
|
||||
for (int k=16; k < 19; k++)
|
||||
for (int k=0; k < 19; k++)
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
|
||||
be32enc(&endiandata[19], work->nonces[0]);
|
||||
be32enc(&endiandata[19], foundNonce);
|
||||
blake256hash(vhashcpu, endiandata, blakerounds);
|
||||
|
||||
//applog(LOG_BLUE, "%08x %16llx", vhashcpu[6], targetHigh);
|
||||
if (vhashcpu[6] <= Htarg && fulltest(vhashcpu, ptarget))
|
||||
{
|
||||
work->valid_nonces = 1;
|
||||
work_set_target_ratio(work, vhashcpu);
|
||||
rc = 1;
|
||||
pdata[19] = foundNonce;
|
||||
*hashes_done = pdata[19] - first_nonce + 1;
|
||||
#if NBN > 1
|
||||
if (extra_results[0] != UINT32_MAX) {
|
||||
work->nonces[1] = extra_results[0];
|
||||
be32enc(&endiandata[19], work->nonces[1]);
|
||||
be32enc(&endiandata[19], extra_results[0]);
|
||||
blake256hash(vhashcpu, endiandata, blakerounds);
|
||||
if (vhashcpu[6] <= Htarg && fulltest(vhashcpu, ptarget)) {
|
||||
if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio[0]) {
|
||||
work_set_target_ratio(work, vhashcpu);
|
||||
xchg(work->nonces[0], work->nonces[1]);
|
||||
} else {
|
||||
bn_set_target_ratio(work, vhashcpu, 1);
|
||||
}
|
||||
work->valid_nonces = 2;
|
||||
if (vhashcpu[6] <= Htarg /* && fulltest(vhashcpu, ptarget) */) {
|
||||
pdata[21] = extra_results[0];
|
||||
applog(LOG_BLUE, "1:%x 2:%x", foundNonce, extra_results[0]);
|
||||
*hashes_done = max(*hashes_done, extra_results[0] - first_nonce + 1);
|
||||
rc = 2;
|
||||
}
|
||||
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
|
||||
extra_results[0] = UINT32_MAX;
|
||||
} else {
|
||||
pdata[19] = work->nonces[0] + 1; // cursor
|
||||
}
|
||||
#endif
|
||||
return work->valid_nonces;
|
||||
//applog_hash((uint8_t*)ptarget);
|
||||
//applog_compare_hash((uint8_t*)vhashcpu,(uint8_t*)ptarget);
|
||||
return rc;
|
||||
}
|
||||
else if (vhashcpu[6] > Htarg) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]);
|
||||
pdata[19] = work->nonces[0] + 1;
|
||||
continue;
|
||||
else if (opt_debug) {
|
||||
applog_hash((uchar*)ptarget);
|
||||
applog_compare_hash((uchar*)vhashcpu, (uchar*)ptarget);
|
||||
applog(LOG_WARNING, "GPU #%d: result for nonce %08x does not validate on CPU!", device_map[thr_id], foundNonce);
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint64_t) pdata[19] + throughput > (uint64_t) max_nonce) {
|
||||
break;
|
||||
}
|
||||
|
||||
pdata[19] += throughput;
|
||||
|
||||
} while (!work_restart[thr_id].restart && max_nonce > (uint64_t)throughput + pdata[19]);
|
||||
} while (!work_restart[thr_id].restart);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
|
||||
MyStreamSynchronize(NULL, 0, device_map[thr_id]);
|
||||
return rc;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_blake256(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
|
||||
cudaFreeHost(h_resNonce[thr_id]);
|
||||
cudaFree(d_resNonce[thr_id]);
|
||||
|
||||
init[thr_id] = false;
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
}
|
||||
|
||||
@@ -1,565 +0,0 @@
|
||||
/**
|
||||
* Based on the SPH implementation of blake2s
|
||||
* Provos Alexis - 2016
|
||||
*/
|
||||
|
||||
#include "miner.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "sph/blake2s.h"
|
||||
#include "sph/sph_types.h"
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
#define __byte_perm(x, y, b) x
|
||||
#endif
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
#ifdef __CUDA_ARCH__
|
||||
|
||||
__device__ __forceinline__
|
||||
uint32_t ROR8(const uint32_t a) {
|
||||
return __byte_perm(a, 0, 0x0321);
|
||||
}
|
||||
|
||||
__device__ __forceinline__
|
||||
uint32_t ROL16(const uint32_t a) {
|
||||
return __byte_perm(a, 0, 0x1032);
|
||||
}
|
||||
|
||||
#else
|
||||
#define ROR8(u) (u >> 8)
|
||||
#define ROL16(u) (u << 16)
|
||||
#endif
|
||||
|
||||
__device__ __forceinline__
|
||||
uint32_t xor3x(uint32_t a, uint32_t b, uint32_t c)
|
||||
{
|
||||
uint32_t result;
|
||||
#if __CUDA_ARCH__ >= 500 && CUDA_VERSION >= 7050
|
||||
asm ("lop3.b32 %0, %1, %2, %3, 0x96;" : "=r"(result) : "r"(a), "r"(b),"r"(c)); //0x96 = 0xF0 ^ 0xCC ^ 0xAA
|
||||
#else
|
||||
result = a^b^c;
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
static const uint32_t blake2s_IV[8] = {
|
||||
0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL,
|
||||
0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL
|
||||
};
|
||||
|
||||
static const uint8_t blake2s_sigma[10][16] = {
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
|
||||
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
|
||||
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
|
||||
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
|
||||
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 },
|
||||
};
|
||||
|
||||
#define G(r,i,a,b,c,d) \
|
||||
do { \
|
||||
a = a + b + m[blake2s_sigma[r][2*i+0]]; \
|
||||
d = SPH_ROTR32(d ^ a, 16); \
|
||||
c = c + d; \
|
||||
b = SPH_ROTR32(b ^ c, 12); \
|
||||
a = a + b + m[blake2s_sigma[r][2*i+1]]; \
|
||||
d = SPH_ROTR32(d ^ a, 8); \
|
||||
c = c + d; \
|
||||
b = SPH_ROTR32(b ^ c, 7); \
|
||||
} while(0)
|
||||
#define ROUND(r) \
|
||||
do { \
|
||||
G(r,0,v[0],v[4],v[ 8],v[12]); \
|
||||
G(r,1,v[1],v[5],v[ 9],v[13]); \
|
||||
G(r,2,v[2],v[6],v[10],v[14]); \
|
||||
G(r,3,v[3],v[7],v[11],v[15]); \
|
||||
G(r,4,v[0],v[5],v[10],v[15]); \
|
||||
G(r,5,v[1],v[6],v[11],v[12]); \
|
||||
G(r,6,v[2],v[7],v[ 8],v[13]); \
|
||||
G(r,7,v[3],v[4],v[ 9],v[14]); \
|
||||
} while(0)
|
||||
|
||||
extern "C" void blake2s_hash(void *output, const void *input)
|
||||
{
|
||||
uint32_t m[16];
|
||||
uint32_t v[16];
|
||||
uint32_t h[8];
|
||||
|
||||
uint32_t *in = (uint32_t*)input;
|
||||
// COMPRESS
|
||||
for(int i = 0; i < 16; ++i )
|
||||
m[i] = in[i];
|
||||
|
||||
h[0] = 0x01010020 ^ blake2s_IV[0];
|
||||
h[1] = blake2s_IV[1];
|
||||
h[2] = blake2s_IV[2];
|
||||
h[3] = blake2s_IV[3];
|
||||
h[4] = blake2s_IV[4];
|
||||
h[5] = blake2s_IV[5];
|
||||
h[6] = blake2s_IV[6];
|
||||
h[7] = blake2s_IV[7];
|
||||
|
||||
for(int i = 0; i < 8; ++i )
|
||||
v[i] = h[i];
|
||||
|
||||
v[ 8] = blake2s_IV[0]; v[ 9] = blake2s_IV[1];
|
||||
v[10] = blake2s_IV[2]; v[11] = blake2s_IV[3];
|
||||
v[12] = 64 ^ blake2s_IV[4]; v[13] = blake2s_IV[5];
|
||||
v[14] = blake2s_IV[6]; v[15] = blake2s_IV[7];
|
||||
|
||||
ROUND( 0 ); ROUND( 1 );
|
||||
ROUND( 2 ); ROUND( 3 );
|
||||
ROUND( 4 ); ROUND( 5 );
|
||||
ROUND( 6 ); ROUND( 7 );
|
||||
ROUND( 8 ); ROUND( 9 );
|
||||
|
||||
for(size_t i = 0; i < 8; ++i)
|
||||
h[i] ^= v[i] ^ v[i + 8];
|
||||
|
||||
// COMPRESS
|
||||
m[0] = in[16]; m[1] = in[17];
|
||||
m[2] = in[18]; m[3] = in[19];
|
||||
for(size_t i = 4; i < 16; ++i)
|
||||
m[i] = 0;
|
||||
|
||||
for(size_t i = 0; i < 8; ++i)
|
||||
v[i] = h[i];
|
||||
|
||||
v[ 8] = blake2s_IV[0]; v[ 9] = blake2s_IV[1];
|
||||
v[10] = blake2s_IV[2]; v[11] = blake2s_IV[3];
|
||||
v[12] = 0x50 ^ blake2s_IV[4]; v[13] = blake2s_IV[5];
|
||||
v[14] = ~blake2s_IV[6]; v[15] = blake2s_IV[7];
|
||||
|
||||
ROUND( 0 ); ROUND( 1 );
|
||||
ROUND( 2 ); ROUND( 3 );
|
||||
ROUND( 4 ); ROUND( 5 );
|
||||
ROUND( 6 ); ROUND( 7 );
|
||||
ROUND( 8 ); ROUND( 9 );
|
||||
|
||||
for(size_t i = 0; i < 8; ++i)
|
||||
h[i] ^= v[i] ^ v[i + 8];
|
||||
|
||||
memcpy(output, h, 32);
|
||||
}
|
||||
|
||||
#define TPB 1024
|
||||
#define NPT 256
|
||||
#define maxResults 16
|
||||
#define NBN 1
|
||||
|
||||
__constant__ uint32_t _ALIGN(32) midstate[20];
|
||||
|
||||
static uint32_t *d_resNonce[MAX_GPUS];
|
||||
static uint32_t *h_resNonce[MAX_GPUS];
|
||||
|
||||
#define GS4(a,b,c,d,e,f,a1,b1,c1,d1,e1,f1,a2,b2,c2,d2,e2,f2,a3,b3,c3,d3,e3,f3){ \
|
||||
a += b + e; a1+= b1 + e1; a2+= b2 + e2; a3+= b3 + e3; \
|
||||
d = ROL16( d ^ a); d1 = ROL16(d1 ^ a1); d2 = ROL16(d2 ^ a2); d3 = ROL16(d3 ^ a3); \
|
||||
c +=d; c1+=d1; c2+=d2; c3+=d3;\
|
||||
b = ROTR32(b ^ c, 12); b1 = ROTR32(b1^c1, 12); b2 = ROTR32(b2^c2, 12); b3 = ROTR32(b3^c3, 12); \
|
||||
a += b + f; a1+= b1 + f1; a2+= b2 + f2; a3+= b3 + f3; \
|
||||
d = ROR8(d ^ a); d1 = ROR8(d1^a1); d2 = ROR8(d2^a2); d3 = ROR8(d3^a3); \
|
||||
c += d; c1 += d1; c2 += d2; c3 += d3;\
|
||||
b = ROTR32(b ^ c, 7); b1 = ROTR32(b1^c1, 7); b2 = ROTR32(b2^c2, 7); b3 = ROTR32(b3^c3, 7); \
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(TPB,1)
|
||||
void blake2s_gpu_hash_nonce(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce, const uint32_t ptarget7)
|
||||
{
|
||||
const uint32_t step = gridDim.x * blockDim.x;
|
||||
|
||||
uint32_t m[ 3];
|
||||
uint32_t v[16];
|
||||
|
||||
m[0] = midstate[16];
|
||||
m[1] = midstate[17];
|
||||
m[2] = midstate[18];
|
||||
|
||||
const uint32_t h7 = midstate[19];
|
||||
|
||||
for(uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x ; thread <threads; thread+=step){
|
||||
#pragma unroll
|
||||
for(int i=0;i<16;i++){
|
||||
v[ i] = midstate[ i];
|
||||
}
|
||||
|
||||
uint32_t nonce = cuda_swab32(startNonce + thread);
|
||||
// Round( 0 );
|
||||
v[ 1] += nonce;
|
||||
v[13] = ROR8(v[13] ^ v[ 1]);
|
||||
v[ 9] += v[13];
|
||||
v[ 5] = ROTR32(v[ 5] ^ v[ 9], 7);
|
||||
|
||||
v[ 1]+= v[ 6];
|
||||
v[ 0]+= v[ 5];
|
||||
|
||||
v[12] = ROL16(v[12] ^ v[ 1]);
|
||||
v[13] = ROL16(v[13] ^ v[ 2]);
|
||||
v[15] = ROL16(v[15] ^ v[ 0]);
|
||||
|
||||
v[11]+= v[12]; v[ 8]+= v[13]; v[ 9]+= v[14]; v[10]+= v[15];
|
||||
v[ 6] = ROTR32(v[ 6] ^ v[11], 12); v[ 7] = ROTR32(v[ 7] ^ v[ 8], 12); v[ 4] = ROTR32(v[ 4] ^ v[ 9], 12); v[ 5] = ROTR32(v[ 5] ^ v[10], 12);
|
||||
v[ 1]+= v[ 6]; v[ 2]+= v[ 7]; v[ 3]+= v[ 4]; v[ 0]+= v[ 5];
|
||||
v[12] = ROR8(v[12] ^ v[ 1]); v[13] = ROR8(v[13] ^ v[ 2]); v[14] = ROR8(v[14] ^ v[ 3]); v[15] = ROR8(v[15] ^ v[ 0]);
|
||||
v[11]+= v[12]; v[ 8]+= v[13]; v[ 9]+= v[14]; v[10]+= v[15];
|
||||
v[ 6] = ROTR32(v[ 6] ^ v[11], 7); v[ 7] = ROTR32(v[ 7] ^ v[ 8], 7); v[ 4] = ROTR32(v[ 4] ^ v[ 9], 7); v[ 5] = ROTR32(v[ 5] ^ v[10], 7);
|
||||
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],m[ 1],0, v[ 1],v[ 6],v[11],v[12],m[ 0],m[ 2], v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],0,nonce);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,m[ 0], v[ 2],v[ 6],v[10],v[14],0,m[ 2], v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,0, v[ 1],v[ 6],v[11],v[12],nonce,0, v[ 2],v[ 7],v[ 8],v[13],0,m[ 1], v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],nonce,m[ 1], v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],m[ 2],0, v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,m[ 0], v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,m[ 0], v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],m[ 2],0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,m[ 1], v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],nonce,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],m[ 2],0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],m[ 0],0, v[ 3],v[ 7],v[11],v[15],0,nonce);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,0, v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],m[ 1],0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],m[ 1],0, v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],m[ 0],0, v[ 1],v[ 6],v[11],v[12],0,nonce, v[ 2],v[ 7],v[ 8],v[13],0,m[ 2], v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,m[ 1], v[ 3],v[ 7],v[11],v[15],nonce,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,m[ 0], v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],m[ 2],0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,nonce, v[ 3],v[ 7],v[11],v[15],m[ 0],0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,m[ 2], v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],m[ 1],0, v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,m[ 2], v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],m[ 1],0);
|
||||
|
||||
// GS(9,4,v[ 0],v[ 5],v[10],v[15]);
|
||||
v[ 0] += v[ 5];
|
||||
v[ 2] += v[ 7] + nonce;
|
||||
v[15] = ROL16(v[15] ^ v[ 0]);
|
||||
v[13] = ROL16(v[13] ^ v[ 2]);
|
||||
v[10] += v[15];
|
||||
v[ 8] += v[13];
|
||||
v[ 5] = ROTR32(v[ 5] ^ v[10], 12);
|
||||
v[ 7] = ROTR32(v[ 7] ^ v[ 8], 12);
|
||||
v[ 0] += v[ 5];
|
||||
v[ 2] += v[ 7];
|
||||
v[15] = ROR8(v[15] ^ v[ 0]);
|
||||
v[13] = ROR8(v[13] ^ v[ 2]);
|
||||
|
||||
v[ 8] += v[13];
|
||||
v[ 7] = ROTR32(v[ 7] ^ v[ 8], 7);
|
||||
|
||||
if (xor3x(h7,v[7],v[15]) <= ptarget7){
|
||||
uint32_t pos = atomicInc(&resNonce[0],0xffffffff)+1;
|
||||
if(pos < maxResults)
|
||||
resNonce[pos] = nonce;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(TPB,1)
|
||||
void blake2s_gpu_hash_nonce(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce)
|
||||
{
|
||||
const uint32_t step = gridDim.x * blockDim.x;
|
||||
|
||||
uint32_t m[ 3];
|
||||
uint32_t v[16];
|
||||
|
||||
m[0] = midstate[16];
|
||||
m[1] = midstate[17];
|
||||
m[2] = midstate[18];
|
||||
|
||||
const uint32_t h7 = midstate[19];
|
||||
|
||||
for(uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x ; thread <threads; thread+=step)
|
||||
{
|
||||
#pragma unroll
|
||||
for(int i=0;i<16;i++){
|
||||
v[ i] = midstate[ i];
|
||||
}
|
||||
|
||||
uint32_t nonce = cuda_swab32(startNonce+thread);
|
||||
|
||||
// Round( 0 );
|
||||
v[ 1] += nonce;
|
||||
v[13] = ROR8(v[13] ^ v[ 1]);
|
||||
v[ 9] += v[13];
|
||||
v[ 5] = ROTR32(v[ 5] ^ v[ 9], 7);
|
||||
|
||||
v[ 1]+= v[ 6];
|
||||
v[ 0]+= v[ 5];
|
||||
|
||||
v[13] = ROL16(v[13] ^ v[ 2]); v[12] = ROL16(v[12] ^ v[ 1]); v[15] = ROL16(v[15] ^ v[ 0]);
|
||||
|
||||
v[ 8]+= v[13]; v[11]+= v[12]; v[ 9]+= v[14]; v[10]+= v[15];
|
||||
v[ 7] = ROTR32(v[ 7] ^ v[ 8], 12); v[ 6] = ROTR32(v[ 6] ^ v[11], 12); v[ 4] = ROTR32(v[ 4] ^ v[ 9], 12); v[ 5] = ROTR32(v[ 5] ^ v[10], 12);
|
||||
v[ 2]+= v[ 7]; v[ 1]+= v[ 6]; v[ 3]+= v[ 4]; v[ 0]+= v[ 5];
|
||||
v[13] = ROR8(v[13] ^ v[ 2]); v[12] = ROR8(v[12] ^ v[ 1]); v[14] = ROR8(v[14] ^ v[ 3]); v[15] = ROR8(v[15] ^ v[ 0]);
|
||||
v[ 8]+= v[13]; v[11]+= v[12]; v[ 9]+= v[14]; v[10]+= v[15];
|
||||
v[ 6] = ROTR32(v[ 6] ^ v[11], 7); v[ 7] = ROTR32(v[ 7] ^ v[8], 7); v[ 4] = ROTR32(v[ 4] ^ v[ 9], 7); v[ 5] = ROTR32(v[ 5] ^ v[10], 7);
|
||||
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],m[ 1],0, v[ 1],v[ 6],v[11],v[12],m[ 0],m[ 2], v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],0,nonce);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,m[ 0], v[ 2],v[ 6],v[10],v[14],0,m[ 2], v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,0, v[ 1],v[ 6],v[11],v[12],nonce,0, v[ 2],v[ 7],v[ 8],v[13],0,m[ 1], v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],nonce,m[ 1], v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],m[ 2],0, v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,m[ 0], v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,m[ 0], v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],m[ 2],0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,m[ 1], v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],nonce,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],m[ 2],0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],m[ 0],0, v[ 3],v[ 7],v[11],v[15],0,nonce);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,0, v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],m[ 1],0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],m[ 1],0, v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],m[ 0],0, v[ 1],v[ 6],v[11],v[12],0,nonce, v[ 2],v[ 7],v[ 8],v[13],0,m[ 2], v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,m[ 1], v[ 3],v[ 7],v[11],v[15],nonce,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,m[ 0], v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],m[ 2],0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,nonce, v[ 3],v[ 7],v[11],v[15],m[ 0],0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,m[ 2], v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],m[ 1],0, v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,m[ 2], v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],m[ 1],0);
|
||||
|
||||
v[ 0] += v[ 5];
|
||||
v[ 2] += v[ 7] + nonce;
|
||||
v[15] = ROL16(v[15] ^ v[ 0]);
|
||||
v[13] = ROL16(v[13] ^ v[ 2]);
|
||||
v[10] += v[15];
|
||||
v[ 8] += v[13];
|
||||
v[ 5] = ROTR32(v[ 5] ^ v[10], 12);
|
||||
v[ 7] = ROTR32(v[ 7] ^ v[ 8], 12);
|
||||
v[ 0] += v[ 5];
|
||||
v[ 2] += v[ 7];
|
||||
v[15] = ROTR32(v[15] ^ v[ 0],1);
|
||||
v[13] = ROR8(v[13] ^ v[ 2]);
|
||||
|
||||
v[ 8] += v[13];
|
||||
|
||||
if(xor3x(v[ 7],h7,v[ 8])==v[15]){
|
||||
uint32_t pos = atomicInc(&resNonce[0],0xffffffff)+1;
|
||||
if(pos < maxResults)
|
||||
resNonce[pos]=nonce;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void blake2s_setBlock(const uint32_t* input,const uint32_t ptarget7)
|
||||
{
|
||||
uint32_t _ALIGN(64) m[16];
|
||||
uint32_t _ALIGN(64) v[16];
|
||||
uint32_t _ALIGN(64) h[21];
|
||||
|
||||
// COMPRESS
|
||||
for(int i = 0; i < 16; ++i )
|
||||
m[i] = input[i];
|
||||
|
||||
h[0] = 0x01010020 ^ blake2s_IV[0];
|
||||
h[1] = blake2s_IV[1];
|
||||
h[2] = blake2s_IV[2]; h[3] = blake2s_IV[3];
|
||||
h[4] = blake2s_IV[4]; h[5] = blake2s_IV[5];
|
||||
h[6] = blake2s_IV[6]; h[7] = blake2s_IV[7];
|
||||
|
||||
for(int i = 0; i < 8; ++i )
|
||||
v[i] = h[i];
|
||||
|
||||
v[ 8] = blake2s_IV[0]; v[ 9] = blake2s_IV[1];
|
||||
v[10] = blake2s_IV[2]; v[11] = blake2s_IV[3];
|
||||
v[12] = 64 ^ blake2s_IV[4]; v[13] = blake2s_IV[5];
|
||||
v[14] = blake2s_IV[6]; v[15] = blake2s_IV[7];
|
||||
|
||||
ROUND( 0 ); ROUND( 1 );
|
||||
ROUND( 2 ); ROUND( 3 );
|
||||
ROUND( 4 ); ROUND( 5 );
|
||||
ROUND( 6 ); ROUND( 7 );
|
||||
ROUND( 8 ); ROUND( 9 );
|
||||
|
||||
for(int i = 0; i < 8; ++i )
|
||||
h[i] ^= v[i] ^ v[i + 8];
|
||||
|
||||
h[16] = input[16];
|
||||
h[17] = input[17];
|
||||
h[18] = input[18];
|
||||
|
||||
h[ 8] = 0x6A09E667; h[ 9] = 0xBB67AE85;
|
||||
h[10] = 0x3C6EF372; h[11] = 0xA54FF53A;
|
||||
h[12] = 0x510E522F; h[13] = 0x9B05688C;
|
||||
h[14] =~0x1F83D9AB; h[15] = 0x5BE0CD19;
|
||||
|
||||
h[ 0]+= h[ 4] + h[16];
|
||||
h[12] = SPH_ROTR32(h[12] ^ h[ 0],16);
|
||||
h[ 8]+= h[12];
|
||||
h[ 4] = SPH_ROTR32(h[ 4] ^ h[ 8],12);
|
||||
h[ 0]+= h[ 4] + h[17];
|
||||
h[12] = SPH_ROTR32(h[12] ^ h[ 0],8);
|
||||
h[ 8]+= h[12];
|
||||
h[ 4] = SPH_ROTR32(h[ 4] ^ h[ 8],7);
|
||||
|
||||
h[ 1]+= h[ 5] + h[18];
|
||||
h[13] = SPH_ROTR32(h[13] ^ h[ 1], 16);
|
||||
h[ 9]+= h[13];
|
||||
h[ 5] = ROTR32(h[ 5] ^ h[ 9], 12);
|
||||
|
||||
h[ 2]+= h[ 6];
|
||||
h[14] = SPH_ROTR32(h[14] ^ h[ 2],16);
|
||||
h[10]+= h[14];
|
||||
h[ 6] = SPH_ROTR32(h[ 6] ^ h[10], 12);
|
||||
h[ 2]+= h[ 6];
|
||||
h[14] = SPH_ROTR32(h[14] ^ h[ 2],8);
|
||||
h[10]+= h[14];
|
||||
h[ 6] = SPH_ROTR32(h[ 6] ^ h[10], 7);
|
||||
|
||||
h[19] = h[7]; //constant h[7] for nonce check
|
||||
|
||||
h[ 3]+= h[ 7];
|
||||
h[15] = SPH_ROTR32(h[15] ^ h[ 3],16);
|
||||
h[11]+= h[15];
|
||||
h[ 7] = SPH_ROTR32(h[ 7] ^ h[11], 12);
|
||||
h[ 3]+= h[ 7];
|
||||
h[15] = SPH_ROTR32(h[15] ^ h[ 3],8);
|
||||
h[11]+= h[15];
|
||||
h[ 7] = SPH_ROTR32(h[ 7] ^ h[11], 7);
|
||||
|
||||
h[ 1]+= h[ 5];
|
||||
h[ 3]+= h[ 4];
|
||||
h[14] = SPH_ROTR32(h[14] ^ h[ 3],16);
|
||||
|
||||
h[ 2]+= h[ 7];
|
||||
if(ptarget7==0){
|
||||
h[19] = SPH_ROTL32(h[19],7); //align the rotation with v[7] v[15];
|
||||
}
|
||||
cudaMemcpyToSymbol(midstate, h, 20*sizeof(uint32_t), 0, cudaMemcpyHostToDevice);
|
||||
}
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_blake2s(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done)
|
||||
{
|
||||
uint32_t _ALIGN(64) endiandata[20];
|
||||
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
uint32_t *resNonces;
|
||||
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
|
||||
const int dev_id = device_map[thr_id];
|
||||
int rc = 0;
|
||||
int intensity = is_windows() ? 25 : 28;
|
||||
uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
const dim3 grid((throughput + (NPT*TPB)-1)/(NPT*TPB));
|
||||
const dim3 block(TPB);
|
||||
|
||||
if (!init[thr_id])
|
||||
{
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage (linux)
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
|
||||
cuda_get_arch(thr_id);
|
||||
|
||||
CUDA_CALL_OR_RET_X(cudaMalloc(&d_resNonce[thr_id], maxResults * sizeof(uint32_t)), -1);
|
||||
CUDA_CALL_OR_RET_X(cudaMallocHost(&h_resNonce[thr_id], maxResults * sizeof(uint32_t)), -1);
|
||||
init[thr_id] = true;
|
||||
}
|
||||
resNonces = h_resNonce[thr_id];
|
||||
|
||||
for (int i=0; i < 19; i++) {
|
||||
be32enc(&endiandata[i], pdata[i]);
|
||||
}
|
||||
blake2s_setBlock(endiandata,ptarget[7]);
|
||||
|
||||
cudaMemset(d_resNonce[thr_id], 0x00, maxResults*sizeof(uint32_t));
|
||||
|
||||
do {
|
||||
if(ptarget[7]) {
|
||||
blake2s_gpu_hash_nonce<<<grid, block>>>(throughput,pdata[19],d_resNonce[thr_id],ptarget[7]);
|
||||
} else {
|
||||
blake2s_gpu_hash_nonce<<<grid, block>>>(throughput,pdata[19],d_resNonce[thr_id]);
|
||||
}
|
||||
cudaMemcpy(resNonces, d_resNonce[thr_id], sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
|
||||
if(resNonces[0])
|
||||
{
|
||||
cudaMemcpy(resNonces, d_resNonce[thr_id], maxResults*sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
cudaMemset(d_resNonce[thr_id], 0x00, sizeof(uint32_t));
|
||||
|
||||
if(resNonces[0] >= maxResults) {
|
||||
gpulog(LOG_WARNING, thr_id, "candidates flood: %u", resNonces[0]);
|
||||
resNonces[0] = maxResults-1;
|
||||
}
|
||||
|
||||
uint32_t vhashcpu[8];
|
||||
uint32_t nonce = sph_bswap32(resNonces[1]);
|
||||
be32enc(&endiandata[19], nonce);
|
||||
blake2s_hash(vhashcpu, endiandata);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce + throughput;
|
||||
|
||||
if(vhashcpu[6] <= ptarget[6] && fulltest(vhashcpu, ptarget))
|
||||
{
|
||||
work_set_target_ratio(work, vhashcpu);
|
||||
work->nonces[0] = nonce;
|
||||
rc = work->valid_nonces = 1;
|
||||
|
||||
// search for 2nd best nonce
|
||||
for(uint32_t j=2; j <= resNonces[0]; j++)
|
||||
{
|
||||
nonce = sph_bswap32(resNonces[j]);
|
||||
be32enc(&endiandata[19], nonce);
|
||||
blake2s_hash(vhashcpu, endiandata);
|
||||
if(vhashcpu[6] <= ptarget[6] && fulltest(vhashcpu, ptarget))
|
||||
{
|
||||
gpulog(LOG_DEBUG, thr_id, "Multiple nonces: 1/%08x - %u/%08x", work->nonces[0], j, nonce);
|
||||
|
||||
work->nonces[1] = nonce;
|
||||
if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio[0]) {
|
||||
work->shareratio[1] = work->shareratio[0];
|
||||
work->sharediff[1] = work->sharediff[0];
|
||||
xchg(work->nonces[1], work->nonces[0]);
|
||||
work_set_target_ratio(work, vhashcpu);
|
||||
} else if (work->valid_nonces == 1) {
|
||||
bn_set_target_ratio(work, vhashcpu, 1);
|
||||
}
|
||||
|
||||
work->valid_nonces++;
|
||||
rc = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pdata[19] = max(work->nonces[0], work->nonces[1]); // next scan start
|
||||
return rc;
|
||||
} else if (vhashcpu[7] > ptarget[7]) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", resNonces[0]);
|
||||
}
|
||||
}
|
||||
|
||||
pdata[19] += throughput;
|
||||
|
||||
} while (!work_restart[thr_id].restart && (uint64_t)max_nonce > (uint64_t)throughput + pdata[19]);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_blake2s(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
|
||||
cudaFreeHost(h_resNonce[thr_id]);
|
||||
cudaFree(d_resNonce[thr_id]);
|
||||
|
||||
init[thr_id] = false;
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
}
|
||||
|
||||
-138
@@ -1,138 +0,0 @@
|
||||
/**
|
||||
* bmw-256 MDT
|
||||
* tpruvot - 2015
|
||||
*/
|
||||
extern "C" {
|
||||
#include "sph/sph_bmw.h"
|
||||
}
|
||||
|
||||
#include <miner.h>
|
||||
#include <cuda_helper.h>
|
||||
|
||||
static uint32_t *d_hash[MAX_GPUS];
|
||||
|
||||
extern void bmw256_midstate_init(int thr_id, uint32_t threads);
|
||||
extern void bmw256_midstate_free(int thr_id);
|
||||
extern void bmw256_setBlock_80(int thr_id, void *pdata);
|
||||
extern void bmw256_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_outputHash, int swap);
|
||||
|
||||
extern uint32_t cuda_check_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_inputHash);
|
||||
|
||||
// CPU Hash
|
||||
extern "C" void bmw_hash(void *state, const void *input)
|
||||
{
|
||||
uint32_t _ALIGN(64) hash[16];
|
||||
sph_bmw256_context ctx;
|
||||
|
||||
sph_bmw256_init(&ctx);
|
||||
sph_bmw256(&ctx, input, 80);
|
||||
sph_bmw256_close(&ctx, (void*) hash);
|
||||
|
||||
memcpy(state, hash, 32);
|
||||
}
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_bmw(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done)
|
||||
{
|
||||
uint32_t _ALIGN(64) endiandata[20];
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
uint32_t throughput = cuda_default_throughput(thr_id, 1U << 21);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
if (opt_benchmark)
|
||||
ptarget[7] = 0x0005;
|
||||
|
||||
if (!init[thr_id]) {
|
||||
cudaSetDevice(device_map[thr_id]);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
}
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
|
||||
cuda_check_cpu_init(thr_id, throughput);
|
||||
bmw256_midstate_init(thr_id, throughput);
|
||||
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], (size_t)32 * throughput));
|
||||
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
for (int k=0; k < 20; k++) {
|
||||
be32enc(&endiandata[k], ((uint32_t*)pdata)[k]);
|
||||
}
|
||||
|
||||
cudaGetLastError();
|
||||
bmw256_setBlock_80(thr_id, (void*)endiandata);
|
||||
|
||||
cuda_check_cpu_setTarget(ptarget);
|
||||
|
||||
do {
|
||||
bmw256_cpu_hash_80(thr_id, (int) throughput, pdata[19], d_hash[thr_id], 1);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce + throughput;
|
||||
|
||||
work->nonces[0] = cuda_check_hash_32(thr_id, throughput, pdata[19], d_hash[thr_id]);
|
||||
if (work->nonces[0] != UINT32_MAX)
|
||||
{
|
||||
const uint32_t Htarg = ptarget[7];
|
||||
uint32_t _ALIGN(64) vhash[8];
|
||||
be32enc(&endiandata[19], work->nonces[0]);
|
||||
bmw_hash(vhash, endiandata);
|
||||
|
||||
if (vhash[7] <= Htarg && fulltest(vhash, ptarget)) {
|
||||
work->valid_nonces = 1;
|
||||
work_set_target_ratio(work, vhash);
|
||||
work->nonces[1] = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1);
|
||||
if (work->nonces[1] != 0) {
|
||||
be32enc(&endiandata[19], work->nonces[1]);
|
||||
bmw_hash(vhash, endiandata);
|
||||
bn_set_target_ratio(work, vhash, 1);
|
||||
work->valid_nonces++;
|
||||
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
|
||||
} else {
|
||||
pdata[19] = work->nonces[0] + 1; // cursor
|
||||
}
|
||||
return work->valid_nonces;
|
||||
}
|
||||
else if (vhash[7] > Htarg) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]);
|
||||
pdata[19] = work->nonces[0] + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint64_t) throughput + pdata[19] >= max_nonce) {
|
||||
pdata[19] = max_nonce;
|
||||
break;
|
||||
}
|
||||
|
||||
pdata[19] += throughput;
|
||||
|
||||
} while (!work_restart[thr_id].restart);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_bmw(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaThreadSynchronize();
|
||||
|
||||
cudaFree(d_hash[thr_id]);
|
||||
bmw256_midstate_free(thr_id);
|
||||
cuda_check_cpu_free(thr_id);
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
init[thr_id] = false;
|
||||
}
|
||||
+21
-351
@@ -2,8 +2,6 @@
|
||||
* Blake-256 Cuda Kernel (Tested on SM 5.0)
|
||||
*
|
||||
* Tanguy Pruvot - Nov. 2014
|
||||
*
|
||||
* + merged blake+keccak kernel for lyra2v2
|
||||
*/
|
||||
extern "C" {
|
||||
#include "sph/sph_blake.h"
|
||||
@@ -13,25 +11,11 @@ extern "C" {
|
||||
|
||||
#include <memory.h>
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
/* just for vstudio code colors */
|
||||
__device__ uint32_t __byte_perm(uint32_t a, uint32_t b, uint32_t c);
|
||||
#endif
|
||||
|
||||
#define UINT2(x,y) make_uint2(x,y)
|
||||
|
||||
__device__ __inline__ uint2 ROR8(const uint2 a) {
|
||||
uint2 result;
|
||||
result.x = __byte_perm(a.y, a.x, 0x0765);
|
||||
result.y = __byte_perm(a.x, a.y, 0x0765);
|
||||
return result;
|
||||
}
|
||||
|
||||
static __device__ uint64_t cuda_swab32ll(uint64_t x) {
|
||||
return MAKE_ULONGLONG(cuda_swab32(_LODWORD(x)), cuda_swab32(_HIDWORD(x)));
|
||||
}
|
||||
|
||||
__constant__ static uint32_t c_data[3 + 1];
|
||||
__constant__ static uint32_t c_data[20];
|
||||
|
||||
__constant__ static uint32_t sigma[16][16];
|
||||
static uint32_t c_sigma[16][16] = {
|
||||
@@ -74,25 +58,9 @@ static const uint32_t c_u256[16] = {
|
||||
0x3F84D5B5, 0xB5470917
|
||||
};
|
||||
|
||||
__constant__ uint2 keccak_round_constants35[24] = {
|
||||
{ 0x00000001ul, 0x00000000 }, { 0x00008082ul, 0x00000000 },
|
||||
{ 0x0000808aul, 0x80000000 }, { 0x80008000ul, 0x80000000 },
|
||||
{ 0x0000808bul, 0x00000000 }, { 0x80000001ul, 0x00000000 },
|
||||
{ 0x80008081ul, 0x80000000 }, { 0x00008009ul, 0x80000000 },
|
||||
{ 0x0000008aul, 0x00000000 }, { 0x00000088ul, 0x00000000 },
|
||||
{ 0x80008009ul, 0x00000000 }, { 0x8000000aul, 0x00000000 },
|
||||
{ 0x8000808bul, 0x00000000 }, { 0x0000008bul, 0x80000000 },
|
||||
{ 0x00008089ul, 0x80000000 }, { 0x00008003ul, 0x80000000 },
|
||||
{ 0x00008002ul, 0x80000000 }, { 0x00000080ul, 0x80000000 },
|
||||
{ 0x0000800aul, 0x00000000 }, { 0x8000000aul, 0x80000000 },
|
||||
{ 0x80008081ul, 0x80000000 }, { 0x00008080ul, 0x80000000 },
|
||||
{ 0x80000001ul, 0x00000000 }, { 0x80008008ul, 0x80000000 }
|
||||
};
|
||||
|
||||
|
||||
#define GS2(a,b,c,d,x) { \
|
||||
const uint32_t idx1 = sigma[r][x]; \
|
||||
const uint32_t idx2 = sigma[r][(x)+1]; \
|
||||
const uint32_t idx2 = sigma[r][x+1]; \
|
||||
v[a] += (m[idx1] ^ u256[idx2]) + v[b]; \
|
||||
v[d] = SPH_ROTL32(v[d] ^ v[a], 16); \
|
||||
v[c] += v[d]; \
|
||||
@@ -108,7 +76,7 @@ __constant__ uint2 keccak_round_constants35[24] = {
|
||||
//#define ROTR32(x, n) (((x) >> (n)) | ((x) << (32 - (n))))
|
||||
#define hostGS(a,b,c,d,x) { \
|
||||
const uint32_t idx1 = c_sigma[r][x]; \
|
||||
const uint32_t idx2 = c_sigma[r][(x)+1]; \
|
||||
const uint32_t idx2 = c_sigma[r][x+1]; \
|
||||
v[a] += (m[idx1] ^ c_u256[idx2]) + v[b]; \
|
||||
v[d] = ROTR32(v[d] ^ v[a], 16); \
|
||||
v[c] += v[d]; \
|
||||
@@ -120,17 +88,6 @@ __constant__ uint2 keccak_round_constants35[24] = {
|
||||
v[b] = ROTR32(v[b] ^ v[c], 7); \
|
||||
}
|
||||
|
||||
#define GSPREC(a,b,c,d,x,y) { \
|
||||
v[a] += (m[x] ^ u256[y]) + v[b]; \
|
||||
v[d] = __byte_perm(v[d] ^ v[a],0, 0x1032); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = SPH_ROTR32(v[b] ^ v[c], 12); \
|
||||
v[a] += (m[y] ^ u256[x]) + v[b]; \
|
||||
v[d] = __byte_perm(v[d] ^ v[a],0, 0x0321); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = SPH_ROTR32(v[b] ^ v[c], 7); \
|
||||
}
|
||||
|
||||
/* Second part (64-80) msg never change, store it */
|
||||
__device__ __constant__ static const uint32_t c_Padding[16] = {
|
||||
0, 0, 0, 0,
|
||||
@@ -201,8 +158,8 @@ static void blake256_compress2nd(uint32_t *h, const uint32_t *block, const uint3
|
||||
for (int i = 0; i < 8; i++)
|
||||
v[i] = h[i];
|
||||
|
||||
v[8] = u256[0];
|
||||
v[9] = u256[1];
|
||||
v[8] = u256[0];
|
||||
v[9] = u256[1];
|
||||
v[10] = u256[2];
|
||||
v[11] = u256[3];
|
||||
|
||||
@@ -232,293 +189,28 @@ static void blake256_compress2nd(uint32_t *h, const uint32_t *block, const uint3
|
||||
}
|
||||
}
|
||||
|
||||
static void __forceinline__ __device__ keccak_block(uint2 *s)
|
||||
{
|
||||
uint2 bc[5], tmpxor[5], u, v;
|
||||
// uint2 s[25];
|
||||
|
||||
#pragma unroll 1
|
||||
for (int i = 0; i < 24; i++)
|
||||
{
|
||||
#pragma unroll
|
||||
for (uint32_t x = 0; x < 5; x++)
|
||||
tmpxor[x] = s[x] ^ s[x + 5] ^ s[x + 10] ^ s[x + 15] ^ s[x + 20];
|
||||
|
||||
bc[0] = tmpxor[0] ^ ROL2(tmpxor[2], 1);
|
||||
bc[1] = tmpxor[1] ^ ROL2(tmpxor[3], 1);
|
||||
bc[2] = tmpxor[2] ^ ROL2(tmpxor[4], 1);
|
||||
bc[3] = tmpxor[3] ^ ROL2(tmpxor[0], 1);
|
||||
bc[4] = tmpxor[4] ^ ROL2(tmpxor[1], 1);
|
||||
|
||||
u = s[1] ^ bc[0];
|
||||
|
||||
s[0] ^= bc[4];
|
||||
s[1] = ROL2(s[6] ^ bc[0], 44);
|
||||
s[6] = ROL2(s[9] ^ bc[3], 20);
|
||||
s[9] = ROL2(s[22] ^ bc[1], 61);
|
||||
s[22] = ROL2(s[14] ^ bc[3], 39);
|
||||
s[14] = ROL2(s[20] ^ bc[4], 18);
|
||||
s[20] = ROL2(s[2] ^ bc[1], 62);
|
||||
s[2] = ROL2(s[12] ^ bc[1], 43);
|
||||
s[12] = ROL2(s[13] ^ bc[2], 25);
|
||||
s[13] = ROL8(s[19] ^ bc[3]);
|
||||
s[19] = ROR8(s[23] ^ bc[2]);
|
||||
s[23] = ROL2(s[15] ^ bc[4], 41);
|
||||
s[15] = ROL2(s[4] ^ bc[3], 27);
|
||||
s[4] = ROL2(s[24] ^ bc[3], 14);
|
||||
s[24] = ROL2(s[21] ^ bc[0], 2);
|
||||
s[21] = ROL2(s[8] ^ bc[2], 55);
|
||||
s[8] = ROL2(s[16] ^ bc[0], 45);
|
||||
s[16] = ROL2(s[5] ^ bc[4], 36);
|
||||
s[5] = ROL2(s[3] ^ bc[2], 28);
|
||||
s[3] = ROL2(s[18] ^ bc[2], 21);
|
||||
s[18] = ROL2(s[17] ^ bc[1], 15);
|
||||
s[17] = ROL2(s[11] ^ bc[0], 10);
|
||||
s[11] = ROL2(s[7] ^ bc[1], 6);
|
||||
s[7] = ROL2(s[10] ^ bc[4], 3);
|
||||
s[10] = ROL2(u, 1);
|
||||
|
||||
u = s[0]; v = s[1]; s[0] ^= (~v) & s[2]; s[1] ^= (~s[2]) & s[3]; s[2] ^= (~s[3]) & s[4]; s[3] ^= (~s[4]) & u; s[4] ^= (~u) & v;
|
||||
u = s[5]; v = s[6]; s[5] ^= (~v) & s[7]; s[6] ^= (~s[7]) & s[8]; s[7] ^= (~s[8]) & s[9]; s[8] ^= (~s[9]) & u; s[9] ^= (~u) & v;
|
||||
u = s[10]; v = s[11]; s[10] ^= (~v) & s[12]; s[11] ^= (~s[12]) & s[13]; s[12] ^= (~s[13]) & s[14]; s[13] ^= (~s[14]) & u; s[14] ^= (~u) & v;
|
||||
u = s[15]; v = s[16]; s[15] ^= (~v) & s[17]; s[16] ^= (~s[17]) & s[18]; s[17] ^= (~s[18]) & s[19]; s[18] ^= (~s[19]) & u; s[19] ^= (~u) & v;
|
||||
u = s[20]; v = s[21]; s[20] ^= (~v) & s[22]; s[21] ^= (~s[22]) & s[23]; s[22] ^= (~s[23]) & s[24]; s[23] ^= (~s[24]) & u; s[24] ^= (~u) & v;
|
||||
s[0] ^= keccak_round_constants35[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//__launch_bounds__(256)
|
||||
__global__
|
||||
void blakeKeccak256_gpu_hash_80(const uint32_t threads, const uint32_t startNonce, uint32_t * Hash)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
const uint32_t nonce = startNonce + thread;
|
||||
const uint32_t T0 = 640;
|
||||
|
||||
uint32_t h[8];
|
||||
#pragma unroll 8
|
||||
for (int i = 0; i<8; i++) { h[i] = cpu_h[i]; }
|
||||
|
||||
uint32_t v[16];
|
||||
|
||||
const uint32_t c_Padding[12] = {
|
||||
0x80000000, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 1, 0, 640
|
||||
};
|
||||
|
||||
const uint32_t u256[16] = {
|
||||
0x243F6A88, 0x85A308D3,
|
||||
0x13198A2E, 0x03707344,
|
||||
0xA4093822, 0x299F31D0,
|
||||
0x082EFA98, 0xEC4E6C89,
|
||||
0x452821E6, 0x38D01377,
|
||||
0xBE5466CF, 0x34E90C6C,
|
||||
0xC0AC29B7, 0xC97C50DD,
|
||||
0x3F84D5B5, 0xB5470917
|
||||
};
|
||||
|
||||
uint32_t m[16] = {
|
||||
c_data[0], c_data[1], c_data[2], nonce,
|
||||
c_Padding[0], c_Padding[1], c_Padding[2], c_Padding[3],
|
||||
c_Padding[4], c_Padding[5], c_Padding[6], c_Padding[7],
|
||||
c_Padding[8], c_Padding[9], c_Padding[10], c_Padding[11]
|
||||
};
|
||||
|
||||
#pragma unroll 8
|
||||
for (int i = 0; i < 8; i++)
|
||||
v[i] = h[i];
|
||||
|
||||
v[8] = u256[0];
|
||||
v[9] = u256[1];
|
||||
v[10] = u256[2];
|
||||
v[11] = u256[3];
|
||||
v[12] = u256[4] ^ T0;
|
||||
v[13] = u256[5] ^ T0;
|
||||
v[14] = u256[6];
|
||||
v[15] = u256[7];
|
||||
|
||||
// { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 0, 1);
|
||||
GSPREC(1, 5, 0x9, 0xD, 2, 3);
|
||||
GSPREC(2, 6, 0xA, 0xE, 4, 5);
|
||||
GSPREC(3, 7, 0xB, 0xF, 6, 7);
|
||||
GSPREC(0, 5, 0xA, 0xF, 8, 9);
|
||||
GSPREC(1, 6, 0xB, 0xC, 10, 11);
|
||||
GSPREC(2, 7, 0x8, 0xD, 12, 13);
|
||||
GSPREC(3, 4, 0x9, 0xE, 14, 15);
|
||||
// { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 14, 10);
|
||||
GSPREC(1, 5, 0x9, 0xD, 4, 8);
|
||||
GSPREC(2, 6, 0xA, 0xE, 9, 15);
|
||||
GSPREC(3, 7, 0xB, 0xF, 13, 6);
|
||||
GSPREC(0, 5, 0xA, 0xF, 1, 12);
|
||||
GSPREC(1, 6, 0xB, 0xC, 0, 2);
|
||||
GSPREC(2, 7, 0x8, 0xD, 11, 7);
|
||||
GSPREC(3, 4, 0x9, 0xE, 5, 3);
|
||||
// { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 11, 8);
|
||||
GSPREC(1, 5, 0x9, 0xD, 12, 0);
|
||||
GSPREC(2, 6, 0xA, 0xE, 5, 2);
|
||||
GSPREC(3, 7, 0xB, 0xF, 15, 13);
|
||||
GSPREC(0, 5, 0xA, 0xF, 10, 14);
|
||||
GSPREC(1, 6, 0xB, 0xC, 3, 6);
|
||||
GSPREC(2, 7, 0x8, 0xD, 7, 1);
|
||||
GSPREC(3, 4, 0x9, 0xE, 9, 4);
|
||||
// { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 7, 9);
|
||||
GSPREC(1, 5, 0x9, 0xD, 3, 1);
|
||||
GSPREC(2, 6, 0xA, 0xE, 13, 12);
|
||||
GSPREC(3, 7, 0xB, 0xF, 11, 14);
|
||||
GSPREC(0, 5, 0xA, 0xF, 2, 6);
|
||||
GSPREC(1, 6, 0xB, 0xC, 5, 10);
|
||||
GSPREC(2, 7, 0x8, 0xD, 4, 0);
|
||||
GSPREC(3, 4, 0x9, 0xE, 15, 8);
|
||||
// { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 9, 0);
|
||||
GSPREC(1, 5, 0x9, 0xD, 5, 7);
|
||||
GSPREC(2, 6, 0xA, 0xE, 2, 4);
|
||||
GSPREC(3, 7, 0xB, 0xF, 10, 15);
|
||||
GSPREC(0, 5, 0xA, 0xF, 14, 1);
|
||||
GSPREC(1, 6, 0xB, 0xC, 11, 12);
|
||||
GSPREC(2, 7, 0x8, 0xD, 6, 8);
|
||||
GSPREC(3, 4, 0x9, 0xE, 3, 13);
|
||||
// { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 2, 12);
|
||||
GSPREC(1, 5, 0x9, 0xD, 6, 10);
|
||||
GSPREC(2, 6, 0xA, 0xE, 0, 11);
|
||||
GSPREC(3, 7, 0xB, 0xF, 8, 3);
|
||||
GSPREC(0, 5, 0xA, 0xF, 4, 13);
|
||||
GSPREC(1, 6, 0xB, 0xC, 7, 5);
|
||||
GSPREC(2, 7, 0x8, 0xD, 15, 14);
|
||||
GSPREC(3, 4, 0x9, 0xE, 1, 9);
|
||||
// { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 12, 5);
|
||||
GSPREC(1, 5, 0x9, 0xD, 1, 15);
|
||||
GSPREC(2, 6, 0xA, 0xE, 14, 13);
|
||||
GSPREC(3, 7, 0xB, 0xF, 4, 10);
|
||||
GSPREC(0, 5, 0xA, 0xF, 0, 7);
|
||||
GSPREC(1, 6, 0xB, 0xC, 6, 3);
|
||||
GSPREC(2, 7, 0x8, 0xD, 9, 2);
|
||||
GSPREC(3, 4, 0x9, 0xE, 8, 11);
|
||||
// { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 13, 11);
|
||||
GSPREC(1, 5, 0x9, 0xD, 7, 14);
|
||||
GSPREC(2, 6, 0xA, 0xE, 12, 1);
|
||||
GSPREC(3, 7, 0xB, 0xF, 3, 9);
|
||||
GSPREC(0, 5, 0xA, 0xF, 5, 0);
|
||||
GSPREC(1, 6, 0xB, 0xC, 15, 4);
|
||||
GSPREC(2, 7, 0x8, 0xD, 8, 6);
|
||||
GSPREC(3, 4, 0x9, 0xE, 2, 10);
|
||||
// { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 6, 15);
|
||||
GSPREC(1, 5, 0x9, 0xD, 14, 9);
|
||||
GSPREC(2, 6, 0xA, 0xE, 11, 3);
|
||||
GSPREC(3, 7, 0xB, 0xF, 0, 8);
|
||||
GSPREC(0, 5, 0xA, 0xF, 12, 2);
|
||||
GSPREC(1, 6, 0xB, 0xC, 13, 7);
|
||||
GSPREC(2, 7, 0x8, 0xD, 1, 4);
|
||||
GSPREC(3, 4, 0x9, 0xE, 10, 5);
|
||||
// { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 10, 2);
|
||||
GSPREC(1, 5, 0x9, 0xD, 8, 4);
|
||||
GSPREC(2, 6, 0xA, 0xE, 7, 6);
|
||||
GSPREC(3, 7, 0xB, 0xF, 1, 5);
|
||||
GSPREC(0, 5, 0xA, 0xF, 15, 11);
|
||||
GSPREC(1, 6, 0xB, 0xC, 9, 14);
|
||||
GSPREC(2, 7, 0x8, 0xD, 3, 12);
|
||||
GSPREC(3, 4, 0x9, 0xE, 13, 0);
|
||||
// { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 0, 1);
|
||||
GSPREC(1, 5, 0x9, 0xD, 2, 3);
|
||||
GSPREC(2, 6, 0xA, 0xE, 4, 5);
|
||||
GSPREC(3, 7, 0xB, 0xF, 6, 7);
|
||||
GSPREC(0, 5, 0xA, 0xF, 8, 9);
|
||||
GSPREC(1, 6, 0xB, 0xC, 10, 11);
|
||||
GSPREC(2, 7, 0x8, 0xD, 12, 13);
|
||||
GSPREC(3, 4, 0x9, 0xE, 14, 15);
|
||||
// { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 14, 10);
|
||||
GSPREC(1, 5, 0x9, 0xD, 4, 8);
|
||||
GSPREC(2, 6, 0xA, 0xE, 9, 15);
|
||||
GSPREC(3, 7, 0xB, 0xF, 13, 6);
|
||||
GSPREC(0, 5, 0xA, 0xF, 1, 12);
|
||||
GSPREC(1, 6, 0xB, 0xC, 0, 2);
|
||||
GSPREC(2, 7, 0x8, 0xD, 11, 7);
|
||||
GSPREC(3, 4, 0x9, 0xE, 5, 3);
|
||||
// { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 11, 8);
|
||||
GSPREC(1, 5, 0x9, 0xD, 12, 0);
|
||||
GSPREC(2, 6, 0xA, 0xE, 5, 2);
|
||||
GSPREC(3, 7, 0xB, 0xF, 15, 13);
|
||||
GSPREC(0, 5, 0xA, 0xF, 10, 14);
|
||||
GSPREC(1, 6, 0xB, 0xC, 3, 6);
|
||||
GSPREC(2, 7, 0x8, 0xD, 7, 1);
|
||||
GSPREC(3, 4, 0x9, 0xE, 9, 4);
|
||||
// { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 7, 9);
|
||||
GSPREC(1, 5, 0x9, 0xD, 3, 1);
|
||||
GSPREC(2, 6, 0xA, 0xE, 13, 12);
|
||||
GSPREC(3, 7, 0xB, 0xF, 11, 14);
|
||||
GSPREC(0, 5, 0xA, 0xF, 2, 6);
|
||||
GSPREC(1, 6, 0xB, 0xC, 5, 10);
|
||||
GSPREC(2, 7, 0x8, 0xD, 4, 0);
|
||||
GSPREC(3, 4, 0x9, 0xE, 15, 8);
|
||||
|
||||
h[0] = cuda_swab32(h[0] ^ v[0] ^ v[8]);
|
||||
h[1] = cuda_swab32(h[1] ^ v[1] ^ v[9]);
|
||||
h[2] = cuda_swab32(h[2] ^ v[2] ^ v[10]);
|
||||
h[3] = cuda_swab32(h[3] ^ v[3] ^ v[11]);
|
||||
h[4] = cuda_swab32(h[4] ^ v[4] ^ v[12]);
|
||||
h[5] = cuda_swab32(h[5] ^ v[5] ^ v[13]);
|
||||
h[6] = cuda_swab32(h[6] ^ v[6] ^ v[14]);
|
||||
h[7] = cuda_swab32(h[7] ^ v[7] ^ v[15]);
|
||||
|
||||
uint2 keccak_gpu_state[25] = { 0 };
|
||||
keccak_gpu_state[0].x = h[0];
|
||||
keccak_gpu_state[0].y = h[1];
|
||||
keccak_gpu_state[1].x = h[2];
|
||||
keccak_gpu_state[1].y = h[3];
|
||||
keccak_gpu_state[2].x = h[4];
|
||||
keccak_gpu_state[2].y = h[5];
|
||||
keccak_gpu_state[3].x = h[6];
|
||||
keccak_gpu_state[3].y = h[7];
|
||||
keccak_gpu_state[4] = UINT2(1, 0);
|
||||
|
||||
keccak_gpu_state[16] = UINT2(0, 0x80000000);
|
||||
keccak_block(keccak_gpu_state);
|
||||
|
||||
uint64_t *outputHash = (uint64_t *)Hash;
|
||||
#pragma unroll 4
|
||||
for (int i = 0; i<4; i++)
|
||||
outputHash[i*threads + thread] = devectorize(keccak_gpu_state[i]);
|
||||
}
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(256, 3)
|
||||
__global__ __launch_bounds__(256,3)
|
||||
void blake256_gpu_hash_80(const uint32_t threads, const uint32_t startNonce, uint64_t * Hash)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
const uint32_t nonce = startNonce + thread;
|
||||
uint32_t h[8];
|
||||
uint32_t input[4];
|
||||
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 8; i++) h[i] = cpu_h[i];
|
||||
#pragma unroll 8
|
||||
for (int i = 0; i<8; i++) { h[i] = cpu_h[i];}
|
||||
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 3; ++i) input[i] = c_data[i];
|
||||
#pragma unroll 3
|
||||
for (int i = 0; i < 3; ++i) input[i] = c_data[16 + i];
|
||||
|
||||
input[3] = startNonce + thread;
|
||||
input[3] = nonce;
|
||||
blake256_compress2nd(h, input, 640);
|
||||
|
||||
#pragma unroll
|
||||
#pragma unroll
|
||||
for (int i = 0; i<4; i++) {
|
||||
Hash[i*threads + thread] = cuda_swab32ll(MAKE_ULONGLONG(h[2 * i], h[2 * i + 1]));
|
||||
Hash[i*threads + thread] = cuda_swab32ll(MAKE_ULONGLONG(h[2 * i], h[2*i+1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -531,21 +223,23 @@ void blake256_cpu_hash_80(const int thr_id, const uint32_t threads, const uint32
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
blake256_gpu_hash_80 << <grid, block >> > (threads, startNonce, Hash);
|
||||
blake256_gpu_hash_80 <<<grid, block>>> (threads, startNonce, Hash);
|
||||
MyStreamSynchronize(NULL, order, thr_id);
|
||||
}
|
||||
|
||||
__host__
|
||||
void blake256_cpu_setBlock_80(uint32_t *pdata)
|
||||
{
|
||||
uint32_t h[8], data[20];
|
||||
|
||||
uint32_t h[8];
|
||||
uint32_t data[20];
|
||||
memcpy(data, pdata, 80);
|
||||
memcpy(h, c_IV256, sizeof(c_IV256));
|
||||
for (int i = 0; i<8; i++) {
|
||||
h[i] = c_IV256[i];
|
||||
}
|
||||
blake256_compress1st(h, pdata, 512);
|
||||
|
||||
cudaMemcpyToSymbol(cpu_h, h, sizeof(h), 0, cudaMemcpyHostToDevice);
|
||||
cudaMemcpyToSymbol(c_data, &data[16], sizeof(c_data), 0, cudaMemcpyHostToDevice);
|
||||
cudaMemcpyToSymbol(c_data, data, sizeof(data), 0, cudaMemcpyHostToDevice);
|
||||
}
|
||||
|
||||
__host__
|
||||
@@ -554,27 +248,3 @@ void blake256_cpu_init(int thr_id, uint32_t threads)
|
||||
cudaMemcpyToSymbol(u256, c_u256, sizeof(c_u256), 0, cudaMemcpyHostToDevice);
|
||||
cudaMemcpyToSymbol(sigma, c_sigma, sizeof(c_sigma), 0, cudaMemcpyHostToDevice);
|
||||
}
|
||||
|
||||
/** for lyra2v2 **/
|
||||
|
||||
__host__
|
||||
void blakeKeccak256_cpu_hash_80(const int thr_id, const uint32_t threads, const uint32_t startNonce, uint64_t *Hash, int order)
|
||||
{
|
||||
const uint32_t threadsperblock = 256;
|
||||
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
blakeKeccak256_gpu_hash_80 <<<grid, block>>> (threads, startNonce, (uint32_t *)Hash);
|
||||
}
|
||||
|
||||
__host__
|
||||
void blakeKeccak256_cpu_hash_80(const int thr_id, const uint32_t threads, const uint32_t startNonce, uint64_t *Hash, int order, cudaStream_t stream)
|
||||
{
|
||||
const uint32_t threadsperblock = 256;
|
||||
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
blakeKeccak256_gpu_hash_80 <<<grid, block, 0, stream>>> (threads, startNonce, (uint32_t *)Hash);
|
||||
}
|
||||
@@ -1,380 +0,0 @@
|
||||
/**
|
||||
* BMW-256 CUDA Implementation - tpruvot 2015
|
||||
*
|
||||
* Not optimal but close to the sph version and easier to adapt.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
|
||||
#define SPH_64 1
|
||||
#define USE_MIDSTATE
|
||||
|
||||
extern "C" {
|
||||
#include "sph/sph_bmw.h"
|
||||
}
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
__constant__ uint64_t c_PaddedMessage80[16]; // padded message (80 bytes + padding)
|
||||
|
||||
#ifndef USE_MIDSTATE
|
||||
__constant__ static sph_u32 IV256[16] = {
|
||||
0x40414243, 0x44454647, 0x48494A4B, 0x4C4D4E4F,
|
||||
0x50515253, 0x54555657, 0x58595A5B, 0x5C5D5E5F,
|
||||
0x60616263, 0x64656667, 0x68696A6B, 0x6C6D6E6F,
|
||||
0x70717273, 0x74757677, 0x78797A7B, 0x7C7D7E7F
|
||||
};
|
||||
#endif
|
||||
|
||||
__constant__ static sph_u32 final_s[16] = {
|
||||
0xaaaaaaa0, 0xaaaaaaa1, 0xaaaaaaa2, 0xaaaaaaa3,
|
||||
0xaaaaaaa4, 0xaaaaaaa5, 0xaaaaaaa6, 0xaaaaaaa7,
|
||||
0xaaaaaaa8, 0xaaaaaaa9, 0xaaaaaaaa, 0xaaaaaaab,
|
||||
0xaaaaaaac, 0xaaaaaaad, 0xaaaaaaae, 0xaaaaaaaf
|
||||
};
|
||||
|
||||
static sph_bmw_small_context* d_midstate[MAX_GPUS];
|
||||
|
||||
#define I16_16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
|
||||
#define I16_17 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
|
||||
#define I16_18 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
|
||||
#define I16_19 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18
|
||||
#define I16_20 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
|
||||
#define I16_21 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
|
||||
#define I16_22 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
|
||||
#define I16_23 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
|
||||
#define I16_24 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
|
||||
#define I16_25 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
|
||||
#define I16_26 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25
|
||||
#define I16_27 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26
|
||||
#define I16_28 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27
|
||||
#define I16_29 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
|
||||
#define I16_30 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
|
||||
#define I16_31 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
|
||||
|
||||
//#define M16_16 0, 1, 3, 4, 7, 10, 11
|
||||
//#define M16_17 1, 2, 4, 5, 8, 11, 12
|
||||
#define M16_18 2, 3, 5, 6, 9, 12, 13
|
||||
#define M16_19 3, 4, 6, 7, 10, 13, 14
|
||||
#define M16_20 4, 5, 7, 8, 11, 14, 15
|
||||
#define M16_21 5, 6, 8, 9, 12, 15, 16
|
||||
#define M16_22 6, 7, 9, 10, 13, 0, 1
|
||||
#define M16_23 7, 8, 10, 11, 14, 1, 2
|
||||
#define M16_24 8, 9, 11, 12, 15, 2, 3
|
||||
#define M16_25 9, 10, 12, 13, 0, 3, 4
|
||||
#define M16_26 10, 11, 13, 14, 1, 4, 5
|
||||
#define M16_27 11, 12, 14, 15, 2, 5, 6
|
||||
#define M16_28 12, 13, 15, 16, 3, 6, 7
|
||||
#define M16_29 13, 14, 0, 1, 4, 7, 8
|
||||
#define M16_30 14, 15, 1, 2, 5, 8, 9
|
||||
#define M16_31 15, 16, 2, 3, 6, 9, 10
|
||||
|
||||
#define ss0(x) (((x) >> 1) ^ ((x) << 3) ^ ROTL32(x, 4) ^ ROTL32(x, 19))
|
||||
#define ss1(x) (((x) >> 1) ^ ((x) << 2) ^ ROTL32(x, 8) ^ ROTL32(x, 23))
|
||||
#define ss2(x) (((x) >> 2) ^ ((x) << 1) ^ ROTL32(x, 12) ^ ROTL32(x, 25))
|
||||
#define ss3(x) (((x) >> 2) ^ ((x) << 2) ^ ROTL32(x, 15) ^ ROTL32(x, 29))
|
||||
#define ss4(x) (((x) >> 1) ^ (x))
|
||||
#define ss5(x) (((x) >> 2) ^ (x))
|
||||
|
||||
#define rs1(x) ROTL32(x, 3)
|
||||
#define rs2(x) ROTL32(x, 7)
|
||||
#define rs3(x) ROTL32(x, 13)
|
||||
#define rs4(x) ROTL32(x, 16)
|
||||
#define rs5(x) ROTL32(x, 19)
|
||||
#define rs6(x) ROTL32(x, 23)
|
||||
#define rs7(x) ROTL32(x, 27)
|
||||
|
||||
#define MAKE_W(tt, i0, op01, i1, op12, i2, op23, i3, op34, i4) \
|
||||
tt((data[i0] ^ h[i0]) op01 (data[i1] ^ h[i1]) op12 (data[i2] ^ h[i2]) op23 (data[i3] ^ h[i3]) op34 (data[i4] ^ h[i4]))
|
||||
//#define Ws0 MAKE_W(SPH_T32, 5, -, 7, +, 10, +, 13, +, 14)
|
||||
//#define Ws1 MAKE_W(SPH_T32, 6, -, 8, +, 11, +, 14, -, 15)
|
||||
//#define Ws2 MAKE_W(SPH_T32, 0, +, 7, +, 9, -, 12, +, 15)
|
||||
//#define Ws3 MAKE_W(SPH_T32, 0, -, 1, +, 8, -, 10, +, 13)
|
||||
//#define Ws4 MAKE_W(SPH_T32, 1, +, 2, +, 9, -, 11, -, 14)
|
||||
//#define Ws5 MAKE_W(SPH_T32, 3, -, 2, +, 10, -, 12, +, 15)
|
||||
//#define Ws6 MAKE_W(SPH_T32, 4, -, 0, -, 3, -, 11, +, 13)
|
||||
//#define Ws7 MAKE_W(SPH_T32, 1, -, 4, -, 5, -, 12, -, 14)
|
||||
//#define Ws8 MAKE_W(SPH_T32, 2, -, 5, -, 6, +, 13, -, 15)
|
||||
//#define Ws9 MAKE_W(SPH_T32, 0, -, 3, +, 6, -, 7, +, 14)
|
||||
//#define Ws10 MAKE_W(SPH_T32, 8, -, 1, -, 4, -, 7, +, 15)
|
||||
//#define Ws11 MAKE_W(SPH_T32, 8, -, 0, -, 2, -, 5, +, 9)
|
||||
//#define Ws12 MAKE_W(SPH_T32, 1, +, 3, -, 6, -, 9, +, 10)
|
||||
//#define Ws13 MAKE_W(SPH_T32, 2, +, 4, +, 7, +, 10, +, 11)
|
||||
//#define Ws14 MAKE_W(SPH_T32, 3, -, 5, +, 8, -, 11, -, 12)
|
||||
//#define Ws15 MAKE_W(SPH_T32, 12, -, 4, -, 6, -, 9, +, 13)
|
||||
|
||||
__device__
|
||||
static void gpu_compress_small(const sph_u32 *data, const sph_u32 h[16], sph_u32 dh[16])
|
||||
{
|
||||
// FOLD MAKE_Qas;
|
||||
|
||||
sph_u32 dx[16];
|
||||
for (int i=0; i<16; i++)
|
||||
dx[i] = data[i] ^ h[i];
|
||||
|
||||
sph_u32 qt[32];
|
||||
qt[ 0] = dx[ 5] - dx[7] + dx[10] + dx[13] + dx[14]; // Ws0
|
||||
qt[ 1] = dx[ 6] - dx[8] + dx[11] + dx[14] - dx[15]; // Ws1
|
||||
qt[ 2] = dx[ 0] + dx[7] + dx[ 9] - dx[12] + dx[15]; // Ws2
|
||||
qt[ 3] = dx[ 0] - dx[1] + dx[ 8] - dx[10] + dx[13]; // Ws3
|
||||
qt[ 4] = dx[ 1] + dx[2] + dx[ 9] - dx[11] - dx[14]; // Ws4;
|
||||
qt[ 5] = dx[ 3] - dx[2] + dx[10] - dx[12] + dx[15]; // Ws5;
|
||||
qt[ 6] = dx[ 4] - dx[0] - dx[ 3] - dx[11] + dx[13]; // Ws6;
|
||||
qt[ 7] = dx[ 1] - dx[4] - dx[ 5] - dx[12] - dx[14]; // Ws7;
|
||||
qt[ 8] = dx[ 2] - dx[5] - dx[ 6] + dx[13] - dx[15]; // Ws8;
|
||||
qt[ 9] = dx[ 0] - dx[3] + dx[ 6] - dx[ 7] + dx[14]; // Ws9;
|
||||
qt[10] = dx[ 8] - dx[1] - dx[ 4] - dx[ 7] + dx[15]; // Ws10;
|
||||
qt[11] = dx[ 8] - dx[0] - dx[ 2] - dx[ 5] + dx[ 9]; // Ws11;
|
||||
qt[12] = dx[ 1] + dx[3] - dx[ 6] - dx[ 9] + dx[10]; // Ws12;
|
||||
qt[13] = dx[ 2] + dx[4] + dx[ 7] + dx[10] + dx[11]; // Ws13;
|
||||
qt[14] = dx[ 3] - dx[5] + dx[ 8] - dx[11] - dx[12]; // Ws14;
|
||||
qt[15] = dx[12] - dx[4] - dx[ 6] - dx[ 9] + dx[13]; // Ws15;
|
||||
|
||||
qt[ 0] = ss0(qt[ 0]) + h[ 1];
|
||||
qt[ 1] = ss1(qt[ 1]) + h[ 2];
|
||||
qt[ 2] = ss2(qt[ 2]) + h[ 3];
|
||||
qt[ 3] = ss3(qt[ 3]) + h[ 4];
|
||||
qt[ 4] = ss4(qt[ 4]) + h[ 5];
|
||||
|
||||
qt[ 5] = ss0(qt[ 5]) + h[ 6];
|
||||
qt[ 6] = ss1(qt[ 6]) + h[ 7];
|
||||
qt[ 7] = ss2(qt[ 7]) + h[ 8];
|
||||
qt[ 8] = ss3(qt[ 8]) + h[ 9];
|
||||
qt[ 9] = ss4(qt[ 9]) + h[10];
|
||||
|
||||
qt[10] = ss0(qt[10]) + h[11];
|
||||
qt[11] = ss1(qt[11]) + h[12];
|
||||
qt[12] = ss2(qt[12]) + h[13];
|
||||
qt[13] = ss3(qt[13]) + h[14];
|
||||
qt[14] = ss4(qt[14]) + h[15];
|
||||
|
||||
qt[15] = ss0(qt[15]) + h[ 0];
|
||||
|
||||
//MAKE_Qbs;
|
||||
#define Ks(j) ((sph_u32)(0x05555555UL * j))
|
||||
#define Qs(j) (qt[j])
|
||||
|
||||
#define expand1s_in(i16, \
|
||||
i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, \
|
||||
i0m, i1m, i3m, i4m, i7m, i10m, i11m) \
|
||||
(ss1(qt[i0]) + ss2(qt[i1]) + ss3(qt[i2]) + ss0(qt[i3]) + ss1(qt[i4]) + ss2(qt[i5]) + ss3(qt[i6]) + ss0(qt[i7]) \
|
||||
+ ss1(qt[i8]) + ss2(qt[i9]) + ss3(qt[i10]) + ss0(qt[i11]) + ss1(qt[i12]) + ss2(qt[i13]) + ss3(qt[i14]) + ss0(qt[i15]) \
|
||||
+ ((ROTL32(data[i0m], i1m) + ROTL32(data[i3m], i4m) - ROTL32(data[i10m], i11m) + Ks(i16)) ^ h[i7m]))
|
||||
|
||||
qt[16] = expand1s_in(16, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 3, 4, 7, 10, 11);
|
||||
qt[17] = expand1s_in(17, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 4, 5, 8, 11, 12);
|
||||
|
||||
#define expand2s_inner(qf, i16, \
|
||||
i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, \
|
||||
i0m, i1m, i3m, i4m, i7m, i10m, i11m) \
|
||||
(qf(i0) + rs1(qf(i1)) + qf(i2) + rs2(qf(i3)) \
|
||||
+ qf(i4) + rs3(qf(i5)) + qf(i6) + rs4(qf(i7)) + qf(i8) + rs5(qf(i9)) + qf(i10) + rs6(qf(i11)) \
|
||||
+ qf(i12) + rs7(qf(i13)) + ss4(qf(i14)) + ss5(qf(i15)) \
|
||||
+ ((ROTL32(data[i0m], i1m) + ROTL32(data[i3m], i4m) - ROTL32(data[i10m], i11m) + Ks(i16)) ^ h[i7m]))
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define LPAR (
|
||||
#define expand2s(i16) \
|
||||
expand2s_(Qs, i16, I16_ ## i16, M16_ ## i16)
|
||||
#define expand2s_(qf, i16, ix, iy) \
|
||||
expand2s_inner LPAR qf, i16, ix, iy)
|
||||
#else
|
||||
#define expand2s_(i16, ix, iy) \
|
||||
expand2s_inner(Qs, i16, ix, iy)
|
||||
#define expand2s(i16) \
|
||||
expand2s_(i16, I16_ ## i16, M16_ ## i16)
|
||||
#endif
|
||||
|
||||
qt[18] = expand2s(18);
|
||||
qt[19] = expand2s(19);
|
||||
qt[20] = expand2s(20);
|
||||
qt[21] = expand2s(21);
|
||||
qt[22] = expand2s(22);
|
||||
qt[23] = expand2s(23);
|
||||
qt[24] = expand2s(24);
|
||||
qt[25] = expand2s(25);
|
||||
qt[26] = expand2s(26);
|
||||
qt[27] = expand2s(27);
|
||||
qt[28] = expand2s(28);
|
||||
qt[29] = expand2s(29);
|
||||
qt[30] = expand2s(30);
|
||||
qt[31] = expand2s(31);
|
||||
|
||||
sph_u32 xl, xh;
|
||||
xl = Qs(16) ^ Qs(17) ^ Qs(18) ^ Qs(19) ^ Qs(20) ^ Qs(21) ^ Qs(22) ^ Qs(23);
|
||||
|
||||
xh = xl ^ Qs(24) ^ Qs(25) ^ Qs(26) ^ Qs(27) ^ Qs(28) ^ Qs(29) ^ Qs(30) ^ Qs(31);
|
||||
|
||||
dh[ 0] = ((xh << 5) ^ (Qs(16) >> 5) ^ data[ 0]) + (xl ^ Qs(24) ^ Qs(0));
|
||||
dh[ 1] = ((xh >> 7) ^ (Qs(17) << 8) ^ data[ 1]) + (xl ^ Qs(25) ^ Qs(1));
|
||||
dh[ 2] = ((xh >> 5) ^ (Qs(18) << 5) ^ data[ 2]) + (xl ^ Qs(26) ^ Qs(2));
|
||||
dh[ 3] = ((xh >> 1) ^ (Qs(19) << 5) ^ data[ 3]) + (xl ^ Qs(27) ^ Qs(3));
|
||||
dh[ 4] = ((xh >> 3) ^ (Qs(20) << 0) ^ data[ 4]) + (xl ^ Qs(28) ^ Qs(4));
|
||||
dh[ 5] = ((xh << 6) ^ (Qs(21) >> 6) ^ data[ 5]) + (xl ^ Qs(29) ^ Qs(5));
|
||||
dh[ 6] = ((xh >> 4) ^ (Qs(22) << 6) ^ data[ 6]) + (xl ^ Qs(30) ^ Qs(6));
|
||||
dh[ 7] = ((xh >> 11) ^ (Qs(23) << 2) ^ data[ 7]) + (xl ^ Qs(31) ^ Qs(7));
|
||||
|
||||
dh[ 8] = ROTL32(dh[4], 9) + (xh ^ Qs(24) ^ data[ 8]) + ((xl << 8) ^ Qs(23) ^ Qs( 8));
|
||||
dh[ 9] = ROTL32(dh[5], 10) + (xh ^ Qs(25) ^ data[ 9]) + ((xl >> 6) ^ Qs(16) ^ Qs( 9));
|
||||
dh[10] = ROTL32(dh[6], 11) + (xh ^ Qs(26) ^ data[10]) + ((xl << 6) ^ Qs(17) ^ Qs(10));
|
||||
dh[11] = ROTL32(dh[7], 12) + (xh ^ Qs(27) ^ data[11]) + ((xl << 4) ^ Qs(18) ^ Qs(11));
|
||||
dh[12] = ROTL32(dh[0], 13) + (xh ^ Qs(28) ^ data[12]) + ((xl >> 3) ^ Qs(19) ^ Qs(12));
|
||||
dh[13] = ROTL32(dh[1], 14) + (xh ^ Qs(29) ^ data[13]) + ((xl >> 4) ^ Qs(20) ^ Qs(13));
|
||||
dh[14] = ROTL32(dh[2], 15) + (xh ^ Qs(30) ^ data[14]) + ((xl >> 7) ^ Qs(21) ^ Qs(14));
|
||||
dh[15] = ROTL32(dh[3], 16) + (xh ^ Qs(31) ^ data[15]) + ((xl >> 2) ^ Qs(22) ^ Qs(15));
|
||||
}
|
||||
|
||||
#ifndef USE_MIDSTATE
|
||||
|
||||
__device__
|
||||
static void gpu_bmw256_init(sph_bmw_small_context *sc)
|
||||
{
|
||||
memcpy(sc->H, IV256, sizeof sc->H);
|
||||
sc->ptr = 0;
|
||||
sc->bit_count = 0;
|
||||
}
|
||||
|
||||
__device__
|
||||
static void gpu_bmw256(sph_bmw_small_context *sc, const void *data, size_t len)
|
||||
{
|
||||
sph_u32 htmp[16];
|
||||
sph_u32 *h1, *h2;
|
||||
unsigned char *buf = sc->buf;
|
||||
size_t ptr = sc->ptr;
|
||||
|
||||
sc->bit_count += (sph_u64)len << 3;
|
||||
|
||||
h1 = sc->H;
|
||||
h2 = htmp;
|
||||
while (len > 0) {
|
||||
size_t clen;
|
||||
|
||||
clen = (sizeof sc->buf) - ptr;
|
||||
if (clen > len)
|
||||
clen = len;
|
||||
memcpy(buf + ptr, data, clen);
|
||||
data = (const unsigned char *)data + clen;
|
||||
len -= clen;
|
||||
ptr += clen;
|
||||
if (ptr == sizeof sc->buf) {
|
||||
sph_u32 *ht;
|
||||
|
||||
gpu_compress_small((sph_u32 *) buf, h1, h2);
|
||||
ht = h1;
|
||||
h1 = h2;
|
||||
h2 = ht;
|
||||
ptr = 0;
|
||||
}
|
||||
}
|
||||
sc->ptr = ptr;
|
||||
if (h1 != sc->H)
|
||||
memcpy(sc->H, h1, sizeof sc->H);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define sph_enc64le(ptr, x) \
|
||||
*((uint64_t*)(ptr)) = x
|
||||
#define sph_enc64le_aligned sph_enc64le
|
||||
|
||||
__device__
|
||||
static void gpu_bmw256_close(sph_bmw_small_context *sc, uint2 *out)
|
||||
{
|
||||
unsigned char *buf = sc->buf;
|
||||
size_t ptr = sc->ptr;
|
||||
|
||||
buf[ptr ++] = 0x80;
|
||||
sph_u32 *h = sc->H;
|
||||
|
||||
sph_u32 h1[16];
|
||||
if (ptr > (sizeof sc->buf) - 8) {
|
||||
memset(buf + ptr, 0, (sizeof sc->buf) - ptr);
|
||||
gpu_compress_small((sph_u32 *) buf, h, h1);
|
||||
ptr = 0;
|
||||
h = h1;
|
||||
}
|
||||
memset(buf + ptr, 0, sizeof(sc->buf) - 8 - ptr);
|
||||
|
||||
sph_enc64le_aligned(buf + sizeof(sc->buf) - 8, SPH_T64(sc->bit_count));
|
||||
|
||||
sph_u32 h2[16];
|
||||
gpu_compress_small((sph_u32 *) buf, h, h2);
|
||||
gpu_compress_small(h2, final_s, h1);
|
||||
|
||||
uint64_t* h64 = (uint64_t*) (&h1[8]);
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 4; i++) {
|
||||
out[i] = vectorize(h64[i]);
|
||||
}
|
||||
}
|
||||
|
||||
__global__ /* __launch_bounds__(256, 3) */
|
||||
void bmw256_gpu_hash_80(uint32_t threads, uint32_t startNonce, uint64_t *g_hash, sph_bmw256_context *d_midstate, int swap)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
uint32_t nonce = startNonce + thread;
|
||||
nonce = swap ? cuda_swab32(nonce): nonce;
|
||||
|
||||
#ifndef USE_MIDSTATE
|
||||
uint2 hash[10];
|
||||
#pragma unroll
|
||||
for(int i=0;i<9;i++)
|
||||
hash[i] = vectorize(c_PaddedMessage80[i]);
|
||||
hash[9] = make_uint2(c_PaddedMessage80[9], nonce);
|
||||
|
||||
sph_bmw256_context ctx;
|
||||
gpu_bmw256_init(&ctx);
|
||||
gpu_bmw256(&ctx, (void*) hash, 80);
|
||||
#else
|
||||
sph_bmw256_context ctx;
|
||||
ctx.ptr = 16; ctx.bit_count = 640;
|
||||
uint2 *buf = (uint2 *) ctx.buf;
|
||||
buf[0] = vectorize(c_PaddedMessage80[8]);
|
||||
buf[1] = make_uint2(c_PaddedMessage80[9], nonce);
|
||||
#pragma unroll
|
||||
for(int i=0;i<16;i++)
|
||||
ctx.H[i] = d_midstate->H[i];
|
||||
#endif
|
||||
gpu_bmw256_close(&ctx, (uint2*) &g_hash[thread << 2]);
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void bmw256_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *d_outputHash, int swap)
|
||||
{
|
||||
const uint32_t threadsperblock = 256;
|
||||
|
||||
dim3 grid((threads + threadsperblock-1)/threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
bmw256_gpu_hash_80<<<grid, block>>>(threads, startNonce, (uint64_t*)d_outputHash, d_midstate[thr_id], swap);
|
||||
}
|
||||
|
||||
__host__
|
||||
void bmw256_setBlock_80(int thr_id, void *pdata)
|
||||
{
|
||||
uint64_t PaddedMessage[16];
|
||||
memcpy(PaddedMessage, pdata, 80);
|
||||
memset(&PaddedMessage[10], 0, 48);
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_PaddedMessage80, PaddedMessage, sizeof(PaddedMessage), 0, cudaMemcpyHostToDevice));
|
||||
|
||||
sph_bmw256_context ctx;
|
||||
sph_bmw256_init(&ctx);
|
||||
sph_bmw256(&ctx, (void*) PaddedMessage, 80);
|
||||
CUDA_SAFE_CALL(cudaMemcpy(d_midstate[thr_id], &ctx, sizeof(sph_bmw256_context), cudaMemcpyHostToDevice));
|
||||
}
|
||||
|
||||
__host__
|
||||
void bmw256_midstate_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
cudaMalloc(&d_midstate[thr_id], sizeof(sph_bmw256_context));
|
||||
}
|
||||
|
||||
__host__
|
||||
void bmw256_midstate_free(int thr_id)
|
||||
{
|
||||
cudaFree(d_midstate[thr_id]);
|
||||
}
|
||||
@@ -1,283 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
#undef SPH_ROTL32
|
||||
#define SPH_ROTL32 ROTL32
|
||||
|
||||
static uint32_t *d_gnounce[MAX_GPUS];
|
||||
static uint32_t *d_GNonce[MAX_GPUS];
|
||||
|
||||
__constant__ uint64_t pTarget[4];
|
||||
|
||||
#define shl(x, n) ((x) << (n))
|
||||
#define shr(x, n) ((x) >> (n))
|
||||
|
||||
#define ss0(x) (shr((x), 1) ^ shl((x), 3) ^ SPH_ROTL32((x), 4) ^ SPH_ROTL32((x), 19))
|
||||
#define ss1(x) (shr((x), 1) ^ shl((x), 2) ^ SPH_ROTL32((x), 8) ^ SPH_ROTL32((x), 23))
|
||||
#define ss2(x) (shr((x), 2) ^ shl((x), 1) ^ SPH_ROTL32((x), 12) ^ SPH_ROTL32((x), 25))
|
||||
#define ss3(x) (shr((x), 2) ^ shl((x), 2) ^ SPH_ROTL32((x), 15) ^ SPH_ROTL32((x), 29))
|
||||
#define ss4(x) (shr((x), 1) ^ (x))
|
||||
#define ss5(x) (shr((x), 2) ^ (x))
|
||||
|
||||
#define rs1(x) SPH_ROTL32((x), 3)
|
||||
#define rs2(x) SPH_ROTL32((x), 7)
|
||||
#define rs3(x) SPH_ROTL32((x), 13)
|
||||
#define rs4(x) SPH_ROTL32((x), 16)
|
||||
#define rs5(x) SPH_ROTL32((x), 19)
|
||||
#define rs6(x) SPH_ROTL32((x), 23)
|
||||
#define rs7(x) SPH_ROTL32((x), 27)
|
||||
|
||||
/* Message expansion function 1 */
|
||||
__forceinline__ __device__
|
||||
uint32_t expand32_1(int i, uint32_t *M32, const uint32_t *H, uint32_t *Q)
|
||||
{
|
||||
return (ss1(Q[i - 16]) + ss2(Q[i - 15]) + ss3(Q[i - 14]) + ss0(Q[i - 13])
|
||||
+ ss1(Q[i - 12]) + ss2(Q[i - 11]) + ss3(Q[i - 10]) + ss0(Q[i - 9])
|
||||
+ ss1(Q[i - 8]) + ss2(Q[i - 7]) + ss3(Q[i - 6]) + ss0(Q[i - 5])
|
||||
+ ss1(Q[i - 4]) + ss2(Q[i - 3]) + ss3(Q[i - 2]) + ss0(Q[i - 1])
|
||||
+ ((i*(0x05555555ul) + SPH_ROTL32(M32[(i - 16) % 16], ((i - 16) % 16) + 1)
|
||||
+ SPH_ROTL32(M32[(i - 13) % 16], ((i - 13) % 16) + 1)
|
||||
- SPH_ROTL32(M32[(i - 6) % 16], ((i - 6) % 16) + 1)) ^ H[(i - 16 + 7) % 16]));
|
||||
}
|
||||
|
||||
/* Message expansion function 2 */
|
||||
__forceinline__ __device__
|
||||
uint32_t expand32_2(int i, uint32_t *M32, const uint32_t *H, uint32_t *Q)
|
||||
{
|
||||
return (Q[i - 16] + rs1(Q[i - 15]) + Q[i - 14] + rs2(Q[i - 13])
|
||||
+ Q[i - 12] + rs3(Q[i - 11]) + Q[i - 10] + rs4(Q[i - 9])
|
||||
+ Q[i - 8] + rs5(Q[i - 7]) + Q[i - 6] + rs6(Q[i - 5])
|
||||
+ Q[i - 4] + rs7(Q[i - 3]) + ss4(Q[i - 2]) + ss5(Q[i - 1])
|
||||
+ ((i*(0x05555555ul) + SPH_ROTL32(M32[(i - 16) % 16], ((i - 16) % 16) + 1)
|
||||
+ SPH_ROTL32(M32[(i - 13) % 16], ((i - 13) % 16) + 1)
|
||||
- SPH_ROTL32(M32[(i - 6) % 16], ((i - 6) % 16) + 1)) ^ H[(i - 16 + 7) % 16]));
|
||||
}
|
||||
|
||||
__forceinline__ __device__
|
||||
void Compression256(uint32_t * M32)
|
||||
{
|
||||
uint32_t Q[32], XL32, XH32;
|
||||
|
||||
const uint32_t H[16] = {
|
||||
0x40414243, 0x44454647, 0x48494A4B, 0x4C4D4E4F,
|
||||
0x50515253, 0x54555657, 0x58595A5B, 0x5C5D5E5F,
|
||||
0x60616263, 0x64656667, 0x68696A6B, 0x6C6D6E6F,
|
||||
0x70717273, 0x74757677, 0x78797A7B, 0x7C7D7E7F
|
||||
};
|
||||
|
||||
Q[0] = (M32[5] ^ H[5]) - (M32[7] ^ H[7]) + (M32[10] ^ H[10]) + (M32[13] ^ H[13]) + (M32[14] ^ H[14]);
|
||||
Q[1] = (M32[6] ^ H[6]) - (M32[8] ^ H[8]) + (M32[11] ^ H[11]) + (M32[14] ^ H[14]) - (M32[15] ^ H[15]);
|
||||
Q[2] = (M32[0] ^ H[0]) + (M32[7] ^ H[7]) + (M32[9] ^ H[9]) - (M32[12] ^ H[12]) + (M32[15] ^ H[15]);
|
||||
Q[3] = (M32[0] ^ H[0]) - (M32[1] ^ H[1]) + (M32[8] ^ H[8]) - (M32[10] ^ H[10]) + (M32[13] ^ H[13]);
|
||||
Q[4] = (M32[1] ^ H[1]) + (M32[2] ^ H[2]) + (M32[9] ^ H[9]) - (M32[11] ^ H[11]) - (M32[14] ^ H[14]);
|
||||
Q[5] = (M32[3] ^ H[3]) - (M32[2] ^ H[2]) + (M32[10] ^ H[10]) - (M32[12] ^ H[12]) + (M32[15] ^ H[15]);
|
||||
Q[6] = (M32[4] ^ H[4]) - (M32[0] ^ H[0]) - (M32[3] ^ H[3]) - (M32[11] ^ H[11]) + (M32[13] ^ H[13]);
|
||||
Q[7] = (M32[1] ^ H[1]) - (M32[4] ^ H[4]) - (M32[5] ^ H[5]) - (M32[12] ^ H[12]) - (M32[14] ^ H[14]);
|
||||
Q[8] = (M32[2] ^ H[2]) - (M32[5] ^ H[5]) - (M32[6] ^ H[6]) + (M32[13] ^ H[13]) - (M32[15] ^ H[15]);
|
||||
Q[9] = (M32[0] ^ H[0]) - (M32[3] ^ H[3]) + (M32[6] ^ H[6]) - (M32[7] ^ H[7]) + (M32[14] ^ H[14]);
|
||||
Q[10] = (M32[8] ^ H[8]) - (M32[1] ^ H[1]) - (M32[4] ^ H[4]) - (M32[7] ^ H[7]) + (M32[15] ^ H[15]);
|
||||
Q[11] = (M32[8] ^ H[8]) - (M32[0] ^ H[0]) - (M32[2] ^ H[2]) - (M32[5] ^ H[5]) + (M32[9] ^ H[9]);
|
||||
Q[12] = (M32[1] ^ H[1]) + (M32[3] ^ H[3]) - (M32[6] ^ H[6]) - (M32[9] ^ H[9]) + (M32[10] ^ H[10]);
|
||||
Q[13] = (M32[2] ^ H[2]) + (M32[4] ^ H[4]) + (M32[7] ^ H[7]) + (M32[10] ^ H[10]) + (M32[11] ^ H[11]);
|
||||
Q[14] = (M32[3] ^ H[3]) - (M32[5] ^ H[5]) + (M32[8] ^ H[8]) - (M32[11] ^ H[11]) - (M32[12] ^ H[12]);
|
||||
Q[15] = (M32[12] ^ H[12]) - (M32[4] ^ H[4]) - (M32[6] ^ H[6]) - (M32[9] ^ H[9]) + (M32[13] ^ H[13]);
|
||||
|
||||
/* Diffuse the differences in every word in a bijective manner with ssi, and then add the values of the previous double pipe. */
|
||||
Q[0] = ss0(Q[0]) + H[1];
|
||||
Q[1] = ss1(Q[1]) + H[2];
|
||||
Q[2] = ss2(Q[2]) + H[3];
|
||||
Q[3] = ss3(Q[3]) + H[4];
|
||||
Q[4] = ss4(Q[4]) + H[5];
|
||||
Q[5] = ss0(Q[5]) + H[6];
|
||||
Q[6] = ss1(Q[6]) + H[7];
|
||||
Q[7] = ss2(Q[7]) + H[8];
|
||||
Q[8] = ss3(Q[8]) + H[9];
|
||||
Q[9] = ss4(Q[9]) + H[10];
|
||||
Q[10] = ss0(Q[10]) + H[11];
|
||||
Q[11] = ss1(Q[11]) + H[12];
|
||||
Q[12] = ss2(Q[12]) + H[13];
|
||||
Q[13] = ss3(Q[13]) + H[14];
|
||||
Q[14] = ss4(Q[14]) + H[15];
|
||||
Q[15] = ss0(Q[15]) + H[0];
|
||||
|
||||
/* This is the Message expansion or f_1 in the documentation. */
|
||||
/* It has 16 rounds. */
|
||||
/* Blue Midnight Wish has two tunable security parameters. */
|
||||
/* The parameters are named EXPAND_1_ROUNDS and EXPAND_2_ROUNDS. */
|
||||
/* The following relation for these parameters should is satisfied: */
|
||||
/* EXPAND_1_ROUNDS + EXPAND_2_ROUNDS = 16 */
|
||||
|
||||
#pragma unroll
|
||||
for (int i=16; i<18; i++)
|
||||
Q[i] = expand32_1(i, M32, H, Q);
|
||||
|
||||
#pragma nounroll
|
||||
for (int i=18; i<32; i++)
|
||||
Q[i] = expand32_2(i, M32, H, Q);
|
||||
|
||||
/* Blue Midnight Wish has two temporary cummulative variables that accumulate via XORing */
|
||||
/* 16 new variables that are prooduced in the Message Expansion part. */
|
||||
XL32 = Q[16] ^ Q[17] ^ Q[18] ^ Q[19] ^ Q[20] ^ Q[21] ^ Q[22] ^ Q[23];
|
||||
XH32 = XL32^Q[24] ^ Q[25] ^ Q[26] ^ Q[27] ^ Q[28] ^ Q[29] ^ Q[30] ^ Q[31];
|
||||
|
||||
|
||||
/* This part is the function f_2 - in the documentation */
|
||||
|
||||
/* Compute the double chaining pipe for the next message block. */
|
||||
M32[0] = (shl(XH32, 5) ^ shr(Q[16], 5) ^ M32[0]) + (XL32 ^ Q[24] ^ Q[0]);
|
||||
M32[1] = (shr(XH32, 7) ^ shl(Q[17], 8) ^ M32[1]) + (XL32 ^ Q[25] ^ Q[1]);
|
||||
M32[2] = (shr(XH32, 5) ^ shl(Q[18], 5) ^ M32[2]) + (XL32 ^ Q[26] ^ Q[2]);
|
||||
M32[3] = (shr(XH32, 1) ^ shl(Q[19], 5) ^ M32[3]) + (XL32 ^ Q[27] ^ Q[3]);
|
||||
M32[4] = (shr(XH32, 3) ^ Q[20] ^ M32[4]) + (XL32 ^ Q[28] ^ Q[4]);
|
||||
M32[5] = (shl(XH32, 6) ^ shr(Q[21], 6) ^ M32[5]) + (XL32 ^ Q[29] ^ Q[5]);
|
||||
M32[6] = (shr(XH32, 4) ^ shl(Q[22], 6) ^ M32[6]) + (XL32 ^ Q[30] ^ Q[6]);
|
||||
M32[7] = (shr(XH32, 11) ^ shl(Q[23], 2) ^ M32[7]) + (XL32 ^ Q[31] ^ Q[7]);
|
||||
|
||||
M32[8] = SPH_ROTL32(M32[4], 9) + (XH32 ^ Q[24] ^ M32[8]) + (shl(XL32, 8) ^ Q[23] ^ Q[8]);
|
||||
M32[9] = SPH_ROTL32(M32[5], 10) + (XH32 ^ Q[25] ^ M32[9]) + (shr(XL32, 6) ^ Q[16] ^ Q[9]);
|
||||
M32[10] = SPH_ROTL32(M32[6], 11) + (XH32 ^ Q[26] ^ M32[10]) + (shl(XL32, 6) ^ Q[17] ^ Q[10]);
|
||||
M32[11] = SPH_ROTL32(M32[7], 12) + (XH32 ^ Q[27] ^ M32[11]) + (shl(XL32, 4) ^ Q[18] ^ Q[11]);
|
||||
M32[12] = SPH_ROTL32(M32[0], 13) + (XH32 ^ Q[28] ^ M32[12]) + (shr(XL32, 3) ^ Q[19] ^ Q[12]);
|
||||
M32[13] = SPH_ROTL32(M32[1], 14) + (XH32 ^ Q[29] ^ M32[13]) + (shr(XL32, 4) ^ Q[20] ^ Q[13]);
|
||||
M32[14] = SPH_ROTL32(M32[2], 15) + (XH32 ^ Q[30] ^ M32[14]) + (shr(XL32, 7) ^ Q[21] ^ Q[14]);
|
||||
M32[15] = SPH_ROTL32(M32[3], 16) + (XH32 ^ Q[31] ^ M32[15]) + (shr(XL32, 2) ^ Q[22] ^ Q[15]);
|
||||
}
|
||||
|
||||
__forceinline__ __device__
|
||||
void Compression256_2(uint32_t * M32)
|
||||
{
|
||||
uint32_t XL32, XH32, Q[32];
|
||||
|
||||
const uint32_t H[16] = {
|
||||
0xaaaaaaa0, 0xaaaaaaa1, 0xaaaaaaa2, 0xaaaaaaa3,
|
||||
0xaaaaaaa4, 0xaaaaaaa5, 0xaaaaaaa6, 0xaaaaaaa7,
|
||||
0xaaaaaaa8, 0xaaaaaaa9, 0xaaaaaaaa, 0xaaaaaaab,
|
||||
0xaaaaaaac, 0xaaaaaaad, 0xaaaaaaae, 0xaaaaaaaf
|
||||
};
|
||||
|
||||
Q[0] = (M32[5] ^ H[5]) - (M32[7] ^ H[7]) + (M32[10] ^ H[10]) + (M32[13] ^ H[13]) + (M32[14] ^ H[14]);
|
||||
Q[1] = (M32[6] ^ H[6]) - (M32[8] ^ H[8]) + (M32[11] ^ H[11]) + (M32[14] ^ H[14]) - (M32[15] ^ H[15]);
|
||||
Q[2] = (M32[0] ^ H[0]) + (M32[7] ^ H[7]) + (M32[9] ^ H[9]) - (M32[12] ^ H[12]) + (M32[15] ^ H[15]);
|
||||
Q[3] = (M32[0] ^ H[0]) - (M32[1] ^ H[1]) + (M32[8] ^ H[8]) - (M32[10] ^ H[10]) + (M32[13] ^ H[13]);
|
||||
Q[4] = (M32[1] ^ H[1]) + (M32[2] ^ H[2]) + (M32[9] ^ H[9]) - (M32[11] ^ H[11]) - (M32[14] ^ H[14]);
|
||||
Q[5] = (M32[3] ^ H[3]) - (M32[2] ^ H[2]) + (M32[10] ^ H[10]) - (M32[12] ^ H[12]) + (M32[15] ^ H[15]);
|
||||
Q[6] = (M32[4] ^ H[4]) - (M32[0] ^ H[0]) - (M32[3] ^ H[3]) - (M32[11] ^ H[11]) + (M32[13] ^ H[13]);
|
||||
Q[7] = (M32[1] ^ H[1]) - (M32[4] ^ H[4]) - (M32[5] ^ H[5]) - (M32[12] ^ H[12]) - (M32[14] ^ H[14]);
|
||||
Q[8] = (M32[2] ^ H[2]) - (M32[5] ^ H[5]) - (M32[6] ^ H[6]) + (M32[13] ^ H[13]) - (M32[15] ^ H[15]);
|
||||
Q[9] = (M32[0] ^ H[0]) - (M32[3] ^ H[3]) + (M32[6] ^ H[6]) - (M32[7] ^ H[7]) + (M32[14] ^ H[14]);
|
||||
Q[10] = (M32[8] ^ H[8]) - (M32[1] ^ H[1]) - (M32[4] ^ H[4]) - (M32[7] ^ H[7]) + (M32[15] ^ H[15]);
|
||||
Q[11] = (M32[8] ^ H[8]) - (M32[0] ^ H[0]) - (M32[2] ^ H[2]) - (M32[5] ^ H[5]) + (M32[9] ^ H[9]);
|
||||
Q[12] = (M32[1] ^ H[1]) + (M32[3] ^ H[3]) - (M32[6] ^ H[6]) - (M32[9] ^ H[9]) + (M32[10] ^ H[10]);
|
||||
Q[13] = (M32[2] ^ H[2]) + (M32[4] ^ H[4]) + (M32[7] ^ H[7]) + (M32[10] ^ H[10]) + (M32[11] ^ H[11]);
|
||||
Q[14] = (M32[3] ^ H[3]) - (M32[5] ^ H[5]) + (M32[8] ^ H[8]) - (M32[11] ^ H[11]) - (M32[12] ^ H[12]);
|
||||
Q[15] = (M32[12] ^ H[12]) - (M32[4] ^ H[4]) - (M32[6] ^ H[6]) - (M32[9] ^ H[9]) + (M32[13] ^ H[13]);
|
||||
|
||||
/* Diffuse the differences in every word in a bijective manner with ssi, and then add the values of the previous double pipe.*/
|
||||
Q[0] = ss0(Q[0]) + H[1];
|
||||
Q[1] = ss1(Q[1]) + H[2];
|
||||
Q[2] = ss2(Q[2]) + H[3];
|
||||
Q[3] = ss3(Q[3]) + H[4];
|
||||
Q[4] = ss4(Q[4]) + H[5];
|
||||
Q[5] = ss0(Q[5]) + H[6];
|
||||
Q[6] = ss1(Q[6]) + H[7];
|
||||
Q[7] = ss2(Q[7]) + H[8];
|
||||
Q[8] = ss3(Q[8]) + H[9];
|
||||
Q[9] = ss4(Q[9]) + H[10];
|
||||
Q[10] = ss0(Q[10]) + H[11];
|
||||
Q[11] = ss1(Q[11]) + H[12];
|
||||
Q[12] = ss2(Q[12]) + H[13];
|
||||
Q[13] = ss3(Q[13]) + H[14];
|
||||
Q[14] = ss4(Q[14]) + H[15];
|
||||
Q[15] = ss0(Q[15]) + H[0];
|
||||
|
||||
/* This is the Message expansion or f_1 in the documentation. */
|
||||
/* It has 16 rounds. */
|
||||
/* Blue Midnight Wish has two tunable security parameters. */
|
||||
/* The parameters are named EXPAND_1_ROUNDS and EXPAND_2_ROUNDS. */
|
||||
/* The following relation for these parameters should is satisfied: */
|
||||
/* EXPAND_1_ROUNDS + EXPAND_2_ROUNDS = 16 */
|
||||
|
||||
#pragma unroll
|
||||
for (int i = 16; i<18; i++)
|
||||
Q[i] = expand32_1(i, M32, H, Q);
|
||||
|
||||
#pragma nounroll
|
||||
for (int i = 18; i<32; i++)
|
||||
Q[i] = expand32_2(i, M32, H, Q);
|
||||
|
||||
/* Blue Midnight Wish has two temporary cummulative variables that accumulate via XORing */
|
||||
/* 16 new variables that are prooduced in the Message Expansion part. */
|
||||
XL32 = Q[16] ^ Q[17] ^ Q[18] ^ Q[19] ^ Q[20] ^ Q[21] ^ Q[22] ^ Q[23];
|
||||
XH32 = XL32 ^ Q[24] ^ Q[25] ^ Q[26] ^ Q[27] ^ Q[28] ^ Q[29] ^ Q[30] ^ Q[31];
|
||||
|
||||
M32[2] = (shr(XH32, 5) ^ shl(Q[18], 5) ^ M32[2]) + (XL32 ^ Q[26] ^ Q[2]);
|
||||
M32[3] = (shr(XH32, 1) ^ shl(Q[19], 5) ^ M32[3]) + (XL32 ^ Q[27] ^ Q[3]);
|
||||
M32[14] = SPH_ROTL32(M32[2], 15) + (XH32 ^ Q[30] ^ M32[14]) + (shr(XL32, 7) ^ Q[21] ^ Q[14]);
|
||||
M32[15] = SPH_ROTL32(M32[3], 16) + (XH32 ^ Q[31] ^ M32[15]) + (shr(XL32, 2) ^ Q[22] ^ Q[15]);
|
||||
}
|
||||
|
||||
#define TPB 512
|
||||
__global__ __launch_bounds__(TPB, 2)
|
||||
void bmw256_gpu_hash_32(uint32_t threads, uint32_t startNounce, uint64_t *g_hash, uint32_t *const __restrict__ nonceVector)
|
||||
{
|
||||
const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
uint32_t message[16] = { 0 };
|
||||
|
||||
LOHI(message[0], message[1], __ldg(&g_hash[thread]));
|
||||
LOHI(message[2], message[3], __ldg(&g_hash[thread + 1 * threads]));
|
||||
LOHI(message[4], message[5], __ldg(&g_hash[thread + 2 * threads]));
|
||||
LOHI(message[6], message[7], __ldg(&g_hash[thread + 3 * threads]));
|
||||
|
||||
message[8]=0x80;
|
||||
message[14]=0x100;
|
||||
Compression256(message);
|
||||
Compression256_2(message);
|
||||
|
||||
if (((uint64_t*)message)[7] <= pTarget[3])
|
||||
{
|
||||
uint32_t tmp = atomicExch(&nonceVector[0], startNounce + thread);
|
||||
if (tmp != 0)
|
||||
nonceVector[1] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void bmw256_cpu_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint64_t *g_hash, uint32_t *resultnonces)
|
||||
{
|
||||
const uint32_t threadsperblock = TPB;
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
cudaMemset(d_GNonce[thr_id], 0, 2 * sizeof(uint32_t));
|
||||
|
||||
bmw256_gpu_hash_32 << <grid, block >> >(threads, startNounce, g_hash, d_GNonce[thr_id]);
|
||||
cudaMemcpy(d_gnounce[thr_id], d_GNonce[thr_id], 2 * sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
resultnonces[0] = *(d_gnounce[thr_id]);
|
||||
resultnonces[1] = *(d_gnounce[thr_id] + 1);
|
||||
}
|
||||
|
||||
|
||||
__host__
|
||||
void bmw256_cpu_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
cudaMalloc(&d_GNonce[thr_id], 2 * sizeof(uint32_t));
|
||||
cudaMallocHost(&d_gnounce[thr_id], 2 * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
__host__
|
||||
void bmw256_cpu_free(int thr_id)
|
||||
{
|
||||
cudaFree(d_GNonce[thr_id]);
|
||||
cudaFreeHost(d_gnounce[thr_id]);
|
||||
}
|
||||
|
||||
__host__
|
||||
void bmw256_setTarget(const void *pTargetIn)
|
||||
{
|
||||
cudaMemcpyToSymbol(pTarget, pTargetIn, 32, 0, cudaMemcpyHostToDevice);
|
||||
}
|
||||
@@ -1,370 +0,0 @@
|
||||
#include "cuda_helper.h"
|
||||
|
||||
#define CUBEHASH_ROUNDS 16 /* this is r for CubeHashr/b */
|
||||
#define CUBEHASH_BLOCKBYTES 32 /* this is b for CubeHashr/b */
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
/* just for vstudio code colors */
|
||||
#define __CUDA_ARCH__ 520
|
||||
#endif
|
||||
|
||||
#if __CUDA_ARCH__ < 350
|
||||
#define LROT(x,bits) ((x << bits) | (x >> (32 - bits)))
|
||||
#else
|
||||
#define LROT(x, bits) __funnelshift_l(x, x, bits)
|
||||
#endif
|
||||
|
||||
#define TPB35 576
|
||||
#define TPB50 1024
|
||||
|
||||
#define ROTATEUPWARDS7(a) LROT(a,7)
|
||||
#define ROTATEUPWARDS11(a) LROT(a,11)
|
||||
|
||||
__device__ __forceinline__ void rrounds(uint32_t x[2][2][2][2][2])
|
||||
{
|
||||
int r;
|
||||
|
||||
uint32_t x0[2][2][2][2];
|
||||
uint32_t x1[2][2][2][2];
|
||||
|
||||
for (r = 0; r < CUBEHASH_ROUNDS; r += 2) {
|
||||
/* "rotate x_0jklm upwards by 7 bits" */
|
||||
x0[0][0][0][0] = ROTATEUPWARDS7(x[0][0][0][0][0]);
|
||||
x0[0][0][0][1] = ROTATEUPWARDS7(x[0][0][0][0][1]);
|
||||
x0[0][0][1][0] = ROTATEUPWARDS7(x[0][0][0][1][0]);
|
||||
x0[0][0][1][1] = ROTATEUPWARDS7(x[0][0][0][1][1]);
|
||||
x0[0][1][0][0] = ROTATEUPWARDS7(x[0][0][1][0][0]);
|
||||
x0[0][1][0][1] = ROTATEUPWARDS7(x[0][0][1][0][1]);
|
||||
x0[0][1][1][0] = ROTATEUPWARDS7(x[0][0][1][1][0]);
|
||||
x0[0][1][1][1] = ROTATEUPWARDS7(x[0][0][1][1][1]);
|
||||
x0[1][0][0][0] = ROTATEUPWARDS7(x[0][1][0][0][0]);
|
||||
x0[1][0][0][1] = ROTATEUPWARDS7(x[0][1][0][0][1]);
|
||||
x0[1][0][1][0] = ROTATEUPWARDS7(x[0][1][0][1][0]);
|
||||
x0[1][0][1][1] = ROTATEUPWARDS7(x[0][1][0][1][1]);
|
||||
x0[1][1][0][0] = ROTATEUPWARDS7(x[0][1][1][0][0]);
|
||||
x0[1][1][0][1] = ROTATEUPWARDS7(x[0][1][1][0][1]);
|
||||
x0[1][1][1][0] = ROTATEUPWARDS7(x[0][1][1][1][0]);
|
||||
x0[1][1][1][1] = ROTATEUPWARDS7(x[0][1][1][1][1]);
|
||||
|
||||
/* "add x_0jklm into x_1jklm modulo 2^32" */
|
||||
x1[0][0][0][0] = x[1][0][0][0][0] + x[0][0][0][0][0];
|
||||
x1[0][0][0][1] = x[1][0][0][0][1] + x[0][0][0][0][1];
|
||||
x1[0][0][1][0] = x[1][0][0][1][0] + x[0][0][0][1][0];
|
||||
x1[0][0][1][1] = x[1][0][0][1][1] + x[0][0][0][1][1];
|
||||
x1[0][1][0][0] = x[1][0][1][0][0] + x[0][0][1][0][0];
|
||||
x1[0][1][0][1] = x[1][0][1][0][1] + x[0][0][1][0][1];
|
||||
x1[0][1][1][0] = x[1][0][1][1][0] + x[0][0][1][1][0];
|
||||
x1[0][1][1][1] = x[1][0][1][1][1] + x[0][0][1][1][1];
|
||||
x1[1][0][0][0] = x[1][1][0][0][0] + x[0][1][0][0][0];
|
||||
x1[1][0][0][1] = x[1][1][0][0][1] + x[0][1][0][0][1];
|
||||
x1[1][0][1][0] = x[1][1][0][1][0] + x[0][1][0][1][0];
|
||||
x1[1][0][1][1] = x[1][1][0][1][1] + x[0][1][0][1][1];
|
||||
x1[1][1][0][0] = x[1][1][1][0][0] + x[0][1][1][0][0];
|
||||
x1[1][1][0][1] = x[1][1][1][0][1] + x[0][1][1][0][1];
|
||||
x1[1][1][1][0] = x[1][1][1][1][0] + x[0][1][1][1][0];
|
||||
x1[1][1][1][1] = x[1][1][1][1][1] + x[0][1][1][1][1];
|
||||
|
||||
/* "xor x_1~jklm into x_0jklm" */
|
||||
x[0][0][0][0][0] = x0[0][0][0][0] ^ x1[1][0][0][0];
|
||||
x[0][0][0][0][1] = x0[0][0][0][1] ^ x1[1][0][0][1];
|
||||
x[0][0][0][1][0] = x0[0][0][1][0] ^ x1[1][0][1][0];
|
||||
x[0][0][0][1][1] = x0[0][0][1][1] ^ x1[1][0][1][1];
|
||||
x[0][0][1][0][0] = x0[0][1][0][0] ^ x1[1][1][0][0];
|
||||
x[0][0][1][0][1] = x0[0][1][0][1] ^ x1[1][1][0][1];
|
||||
x[0][0][1][1][0] = x0[0][1][1][0] ^ x1[1][1][1][0];
|
||||
x[0][0][1][1][1] = x0[0][1][1][1] ^ x1[1][1][1][1];
|
||||
x[0][1][0][0][0] = x0[1][0][0][0] ^ x1[0][0][0][0];
|
||||
x[0][1][0][0][1] = x0[1][0][0][1] ^ x1[0][0][0][1];
|
||||
x[0][1][0][1][0] = x0[1][0][1][0] ^ x1[0][0][1][0];
|
||||
x[0][1][0][1][1] = x0[1][0][1][1] ^ x1[0][0][1][1];
|
||||
x[0][1][1][0][0] = x0[1][1][0][0] ^ x1[0][1][0][0];
|
||||
x[0][1][1][0][1] = x0[1][1][0][1] ^ x1[0][1][0][1];
|
||||
x[0][1][1][1][0] = x0[1][1][1][0] ^ x1[0][1][1][0];
|
||||
x[0][1][1][1][1] = x0[1][1][1][1] ^ x1[0][1][1][1];
|
||||
|
||||
/* "rotate x_0jklm upwards by 11 bits" */
|
||||
x0[0][0][0][0] = ROTATEUPWARDS11(x[0][0][0][0][0]);
|
||||
x0[0][0][0][1] = ROTATEUPWARDS11(x[0][0][0][0][1]);
|
||||
x0[0][0][1][0] = ROTATEUPWARDS11(x[0][0][0][1][0]);
|
||||
x0[0][0][1][1] = ROTATEUPWARDS11(x[0][0][0][1][1]);
|
||||
x0[0][1][0][0] = ROTATEUPWARDS11(x[0][0][1][0][0]);
|
||||
x0[0][1][0][1] = ROTATEUPWARDS11(x[0][0][1][0][1]);
|
||||
x0[0][1][1][0] = ROTATEUPWARDS11(x[0][0][1][1][0]);
|
||||
x0[0][1][1][1] = ROTATEUPWARDS11(x[0][0][1][1][1]);
|
||||
x0[1][0][0][0] = ROTATEUPWARDS11(x[0][1][0][0][0]);
|
||||
x0[1][0][0][1] = ROTATEUPWARDS11(x[0][1][0][0][1]);
|
||||
x0[1][0][1][0] = ROTATEUPWARDS11(x[0][1][0][1][0]);
|
||||
x0[1][0][1][1] = ROTATEUPWARDS11(x[0][1][0][1][1]);
|
||||
x0[1][1][0][0] = ROTATEUPWARDS11(x[0][1][1][0][0]);
|
||||
x0[1][1][0][1] = ROTATEUPWARDS11(x[0][1][1][0][1]);
|
||||
x0[1][1][1][0] = ROTATEUPWARDS11(x[0][1][1][1][0]);
|
||||
x0[1][1][1][1] = ROTATEUPWARDS11(x[0][1][1][1][1]);
|
||||
|
||||
/* "add x_0jklm into x_1~jk~lm modulo 2^32" */
|
||||
x[1][1][0][1][0] = x1[1][0][1][0] + x[0][0][0][0][0];
|
||||
x[1][1][0][1][1] = x1[1][0][1][1] + x[0][0][0][0][1];
|
||||
x[1][1][0][0][0] = x1[1][0][0][0] + x[0][0][0][1][0];
|
||||
x[1][1][0][0][1] = x1[1][0][0][1] + x[0][0][0][1][1];
|
||||
x[1][1][1][1][0] = x1[1][1][1][0] + x[0][0][1][0][0];
|
||||
x[1][1][1][1][1] = x1[1][1][1][1] + x[0][0][1][0][1];
|
||||
x[1][1][1][0][0] = x1[1][1][0][0] + x[0][0][1][1][0];
|
||||
x[1][1][1][0][1] = x1[1][1][0][1] + x[0][0][1][1][1];
|
||||
x[1][0][0][1][0] = x1[0][0][1][0] + x[0][1][0][0][0];
|
||||
x[1][0][0][1][1] = x1[0][0][1][1] + x[0][1][0][0][1];
|
||||
x[1][0][0][0][0] = x1[0][0][0][0] + x[0][1][0][1][0];
|
||||
x[1][0][0][0][1] = x1[0][0][0][1] + x[0][1][0][1][1];
|
||||
x[1][0][1][1][0] = x1[0][1][1][0] + x[0][1][1][0][0];
|
||||
x[1][0][1][1][1] = x1[0][1][1][1] + x[0][1][1][0][1];
|
||||
x[1][0][1][0][0] = x1[0][1][0][0] + x[0][1][1][1][0];
|
||||
x[1][0][1][0][1] = x1[0][1][0][1] + x[0][1][1][1][1];
|
||||
|
||||
/* "xor x_1~j~k~lm into x_0jklm" */
|
||||
x[0][0][0][0][0] = x0[0][0][0][0] ^ x[1][1][1][1][0];
|
||||
x[0][0][0][0][1] = x0[0][0][0][1] ^ x[1][1][1][1][1];
|
||||
x[0][0][0][1][0] = x0[0][0][1][0] ^ x[1][1][1][0][0];
|
||||
x[0][0][0][1][1] = x0[0][0][1][1] ^ x[1][1][1][0][1];
|
||||
x[0][0][1][0][0] = x0[0][1][0][0] ^ x[1][1][0][1][0];
|
||||
x[0][0][1][0][1] = x0[0][1][0][1] ^ x[1][1][0][1][1];
|
||||
x[0][0][1][1][0] = x0[0][1][1][0] ^ x[1][1][0][0][0];
|
||||
x[0][0][1][1][1] = x0[0][1][1][1] ^ x[1][1][0][0][1];
|
||||
x[0][1][0][0][0] = x0[1][0][0][0] ^ x[1][0][1][1][0];
|
||||
x[0][1][0][0][1] = x0[1][0][0][1] ^ x[1][0][1][1][1];
|
||||
x[0][1][0][1][0] = x0[1][0][1][0] ^ x[1][0][1][0][0];
|
||||
x[0][1][0][1][1] = x0[1][0][1][1] ^ x[1][0][1][0][1];
|
||||
x[0][1][1][0][0] = x0[1][1][0][0] ^ x[1][0][0][1][0];
|
||||
x[0][1][1][0][1] = x0[1][1][0][1] ^ x[1][0][0][1][1];
|
||||
x[0][1][1][1][0] = x0[1][1][1][0] ^ x[1][0][0][0][0];
|
||||
x[0][1][1][1][1] = x0[1][1][1][1] ^ x[1][0][0][0][1];
|
||||
|
||||
/* "rotate x_0jklm upwards by 7 bits" */
|
||||
x0[0][0][0][0] = ROTATEUPWARDS7(x[0][0][0][0][0]);
|
||||
x0[0][0][0][1] = ROTATEUPWARDS7(x[0][0][0][0][1]);
|
||||
x0[0][0][1][0] = ROTATEUPWARDS7(x[0][0][0][1][0]);
|
||||
x0[0][0][1][1] = ROTATEUPWARDS7(x[0][0][0][1][1]);
|
||||
x0[0][1][0][0] = ROTATEUPWARDS7(x[0][0][1][0][0]);
|
||||
x0[0][1][0][1] = ROTATEUPWARDS7(x[0][0][1][0][1]);
|
||||
x0[0][1][1][0] = ROTATEUPWARDS7(x[0][0][1][1][0]);
|
||||
x0[0][1][1][1] = ROTATEUPWARDS7(x[0][0][1][1][1]);
|
||||
x0[1][0][0][0] = ROTATEUPWARDS7(x[0][1][0][0][0]);
|
||||
x0[1][0][0][1] = ROTATEUPWARDS7(x[0][1][0][0][1]);
|
||||
x0[1][0][1][0] = ROTATEUPWARDS7(x[0][1][0][1][0]);
|
||||
x0[1][0][1][1] = ROTATEUPWARDS7(x[0][1][0][1][1]);
|
||||
x0[1][1][0][0] = ROTATEUPWARDS7(x[0][1][1][0][0]);
|
||||
x0[1][1][0][1] = ROTATEUPWARDS7(x[0][1][1][0][1]);
|
||||
x0[1][1][1][0] = ROTATEUPWARDS7(x[0][1][1][1][0]);
|
||||
x0[1][1][1][1] = ROTATEUPWARDS7(x[0][1][1][1][1]);
|
||||
|
||||
/* "add x_0jklm into x_1~j~k~l~m modulo 2^32" */
|
||||
x1[1][1][1][1] = x[1][1][1][1][1] + x[0][0][0][0][0];
|
||||
x1[1][1][1][0] = x[1][1][1][1][0] + x[0][0][0][0][1];
|
||||
x1[1][1][0][1] = x[1][1][1][0][1] + x[0][0][0][1][0];
|
||||
x1[1][1][0][0] = x[1][1][1][0][0] + x[0][0][0][1][1];
|
||||
x1[1][0][1][1] = x[1][1][0][1][1] + x[0][0][1][0][0];
|
||||
x1[1][0][1][0] = x[1][1][0][1][0] + x[0][0][1][0][1];
|
||||
x1[1][0][0][1] = x[1][1][0][0][1] + x[0][0][1][1][0];
|
||||
x1[1][0][0][0] = x[1][1][0][0][0] + x[0][0][1][1][1];
|
||||
x1[0][1][1][1] = x[1][0][1][1][1] + x[0][1][0][0][0];
|
||||
x1[0][1][1][0] = x[1][0][1][1][0] + x[0][1][0][0][1];
|
||||
x1[0][1][0][1] = x[1][0][1][0][1] + x[0][1][0][1][0];
|
||||
x1[0][1][0][0] = x[1][0][1][0][0] + x[0][1][0][1][1];
|
||||
x1[0][0][1][1] = x[1][0][0][1][1] + x[0][1][1][0][0];
|
||||
x1[0][0][1][0] = x[1][0][0][1][0] + x[0][1][1][0][1];
|
||||
x1[0][0][0][1] = x[1][0][0][0][1] + x[0][1][1][1][0];
|
||||
x1[0][0][0][0] = x[1][0][0][0][0] + x[0][1][1][1][1];
|
||||
|
||||
/* "xor x_1j~k~l~m into x_0jklm" */
|
||||
x[0][0][0][0][0] = x0[0][0][0][0] ^ x1[0][1][1][1];
|
||||
x[0][0][0][0][1] = x0[0][0][0][1] ^ x1[0][1][1][0];
|
||||
x[0][0][0][1][0] = x0[0][0][1][0] ^ x1[0][1][0][1];
|
||||
x[0][0][0][1][1] = x0[0][0][1][1] ^ x1[0][1][0][0];
|
||||
x[0][0][1][0][0] = x0[0][1][0][0] ^ x1[0][0][1][1];
|
||||
x[0][0][1][0][1] = x0[0][1][0][1] ^ x1[0][0][1][0];
|
||||
x[0][0][1][1][0] = x0[0][1][1][0] ^ x1[0][0][0][1];
|
||||
x[0][0][1][1][1] = x0[0][1][1][1] ^ x1[0][0][0][0];
|
||||
x[0][1][0][0][0] = x0[1][0][0][0] ^ x1[1][1][1][1];
|
||||
x[0][1][0][0][1] = x0[1][0][0][1] ^ x1[1][1][1][0];
|
||||
x[0][1][0][1][0] = x0[1][0][1][0] ^ x1[1][1][0][1];
|
||||
x[0][1][0][1][1] = x0[1][0][1][1] ^ x1[1][1][0][0];
|
||||
x[0][1][1][0][0] = x0[1][1][0][0] ^ x1[1][0][1][1];
|
||||
x[0][1][1][0][1] = x0[1][1][0][1] ^ x1[1][0][1][0];
|
||||
x[0][1][1][1][0] = x0[1][1][1][0] ^ x1[1][0][0][1];
|
||||
x[0][1][1][1][1] = x0[1][1][1][1] ^ x1[1][0][0][0];
|
||||
|
||||
/* "rotate x_0jklm upwards by 11 bits" */
|
||||
x0[0][0][0][0] = ROTATEUPWARDS11(x[0][0][0][0][0]);
|
||||
x0[0][0][0][1] = ROTATEUPWARDS11(x[0][0][0][0][1]);
|
||||
x0[0][0][1][0] = ROTATEUPWARDS11(x[0][0][0][1][0]);
|
||||
x0[0][0][1][1] = ROTATEUPWARDS11(x[0][0][0][1][1]);
|
||||
x0[0][1][0][0] = ROTATEUPWARDS11(x[0][0][1][0][0]);
|
||||
x0[0][1][0][1] = ROTATEUPWARDS11(x[0][0][1][0][1]);
|
||||
x0[0][1][1][0] = ROTATEUPWARDS11(x[0][0][1][1][0]);
|
||||
x0[0][1][1][1] = ROTATEUPWARDS11(x[0][0][1][1][1]);
|
||||
x0[1][0][0][0] = ROTATEUPWARDS11(x[0][1][0][0][0]);
|
||||
x0[1][0][0][1] = ROTATEUPWARDS11(x[0][1][0][0][1]);
|
||||
x0[1][0][1][0] = ROTATEUPWARDS11(x[0][1][0][1][0]);
|
||||
x0[1][0][1][1] = ROTATEUPWARDS11(x[0][1][0][1][1]);
|
||||
x0[1][1][0][0] = ROTATEUPWARDS11(x[0][1][1][0][0]);
|
||||
x0[1][1][0][1] = ROTATEUPWARDS11(x[0][1][1][0][1]);
|
||||
x0[1][1][1][0] = ROTATEUPWARDS11(x[0][1][1][1][0]);
|
||||
x0[1][1][1][1] = ROTATEUPWARDS11(x[0][1][1][1][1]);
|
||||
|
||||
/* "add x_0jklm into x_1j~kl~m modulo 2^32" */
|
||||
x[1][0][1][0][1] = x1[0][1][0][1] + x[0][0][0][0][0];
|
||||
x[1][0][1][0][0] = x1[0][1][0][0] + x[0][0][0][0][1];
|
||||
x[1][0][1][1][1] = x1[0][1][1][1] + x[0][0][0][1][0];
|
||||
x[1][0][1][1][0] = x1[0][1][1][0] + x[0][0][0][1][1];
|
||||
x[1][0][0][0][1] = x1[0][0][0][1] + x[0][0][1][0][0];
|
||||
x[1][0][0][0][0] = x1[0][0][0][0] + x[0][0][1][0][1];
|
||||
x[1][0][0][1][1] = x1[0][0][1][1] + x[0][0][1][1][0];
|
||||
x[1][0][0][1][0] = x1[0][0][1][0] + x[0][0][1][1][1];
|
||||
x[1][1][1][0][1] = x1[1][1][0][1] + x[0][1][0][0][0];
|
||||
x[1][1][1][0][0] = x1[1][1][0][0] + x[0][1][0][0][1];
|
||||
x[1][1][1][1][1] = x1[1][1][1][1] + x[0][1][0][1][0];
|
||||
x[1][1][1][1][0] = x1[1][1][1][0] + x[0][1][0][1][1];
|
||||
x[1][1][0][0][1] = x1[1][0][0][1] + x[0][1][1][0][0];
|
||||
x[1][1][0][0][0] = x1[1][0][0][0] + x[0][1][1][0][1];
|
||||
x[1][1][0][1][1] = x1[1][0][1][1] + x[0][1][1][1][0];
|
||||
x[1][1][0][1][0] = x1[1][0][1][0] + x[0][1][1][1][1];
|
||||
|
||||
/* "xor x_1jkl~m into x_0jklm" */
|
||||
x[0][0][0][0][0] = x0[0][0][0][0] ^ x[1][0][0][0][1];
|
||||
x[0][0][0][0][1] = x0[0][0][0][1] ^ x[1][0][0][0][0];
|
||||
x[0][0][0][1][0] = x0[0][0][1][0] ^ x[1][0][0][1][1];
|
||||
x[0][0][0][1][1] = x0[0][0][1][1] ^ x[1][0][0][1][0];
|
||||
x[0][0][1][0][0] = x0[0][1][0][0] ^ x[1][0][1][0][1];
|
||||
x[0][0][1][0][1] = x0[0][1][0][1] ^ x[1][0][1][0][0];
|
||||
x[0][0][1][1][0] = x0[0][1][1][0] ^ x[1][0][1][1][1];
|
||||
x[0][0][1][1][1] = x0[0][1][1][1] ^ x[1][0][1][1][0];
|
||||
x[0][1][0][0][0] = x0[1][0][0][0] ^ x[1][1][0][0][1];
|
||||
x[0][1][0][0][1] = x0[1][0][0][1] ^ x[1][1][0][0][0];
|
||||
x[0][1][0][1][0] = x0[1][0][1][0] ^ x[1][1][0][1][1];
|
||||
x[0][1][0][1][1] = x0[1][0][1][1] ^ x[1][1][0][1][0];
|
||||
x[0][1][1][0][0] = x0[1][1][0][0] ^ x[1][1][1][0][1];
|
||||
x[0][1][1][0][1] = x0[1][1][0][1] ^ x[1][1][1][0][0];
|
||||
x[0][1][1][1][0] = x0[1][1][1][0] ^ x[1][1][1][1][1];
|
||||
x[0][1][1][1][1] = x0[1][1][1][1] ^ x[1][1][1][1][0];
|
||||
}
|
||||
}
|
||||
|
||||
__device__ __forceinline__
|
||||
void Final(uint32_t x[2][2][2][2][2], uint32_t *hashval)
|
||||
{
|
||||
/* "the integer 1 is xored into the last state word x_11111" */
|
||||
x[1][1][1][1][1] ^= 1U;
|
||||
|
||||
/* "the state is then transformed invertibly through 10r identical rounds" */
|
||||
for (int i = 0; i < 10; ++i) rrounds(x);
|
||||
|
||||
/* "output the first h/8 bytes of the state" */
|
||||
hashval[0] = x[0][0][0][0][0];
|
||||
hashval[1] = x[0][0][0][0][1];
|
||||
hashval[2] = x[0][0][0][1][0];
|
||||
hashval[3] = x[0][0][0][1][1];
|
||||
hashval[4] = x[0][0][1][0][0];
|
||||
hashval[5] = x[0][0][1][0][1];
|
||||
hashval[6] = x[0][0][1][1][0];
|
||||
hashval[7] = x[0][0][1][1][1];
|
||||
}
|
||||
|
||||
#if __CUDA_ARCH__ >= 500
|
||||
__global__ __launch_bounds__(TPB50, 1)
|
||||
#else
|
||||
__global__ __launch_bounds__(TPB35, 1)
|
||||
#endif
|
||||
void cubehash256_gpu_hash_32(uint32_t threads, uint32_t startNounce, uint2 *g_hash)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
#if __CUDA_ARCH__ >= 500
|
||||
uint2 Hash[4];
|
||||
|
||||
Hash[0] = __ldg(&g_hash[thread]);
|
||||
Hash[1] = __ldg(&g_hash[thread + 1 * threads]);
|
||||
Hash[2] = __ldg(&g_hash[thread + 2 * threads]);
|
||||
Hash[3] = __ldg(&g_hash[thread + 3 * threads]);
|
||||
#else
|
||||
uint32_t Hash[8];
|
||||
|
||||
LOHI(Hash[0], Hash[1], __ldg(&((uint64_t*)g_hash)[thread]));
|
||||
LOHI(Hash[2], Hash[3], __ldg(&((uint64_t*)g_hash)[thread + 1 * threads]));
|
||||
LOHI(Hash[4], Hash[5], __ldg(&((uint64_t*)g_hash)[thread + 2 * threads]));
|
||||
LOHI(Hash[6], Hash[7], __ldg(&((uint64_t*)g_hash)[thread + 3 * threads]));
|
||||
#endif
|
||||
|
||||
uint32_t x[2][2][2][2][2] =
|
||||
{
|
||||
0xEA2BD4B4, 0xCCD6F29F, 0x63117E71, 0x35481EAE,
|
||||
0x22512D5B, 0xE5D94E63, 0x7E624131, 0xF4CC12BE,
|
||||
0xC2D0B696, 0x42AF2070, 0xD0720C35, 0x3361DA8C,
|
||||
0x28CCECA4, 0x8EF8AD83, 0x4680AC00, 0x40E5FBAB,
|
||||
0xD89041C3, 0x6107FBD5, 0x6C859D41, 0xF0B26679,
|
||||
0x09392549, 0x5FA25603, 0x65C892FD, 0x93CB6285,
|
||||
0x2AF2B5AE, 0x9E4B4E60, 0x774ABFDD, 0x85254725,
|
||||
0x15815AEB, 0x4AB6AAD6, 0x9CDAF8AF, 0xD6032C0A
|
||||
};
|
||||
|
||||
#if __CUDA_ARCH__ >= 500
|
||||
x[0][0][0][0][0] ^= Hash[0].x;
|
||||
x[0][0][0][0][1] ^= Hash[0].y;
|
||||
x[0][0][0][1][0] ^= Hash[1].x;
|
||||
x[0][0][0][1][1] ^= Hash[1].y;
|
||||
x[0][0][1][0][0] ^= Hash[2].x;
|
||||
x[0][0][1][0][1] ^= Hash[2].y;
|
||||
x[0][0][1][1][0] ^= Hash[3].x;
|
||||
x[0][0][1][1][1] ^= Hash[3].y;
|
||||
#else
|
||||
x[0][0][0][0][0] ^= Hash[0];
|
||||
x[0][0][0][0][1] ^= Hash[1];
|
||||
x[0][0][0][1][0] ^= Hash[2];
|
||||
x[0][0][0][1][1] ^= Hash[3];
|
||||
x[0][0][1][0][0] ^= Hash[4];
|
||||
x[0][0][1][0][1] ^= Hash[5];
|
||||
x[0][0][1][1][0] ^= Hash[6];
|
||||
x[0][0][1][1][1] ^= Hash[7];
|
||||
#endif
|
||||
rrounds(x);
|
||||
x[0][0][0][0][0] ^= 0x80U;
|
||||
rrounds(x);
|
||||
|
||||
#if __CUDA_ARCH__ >= 500
|
||||
Final(x, (uint32_t*)Hash);
|
||||
|
||||
g_hash[thread] = Hash[0];
|
||||
g_hash[1 * threads + thread] = Hash[1];
|
||||
g_hash[2 * threads + thread] = Hash[2];
|
||||
g_hash[3 * threads + thread] = Hash[3];
|
||||
#else
|
||||
Final(x, Hash);
|
||||
|
||||
((uint64_t*)g_hash)[thread] = ((uint64_t*)Hash)[0];
|
||||
((uint64_t*)g_hash)[1 * threads + thread] = ((uint64_t*)Hash)[1];
|
||||
((uint64_t*)g_hash)[2 * threads + thread] = ((uint64_t*)Hash)[2];
|
||||
((uint64_t*)g_hash)[3 * threads + thread] = ((uint64_t*)Hash)[3];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void cubehash256_cpu_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint64_t *d_hash, int order)
|
||||
{
|
||||
uint32_t tpb = TPB35;
|
||||
if (cuda_arch[thr_id] >= 500) tpb = TPB50;
|
||||
|
||||
dim3 grid((threads + tpb - 1) / tpb);
|
||||
dim3 block(tpb);
|
||||
|
||||
cubehash256_gpu_hash_32 <<<grid, block >>> (threads, startNounce, (uint2*)d_hash);
|
||||
}
|
||||
|
||||
__host__
|
||||
void cubehash256_cpu_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint64_t *d_hash, int order, cudaStream_t stream)
|
||||
{
|
||||
uint32_t tpb = TPB35;
|
||||
if (cuda_arch[thr_id] >= 500) tpb = TPB50;
|
||||
|
||||
dim3 grid((threads + tpb - 1) / tpb);
|
||||
dim3 block(tpb);
|
||||
|
||||
cubehash256_gpu_hash_32 <<<grid, block, 0, stream >>> (threads, startNounce, (uint2*)d_hash);
|
||||
}
|
||||
+19
-29
@@ -10,15 +10,14 @@
|
||||
|
||||
uint32_t *d_fugue256_hashoutput[MAX_GPUS];
|
||||
static uint32_t *d_resultNonce[MAX_GPUS];
|
||||
static unsigned int* d_textures[MAX_GPUS][8];
|
||||
|
||||
__constant__ uint32_t GPUstate[30]; // Single GPU
|
||||
__constant__ uint32_t pTarget[8]; // Single GPU
|
||||
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> mixTab0Tex;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> mixTab1Tex;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> mixTab2Tex;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> mixTab3Tex;
|
||||
texture<unsigned int, 1, cudaReadModeElementType> mixTab0Tex;
|
||||
texture<unsigned int, 1, cudaReadModeElementType> mixTab1Tex;
|
||||
texture<unsigned int, 1, cudaReadModeElementType> mixTab2Tex;
|
||||
texture<unsigned int, 1, cudaReadModeElementType> mixTab3Tex;
|
||||
|
||||
#if USE_SHARED
|
||||
#define mixtab0(x) (*((uint32_t*)mixtabs + ( (x))))
|
||||
@@ -708,57 +707,48 @@ fugue256_gpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, void *outp
|
||||
}
|
||||
}
|
||||
|
||||
#define texDef(id, texname, texmem, texsource, texsize) { \
|
||||
#define texDef(texname, texmem, texsource, texsize) \
|
||||
unsigned int *texmem; \
|
||||
cudaMalloc(&texmem, texsize); \
|
||||
d_textures[thr_id][id] = texmem; \
|
||||
cudaMemcpy(texmem, texsource, texsize, cudaMemcpyHostToDevice); \
|
||||
texname.normalized = 0; \
|
||||
texname.filterMode = cudaFilterModePoint; \
|
||||
texname.addressMode[0] = cudaAddressModeClamp; \
|
||||
{ cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc<unsigned int>(); \
|
||||
cudaBindTexture(NULL, &texname, texmem, &channelDesc, texsize ); \
|
||||
} \
|
||||
}
|
||||
cudaBindTexture(NULL, &texname, texmem, &channelDesc, texsize ); }
|
||||
|
||||
|
||||
__host__
|
||||
void fugue256_cpu_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
// Link the hash tables in the GPU
|
||||
texDef(0, mixTab0Tex, mixTab0m, mixtab0_cpu, sizeof(uint32_t)*256);
|
||||
texDef(1, mixTab1Tex, mixTab1m, mixtab1_cpu, sizeof(uint32_t)*256);
|
||||
texDef(2, mixTab2Tex, mixTab2m, mixtab2_cpu, sizeof(uint32_t)*256);
|
||||
texDef(3, mixTab3Tex, mixTab3m, mixtab3_cpu, sizeof(uint32_t)*256);
|
||||
// Kopiere die Hash-Tabellen in den GPU-Speicher
|
||||
texDef(mixTab0Tex, mixTab0m, mixtab0_cpu, sizeof(uint32_t)*256);
|
||||
texDef(mixTab1Tex, mixTab1m, mixtab1_cpu, sizeof(uint32_t)*256);
|
||||
texDef(mixTab2Tex, mixTab2m, mixtab2_cpu, sizeof(uint32_t)*256);
|
||||
texDef(mixTab3Tex, mixTab3m, mixtab3_cpu, sizeof(uint32_t)*256);
|
||||
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_fugue256_hashoutput[thr_id], (size_t) 32 * threads));
|
||||
// Speicher für alle Ergebnisse belegen
|
||||
cudaMalloc(&d_fugue256_hashoutput[thr_id], 8 * sizeof(uint32_t) * threads);
|
||||
cudaMalloc(&d_resultNonce[thr_id], sizeof(uint32_t));
|
||||
}
|
||||
|
||||
__host__
|
||||
void fugue256_cpu_free(int thr_id)
|
||||
{
|
||||
cudaFree(d_fugue256_hashoutput[thr_id]);
|
||||
cudaFree(d_resultNonce[thr_id]);
|
||||
|
||||
for (int i=0; i<4; i++)
|
||||
cudaFree(d_textures[thr_id][i]);
|
||||
}
|
||||
|
||||
__host__
|
||||
void fugue256_cpu_setBlock(int thr_id, void *data, void *pTargetIn)
|
||||
{
|
||||
// CPU-Vorbereitungen treffen
|
||||
sph_fugue256_context ctx_fugue_const;
|
||||
sph_fugue256_init(&ctx_fugue_const);
|
||||
sph_fugue256 (&ctx_fugue_const, data, 80);
|
||||
sph_fugue256 (&ctx_fugue_const, data, 80); // State speichern
|
||||
|
||||
cudaMemcpyToSymbol(GPUstate, ctx_fugue_const.S, sizeof(uint32_t) * 30);
|
||||
|
||||
cudaMemcpyToSymbol(pTarget, pTargetIn, 32);
|
||||
cudaMemcpyToSymbol(pTarget, pTargetIn, sizeof(uint32_t) * 8);
|
||||
|
||||
cudaMemset(d_resultNonce[thr_id], 0xFF, sizeof(uint32_t));
|
||||
}
|
||||
|
||||
__host__
|
||||
void fugue256_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, void *outputHashes, uint32_t *nounce)
|
||||
void fugue256_cpu_hash(int thr_id, uint32_t threads, int startNounce, void *outputHashes, uint32_t *nounce)
|
||||
{
|
||||
#if USE_SHARED
|
||||
const uint32_t threadsperblock = 256; // Alignment mit mixtab Grösse. NICHT ÄNDERN
|
||||
|
||||
+21
-34
@@ -7,7 +7,6 @@
|
||||
|
||||
static uint32_t *h_GNonces[MAX_GPUS];
|
||||
static uint32_t *d_GNonces[MAX_GPUS];
|
||||
static unsigned int* d_textures[MAX_GPUS][8];
|
||||
|
||||
__constant__ uint32_t pTarget[8];
|
||||
|
||||
@@ -67,14 +66,14 @@ __constant__ uint32_t pTarget[8];
|
||||
#define T3dn(x) tex1Dfetch(t3dn2, x)
|
||||
#endif
|
||||
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t0up2;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t0dn2;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t1up2;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t1dn2;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t2up2;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t2dn2;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t3up2;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t3dn2;
|
||||
texture<unsigned int, 1, cudaReadModeElementType> t0up2;
|
||||
texture<unsigned int, 1, cudaReadModeElementType> t0dn2;
|
||||
texture<unsigned int, 1, cudaReadModeElementType> t1up2;
|
||||
texture<unsigned int, 1, cudaReadModeElementType> t1dn2;
|
||||
texture<unsigned int, 1, cudaReadModeElementType> t2up2;
|
||||
texture<unsigned int, 1, cudaReadModeElementType> t2dn2;
|
||||
texture<unsigned int, 1, cudaReadModeElementType> t3up2;
|
||||
texture<unsigned int, 1, cudaReadModeElementType> t3dn2;
|
||||
|
||||
#define RSTT(d0, d1, a, b0, b1, b2, b3, b4, b5, b6, b7) do { \
|
||||
t[d0] = T0up(B32_0(a[b0])) \
|
||||
@@ -176,7 +175,7 @@ void groestl256_perm_Q(uint32_t thread, uint32_t *a, char *mixtabs)
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(256,1)
|
||||
void groestl256_gpu_hash_32(uint32_t threads, uint32_t startNounce, uint64_t *outputHash, uint32_t *resNonces)
|
||||
void groestl256_gpu_hash32(uint32_t threads, uint32_t startNounce, uint64_t *outputHash, uint32_t *resNonces)
|
||||
{
|
||||
#if USE_SHARED
|
||||
extern __shared__ char mixtabs[];
|
||||
@@ -250,46 +249,34 @@ void groestl256_gpu_hash_32(uint32_t threads, uint32_t startNounce, uint64_t *ou
|
||||
}
|
||||
}
|
||||
|
||||
#define texDef(id, texname, texmem, texsource, texsize) { \
|
||||
#define texDef(texname, texmem, texsource, texsize) \
|
||||
unsigned int *texmem; \
|
||||
cudaMalloc(&texmem, texsize); \
|
||||
d_textures[thr_id][id] = texmem; \
|
||||
cudaMemcpy(texmem, texsource, texsize, cudaMemcpyHostToDevice); \
|
||||
texname.normalized = 0; \
|
||||
texname.filterMode = cudaFilterModePoint; \
|
||||
texname.addressMode[0] = cudaAddressModeClamp; \
|
||||
{ cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc<unsigned int>(); \
|
||||
cudaBindTexture(NULL, &texname, texmem, &channelDesc, texsize ); \
|
||||
} \
|
||||
}
|
||||
cudaBindTexture(NULL, &texname, texmem, &channelDesc, texsize ); } \
|
||||
|
||||
__host__
|
||||
void groestl256_cpu_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
|
||||
// Texturen mit obigem Makro initialisieren
|
||||
texDef(0, t0up2, d_T0up, T0up_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(1, t0dn2, d_T0dn, T0dn_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(2, t1up2, d_T1up, T1up_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(3, t1dn2, d_T1dn, T1dn_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(4, t2up2, d_T2up, T2up_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(5, t2dn2, d_T2dn, T2dn_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(6, t3up2, d_T3up, T3up_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(7, t3dn2, d_T3dn, T3dn_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(t0up2, d_T0up, T0up_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(t0dn2, d_T0dn, T0dn_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(t1up2, d_T1up, T1up_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(t1dn2, d_T1dn, T1dn_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(t2up2, d_T2up, T2up_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(t2dn2, d_T2dn, T2dn_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(t3up2, d_T3up, T3up_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(t3dn2, d_T3dn, T3dn_cpu, sizeof(uint32_t) * 256);
|
||||
|
||||
cudaMalloc(&d_GNonces[thr_id], 2*sizeof(uint32_t));
|
||||
cudaMallocHost(&h_GNonces[thr_id], 2*sizeof(uint32_t));
|
||||
}
|
||||
|
||||
__host__
|
||||
void groestl256_cpu_free(int thr_id)
|
||||
{
|
||||
for (int i=0; i<8; i++)
|
||||
cudaFree(d_textures[thr_id][i]);
|
||||
|
||||
cudaFree(d_GNonces[thr_id]);
|
||||
cudaFreeHost(h_GNonces[thr_id]);
|
||||
}
|
||||
|
||||
__host__
|
||||
uint32_t groestl256_cpu_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint64_t *d_outputHash, int order)
|
||||
{
|
||||
@@ -306,7 +293,7 @@ uint32_t groestl256_cpu_hash_32(int thr_id, uint32_t threads, uint32_t startNoun
|
||||
#else
|
||||
size_t shared_size = 0;
|
||||
#endif
|
||||
groestl256_gpu_hash_32<<<grid, block, shared_size>>>(threads, startNounce, d_outputHash, d_GNonces[thr_id]);
|
||||
groestl256_gpu_hash32<<<grid, block, shared_size>>>(threads, startNounce, d_outputHash, d_GNonces[thr_id]);
|
||||
|
||||
MyStreamSynchronize(NULL, order, thr_id);
|
||||
|
||||
|
||||
+255
-336
@@ -1,383 +1,302 @@
|
||||
/**
|
||||
* KECCAK-256 CUDA optimised implementation, based on ccminer-alexis code
|
||||
*/
|
||||
|
||||
#include <miner.h>
|
||||
#include "miner.h"
|
||||
|
||||
extern "C" {
|
||||
#include <stdint.h>
|
||||
#include <memory.h>
|
||||
}
|
||||
|
||||
#include <cuda_helper.h>
|
||||
#include <cuda_vectors.h>
|
||||
#include "cuda_helper.h"
|
||||
|
||||
#define TPB52 1024
|
||||
#define TPB50 384
|
||||
#define NPT 2
|
||||
#define NBN 2
|
||||
|
||||
static uint32_t *d_nonces[MAX_GPUS];
|
||||
static uint32_t *h_nonces[MAX_GPUS];
|
||||
|
||||
__constant__ uint2 c_message48[6];
|
||||
__constant__ uint2 c_mid[17];
|
||||
|
||||
__constant__ uint2 keccak_round_constants[24] = {
|
||||
{ 0x00000001, 0x00000000 }, { 0x00008082, 0x00000000 }, { 0x0000808a, 0x80000000 }, { 0x80008000, 0x80000000 },
|
||||
{ 0x0000808b, 0x00000000 }, { 0x80000001, 0x00000000 }, { 0x80008081, 0x80000000 }, { 0x00008009, 0x80000000 },
|
||||
{ 0x0000008a, 0x00000000 }, { 0x00000088, 0x00000000 }, { 0x80008009, 0x00000000 }, { 0x8000000a, 0x00000000 },
|
||||
{ 0x8000808b, 0x00000000 }, { 0x0000008b, 0x80000000 }, { 0x00008089, 0x80000000 }, { 0x00008003, 0x80000000 },
|
||||
{ 0x00008002, 0x80000000 }, { 0x00000080, 0x80000000 }, { 0x0000800a, 0x00000000 }, { 0x8000000a, 0x80000000 },
|
||||
{ 0x80008081, 0x80000000 }, { 0x00008080, 0x80000000 }, { 0x80000001, 0x00000000 }, { 0x80008008, 0x80000000 }
|
||||
static const uint64_t host_keccak_round_constants[24] = {
|
||||
0x0000000000000001ull, 0x0000000000008082ull,
|
||||
0x800000000000808aull, 0x8000000080008000ull,
|
||||
0x000000000000808bull, 0x0000000080000001ull,
|
||||
0x8000000080008081ull, 0x8000000000008009ull,
|
||||
0x000000000000008aull, 0x0000000000000088ull,
|
||||
0x0000000080008009ull, 0x000000008000000aull,
|
||||
0x000000008000808bull, 0x800000000000008bull,
|
||||
0x8000000000008089ull, 0x8000000000008003ull,
|
||||
0x8000000000008002ull, 0x8000000000000080ull,
|
||||
0x000000000000800aull, 0x800000008000000aull,
|
||||
0x8000000080008081ull, 0x8000000000008080ull,
|
||||
0x0000000080000001ull, 0x8000000080008008ull
|
||||
};
|
||||
|
||||
__device__ __forceinline__
|
||||
uint2 xor3x(const uint2 a,const uint2 b,const uint2 c) {
|
||||
uint2 result;
|
||||
#if __CUDA_ARCH__ >= 500 && CUDA_VERSION >= 7050
|
||||
asm ("lop3.b32 %0, %1, %2, %3, 0x96;" : "=r"(result.x) : "r"(a.x), "r"(b.x),"r"(c.x)); //0x96 = 0xF0 ^ 0xCC ^ 0xAA
|
||||
asm ("lop3.b32 %0, %1, %2, %3, 0x96;" : "=r"(result.y) : "r"(a.y), "r"(b.y),"r"(c.y)); //0x96 = 0xF0 ^ 0xCC ^ 0xAA
|
||||
#else
|
||||
result = a^b^c;
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
uint32_t *d_nounce[MAX_GPUS];
|
||||
uint32_t *d_KNonce[MAX_GPUS];
|
||||
|
||||
__device__ __forceinline__
|
||||
uint2 chi(const uint2 a,const uint2 b,const uint2 c) { // keccak chi
|
||||
uint2 result;
|
||||
#if __CUDA_ARCH__ >= 500 && CUDA_VERSION >= 7050
|
||||
asm ("lop3.b32 %0, %1, %2, %3, 0xD2;" : "=r"(result.x) : "r"(a.x), "r"(b.x),"r"(c.x)); //0xD2 = 0xF0 ^ ((~0xCC) & 0xAA)
|
||||
asm ("lop3.b32 %0, %1, %2, %3, 0xD2;" : "=r"(result.y) : "r"(a.y), "r"(b.y),"r"(c.y)); //0xD2 = 0xF0 ^ ((~0xCC) & 0xAA)
|
||||
#else
|
||||
result = a ^ (~b) & c;
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
__constant__ uint32_t pTarget[8];
|
||||
__constant__ uint64_t keccak_round_constants[24];
|
||||
__constant__ uint64_t c_PaddedMessage80[10]; // padded message (80 bytes + padding?)
|
||||
|
||||
#if __CUDA_ARCH__ >= 350
|
||||
__device__ __forceinline__
|
||||
uint64_t xor5(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e)
|
||||
static void keccak_blockv35(uint2 *s, const uint64_t *keccak_round_constants)
|
||||
{
|
||||
uint64_t result;
|
||||
asm("xor.b64 %0, %1, %2;" : "=l"(result) : "l"(d) ,"l"(e));
|
||||
asm("xor.b64 %0, %0, %1;" : "+l"(result) : "l"(c));
|
||||
asm("xor.b64 %0, %0, %1;" : "+l"(result) : "l"(b));
|
||||
asm("xor.b64 %0, %0, %1;" : "+l"(result) : "l"(a));
|
||||
return result;
|
||||
}
|
||||
size_t i;
|
||||
uint2 t[5], u[5], v, w;
|
||||
|
||||
#if __CUDA_ARCH__ <= 500
|
||||
__global__ __launch_bounds__(TPB50, 2)
|
||||
#else
|
||||
__global__ __launch_bounds__(TPB52, 1)
|
||||
#endif
|
||||
void keccak256_gpu_hash_80(uint32_t threads, uint32_t startNonce, uint32_t *resNounce, const uint2 highTarget)
|
||||
{
|
||||
uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
uint2 s[25], t[5], v, w, u[5];
|
||||
#if __CUDA_ARCH__ > 500
|
||||
uint64_t step = gridDim.x * blockDim.x;
|
||||
uint64_t maxNonce = startNonce + threads;
|
||||
for(uint64_t nounce = startNonce + thread; nounce<maxNonce;nounce+=step) {
|
||||
#else
|
||||
uint32_t nounce = startNonce+thread;
|
||||
if(thread<threads) {
|
||||
#endif
|
||||
s[ 9] = make_uint2(c_message48[0].x,cuda_swab32(nounce));
|
||||
s[10] = keccak_round_constants[0];
|
||||
#pragma unroll
|
||||
for (i = 0; i < 24; i++) {
|
||||
/* theta: c = a[0,i] ^ a[1,i] ^ .. a[4,i] */
|
||||
t[0] = s[0] ^ s[5] ^ s[10] ^ s[15] ^ s[20];
|
||||
t[1] = s[1] ^ s[6] ^ s[11] ^ s[16] ^ s[21];
|
||||
t[2] = s[2] ^ s[7] ^ s[12] ^ s[17] ^ s[22];
|
||||
t[3] = s[3] ^ s[8] ^ s[13] ^ s[18] ^ s[23];
|
||||
t[4] = s[4] ^ s[9] ^ s[14] ^ s[19] ^ s[24];
|
||||
|
||||
t[ 4] = c_message48[1]^s[ 9];
|
||||
/* theta: d[i] = c[i+4] ^ rotl(c[i+1],1) */
|
||||
u[ 0] = t[4] ^ c_mid[ 0];
|
||||
u[ 1] = c_mid[ 1] ^ ROL2(t[4],1);
|
||||
u[ 2] = c_mid[ 2];
|
||||
/* thetarho pi: b[..] = rotl(a[..] ^ d[...], ..)*/
|
||||
s[ 7] = ROL2(s[10]^u[0], 3);
|
||||
s[10] = c_mid[ 3];
|
||||
w = c_mid[ 4];
|
||||
s[20] = c_mid[ 5];
|
||||
s[ 6] = ROL2(s[ 9]^u[2],20);
|
||||
s[ 9] = c_mid[ 6];
|
||||
s[22] = c_mid[ 7];
|
||||
s[14] = ROL2(u[0],18);
|
||||
s[ 2] = c_mid[ 8];
|
||||
s[12] = ROL2(u[1],25);
|
||||
s[13] = c_mid[ 9];
|
||||
s[19] = ROR8(u[1]);
|
||||
s[23] = ROR2(u[0],23);
|
||||
s[15] = c_mid[10];
|
||||
s[ 4] = c_mid[11];
|
||||
s[24] = c_mid[12];
|
||||
s[21] = ROR2(c_message48[2]^u[1], 9);
|
||||
s[ 8] = c_mid[13];
|
||||
s[16] = ROR2(c_message48[3]^u[0],28);
|
||||
s[ 5] = ROL2(c_message48[4]^u[1],28);
|
||||
s[ 3] = ROL2(u[1],21);
|
||||
s[18] = c_mid[14];
|
||||
s[17] = c_mid[15];
|
||||
s[11] = c_mid[16];
|
||||
u[0] = t[4] ^ ROL2(t[1], 1);
|
||||
u[1] = t[0] ^ ROL2(t[2], 1);
|
||||
u[2] = t[1] ^ ROL2(t[3], 1);
|
||||
u[3] = t[2] ^ ROL2(t[4], 1);
|
||||
u[4] = t[3] ^ ROL2(t[0], 1);
|
||||
|
||||
/* theta: a[0,i], a[1,i], .. a[4,i] ^= d[i] */
|
||||
s[0] ^= u[0]; s[5] ^= u[0]; s[10] ^= u[0]; s[15] ^= u[0]; s[20] ^= u[0];
|
||||
s[1] ^= u[1]; s[6] ^= u[1]; s[11] ^= u[1]; s[16] ^= u[1]; s[21] ^= u[1];
|
||||
s[2] ^= u[2]; s[7] ^= u[2]; s[12] ^= u[2]; s[17] ^= u[2]; s[22] ^= u[2];
|
||||
s[3] ^= u[3]; s[8] ^= u[3]; s[13] ^= u[3]; s[18] ^= u[3]; s[23] ^= u[3];
|
||||
s[4] ^= u[4]; s[9] ^= u[4]; s[14] ^= u[4]; s[19] ^= u[4]; s[24] ^= u[4];
|
||||
|
||||
/* rho pi: b[..] = rotl(a[..], ..) */
|
||||
v = s[1];
|
||||
s[1] = ROL2(s[6], 44);
|
||||
s[6] = ROL2(s[9], 20);
|
||||
s[9] = ROL2(s[22], 61);
|
||||
s[22] = ROL2(s[14], 39);
|
||||
s[14] = ROL2(s[20], 18);
|
||||
s[20] = ROL2(s[2], 62);
|
||||
s[2] = ROL2(s[12], 43);
|
||||
s[12] = ROL2(s[13], 25);
|
||||
s[13] = ROL2(s[19], 8);
|
||||
s[19] = ROL2(s[23], 56);
|
||||
s[23] = ROL2(s[15], 41);
|
||||
s[15] = ROL2(s[4], 27);
|
||||
s[4] = ROL2(s[24], 14);
|
||||
s[24] = ROL2(s[21], 2);
|
||||
s[21] = ROL2(s[8], 55);
|
||||
s[8] = ROL2(s[16], 45);
|
||||
s[16] = ROL2(s[5], 36);
|
||||
s[5] = ROL2(s[3], 28);
|
||||
s[3] = ROL2(s[18], 21);
|
||||
s[18] = ROL2(s[17], 15);
|
||||
s[17] = ROL2(s[11], 10);
|
||||
s[11] = ROL2(s[7], 6);
|
||||
s[7] = ROL2(s[10], 3);
|
||||
s[10] = ROL2(v, 1);
|
||||
|
||||
/* chi: a[i,j] ^= ~b[i,j+1] & b[i,j+2] */
|
||||
v = c_message48[5]^u[0];
|
||||
s[ 0] = chi(v,w,s[ 2]);
|
||||
s[ 1] = chi(w,s[ 2],s[ 3]);
|
||||
s[ 2] = chi(s[ 2],s[ 3],s[ 4]);
|
||||
s[ 3] = chi(s[ 3],s[ 4],v);
|
||||
s[ 4] = chi(s[ 4],v,w);
|
||||
v = s[ 5]; w = s[ 6]; s[ 5] = chi(v,w,s[ 7]); s[ 6] = chi(w,s[ 7],s[ 8]); s[ 7] = chi(s[ 7],s[ 8],s[ 9]); s[ 8] = chi(s[ 8],s[ 9],v);s[ 9] = chi(s[ 9],v,w);
|
||||
v = s[10]; w = s[11]; s[10] = chi(v,w,s[12]); s[11] = chi(w,s[12],s[13]); s[12] = chi(s[12],s[13],s[14]); s[13] = chi(s[13],s[14],v);s[14] = chi(s[14],v,w);
|
||||
v = s[15]; w = s[16]; s[15] = chi(v,w,s[17]); s[16] = chi(w,s[17],s[18]); s[17] = chi(s[17],s[18],s[19]); s[18] = chi(s[18],s[19],v);s[19] = chi(s[19],v,w);
|
||||
v = s[20]; w = s[21]; s[20] = chi(v,w,s[22]); s[21] = chi(w,s[22],s[23]); s[22] = chi(s[22],s[23],s[24]); s[23] = chi(s[23],s[24],v);s[24] = chi(s[24],v,w);
|
||||
v = s[0]; w = s[1]; s[0] ^= (~w) & s[2]; s[1] ^= (~s[2]) & s[3]; s[2] ^= (~s[3]) & s[4]; s[3] ^= (~s[4]) & v; s[4] ^= (~v) & w;
|
||||
v = s[5]; w = s[6]; s[5] ^= (~w) & s[7]; s[6] ^= (~s[7]) & s[8]; s[7] ^= (~s[8]) & s[9]; s[8] ^= (~s[9]) & v; s[9] ^= (~v) & w;
|
||||
v = s[10]; w = s[11]; s[10] ^= (~w) & s[12]; s[11] ^= (~s[12]) & s[13]; s[12] ^= (~s[13]) & s[14]; s[13] ^= (~s[14]) & v; s[14] ^= (~v) & w;
|
||||
v = s[15]; w = s[16]; s[15] ^= (~w) & s[17]; s[16] ^= (~s[17]) & s[18]; s[17] ^= (~s[18]) & s[19]; s[18] ^= (~s[19]) & v; s[19] ^= (~v) & w;
|
||||
v = s[20]; w = s[21]; s[20] ^= (~w) & s[22]; s[21] ^= (~s[22]) & s[23]; s[22] ^= (~s[23]) & s[24]; s[23] ^= (~s[24]) & v; s[24] ^= (~v) & w;
|
||||
|
||||
/* iota: a[0,0] ^= round constant */
|
||||
s[ 0] ^=keccak_round_constants[ 0];
|
||||
|
||||
#if __CUDA_ARCH__ > 500
|
||||
#pragma unroll 22
|
||||
#else
|
||||
#pragma unroll 4
|
||||
#endif
|
||||
for (int i = 1; i < 23; i++) {
|
||||
#pragma unroll
|
||||
for(int j=0;j<5;j++) {
|
||||
t[ j] = vectorize(xor5(devectorize(s[ j]),devectorize(s[j+5]),devectorize(s[j+10]),devectorize(s[j+15]),devectorize(s[j+20])));
|
||||
}
|
||||
/*theta*/
|
||||
#pragma unroll
|
||||
for(int j=0;j<5;j++) {
|
||||
u[j] = ROL2(t[j], 1);
|
||||
}
|
||||
s[ 4] = xor3x(s[ 4], t[3], u[0]);s[ 9] = xor3x(s[ 9], t[3], u[0]);s[14] = xor3x(s[14], t[3], u[0]);s[19] = xor3x(s[19], t[3], u[0]);s[24] = xor3x(s[24], t[3], u[0]);
|
||||
s[ 0] = xor3x(s[ 0], t[4], u[1]);s[ 5] = xor3x(s[ 5], t[4], u[1]);s[10] = xor3x(s[10], t[4], u[1]);s[15] = xor3x(s[15], t[4], u[1]);s[20] = xor3x(s[20], t[4], u[1]);
|
||||
s[ 1] = xor3x(s[ 1], t[0], u[2]);s[ 6] = xor3x(s[ 6], t[0], u[2]);s[11] = xor3x(s[11], t[0], u[2]);s[16] = xor3x(s[16], t[0], u[2]);s[21] = xor3x(s[21], t[0], u[2]);
|
||||
s[ 2] = xor3x(s[ 2], t[1], u[3]);s[ 7] = xor3x(s[ 7], t[1], u[3]);s[12] = xor3x(s[12], t[1], u[3]);s[17] = xor3x(s[17], t[1], u[3]);s[22] = xor3x(s[22], t[1], u[3]);
|
||||
s[ 3] = xor3x(s[ 3], t[2], u[4]);s[ 8] = xor3x(s[ 8], t[2], u[4]);s[13] = xor3x(s[13], t[2], u[4]);s[18] = xor3x(s[18], t[2], u[4]);s[23] = xor3x(s[23], t[2], u[4]);
|
||||
/*rho pi: b[..] = rotl(a[..] ^ d[...], ..)*/
|
||||
v = s[ 1];
|
||||
s[ 1] = ROL2(s[ 6],44); s[ 6] = ROL2(s[ 9],20); s[ 9] = ROL2(s[22],61); s[22] = ROL2(s[14],39);
|
||||
s[14] = ROL2(s[20],18); s[20] = ROL2(s[ 2],62); s[ 2] = ROL2(s[12],43); s[12] = ROL2(s[13],25);
|
||||
s[13] = ROL8(s[19]); s[19] = ROR8(s[23]); s[23] = ROL2(s[15],41); s[15] = ROL2(s[ 4],27);
|
||||
s[ 4] = ROL2(s[24],14); s[24] = ROL2(s[21], 2); s[21] = ROL2(s[ 8],55); s[ 8] = ROL2(s[16],45);
|
||||
s[16] = ROL2(s[ 5],36); s[ 5] = ROL2(s[ 3],28); s[ 3] = ROL2(s[18],21); s[18] = ROL2(s[17],15);
|
||||
s[17] = ROL2(s[11],10); s[11] = ROL2(s[ 7], 6); s[ 7] = ROL2(s[10], 3); s[10] = ROL2(v, 1);
|
||||
/* chi: a[i,j] ^= ~b[i,j+1] & b[i,j+2] */
|
||||
#pragma unroll
|
||||
for(int j=0;j<25;j+=5) {
|
||||
v=s[j];w=s[j + 1];s[j] = chi(s[j],s[j+1],s[j+2]);s[j+1] = chi(s[j+1],s[j+2],s[j+3]);s[j+2]=chi(s[j+2],s[j+3],s[j+4]);s[j+3]=chi(s[j+3],s[j+4],v);s[j+4]=chi(s[j+4],v,w);
|
||||
}
|
||||
/* iota: a[0,0] ^= round constant */
|
||||
s[ 0] ^=keccak_round_constants[ i];
|
||||
}
|
||||
/* theta: c = a[0,i] ^ a[1,i] ^ .. a[4,i] */
|
||||
#pragma unroll 5
|
||||
for(int j=0;j<5;j++) {
|
||||
t[ j] = xor3x(xor3x(s[j+0],s[j+5],s[j+10]), s[j+15], s[j+20]);
|
||||
}
|
||||
s[24] = xor3x(s[24],t[3],ROL2(t[0],1));
|
||||
s[18] = xor3x(s[18],t[2],ROL2(t[4],1));
|
||||
s[ 0] = xor3x(s[ 0],t[4],ROL2(t[1],1));
|
||||
/* theta: d[i] = c[i+4] ^ rotl(c[i+1],1) */
|
||||
s[24] = ROL2(s[24],14);
|
||||
s[18] = ROL2(s[18],21);
|
||||
if (devectorize(chi(s[18],s[24],s[ 0])) <= devectorize(highTarget)) {
|
||||
// if(chi(s[18].x,s[24].x,s[0].x)<=highTarget.x) {
|
||||
// if(chi(s[18].y,s[24].y,s[0].y)<=highTarget.y) {
|
||||
const uint32_t tmp = atomicExch(&resNounce[0], nounce);
|
||||
if (tmp != UINT32_MAX)
|
||||
resNounce[1] = tmp;
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
s[0] ^= vectorize(keccak_round_constants[i]);
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t* resNonces, const uint2 highTarget)
|
||||
{
|
||||
uint32_t tpb;
|
||||
dim3 grid;
|
||||
if (device_sm[device_map[thr_id]] <= 500) {
|
||||
tpb = TPB50;
|
||||
grid.x = (threads + tpb-1)/tpb;
|
||||
} else {
|
||||
tpb = TPB52;
|
||||
grid.x = (threads + (NPT*tpb)-1)/(NPT*tpb);
|
||||
}
|
||||
const dim3 block(tpb);
|
||||
|
||||
keccak256_gpu_hash_80<<<grid, block>>>(threads, startNonce, d_nonces[thr_id], highTarget);
|
||||
// cudaThreadSynchronize();
|
||||
cudaMemcpy(h_nonces[thr_id], d_nonces[thr_id], NBN*sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
memcpy(resNonces, h_nonces[thr_id], NBN*sizeof(uint32_t));
|
||||
}
|
||||
|
||||
#if 0
|
||||
#if __CUDA_ARCH__ <= 500
|
||||
__global__ __launch_bounds__(TPB50, 2)
|
||||
#else
|
||||
__global__ __launch_bounds__(TPB52, 1)
|
||||
#endif
|
||||
void keccak256_gpu_hash_32(uint32_t threads, uint2* outputHash)
|
||||
{
|
||||
uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
uint2 s[25], t[5], v, w, u[5];
|
||||
|
||||
if(thread < threads) {
|
||||
#pragma unroll 25
|
||||
for (int i = 0; i<25; i++) {
|
||||
if (i<4) s[i] = __ldg(&outputHash[i*threads+thread]);
|
||||
else s[i] = make_uint2(0, 0);
|
||||
}
|
||||
s[4] = keccak_round_constants[ 0];
|
||||
s[16] = make_uint2(0, 0x80000000);
|
||||
#if __CUDA_ARCH__ > 500
|
||||
#pragma unroll
|
||||
#else
|
||||
#pragma unroll 4
|
||||
#endif
|
||||
for (uint32_t i = 0; i < 23; i++) {
|
||||
/*theta*/
|
||||
#pragma unroll 5
|
||||
for(int j=0; j<5; j++) {
|
||||
t[ j] = vectorize(xor5(devectorize(s[ j]),devectorize(s[j+5]),devectorize(s[j+10]),devectorize(s[j+15]),devectorize(s[j+20])));
|
||||
}
|
||||
/*theta*/
|
||||
#pragma unroll 5
|
||||
for(int j=0; j<5; j++) {
|
||||
u[j] = ROL2(t[j], 1);
|
||||
}
|
||||
s[ 4] = xor3x(s[ 4], t[3], u[0]);s[ 9] = xor3x(s[ 9], t[3], u[0]);s[14] = xor3x(s[14], t[3], u[0]);s[19] = xor3x(s[19], t[3], u[0]);s[24] = xor3x(s[24], t[3], u[0]);
|
||||
s[ 0] = xor3x(s[ 0], t[4], u[1]);s[ 5] = xor3x(s[ 5], t[4], u[1]);s[10] = xor3x(s[10], t[4], u[1]);s[15] = xor3x(s[15], t[4], u[1]);s[20] = xor3x(s[20], t[4], u[1]);
|
||||
s[ 1] = xor3x(s[ 1], t[0], u[2]);s[ 6] = xor3x(s[ 6], t[0], u[2]);s[11] = xor3x(s[11], t[0], u[2]);s[16] = xor3x(s[16], t[0], u[2]);s[21] = xor3x(s[21], t[0], u[2]);
|
||||
s[ 2] = xor3x(s[ 2], t[1], u[3]);s[ 7] = xor3x(s[ 7], t[1], u[3]);s[12] = xor3x(s[12], t[1], u[3]);s[17] = xor3x(s[17], t[1], u[3]);s[22] = xor3x(s[22], t[1], u[3]);
|
||||
s[ 3] = xor3x(s[ 3], t[2], u[4]);s[ 8] = xor3x(s[ 8], t[2], u[4]);s[13] = xor3x(s[13], t[2], u[4]);s[18] = xor3x(s[18], t[2], u[4]);s[23] = xor3x(s[23], t[2], u[4]);
|
||||
/*rho pi: b[..] = rotl(a[..] ^ d[...], ..)*/
|
||||
v = s[ 1];
|
||||
s[ 1] = ROL2(s[ 6],44); s[ 6] = ROL2(s[ 9],20); s[ 9] = ROL2(s[22],61); s[22] = ROL2(s[14],39);
|
||||
s[14] = ROL2(s[20],18); s[20] = ROL2(s[ 2],62); s[ 2] = ROL2(s[12],43); s[12] = ROL2(s[13],25);
|
||||
s[13] = ROL8(s[19]); s[19] = ROR8(s[23]); s[23] = ROL2(s[15],41); s[15] = ROL2(s[ 4],27);
|
||||
s[ 4] = ROL2(s[24],14); s[24] = ROL2(s[21], 2); s[21] = ROL2(s[ 8],55); s[ 8] = ROL2(s[16],45);
|
||||
s[16] = ROL2(s[ 5],36); s[ 5] = ROL2(s[ 3],28); s[ 3] = ROL2(s[18],21); s[18] = ROL2(s[17],15);
|
||||
s[17] = ROL2(s[11],10); s[11] = ROL2(s[ 7], 6); s[ 7] = ROL2(s[10], 3); s[10] = ROL2(v, 1);
|
||||
/* chi: a[i,j] ^= ~b[i,j+1] & b[i,j+2] */
|
||||
#pragma unroll 5
|
||||
for(int j=0; j<25; j+=5) {
|
||||
v=s[j];w=s[j + 1]; s[j] = chi(v,w,s[j+2]); s[j+1] = chi(w,s[j+2],s[j+3]); s[j+2]=chi(s[j+2],s[j+3],s[j+4]); s[j+3]=chi(s[j+3],s[j+4],v); s[j+4]=chi(s[j+4],v,w);
|
||||
}
|
||||
/* iota: a[0,0] ^= round constant */
|
||||
s[ 0] ^=keccak_round_constants[ i];
|
||||
}
|
||||
__device__ __forceinline__
|
||||
static void keccak_blockv30(uint64_t *s, const uint64_t *keccak_round_constants)
|
||||
{
|
||||
size_t i;
|
||||
uint64_t t[5], u[5], v, w;
|
||||
|
||||
/* absorb input */
|
||||
|
||||
for (i = 0; i < 24; i++) {
|
||||
/* theta: c = a[0,i] ^ a[1,i] ^ .. a[4,i] */
|
||||
#pragma unroll 5
|
||||
for(int j=0;j<5;j++) {
|
||||
t[ j] = xor3x(xor3x(s[j+0],s[j+5],s[j+10]), s[j+15], s[j+20]);
|
||||
}
|
||||
t[0] = s[0] ^ s[5] ^ s[10] ^ s[15] ^ s[20];
|
||||
t[1] = s[1] ^ s[6] ^ s[11] ^ s[16] ^ s[21];
|
||||
t[2] = s[2] ^ s[7] ^ s[12] ^ s[17] ^ s[22];
|
||||
t[3] = s[3] ^ s[8] ^ s[13] ^ s[18] ^ s[23];
|
||||
t[4] = s[4] ^ s[9] ^ s[14] ^ s[19] ^ s[24];
|
||||
|
||||
/* theta: d[i] = c[i+4] ^ rotl(c[i+1],1) */
|
||||
#pragma unroll 5
|
||||
for(int j=0;j<5;j++) {
|
||||
u[j] = ROL2(t[j],1);
|
||||
}
|
||||
/* thetarho pi: b[..] = rotl(a[..] ^ d[...], ..) //There's no need to perform theta and -store- the result since it's unique for each a[..]*/
|
||||
s[ 4] = xor3x(s[24], t[3], u[0]);
|
||||
s[ 0] = xor3x(s[ 0], t[4], u[1]);
|
||||
s[ 1] = xor3x(s[ 6], t[0], u[2]);
|
||||
s[ 2] = xor3x(s[12], t[1], u[3]);
|
||||
s[ 3] = xor3x(s[18], t[2], u[4]);
|
||||
s[ 1] = ROR2(s[ 1],20);
|
||||
s[ 2] = ROR2(s[ 2],21);
|
||||
s[ 3] = ROL2(s[ 3],21);
|
||||
s[ 4] = ROL2(s[ 4],14);
|
||||
u[0] = t[4] ^ ROTL64(t[1], 1);
|
||||
u[1] = t[0] ^ ROTL64(t[2], 1);
|
||||
u[2] = t[1] ^ ROTL64(t[3], 1);
|
||||
u[3] = t[2] ^ ROTL64(t[4], 1);
|
||||
u[4] = t[3] ^ ROTL64(t[0], 1);
|
||||
|
||||
/* theta: a[0,i], a[1,i], .. a[4,i] ^= d[i] */
|
||||
s[0] ^= u[0]; s[5] ^= u[0]; s[10] ^= u[0]; s[15] ^= u[0]; s[20] ^= u[0];
|
||||
s[1] ^= u[1]; s[6] ^= u[1]; s[11] ^= u[1]; s[16] ^= u[1]; s[21] ^= u[1];
|
||||
s[2] ^= u[2]; s[7] ^= u[2]; s[12] ^= u[2]; s[17] ^= u[2]; s[22] ^= u[2];
|
||||
s[3] ^= u[3]; s[8] ^= u[3]; s[13] ^= u[3]; s[18] ^= u[3]; s[23] ^= u[3];
|
||||
s[4] ^= u[4]; s[9] ^= u[4]; s[14] ^= u[4]; s[19] ^= u[4]; s[24] ^= u[4];
|
||||
|
||||
/* rho pi: b[..] = rotl(a[..], ..) */
|
||||
v = s[ 1];
|
||||
s[ 1] = ROTL64(s[ 6], 44);
|
||||
s[ 6] = ROTL64(s[ 9], 20);
|
||||
s[ 9] = ROTL64(s[22], 61);
|
||||
s[22] = ROTL64(s[14], 39);
|
||||
s[14] = ROTL64(s[20], 18);
|
||||
s[20] = ROTL64(s[ 2], 62);
|
||||
s[ 2] = ROTL64(s[12], 43);
|
||||
s[12] = ROTL64(s[13], 25);
|
||||
s[13] = ROTL64(s[19], 8);
|
||||
s[19] = ROTL64(s[23], 56);
|
||||
s[23] = ROTL64(s[15], 41);
|
||||
s[15] = ROTL64(s[ 4], 27);
|
||||
s[ 4] = ROTL64(s[24], 14);
|
||||
s[24] = ROTL64(s[21], 2);
|
||||
s[21] = ROTL64(s[ 8], 55);
|
||||
s[ 8] = ROTL64(s[16], 45);
|
||||
s[16] = ROTL64(s[ 5], 36);
|
||||
s[ 5] = ROTL64(s[ 3], 28);
|
||||
s[ 3] = ROTL64(s[18], 21);
|
||||
s[18] = ROTL64(s[17], 15);
|
||||
s[17] = ROTL64(s[11], 10);
|
||||
s[11] = ROTL64(s[ 7], 6);
|
||||
s[ 7] = ROTL64(s[10], 3);
|
||||
s[10] = ROTL64( v, 1);
|
||||
|
||||
/* chi: a[i,j] ^= ~b[i,j+1] & b[i,j+2] */
|
||||
outputHash[0*threads+thread] = chi(s[ 0],s[ 1],s[ 2]) ^ keccak_round_constants[23];
|
||||
outputHash[1*threads+thread] = chi(s[ 1],s[ 2],s[ 3]);
|
||||
outputHash[2*threads+thread] = chi(s[ 2],s[ 3],s[ 4]);
|
||||
outputHash[3*threads+thread] = chi(s[ 3],s[ 4],s[ 0]);
|
||||
v = s[ 0]; w = s[ 1]; s[ 0] ^= (~w) & s[ 2]; s[ 1] ^= (~s[ 2]) & s[ 3]; s[ 2] ^= (~s[ 3]) & s[ 4]; s[ 3] ^= (~s[ 4]) & v; s[ 4] ^= (~v) & w;
|
||||
v = s[ 5]; w = s[ 6]; s[ 5] ^= (~w) & s[ 7]; s[ 6] ^= (~s[ 7]) & s[ 8]; s[ 7] ^= (~s[ 8]) & s[ 9]; s[ 8] ^= (~s[ 9]) & v; s[ 9] ^= (~v) & w;
|
||||
v = s[10]; w = s[11]; s[10] ^= (~w) & s[12]; s[11] ^= (~s[12]) & s[13]; s[12] ^= (~s[13]) & s[14]; s[13] ^= (~s[14]) & v; s[14] ^= (~v) & w;
|
||||
v = s[15]; w = s[16]; s[15] ^= (~w) & s[17]; s[16] ^= (~s[17]) & s[18]; s[17] ^= (~s[18]) & s[19]; s[18] ^= (~s[19]) & v; s[19] ^= (~v) & w;
|
||||
v = s[20]; w = s[21]; s[20] ^= (~w) & s[22]; s[21] ^= (~s[22]) & s[23]; s[22] ^= (~s[23]) & s[24]; s[23] ^= (~s[24]) & v; s[24] ^= (~v) & w;
|
||||
|
||||
/* iota: a[0,0] ^= round constant */
|
||||
s[0] ^= keccak_round_constants[i];
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_cpu_hash_32(const int thr_id,const uint32_t threads, uint2* d_hash)
|
||||
{
|
||||
uint32_t tpb = TPB52;
|
||||
if (device_sm[device_map[thr_id]] == 500) tpb = TPB50;
|
||||
const dim3 grid((threads + tpb-1)/tpb);
|
||||
const dim3 block(tpb);
|
||||
|
||||
keccak256_gpu_hash_32 <<<grid, block>>> (threads, d_hash);
|
||||
}
|
||||
#endif
|
||||
|
||||
__host__
|
||||
void keccak256_setBlock_80(uint64_t *endiandata)
|
||||
__global__ __launch_bounds__(128,5)
|
||||
void keccak256_gpu_hash_80(uint32_t threads, uint32_t startNounce, void *outputHash, uint32_t *resNounce)
|
||||
{
|
||||
uint64_t midstate[17], s[25];
|
||||
uint64_t t[5], u[5];
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
uint32_t nounce = startNounce + thread;
|
||||
|
||||
s[10] = 1; //(uint64_t)make_uint2(1, 0);
|
||||
s[16] = ((uint64_t)1)<<63; //(uint64_t)make_uint2(0, 0x80000000);
|
||||
#if __CUDA_ARCH__ >= 350
|
||||
uint2 keccak_gpu_state[25];
|
||||
#pragma unroll 25
|
||||
for (int i=0; i<25; i++) {
|
||||
if (i<9) keccak_gpu_state[i] = vectorize(c_PaddedMessage80[i]);
|
||||
else keccak_gpu_state[i] = make_uint2(0, 0);
|
||||
}
|
||||
|
||||
t[0] = endiandata[0] ^ endiandata[5] ^ s[10];
|
||||
t[1] = endiandata[1] ^ endiandata[6] ^ s[16];
|
||||
t[2] = endiandata[2] ^ endiandata[7];
|
||||
t[3] = endiandata[3] ^ endiandata[8];
|
||||
keccak_gpu_state[9]= vectorize(c_PaddedMessage80[9]);
|
||||
keccak_gpu_state[9].y = cuda_swab32(nounce);
|
||||
keccak_gpu_state[10] = make_uint2(1, 0);
|
||||
keccak_gpu_state[16] = make_uint2(0, 0x80000000);
|
||||
|
||||
midstate[ 0] = ROTL64(t[1], 1); //u[0] -partial
|
||||
u[1] = t[ 0] ^ ROTL64(t[2], 1); //u[1]
|
||||
u[2] = t[ 1] ^ ROTL64(t[3], 1); //u[2]
|
||||
midstate[ 1] = t[ 2]; //u[3] -partial
|
||||
midstate[ 2] = t[ 3] ^ ROTL64(t[0], 1); //u[4]
|
||||
midstate[ 3] = ROTL64(endiandata[1]^u[1], 1); //v
|
||||
midstate[ 4] = ROTL64(endiandata[6]^u[1], 44);
|
||||
midstate[ 5] = ROTL64(endiandata[2]^u[2], 62);
|
||||
midstate[ 6] = ROTL64(u[2], 61);
|
||||
midstate[ 7] = ROTL64(midstate[2], 39);
|
||||
midstate[ 8] = ROTL64(u[2], 43);
|
||||
midstate[ 9] = ROTL64(midstate[2], 8);
|
||||
midstate[10] = ROTL64(endiandata[4]^midstate[ 2],27);
|
||||
midstate[11] = ROTL64(midstate[2], 14);
|
||||
midstate[12] = ROTL64(u[1], 2);
|
||||
midstate[13] = ROTL64(s[16] ^ u[1], 45);
|
||||
midstate[14] = ROTL64(u[2],15);
|
||||
midstate[15] = ROTL64(u[1],10);
|
||||
midstate[16] = ROTL64(endiandata[7]^u[2], 6);
|
||||
keccak_blockv35(keccak_gpu_state,keccak_round_constants);
|
||||
if (devectorize(keccak_gpu_state[3]) <= ((uint64_t*)pTarget)[3]) {resNounce[0] = nounce;}
|
||||
#else
|
||||
uint64_t keccak_gpu_state[25];
|
||||
#pragma unroll 25
|
||||
for (int i=0; i<25; i++) {
|
||||
if (i<9) keccak_gpu_state[i] = c_PaddedMessage80[i];
|
||||
else keccak_gpu_state[i] = 0;
|
||||
}
|
||||
keccak_gpu_state[9] = REPLACE_HIDWORD(c_PaddedMessage80[9], cuda_swab32(nounce));
|
||||
keccak_gpu_state[10] = 0x0000000000000001;
|
||||
keccak_gpu_state[16] = 0x8000000000000000;
|
||||
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_mid, midstate,17*sizeof(uint64_t), 0, cudaMemcpyHostToDevice));
|
||||
|
||||
// pass only what's needed
|
||||
uint64_t message48[6];
|
||||
message48[0] = endiandata[9];
|
||||
message48[1] = endiandata[4];
|
||||
message48[2] = endiandata[8];
|
||||
message48[3] = endiandata[5];
|
||||
message48[4] = endiandata[3];
|
||||
message48[5] = endiandata[0];
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_message48, message48, 6*sizeof(uint64_t), 0, cudaMemcpyHostToDevice));
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_cpu_init(int thr_id)
|
||||
{
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_nonces[thr_id], NBN*sizeof(uint32_t)));
|
||||
//CUDA_SAFE_CALL(cudaMallocHost(&h_nonces[thr_id], NBN*sizeof(uint32_t)));
|
||||
h_nonces[thr_id] = (uint32_t*) malloc(NBN * sizeof(uint32_t));
|
||||
if(h_nonces[thr_id] == NULL) {
|
||||
gpulog(LOG_ERR,thr_id,"Host memory allocation failed");
|
||||
exit(EXIT_FAILURE);
|
||||
keccak_blockv30(keccak_gpu_state, keccak_round_constants);
|
||||
if (keccak_gpu_state[3] <= ((uint64_t*)pTarget)[3]) { resNounce[0] = nounce; }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_setOutput(int thr_id)
|
||||
uint32_t keccak256_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_outputHash, int order)
|
||||
{
|
||||
CUDA_SAFE_CALL(cudaMemset(d_nonces[thr_id], 0xff, NBN*sizeof(uint32_t)));
|
||||
uint32_t result = UINT32_MAX;
|
||||
cudaMemset(d_KNonce[thr_id], 0xff, sizeof(uint32_t));
|
||||
const uint32_t threadsperblock = 128;
|
||||
|
||||
dim3 grid((threads + threadsperblock-1)/threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
size_t shared_size = 0;
|
||||
|
||||
keccak256_gpu_hash_80<<<grid, block, shared_size>>>(threads, startNounce, d_outputHash, d_KNonce[thr_id]);
|
||||
|
||||
MyStreamSynchronize(NULL, order, thr_id);
|
||||
cudaMemcpy(d_nounce[thr_id], d_KNonce[thr_id], sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
cudaThreadSynchronize();
|
||||
result = *d_nounce[thr_id];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(256,3)
|
||||
void keccak256_gpu_hash_32(uint32_t threads, uint32_t startNounce, uint64_t *outputHash)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
#if __CUDA_ARCH__ >= 350 /* tpr: to double check if faster on SM5+ */
|
||||
uint2 keccak_gpu_state[25];
|
||||
#pragma unroll 25
|
||||
for (int i = 0; i<25; i++) {
|
||||
if (i<4) keccak_gpu_state[i] = vectorize(outputHash[i*threads+thread]);
|
||||
else keccak_gpu_state[i] = make_uint2(0, 0);
|
||||
}
|
||||
keccak_gpu_state[4] = make_uint2(1, 0);
|
||||
keccak_gpu_state[16] = make_uint2(0, 0x80000000);
|
||||
keccak_blockv35(keccak_gpu_state, keccak_round_constants);
|
||||
|
||||
#pragma unroll 4
|
||||
for (int i=0; i<4; i++)
|
||||
outputHash[i*threads+thread] = devectorize(keccak_gpu_state[i]);
|
||||
#else
|
||||
uint64_t keccak_gpu_state[25];
|
||||
#pragma unroll 25
|
||||
for (int i = 0; i<25; i++) {
|
||||
if (i<4)
|
||||
keccak_gpu_state[i] = outputHash[i*threads+thread];
|
||||
else
|
||||
keccak_gpu_state[i] = 0;
|
||||
}
|
||||
keccak_gpu_state[4] = 0x0000000000000001;
|
||||
keccak_gpu_state[16] = 0x8000000000000000;
|
||||
|
||||
keccak_blockv30(keccak_gpu_state, keccak_round_constants);
|
||||
#pragma unroll 4
|
||||
for (int i = 0; i<4; i++)
|
||||
outputHash[i*threads + thread] = keccak_gpu_state[i];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_cpu_free(int thr_id)
|
||||
void keccak256_cpu_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint64_t *d_outputHash, int order)
|
||||
{
|
||||
cudaFree(d_nonces[thr_id]);
|
||||
//cudaFreeHost(h_nonces[thr_id]);
|
||||
free(h_nonces[thr_id]);
|
||||
const uint32_t threadsperblock = 256;
|
||||
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
keccak256_gpu_hash_32 <<<grid, block>>> (threads, startNounce, d_outputHash);
|
||||
MyStreamSynchronize(NULL, order, thr_id);
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_setBlock_80(void *pdata,const void *pTargetIn)
|
||||
{
|
||||
unsigned char PaddedMessage[80];
|
||||
memcpy(PaddedMessage, pdata, 80);
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(pTarget, pTargetIn, 8*sizeof(uint32_t), 0, cudaMemcpyHostToDevice));
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_PaddedMessage80, PaddedMessage, 10*sizeof(uint64_t), 0, cudaMemcpyHostToDevice));
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_cpu_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(keccak_round_constants, host_keccak_round_constants,
|
||||
sizeof(host_keccak_round_constants), 0, cudaMemcpyHostToDevice));
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_KNonce[thr_id], sizeof(uint32_t)));
|
||||
CUDA_SAFE_CALL(cudaMallocHost(&d_nounce[thr_id], 1*sizeof(uint32_t)));
|
||||
}
|
||||
@@ -1,303 +0,0 @@
|
||||
#include "miner.h"
|
||||
|
||||
extern "C" {
|
||||
#include <stdint.h>
|
||||
#include <memory.h>
|
||||
}
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
static const uint64_t host_keccak_round_constants[24] = {
|
||||
0x0000000000000001ull, 0x0000000000008082ull,
|
||||
0x800000000000808aull, 0x8000000080008000ull,
|
||||
0x000000000000808bull, 0x0000000080000001ull,
|
||||
0x8000000080008081ull, 0x8000000000008009ull,
|
||||
0x000000000000008aull, 0x0000000000000088ull,
|
||||
0x0000000080008009ull, 0x000000008000000aull,
|
||||
0x000000008000808bull, 0x800000000000008bull,
|
||||
0x8000000000008089ull, 0x8000000000008003ull,
|
||||
0x8000000000008002ull, 0x8000000000000080ull,
|
||||
0x000000000000800aull, 0x800000008000000aull,
|
||||
0x8000000080008081ull, 0x8000000000008080ull,
|
||||
0x0000000080000001ull, 0x8000000080008008ull
|
||||
};
|
||||
|
||||
static uint32_t *d_KNonce[MAX_GPUS];
|
||||
|
||||
__constant__ uint32_t pTarget[8];
|
||||
__constant__ uint64_t keccak_round_constants[24];
|
||||
__constant__ uint64_t c_PaddedMessage80[10]; // padded message (80 bytes + padding?)
|
||||
|
||||
#if __CUDA_ARCH__ >= 350
|
||||
__device__ __forceinline__
|
||||
static void keccak_blockv35(uint2 *s, const uint64_t *keccak_round_constants)
|
||||
{
|
||||
size_t i;
|
||||
uint2 t[5], u[5], v, w;
|
||||
|
||||
#pragma unroll
|
||||
for (i = 0; i < 24; i++) {
|
||||
/* theta: c = a[0,i] ^ a[1,i] ^ .. a[4,i] */
|
||||
t[0] = s[0] ^ s[5] ^ s[10] ^ s[15] ^ s[20];
|
||||
t[1] = s[1] ^ s[6] ^ s[11] ^ s[16] ^ s[21];
|
||||
t[2] = s[2] ^ s[7] ^ s[12] ^ s[17] ^ s[22];
|
||||
t[3] = s[3] ^ s[8] ^ s[13] ^ s[18] ^ s[23];
|
||||
t[4] = s[4] ^ s[9] ^ s[14] ^ s[19] ^ s[24];
|
||||
|
||||
/* theta: d[i] = c[i+4] ^ rotl(c[i+1],1) */
|
||||
u[0] = t[4] ^ ROL2(t[1], 1);
|
||||
u[1] = t[0] ^ ROL2(t[2], 1);
|
||||
u[2] = t[1] ^ ROL2(t[3], 1);
|
||||
u[3] = t[2] ^ ROL2(t[4], 1);
|
||||
u[4] = t[3] ^ ROL2(t[0], 1);
|
||||
|
||||
/* theta: a[0,i], a[1,i], .. a[4,i] ^= d[i] */
|
||||
s[0] ^= u[0]; s[5] ^= u[0]; s[10] ^= u[0]; s[15] ^= u[0]; s[20] ^= u[0];
|
||||
s[1] ^= u[1]; s[6] ^= u[1]; s[11] ^= u[1]; s[16] ^= u[1]; s[21] ^= u[1];
|
||||
s[2] ^= u[2]; s[7] ^= u[2]; s[12] ^= u[2]; s[17] ^= u[2]; s[22] ^= u[2];
|
||||
s[3] ^= u[3]; s[8] ^= u[3]; s[13] ^= u[3]; s[18] ^= u[3]; s[23] ^= u[3];
|
||||
s[4] ^= u[4]; s[9] ^= u[4]; s[14] ^= u[4]; s[19] ^= u[4]; s[24] ^= u[4];
|
||||
|
||||
/* rho pi: b[..] = rotl(a[..], ..) */
|
||||
v = s[1];
|
||||
s[1] = ROL2(s[6], 44);
|
||||
s[6] = ROL2(s[9], 20);
|
||||
s[9] = ROL2(s[22], 61);
|
||||
s[22] = ROL2(s[14], 39);
|
||||
s[14] = ROL2(s[20], 18);
|
||||
s[20] = ROL2(s[2], 62);
|
||||
s[2] = ROL2(s[12], 43);
|
||||
s[12] = ROL2(s[13], 25);
|
||||
s[13] = ROL2(s[19], 8);
|
||||
s[19] = ROL2(s[23], 56);
|
||||
s[23] = ROL2(s[15], 41);
|
||||
s[15] = ROL2(s[4], 27);
|
||||
s[4] = ROL2(s[24], 14);
|
||||
s[24] = ROL2(s[21], 2);
|
||||
s[21] = ROL2(s[8], 55);
|
||||
s[8] = ROL2(s[16], 45);
|
||||
s[16] = ROL2(s[5], 36);
|
||||
s[5] = ROL2(s[3], 28);
|
||||
s[3] = ROL2(s[18], 21);
|
||||
s[18] = ROL2(s[17], 15);
|
||||
s[17] = ROL2(s[11], 10);
|
||||
s[11] = ROL2(s[7], 6);
|
||||
s[7] = ROL2(s[10], 3);
|
||||
s[10] = ROL2(v, 1);
|
||||
|
||||
/* chi: a[i,j] ^= ~b[i,j+1] & b[i,j+2] */
|
||||
v = s[0]; w = s[1]; s[0] ^= (~w) & s[2]; s[1] ^= (~s[2]) & s[3]; s[2] ^= (~s[3]) & s[4]; s[3] ^= (~s[4]) & v; s[4] ^= (~v) & w;
|
||||
v = s[5]; w = s[6]; s[5] ^= (~w) & s[7]; s[6] ^= (~s[7]) & s[8]; s[7] ^= (~s[8]) & s[9]; s[8] ^= (~s[9]) & v; s[9] ^= (~v) & w;
|
||||
v = s[10]; w = s[11]; s[10] ^= (~w) & s[12]; s[11] ^= (~s[12]) & s[13]; s[12] ^= (~s[13]) & s[14]; s[13] ^= (~s[14]) & v; s[14] ^= (~v) & w;
|
||||
v = s[15]; w = s[16]; s[15] ^= (~w) & s[17]; s[16] ^= (~s[17]) & s[18]; s[17] ^= (~s[18]) & s[19]; s[18] ^= (~s[19]) & v; s[19] ^= (~v) & w;
|
||||
v = s[20]; w = s[21]; s[20] ^= (~w) & s[22]; s[21] ^= (~s[22]) & s[23]; s[22] ^= (~s[23]) & s[24]; s[23] ^= (~s[24]) & v; s[24] ^= (~v) & w;
|
||||
|
||||
/* iota: a[0,0] ^= round constant */
|
||||
s[0] ^= vectorize(keccak_round_constants[i]);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
__device__ __forceinline__
|
||||
static void keccak_blockv30(uint64_t *s, const uint64_t *keccak_round_constants)
|
||||
{
|
||||
size_t i;
|
||||
uint64_t t[5], u[5], v, w;
|
||||
|
||||
/* absorb input */
|
||||
|
||||
for (i = 0; i < 24; i++) {
|
||||
/* theta: c = a[0,i] ^ a[1,i] ^ .. a[4,i] */
|
||||
t[0] = s[0] ^ s[5] ^ s[10] ^ s[15] ^ s[20];
|
||||
t[1] = s[1] ^ s[6] ^ s[11] ^ s[16] ^ s[21];
|
||||
t[2] = s[2] ^ s[7] ^ s[12] ^ s[17] ^ s[22];
|
||||
t[3] = s[3] ^ s[8] ^ s[13] ^ s[18] ^ s[23];
|
||||
t[4] = s[4] ^ s[9] ^ s[14] ^ s[19] ^ s[24];
|
||||
|
||||
/* theta: d[i] = c[i+4] ^ rotl(c[i+1],1) */
|
||||
u[0] = t[4] ^ ROTL64(t[1], 1);
|
||||
u[1] = t[0] ^ ROTL64(t[2], 1);
|
||||
u[2] = t[1] ^ ROTL64(t[3], 1);
|
||||
u[3] = t[2] ^ ROTL64(t[4], 1);
|
||||
u[4] = t[3] ^ ROTL64(t[0], 1);
|
||||
|
||||
/* theta: a[0,i], a[1,i], .. a[4,i] ^= d[i] */
|
||||
s[0] ^= u[0]; s[5] ^= u[0]; s[10] ^= u[0]; s[15] ^= u[0]; s[20] ^= u[0];
|
||||
s[1] ^= u[1]; s[6] ^= u[1]; s[11] ^= u[1]; s[16] ^= u[1]; s[21] ^= u[1];
|
||||
s[2] ^= u[2]; s[7] ^= u[2]; s[12] ^= u[2]; s[17] ^= u[2]; s[22] ^= u[2];
|
||||
s[3] ^= u[3]; s[8] ^= u[3]; s[13] ^= u[3]; s[18] ^= u[3]; s[23] ^= u[3];
|
||||
s[4] ^= u[4]; s[9] ^= u[4]; s[14] ^= u[4]; s[19] ^= u[4]; s[24] ^= u[4];
|
||||
|
||||
/* rho pi: b[..] = rotl(a[..], ..) */
|
||||
v = s[ 1];
|
||||
s[ 1] = ROTL64(s[ 6], 44);
|
||||
s[ 6] = ROTL64(s[ 9], 20);
|
||||
s[ 9] = ROTL64(s[22], 61);
|
||||
s[22] = ROTL64(s[14], 39);
|
||||
s[14] = ROTL64(s[20], 18);
|
||||
s[20] = ROTL64(s[ 2], 62);
|
||||
s[ 2] = ROTL64(s[12], 43);
|
||||
s[12] = ROTL64(s[13], 25);
|
||||
s[13] = ROTL64(s[19], 8);
|
||||
s[19] = ROTL64(s[23], 56);
|
||||
s[23] = ROTL64(s[15], 41);
|
||||
s[15] = ROTL64(s[ 4], 27);
|
||||
s[ 4] = ROTL64(s[24], 14);
|
||||
s[24] = ROTL64(s[21], 2);
|
||||
s[21] = ROTL64(s[ 8], 55);
|
||||
s[ 8] = ROTL64(s[16], 45);
|
||||
s[16] = ROTL64(s[ 5], 36);
|
||||
s[ 5] = ROTL64(s[ 3], 28);
|
||||
s[ 3] = ROTL64(s[18], 21);
|
||||
s[18] = ROTL64(s[17], 15);
|
||||
s[17] = ROTL64(s[11], 10);
|
||||
s[11] = ROTL64(s[ 7], 6);
|
||||
s[ 7] = ROTL64(s[10], 3);
|
||||
s[10] = ROTL64( v, 1);
|
||||
|
||||
/* chi: a[i,j] ^= ~b[i,j+1] & b[i,j+2] */
|
||||
v = s[ 0]; w = s[ 1]; s[ 0] ^= (~w) & s[ 2]; s[ 1] ^= (~s[ 2]) & s[ 3]; s[ 2] ^= (~s[ 3]) & s[ 4]; s[ 3] ^= (~s[ 4]) & v; s[ 4] ^= (~v) & w;
|
||||
v = s[ 5]; w = s[ 6]; s[ 5] ^= (~w) & s[ 7]; s[ 6] ^= (~s[ 7]) & s[ 8]; s[ 7] ^= (~s[ 8]) & s[ 9]; s[ 8] ^= (~s[ 9]) & v; s[ 9] ^= (~v) & w;
|
||||
v = s[10]; w = s[11]; s[10] ^= (~w) & s[12]; s[11] ^= (~s[12]) & s[13]; s[12] ^= (~s[13]) & s[14]; s[13] ^= (~s[14]) & v; s[14] ^= (~v) & w;
|
||||
v = s[15]; w = s[16]; s[15] ^= (~w) & s[17]; s[16] ^= (~s[17]) & s[18]; s[17] ^= (~s[18]) & s[19]; s[18] ^= (~s[19]) & v; s[19] ^= (~v) & w;
|
||||
v = s[20]; w = s[21]; s[20] ^= (~w) & s[22]; s[21] ^= (~s[22]) & s[23]; s[22] ^= (~s[23]) & s[24]; s[23] ^= (~s[24]) & v; s[24] ^= (~v) & w;
|
||||
|
||||
/* iota: a[0,0] ^= round constant */
|
||||
s[0] ^= keccak_round_constants[i];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
__global__ __launch_bounds__(128,5)
|
||||
void keccak256_sm3_gpu_hash_80(uint32_t threads, uint32_t startNounce, uint32_t *resNounce)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
uint32_t nounce = startNounce + thread;
|
||||
|
||||
#if __CUDA_ARCH__ >= 350
|
||||
uint2 keccak_gpu_state[25];
|
||||
#pragma unroll 25
|
||||
for (int i=0; i<25; i++) {
|
||||
if (i<9) keccak_gpu_state[i] = vectorize(c_PaddedMessage80[i]);
|
||||
else keccak_gpu_state[i] = make_uint2(0, 0);
|
||||
}
|
||||
|
||||
keccak_gpu_state[9]= vectorize(c_PaddedMessage80[9]);
|
||||
keccak_gpu_state[9].y = cuda_swab32(nounce);
|
||||
keccak_gpu_state[10] = make_uint2(1, 0);
|
||||
keccak_gpu_state[16] = make_uint2(0, 0x80000000);
|
||||
|
||||
keccak_blockv35(keccak_gpu_state,keccak_round_constants);
|
||||
if (devectorize(keccak_gpu_state[3]) <= ((uint64_t*)pTarget)[3]) {resNounce[0] = nounce;}
|
||||
#else
|
||||
uint64_t keccak_gpu_state[25];
|
||||
#pragma unroll 25
|
||||
for (int i=0; i<25; i++) {
|
||||
if (i<9) keccak_gpu_state[i] = c_PaddedMessage80[i];
|
||||
else keccak_gpu_state[i] = 0;
|
||||
}
|
||||
keccak_gpu_state[9] = REPLACE_HIDWORD(c_PaddedMessage80[9], cuda_swab32(nounce));
|
||||
keccak_gpu_state[10] = 0x0000000000000001;
|
||||
keccak_gpu_state[16] = 0x8000000000000000;
|
||||
|
||||
keccak_blockv30(keccak_gpu_state, keccak_round_constants);
|
||||
if (keccak_gpu_state[3] <= ((uint64_t*)pTarget)[3]) { resNounce[0] = nounce; }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_sm3_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *resNonces, int order)
|
||||
{
|
||||
cudaMemset(d_KNonce[thr_id], 0xff, 2*sizeof(uint32_t));
|
||||
const uint32_t threadsperblock = 128;
|
||||
|
||||
dim3 grid((threads + threadsperblock-1)/threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
size_t shared_size = 0;
|
||||
|
||||
keccak256_sm3_gpu_hash_80<<<grid, block, shared_size>>>(threads, startNounce, d_KNonce[thr_id]);
|
||||
|
||||
cudaMemcpy(resNonces, d_KNonce[thr_id], 2*sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
cudaThreadSynchronize();
|
||||
}
|
||||
|
||||
#if 0
|
||||
__global__ __launch_bounds__(256,3)
|
||||
void keccak256_sm3_gpu_hash_32(uint32_t threads, uint32_t startNounce, uint64_t *outputHash)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
#if __CUDA_ARCH__ >= 350 /* tpr: to double check if faster on SM5+ */
|
||||
uint2 keccak_gpu_state[25];
|
||||
#pragma unroll 25
|
||||
for (int i = 0; i<25; i++) {
|
||||
if (i<4) keccak_gpu_state[i] = vectorize(outputHash[i*threads+thread]);
|
||||
else keccak_gpu_state[i] = make_uint2(0, 0);
|
||||
}
|
||||
keccak_gpu_state[4] = make_uint2(1, 0);
|
||||
keccak_gpu_state[16] = make_uint2(0, 0x80000000);
|
||||
keccak_blockv35(keccak_gpu_state, keccak_round_constants);
|
||||
|
||||
#pragma unroll 4
|
||||
for (int i=0; i<4; i++)
|
||||
outputHash[i*threads+thread] = devectorize(keccak_gpu_state[i]);
|
||||
#else
|
||||
uint64_t keccak_gpu_state[25];
|
||||
#pragma unroll 25
|
||||
for (int i = 0; i<25; i++) {
|
||||
if (i<4)
|
||||
keccak_gpu_state[i] = outputHash[i*threads+thread];
|
||||
else
|
||||
keccak_gpu_state[i] = 0;
|
||||
}
|
||||
keccak_gpu_state[4] = 0x0000000000000001;
|
||||
keccak_gpu_state[16] = 0x8000000000000000;
|
||||
|
||||
keccak_blockv30(keccak_gpu_state, keccak_round_constants);
|
||||
#pragma unroll 4
|
||||
for (int i = 0; i<4; i++)
|
||||
outputHash[i*threads + thread] = keccak_gpu_state[i];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_sm3_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint64_t *d_outputHash, int order)
|
||||
{
|
||||
const uint32_t threadsperblock = 256;
|
||||
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
keccak256_sm3_gpu_hash_32 <<<grid, block>>> (threads, startNounce, d_outputHash);
|
||||
MyStreamSynchronize(NULL, order, thr_id);
|
||||
}
|
||||
#endif
|
||||
|
||||
__host__
|
||||
void keccak256_sm3_setBlock_80(void *pdata,const void *pTargetIn)
|
||||
{
|
||||
unsigned char PaddedMessage[80];
|
||||
memcpy(PaddedMessage, pdata, 80);
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(pTarget, pTargetIn, 8*sizeof(uint32_t), 0, cudaMemcpyHostToDevice));
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_PaddedMessage80, PaddedMessage, 10*sizeof(uint64_t), 0, cudaMemcpyHostToDevice));
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_sm3_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(keccak_round_constants, host_keccak_round_constants,
|
||||
sizeof(host_keccak_round_constants), 0, cudaMemcpyHostToDevice));
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_KNonce[thr_id], 2*sizeof(uint32_t)));
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_sm3_free(int thr_id)
|
||||
{
|
||||
cudaFree(d_KNonce[thr_id]);
|
||||
}
|
||||
+186
-183
@@ -2,109 +2,120 @@
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
static __constant__ uint64_t SKEIN_IV512_256[8] = {
|
||||
0xCCD044A12FDB3E13, 0xE83590301A79A9EB,
|
||||
0x55AEA0614F816E6F, 0x2A2767A4AE9B94DB,
|
||||
0xEC06025E74DD7683, 0xE7A436CDC4746251,
|
||||
0xC36FBAF9393AD185, 0x3EEDBA1833EDFC13
|
||||
};
|
||||
|
||||
static __constant__ uint2 vSKEIN_IV512_256[8] = {
|
||||
{ 0x2FDB3E13, 0xCCD044A1 },
|
||||
{ 0x1A79A9EB, 0xE8359030 },
|
||||
{ 0x4F816E6F, 0x55AEA061 },
|
||||
{ 0xAE9B94DB, 0x2A2767A4 },
|
||||
{ 0x74DD7683, 0xEC06025E },
|
||||
{ 0xC4746251, 0xE7A436CD },
|
||||
{ 0x393AD185, 0xC36FBAF9 },
|
||||
{ 0x33EDFC13, 0x3EEDBA18 }
|
||||
};
|
||||
|
||||
static __constant__ int ROT256[8][4] =
|
||||
{
|
||||
46,36, 19, 37,
|
||||
33,27, 14, 42,
|
||||
17,49, 36, 39,
|
||||
44, 9, 54, 56,
|
||||
39,30, 34, 24,
|
||||
13,50, 10, 17,
|
||||
25,29, 39, 43,
|
||||
8, 35, 56, 22,
|
||||
};
|
||||
|
||||
static __constant__ uint2 skein_ks_parity = { 0xA9FC1A22,0x1BD11BDA};
|
||||
static __constant__ uint64_t skein_ks_parity64 = 0x1BD11BDAA9FC1A22ull;
|
||||
|
||||
static __constant__ uint2 t12[6] = {
|
||||
{ 0x20, 0 },
|
||||
{ 0, 0xf0000000 },
|
||||
{ 0x20, 0xf0000000 },
|
||||
{ 0x08, 0 },
|
||||
{ 0, 0xff000000 },
|
||||
{ 0x08, 0xff000000 }
|
||||
};
|
||||
|
||||
static __constant__ uint64_t t12_30[6] = {
|
||||
0x20,
|
||||
0xf000000000000000,
|
||||
0xf000000000000020,
|
||||
0x08,
|
||||
0xff00000000000000,
|
||||
0xff00000000000008
|
||||
};
|
||||
|
||||
static __forceinline__ __device__
|
||||
void Round512v35(uint2 &p0, uint2 &p1, uint2 &p2, uint2 &p3, uint2 &p4, uint2 &p5, uint2 &p6, uint2 &p7,
|
||||
const int ROT0, const int ROT1, const int ROT2, const int ROT3)
|
||||
void Round512v35(uint2 &p0, uint2 &p1, uint2 &p2, uint2 &p3, uint2 &p4, uint2 &p5, uint2 &p6, uint2 &p7, int ROT)
|
||||
{
|
||||
p0 += p1; p1 = ROL2(p1, ROT0) ^ p0;
|
||||
p2 += p3; p3 = ROL2(p3, ROT1) ^ p2;
|
||||
p4 += p5; p5 = ROL2(p5, ROT2) ^ p4;
|
||||
p6 += p7; p7 = ROL2(p7, ROT3) ^ p6;
|
||||
p0 += p1; p1 = ROL2(p1, ROT256[ROT][0]); p1 ^= p0;
|
||||
p2 += p3; p3 = ROL2(p3, ROT256[ROT][1]); p3 ^= p2;
|
||||
p4 += p5; p5 = ROL2(p5, ROT256[ROT][2]); p5 ^= p4;
|
||||
p6 += p7; p7 = ROL2(p7, ROT256[ROT][3]); p7 ^= p6;
|
||||
}
|
||||
|
||||
__forceinline__ __device__
|
||||
void Round_8_512v35(const uint2 *const __restrict__ ks, const uint2 *const __restrict__ ts,
|
||||
uint2 &p0, uint2 &p1, uint2 &p2, uint2 &p3, uint2 &p4, uint2 &p5, uint2 &p6, uint2 &p7, int R)
|
||||
|
||||
static __forceinline__ __device__
|
||||
void Round_8_512v35(uint2 *ks, uint2 *ts,
|
||||
uint2 &p0, uint2 &p1, uint2 &p2, uint2 &p3,
|
||||
uint2 &p4, uint2 &p5, uint2 &p6, uint2 &p7, int R)
|
||||
{
|
||||
Round512v35(p0, p1, p2, p3, p4, p5, p6, p7, 46, 36, 19, 37);
|
||||
Round512v35(p2, p1, p4, p7, p6, p5, p0, p3, 33, 27, 14, 42);
|
||||
Round512v35(p4, p1, p6, p3, p0, p5, p2, p7, 17, 49, 36, 39);
|
||||
Round512v35(p6, p1, p0, p7, p2, p5, p4, p3, 44, 9, 54, 56);
|
||||
|
||||
p0 += ks[(R+0) % 9];
|
||||
p1 += ks[(R+1) % 9];
|
||||
p2 += ks[(R+2) % 9];
|
||||
p3 += ks[(R+3) % 9];
|
||||
p4 += ks[(R+4) % 9];
|
||||
p5 += ks[(R+5) % 9] + ts[(R+0) % 3];
|
||||
p6 += ks[(R+6) % 9] + ts[(R+1) % 3];
|
||||
p7 += ks[(R+7) % 9] + make_uint2(R, 0);
|
||||
|
||||
Round512v35(p0, p1, p2, p3, p4, p5, p6, p7, 39, 30, 34, 24);
|
||||
Round512v35(p2, p1, p4, p7, p6, p5, p0, p3, 13, 50, 10, 17);
|
||||
Round512v35(p4, p1, p6, p3, p0, p5, p2, p7, 25, 29, 39, 43);
|
||||
Round512v35(p6, p1, p0, p7, p2, p5, p4, p3, 8, 35, 56, 22);
|
||||
|
||||
p0 += ks[(R+1) % 9];
|
||||
p1 += ks[(R+2) % 9];
|
||||
p2 += ks[(R+3) % 9];
|
||||
p3 += ks[(R+4) % 9];
|
||||
p4 += ks[(R+5) % 9];
|
||||
p5 += ks[(R+6) % 9] + ts[(R+1) % 3];
|
||||
p6 += ks[(R+7) % 9] + ts[(R+2) % 3];
|
||||
p7 += ks[(R+8) % 9] + make_uint2(R+1, 0);
|
||||
Round512v35(p0, p1, p2, p3, p4, p5, p6, p7, 0);
|
||||
Round512v35(p2, p1, p4, p7, p6, p5, p0, p3, 1);
|
||||
Round512v35(p4, p1, p6, p3, p0, p5, p2, p7, 2);
|
||||
Round512v35(p6, p1, p0, p7, p2, p5, p4, p3, 3);
|
||||
p0 += ks[((R)+0) % 9]; /* inject the key schedule value */
|
||||
p1 += ks[((R)+1) % 9];
|
||||
p2 += ks[((R)+2) % 9];
|
||||
p3 += ks[((R)+3) % 9];
|
||||
p4 += ks[((R)+4) % 9];
|
||||
p5 += ks[((R)+5) % 9] + ts[((R)+0) % 3];
|
||||
p6 += ks[((R)+6) % 9] + ts[((R)+1) % 3];
|
||||
p7 += ks[((R)+7) % 9] + make_uint2((R),0);
|
||||
Round512v35(p0, p1, p2, p3, p4, p5, p6, p7, 4);
|
||||
Round512v35(p2, p1, p4, p7, p6, p5, p0, p3, 5);
|
||||
Round512v35(p4, p1, p6, p3, p0, p5, p2, p7, 6);
|
||||
Round512v35(p6, p1, p0, p7, p2, p5, p4, p3, 7);
|
||||
p0 += ks[((R)+1) % 9]; /* inject the key schedule value */
|
||||
p1 += ks[((R)+2) % 9];
|
||||
p2 += ks[((R)+3) % 9];
|
||||
p3 += ks[((R)+4) % 9];
|
||||
p4 += ks[((R)+5) % 9];
|
||||
p5 += ks[((R)+6) % 9] + ts[((R)+1) % 3];
|
||||
p6 += ks[((R)+7) % 9] + ts[((R)+2) % 3];
|
||||
p7 += ks[((R)+8) % 9] + make_uint2((R)+1, 0);
|
||||
}
|
||||
|
||||
__forceinline__ __device__
|
||||
void Round_8_512v35_final(const uint2 *const __restrict__ ks, const uint2 *const __restrict__ ts,
|
||||
uint2 &p0, uint2 &p1, uint2 &p2, uint2 &p3, uint2 &p4, uint2 &p5, uint2 &p6, uint2 &p7)
|
||||
{
|
||||
Round512v35(p0, p1, p2, p3, p4, p5, p6, p7, 46, 36, 19, 37);
|
||||
Round512v35(p2, p1, p4, p7, p6, p5, p0, p3, 33, 27, 14, 42);
|
||||
Round512v35(p4, p1, p6, p3, p0, p5, p2, p7, 17, 49, 36, 39);
|
||||
Round512v35(p6, p1, p0, p7, p2, p5, p4, p3, 44, 9, 54, 56);
|
||||
|
||||
p0 += ks[8];
|
||||
p1 += ks[0];
|
||||
p2 += ks[1];
|
||||
p3 += ks[2];
|
||||
p4 += ks[3];
|
||||
p5 += ks[4] + ts[2];
|
||||
p6 += ks[5] + ts[0];
|
||||
p7 += ks[6] + make_uint2(17, 0);
|
||||
|
||||
Round512v35(p0, p1, p2, p3, p4, p5, p6, p7, 39, 30, 34, 24);
|
||||
Round512v35(p2, p1, p4, p7, p6, p5, p0, p3, 13, 50, 10, 17);
|
||||
Round512v35(p4, p1, p6, p3, p0, p5, p2, p7, 25, 29, 39, 43);
|
||||
Round512v35(p6, p1, p0, p7, p2, p5, p4, p3, 8, 35, 56, 22);
|
||||
|
||||
p0 += ks[0];
|
||||
p1 += ks[1];
|
||||
p2 += ks[2];
|
||||
p3 += ks[3];
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(256,3)
|
||||
void skein256_gpu_hash_32(uint32_t threads, uint32_t startNounce, uint64_t *outputHash)
|
||||
{
|
||||
const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
const uint2 skein_ks_parity = { 0xA9FC1A22, 0x1BD11BDA };
|
||||
const uint2 t12[6] = {
|
||||
{ 0x20, 0 },
|
||||
{ 0, 0xf0000000 },
|
||||
{ 0x20, 0xf0000000 },
|
||||
{ 0x08, 0 },
|
||||
{ 0, 0xff000000 },
|
||||
{ 0x08, 0xff000000 }
|
||||
};
|
||||
|
||||
uint2 h[9] = {
|
||||
{ 0x2FDB3E13, 0xCCD044A1 },
|
||||
{ 0x1A79A9EB, 0xE8359030 },
|
||||
{ 0x4F816E6F, 0x55AEA061 },
|
||||
{ 0xAE9B94DB, 0x2A2767A4 },
|
||||
{ 0x74DD7683, 0xEC06025E },
|
||||
{ 0xC4746251, 0xE7A436CD },
|
||||
{ 0x393AD185, 0xC36FBAF9 },
|
||||
{ 0x33EDFC13, 0x3EEDBA18 },
|
||||
{ 0xC73A4E2A, 0xB69D3CFC }
|
||||
};
|
||||
uint2 h[9];
|
||||
uint2 t[3];
|
||||
uint2 dt0,dt1,dt2,dt3;
|
||||
uint2 p0, p1, p2, p3, p4, p5, p6, p7;
|
||||
|
||||
h[8] = skein_ks_parity;
|
||||
for (int i = 0; i<8; i++) {
|
||||
h[i] = vSKEIN_IV512_256[i];
|
||||
h[8] ^= h[i];
|
||||
}
|
||||
|
||||
t[0]=t12[0];
|
||||
t[1]=t12[1];
|
||||
t[2]=t12[2];
|
||||
|
||||
LOHI(dt0.x,dt0.y,outputHash[thread]);
|
||||
LOHI(dt1.x,dt1.y,outputHash[threads+thread]);
|
||||
LOHI(dt2.x,dt2.y,outputHash[2*threads+thread]);
|
||||
@@ -115,20 +126,14 @@ void skein256_gpu_hash_32(uint32_t threads, uint32_t startNounce, uint64_t *outp
|
||||
p2 = h[2] + dt2;
|
||||
p3 = h[3] + dt3;
|
||||
p4 = h[4];
|
||||
p5 = h[5] + t12[0];
|
||||
p6 = h[6] + t12[1];
|
||||
p5 = h[5] + t[0];
|
||||
p6 = h[6] + t[1];
|
||||
p7 = h[7];
|
||||
|
||||
// forced unroll required
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 1);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 3);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 5);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 7);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 9);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 11);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 13);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 15);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 17);
|
||||
#pragma unroll
|
||||
for (int i = 1; i<19; i+=2) {
|
||||
Round_8_512v35(h,t,p0,p1,p2,p3,p4,p5,p6,p7,i);
|
||||
}
|
||||
|
||||
p0 ^= dt0;
|
||||
p1 ^= dt1;
|
||||
@@ -143,22 +148,23 @@ void skein256_gpu_hash_32(uint32_t threads, uint32_t startNounce, uint64_t *outp
|
||||
h[5] = p5;
|
||||
h[6] = p6;
|
||||
h[7] = p7;
|
||||
h[8] = skein_ks_parity ^ h[0] ^ h[1] ^ h[2] ^ h[3] ^ h[4] ^ h[5] ^ h[6] ^ h[7];
|
||||
h[8] = skein_ks_parity;
|
||||
|
||||
const uint2 *t = t12+3;
|
||||
p5 += t12[3]; //p5 already equal h[5]
|
||||
p6 += t12[4];
|
||||
#pragma unroll 8
|
||||
for (int i = 0; i<8; i++) {
|
||||
h[8] ^= h[i];
|
||||
}
|
||||
|
||||
// forced unroll
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 1);
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 3);
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 5);
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 7);
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 9);
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 11);
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 13);
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 15);
|
||||
Round_8_512v35_final(h, t, p0, p1, p2, p3, p4, p5, p6, p7);
|
||||
t[0] = t12[3];
|
||||
t[1] = t12[4];
|
||||
t[2] = t12[5];
|
||||
p5 += t[0]; //p5 already equal h[5]
|
||||
p6 += t[1];
|
||||
|
||||
#pragma unroll
|
||||
for (int i = 1; i<19; i+=2) {
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, i);
|
||||
}
|
||||
|
||||
outputHash[thread] = devectorize(p0);
|
||||
outputHash[threads+thread] = devectorize(p1);
|
||||
@@ -169,81 +175,79 @@ void skein256_gpu_hash_32(uint32_t threads, uint32_t startNounce, uint64_t *outp
|
||||
|
||||
static __forceinline__ __device__
|
||||
void Round512v30(uint64_t &p0, uint64_t &p1, uint64_t &p2, uint64_t &p3,
|
||||
uint64_t &p4, uint64_t &p5, uint64_t &p6, uint64_t &p7,
|
||||
const int ROT0, const int ROT1, const int ROT2, const int ROT3)
|
||||
uint64_t &p4, uint64_t &p5, uint64_t &p6, uint64_t &p7, int ROT)
|
||||
{
|
||||
p0 += p1; p1 = ROTL64(p1, ROT0) ^ p0;
|
||||
p2 += p3; p3 = ROTL64(p3, ROT1) ^ p2;
|
||||
p4 += p5; p5 = ROTL64(p5, ROT2) ^ p4;
|
||||
p6 += p7; p7 = ROTL64(p7, ROT3) ^ p6;
|
||||
p0 += p1; p1 = ROTL64(p1, ROT256[ROT][0]); p1 ^= p0;
|
||||
p2 += p3; p3 = ROTL64(p3, ROT256[ROT][1]); p3 ^= p2;
|
||||
p4 += p5; p5 = ROTL64(p5, ROT256[ROT][2]); p5 ^= p4;
|
||||
p6 += p7; p7 = ROTL64(p7, ROT256[ROT][3]); p7 ^= p6;
|
||||
}
|
||||
|
||||
static __forceinline__ __device__
|
||||
void Round_8_512v30(uint64_t *ks, uint64_t *ts,
|
||||
uint64_t &p0, uint64_t &p1, uint64_t &p2, uint64_t &p3,
|
||||
void Round_8_512v30(uint64_t *ks, uint64_t *ts, uint64_t &p0, uint64_t &p1, uint64_t &p2, uint64_t &p3,
|
||||
uint64_t &p4, uint64_t &p5, uint64_t &p6, uint64_t &p7, int R)
|
||||
{
|
||||
Round512v30(p0, p1, p2, p3, p4, p5, p6, p7, 46, 36, 19, 37);
|
||||
Round512v30(p2, p1, p4, p7, p6, p5, p0, p3, 33, 27, 14, 42);
|
||||
Round512v30(p4, p1, p6, p3, p0, p5, p2, p7, 17, 49, 36, 39);
|
||||
Round512v30(p6, p1, p0, p7, p2, p5, p4, p3, 44, 9, 54, 56);
|
||||
|
||||
p0 += ks[(R+0) % 9];
|
||||
p1 += ks[(R+1) % 9];
|
||||
p2 += ks[(R+2) % 9];
|
||||
p3 += ks[(R+3) % 9];
|
||||
p4 += ks[(R+4) % 9];
|
||||
p5 += ks[(R+5) % 9] + ts[(R+0) % 3];
|
||||
p6 += ks[(R+6) % 9] + ts[(R+1) % 3];
|
||||
p7 += ks[(R+7) % 9] + R;
|
||||
|
||||
Round512v30(p0, p1, p2, p3, p4, p5, p6, p7, 39, 30, 34, 24);
|
||||
Round512v30(p2, p1, p4, p7, p6, p5, p0, p3, 13, 50, 10, 17);
|
||||
Round512v30(p4, p1, p6, p3, p0, p5, p2, p7, 25, 29, 39, 43);
|
||||
Round512v30(p6, p1, p0, p7, p2, p5, p4, p3, 8, 35, 56, 22);
|
||||
|
||||
p0 += ks[(R+1) % 9];
|
||||
p1 += ks[(R+2) % 9];
|
||||
p2 += ks[(R+3) % 9];
|
||||
p3 += ks[(R+4) % 9];
|
||||
p4 += ks[(R+5) % 9];
|
||||
p5 += ks[(R+6) % 9] + ts[(R+1) % 3];
|
||||
p6 += ks[(R+7) % 9] + ts[(R+2) % 3];
|
||||
p7 += ks[(R+8) % 9] + R+1;
|
||||
Round512v30(p0, p1, p2, p3, p4, p5, p6, p7, 0);
|
||||
Round512v30(p2, p1, p4, p7, p6, p5, p0, p3, 1);
|
||||
Round512v30(p4, p1, p6, p3, p0, p5, p2, p7, 2);
|
||||
Round512v30(p6, p1, p0, p7, p2, p5, p4, p3, 3);
|
||||
p0 += ks[((R)+0) % 9]; /* inject the key schedule value */
|
||||
p1 += ks[((R)+1) % 9];
|
||||
p2 += ks[((R)+2) % 9];
|
||||
p3 += ks[((R)+3) % 9];
|
||||
p4 += ks[((R)+4) % 9];
|
||||
p5 += ks[((R)+5) % 9] + ts[((R)+0) % 3];
|
||||
p6 += ks[((R)+6) % 9] + ts[((R)+1) % 3];
|
||||
p7 += ks[((R)+7) % 9] + R;
|
||||
Round512v30(p0, p1, p2, p3, p4, p5, p6, p7, 4);
|
||||
Round512v30(p2, p1, p4, p7, p6, p5, p0, p3, 5);
|
||||
Round512v30(p4, p1, p6, p3, p0, p5, p2, p7, 6);
|
||||
Round512v30(p6, p1, p0, p7, p2, p5, p4, p3, 7);
|
||||
p0 += ks[((R)+1) % 9]; /* inject the key schedule value */
|
||||
p1 += ks[((R)+2) % 9];
|
||||
p2 += ks[((R)+3) % 9];
|
||||
p3 += ks[((R)+4) % 9];
|
||||
p4 += ks[((R)+5) % 9];
|
||||
p5 += ks[((R)+6) % 9] + ts[((R)+1) % 3];
|
||||
p6 += ks[((R)+7) % 9] + ts[((R)+2) % 3];
|
||||
p7 += ks[((R)+8) % 9] + (R)+1;
|
||||
}
|
||||
|
||||
#define skein_ks_parity64 0x1BD11BDAA9FC1A22ull
|
||||
#include <stdio.h>
|
||||
__global__ __launch_bounds__(256, 3)
|
||||
void skein256_gpu_hash_32_v30(uint32_t threads, uint32_t startNounce, uint64_t *outputHash)
|
||||
{
|
||||
const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
uint64_t h[12] = { // SKEIN_IV512_256
|
||||
0xCCD044A12FDB3E13, 0xE83590301A79A9EB,
|
||||
0x55AEA0614F816E6F, 0x2A2767A4AE9B94DB,
|
||||
0xEC06025E74DD7683, 0xE7A436CDC4746251,
|
||||
0xC36FBAF9393AD185, 0x3EEDBA1833EDFC13,
|
||||
0xb69d3cfcc73a4e2a, // skein_ks_parity64 ^ h[0..7]
|
||||
0x20, 0xf000000000000000, 0xf000000000000020 // t0..2
|
||||
};
|
||||
uint64_t dt0 = outputHash[thread];
|
||||
uint64_t dt1 = outputHash[threads + thread];
|
||||
uint64_t dt2 = outputHash[threads*2 + thread];
|
||||
uint64_t dt3 = outputHash[threads*3 + thread];
|
||||
uint64_t h[9];
|
||||
uint64_t t[3];
|
||||
uint64_t dt0, dt1, dt2, dt3;
|
||||
uint64_t p0, p1, p2, p3, p4, p5, p6, p7;
|
||||
h[8] = skein_ks_parity64;
|
||||
for (int i = 0; i<8; i++) {
|
||||
h[i] = SKEIN_IV512_256[i];
|
||||
h[8] ^= h[i];
|
||||
}
|
||||
|
||||
uint64_t *t = &h[9];
|
||||
uint64_t p0 = h[0] + dt0;
|
||||
uint64_t p1 = h[1] + dt1;
|
||||
uint64_t p2 = h[2] + dt2;
|
||||
uint64_t p3 = h[3] + dt3;
|
||||
uint64_t p4 = h[4];
|
||||
uint64_t p5 = h[5] + t[0];
|
||||
uint64_t p6 = h[6] + t[1];
|
||||
uint64_t p7 = h[7];
|
||||
t[0] = devectorize(t12[0]);
|
||||
t[1] = devectorize(t12[1]);
|
||||
t[2] = devectorize(t12[2]);
|
||||
|
||||
#pragma unroll 9
|
||||
dt0 = outputHash[thread];
|
||||
dt1 = outputHash[threads+thread];
|
||||
dt2 = outputHash[2*threads+thread];
|
||||
dt3 = outputHash[3*threads+thread];
|
||||
|
||||
p0 = h[0] + dt0;
|
||||
p1 = h[1] + dt1;
|
||||
p2 = h[2] + dt2;
|
||||
p3 = h[3] + dt3;
|
||||
p4 = h[4];
|
||||
p5 = h[5] + t[0];
|
||||
p6 = h[6] + t[1];
|
||||
p7 = h[7];
|
||||
|
||||
#pragma unroll
|
||||
for (int i = 1; i<19; i += 2) {
|
||||
Round_8_512v30(h, t, p0, p1, p2, p3, p4, p5, p6, p7, i);
|
||||
}
|
||||
@@ -268,22 +272,23 @@ void skein256_gpu_hash_32_v30(uint32_t threads, uint32_t startNounce, uint64_t *
|
||||
h[8] ^= h[i];
|
||||
}
|
||||
|
||||
t[0] = 0x08;
|
||||
t[1] = 0xff00000000000000;
|
||||
t[2] = 0xff00000000000008;
|
||||
t[0] = t12_30[3];
|
||||
t[1] = t12_30[4];
|
||||
t[2] = t12_30[5];
|
||||
|
||||
p5 += t[0]; //p5 already equal h[5]
|
||||
p6 += t[1];
|
||||
|
||||
#pragma unroll 9
|
||||
#pragma unroll
|
||||
for (int i = 1; i<19; i += 2) {
|
||||
Round_8_512v30(h, t, p0, p1, p2, p3, p4, p5, p6, p7, i);
|
||||
}
|
||||
|
||||
outputHash[thread] = p0;
|
||||
outputHash[threads + thread] = p1;
|
||||
outputHash[threads*2 + thread] = p2;
|
||||
outputHash[threads*3 + thread] = p3;
|
||||
outputHash[threads + thread] = p1;
|
||||
outputHash[2 * threads + thread] = p2;
|
||||
outputHash[3 * threads + thread] = p3;
|
||||
|
||||
} //thread
|
||||
}
|
||||
|
||||
@@ -297,13 +302,11 @@ __host__
|
||||
void skein256_cpu_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint64_t *d_outputHash, int order)
|
||||
{
|
||||
const uint32_t threadsperblock = 256;
|
||||
int dev_id = device_map[thr_id];
|
||||
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
// only 1kH/s perf change between kernels on a 960...
|
||||
if (device_sm[dev_id] > 300 && cuda_arch[dev_id] > 300)
|
||||
if (device_sm[device_map[thr_id]] > 300 && cuda_arch[device_map[thr_id]] > 300)
|
||||
skein256_gpu_hash_32<<<grid, block>>>(threads, startNounce, d_outputHash);
|
||||
else
|
||||
skein256_gpu_hash_32_v30<<<grid, block>>>(threads, startNounce, d_outputHash);
|
||||
|
||||
@@ -1,475 +0,0 @@
|
||||
/**
|
||||
* Blake-256 Decred 180-Bytes input Cuda Kernel
|
||||
*
|
||||
* Tanguy Pruvot, Alexis Provos - Feb/Sep 2016
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <memory.h>
|
||||
#include <miner.h>
|
||||
|
||||
extern "C" {
|
||||
#include <sph/sph_blake.h>
|
||||
}
|
||||
|
||||
/* threads per block */
|
||||
#define TPB 640
|
||||
|
||||
/* max count of found nonces in one call (like sgminer) */
|
||||
#define MAX_RESULTS 4
|
||||
|
||||
/* hash by cpu with blake 256 */
|
||||
extern "C" void decred_hash(void *output, const void *input)
|
||||
{
|
||||
sph_blake256_context ctx;
|
||||
|
||||
sph_blake256_set_rounds(14);
|
||||
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, input, 180);
|
||||
sph_blake256_close(&ctx, output);
|
||||
}
|
||||
|
||||
#include <cuda_helper.h>
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
#define __byte_perm(x, y, b) x
|
||||
#define atomicInc(p, max) (*p)++
|
||||
#endif
|
||||
|
||||
__constant__ uint32_t _ALIGN(16) c_h[2];
|
||||
__constant__ uint32_t _ALIGN(16) c_data[32];
|
||||
__constant__ uint32_t _ALIGN(16) c_xors[215];
|
||||
|
||||
/* Buffers of candidate nonce(s) */
|
||||
static uint32_t *d_resNonce[MAX_GPUS];
|
||||
static uint32_t *h_resNonce[MAX_GPUS];
|
||||
|
||||
#define ROR8(a) __byte_perm(a, 0, 0x0321)
|
||||
#define ROL16(a) __byte_perm(a, 0, 0x1032)
|
||||
|
||||
/* macro bodies */
|
||||
#define pxorGS(a,b,c,d) { \
|
||||
v[a]+= c_xors[i++] + v[b]; \
|
||||
v[d] = ROL16(v[d] ^ v[a]); \
|
||||
v[c]+= v[d]; \
|
||||
v[b] = ROTR32(v[b] ^ v[c], 12); \
|
||||
v[a]+= c_xors[i++] + v[b]; \
|
||||
v[d] = ROR8(v[d] ^ v[a]); \
|
||||
v[c]+= v[d]; \
|
||||
v[b] = ROTR32(v[b] ^ v[c], 7); \
|
||||
}
|
||||
|
||||
#define pxorGS2(a,b,c,d, a1,b1,c1,d1) {\
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROL16(v[ d] ^ v[ a]); v[d1] = ROL16(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROR8(v[ d] ^ v[ a]); v[d1] = ROR8(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
}
|
||||
|
||||
#define pxory1GS2(a,b,c,d, a1,b1,c1,d1) { \
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROL16(v[ d] ^ v[ a]); v[d1] = ROL16(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= (c_xors[i++]^nonce) + v[b1]; \
|
||||
v[ d] = ROR8(v[ d] ^ v[ a]); v[d1] = ROR8(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
}
|
||||
|
||||
#define pxory0GS2(a,b,c,d, a1,b1,c1,d1) { \
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROL16(v[ d] ^ v[ a]); v[d1] = ROL16(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
v[ a]+= (c_xors[i++]^nonce) + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROR8(v[ d] ^ v[ a]); v[d1] = ROR8(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
}
|
||||
|
||||
#define pxorx1GS2(a,b,c,d, a1,b1,c1,d1) { \
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= (c_xors[i++]^nonce) + v[b1]; \
|
||||
v[ d] = ROL16(v[ d] ^ v[ a]); v[d1] = ROL16(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROR8(v[ d] ^ v[ a]); v[d1] = ROR8(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
}
|
||||
|
||||
#define pxorx0GS2(a,b,c,d, a1,b1,c1,d1) { \
|
||||
v[ a]+= (c_xors[i++]^nonce) + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROL16(v[ d] ^ v[ a]); v[d1] = ROL16(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROR8(v[ d] ^ v[ a]); v[d1] = ROR8(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(TPB,1)
|
||||
void decred_gpu_hash_nonce(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce, const uint32_t highTarget)
|
||||
{
|
||||
const uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
|
||||
if (thread < threads)
|
||||
{
|
||||
uint32_t v[16];
|
||||
#pragma unroll
|
||||
for(int i=0; i<16; i+=4) {
|
||||
*(uint4*)&v[i] = *(uint4*)&c_data[i];
|
||||
}
|
||||
|
||||
const uint32_t nonce = startNonce + thread;
|
||||
v[ 1]+= (nonce ^ 0x13198A2E);
|
||||
v[13] = ROR8(v[13] ^ v[1]);
|
||||
v[ 9]+= v[13];
|
||||
v[ 5] = ROTR32(v[5] ^ v[9], 7);
|
||||
|
||||
int i = 0;
|
||||
v[ 1]+= c_xors[i++];// + v[ 6];
|
||||
v[ 0]+= v[5];
|
||||
v[12] = ROL16(v[12] ^ v[ 1]); v[15] = ROL16(v[15] ^ v[ 0]);
|
||||
v[11]+= v[12]; v[10]+= v[15];
|
||||
v[ 6] = ROTR32(v[ 6] ^ v[11], 12); v[ 5] = ROTR32(v[5] ^ v[10], 12);
|
||||
v[ 1]+= c_xors[i++] + v[ 6]; v[ 0]+= c_xors[i++] + v[ 5];
|
||||
v[12] = ROR8(v[12] ^ v[ 1]); v[15] = ROR8(v[15] ^ v[ 0]);
|
||||
v[11]+= v[12]; v[10]+= v[15];
|
||||
v[ 6] = ROTR32(v[ 6] ^ v[11], 7); v[ 5] = ROTR32(v[ 5] ^ v[10], 7);
|
||||
|
||||
pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxory1GS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorx1GS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorx1GS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorx1GS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxory1GS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxory1GS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorx1GS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxory0GS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorx0GS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxory1GS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxory1GS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorx1GS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorx1GS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS( 2, 7, 8, 13);
|
||||
|
||||
if ((c_h[1]^v[15]) == v[7]) {
|
||||
v[ 3] += c_xors[i++] + v[4];
|
||||
v[14] = ROL16(v[14] ^ v[3]);
|
||||
v[ 9] += v[14];
|
||||
v[ 4] = ROTR32(v[4] ^ v[9], 12);
|
||||
v[ 3] += c_xors[i++] + v[4];
|
||||
v[14] = ROR8(v[14] ^ v[3]);
|
||||
if(cuda_swab32((c_h[0]^v[6]^v[14])) <= highTarget) {
|
||||
uint32_t pos = atomicInc(&resNonce[0], UINT32_MAX)+1;
|
||||
resNonce[pos] = nonce;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void decred_cpu_setBlock_52(const uint32_t *input)
|
||||
{
|
||||
/*
|
||||
Precompute everything possible and pass it on constant memory
|
||||
*/
|
||||
const uint32_t z[16] = {
|
||||
0x243F6A88U, 0x85A308D3U, 0x13198A2EU, 0x03707344U,
|
||||
0xA4093822U, 0x299F31D0U, 0x082EFA98U, 0xEC4E6C89U,
|
||||
0x452821E6U, 0x38D01377U, 0xBE5466CFU, 0x34E90C6CU,
|
||||
0xC0AC29B7U, 0xC97C50DDU, 0x3F84D5B5U, 0xB5470917U
|
||||
};
|
||||
|
||||
int i=0;
|
||||
uint32_t _ALIGN(64) preXOR[215];
|
||||
uint32_t _ALIGN(64) data[16];
|
||||
uint32_t _ALIGN(64) m[16];
|
||||
uint32_t _ALIGN(64) h[ 2];
|
||||
|
||||
sph_blake256_context ctx;
|
||||
sph_blake256_set_rounds(14);
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, input, 128);
|
||||
|
||||
data[ 0] = ctx.H[0];
|
||||
data[ 1] = ctx.H[1];
|
||||
data[ 2] = ctx.H[2];
|
||||
data[ 3] = ctx.H[3];
|
||||
data[ 4] = ctx.H[4];
|
||||
data[ 5] = ctx.H[5];
|
||||
data[ 8] = ctx.H[6];
|
||||
|
||||
data[12] = swab32(input[35]);
|
||||
data[13] = ctx.H[7];
|
||||
|
||||
// pre swab32
|
||||
m[ 0] = swab32(input[32]); m[ 1] = swab32(input[33]);
|
||||
m[ 2] = swab32(input[34]); m[ 3] = 0;
|
||||
m[ 4] = swab32(input[36]); m[ 5] = swab32(input[37]);
|
||||
m[ 6] = swab32(input[38]); m[ 7] = swab32(input[39]);
|
||||
m[ 8] = swab32(input[40]); m[ 9] = swab32(input[41]);
|
||||
m[10] = swab32(input[42]); m[11] = swab32(input[43]);
|
||||
m[12] = swab32(input[44]); m[13] = 0x80000001;
|
||||
m[14] = 0;
|
||||
m[15] = 0x000005a0;
|
||||
|
||||
h[ 0] = data[ 8];
|
||||
h[ 1] = data[13];
|
||||
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_h,h, 8, 0, cudaMemcpyHostToDevice));
|
||||
|
||||
data[ 0]+= (m[ 0] ^ z[1]) + data[ 4];
|
||||
data[12] = SPH_ROTR32(z[4] ^ SPH_C32(0x5A0) ^ data[ 0], 16);
|
||||
|
||||
data[ 8] = z[0]+data[12];
|
||||
data[ 4] = SPH_ROTR32(data[ 4] ^ data[ 8], 12);
|
||||
data[ 0]+= (m[ 1] ^ z[0]) + data[ 4];
|
||||
data[12] = SPH_ROTR32(data[12] ^ data[ 0],8);
|
||||
data[ 8]+= data[12];
|
||||
data[ 4] = SPH_ROTR32(data[ 4] ^ data[ 8], 7);
|
||||
|
||||
data[ 1]+= (m[ 2] ^ z[3]) + data[ 5];
|
||||
data[13] = SPH_ROTR32((z[5] ^ SPH_C32(0x5A0)) ^ data[ 1], 16);
|
||||
data[ 9] = z[1]+data[13];
|
||||
data[ 5] = SPH_ROTR32(data[ 5] ^ data[ 9], 12);
|
||||
data[ 1]+= data[ 5]; //+nonce ^ ...
|
||||
|
||||
data[ 2]+= (m[ 4] ^ z[5]) + h[ 0];
|
||||
data[14] = SPH_ROTR32(z[6] ^ data[ 2],16);
|
||||
data[10] = z[2] + data[14];
|
||||
data[ 6] = SPH_ROTR32(h[ 0] ^ data[10], 12);
|
||||
data[ 2]+= (m[ 5] ^ z[4]) + data[ 6];
|
||||
data[14] = SPH_ROTR32(data[14] ^ data[ 2], 8);
|
||||
data[10]+= data[14];
|
||||
data[ 6] = SPH_ROTR32(data[ 6] ^ data[10], 7);
|
||||
|
||||
data[ 3]+= (m[ 6] ^ z[7]) + h[ 1];
|
||||
data[15] = SPH_ROTR32(z[7] ^ data[ 3],16);
|
||||
data[11] = z[3] + data[15];
|
||||
data[ 7] = SPH_ROTR32(h[ 1] ^ data[11], 12);
|
||||
data[ 3]+= (m[ 7] ^ z[6]) + data[ 7];
|
||||
data[15] = SPH_ROTR32(data[15] ^ data[ 3],8);
|
||||
data[11]+= data[15];
|
||||
data[ 7] = SPH_ROTR32(data[11] ^ data[ 7], 7);
|
||||
data[ 0]+= m[ 8] ^ z[9];
|
||||
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_data, data, 64, 0, cudaMemcpyHostToDevice));
|
||||
|
||||
#define precalcXORGS(x,y) { \
|
||||
preXOR[i++]= (m[x] ^ z[y]); \
|
||||
preXOR[i++]= (m[y] ^ z[x]); \
|
||||
}
|
||||
#define precalcXORGS2(x,y,x1,y1){\
|
||||
preXOR[i++] = (m[ x] ^ z[ y]);\
|
||||
preXOR[i++] = (m[x1] ^ z[y1]);\
|
||||
preXOR[i++] = (m[ y] ^ z[ x]);\
|
||||
preXOR[i++] = (m[y1] ^ z[x1]);\
|
||||
}
|
||||
precalcXORGS(10,11);
|
||||
preXOR[ 0]+=data[ 6];
|
||||
preXOR[i++] = (m[9] ^ z[8]);
|
||||
precalcXORGS2(12,13,14,15);
|
||||
precalcXORGS2(14,10, 4, 8);
|
||||
precalcXORGS2( 9,15,13, 6);
|
||||
precalcXORGS2( 1,12, 0, 2);
|
||||
precalcXORGS2(11, 7, 5, 3);
|
||||
precalcXORGS2(11, 8,12, 0);
|
||||
precalcXORGS2( 5, 2,15,13);
|
||||
precalcXORGS2(10,14, 3, 6);
|
||||
precalcXORGS2( 7, 1, 9, 4);
|
||||
precalcXORGS2( 7, 9, 3, 1);
|
||||
precalcXORGS2(13,12,11,14);
|
||||
precalcXORGS2( 2, 6, 5,10);
|
||||
precalcXORGS2( 4, 0,15, 8);
|
||||
precalcXORGS2( 9, 0, 5, 7);
|
||||
precalcXORGS2( 2, 4,10,15);
|
||||
precalcXORGS2(14, 1,11,12);
|
||||
precalcXORGS2( 6, 8, 3,13);
|
||||
precalcXORGS2( 2,12, 6,10);
|
||||
precalcXORGS2( 0,11, 8, 3);
|
||||
precalcXORGS2( 4,13, 7, 5);
|
||||
precalcXORGS2(15,14, 1, 9);
|
||||
precalcXORGS2(12, 5, 1,15);
|
||||
precalcXORGS2(14,13, 4,10);
|
||||
precalcXORGS2( 0, 7, 6, 3);
|
||||
precalcXORGS2( 9, 2, 8,11);
|
||||
precalcXORGS2(13,11, 7,14);
|
||||
precalcXORGS2(12, 1, 3, 9);
|
||||
precalcXORGS2( 5, 0,15, 4);
|
||||
precalcXORGS2( 8, 6, 2,10);
|
||||
precalcXORGS2( 6,15,14, 9);
|
||||
precalcXORGS2(11, 3, 0, 8);
|
||||
precalcXORGS2(12, 2,13, 7);
|
||||
precalcXORGS2( 1, 4,10, 5);
|
||||
precalcXORGS2(10, 2, 8, 4);
|
||||
precalcXORGS2( 7, 6, 1, 5);
|
||||
precalcXORGS2(15,11, 9,14);
|
||||
precalcXORGS2( 3,12,13, 0);
|
||||
precalcXORGS2( 0, 1, 2, 3);
|
||||
precalcXORGS2( 4, 5, 6, 7);
|
||||
precalcXORGS2( 8, 9,10,11);
|
||||
precalcXORGS2(12,13,14,15);
|
||||
precalcXORGS2(14,10, 4, 8);
|
||||
precalcXORGS2( 9,15,13, 6);
|
||||
precalcXORGS2( 1,12, 0, 2);
|
||||
precalcXORGS2(11, 7, 5, 3);
|
||||
precalcXORGS2(11, 8,12, 0);
|
||||
precalcXORGS2( 5, 2,15,13);
|
||||
precalcXORGS2(10,14, 3, 6);
|
||||
precalcXORGS2( 7, 1, 9, 4);
|
||||
precalcXORGS2( 7, 9, 3, 1);
|
||||
precalcXORGS2(13,12,11,14);
|
||||
precalcXORGS2( 2, 6, 5,10);
|
||||
precalcXORGS( 4, 0);
|
||||
precalcXORGS(15, 8);
|
||||
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_xors, preXOR, 215*sizeof(uint32_t), 0, cudaMemcpyHostToDevice));
|
||||
}
|
||||
|
||||
/* ############################################################################################################################### */
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
// nonce position is different in decred
|
||||
#define DCR_NONCE_OFT32 35
|
||||
|
||||
extern "C" int scanhash_decred(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done)
|
||||
{
|
||||
uint32_t _ALIGN(64) endiandata[48];
|
||||
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
uint32_t *pnonce = &pdata[DCR_NONCE_OFT32];
|
||||
|
||||
const uint32_t first_nonce = *pnonce;
|
||||
const uint32_t targetHigh = opt_benchmark ? 0x1ULL : ptarget[6];
|
||||
|
||||
const int dev_id = device_map[thr_id];
|
||||
int intensity = (device_sm[dev_id] > 500 && !is_windows()) ? 29 : 25;
|
||||
if (device_sm[dev_id] < 350) intensity = 22;
|
||||
|
||||
uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
const dim3 grid((throughput + TPB-1)/(TPB));
|
||||
const dim3 block(TPB);
|
||||
|
||||
if (!init[thr_id]) {
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage (linux)
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
cudaDeviceSetCacheConfig(cudaFuncCachePreferL1);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
|
||||
cuda_get_arch(thr_id);
|
||||
|
||||
CUDA_CALL_OR_RET_X(cudaMalloc(&d_resNonce[thr_id], MAX_RESULTS*sizeof(uint32_t)), -1);
|
||||
CUDA_CALL_OR_RET_X(cudaMallocHost(&h_resNonce[thr_id], MAX_RESULTS*sizeof(uint32_t)), -1);
|
||||
init[thr_id] = true;
|
||||
}
|
||||
memcpy(endiandata, pdata, 180);
|
||||
|
||||
decred_cpu_setBlock_52(endiandata);
|
||||
cudaMemset(d_resNonce[thr_id], 0x00, sizeof(uint32_t));
|
||||
|
||||
do {
|
||||
uint32_t* resNonces = h_resNonce[thr_id];
|
||||
|
||||
if (resNonces[0]) cudaMemset(d_resNonce[thr_id], 0x00, sizeof(uint32_t));
|
||||
|
||||
// GPU HASH
|
||||
decred_gpu_hash_nonce <<<grid, block>>> (throughput, (*pnonce), d_resNonce[thr_id], targetHigh);
|
||||
|
||||
*hashes_done = (*pnonce) - first_nonce + throughput;
|
||||
|
||||
// first cell contains the valid nonces count
|
||||
cudaMemcpy(resNonces, d_resNonce[thr_id], sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
|
||||
if (resNonces[0])
|
||||
{
|
||||
uint32_t _ALIGN(64) vhash[8];
|
||||
|
||||
cudaMemcpy(resNonces, d_resNonce[thr_id], (resNonces[0]+1)*sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
|
||||
be32enc(&endiandata[DCR_NONCE_OFT32], resNonces[1]);
|
||||
decred_hash(vhash, endiandata);
|
||||
if (vhash[6] <= ptarget[6] && fulltest(vhash, ptarget))
|
||||
{
|
||||
work->valid_nonces = 1;
|
||||
work_set_target_ratio(work, vhash);
|
||||
work->nonces[0] = swab32(resNonces[1]);
|
||||
*pnonce = work->nonces[0];
|
||||
|
||||
// search for another nonce
|
||||
for(uint32_t n=2; n <= resNonces[0]; n++)
|
||||
{
|
||||
be32enc(&endiandata[DCR_NONCE_OFT32], resNonces[n]);
|
||||
decred_hash(vhash, endiandata);
|
||||
if (vhash[6] <= ptarget[6] && fulltest(vhash, ptarget)) {
|
||||
work->nonces[1] = swab32(resNonces[n]);
|
||||
if (bn_hash_target_ratio(vhash, ptarget) > work->shareratio[0]) {
|
||||
// we really want the best first ? depends...
|
||||
work->shareratio[1] = work->shareratio[0];
|
||||
work->sharediff[1] = work->sharediff[0];
|
||||
xchg(work->nonces[1], work->nonces[0]);
|
||||
work_set_target_ratio(work, vhash);
|
||||
work->valid_nonces++;
|
||||
} else if (work->valid_nonces == 1) {
|
||||
bn_set_target_ratio(work, vhash, 1);
|
||||
work->valid_nonces++;
|
||||
}
|
||||
work->valid_nonces = 2; // MAX_NONCES submit limited to 2
|
||||
|
||||
gpulog(LOG_DEBUG, thr_id, "multiple nonces 1:%08x (%g) %u:%08x (%g)",
|
||||
work->nonces[0], work->sharediff[0], n, work->nonces[1], work->sharediff[1]);
|
||||
|
||||
} else if (vhash[6] > ptarget[6]) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result %u for %08x does not validate on CPU!", n, resNonces[n]);
|
||||
}
|
||||
}
|
||||
return work->valid_nonces;
|
||||
|
||||
} else if (vhash[6] > ptarget[6]) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", resNonces[1]);
|
||||
}
|
||||
}
|
||||
*pnonce += throughput;
|
||||
|
||||
} while (!work_restart[thr_id].restart && max_nonce > (uint64_t)throughput + (*pnonce));
|
||||
|
||||
*hashes_done = (*pnonce) - first_nonce;
|
||||
MyStreamSynchronize(NULL, 0, device_map[thr_id]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_decred(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
cudaFreeHost(h_resNonce[thr_id]);
|
||||
cudaFree(d_resNonce[thr_id]);
|
||||
|
||||
init[thr_id] = false;
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
}
|
||||
+28
-109
@@ -14,18 +14,11 @@ extern "C"
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
// SM5+ cuda
|
||||
extern void keccak256_cpu_init(int thr_id);
|
||||
extern void keccak256_cpu_free(int thr_id);
|
||||
extern void keccak256_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t* resNonces, const uint2 highTarget);
|
||||
extern void keccak256_setBlock_80(uint64_t *endiandata);
|
||||
extern void keccak256_setOutput(int thr_id);
|
||||
static uint32_t *d_hash[MAX_GPUS];
|
||||
|
||||
// compat
|
||||
extern void keccak256_sm3_init(int thr_id, uint32_t threads);
|
||||
extern void keccak256_sm3_free(int thr_id);
|
||||
extern void keccak256_sm3_setBlock_80(void *pdata, const void *ptarget);
|
||||
extern void keccak256_sm3_hash_80(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t* resNonces, int order);
|
||||
extern void keccak256_cpu_init(int thr_id, uint32_t threads);
|
||||
extern void keccak256_setBlock_80(void *pdata,const void *ptarget);
|
||||
extern uint32_t keccak256_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_hash, int order);
|
||||
|
||||
// CPU Hash
|
||||
extern "C" void keccak256_hash(void *state, const void *input)
|
||||
@@ -41,110 +34,55 @@ extern "C" void keccak256_hash(void *state, const void *input)
|
||||
}
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
static bool use_compat_kernels[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_keccak256(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done)
|
||||
extern "C" int scanhash_keccak256(int thr_id, uint32_t *pdata,
|
||||
const uint32_t *ptarget, uint32_t max_nonce,
|
||||
unsigned long *hashes_done)
|
||||
{
|
||||
uint32_t _ALIGN(64) endiandata[20];
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
const int dev_id = device_map[thr_id];
|
||||
uint32_t throughput;
|
||||
uint32_t intensity = 23;
|
||||
if(!use_compat_kernels[thr_id]) {
|
||||
if (strstr(device_name[dev_id], "GTX 1070")) intensity = 25;
|
||||
if (strstr(device_name[dev_id], "GTX 1080")) intensity = 26;
|
||||
}
|
||||
throughput = cuda_default_throughput(thr_id, 1U << intensity);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
uint32_t throughput = device_intensity(thr_id, __func__, 1U << 21); // 256*256*8*4
|
||||
throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
if (opt_benchmark)
|
||||
ptarget[7] = 0x000f;
|
||||
((uint32_t*)ptarget)[7] = 0x0005;
|
||||
|
||||
if (!init[thr_id])
|
||||
{
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
cuda_get_arch(thr_id);
|
||||
use_compat_kernels[thr_id] = (cuda_arch[dev_id] < 500);
|
||||
if (!init[thr_id]) {
|
||||
cudaSetDevice(device_map[thr_id]);
|
||||
|
||||
if(!use_compat_kernels[thr_id]) {
|
||||
keccak256_cpu_init(thr_id);
|
||||
} else {
|
||||
// really useful ?
|
||||
keccak256_sm3_init(thr_id, throughput);
|
||||
}
|
||||
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], throughput * 64));
|
||||
keccak256_cpu_init(thr_id, throughput);
|
||||
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
for (int k=0; k < 19; k++) {
|
||||
uint32_t endiandata[20];
|
||||
for (int k=0; k < 20; k++) {
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
}
|
||||
|
||||
const uint2 highTarget = make_uint2(ptarget[6], ptarget[7]);
|
||||
if(use_compat_kernels[thr_id])
|
||||
keccak256_sm3_setBlock_80((void*)endiandata, ptarget);
|
||||
else {
|
||||
keccak256_setBlock_80((uint64_t*)endiandata);
|
||||
keccak256_setOutput(thr_id);
|
||||
}
|
||||
|
||||
keccak256_setBlock_80((void*)endiandata, ptarget);
|
||||
do {
|
||||
int order = 0;
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce + throughput;
|
||||
|
||||
if(use_compat_kernels[thr_id])
|
||||
keccak256_sm3_hash_80(thr_id, throughput, pdata[19], work->nonces, order++);
|
||||
else {
|
||||
keccak256_cpu_hash_80(thr_id, throughput, pdata[19], work->nonces, highTarget);
|
||||
}
|
||||
|
||||
if (work->nonces[0] != UINT32_MAX && bench_algo < 0)
|
||||
uint32_t foundNonce = keccak256_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id], order++);
|
||||
if (foundNonce != UINT32_MAX)
|
||||
{
|
||||
const uint32_t Htarg = ptarget[7];
|
||||
uint32_t _ALIGN(64) vhash[8];
|
||||
uint32_t _ALIGN(64) vhash64[8];
|
||||
be32enc(&endiandata[19], foundNonce);
|
||||
keccak256_hash(vhash64, endiandata);
|
||||
|
||||
be32enc(&endiandata[19], work->nonces[0]);
|
||||
keccak256_hash(vhash, endiandata);
|
||||
|
||||
if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) {
|
||||
work->valid_nonces = 1;
|
||||
work_set_target_ratio(work, vhash);
|
||||
if (!use_compat_kernels[thr_id] && work->nonces[1] != UINT32_MAX) {
|
||||
be32enc(&endiandata[19], work->nonces[1]);
|
||||
keccak256_hash(vhash, endiandata);
|
||||
if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) {
|
||||
work->valid_nonces++;
|
||||
bn_set_target_ratio(work, vhash, 1);
|
||||
}
|
||||
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
|
||||
} else {
|
||||
pdata[19] = work->nonces[0] + 1;
|
||||
}
|
||||
return work->valid_nonces;
|
||||
if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) {
|
||||
pdata[19] = foundNonce;
|
||||
return 1;
|
||||
}
|
||||
else if (vhash[7] > Htarg) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]);
|
||||
pdata[19] = work->nonces[0] + 1;
|
||||
//keccak256_setOutput(thr_id);
|
||||
continue;
|
||||
else {
|
||||
applog(LOG_WARNING, "GPU #%d: result for nounce %08x does not validate on CPU!", device_map[thr_id], foundNonce);
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint64_t) throughput + pdata[19] >= max_nonce) {
|
||||
pdata[19] = max_nonce;
|
||||
if ((uint64_t) pdata[19] + throughput > max_nonce) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -152,24 +90,5 @@ extern "C" int scanhash_keccak256(int thr_id, struct work* work, uint32_t max_no
|
||||
|
||||
} while (!work_restart[thr_id].restart);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_keccak256(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaThreadSynchronize();
|
||||
|
||||
if(!use_compat_kernels[thr_id])
|
||||
keccak256_cpu_free(thr_id);
|
||||
else {
|
||||
keccak256_sm3_free(thr_id);
|
||||
}
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
init[thr_id] = false;
|
||||
}
|
||||
@@ -1,492 +0,0 @@
|
||||
/**
|
||||
* Optimized Blake-256 8-rounds Cuda Kernel (Tested on SM >3.0)
|
||||
* Based upon Blake-256 implementation of Tanguy Pruvot - Nov. 2014
|
||||
*
|
||||
* Provos Alexis - Jan. 2016
|
||||
*
|
||||
* Fixed CUDA 7.5 flaw
|
||||
* minor code changes
|
||||
* code cleanup
|
||||
* increased nonces per thread
|
||||
* removed SSE2 midstate computation
|
||||
* Provos Alexis - Mar 2016
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include "miner.h"
|
||||
|
||||
extern "C" {
|
||||
#include "sph/sph_blake.h"
|
||||
}
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
#define __byte_perm(x, y, b) x
|
||||
#endif
|
||||
|
||||
/* threads per block and nonces per thread */
|
||||
#define TPB 768
|
||||
#define NPT 384
|
||||
#define NBN 2
|
||||
|
||||
__constant__ uint32_t _ALIGN(16) d_data[21];
|
||||
|
||||
/* 16 gpu threads max */
|
||||
static uint32_t *d_resNonce[MAX_GPUS];
|
||||
static uint32_t *h_resNonce[MAX_GPUS];
|
||||
static cudaStream_t streams[MAX_GPUS];
|
||||
|
||||
/* hash by cpu with blake 256 */
|
||||
extern "C" void vanillahash(void *output, const void *input, int8_t blakerounds){
|
||||
uchar hash[64];
|
||||
sph_blake256_context ctx;
|
||||
|
||||
sph_blake256_set_rounds(blakerounds);
|
||||
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, input, 80);
|
||||
sph_blake256_close(&ctx, hash);
|
||||
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
#define GS4(a,b,c,d,x,y,a1,b1,c1,d1,x1,y1,a2,b2,c2,d2,x2,y2,a3,b3,c3,d3,x3,y3) { \
|
||||
v[ a]+= (m[ x] ^ z[ y]) + v[ b]; \
|
||||
v[a1]+= (m[x1] ^ z[y1]) + v[b1]; \
|
||||
v[a2]+= (m[x2] ^ z[y2]) + v[b2]; \
|
||||
v[a3]+= (m[x3] ^ z[y3]) + v[b3]; \
|
||||
\
|
||||
v[ d] = __byte_perm(v[ d] ^ v[ a], 0, 0x1032); \
|
||||
v[d1] = __byte_perm(v[d1] ^ v[a1], 0, 0x1032); \
|
||||
v[d2] = __byte_perm(v[d2] ^ v[a2], 0, 0x1032); \
|
||||
v[d3] = __byte_perm(v[d3] ^ v[a3], 0, 0x1032); \
|
||||
\
|
||||
v[ c]+= v[ d]; \
|
||||
v[c1]+= v[d1]; \
|
||||
v[c2]+= v[d2]; \
|
||||
v[c3]+= v[d3]; \
|
||||
\
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); \
|
||||
v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
v[b2] = ROTR32(v[b2] ^ v[c2], 12); \
|
||||
v[b3] = ROTR32(v[b3] ^ v[c3], 12); \
|
||||
\
|
||||
v[ a]+= (m[ y] ^ z[ x]) + v[ b]; \
|
||||
v[a1]+= (m[y1] ^ z[x1]) + v[b1]; \
|
||||
v[a2]+= (m[y2] ^ z[x2]) + v[b2]; \
|
||||
v[a3]+= (m[y3] ^ z[x3]) + v[b3]; \
|
||||
\
|
||||
v[ d] = __byte_perm(v[ d] ^ v[ a], 0, 0x0321); \
|
||||
v[d1] = __byte_perm(v[d1] ^ v[a1], 0, 0x0321); \
|
||||
v[d2] = __byte_perm(v[d2] ^ v[a2], 0, 0x0321); \
|
||||
v[d3] = __byte_perm(v[d3] ^ v[a3], 0, 0x0321); \
|
||||
\
|
||||
v[ c]+= v[ d]; \
|
||||
v[c1]+= v[d1]; \
|
||||
v[c2]+= v[d2]; \
|
||||
v[c3]+= v[d3]; \
|
||||
\
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); \
|
||||
v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
v[b2] = ROTR32(v[b2] ^ v[c2], 7); \
|
||||
v[b3] = ROTR32(v[b3] ^ v[c3], 7); \
|
||||
}
|
||||
|
||||
#define GS3(a,b,c,d,x,y,a1,b1,c1,d1,x1,y1,a2,b2,c2,d2,x2,y2) { \
|
||||
v[ a]+= (m[ x] ^ z[ y]) + v[ b]; \
|
||||
v[a1]+= (m[x1] ^ z[y1]) + v[b1]; \
|
||||
v[a2]+= (m[x2] ^ z[y2]) + v[b2]; \
|
||||
\
|
||||
v[ d] = __byte_perm(v[ d] ^ v[ a], 0, 0x1032); \
|
||||
v[d1] = __byte_perm(v[d1] ^ v[a1], 0, 0x1032); \
|
||||
v[d2] = __byte_perm(v[d2] ^ v[a2], 0, 0x1032); \
|
||||
\
|
||||
v[ c]+= v[ d]; \
|
||||
v[c1]+= v[d1]; \
|
||||
v[c2]+= v[d2]; \
|
||||
\
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); \
|
||||
v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
v[b2] = ROTR32(v[b2] ^ v[c2], 12); \
|
||||
\
|
||||
v[ a]+= (m[ y] ^ z[ x]) + v[ b]; \
|
||||
v[a1]+= (m[y1] ^ z[x1]) + v[b1]; \
|
||||
v[a2]+= (m[y2] ^ z[x2]) + v[b2]; \
|
||||
\
|
||||
v[ d] = __byte_perm(v[ d] ^ v[ a], 0, 0x0321); \
|
||||
v[d1] = __byte_perm(v[d1] ^ v[a1], 0, 0x0321); \
|
||||
v[d2] = __byte_perm(v[d2] ^ v[a2], 0, 0x0321); \
|
||||
\
|
||||
v[ c]+= v[ d]; \
|
||||
v[c1]+= v[d1]; \
|
||||
v[c2]+= v[d2]; \
|
||||
\
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); \
|
||||
v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
v[b2] = ROTR32(v[b2] ^ v[c2], 7); \
|
||||
}
|
||||
|
||||
#define GS2(a,b,c,d,x,y,a1,b1,c1,d1,x1,y1) { \
|
||||
v[ a]+= (m[ x] ^ z[ y]) + v[ b]; \
|
||||
v[a1]+= (m[x1] ^ z[y1]) + v[b1]; \
|
||||
\
|
||||
v[ d] = __byte_perm(v[ d] ^ v[ a], 0, 0x1032); \
|
||||
v[d1] = __byte_perm(v[d1] ^ v[a1], 0, 0x1032); \
|
||||
\
|
||||
v[ c]+= v[ d]; \
|
||||
v[c1]+= v[d1]; \
|
||||
\
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); \
|
||||
v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
\
|
||||
v[ a]+= (m[ y] ^ z[ x]) + v[ b]; \
|
||||
v[a1]+= (m[y1] ^ z[x1]) + v[b1]; \
|
||||
\
|
||||
v[ d] = __byte_perm(v[ d] ^ v[ a], 0, 0x0321); \
|
||||
v[d1] = __byte_perm(v[d1] ^ v[a1], 0, 0x0321); \
|
||||
\
|
||||
v[ c]+= v[ d]; \
|
||||
v[c1]+= v[d1]; \
|
||||
\
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); \
|
||||
v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
}
|
||||
|
||||
#define GS(a,b,c,d,x,y) { \
|
||||
v[a] += (m[x] ^ z[y]) + v[b]; \
|
||||
v[d] = __byte_perm(v[d] ^ v[a],0, 0x1032); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = ROTR32(v[b] ^ v[c], 12); \
|
||||
v[a] += (m[y] ^ z[x]) + v[b]; \
|
||||
v[d] = __byte_perm(v[d] ^ v[a],0, 0x0321); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = ROTR32(v[b] ^ v[c], 7); \
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(TPB,1)
|
||||
void vanilla_gpu_hash_16_8(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce,const uint64_t highTarget){
|
||||
uint32_t _ALIGN(16) v[16];
|
||||
uint32_t _ALIGN(16) tmp[16];
|
||||
|
||||
const size_t thread = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
const uint64_t step = gridDim.x * blockDim.x;
|
||||
const uint64_t maxNonce = startNonce + threads;
|
||||
|
||||
const int8_t r[][16] = {
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
|
||||
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 }
|
||||
};
|
||||
const uint32_t z[16] = {
|
||||
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, 0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
|
||||
0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C, 0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917
|
||||
};
|
||||
|
||||
//PREFETCH
|
||||
#pragma unroll
|
||||
for(int i=0;i<16;i++){
|
||||
tmp[ i] = d_data[ i];
|
||||
}
|
||||
|
||||
uint32_t m[16] = {
|
||||
d_data[16], d_data[17], d_data[18], 0,
|
||||
0x80000000UL, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 1, 0, 640
|
||||
};
|
||||
|
||||
const uint32_t h7 = d_data[19];
|
||||
const uint32_t h6 = d_data[20];
|
||||
//END OF PREFETCH
|
||||
uint64_t m3 = startNonce + thread;
|
||||
loopstart:
|
||||
if(m3>=maxNonce)return;
|
||||
m[3] = m3;
|
||||
|
||||
#pragma unroll
|
||||
for(int i=0;i<16;i++)
|
||||
v[ i] = tmp[ i];
|
||||
|
||||
v[ 1]+= m[3] ^ z[2];
|
||||
v[13] = __byte_perm(v[13] ^ v[1],0, 0x0321);
|
||||
v[ 9]+= v[13];
|
||||
v[ 5] = ROTR32(v[5] ^ v[9], 7);
|
||||
v[ 0]+= v[5];
|
||||
v[15] = __byte_perm(v[15] ^ v[0],0, 0x1032);
|
||||
|
||||
v[10]+= v[15];
|
||||
v[ 5] = ROTR32(v[5] ^ v[10], 12);
|
||||
v[ 0]+= z[8] + v[5];
|
||||
v[15] = __byte_perm(v[15] ^ v[0],0, 0x0321);
|
||||
v[10]+= v[15];
|
||||
v[ 5] = ROTR32(v[5] ^ v[10], 7);
|
||||
|
||||
GS3( 1, 6,11,12,10,11, 2, 7, 8,13,12,13, 3, 4, 9,14,14,15);
|
||||
|
||||
#pragma unroll
|
||||
for(int i=0;i<6;i++){
|
||||
GS4(0, 4, 8,12,r[i][ 0],r[i][ 1], 1, 5, 9,13,r[i][ 2],r[i][ 3], 2, 6,10,14,r[i][ 4],r[i][ 5], 3, 7,11,15,r[i][ 6],r[i][ 7]);
|
||||
GS4(0, 5,10,15,r[i][ 8],r[i][ 9], 1, 6,11,12,r[i][10],r[i][11], 2, 7, 8,13,r[i][12],r[i][13], 3, 4, 9,14,r[i][14],r[i][15]);
|
||||
}
|
||||
GS4(0, 4, 8,12,r[6][ 0],r[6][ 1], 1, 5, 9,13,r[6][ 2],r[6][ 3], 2, 6,10,14,r[6][ 4],r[6][ 5], 3, 7,11,15,r[6][ 6],r[6][ 7]);
|
||||
|
||||
v[ 0] += (m[ 5] ^ z[0]) + v[5];
|
||||
v[ 2] += (m[ 8] ^ z[6]) + v[7];
|
||||
v[13] = __byte_perm(v[13] ^ v[2],0, 0x1032);
|
||||
v[15] = __byte_perm(v[15] ^ v[0],0, 0x1032);
|
||||
|
||||
v[ 8] += v[13];
|
||||
v[10] += v[15];
|
||||
|
||||
v[ 5] = ROTR32(v[ 5] ^ v[10], 12);
|
||||
v[ 7] = ROTR32(v[ 7] ^ v[ 8], 12);
|
||||
|
||||
v[ 0] += (m[ 0] ^ z[5]) + v[5];
|
||||
v[ 2] += (m[ 6] ^ z[8]) + v[7];
|
||||
|
||||
v[15] = __byte_perm(v[15] ^ v[ 0],0, 0x0321);
|
||||
v[13] = __byte_perm(v[13] ^ v[ 2],0, 0x0321);
|
||||
|
||||
v[8] += v[13];
|
||||
v[7] = ROTR32(v[7] ^ v[8], 7);
|
||||
|
||||
// only compute h6 & 7
|
||||
if((v[15]^h7)==v[7]){
|
||||
v[ 1] += (m[15] ^ z[ 4]) + v[6];
|
||||
v[ 3] += (m[2] ^ z[10]) + v[4];
|
||||
v[12] = __byte_perm(v[12] ^ v[ 1],0, 0x1032);
|
||||
v[14] = __byte_perm(v[14] ^ v[3],0, 0x1032);
|
||||
v[11] += v[12];
|
||||
v[ 9] += v[14];
|
||||
v[ 6] = ROTR32(v[ 6] ^ v[11], 12);
|
||||
|
||||
v[ 1] += (m[ 4] ^ z[15]) + v[ 6];
|
||||
v[ 3] += (m[10] ^ z[ 2]) + ROTR32(v[ 4] ^ v[ 9],12);
|
||||
v[12] = __byte_perm(v[12] ^ v[ 1],0, 0x0321);
|
||||
v[14] = __byte_perm(v[14] ^ v[ 3],0, 0x0321);
|
||||
|
||||
v[11] += v[12];
|
||||
v[ 6] = ROTR32(v[ 6] ^ v[11], 7);
|
||||
|
||||
if(cuda_swab32(h6^v[6]^v[14]) <= highTarget) {
|
||||
#if NBN == 2
|
||||
/* keep the smallest nonce, + extra one if found */
|
||||
if (m[3] < resNonce[0]){
|
||||
resNonce[1] = resNonce[0];
|
||||
resNonce[0] = m[3];
|
||||
}
|
||||
else
|
||||
resNonce[1] = m[3];
|
||||
#else
|
||||
resNonce[0] = m[3];
|
||||
#endif
|
||||
return; //<-- this may cause a problem on extranonce if the extranonce is on position current_nonce + X * step where X=[1,2,3..,N]
|
||||
}
|
||||
}
|
||||
m3+=step;
|
||||
goto loopstart;
|
||||
}
|
||||
|
||||
__host__
|
||||
void vanilla_cpu_setBlock_16(const int thr_id,const uint32_t* endiandata, uint32_t *penddata){
|
||||
|
||||
const uint32_t _ALIGN(64) z[16] = {
|
||||
SPH_C32(0x243F6A88), SPH_C32(0x85A308D3), SPH_C32(0x13198A2E), SPH_C32(0x03707344),
|
||||
SPH_C32(0xA4093822), SPH_C32(0x299F31D0), SPH_C32(0x082EFA98), SPH_C32(0xEC4E6C89),
|
||||
SPH_C32(0x452821E6), SPH_C32(0x38D01377), SPH_C32(0xBE5466CF), SPH_C32(0x34E90C6C),
|
||||
SPH_C32(0xC0AC29B7), SPH_C32(0xC97C50DD), SPH_C32(0x3F84D5B5), SPH_C32(0xB5470917)
|
||||
};
|
||||
uint32_t _ALIGN(64) h[22];
|
||||
|
||||
sph_blake256_context ctx;
|
||||
|
||||
sph_blake256_set_rounds(8);
|
||||
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, endiandata, 64);
|
||||
|
||||
h[ 0] = ctx.H[0]; h[ 1] = ctx.H[1];
|
||||
h[ 2] = ctx.H[2]; h[21] = ctx.H[3];
|
||||
h[ 4] = ctx.H[4]; h[20] = ctx.H[5];
|
||||
h[19] = ctx.H[6]; h[16] = ctx.H[7];
|
||||
|
||||
uint32_t tmp = h[20];
|
||||
h[20] = h[19];
|
||||
h[19] = h[16];
|
||||
h[16] = penddata[ 0];
|
||||
h[17] = penddata[ 1];
|
||||
h[18] = penddata[ 2];
|
||||
h[12] = z[ 4] ^ 640;
|
||||
h[ 8] = z[ 0];
|
||||
|
||||
h[ 0] += (h[16] ^ z[ 1]) + h[ 4];
|
||||
h[12] = SPH_ROTR32(h[12] ^ h[0],16);
|
||||
h[ 8] += h[12];
|
||||
h[ 4] = SPH_ROTR32(h[ 4] ^ h[ 8], 12);
|
||||
h[ 0] += (h[17] ^ z[ 0]) + h[ 4];
|
||||
h[12] = SPH_ROTR32(h[12] ^ h[0],8);
|
||||
h[ 8] += h[12];
|
||||
h[ 4] = SPH_ROTR32(h[ 4] ^ h[ 8], 7);
|
||||
|
||||
h[1] += (h[18] ^ z[ 3]) + tmp;
|
||||
|
||||
h[13] = SPH_ROTR32(z[ 5] ^ 640 ^ h[1],16);
|
||||
h[ 5] = ROTR32(tmp ^ (z[ 1] + h[13]), 12);
|
||||
|
||||
h[ 1] += h[ 5];
|
||||
h[ 2] += (0x80000000UL ^ z[ 5]) + h[20];
|
||||
|
||||
h[14] = SPH_ROTR32(z[ 6] ^ h[2], 16);
|
||||
h[ 6] = z[ 2] + h[14];
|
||||
h[ 6] = SPH_ROTR32(h[20] ^ h[ 6], 12);
|
||||
|
||||
h[21] += z[ 7] + h[19];
|
||||
h[ 0] += z[ 9];
|
||||
|
||||
h[ 2] += z[ 4] + h[ 6];
|
||||
|
||||
h[ 9] = z[ 1] + h[13];
|
||||
h[10] = z[ 2] + h[14];
|
||||
|
||||
h[14] = SPH_ROTR32(h[14] ^ h[2],8); //0x0321
|
||||
h[10]+=h[14];
|
||||
|
||||
h[ 6] = SPH_ROTR32(h[ 6] ^ h[10],7);
|
||||
h[15] = SPH_ROTR32(z[ 7] ^ h[21],16);
|
||||
|
||||
h[11] = z[ 3] + h[15];
|
||||
h[ 7] = SPH_ROTR32(h[19] ^ h[11], 12);
|
||||
h[ 3] = h[21] + h[ 7] + z[ 6];
|
||||
|
||||
h[15] = SPH_ROTR32(h[15] ^ h[ 3],8);
|
||||
h[11]+= h[15];
|
||||
h[ 7] = ROTR32(h[ 7] ^ h[11],7);
|
||||
|
||||
cudaMemcpyToSymbolAsync(d_data, h, 21*sizeof(uint32_t), 0, cudaMemcpyHostToDevice, streams[thr_id]);
|
||||
}
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_vanilla(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done, const int8_t blakerounds)
|
||||
{
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
const uint32_t targetHigh = ptarget[6];
|
||||
int dev_id = device_map[thr_id];
|
||||
|
||||
int intensity = (device_sm[dev_id] > 500 && !is_windows()) ? 30 : 24;
|
||||
if (device_sm[dev_id] < 350) intensity = 22;
|
||||
uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
if (!init[thr_id]) {
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage (linux)
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
cudaDeviceSetCacheConfig(cudaFuncCachePreferL1);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
|
||||
cuda_get_arch(thr_id);
|
||||
|
||||
CUDA_CALL_OR_RET_X(cudaMalloc(&d_resNonce[thr_id], NBN * sizeof(uint32_t)), -1);
|
||||
CUDA_CALL_OR_RET_X(cudaMallocHost(&h_resNonce[thr_id], NBN * sizeof(uint32_t)), -1);
|
||||
cudaStreamCreate(&streams[thr_id]);
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
uint32_t _ALIGN(64) endiandata[20];
|
||||
|
||||
for (int k = 0; k < 16; k++)
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
|
||||
cudaMemsetAsync(d_resNonce[thr_id], 0xff, sizeof(uint32_t),streams[thr_id]);
|
||||
|
||||
vanilla_cpu_setBlock_16(thr_id,endiandata,&pdata[16]);
|
||||
|
||||
const dim3 grid((throughput + (NPT*TPB)-1)/(NPT*TPB));
|
||||
const dim3 block(TPB);
|
||||
int rc = 0;
|
||||
|
||||
do {
|
||||
vanilla_gpu_hash_16_8<<<grid,block, 0, streams[thr_id]>>>(throughput, pdata[19], d_resNonce[thr_id], targetHigh);
|
||||
cudaMemcpyAsync(h_resNonce[thr_id], d_resNonce[thr_id], NBN*sizeof(uint32_t), cudaMemcpyDeviceToHost,streams[thr_id]);
|
||||
*hashes_done = pdata[19] - first_nonce + throughput;
|
||||
cudaStreamSynchronize(streams[thr_id]);
|
||||
|
||||
if (h_resNonce[thr_id][0] != UINT32_MAX){
|
||||
uint32_t vhashcpu[8];
|
||||
uint32_t Htarg = (uint32_t)targetHigh;
|
||||
|
||||
for (int k=0; k < 19; k++)
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
|
||||
be32enc(&endiandata[19], h_resNonce[thr_id][0]);
|
||||
vanillahash(vhashcpu, endiandata, blakerounds);
|
||||
|
||||
if (vhashcpu[6] <= Htarg && fulltest(vhashcpu, ptarget)) {
|
||||
work->valid_nonces = 1;
|
||||
work->nonces[0] = h_resNonce[thr_id][0];
|
||||
work_set_target_ratio(work, vhashcpu);
|
||||
#if NBN > 1
|
||||
if (h_resNonce[thr_id][1] != UINT32_MAX) {
|
||||
work->nonces[1] = h_resNonce[thr_id][1];
|
||||
be32enc(&endiandata[19], h_resNonce[thr_id][1]);
|
||||
vanillahash(vhashcpu, endiandata, blakerounds);
|
||||
if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio[0]) {
|
||||
work_set_target_ratio(work, vhashcpu);
|
||||
xchg(work->nonces[0], work->nonces[1]);
|
||||
}
|
||||
work->valid_nonces = 2;
|
||||
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
|
||||
} else {
|
||||
pdata[19] = work->nonces[0] + 1; // cursor
|
||||
}
|
||||
#endif
|
||||
return work->valid_nonces;
|
||||
}
|
||||
else if (vhashcpu[6] > Htarg) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", h_resNonce[thr_id][0]);
|
||||
pdata[19] = work->nonces[0] + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint64_t) throughput + pdata[19] >= max_nonce) {
|
||||
pdata[19] = max_nonce;
|
||||
break;
|
||||
}
|
||||
|
||||
pdata[19] += throughput;
|
||||
|
||||
} while (!work_restart[thr_id].restart);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
MyStreamSynchronize(NULL, 0, dev_id);
|
||||
return rc;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_vanilla(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaThreadSynchronize();
|
||||
|
||||
cudaFreeHost(h_resNonce[thr_id]);
|
||||
cudaFree(d_resNonce[thr_id]);
|
||||
|
||||
init[thr_id] = false;
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
}
|
||||
@@ -1,97 +1,11 @@
|
||||
|
||||
You can use ./build.sh to configure and build with default options.
|
||||
|
||||
It is advised to run ./autogen.sh before ./configure (autoconf and automake
|
||||
need to be installed on your system for autogen.sh to work)
|
||||
|
||||
./configure has an option named --with-cuda that allows you to specify
|
||||
where your CUDA 6.5 toolkit is installed (usually /usr/local/cuda,
|
||||
but some distros may have a different default location)
|
||||
|
||||
|
||||
** How to compile on Ubuntu (16.04 LTS)
|
||||
|
||||
First, install Cuda toolkit and nVidia Driver, and type `nvidia-smi` to check if your card is detected.
|
||||
|
||||
Install dependencies
|
||||
```sudo apt-get install libcurl4-openssl-dev libssl-dev libjansson-dev automake autotools-dev build-essential```
|
||||
|
||||
Ubuntu is now shipped with gcc 6 or 7 so please install gcc/g++ 5 and make it the default (required by the cuda toolkit)
|
||||
```
|
||||
sudo apt-get install gcc-5 g++-5
|
||||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 1
|
||||
```
|
||||
|
||||
Then use the helper ./build.sh in ccminer source folder, edit configure.sh and the Makefile.am if required.
|
||||
```
|
||||
./build.sh
|
||||
./ccminer --version
|
||||
```
|
||||
|
||||
|
||||
** How to compile on Fedora 25 **
|
||||
|
||||
Note: You may find an alternative method via rpms :
|
||||
see https://negativo17.org/nvidia-driver/ and https://negativo17.org/repos/multimedia/
|
||||
|
||||
|
||||
# Step 1: gcc and dependencies
|
||||
dnf install gcc gcc-c++ autoconf automake
|
||||
dnf install jansson-devel openssl-devel libcurl-devel zlib-devel
|
||||
|
||||
# Step 2: nvidia drivers (Download common linux drivers from nvidia site)
|
||||
dnf install kernel-devel
|
||||
dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
|
||||
dnf check-update
|
||||
dnf install xorg-x11-drv-nvidia-cuda kmod-nvidia
|
||||
ln -s libnvidia-ml.so.1 /usr/lib64/libnvidia-ml.so
|
||||
|
||||
# Step 3: CUDA SDK (Download from nvidia the generic ".run" archive)
|
||||
# --override is required to ignore "too recent" gcc 6.3
|
||||
# --silent is required to install only the toolkit (no kmod)
|
||||
./cuda_8.0.61_375.26_linux.run --toolkit --silent --override
|
||||
nvcc --version
|
||||
|
||||
# add the nvcc binary path to the system
|
||||
ln -s /usr/local/cuda-8.0 /usr/local/cuda # (if not already made)
|
||||
echo 'export PATH=$PATH:/usr/local/cuda/bin' > /etc/profile.d/cuda.sh
|
||||
|
||||
# add the cudart library path to the system
|
||||
echo /usr/local/cuda/lib64 > /etc/ld.so.conf.d/cuda.conf
|
||||
ldconfig
|
||||
|
||||
# Step 4: Fix the toolkit incompatibility with gcc 6
|
||||
|
||||
# You need to build yourself an older GCC/G++ version, i recommend the 5.4
|
||||
# see https://gcc.gnu.org/mirrors.html
|
||||
# Note: this manual method will override the default gcc, it could be better to use a custom toolchain prefix
|
||||
|
||||
wget ftp://ftp.lip6.fr/pub/gcc/releases/gcc-5.4.0/gcc-5.4.0.tar.bz2
|
||||
dnf install libmpc-devel mpfr-devel gmp-devel
|
||||
./configure --prefix=/usr/local --enable-languages=c,c++,lto --disable-multilib
|
||||
make -j 8 && make install
|
||||
(while this step, you have the time to cook something :p)
|
||||
|
||||
# or, for previous fedora versions, edit the file /usr/local/cuda/include/host_config.h
|
||||
# and comment/delete the line 121 : #error -- unsupported GNU version! gcc versions later than 5 are not supported!
|
||||
|
||||
./build.sh
|
||||
|
||||
./ccminer -n
|
||||
|
||||
|
||||
** How to compile on macOS **
|
||||
|
||||
# Step 1: download and install CUDA Toolkit 8 or more recent
|
||||
# https://developer.nvidia.com/cuda-toolkit-archive
|
||||
|
||||
# Step 2: install Homebrew
|
||||
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
|
||||
# Step 3: dependencies
|
||||
brew install pkg-config autoconf automake curl openssl llvm
|
||||
|
||||
./build.sh
|
||||
|
||||
./ccminer -n
|
||||
|
||||
|
||||
You can use ./build.sh to configure and build with default options.
|
||||
|
||||
It is advised to run ./autogen.sh before ./configure (autoconf and automake
|
||||
need to be installed on your system for autogen.sh to work)
|
||||
|
||||
./configure has an option named --with-cuda that allows you to specify
|
||||
where your CUDA 6.5 toolkit is installed (usually /usr/local/cuda,
|
||||
but some distros may have a different default location)
|
||||
|
||||
See README.txt
|
||||
@@ -33,9 +33,8 @@ __device__ cuda_compactTestFunction_t d_JackpotTrueFunction = JackpotTrueTest, d
|
||||
|
||||
cuda_compactTestFunction_t h_JackpotTrueFunction[MAX_GPUS], h_JackpotFalseFunction[MAX_GPUS];
|
||||
|
||||
// Setup-Function
|
||||
__host__
|
||||
void jackpot_compactTest_cpu_init(int thr_id, uint32_t threads)
|
||||
// Setup-Funktionen
|
||||
__host__ void jackpot_compactTest_cpu_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
cudaMemcpyFromSymbol(&h_JackpotTrueFunction[thr_id], d_JackpotTrueFunction, sizeof(cuda_compactTestFunction_t));
|
||||
cudaMemcpyFromSymbol(&h_JackpotFalseFunction[thr_id], d_JackpotFalseFunction, sizeof(cuda_compactTestFunction_t));
|
||||
@@ -52,18 +51,6 @@ void jackpot_compactTest_cpu_init(int thr_id, uint32_t threads)
|
||||
cudaMalloc(&d_partSum[1][thr_id], sizeof(uint32_t) * s1); // BLOCKSIZE (Threads/Block)
|
||||
}
|
||||
|
||||
__host__
|
||||
void jackpot_compactTest_cpu_free(int thr_id)
|
||||
{
|
||||
cudaFree(d_tempBranch1Nonces[thr_id]);
|
||||
cudaFree(d_numValid[thr_id]);
|
||||
|
||||
cudaFree(d_partSum[0][thr_id]);
|
||||
cudaFree(d_partSum[1][thr_id]);
|
||||
|
||||
cudaFreeHost(h_numValid[thr_id]);
|
||||
}
|
||||
|
||||
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 300
|
||||
/**
|
||||
* __shfl_up() calculates a source lane ID by subtracting delta from the caller's lane ID, and clamping to the range 0..width-1
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <memory.h>
|
||||
|
||||
#include "cuda_helper.h"
|
||||
#include "miner.h"
|
||||
|
||||
// ZR5
|
||||
__constant__ uint32_t d_OriginalData[20];
|
||||
@@ -10,6 +9,9 @@ __constant__ uint32_t d_OriginalData[20];
|
||||
__constant__ uint32_t c_PaddedMessage[18];
|
||||
__constant__ uint64_t c_State[25];
|
||||
|
||||
#define POK_DATA_MASK 0xFFFF0000
|
||||
#define POK_VERSION 0x1
|
||||
|
||||
#define U32TO64_LE(p) \
|
||||
(((uint64_t)(*p)) | (((uint64_t)(*(p + 1))) << 32))
|
||||
|
||||
@@ -655,7 +657,7 @@ __host__
|
||||
void zr5_keccak512_cpu_hash_pok(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t* pdata, uint32_t *d_hash, uint16_t *d_poks)
|
||||
{
|
||||
const uint32_t threadsperblock = 256;
|
||||
const uint32_t version = (pdata[0] & (~POK_DATA_MASK)) | (use_pok ? POK_BOOL_MASK : 0);
|
||||
const uint32_t version = pdata[0] & (~POK_DATA_MASK);
|
||||
|
||||
dim3 grid((threads + threadsperblock-1)/threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
+91
-139
@@ -9,103 +9,101 @@ extern "C"
|
||||
|
||||
#include "miner.h"
|
||||
#include "cuda_helper.h"
|
||||
#include "quark/cuda_quark.h"
|
||||
|
||||
static uint32_t *d_hash[MAX_GPUS] = { 0 };
|
||||
|
||||
// Speicher zur Generierung der Noncevektoren für die bedingten Hashes
|
||||
static uint32_t *d_jackpotNonces[MAX_GPUS] = { 0 };
|
||||
static uint32_t *d_branch1Nonces[MAX_GPUS] = { 0 };
|
||||
static uint32_t *d_branch2Nonces[MAX_GPUS] = { 0 };
|
||||
static uint32_t *d_branch3Nonces[MAX_GPUS] = { 0 };
|
||||
static uint32_t *d_hash[MAX_GPUS];
|
||||
|
||||
extern void jackpot_keccak512_cpu_init(int thr_id, uint32_t threads);
|
||||
extern void jackpot_keccak512_cpu_setBlock(void *pdata, size_t inlen);
|
||||
extern void jackpot_keccak512_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_hash, int order);
|
||||
|
||||
extern void quark_blake512_cpu_init(int thr_id, uint32_t threads);
|
||||
extern void quark_blake512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order);
|
||||
|
||||
extern void quark_groestl512_cpu_init(int thr_id, uint32_t threads);
|
||||
extern void quark_groestl512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order);
|
||||
|
||||
extern void quark_jh512_cpu_init(int thr_id, uint32_t threads);
|
||||
extern void quark_jh512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order);
|
||||
|
||||
extern void quark_skein512_cpu_init(int thr_id, uint32_t threads);
|
||||
extern void quark_skein512_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order);
|
||||
|
||||
extern void jackpot_compactTest_cpu_init(int thr_id, uint32_t threads);
|
||||
extern void jackpot_compactTest_cpu_free(int thr_id);
|
||||
extern void jackpot_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable,
|
||||
uint32_t *d_nonces1, uint32_t *nrm1, uint32_t *d_nonces2, uint32_t *nrm2, int order);
|
||||
extern void jackpot_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable,
|
||||
uint32_t *d_nonces1, uint32_t *nrm1,
|
||||
uint32_t *d_nonces2, uint32_t *nrm2,
|
||||
int order);
|
||||
|
||||
extern uint32_t cuda_check_hash_branch(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_inputHash, int order);
|
||||
|
||||
// CPU HASH JHA v8
|
||||
extern "C" void jackpothash(void *state, const void *input)
|
||||
// Speicher zur Generierung der Noncevektoren für die bedingten Hashes
|
||||
static uint32_t *d_jackpotNonces[MAX_GPUS];
|
||||
static uint32_t *d_branch1Nonces[MAX_GPUS];
|
||||
static uint32_t *d_branch2Nonces[MAX_GPUS];
|
||||
static uint32_t *d_branch3Nonces[MAX_GPUS];
|
||||
|
||||
// Original jackpothash Funktion aus einem miner Quelltext
|
||||
extern "C" unsigned int jackpothash(void *state, const void *input)
|
||||
{
|
||||
uint32_t hash[16];
|
||||
unsigned int rnd;
|
||||
sph_blake512_context ctx_blake;
|
||||
sph_groestl512_context ctx_groestl;
|
||||
sph_jh512_context ctx_jh;
|
||||
sph_keccak512_context ctx_keccak;
|
||||
sph_skein512_context ctx_skein;
|
||||
|
||||
sph_blake512_context ctx_blake;
|
||||
sph_groestl512_context ctx_groestl;
|
||||
sph_jh512_context ctx_jh;
|
||||
sph_keccak512_context ctx_keccak;
|
||||
sph_skein512_context ctx_skein;
|
||||
uint32_t hash[16];
|
||||
|
||||
sph_keccak512_init(&ctx_keccak);
|
||||
sph_keccak512 (&ctx_keccak, input, 80);
|
||||
sph_keccak512_close(&ctx_keccak, hash);
|
||||
sph_keccak512_init(&ctx_keccak);
|
||||
sph_keccak512 (&ctx_keccak, input, 80);
|
||||
sph_keccak512_close(&ctx_keccak, hash);
|
||||
|
||||
for (rnd = 0; rnd < 3; rnd++)
|
||||
{
|
||||
if (hash[0] & 0x01) {
|
||||
sph_groestl512_init(&ctx_groestl);
|
||||
sph_groestl512 (&ctx_groestl, (&hash), 64);
|
||||
sph_groestl512_close(&ctx_groestl, (&hash));
|
||||
}
|
||||
else {
|
||||
sph_skein512_init(&ctx_skein);
|
||||
sph_skein512 (&ctx_skein, (&hash), 64);
|
||||
sph_skein512_close(&ctx_skein, (&hash));
|
||||
}
|
||||
unsigned int round;
|
||||
for (round = 0; round < 3; round++) {
|
||||
if (hash[0] & 0x01) {
|
||||
sph_groestl512_init(&ctx_groestl);
|
||||
sph_groestl512 (&ctx_groestl, (&hash), 64);
|
||||
sph_groestl512_close(&ctx_groestl, (&hash));
|
||||
}
|
||||
else {
|
||||
sph_skein512_init(&ctx_skein);
|
||||
sph_skein512 (&ctx_skein, (&hash), 64);
|
||||
sph_skein512_close(&ctx_skein, (&hash));
|
||||
}
|
||||
if (hash[0] & 0x01) {
|
||||
sph_blake512_init(&ctx_blake);
|
||||
sph_blake512 (&ctx_blake, (&hash), 64);
|
||||
sph_blake512_close(&ctx_blake, (&hash));
|
||||
}
|
||||
else {
|
||||
sph_jh512_init(&ctx_jh);
|
||||
sph_jh512 (&ctx_jh, (&hash), 64);
|
||||
sph_jh512_close(&ctx_jh, (&hash));
|
||||
}
|
||||
}
|
||||
memcpy(state, hash, 32);
|
||||
|
||||
if (hash[0] & 0x01) {
|
||||
sph_blake512_init(&ctx_blake);
|
||||
sph_blake512 (&ctx_blake, (&hash), 64);
|
||||
sph_blake512_close(&ctx_blake, (&hash));
|
||||
}
|
||||
else {
|
||||
sph_jh512_init(&ctx_jh);
|
||||
sph_jh512 (&ctx_jh, (&hash), 64);
|
||||
sph_jh512_close(&ctx_jh, (&hash));
|
||||
}
|
||||
}
|
||||
memcpy(state, hash, 32);
|
||||
return round;
|
||||
}
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_jackpot(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done)
|
||||
extern "C" int scanhash_jackpot(int thr_id, uint32_t *pdata,
|
||||
const uint32_t *ptarget, uint32_t max_nonce,
|
||||
unsigned long *hashes_done)
|
||||
{
|
||||
uint32_t _ALIGN(64) endiandata[22];
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
int dev_id = device_map[thr_id];
|
||||
|
||||
uint32_t throughput = cuda_default_throughput(thr_id, 1U << 20);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
uint32_t throughput = device_intensity(thr_id, __func__, 1U << 20);
|
||||
throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
if (opt_benchmark)
|
||||
ptarget[7] = 0x000f;
|
||||
((uint32_t*)ptarget)[7] = 0x000f;
|
||||
|
||||
if (!init[thr_id])
|
||||
{
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
cuda_get_arch(thr_id);
|
||||
if (device_sm[dev_id] < 300 || cuda_arch[dev_id] < 300) {
|
||||
gpulog(LOG_ERR, thr_id, "Sorry, This algo is not supported by this GPU arch (SM 3.0 required)");
|
||||
proper_exit(EXIT_CODE_CUDA_ERROR);
|
||||
}
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
cudaSetDevice(device_map[thr_id]);
|
||||
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], (size_t) 64 * throughput));
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], 16 * sizeof(uint32_t) * throughput));
|
||||
|
||||
jackpot_keccak512_cpu_init(thr_id, throughput);
|
||||
jackpot_compactTest_cpu_init(thr_id, throughput);
|
||||
@@ -116,15 +114,16 @@ extern "C" int scanhash_jackpot(int thr_id, struct work *work, uint32_t max_nonc
|
||||
|
||||
cuda_check_cpu_init(thr_id, throughput);
|
||||
|
||||
cudaMalloc(&d_branch1Nonces[thr_id], (size_t) sizeof(uint32_t)*throughput*2);
|
||||
cudaMalloc(&d_branch2Nonces[thr_id], (size_t) sizeof(uint32_t)*throughput*2);
|
||||
cudaMalloc(&d_branch3Nonces[thr_id], (size_t) sizeof(uint32_t)*throughput*2);
|
||||
cudaMalloc(&d_branch1Nonces[thr_id], sizeof(uint32_t)*throughput*2);
|
||||
cudaMalloc(&d_branch2Nonces[thr_id], sizeof(uint32_t)*throughput*2);
|
||||
cudaMalloc(&d_branch3Nonces[thr_id], sizeof(uint32_t)*throughput*2);
|
||||
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_jackpotNonces[thr_id], (size_t) sizeof(uint32_t)*throughput*2));
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_jackpotNonces[thr_id], sizeof(uint32_t)*throughput*2));
|
||||
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
uint32_t endiandata[22];
|
||||
for (int k=0; k < 22; k++)
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
|
||||
@@ -210,48 +209,32 @@ extern "C" int scanhash_jackpot(int thr_id, struct work *work, uint32_t max_nonc
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce + throughput;
|
||||
|
||||
CUDA_LOG_ERROR();
|
||||
|
||||
work->nonces[0] = cuda_check_hash_branch(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++);
|
||||
|
||||
if (work->nonces[0] != UINT32_MAX)
|
||||
uint32_t foundNonce = cuda_check_hash_branch(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++);
|
||||
if (foundNonce != 0xffffffff)
|
||||
{
|
||||
const uint32_t Htarg = ptarget[7];
|
||||
uint32_t _ALIGN(64) vhash[8];
|
||||
be32enc(&endiandata[19], work->nonces[0]);
|
||||
uint32_t vhash64[8];
|
||||
be32enc(&endiandata[19], foundNonce);
|
||||
|
||||
// jackpothash function gibt die Zahl der Runden zurück
|
||||
jackpothash(vhash, endiandata);
|
||||
// diese jackpothash Funktion gibt die Zahl der Runden zurück
|
||||
jackpothash(vhash64, endiandata);
|
||||
|
||||
if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) {
|
||||
work->valid_nonces = 1;
|
||||
work_set_target_ratio(work, vhash);
|
||||
#if 0
|
||||
work->nonces[1] = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1);
|
||||
if (work->nonces[1] != 0) {
|
||||
be32enc(&endiandata[19], work->nonces[1]);
|
||||
jackpothash(vhash, endiandata);
|
||||
bn_set_target_ratio(work, vhash, 1);
|
||||
work->valid_nonces++;
|
||||
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
|
||||
} else {
|
||||
pdata[19] = work->nonces[0] + 1; // cursor
|
||||
if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) {
|
||||
int res = 1;
|
||||
uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1);
|
||||
if (secNonce != 0) {
|
||||
pdata[21] = secNonce;
|
||||
res++;
|
||||
}
|
||||
#else
|
||||
pdata[19] = work->nonces[0] + 1; // cursor
|
||||
#endif
|
||||
return work->valid_nonces;
|
||||
}
|
||||
else if (vhash[7] > Htarg) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]);
|
||||
pdata[19] = work->nonces[0] + 1;
|
||||
continue;
|
||||
pdata[19] = foundNonce;
|
||||
return res;
|
||||
} else {
|
||||
applog(LOG_WARNING, "GPU #%d: result for nonce %08x does not validate on CPU!",
|
||||
device_map[thr_id], foundNonce);
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint64_t) throughput + pdata[19] >= max_nonce) {
|
||||
if ((uint64_t) pdata[19] + throughput > max_nonce) {
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
pdata[19] = max_nonce;
|
||||
break;
|
||||
}
|
||||
@@ -260,36 +243,5 @@ extern "C" int scanhash_jackpot(int thr_id, struct work *work, uint32_t max_nonc
|
||||
|
||||
} while (!work_restart[thr_id].restart);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
|
||||
CUDA_LOG_ERROR();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_jackpot(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaThreadSynchronize();
|
||||
|
||||
cudaFree(d_branch1Nonces[thr_id]);
|
||||
cudaFree(d_branch2Nonces[thr_id]);
|
||||
cudaFree(d_branch3Nonces[thr_id]);
|
||||
cudaFree(d_jackpotNonces[thr_id]);
|
||||
|
||||
quark_blake512_cpu_free(thr_id);
|
||||
quark_groestl512_cpu_free(thr_id);
|
||||
jackpot_compactTest_cpu_free(thr_id);
|
||||
|
||||
cudaFree(d_hash[thr_id]);
|
||||
|
||||
cuda_check_cpu_free(thr_id);
|
||||
CUDA_LOG_ERROR();
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
|
||||
init[thr_id] = false;
|
||||
}
|
||||
-265
@@ -1,265 +0,0 @@
|
||||
/**
|
||||
* JHA v8 algorithm - compatible implementation
|
||||
* @author tpruvot@github 05-2017
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#include "sph/sph_keccak.h"
|
||||
#include "sph/sph_blake.h"
|
||||
#include "sph/sph_groestl.h"
|
||||
#include "sph/sph_jh.h"
|
||||
#include "sph/sph_skein.h"
|
||||
}
|
||||
|
||||
#include "miner.h"
|
||||
#include "cuda_helper.h"
|
||||
#include "quark/cuda_quark.h"
|
||||
|
||||
static uint32_t *d_hash[MAX_GPUS] = { 0 };
|
||||
static uint32_t *d_hash_br2[MAX_GPUS];
|
||||
static uint32_t *d_tempBranch[MAX_GPUS];
|
||||
|
||||
extern void jackpot_keccak512_cpu_init(int thr_id, uint32_t threads);
|
||||
extern void jackpot_keccak512_cpu_setBlock(void *pdata, size_t inlen);
|
||||
extern void jackpot_keccak512_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_hash, int order);
|
||||
|
||||
// CPU HASH
|
||||
extern "C" void jha_hash(void *output, const void *input)
|
||||
{
|
||||
uint32_t hash[16];
|
||||
|
||||
sph_blake512_context ctx_blake;
|
||||
sph_groestl512_context ctx_groestl;
|
||||
sph_jh512_context ctx_jh;
|
||||
sph_keccak512_context ctx_keccak;
|
||||
sph_skein512_context ctx_skein;
|
||||
|
||||
sph_keccak512_init(&ctx_keccak);
|
||||
sph_keccak512 (&ctx_keccak, input, 80);
|
||||
sph_keccak512_close(&ctx_keccak, hash);
|
||||
|
||||
for (int rnd = 0; rnd < 3; rnd++)
|
||||
{
|
||||
if (hash[0] & 0x01) {
|
||||
sph_groestl512_init(&ctx_groestl);
|
||||
sph_groestl512 (&ctx_groestl, (&hash), 64);
|
||||
sph_groestl512_close(&ctx_groestl, (&hash));
|
||||
}
|
||||
else {
|
||||
sph_skein512_init(&ctx_skein);
|
||||
sph_skein512 (&ctx_skein, (&hash), 64);
|
||||
sph_skein512_close(&ctx_skein, (&hash));
|
||||
}
|
||||
|
||||
if (hash[0] & 0x01) {
|
||||
sph_blake512_init(&ctx_blake);
|
||||
sph_blake512 (&ctx_blake, (&hash), 64);
|
||||
sph_blake512_close(&ctx_blake, (&hash));
|
||||
}
|
||||
else {
|
||||
sph_jh512_init(&ctx_jh);
|
||||
sph_jh512 (&ctx_jh, (&hash), 64);
|
||||
sph_jh512_close(&ctx_jh, (&hash));
|
||||
}
|
||||
}
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(128, 8)
|
||||
void jha_filter_gpu(const uint32_t threads, const uint32_t* d_hash, uint32_t* d_branch2, uint32_t* d_NonceBranch)
|
||||
{
|
||||
const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
const uint32_t offset = thread * 16U; // 64U / sizeof(uint32_t);
|
||||
uint4 *psrc = (uint4*) (&d_hash[offset]);
|
||||
d_NonceBranch[thread] = ((uint8_t*)psrc)[0] & 0x01;
|
||||
if (d_NonceBranch[thread]) return;
|
||||
// uint4 = 4x uint32_t = 16 bytes
|
||||
uint4 *pdst = (uint4*) (&d_branch2[offset]);
|
||||
pdst[0] = psrc[0];
|
||||
pdst[1] = psrc[1];
|
||||
pdst[2] = psrc[2];
|
||||
pdst[3] = psrc[3];
|
||||
}
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(128, 8)
|
||||
void jha_merge_gpu(const uint32_t threads, uint32_t* d_hash, uint32_t* d_branch2, uint32_t* const d_NonceBranch)
|
||||
{
|
||||
const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads && !d_NonceBranch[thread])
|
||||
{
|
||||
const uint32_t offset = thread * 16U;
|
||||
uint4 *pdst = (uint4*) (&d_hash[offset]);
|
||||
uint4 *psrc = (uint4*) (&d_branch2[offset]);
|
||||
pdst[0] = psrc[0];
|
||||
pdst[1] = psrc[1];
|
||||
pdst[2] = psrc[2];
|
||||
pdst[3] = psrc[3];
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
uint32_t jha_filter_cpu(const int thr_id, const uint32_t threads, const uint32_t *inpHashes, uint32_t* d_branch2)
|
||||
{
|
||||
const uint32_t threadsperblock = 128;
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
// extract algo permution hashes to a second branch buffer
|
||||
jha_filter_gpu <<<grid, block>>> (threads, inpHashes, d_branch2, d_tempBranch[thr_id]);
|
||||
return threads;
|
||||
}
|
||||
|
||||
__host__
|
||||
void jha_merge_cpu(const int thr_id, const uint32_t threads, uint32_t *outpHashes, uint32_t* d_branch2)
|
||||
{
|
||||
const uint32_t threadsperblock = 128;
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
// put back second branch hashes to the common buffer d_hash
|
||||
jha_merge_gpu <<<grid, block>>> (threads, outpHashes, d_branch2, d_tempBranch[thr_id]);
|
||||
}
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_jha(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done)
|
||||
{
|
||||
uint32_t _ALIGN(64) endiandata[22];
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
int dev_id = device_map[thr_id];
|
||||
|
||||
uint32_t throughput = cuda_default_throughput(thr_id, 1U << 20);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
if (opt_benchmark)
|
||||
ptarget[7] = 0x000f;
|
||||
|
||||
if (!init[thr_id])
|
||||
{
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
cuda_get_arch(thr_id);
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], (size_t) 64 * throughput));
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_hash_br2[thr_id], (size_t) 64 * throughput));
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_tempBranch[thr_id], sizeof(uint32_t) * throughput));
|
||||
|
||||
jackpot_keccak512_cpu_init(thr_id, throughput);
|
||||
quark_blake512_cpu_init(thr_id, throughput);
|
||||
quark_groestl512_cpu_init(thr_id, throughput);
|
||||
quark_jh512_cpu_init(thr_id, throughput);
|
||||
quark_skein512_cpu_init(thr_id, throughput);
|
||||
|
||||
cuda_check_cpu_init(thr_id, throughput);
|
||||
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
for (int k=0; k < 22; k++)
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
|
||||
jackpot_keccak512_cpu_setBlock((void*)endiandata, 80);
|
||||
cuda_check_cpu_setTarget(ptarget);
|
||||
|
||||
do {
|
||||
int order = 0;
|
||||
|
||||
jackpot_keccak512_cpu_hash(thr_id, throughput, pdata[19], d_hash[thr_id], order++);
|
||||
|
||||
for (int rnd = 0; rnd < 3; rnd++)
|
||||
{
|
||||
jha_filter_cpu(thr_id, throughput, d_hash[thr_id], d_hash_br2[thr_id]);
|
||||
quark_groestl512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
|
||||
quark_skein512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash_br2[thr_id], order++);
|
||||
jha_merge_cpu(thr_id, throughput, d_hash[thr_id], d_hash_br2[thr_id]);
|
||||
|
||||
jha_filter_cpu(thr_id, throughput, d_hash[thr_id], d_hash_br2[thr_id]);
|
||||
quark_blake512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
|
||||
quark_jh512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash_br2[thr_id], order++);
|
||||
jha_merge_cpu(thr_id, throughput, d_hash[thr_id], d_hash_br2[thr_id]);
|
||||
}
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce + throughput;
|
||||
|
||||
CUDA_LOG_ERROR();
|
||||
|
||||
work->nonces[0] = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]);
|
||||
|
||||
if (work->nonces[0] != UINT32_MAX)
|
||||
{
|
||||
const uint32_t Htarg = ptarget[7];
|
||||
uint32_t _ALIGN(64) vhash[8];
|
||||
|
||||
be32enc(&endiandata[19], work->nonces[0]);
|
||||
jha_hash(vhash, endiandata);
|
||||
|
||||
if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) {
|
||||
work->valid_nonces = 1;
|
||||
work_set_target_ratio(work, vhash);
|
||||
work->nonces[1] = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1);
|
||||
if (work->nonces[1] != 0) {
|
||||
be32enc(&endiandata[19], work->nonces[1]);
|
||||
jha_hash(vhash, endiandata);
|
||||
bn_set_target_ratio(work, vhash, 1);
|
||||
work->valid_nonces++;
|
||||
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
|
||||
} else {
|
||||
pdata[19] = work->nonces[0] + 1; // cursor
|
||||
}
|
||||
return work->valid_nonces;
|
||||
}
|
||||
else if (vhash[7] > Htarg) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]);
|
||||
pdata[19] = work->nonces[0] + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint64_t) throughput + pdata[19] >= max_nonce) {
|
||||
pdata[19] = max_nonce;
|
||||
break;
|
||||
}
|
||||
|
||||
pdata[19] += throughput;
|
||||
|
||||
} while (!work_restart[thr_id].restart);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
|
||||
CUDA_LOG_ERROR();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_jha(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaThreadSynchronize();
|
||||
|
||||
cudaFree(d_hash[thr_id]);
|
||||
cudaFree(d_hash_br2[thr_id]);
|
||||
cudaFree(d_tempBranch[thr_id]);
|
||||
|
||||
quark_blake512_cpu_free(thr_id);
|
||||
quark_groestl512_cpu_free(thr_id);
|
||||
|
||||
cuda_check_cpu_free(thr_id);
|
||||
CUDA_LOG_ERROR();
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
init[thr_id] = false;
|
||||
}
|
||||
+29
-83
@@ -9,7 +9,7 @@ endif
|
||||
|
||||
EXTRA_DIST = autogen.sh README.md README.txt LICENSE.txt \
|
||||
ccminer.sln ccminer.vcxproj ccminer.vcxproj.filters \
|
||||
compat/gettimeofday.c compat/getopt/getopt_long.c
|
||||
compat/gettimeofday.c compat/getopt/getopt_long.c cpuminer-config.h.in
|
||||
|
||||
SUBDIRS = compat
|
||||
|
||||
@@ -19,11 +19,8 @@ ccminer_SOURCES = elist.h miner.h compat.h \
|
||||
compat/inttypes.h compat/stdbool.h compat/unistd.h \
|
||||
compat/sys/time.h compat/getopt/getopt.h \
|
||||
crc32.c hefty1.c \
|
||||
ccminer.cpp pools.cpp util.cpp bench.cpp bignum.cpp \
|
||||
ccminer.cpp util.cpp \
|
||||
api.cpp hashlog.cpp nvml.cpp stats.cpp sysinfos.cpp cuda.cpp \
|
||||
nvsettings.cpp \
|
||||
equi/equi-stratum.cpp equi/equi.cpp equi/blake2/blake2bx.cpp \
|
||||
equi/equihash.cpp equi/cuda_equi.cu \
|
||||
heavy/heavy.cu \
|
||||
heavy/cuda_blake512.cu heavy/cuda_blake512.h \
|
||||
heavy/cuda_combine.cu heavy/cuda_combine.h \
|
||||
@@ -31,60 +28,34 @@ ccminer_SOURCES = elist.h miner.h compat.h \
|
||||
heavy/cuda_hefty1.cu heavy/cuda_hefty1.h \
|
||||
heavy/cuda_keccak512.cu heavy/cuda_keccak512.h \
|
||||
heavy/cuda_sha256.cu heavy/cuda_sha256.h \
|
||||
heavy/bastion.cu heavy/cuda_bastion.cu \
|
||||
fuguecoin.cpp Algo256/cuda_fugue256.cu sph/fugue.c uint256.h \
|
||||
groestlcoin.cpp cuda_groestlcoin.cu cuda_groestlcoin.h \
|
||||
myriadgroestl.cpp cuda_myriadgroestl.cu \
|
||||
lyra2/Lyra2.c lyra2/Sponge.c \
|
||||
lyra2/lyra2RE.cu lyra2/cuda_lyra2.cu \
|
||||
lyra2/lyra2REv2.cu lyra2/cuda_lyra2v2.cu \
|
||||
lyra2/lyra2REv3.cu lyra2/cuda_lyra2v3.cu \
|
||||
lyra2/Lyra2Z.c lyra2/lyra2Z.cu lyra2/cuda_lyra2Z.cu \
|
||||
lyra2/allium.cu \
|
||||
Algo256/cuda_bmw256.cu Algo256/cuda_cubehash256.cu \
|
||||
Algo256/cuda_blake256.cu Algo256/cuda_groestl256.cu \
|
||||
Algo256/cuda_keccak256_sm3.cu Algo256/cuda_keccak256.cu Algo256/cuda_skein256.cu \
|
||||
Algo256/blake256.cu Algo256/decred.cu Algo256/vanilla.cu Algo256/keccak256.cu \
|
||||
Algo256/blake2s.cu sph/blake2s.c \
|
||||
Algo256/bmw.cu Algo256/cuda_bmw.cu \
|
||||
blake2b.cu \
|
||||
crypto/xmr-rpc.cpp crypto/wildkeccak-cpu.cpp crypto/wildkeccak.cu \
|
||||
crypto/cryptolight.cu crypto/cryptolight-core.cu crypto/cryptolight-cpu.cpp \
|
||||
crypto/cryptonight.cu crypto/cryptonight-core.cu crypto/cryptonight-extra.cu \
|
||||
crypto/cryptonight-cpu.cpp crypto/oaes_lib.cpp crypto/aesb.cpp crypto/cpu/c_keccak.c \
|
||||
JHA/jha.cu JHA/jackpotcoin.cu JHA/cuda_jha_keccak512.cu \
|
||||
Algo256/cuda_blake256.cu Algo256/cuda_groestl256.cu Algo256/cuda_keccak256.cu Algo256/cuda_skein256.cu \
|
||||
Algo256/blake256.cu Algo256/keccak256.cu \
|
||||
JHA/jackpotcoin.cu JHA/cuda_jha_keccak512.cu \
|
||||
JHA/cuda_jha_compactionTest.cu cuda_checkhash.cu \
|
||||
quark/cuda_jh512.cu quark/cuda_quark_blake512.cu quark/cuda_quark_groestl512.cu quark/cuda_skein512.cu \
|
||||
quark/cuda_bmw512.cu quark/cuda_quark_keccak512.cu \
|
||||
quark/nist5.cu \
|
||||
quark/quarkcoin.cu quark/cuda_quark_compactionTest.cu \
|
||||
quark/quarkcoin.cu quark/animecoin.cu \
|
||||
quark/cuda_quark_compactionTest.cu \
|
||||
neoscrypt/neoscrypt.cpp neoscrypt/neoscrypt-cpu.c neoscrypt/cuda_neoscrypt.cu \
|
||||
pentablake.cu skein.cu cuda_skeincoin.cu skein2.cpp zr5.cu \
|
||||
skunk/skunk.cu skunk/cuda_skunk.cu skunk/cuda_skunk_streebog.cu \
|
||||
sha256/sha256d.cu sha256/cuda_sha256d.cu sha256/sha256t.cu sha256/cuda_sha256t.cu sha256/sha256q.cu sha256/cuda_sha256q.cu \
|
||||
sia/sia.cu sia/sia-rpc.cpp sph/blake2b.c \
|
||||
cuda_nist5.cu pentablake.cu skein.cu cuda_skeincoin.cu skein2.cpp zr5.cu \
|
||||
sph/bmw.c sph/blake.c sph/groestl.c sph/jh.c sph/keccak.c sph/skein.c \
|
||||
sph/cubehash.c sph/echo.c sph/luffa.c sph/sha2.c sph/shavite.c sph/simd.c \
|
||||
sph/hamsi.c sph/hamsi_helper.c sph/streebog.c \
|
||||
sph/hamsi.c sph/hamsi_helper.c sph/sph_hamsi.h \
|
||||
sph/shabal.c sph/whirlpool.c sph/sha2big.c sph/haval.c \
|
||||
sph/ripemd.c sph/sph_sha2.c \
|
||||
polytimos.cu \
|
||||
lbry/lbry.cu lbry/cuda_sha256_lbry.cu lbry/cuda_sha512_lbry.cu lbry/cuda_lbry_merged.cu \
|
||||
qubit/qubit.cu qubit/qubit_luffa512.cu qubit/deep.cu qubit/luffa.cu \
|
||||
tribus/tribus.cu tribus/cuda_echo512_final.cu \
|
||||
x11/x11.cu x12/x12.cu x11/fresh.cu x11/cuda_x11_luffa512.cu x11/cuda_x11_cubehash512.cu \
|
||||
x11/cuda_x11_shavite512.cu x11/cuda_x11_simd512.cu x11/cuda_x11_echo.cu x11/exosis.cu \
|
||||
x11/cuda_x11_luffa512_Cubehash.cu x11/x11evo.cu x11/timetravel.cu x11/bitcore.cu \
|
||||
pluck/pluck.cu pluck/cuda_pluck.cu \
|
||||
qubit/qubit.cu qubit/qubit_luffa512.cu qubit/deep.cu qubit/doom.cu \
|
||||
x11/x11.cu x11/fresh.cu x11/cuda_x11_luffa512.cu x11/cuda_x11_cubehash512.cu \
|
||||
x11/cuda_x11_shavite512.cu x11/cuda_x11_simd512.cu x11/cuda_x11_echo.cu \
|
||||
x11/cuda_x11_luffa512_Cubehash.cu \
|
||||
x13/x13.cu x13/cuda_x13_hamsi512.cu x13/cuda_x13_fugue512.cu \
|
||||
x13/hsr.cu x13/cuda_hsr_sm3.cu x13/sm3.c \
|
||||
x15/x14.cu x15/x15.cu x15/cuda_x14_shabal512.cu x15/cuda_x15_whirlpool.cu \
|
||||
x15/whirlpool.cu x15/cuda_x15_whirlpool_sm3.cu \
|
||||
x16/x16r.cu x16/x16s.cu x16/cuda_x16_echo512.cu x16/cuda_x16_fugue512.cu \
|
||||
x16/cuda_x16_shabal512.cu x16/cuda_x16_simd512_80.cu \
|
||||
x16/cuda_x16_echo512_64.cu \
|
||||
x17/x17.cu x17/hmq17.cu x17/sonoa.cu x17/cuda_x17_haval256.cu x17/cuda_x17_sha512.cu \
|
||||
phi/phi.cu phi/phi2.cu phi/cuda_phi2.cu phi/cuda_phi2_cubehash512.cu x11/cuda_streebog_maxwell.cu \
|
||||
x11/c11.cu x11/s3.cu x11/sib.cu x11/veltor.cu x11/cuda_streebog.cu
|
||||
x17/x17.cu x17/cuda_x17_haval512.cu x17/cuda_x17_sha512.cu \
|
||||
x11/s3.cu
|
||||
|
||||
# scrypt
|
||||
ccminer_SOURCES += scrypt.cpp scrypt-jane.cpp \
|
||||
@@ -104,27 +75,14 @@ endif
|
||||
|
||||
ccminer_LDFLAGS = $(PTHREAD_FLAGS) @CUDA_LDFLAGS@
|
||||
ccminer_LDADD = @LIBCURL@ @JANSSON_LIBS@ @PTHREAD_LIBS@ @WS2_LIBS@ @CUDA_LIBS@ @OPENMP_CFLAGS@ @LIBS@ $(nvml_libs)
|
||||
ccminer_CPPFLAGS = @LIBCURL_CPPFLAGS@ @OPENMP_CFLAGS@ $(CPPFLAGS) $(PTHREAD_FLAGS) -fno-strict-aliasing $(JANSSON_INCLUDES) $(DEF_INCLUDES) $(nvml_defs)
|
||||
ccminer_CPPFLAGS = @LIBCURL_CPPFLAGS@ @OPENMP_CFLAGS@ $(CPPFLAGS) $(PTHREAD_FLAGS) -fno-strict-aliasing $(JANSSON_INCLUDES) $(DEF_INCLUDES) $(nvml_defs) -DSCRYPT_KECCAK512 -DSCRYPT_CHACHA -DSCRYPT_CHOOSE_COMPILETIME
|
||||
|
||||
if HAVE_OSX
|
||||
ccminer_CPPFLAGS += -I/usr/local/llvm/lib/clang/4.0.0/include
|
||||
ccminer_LDFLAGS += -L/usr/local/llvm/lib
|
||||
ccminer_LDADD += -lomp
|
||||
endif
|
||||
nvcc_ARCH = -gencode=arch=compute_50,code=\"sm_50,compute_50\"
|
||||
|
||||
#ccminer_CPPFLAGS += -DUSE_LIBSODIUM
|
||||
#ccminer_LDFLAGS += -Lequi/lib
|
||||
#ccminer_LDADD += -lsodium
|
||||
ccminer_LDADD += -lcuda
|
||||
|
||||
nvcc_ARCH :=
|
||||
#nvcc_ARCH += -gencode=arch=compute_75,code=\"sm_75,compute_75\" # CUDA 10 req.
|
||||
#nvcc_ARCH += -gencode=arch=compute_70,code=\"sm_70,compute_70\" # CUDA 9.1
|
||||
#nvcc_ARCH += -gencode=arch=compute_61,code=\"sm_61,compute_61\" # CUDA 8
|
||||
nvcc_ARCH += -gencode=arch=compute_52,code=\"sm_52,compute_52\"
|
||||
#nvcc_ARCH += -gencode=arch=compute_50,code=\"sm_50,compute_50\"
|
||||
#nvcc_ARCH += -gencode=arch=compute_52,code=\"sm_52,compute_52\"
|
||||
#nvcc_ARCH += -gencode=arch=compute_35,code=\"sm_35,compute_35\"
|
||||
#nvcc_ARCH += -gencode=arch=compute_30,code=\"sm_30,compute_30\"
|
||||
#nvcc_ARCH += -gencode=arch=compute_20,code=\"sm_21,compute_20\"
|
||||
|
||||
nvcc_FLAGS = $(nvcc_ARCH) @CUDA_INCLUDES@ -I. @CUDA_CFLAGS@
|
||||
nvcc_FLAGS += $(JANSSON_INCLUDES) --ptxas-options="-v"
|
||||
@@ -136,15 +94,6 @@ nvcc_FLAGS += $(JANSSON_INCLUDES) --ptxas-options="-v"
|
||||
Algo256/blake256.o: Algo256/blake256.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=64 -o $@ -c $<
|
||||
|
||||
Algo256/cuda_bmw.o: Algo256/cuda_bmw.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=76 -o $@ -c $<
|
||||
|
||||
crypto/cryptonight-core.o: crypto/cryptonight-core.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=64 -o $@ -c $<
|
||||
|
||||
crypto/cryptonight-extra.o: crypto/cryptonight-extra.cu
|
||||
$(NVCC) $(nvcc_FLAGS) -o $@ -c $<
|
||||
|
||||
heavy/cuda_hefty1.o: heavy/cuda_hefty1.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=80 -o $@ -c $<
|
||||
|
||||
@@ -156,10 +105,7 @@ x11/cuda_x11_luffa512.o: x11/cuda_x11_luffa512.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=80 -o $@ -c $<
|
||||
|
||||
x11/cuda_x11_luffa512_Cubehash.o: x11/cuda_x11_luffa512_Cubehash.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=76 -o $@ -c $<
|
||||
|
||||
x11/cuda_x11_simd512.o: x11/cuda_x11_simd512.cu
|
||||
$(NVCC) $(nvcc_FLAGS) -Xcompiler -Wno-unused-variable -o $@ -c $<
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=80 -o $@ -c $<
|
||||
|
||||
x13/cuda_x13_hamsi512.o: x13/cuda_x13_hamsi512.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=72 -o $@ -c $<
|
||||
@@ -170,9 +116,6 @@ x17/cuda_x17_sha512.o: x17/cuda_x17_sha512.cu
|
||||
quark/cuda_quark_blake512.o: quark/cuda_quark_blake512.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=80 -o $@ -c $<
|
||||
|
||||
quark/cuda_jh512.o: quark/cuda_jh512.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=80 -o $@ -c $<
|
||||
|
||||
quark/cuda_quark_keccak512.o: quark/cuda_quark_keccak512.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=88 -o $@ -c $<
|
||||
|
||||
@@ -184,21 +127,21 @@ JHA/cuda_jha_compactionTest.o: JHA/cuda_jha_compactionTest.cu
|
||||
|
||||
# This object does not use cuda device code but call the different kernels (autotune)
|
||||
scrypt/salsa_kernel.o: scrypt/salsa_kernel.cu
|
||||
$(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_30,code=\"sm_30,compute_30\" -o $@ -c $<
|
||||
$(NVCC) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_20,code=\"sm_21,compute_20\" -o $@ -c $<
|
||||
|
||||
# These kernels are for older devices (SM)
|
||||
|
||||
scrypt/test_kernel.o: scrypt/test_kernel.cu
|
||||
$(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_30,code=\"sm_30,compute_30\" -o $@ -c $<
|
||||
$(NVCC) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_20,code=\"sm_20,compute_20\" -o $@ -c $<
|
||||
|
||||
scrypt/fermi_kernel.o: scrypt/fermi_kernel.cu
|
||||
$(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_30,code=\"sm_30,compute_30\" -o $@ -c $<
|
||||
$(NVCC) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_20,code=\"sm_21,compute_20\" -o $@ -c $<
|
||||
|
||||
scrypt/kepler_kernel.o: scrypt/kepler_kernel.cu
|
||||
$(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_30,code=\"sm_30,compute_30\" -o $@ -c $<
|
||||
$(NVCC) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_30,code=\"sm_30,compute_30\" -o $@ -c $<
|
||||
|
||||
scrypt/nv_kernel.o: scrypt/nv_kernel.cu
|
||||
$(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_30,code=\"sm_30,compute_30\" -o $@ -c $<
|
||||
$(NVCC) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_30,code=\"sm_30,compute_30\" -o $@ -c $<
|
||||
|
||||
scrypt/titan_kernel.o: scrypt/titan_kernel.cu
|
||||
$(NVCC) $(nvcc_FLAGS) -gencode=arch=compute_35,code=\"sm_35,compute_35\" -o $@ -c $<
|
||||
@@ -206,3 +149,6 @@ scrypt/titan_kernel.o: scrypt/titan_kernel.cu
|
||||
skein.o: skein.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=64 -o $@ -c $<
|
||||
|
||||
skein2.o: skein2.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=64 -o $@ -c $<
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
# ccminer
|
||||
ccminer
|
||||
=======
|
||||
|
||||
Based on Christian Buchner's & Christian H.'s CUDA project, no more active on github since 2014.
|
||||
Based on Christian Buchner's & Christian H.'s CUDA project, no more active on github recently.
|
||||
|
||||
Check the [README.txt](README.txt) for the additions
|
||||
Fork by tpruvot@github with X14,X15,X17,Blake256,BlakeCoin,Lyra2RE,Skein,ZR5 and others, check the [README.txt](README.txt)
|
||||
|
||||
BTC donation address: 1AJdfCpLWPNoAMDfHF1wD5y8VgKSSTHxPo (tpruvot)
|
||||
BTC donation address: 1AJdfCpLWPNoAMDfHF1wD5y8VgKSSTHxPo
|
||||
[](https://tip4commit.com/github/tpruvot/ccminer)
|
||||
|
||||
A part of the recent algos were originally written by [djm34](https://github.com/djm34) and [alexis78](https://github.com/alexis78)
|
||||
A part of the recent algos were originally wrote by [djm34](https://github.com/djm34).
|
||||
|
||||
This variant was tested and built on Linux (ubuntu server 14.04, 16.04, Fedora 22 to 25)
|
||||
It is also built for Windows 7 to 10 with VStudio 2013, to stay compatible with Windows 7 and Vista.
|
||||
This variant was tested and built on Linux (ubuntu server 14.04) and VStudio 2013 on Windows 7.
|
||||
|
||||
Note that the x86 releases are generally faster than x64 ones on Windows, but that tend to change with the recent drivers.
|
||||
|
||||
The recommended CUDA Toolkit version was the [6.5.19](http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda_6.5.19_windows_general_64.exe), but some light algos could be faster with the version 7.5 and 8.0 (like lbry, decred and skein).
|
||||
Note that the x86 releases are generally faster than x64 ones on Windows.
|
||||
|
||||
About source code dependencies
|
||||
------------------------------
|
||||
@@ -21,7 +20,9 @@ About source code dependencies
|
||||
This project requires some libraries to be built :
|
||||
|
||||
- OpenSSL (prebuilt for win)
|
||||
|
||||
- Curl (prebuilt for win)
|
||||
|
||||
- pthreads (prebuilt for win)
|
||||
|
||||
The tree now contains recent prebuilt openssl and curl .lib for both x86 and x64 platforms (windows).
|
||||
@@ -29,8 +30,7 @@ The tree now contains recent prebuilt openssl and curl .lib for both x86 and x64
|
||||
To rebuild them, you need to clone this repository and its submodules :
|
||||
git clone https://github.com/peters/curl-for-windows.git compat/curl-for-windows
|
||||
|
||||
On Linux, you can use the helper ./build.sh (edit it if required)
|
||||
|
||||
Compile on Linux
|
||||
----------------
|
||||
There is also an old [Tutorial for windows](http://cudamining.co.uk/url/tutorials/id/3) on [CudaMining](http://cudamining.co.uk) website.
|
||||
|
||||
Please see [INSTALL](https://github.com/tpruvot/ccminer/blob/linux/INSTALL) file or [project Wiki](https://github.com/tpruvot/ccminer/wiki/Compatibility)
|
||||
+25
-248
@@ -1,5 +1,5 @@
|
||||
|
||||
ccminer 2.3.1 "lyra2v3, exosis and sha256q"
|
||||
ccMiner release 1.6.4-tpruvot (May 2015) - "Multi-pools config"
|
||||
---------------------------------------------------------------
|
||||
|
||||
***************************************************************
|
||||
@@ -8,7 +8,8 @@ If you find this tool useful and like to support its continuous
|
||||
|
||||
tpruvot@github:
|
||||
BTC : 1AJdfCpLWPNoAMDfHF1wD5y8VgKSSTHxPo
|
||||
DCR : DsUCcACGcyP8McNMRXQwbtpDxaVUYLDQDeU
|
||||
DRK : XeVrkPrWB7pDbdFLfKhF1Z3xpqhsx6wkH3
|
||||
ZRC : ZEcubH2xp2mpuwxMjy7wZThr5AzLGu3mqT
|
||||
|
||||
DJM34:
|
||||
BTC donation address: 1NENYmxwZGHsKFmyjTc5WferTn5VTFb7Ze
|
||||
@@ -23,39 +24,26 @@ cbuchner v1.2:
|
||||
|
||||
This is a CUDA accelerated mining application which handle :
|
||||
|
||||
Decred (Blake256 14-rounds - 180 bytes)
|
||||
HeavyCoin & MjollnirCoin
|
||||
FugueCoin
|
||||
GroestlCoin & Myriad-Groestl
|
||||
Lbry Credits
|
||||
JackpotCoin (JHA)
|
||||
JackpotCoin
|
||||
QuarkCoin family & AnimeCoin
|
||||
TalkCoin
|
||||
DarkCoin and other X11 coins
|
||||
Chaincoin and Flaxscript (C11)
|
||||
Saffroncoin blake (256 14-rounds)
|
||||
BlakeCoin (256 8-rounds)
|
||||
Qubit (Digibyte, ...)
|
||||
Luffa (Joincoin)
|
||||
Deep, Doom and Qubit
|
||||
Keccak (Maxcoin)
|
||||
Pentablake (Blake 512 x5)
|
||||
1Coin Triple S
|
||||
Neoscrypt (FeatherCoin)
|
||||
x11evo (Revolver)
|
||||
phi2 (LUXCoin)
|
||||
Scrypt and Scrypt:N
|
||||
Scrypt-Jane (Chacha)
|
||||
sib (Sibcoin)
|
||||
Skein (Skein + SHA)
|
||||
Signatum (Skein cubehash fugue Streebog)
|
||||
SonoA (Sono)
|
||||
Tribus (JH, keccak, simd)
|
||||
Woodcoin (Double Skein)
|
||||
Vanilla (Blake256 8-rounds - double sha256)
|
||||
Vertcoin Lyra2REv3
|
||||
Boolberry (Wild Keccak)
|
||||
Monero (Cryptonight v7 with -a monero)
|
||||
Aeon (Cryptonight-lite)
|
||||
Vertcoin Lyra2RE
|
||||
Ziftrcoin (ZR5)
|
||||
|
||||
where some of these coins have a VERY NOTABLE nVidia advantage
|
||||
over competing AMD (OpenCL Only) implementations.
|
||||
@@ -74,72 +62,37 @@ This code is based on the pooler cpuminer and inherits
|
||||
its command line interface and options.
|
||||
|
||||
-a, --algo=ALGO specify the algorithm to use
|
||||
allium use to mine Garlic
|
||||
bastion use to mine Joincoin
|
||||
bitcore use to mine Bitcore's Timetravel10
|
||||
blake use to mine Saffroncoin (Blake256)
|
||||
anime use to mine Animecoin
|
||||
blake use to mine Saffroncoin (Blake 256)
|
||||
blakecoin use to mine Old Blake 256
|
||||
blake2s use to mine Nevacoin (Blake2-S 256)
|
||||
bmw use to mine Midnight
|
||||
cryptolight use to mine AEON cryptonight variant 1 (MEM/2)
|
||||
cryptonight use to mine original cryptonight
|
||||
c11/flax use to mine Chaincoin and Flax
|
||||
decred use to mine Decred 180 bytes Blake256-14
|
||||
deep use to mine Deepcoin
|
||||
dmd-gr use to mine Diamond-Groestl
|
||||
equihash use to mine ZEC, HUSH and KMD
|
||||
exosis use to mine EXO
|
||||
fresh use to mine Freshcoin
|
||||
fugue256 use to mine Fuguecoin
|
||||
groestl use to mine Groestlcoin
|
||||
hsr use to mine Hshare
|
||||
jackpot use to mine Sweepcoin
|
||||
heavy use to mine Heavycoin
|
||||
jackpot use to mine Jackpotcoin
|
||||
keccak use to mine Maxcoin
|
||||
keccakc use to mine CreativeCoin
|
||||
lbry use to mine LBRY Credits
|
||||
luffa use to mine Joincoin
|
||||
lyra2 use to mine CryptoCoin
|
||||
lyra2v2 use to mine Monacoin
|
||||
lyra2v3 use to mine Vertcoin
|
||||
lyra2z use to mine Zerocoin (XZC)
|
||||
monero use to mine Monero (XMR)
|
||||
luffa use to mine Doomcoin
|
||||
lyra2 use to mine Vertcoin
|
||||
mjollnir use to mine Mjollnircoin
|
||||
myr-gr use to mine Myriad-Groest
|
||||
neoscrypt use to mine FeatherCoin, Trezarcoin, Orbitcoin, etc
|
||||
neoscrypt use to mine FeatherCoin
|
||||
nist5 use to mine TalkCoin
|
||||
penta use to mine Joincoin / Pentablake
|
||||
phi1612 use to mine Seraph
|
||||
phi2 use to mine LUXCoin
|
||||
polytimos use to mine Polytimos
|
||||
pluck use to mine Supcoin
|
||||
quark use to mine Quarkcoin
|
||||
qubit use to mine Qubit
|
||||
scrypt use to mine Scrypt coins (Litecoin, Dogecoin, etc)
|
||||
scrypt use to mine Scrypt coins
|
||||
scrypt:N use to mine Scrypt-N (:10 for 2048 iterations)
|
||||
scrypt-jane use to mine Chacha coins like Cache and Ultracoin
|
||||
s3 use to mine 1coin (ONE)
|
||||
sha256t use to mine OneCoin (OC)
|
||||
sha256q use to mine Pyrite
|
||||
sia use to mine SIA
|
||||
sib use to mine Sibcoin
|
||||
s3 use to mine 1coin
|
||||
skein use to mine Skeincoin
|
||||
skein2 use to mine Woodcoin
|
||||
skunk use to mine Signatum
|
||||
sonoa use to mine Sono
|
||||
stellite use to mine Stellite (a cryptonight variant)
|
||||
timetravel use to mine MachineCoin
|
||||
tribus use to mine Denarius
|
||||
x11evo use to mine Revolver
|
||||
x11 use to mine DarkCoin
|
||||
x12 use to mine GalaxyCash
|
||||
x13 use to mine X13
|
||||
x14 use to mine X14
|
||||
x14 use to mine X14Coin
|
||||
x15 use to mine Halcyon
|
||||
x16r use to mine Raven
|
||||
x16s use to mine Pigeon and Eden
|
||||
x17 use to mine X17
|
||||
vanilla use to mine Vanilla (Blake256)
|
||||
veltor use to mine VeltorCoin
|
||||
whirlpool use to mine Joincoin
|
||||
wildkeccak use to mine Boolberry (Stratum only)
|
||||
zr5 use to mine ZiftrCoin
|
||||
|
||||
-d, --devices gives a comma separated list of CUDA device IDs
|
||||
@@ -149,9 +102,8 @@ its command line interface and options.
|
||||
|
||||
-i, --intensity=N[,N] GPU threads per call 8-25 (2^N + F, default: 0=auto)
|
||||
Decimals and multiple values are allowed for fine tuning
|
||||
--cuda-schedule Set device threads scheduling mode (default: auto)
|
||||
-f, --diff-factor Divide difficulty by this factor (default 1.0)
|
||||
-m, --diff-multiplier Multiply difficulty by this value (default 1.0)
|
||||
-f, --diff Divide difficulty by this factor (std is 1)
|
||||
-v, --vote Heavycoin block vote (default: 512)
|
||||
-o, --url=URL URL of mining server
|
||||
-O, --userpass=U:P username:password pair for mining server
|
||||
-u, --user=USERNAME username for mining server
|
||||
@@ -162,12 +114,10 @@ its command line interface and options.
|
||||
-r, --retries=N number of times to retry if a network call fails
|
||||
(default: retry indefinitely)
|
||||
-R, --retry-pause=N time to pause between retries, in seconds (default: 15)
|
||||
--shares-limit maximum shares to mine before exiting the program.
|
||||
--time-limit maximum time [s] to mine before exiting the program.
|
||||
-T, --timeout=N network timeout, in seconds (default: 300)
|
||||
-T, --timeout=N network timeout, in seconds (default: 270)
|
||||
-s, --scantime=N upper bound on time spent scanning current work when
|
||||
long polling is unavailable, in seconds (default: 5)
|
||||
--submit-stale ignore stale job checks, may create more rejected shares
|
||||
-n, --ndevs list cuda devices
|
||||
-N, --statsavg number of samples used to display hashrate (default: 30)
|
||||
--no-gbt disable getblocktemplate support (height check in solo)
|
||||
@@ -177,26 +127,17 @@ its command line interface and options.
|
||||
--no-color disable colored output
|
||||
-D, --debug enable debug output
|
||||
-P, --protocol-dump verbose dump of protocol-level activities
|
||||
-b, --api-bind=port IP:port for the miner API (default: 127.0.0.1:4068), 0 disabled
|
||||
--api-remote Allow remote control, like pool switching, imply --api-allow=0/0
|
||||
--api-allow=... IP/mask of the allowed api client(s), 0/0 for all
|
||||
-b, --api-bind IP/Port for the miner API (default: 127.0.0.1:4068)
|
||||
--api-remote Allow remote control
|
||||
--max-temp=N Only mine if gpu temp is less than specified value
|
||||
--max-rate=N[KMG] Only mine if net hashrate is less than specified value
|
||||
--max-diff=N Only mine if net difficulty is less than specified value
|
||||
--max-log-rate Interval to reduce per gpu hashrate logs (default: 3)
|
||||
--pstate=0 will force the Geforce 9xx to run in P0 P-State
|
||||
--plimit=150W set the gpu power limit, allow multiple values for N cards
|
||||
on windows this parameter use percentages (like OC tools)
|
||||
--tlimit=85 Set the gpu thermal limit (windows only)
|
||||
--keep-clocks prevent reset clocks and/or power limit on exit
|
||||
--hide-diff Hide submitted shares diff and net difficulty
|
||||
-B, --background run the miner in the background
|
||||
--benchmark run in offline benchmark mode
|
||||
--cputest debug hashes from cpu algorithms
|
||||
--cpu-affinity set process affinity to specific cpu core(s) mask
|
||||
--cpu-priority set process priority (default: 0 idle, 2 normal to 5 highest)
|
||||
-c, --config=FILE load a JSON-format configuration file
|
||||
can be from an url with the http:// prefix
|
||||
-V, --version display version information and exit
|
||||
-h, --help display this help text and exit
|
||||
|
||||
@@ -210,23 +151,8 @@ Scrypt specific options:
|
||||
-L, --lookup-gap Divides the per-hash memory requirement by this factor
|
||||
by storing only every N'th value in the scratchpad.
|
||||
Default is 1.
|
||||
--texture-cache comma separated list of flags (0/1/2) specifying
|
||||
which of the CUDA devices shall use the texture
|
||||
cache for mining. Kepler devices may profit.
|
||||
--no-autotune disable auto-tuning of kernel launch parameters
|
||||
|
||||
CryptoNight specific options:
|
||||
-l, --launch-config gives the launch configuration for each kernel
|
||||
in a comma separated list, one per device.
|
||||
--bfactor=[0-12] Run Cryptonight core kernel in smaller pieces,
|
||||
From 0 (ui freeze) to 12 (smooth), win default is 11
|
||||
This is a per-device setting like the launch config.
|
||||
|
||||
Wildkeccak specific:
|
||||
-l, --launch-config gives the launch configuration for each kernel
|
||||
in a comma separated list, one per device.
|
||||
-k, --scratchpad url Url used to download the scratchpad cache.
|
||||
|
||||
|
||||
>>> Examples <<<
|
||||
|
||||
@@ -250,8 +176,6 @@ Example for Fuguecoin pool mining on dwarfpool.com with all your GPUs
|
||||
Example for Groestlcoin solo mining
|
||||
ccminer -q -s 1 -a groestl -o http://127.0.0.1:1441/ -u USERNAME -p PASSWORD
|
||||
|
||||
Example for Boolberry
|
||||
ccminer -a wildkeccak -o stratum+tcp://bbr.suprnova.cc:7777 -u tpruvot.donate -p x -k http://bbr.suprnova.cc/scratchpad.bin -l 64x360
|
||||
|
||||
Example for Scrypt-N (2048) on Nicehash
|
||||
ccminer -a scrypt:10 -o stratum+tcp://stratum.nicehash.com:3335 -u 3EujYFcoBzWvpUEvbe3obEG95mBuU88QBD -p x
|
||||
@@ -290,155 +214,8 @@ so we can more efficiently implement new algorithms using the latest hardware
|
||||
features.
|
||||
|
||||
>>> RELEASE HISTORY <<<
|
||||
Jan. 30th 2019 v2.3.1
|
||||
Handle Lyra2v3 algo
|
||||
Handle sha256q algo
|
||||
Handle exosis algo
|
||||
Handle blake2b standard algo
|
||||
|
||||
June 23th 2018 v2.3
|
||||
Handle phi2 header variation for smart contracts
|
||||
Handle monero, stellite, graft and cryptolight variants
|
||||
Handle SonoA algo
|
||||
|
||||
June 10th 2018 v2.2.6
|
||||
New phi2 algo for LUX
|
||||
New allium algo for Garlic
|
||||
|
||||
Apr. 02nd 2018 v2.2.5
|
||||
New x16r algo for Raven
|
||||
New x16s algo for Pigeon and Eden
|
||||
New x12 algo for Galaxycash
|
||||
Equihash (SIMT) sync issues for the Volta generation
|
||||
|
||||
Jan. 04th 2018 v2.2.4
|
||||
Improve lyra2v2
|
||||
Higher keccak default intensity
|
||||
Drop SM 2.x support by default, for CUDA 9 and more recent
|
||||
|
||||
Dec. 04th 2017 v2.2.3
|
||||
Polytimos Algo
|
||||
Handle keccakc variant (with refreshed sha256d merkle)
|
||||
Optimised keccak for SM5+, based on alexis improvements
|
||||
|
||||
Oct. 09th 2017 v2.2.2
|
||||
Import and clean the hsr algo (x13 + custom hash)
|
||||
Import and optimise phi algo from LuxCoin repository
|
||||
Improve sib algo too for maxwell and pascal cards
|
||||
Small fix to handle more than 9 cards on linux (-d 10+)
|
||||
Attempt to free equihash memory "properly"
|
||||
--submit-stale parameter for supernova pool (which change diff too fast)
|
||||
|
||||
Sep. 01st 2017 v2.2.1
|
||||
Improve tribus algo on recent cards (up to +10%)
|
||||
|
||||
Aug. 13th 2017 v2.2
|
||||
New skunk algo, using the heavy streebog algorithm
|
||||
Enhance tribus algo (+10%)
|
||||
equihash protocol enhancement on yiimp.ccminer.org and zpool.ca
|
||||
|
||||
June 16th 2017 v2.1-tribus
|
||||
Interface equihash algo with djeZo solver (from nheqminer 0.5c)
|
||||
New api parameters (and multicast announces for local networks)
|
||||
New tribus algo
|
||||
|
||||
May. 14th 2017 v2.0
|
||||
Handle cryptonight, wildkeccak and cryptonight-lite
|
||||
Add a serie of new algos: timetravel, bastion, hmq1725, sha256t
|
||||
Import lyra2z from djm34 work...
|
||||
Rework the common skein512 (used in most algos except skein ;)
|
||||
Upgrade whirlpool algo with alexis version (2x faster)
|
||||
Store the share diff of second nonce(s) in most algos
|
||||
Hardware monitoring thread to get more accurate power readings
|
||||
Small changes for the quiet mode & max-log-rate to reduce logs
|
||||
Add bitcore and a compatible jha algo
|
||||
|
||||
Dec. 21th 2016 v1.8.4
|
||||
Improve streebog based algos, veltor and sib (from alexis work)
|
||||
Blake2s greetly improved (3x), thanks to alexis too...
|
||||
|
||||
Sep. 28th 2016 v1.8.3
|
||||
show intensity on startup for each cards
|
||||
show-diff is now used by default, use --hide-diff if not wanted
|
||||
|
||||
Sep. 22th 2016 v1.8.2
|
||||
lbry improvements by Alexis Provos
|
||||
Prevent Windows hibernate while mining
|
||||
veltor algo (basic implementation)
|
||||
|
||||
Aug. 10th 2016 v1.8.1
|
||||
SIA Blake2-B Algo (getwork over stratum for Suprnova)
|
||||
SIA Nanopool RPC (getwork over http)
|
||||
Update also the older lyra2 with Nanashi version
|
||||
|
||||
July 20th 2016 v1.8.0
|
||||
Pascal support with cuda 8
|
||||
lbry new multi sha / ripemd algo (LBC)
|
||||
x11evo algo (XRE)
|
||||
Lyra2v2, Neoscrypt and Decred improvements
|
||||
Enhance windows NVAPI clock and power limits
|
||||
Led support for mining/shares activity on windows
|
||||
|
||||
May 18th 2016 v1.7.6
|
||||
Decred vote support
|
||||
X17 cleanup and improvement
|
||||
Add mining.ping stratum method and handle unknown methods
|
||||
Implement a pool stats/benchmark mode (-p stats on yiimp)
|
||||
Add --shares-limit parameter, can be used for benchmarks
|
||||
|
||||
Mar. 13th 2016 v1.7.5
|
||||
Blake2S Algo (NEVA/OXEN)
|
||||
|
||||
Feb. 28th 2016 v1.7.4 (1.7.3 was a preview, not official)
|
||||
Decred simplified stratum (getwork over stratum)
|
||||
Vanilla kernel by MrMad
|
||||
Drop/Disable WhirlpoolX
|
||||
|
||||
Feb. 11th 2016 v1.7.2
|
||||
Decred Algo (longpoll only)
|
||||
Blake256 improvements/cleanup
|
||||
|
||||
Jan. 26th 2016 v1.7.1
|
||||
Implement sib algo (X11 + Russian Streebog-512/GOST)
|
||||
Whirlpool speed x2 with the midstate precompute
|
||||
Small bug fixes about device ids mapping (and vendor names)
|
||||
Add Vanilla algo (Blake256 8-rounds - double sha256)
|
||||
|
||||
Nov. 06th 2015 v1.7
|
||||
Improve old devices compatibility (x11, lyra2v2, quark, qubit...)
|
||||
Add windows support for SM 2.1 and drop SM 3.5 (x86)
|
||||
Improve lyra2 (v1/v2) cuda implementations
|
||||
Improve most common algos on SM5+ with sp blake kernel
|
||||
Restore whirlpool algo (and whirlcoin variant)
|
||||
Prepare algo/pool switch ability, trivial method
|
||||
Add --benchmark alone to run a benchmark for all algos
|
||||
Add --cuda-schedule parameter
|
||||
Add --show-diff parameter, which display shares diff,
|
||||
and is able to detect real solved blocks on pools.
|
||||
|
||||
Aug. 28th 2015 v1.6.6
|
||||
Allow to load remote config with curl (-c http://...)
|
||||
Add Lyra2REv2 algo (Vertcoin/Zoom)
|
||||
Restore WhirlpoolX algo (VNL)
|
||||
Drop Animecoin support
|
||||
Add bmw (Midnight) algo
|
||||
|
||||
July 06th 2015 v1.6.5-C11
|
||||
Nvml api power limits
|
||||
Add chaincoin c11 algo (used by Flaxscript too)
|
||||
Remove pluck algo
|
||||
|
||||
June 23th 2015 v1.6.5
|
||||
Handle Ziftrcoin PoK solo mining
|
||||
Basic compatibility with CUDA 7.0 (generally slower hashrate)
|
||||
Show gpus vendor names on linux (windows test branch is pciutils)
|
||||
Remove -v and -m short params specific to heavycoin
|
||||
Add --diff-multiplier (-m) and rename --diff to --diff-factor (-f)
|
||||
First steps to handle nvml application clocks and P0 on the GTX9xx
|
||||
Various improvements on multipool and cmdline parameters
|
||||
Optimize a bit qubit, deep, luffa, x11 and quark algos
|
||||
|
||||
May 26th 2015 v1.6.4
|
||||
May 21th 2015 v1.6.4
|
||||
Implement multi-pool support (failover and time rotate)
|
||||
try "ccminer -c pools.conf" to test the sample config
|
||||
Update the API to allow remote pool switching and pool stats
|
||||
|
||||
@@ -1,252 +0,0 @@
|
||||
#ifndef ALGOS_H
|
||||
#define ALGOS_H
|
||||
|
||||
#include <string.h>
|
||||
#include "compat.h"
|
||||
|
||||
enum sha_algos {
|
||||
ALGO_BLAKECOIN = 0,
|
||||
ALGO_BLAKE,
|
||||
ALGO_BLAKE2B,
|
||||
ALGO_BLAKE2S,
|
||||
ALGO_ALLIUM,
|
||||
ALGO_BMW,
|
||||
ALGO_BASTION,
|
||||
ALGO_C11,
|
||||
ALGO_CRYPTOLIGHT,
|
||||
ALGO_CRYPTONIGHT,
|
||||
ALGO_DEEP,
|
||||
ALGO_DECRED,
|
||||
ALGO_DMD_GR,
|
||||
ALGO_EQUIHASH,
|
||||
ALGO_EXOSIS,
|
||||
ALGO_FRESH,
|
||||
ALGO_FUGUE256, /* Fugue256 */
|
||||
ALGO_GROESTL,
|
||||
ALGO_HEAVY, /* Heavycoin hash */
|
||||
ALGO_HMQ1725,
|
||||
ALGO_HSR,
|
||||
ALGO_KECCAK,
|
||||
ALGO_KECCAKC, /* refreshed Keccak with pool factor 256 */
|
||||
ALGO_JACKPOT,
|
||||
ALGO_JHA,
|
||||
ALGO_LBRY,
|
||||
ALGO_LUFFA,
|
||||
ALGO_LYRA2,
|
||||
ALGO_LYRA2v2,
|
||||
ALGO_LYRA2v3,
|
||||
ALGO_LYRA2Z,
|
||||
ALGO_MJOLLNIR, /* Hefty hash */
|
||||
ALGO_MYR_GR,
|
||||
ALGO_NEOSCRYPT,
|
||||
ALGO_NIST5,
|
||||
ALGO_PENTABLAKE,
|
||||
ALGO_PHI,
|
||||
ALGO_PHI2,
|
||||
ALGO_POLYTIMOS,
|
||||
ALGO_QUARK,
|
||||
ALGO_QUBIT,
|
||||
ALGO_SCRYPT,
|
||||
ALGO_SCRYPT_JANE,
|
||||
ALGO_SHA256D,
|
||||
ALGO_SHA256T,
|
||||
ALGO_SHA256Q,
|
||||
ALGO_SIA,
|
||||
ALGO_SIB,
|
||||
ALGO_SKEIN,
|
||||
ALGO_SKEIN2,
|
||||
ALGO_SKUNK,
|
||||
ALGO_SONOA,
|
||||
ALGO_S3,
|
||||
ALGO_TIMETRAVEL,
|
||||
ALGO_TRIBUS,
|
||||
ALGO_BITCORE,
|
||||
ALGO_X11EVO,
|
||||
ALGO_X11,
|
||||
ALGO_X12,
|
||||
ALGO_X13,
|
||||
ALGO_X14,
|
||||
ALGO_X15,
|
||||
ALGO_X16R,
|
||||
ALGO_X16S,
|
||||
ALGO_X17,
|
||||
ALGO_VANILLA,
|
||||
ALGO_VELTOR,
|
||||
ALGO_WHIRLCOIN,
|
||||
ALGO_WHIRLPOOL,
|
||||
ALGO_WHIRLPOOLX,
|
||||
ALGO_WILDKECCAK,
|
||||
ALGO_ZR5,
|
||||
ALGO_MONERO,
|
||||
ALGO_GRAFT,
|
||||
ALGO_STELLITE,
|
||||
ALGO_AUTO,
|
||||
ALGO_COUNT
|
||||
};
|
||||
|
||||
extern volatile enum sha_algos opt_algo;
|
||||
|
||||
static const char *algo_names[] = {
|
||||
"blakecoin",
|
||||
"blake",
|
||||
"blake2b",
|
||||
"blake2s",
|
||||
"allium",
|
||||
"bmw",
|
||||
"bastion",
|
||||
"c11",
|
||||
"cryptolight",
|
||||
"cryptonight",
|
||||
"deep",
|
||||
"decred",
|
||||
"dmd-gr",
|
||||
"equihash",
|
||||
"exosis",
|
||||
"fresh",
|
||||
"fugue256",
|
||||
"groestl",
|
||||
"heavy",
|
||||
"hmq1725",
|
||||
"hsr",
|
||||
"keccak",
|
||||
"keccakc",
|
||||
"jackpot",
|
||||
"jha",
|
||||
"lbry",
|
||||
"luffa",
|
||||
"lyra2",
|
||||
"lyra2v2",
|
||||
"lyra2v3",
|
||||
"lyra2z",
|
||||
"mjollnir",
|
||||
"myr-gr",
|
||||
"neoscrypt",
|
||||
"nist5",
|
||||
"penta",
|
||||
"phi",
|
||||
"phi2",
|
||||
"polytimos",
|
||||
"quark",
|
||||
"qubit",
|
||||
"scrypt",
|
||||
"scrypt-jane",
|
||||
"sha256d",
|
||||
"sha256t",
|
||||
"sha256q",
|
||||
"sia",
|
||||
"sib",
|
||||
"skein",
|
||||
"skein2",
|
||||
"skunk",
|
||||
"sonoa",
|
||||
"s3",
|
||||
"timetravel",
|
||||
"tribus",
|
||||
"bitcore",
|
||||
"x11evo",
|
||||
"x11",
|
||||
"x12",
|
||||
"x13",
|
||||
"x14",
|
||||
"x15",
|
||||
"x16r",
|
||||
"x16s",
|
||||
"x17",
|
||||
"vanilla",
|
||||
"veltor",
|
||||
"whirlcoin",
|
||||
"whirlpool",
|
||||
"whirlpoolx",
|
||||
"wildkeccak",
|
||||
"zr5",
|
||||
"monero",
|
||||
"graft",
|
||||
"stellite",
|
||||
"auto", /* reserved for multi algo */
|
||||
""
|
||||
};
|
||||
|
||||
// string to int/enum
|
||||
static inline int algo_to_int(char* arg)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ALGO_COUNT; i++) {
|
||||
if (algo_names[i] && !strcasecmp(arg, algo_names[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == ALGO_COUNT) {
|
||||
// some aliases...
|
||||
if (!strcasecmp("all", arg))
|
||||
i = ALGO_AUTO;
|
||||
else if (!strcasecmp("cryptonight-light", arg))
|
||||
i = ALGO_CRYPTOLIGHT;
|
||||
else if (!strcasecmp("cryptonight-lite", arg))
|
||||
i = ALGO_CRYPTOLIGHT;
|
||||
else if (!strcasecmp("flax", arg))
|
||||
i = ALGO_C11;
|
||||
else if (!strcasecmp("diamond", arg))
|
||||
i = ALGO_DMD_GR;
|
||||
else if (!strcasecmp("equi", arg))
|
||||
i = ALGO_EQUIHASH;
|
||||
else if (!strcasecmp("doom", arg))
|
||||
i = ALGO_LUFFA;
|
||||
else if (!strcasecmp("hmq17", arg))
|
||||
i = ALGO_HMQ1725;
|
||||
else if (!strcasecmp("hshare", arg))
|
||||
i = ALGO_HSR;
|
||||
else if (!strcasecmp("lyra2re", arg))
|
||||
i = ALGO_LYRA2;
|
||||
else if (!strcasecmp("lyra2rev2", arg))
|
||||
i = ALGO_LYRA2v2;
|
||||
else if (!strcasecmp("lyra2rev3", arg))
|
||||
i = ALGO_LYRA2v3;
|
||||
else if (!strcasecmp("phi1612", arg))
|
||||
i = ALGO_PHI;
|
||||
else if (!strcasecmp("bitcoin", arg))
|
||||
i = ALGO_SHA256D;
|
||||
else if (!strcasecmp("sha256", arg))
|
||||
i = ALGO_SHA256D;
|
||||
else if (!strcasecmp("thorsriddle", arg))
|
||||
i = ALGO_VELTOR;
|
||||
else if (!strcasecmp("timetravel10", arg))
|
||||
i = ALGO_BITCORE;
|
||||
else if (!strcasecmp("whirl", arg))
|
||||
i = ALGO_WHIRLPOOL;
|
||||
else if (!strcasecmp("ziftr", arg))
|
||||
i = ALGO_ZR5;
|
||||
else
|
||||
i = -1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static inline int get_cryptonight_algo(int fork)
|
||||
{
|
||||
int algo = ALGO_COUNT;
|
||||
|
||||
switch (fork) {
|
||||
case 8:
|
||||
algo = ALGO_GRAFT;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
algo = ALGO_MONERO;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
algo = ALGO_STELLITE;
|
||||
break;
|
||||
|
||||
default:
|
||||
algo = ALGO_CRYPTONIGHT;
|
||||
break;
|
||||
}
|
||||
|
||||
return algo;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -8,7 +8,7 @@
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version. See COPYING for more details.
|
||||
*/
|
||||
#define APIVERSION "1.9"
|
||||
#define APIVERSION "1.5"
|
||||
|
||||
#ifdef WIN32
|
||||
# define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||
@@ -33,7 +33,6 @@
|
||||
|
||||
#include "miner.h"
|
||||
#include "nvml.h"
|
||||
#include "algos.h"
|
||||
|
||||
#ifndef WIN32
|
||||
# include <errno.h>
|
||||
@@ -86,20 +85,13 @@ static struct IP4ACCESS *ipaccess = NULL;
|
||||
#define ALLIP4 "0.0.0.0"
|
||||
static const char *localaddr = "127.0.0.1";
|
||||
static const char *UNAVAILABLE = " - API will not be available";
|
||||
static const char *MUNAVAILABLE = " - API multicast listener will not be available";
|
||||
static char *buffer = NULL;
|
||||
static time_t startup = 0;
|
||||
static int bye = 0;
|
||||
|
||||
extern char *opt_api_bind;
|
||||
extern int opt_api_port;
|
||||
extern char *opt_api_allow;
|
||||
extern char *opt_api_groups;
|
||||
extern bool opt_api_mcast;
|
||||
extern char *opt_api_mcast_addr;
|
||||
extern char *opt_api_mcast_code;
|
||||
extern char *opt_api_mcast_des;
|
||||
extern int opt_api_mcast_port;
|
||||
extern int opt_api_listen; /* port */
|
||||
extern int opt_api_remote;
|
||||
|
||||
// current stratum...
|
||||
extern struct stratum_ctx stratum;
|
||||
@@ -108,6 +100,9 @@ extern struct stratum_ctx stratum;
|
||||
extern int num_cpus;
|
||||
extern float cpu_temp(int);
|
||||
extern uint32_t cpu_clock(int);
|
||||
// cuda.cpp
|
||||
int cuda_num_devices();
|
||||
int cuda_gpu_clocks(struct cgpu_info *gpu);
|
||||
|
||||
char driver_version[32] = { 0 };
|
||||
|
||||
@@ -119,45 +114,32 @@ static void gpustatus(int thr_id)
|
||||
|
||||
if (thr_id >= 0 && thr_id < opt_n_threads) {
|
||||
struct cgpu_info *cgpu = &thr_info[thr_id].gpu;
|
||||
double khashes_per_watt = 0;
|
||||
int gpuid = cgpu->gpu_id;
|
||||
char buf[512]; *buf = '\0';
|
||||
char* card;
|
||||
|
||||
cuda_gpu_info(cgpu);
|
||||
cgpu->gpu_plimit = device_plimit[cgpu->gpu_id];
|
||||
|
||||
#ifdef USE_WRAPNVML
|
||||
cgpu->has_monitoring = true;
|
||||
cgpu->gpu_bus = gpu_busid(cgpu);
|
||||
cgpu->gpu_temp = gpu_temp(cgpu);
|
||||
cgpu->gpu_fan = (uint16_t) gpu_fanpercent(cgpu);
|
||||
cgpu->gpu_fan_rpm = (uint16_t) gpu_fanrpm(cgpu);
|
||||
cgpu->gpu_power = gpu_power(cgpu); // mWatts
|
||||
cgpu->gpu_plimit = gpu_plimit(cgpu); // mW or %
|
||||
#endif
|
||||
cuda_gpu_clocks(cgpu);
|
||||
|
||||
// todo: per gpu
|
||||
cgpu->accepted = p->accepted_count;
|
||||
cgpu->rejected = p->rejected_count;
|
||||
|
||||
cgpu->khashes = stats_get_speed(thr_id, 0.0) / 1000.0;
|
||||
if (cgpu->monitor.gpu_power) {
|
||||
cgpu->gpu_power = cgpu->monitor.gpu_power;
|
||||
khashes_per_watt = (double)cgpu->khashes / cgpu->monitor.gpu_power;
|
||||
khashes_per_watt *= 1000; // power in mW
|
||||
//gpulog(LOG_BLUE, thr_id, "KHW: %g", khashes_per_watt);
|
||||
}
|
||||
|
||||
card = device_name[gpuid];
|
||||
|
||||
snprintf(buf, sizeof(buf), "GPU=%d;BUS=%hd;CARD=%s;TEMP=%.1f;"
|
||||
"POWER=%u;FAN=%hu;RPM=%hu;"
|
||||
"FREQ=%u;MEMFREQ=%u;GPUF=%u;MEMF=%u;"
|
||||
"KHS=%.2f;KHW=%.5f;PLIM=%u;"
|
||||
"ACC=%u;REJ=%u;HWF=%u;I=%.1f;THR=%u|",
|
||||
gpuid, cgpu->gpu_bus, card, cgpu->gpu_temp,
|
||||
cgpu->gpu_power, cgpu->gpu_fan, cgpu->gpu_fan_rpm,
|
||||
cgpu->gpu_clock/1000, cgpu->gpu_memclock/1000, // base freqs in MHz
|
||||
cgpu->monitor.gpu_clock, cgpu->monitor.gpu_memclock, // current
|
||||
cgpu->khashes, khashes_per_watt, cgpu->gpu_plimit,
|
||||
cgpu->accepted, (unsigned) cgpu->rejected, (unsigned) cgpu->hw_errors,
|
||||
cgpu->intensity, cgpu->throughput);
|
||||
snprintf(buf, sizeof(buf), "GPU=%d;BUS=%hd;CARD=%s;"
|
||||
"TEMP=%.1f;FAN=%hu;RPM=%hu;FREQ=%d;KHS=%.2f;HWF=%d;I=%.1f;THR=%u|",
|
||||
gpuid, cgpu->gpu_bus, card, cgpu->gpu_temp, cgpu->gpu_fan,
|
||||
cgpu->gpu_fan_rpm, cgpu->gpu_clock, cgpu->khashes,
|
||||
cgpu->hw_errors, cgpu->intensity, cgpu->throughput);
|
||||
|
||||
// append to buffer for multi gpus
|
||||
strcat(buffer, buf);
|
||||
@@ -182,16 +164,14 @@ static char *getthreads(char *params)
|
||||
*/
|
||||
static char *getsummary(char *params)
|
||||
{
|
||||
char algo[64] = { 0 };
|
||||
char algo[64]; *algo = '\0';
|
||||
time_t ts = time(NULL);
|
||||
double accps, uptime = difftime(ts, startup);
|
||||
uint32_t wait_time = 0, solved_count = 0;
|
||||
uint32_t accepted_count = 0, rejected_count = 0;
|
||||
uint32_t wait_time = 0, accepted_count = 0, rejected_count = 0;
|
||||
for (int p = 0; p < num_pools; p++) {
|
||||
wait_time += pools[p].wait_time;
|
||||
accepted_count += pools[p].accepted_count;
|
||||
rejected_count += pools[p].rejected_count;
|
||||
solved_count += pools[p].solved_count;
|
||||
wait_time += pools[cur_pooln].wait_time;
|
||||
accepted_count += pools[cur_pooln].accepted_count;
|
||||
rejected_count += pools[cur_pooln].rejected_count;
|
||||
}
|
||||
accps = (60.0 * accepted_count) / (uptime ? uptime : 1.0);
|
||||
|
||||
@@ -199,13 +179,13 @@ static char *getsummary(char *params)
|
||||
|
||||
*buffer = '\0';
|
||||
sprintf(buffer, "NAME=%s;VER=%s;API=%s;"
|
||||
"ALGO=%s;GPUS=%d;KHS=%.2f;SOLV=%d;ACC=%d;REJ=%d;"
|
||||
"ACCMN=%.3f;DIFF=%.6f;NETKHS=%.0f;"
|
||||
"ALGO=%s;GPUS=%d;KHS=%.2f;ACC=%d;REJ=%d;"
|
||||
"ACCMN=%.3f;DIFF=%.6f;NETKHS=%.2f;"
|
||||
"POOLS=%u;WAIT=%u;UPTIME=%.0f;TS=%u|",
|
||||
PACKAGE_NAME, PACKAGE_VERSION, APIVERSION,
|
||||
algo, active_gpus, (double)global_hashrate / 1000.,
|
||||
solved_count, accepted_count, rejected_count,
|
||||
accps, net_diff > 1e-6 ? net_diff : stratum_diff, (double)net_hashrate / 1000.,
|
||||
accepted_count, rejected_count,
|
||||
accps, net_diff > 0. ? net_diff : stratum_diff, (double)net_hashrate / 1000.,
|
||||
num_pools, wait_time, uptime, (uint32_t) ts);
|
||||
return buffer;
|
||||
}
|
||||
@@ -217,12 +197,8 @@ static char *getpoolnfo(char *params)
|
||||
{
|
||||
char *s = buffer;
|
||||
char jobid[128] = { 0 };
|
||||
char extra[96] = { 0 };
|
||||
int pooln = params ? atoi(params) % num_pools : cur_pooln;
|
||||
struct pool_infos *p = &pools[pooln];
|
||||
uint32_t last_share = 0;
|
||||
if (p->last_share_time)
|
||||
last_share = (uint32_t) (time(NULL) - p->last_share_time);
|
||||
char nonce[128] = { 0 };
|
||||
struct pool_infos *p = &pools[cur_pooln];
|
||||
|
||||
*s = '\0';
|
||||
|
||||
@@ -230,25 +206,17 @@ static char *getpoolnfo(char *params)
|
||||
strncpy(jobid, stratum.job.job_id, sizeof(stratum.job.job_id));
|
||||
if (stratum.job.xnonce2) {
|
||||
/* used temporary to be sure all is ok */
|
||||
sprintf(extra, "0x");
|
||||
if (p->algo == ALGO_DECRED) {
|
||||
char compat[32] = { 0 };
|
||||
cbin2hex(&extra[2], (const char*) stratum.xnonce1, min(36, stratum.xnonce2_size));
|
||||
cbin2hex(compat, (const char*) stratum.job.xnonce2, 4);
|
||||
memcpy(&extra[2], compat, 8); // compat extranonce
|
||||
} else {
|
||||
cbin2hex(&extra[2], (const char*) stratum.job.xnonce2, stratum.xnonce2_size);
|
||||
}
|
||||
sprintf(nonce, "0x");
|
||||
cbin2hex(&nonce[2], (const char*) stratum.job.xnonce2, stratum.xnonce2_size);
|
||||
}
|
||||
|
||||
snprintf(s, MYBUFSIZ, "POOL=%s;ALGO=%s;URL=%s;USER=%s;SOLV=%d;ACC=%d;REJ=%d;STALE=%u;H=%u;JOB=%s;DIFF=%.6f;"
|
||||
"BEST=%.6f;N2SZ=%d;N2=%s;PING=%u;DISCO=%u;WAIT=%u;UPTIME=%u;LAST=%u|",
|
||||
strlen(p->name) ? p->name : p->short_url, algo_names[p->algo],
|
||||
snprintf(s, MYBUFSIZ, "URL=%s;USER=%s;ACC=%d;REJ=%d;H=%u;JOB=%s;DIFF=%.6f;"
|
||||
"N2SZ=%d;N2=%s;PING=%u;DISCO=%u;WAIT=%u;UPTIME=%u|",
|
||||
p->url, p->type & POOL_STRATUM ? p->user : "",
|
||||
p->solved_count, p->accepted_count, p->rejected_count, p->stales_count,
|
||||
stratum.job.height, jobid, stratum_diff, p->best_share,
|
||||
(int) stratum.xnonce2_size, extra, stratum.answer_msec,
|
||||
p->disconnects, p->wait_time, p->work_time, last_share);
|
||||
p->accepted_count, p->rejected_count,
|
||||
stratum.job.height, jobid, stratum_diff,
|
||||
(int) stratum.xnonce2_size, nonce, stratum.answer_msec,
|
||||
p->disconnects, p->wait_time, p->work_time);
|
||||
|
||||
return s;
|
||||
}
|
||||
@@ -257,7 +225,7 @@ static char *getpoolnfo(char *params)
|
||||
|
||||
static void gpuhwinfos(int gpu_id)
|
||||
{
|
||||
char buf[512];
|
||||
char buf[256];
|
||||
char pstate[8];
|
||||
char* card;
|
||||
struct cgpu_info *cgpu = NULL;
|
||||
@@ -272,40 +240,31 @@ static void gpuhwinfos(int gpu_id)
|
||||
if (cgpu == NULL)
|
||||
return;
|
||||
|
||||
cuda_gpu_info(cgpu);
|
||||
cgpu->gpu_plimit = device_plimit[cgpu->gpu_id];
|
||||
|
||||
#ifdef USE_WRAPNVML
|
||||
cgpu->has_monitoring = true;
|
||||
cgpu->gpu_bus = gpu_busid(cgpu);
|
||||
cgpu->gpu_temp = gpu_temp(cgpu);
|
||||
cgpu->gpu_fan = (uint16_t) gpu_fanpercent(cgpu);
|
||||
cgpu->gpu_fan_rpm = (uint16_t) gpu_fanrpm(cgpu);
|
||||
cgpu->gpu_pstate = (int16_t) gpu_pstate(cgpu);
|
||||
cgpu->gpu_power = gpu_power(cgpu);
|
||||
cgpu->gpu_plimit = gpu_plimit(cgpu);
|
||||
cgpu->gpu_pstate = gpu_pstate(cgpu);
|
||||
gpu_info(cgpu);
|
||||
#ifdef WIN32
|
||||
if (opt_debug) nvapi_pstateinfo(cgpu->gpu_id);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
cuda_gpu_clocks(cgpu);
|
||||
|
||||
memset(pstate, 0, sizeof(pstate));
|
||||
if (cgpu->gpu_pstate != -1)
|
||||
snprintf(pstate, sizeof(pstate), "P%d", (int) cgpu->gpu_pstate);
|
||||
snprintf(pstate, sizeof(pstate), "P%hu", cgpu->gpu_pstate);
|
||||
|
||||
card = device_name[gpu_id];
|
||||
|
||||
snprintf(buf, sizeof(buf), "GPU=%d;BUS=%hd;CARD=%s;SM=%hu;MEM=%u;"
|
||||
"TEMP=%.1f;FAN=%hu;RPM=%hu;FREQ=%u;MEMFREQ=%u;GPUF=%u;MEMF=%u;"
|
||||
"PST=%s;POWER=%u;PLIM=%u;"
|
||||
snprintf(buf, sizeof(buf), "GPU=%d;BUS=%hd;CARD=%s;SM=%u;MEM=%lu;"
|
||||
"TEMP=%.1f;FAN=%hu;RPM=%hu;FREQ=%d;MEMFREQ=%d;PST=%s;"
|
||||
"VID=%hx;PID=%hx;NVML=%d;NVAPI=%d;SN=%s;BIOS=%s|",
|
||||
gpu_id, cgpu->gpu_bus, card, cgpu->gpu_arch, (uint32_t) cgpu->gpu_mem,
|
||||
gpu_id, cgpu->gpu_bus, card, cgpu->gpu_arch, cgpu->gpu_mem,
|
||||
cgpu->gpu_temp, cgpu->gpu_fan, cgpu->gpu_fan_rpm,
|
||||
cgpu->gpu_clock/1000U, cgpu->gpu_memclock/1000U, // base clocks
|
||||
cgpu->monitor.gpu_clock, cgpu->monitor.gpu_memclock, // current
|
||||
pstate, cgpu->gpu_power, cgpu->gpu_plimit,
|
||||
cgpu->gpu_vid, cgpu->gpu_pid, cgpu->nvml_id, cgpu->nvapi_id,
|
||||
cgpu->gpu_clock, cgpu->gpu_memclock,
|
||||
pstate, cgpu->gpu_vid, cgpu->gpu_pid, cgpu->nvml_id, cgpu->nvapi_id,
|
||||
cgpu->gpu_sn, cgpu->gpu_desc);
|
||||
|
||||
strcat(buffer, buf);
|
||||
@@ -321,12 +280,8 @@ static const char* os_name()
|
||||
return "windows";
|
||||
#else
|
||||
FILE *fd = fopen("/proc/version", "r");
|
||||
if (!fd)
|
||||
if (!fd || !fscanf(fd, "Linux version %48s", &os_version[6]))
|
||||
return "linux";
|
||||
if (!fscanf(fd, "Linux version %48s", &os_version[6])) {
|
||||
fclose(fd);
|
||||
return "linux";
|
||||
}
|
||||
fclose(fd);
|
||||
os_version[48] = '\0';
|
||||
return (const char*) os_version;
|
||||
@@ -345,7 +300,7 @@ static void syshwinfos()
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
snprintf(buf, sizeof(buf), "OS=%s;NVDRIVER=%s;CPUS=%d;CPUTEMP=%d;CPUFREQ=%d|",
|
||||
os_name(), driver_version, num_cpus, cputc, cpuclk/1000);
|
||||
os_name(), driver_version, num_cpus, cputc, cpuclk);
|
||||
strcat(buffer, buf);
|
||||
}
|
||||
|
||||
@@ -376,7 +331,7 @@ static char *gethistory(char *params)
|
||||
*buffer = '\0';
|
||||
for (int i = 0; i < records; i++) {
|
||||
time_t ts = data[i].tm_stat;
|
||||
p += sprintf(p, "GPU=%d;H=%u;KHS=%.2f;DIFF=%g;"
|
||||
p += sprintf(p, "GPU=%d;H=%u;KHS=%.2f;DIFF=%.6f;"
|
||||
"COUNT=%u;FOUND=%u;ID=%u;TS=%u|",
|
||||
data[i].gpu_id, data[i].height, data[i].hashrate, data[i].difficulty,
|
||||
data[i].hashcount, data[i].hashfound, data[i].uid, (uint32_t)ts);
|
||||
@@ -385,7 +340,7 @@ static char *gethistory(char *params)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the job scans ranges (debug purpose, only with -D)
|
||||
* Returns the job scans ranges (debug purpose)
|
||||
*/
|
||||
static char *getscanlog(char *params)
|
||||
{
|
||||
@@ -395,11 +350,9 @@ static char *getscanlog(char *params)
|
||||
*buffer = '\0';
|
||||
for (int i = 0; i < records; i++) {
|
||||
time_t ts = data[i].tm_upd;
|
||||
p += sprintf(p, "H=%u;P=%u;JOB=%u;ID=%d;DIFF=%g;"
|
||||
"N=0x%x;FROM=0x%x;SCANTO=0x%x;"
|
||||
p += sprintf(p, "H=%u;P=%u;JOB=%u;N=%u;FROM=0x%x;SCANTO=0x%x;"
|
||||
"COUNT=0x%x;FOUND=%u;TS=%u|",
|
||||
data[i].height, data[i].npool, data[i].njobid, (int)data[i].job_nonce_id, data[i].sharediff,
|
||||
data[i].nonce, data[i].scanned_from, data[i].scanned_to,
|
||||
data[i].height, data[i].npool, data[i].njobid, data[i].nonce, data[i].scanned_from, data[i].scanned_to,
|
||||
(data[i].scanned_to - data[i].scanned_from), data[i].tm_sent ? 1 : 0, (uint32_t)ts);
|
||||
}
|
||||
return buffer;
|
||||
@@ -426,6 +379,15 @@ static char *getmeminfo(char *params)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* Remote control allowed ?
|
||||
* TODO: ip filters
|
||||
*/
|
||||
static bool check_remote_access(void)
|
||||
{
|
||||
return (opt_api_remote > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pool by index (pools array in json config)
|
||||
* switchpool|1|
|
||||
@@ -434,15 +396,17 @@ static char *remote_switchpool(char *params)
|
||||
{
|
||||
bool ret = false;
|
||||
*buffer = '\0';
|
||||
if (!check_remote_access())
|
||||
return buffer;
|
||||
if (!params || strlen(params) == 0) {
|
||||
// rotate pool test
|
||||
ret = pool_switch_next(-1);
|
||||
ret = pool_switch_next();
|
||||
} else {
|
||||
int n = atoi(params);
|
||||
if (n == cur_pooln)
|
||||
ret = true;
|
||||
else if (n < num_pools)
|
||||
ret = pool_switch(-1, n);
|
||||
ret = pool_switch(n);
|
||||
}
|
||||
sprintf(buffer, "%s|", ret ? "ok" : "fail");
|
||||
return buffer;
|
||||
@@ -456,9 +420,11 @@ static char *remote_seturl(char *params)
|
||||
{
|
||||
bool ret;
|
||||
*buffer = '\0';
|
||||
if (!check_remote_access())
|
||||
return buffer;
|
||||
if (!params || strlen(params) == 0) {
|
||||
// rotate pool test
|
||||
ret = pool_switch_next(-1);
|
||||
ret = pool_switch_next();
|
||||
} else {
|
||||
ret = pool_switch_url(params);
|
||||
}
|
||||
@@ -472,6 +438,8 @@ static char *remote_seturl(char *params)
|
||||
static char *remote_quit(char *params)
|
||||
{
|
||||
*buffer = '\0';
|
||||
if (!check_remote_access())
|
||||
return buffer;
|
||||
bye = 1;
|
||||
sprintf(buffer, "%s", "bye|");
|
||||
return buffer;
|
||||
@@ -483,23 +451,22 @@ static char *gethelp(char *params);
|
||||
struct CMDS {
|
||||
const char *name;
|
||||
char *(*func)(char *);
|
||||
bool iswritemode;
|
||||
} cmds[] = {
|
||||
{ "summary", getsummary, false },
|
||||
{ "threads", getthreads, false },
|
||||
{ "pool", getpoolnfo, false },
|
||||
{ "histo", gethistory, false },
|
||||
{ "hwinfo", gethwinfos, false },
|
||||
{ "meminfo", getmeminfo, false },
|
||||
{ "scanlog", getscanlog, false },
|
||||
{ "summary", getsummary },
|
||||
{ "threads", getthreads },
|
||||
{ "pool", getpoolnfo },
|
||||
{ "histo", gethistory },
|
||||
{ "hwinfo", gethwinfos },
|
||||
{ "meminfo", getmeminfo },
|
||||
{ "scanlog", getscanlog },
|
||||
|
||||
/* remote functions */
|
||||
{ "seturl", remote_seturl, true }, /* prefer switchpool, deprecated */
|
||||
{ "switchpool", remote_switchpool, true },
|
||||
{ "quit", remote_quit, true },
|
||||
{ "seturl", remote_seturl }, /* prefer switchpool, deprecated */
|
||||
{ "switchpool", remote_switchpool },
|
||||
{ "quit", remote_quit },
|
||||
|
||||
/* keep it the last */
|
||||
{ "help", gethelp, false },
|
||||
{ "help", gethelp },
|
||||
};
|
||||
#define CMDMAX ARRAY_SIZE(cmds)
|
||||
|
||||
@@ -507,10 +474,8 @@ static char *gethelp(char *params)
|
||||
{
|
||||
*buffer = '\0';
|
||||
char * p = buffer;
|
||||
for (int i = 0; i < CMDMAX-1; i++) {
|
||||
bool displayed = !cmds[i].iswritemode || opt_api_allow;
|
||||
if (displayed) p += sprintf(p, "%s\n", cmds[i].name);
|
||||
}
|
||||
for (int i = 0; i < CMDMAX-1; i++)
|
||||
p += sprintf(p, "%s\n", cmds[i].name);
|
||||
sprintf(p, "|");
|
||||
return buffer;
|
||||
}
|
||||
@@ -673,146 +638,6 @@ static int websocket_handshake(SOCKETTYPE c, char *result, char *clientkey)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Interpret --api-groups G:cmd1:cmd2:cmd3,P:cmd4,*,...
|
||||
*/
|
||||
static void setup_groups()
|
||||
{
|
||||
const char *api_groups = opt_api_groups ? opt_api_groups : "";
|
||||
char *buf, *cmd, *ptr, *next, *colon;
|
||||
char commands[512] = { 0 };
|
||||
char cmdbuf[128] = { 0 };
|
||||
char group;
|
||||
bool addstar;
|
||||
int i;
|
||||
|
||||
buf = (char *)calloc(1, strlen(api_groups) + 1);
|
||||
if (unlikely(!buf))
|
||||
proper_exit(1); //, "Failed to malloc ipgroups buf");
|
||||
|
||||
strcpy(buf, api_groups);
|
||||
|
||||
next = buf;
|
||||
// for each group defined
|
||||
while (next && *next) {
|
||||
ptr = next;
|
||||
next = strchr(ptr, ',');
|
||||
if (next)
|
||||
*(next++) = '\0';
|
||||
|
||||
// Validate the group
|
||||
if (*(ptr+1) != ':') {
|
||||
colon = strchr(ptr, ':');
|
||||
if (colon)
|
||||
*colon = '\0';
|
||||
proper_exit(1); //, "API invalid group name '%s'", ptr);
|
||||
}
|
||||
|
||||
group = GROUP(*ptr);
|
||||
if (!VALIDGROUP(group))
|
||||
proper_exit(1); //, "API invalid group name '%c'", *ptr);
|
||||
|
||||
if (group == PRIVGROUP)
|
||||
proper_exit(1); //, "API group name can't be '%c'", PRIVGROUP);
|
||||
|
||||
if (group == NOPRIVGROUP)
|
||||
proper_exit(1); //, "API group name can't be '%c'", NOPRIVGROUP);
|
||||
|
||||
if (apigroups[GROUPOFFSET(group)].commands != NULL)
|
||||
proper_exit(1); //, "API duplicate group name '%c'", *ptr);
|
||||
|
||||
ptr += 2;
|
||||
|
||||
// Validate the command list (and handle '*')
|
||||
cmd = &(commands[0]);
|
||||
*(cmd++) = '|';
|
||||
*cmd = '\0';
|
||||
addstar = false;
|
||||
while (ptr && *ptr) {
|
||||
colon = strchr(ptr, ':');
|
||||
if (colon)
|
||||
*(colon++) = '\0';
|
||||
|
||||
if (strcmp(ptr, "*") == 0)
|
||||
addstar = true;
|
||||
else {
|
||||
bool did = false;
|
||||
for (i = 0; i < CMDMAX-1; i++) {
|
||||
if (strcasecmp(ptr, cmds[i].name) == 0) {
|
||||
did = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (did) {
|
||||
// skip duplicates
|
||||
sprintf(cmdbuf, "|%s|", cmds[i].name);
|
||||
if (strstr(commands, cmdbuf) == NULL) {
|
||||
strcpy(cmd, cmds[i].name);
|
||||
cmd += strlen(cmds[i].name);
|
||||
*(cmd++) = '|';
|
||||
*cmd = '\0';
|
||||
}
|
||||
} else {
|
||||
proper_exit(1); //, "API unknown command '%s' in group '%c'", ptr, group);
|
||||
}
|
||||
}
|
||||
|
||||
ptr = colon;
|
||||
}
|
||||
|
||||
// * = allow all non-iswritemode commands
|
||||
if (addstar) {
|
||||
for (i = 0; i < CMDMAX-1; i++) {
|
||||
if (cmds[i].iswritemode == false) {
|
||||
// skip duplicates
|
||||
sprintf(cmdbuf, "|%s|", cmds[i].name);
|
||||
if (strstr(commands, cmdbuf) == NULL) {
|
||||
strcpy(cmd, cmds[i].name);
|
||||
cmd += strlen(cmds[i].name);
|
||||
*(cmd++) = '|';
|
||||
*cmd = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ptr = apigroups[GROUPOFFSET(group)].commands = (char *)calloc(1, strlen(commands) + 1);
|
||||
if (unlikely(!ptr))
|
||||
proper_exit(1); //, "Failed to malloc group commands buf");
|
||||
|
||||
strcpy(ptr, commands);
|
||||
}
|
||||
|
||||
// Now define R (NOPRIVGROUP) as all non-iswritemode commands
|
||||
cmd = &(commands[0]);
|
||||
*(cmd++) = '|';
|
||||
*cmd = '\0';
|
||||
for (i = 0; i < CMDMAX-1; i++) {
|
||||
if (cmds[i].iswritemode == false) {
|
||||
strcpy(cmd, cmds[i].name);
|
||||
cmd += strlen(cmds[i].name);
|
||||
*(cmd++) = '|';
|
||||
*cmd = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
ptr = apigroups[GROUPOFFSET(NOPRIVGROUP)].commands = (char *)calloc(1, strlen(commands) + 1);
|
||||
if (unlikely(!ptr))
|
||||
proper_exit(1); //, "Failed to malloc noprivgroup commands buf");
|
||||
|
||||
strcpy(ptr, commands);
|
||||
|
||||
// W (PRIVGROUP) is handled as a special case since it simply means all commands
|
||||
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Interpret [W:]IP[/Prefix][,[R|W:]IP2[/Prefix2][,...]] --api-allow option
|
||||
* special case of 0/0 allows /0 (means all IP addresses)
|
||||
*/
|
||||
#define ALLIPS "0/0"
|
||||
/*
|
||||
* N.B. IP4 addresses are by Definition 32bit big endian on all platforms
|
||||
*/
|
||||
@@ -862,7 +687,7 @@ static void setup_ipaccess()
|
||||
|
||||
ipaccess[ips].group = group;
|
||||
|
||||
if (strcmp(ptr, ALLIPS) == 0 || strcmp(ptr, ALLIP4) == 0)
|
||||
if (strcmp(ptr, ALLIP4) == 0)
|
||||
ipaccess[ips].ip = ipaccess[ips].mask = 0;
|
||||
else
|
||||
{
|
||||
@@ -925,184 +750,16 @@ static bool check_connect(struct sockaddr_in *cli, char **connectaddr, char *gro
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (strcmp(opt_api_bind, ALLIP4) == 0)
|
||||
addrok = true;
|
||||
else
|
||||
addrok = (strcmp(*connectaddr, localaddr) == 0);
|
||||
|
||||
return addrok;
|
||||
}
|
||||
|
||||
static void mcast()
|
||||
{
|
||||
struct sockaddr_in listen;
|
||||
struct ip_mreq grp;
|
||||
struct sockaddr_in came_from;
|
||||
time_t bindstart;
|
||||
char *binderror;
|
||||
SOCKETTYPE mcast_sock;
|
||||
SOCKETTYPE reply_sock;
|
||||
socklen_t came_from_siz;
|
||||
char *connectaddr;
|
||||
ssize_t rep;
|
||||
int bound;
|
||||
int count;
|
||||
int reply_port;
|
||||
bool addrok;
|
||||
char group;
|
||||
|
||||
char expect[] = "ccminer-"; // first 8 bytes constant
|
||||
char *expect_code;
|
||||
size_t expect_code_len;
|
||||
char buf[1024];
|
||||
char replybuf[1024];
|
||||
|
||||
memset(&grp, 0, sizeof(grp));
|
||||
grp.imr_multiaddr.s_addr = inet_addr(opt_api_mcast_addr);
|
||||
if (grp.imr_multiaddr.s_addr == INADDR_NONE)
|
||||
proper_exit(1); //, "Invalid Multicast Address");
|
||||
grp.imr_interface.s_addr = INADDR_ANY;
|
||||
|
||||
mcast_sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
|
||||
int optval = 1;
|
||||
if (SOCKETFAIL(setsockopt(mcast_sock, SOL_SOCKET, SO_REUSEADDR, (const char *)(&optval), sizeof(optval)))) {
|
||||
applog(LOG_ERR, "API mcast setsockopt SO_REUSEADDR failed (%s)%s", strerror(errno), MUNAVAILABLE);
|
||||
goto die;
|
||||
}
|
||||
|
||||
memset(&listen, 0, sizeof(listen));
|
||||
listen.sin_family = AF_INET;
|
||||
listen.sin_addr.s_addr = INADDR_ANY;
|
||||
listen.sin_port = htons(opt_api_mcast_port);
|
||||
|
||||
// try for more than 1 minute ... in case the old one hasn't completely gone yet
|
||||
bound = 0;
|
||||
bindstart = time(NULL);
|
||||
while (bound == 0) {
|
||||
if (SOCKETFAIL(bind(mcast_sock, (struct sockaddr *)(&listen), sizeof(listen)))) {
|
||||
binderror = strerror(errno);;
|
||||
if ((time(NULL) - bindstart) > 61)
|
||||
break;
|
||||
else
|
||||
sleep(30);
|
||||
}
|
||||
else
|
||||
bound = 1;
|
||||
}
|
||||
|
||||
if (bound == 0) {
|
||||
applog(LOG_ERR, "API mcast bind to port %d failed (%s)%s", opt_api_port, binderror, MUNAVAILABLE);
|
||||
goto die;
|
||||
}
|
||||
|
||||
if (SOCKETFAIL(setsockopt(mcast_sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char *)(&grp), sizeof(grp)))) {
|
||||
applog(LOG_ERR, "API mcast join failed (%s)%s", strerror(errno), MUNAVAILABLE);
|
||||
goto die;
|
||||
}
|
||||
|
||||
expect_code_len = sizeof(expect) + strlen(opt_api_mcast_code);
|
||||
expect_code = (char *)calloc(1, expect_code_len + 1);
|
||||
if (!expect_code)
|
||||
proper_exit(1); //, "Failed to malloc mcast expect_code");
|
||||
snprintf(expect_code, expect_code_len + 1, "%s%s-", expect, opt_api_mcast_code);
|
||||
|
||||
count = 0;
|
||||
while (42) {
|
||||
sleep(1);
|
||||
|
||||
count++;
|
||||
came_from_siz = sizeof(came_from);
|
||||
if (SOCKETFAIL(rep = recvfrom(mcast_sock, buf, sizeof(buf) - 1,
|
||||
0, (struct sockaddr *)(&came_from), &came_from_siz))) {
|
||||
applog(LOG_DEBUG, "API mcast failed count=%d (%s) (%d)",
|
||||
count, strerror(errno), (int)mcast_sock);
|
||||
continue;
|
||||
}
|
||||
|
||||
addrok = check_connect(&came_from, &connectaddr, &group);
|
||||
applog(LOG_DEBUG, "API mcast from %s - %s",
|
||||
connectaddr, addrok ? "Accepted" : "Ignored");
|
||||
if (!addrok) {
|
||||
continue;
|
||||
}
|
||||
|
||||
buf[rep] = '\0';
|
||||
if (rep > 0 && buf[rep - 1] == '\n')
|
||||
buf[--rep] = '\0';
|
||||
|
||||
applog(LOG_DEBUG, "API mcast request rep=%d (%s) from %s:%d",
|
||||
(int)rep, buf,
|
||||
inet_ntoa(came_from.sin_addr),
|
||||
ntohs(came_from.sin_port));
|
||||
|
||||
if ((size_t)rep > expect_code_len && memcmp(buf, expect_code, expect_code_len) == 0) {
|
||||
reply_port = atoi(&buf[expect_code_len]);
|
||||
if (reply_port < 1 || reply_port > 65535) {
|
||||
applog(LOG_DEBUG, "API mcast request ignored - invalid port (%s)",
|
||||
&buf[expect_code_len]);
|
||||
}
|
||||
else {
|
||||
applog(LOG_DEBUG, "API mcast request OK port %s=%d",
|
||||
&buf[expect_code_len], reply_port);
|
||||
|
||||
came_from.sin_port = htons(reply_port);
|
||||
reply_sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
|
||||
snprintf(replybuf, sizeof(replybuf),
|
||||
"ccm-%s-%d-%s", opt_api_mcast_code, opt_api_port, opt_api_mcast_des);
|
||||
|
||||
rep = sendto(reply_sock, replybuf, (int) strlen(replybuf) + 1,
|
||||
0, (struct sockaddr *)(&came_from), (int) sizeof(came_from));
|
||||
if (SOCKETFAIL(rep)) {
|
||||
applog(LOG_DEBUG, "API mcast send reply failed (%s) (%d)",
|
||||
strerror(errno), (int)reply_sock);
|
||||
} else {
|
||||
applog(LOG_DEBUG, "API mcast send reply (%s) succeeded (%d) (%d)",
|
||||
replybuf, (int)rep, (int)reply_sock);
|
||||
}
|
||||
|
||||
CLOSESOCKET(reply_sock);
|
||||
}
|
||||
}
|
||||
else
|
||||
applog(LOG_DEBUG, "API mcast request was no good");
|
||||
}
|
||||
|
||||
die:
|
||||
CLOSESOCKET(mcast_sock);
|
||||
}
|
||||
|
||||
static void *mcast_thread(void *userdata)
|
||||
{
|
||||
struct thr_info *mythr = (struct thr_info *)userdata;
|
||||
|
||||
pthread_detach(pthread_self());
|
||||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
|
||||
|
||||
mcast();
|
||||
|
||||
//PTH(mythr) = 0L;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void mcast_init()
|
||||
{
|
||||
struct thr_info *thr;
|
||||
|
||||
thr = (struct thr_info *)calloc(1, sizeof(*thr));
|
||||
if (!thr)
|
||||
proper_exit(1); //, "Failed to calloc mcast thr");
|
||||
|
||||
if (unlikely(pthread_create(&thr->pth, NULL, mcast_thread, thr)))
|
||||
proper_exit(1); //, "API mcast thread create failed");
|
||||
}
|
||||
|
||||
static void api()
|
||||
{
|
||||
const char *addr = opt_api_bind;
|
||||
unsigned short port = (unsigned short) opt_api_port; // 4068
|
||||
const char *addr = opt_api_allow;
|
||||
unsigned short port = (unsigned short) opt_api_listen; // 4068
|
||||
char buf[MYBUFSIZ];
|
||||
int n, bound;
|
||||
char *connectaddr;
|
||||
@@ -1120,13 +777,11 @@ static void api()
|
||||
|
||||
SOCKETTYPE c;
|
||||
SOCKETTYPE *apisock;
|
||||
if (!opt_api_port && opt_debug) {
|
||||
if (!opt_api_listen && opt_debug) {
|
||||
applog(LOG_DEBUG, "API disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
setup_groups();
|
||||
|
||||
if (opt_api_allow) {
|
||||
setup_ipaccess();
|
||||
if (ips == 0) {
|
||||
@@ -1147,10 +802,9 @@ static void api()
|
||||
|
||||
memset(&serv, 0, sizeof(serv));
|
||||
serv.sin_family = AF_INET;
|
||||
serv.sin_addr.s_addr = inet_addr(addr); // TODO: allow bind to ip/interface
|
||||
serv.sin_addr.s_addr = inet_addr(addr);
|
||||
if (serv.sin_addr.s_addr == (in_addr_t)INVINETADDR) {
|
||||
applog(LOG_ERR, "API initialisation 2 failed (%s)%s", strerror(errno), UNAVAILABLE);
|
||||
// free(apisock); FIXME!!
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1178,7 +832,7 @@ static void api()
|
||||
binderror = strerror(errno);
|
||||
if ((time(NULL) - bindstart) > 61)
|
||||
break;
|
||||
else if (opt_api_port == 4068) {
|
||||
else if (opt_api_listen == 4068) {
|
||||
/* when port is default one, use first available */
|
||||
if (opt_debug)
|
||||
applog(LOG_DEBUG, "API bind to port %d failed, trying port %u",
|
||||
@@ -1195,10 +849,10 @@ static void api()
|
||||
}
|
||||
else {
|
||||
bound = 1;
|
||||
if (opt_api_port != port) {
|
||||
if (opt_api_listen != port) {
|
||||
applog(LOG_WARNING, "API bind to port %d failed - using port %u",
|
||||
opt_api_port, (uint32_t)port);
|
||||
opt_api_port = port;
|
||||
opt_api_listen, (uint32_t) port);
|
||||
opt_api_listen = port;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1216,20 +870,10 @@ static void api()
|
||||
return;
|
||||
}
|
||||
|
||||
if (opt_api_allow && strcmp(opt_api_bind, "127.0.0.1") == 0)
|
||||
applog(LOG_WARNING, "API open locally in full access mode on port %d", opt_api_port);
|
||||
else if (opt_api_allow)
|
||||
applog(LOG_WARNING, "API open in full access mode to %s on port %d", opt_api_allow, opt_api_port);
|
||||
else if (strcmp(opt_api_bind, "127.0.0.1") != 0)
|
||||
applog(LOG_INFO, "API open to the network in read-only mode on port %d", opt_api_port);
|
||||
|
||||
if (opt_api_mcast)
|
||||
mcast_init();
|
||||
|
||||
buffer = (char *) calloc(1, MYBUFSIZ + 1);
|
||||
|
||||
counter = 0;
|
||||
while (bye == 0 && !abort_flag) {
|
||||
while (bye == 0) {
|
||||
counter++;
|
||||
|
||||
clisiz = sizeof(cli);
|
||||
@@ -1252,7 +896,7 @@ static void api()
|
||||
char *wskey = NULL;
|
||||
n = recv(c, &buf[0], SOCK_REC_BUFSZ, 0);
|
||||
|
||||
fail = SOCKETFAIL(n) || n < 0;
|
||||
fail = SOCKETFAIL(n);
|
||||
if (fail)
|
||||
buf[0] = '\0';
|
||||
else if (n > 0 && buf[n-1] == '\n') {
|
||||
@@ -1261,7 +905,7 @@ static void api()
|
||||
if (n > 0 && buf[n-1] == '\r')
|
||||
buf[n-1] = '\0';
|
||||
}
|
||||
else buf[n] = '\0';
|
||||
buf[n] = '\0';
|
||||
|
||||
//if (opt_debug && opt_protocol && n > 0)
|
||||
// applog(LOG_DEBUG, "API: recv command: (%d) '%s'+char(%x)", n, buf, buf[n-1]);
|
||||
@@ -1312,8 +956,8 @@ static void api()
|
||||
break;
|
||||
}
|
||||
}
|
||||
CLOSESOCKET(c);
|
||||
}
|
||||
CLOSESOCKET(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1342,12 +986,17 @@ void *api_thread(void *userdata)
|
||||
/* to be able to report the default value set in each algo */
|
||||
void api_set_throughput(int thr_id, uint32_t throughput)
|
||||
{
|
||||
if (thr_id < MAX_GPUS && thr_info) {
|
||||
if (&thr_info[thr_id]) {
|
||||
struct cgpu_info *cgpu = &thr_info[thr_id].gpu;
|
||||
cgpu->intensity = throughput2intensity(throughput);
|
||||
if (cgpu->throughput != throughput) cgpu->throughput = throughput;
|
||||
uint32_t ws = throughput;
|
||||
uint8_t i = 0;
|
||||
cgpu->throughput = throughput;
|
||||
while (ws > 1 && i++ < 32)
|
||||
ws = ws >> 1;
|
||||
cgpu->intensity_int = i;
|
||||
cgpu->intensity = (float) i;
|
||||
if (i && (1U << i) < throughput) {
|
||||
cgpu->intensity += ((float) (throughput-(1U << i)) / (1U << i));
|
||||
}
|
||||
}
|
||||
// to display in bench results
|
||||
if (opt_benchmark)
|
||||
bench_set_throughput(thr_id, throughput);
|
||||
}
|
||||
+6
-27
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* ccminer API sample UI (API 1.9) */
|
||||
/* ccminer API sample UI (API 1.5) */
|
||||
|
||||
$host = 'http://localhost/api/'; // 'http://'.$_SERVER['SERVER_NAME'].'/api/';
|
||||
$configs = array(
|
||||
@@ -28,7 +28,7 @@ function ignoreField($key)
|
||||
{
|
||||
$ignored = array(
|
||||
'API','VER','GPU','BUS','POOLS',
|
||||
'CARD','GPUS','CPU','TS','URL',
|
||||
'CARD','GPUS','CPU','TS',
|
||||
);
|
||||
return in_array($key, $ignored);
|
||||
}
|
||||
@@ -46,10 +46,6 @@ function translateField($key)
|
||||
$intl['ACC'] = 'Accepted shares';
|
||||
$intl['ACCMN'] = 'Accepted / mn';
|
||||
$intl['REJ'] = 'Rejected';
|
||||
$intl['SOLV'] = 'Solved';
|
||||
$intl['BEST'] = 'Best share';
|
||||
$intl['STALE'] = 'Stale shares';
|
||||
$intl['LAST'] = 'Last share';
|
||||
$intl['DIFF'] = 'Difficulty';
|
||||
$intl['NETKHS'] = 'Net Rate';
|
||||
$intl['UPTIME'] = 'Miner up time';
|
||||
@@ -57,22 +53,15 @@ function translateField($key)
|
||||
$intl['THR'] = 'Throughput';
|
||||
$intl['WAIT'] = 'Wait time';
|
||||
|
||||
|
||||
$intl['H'] = 'Bloc height';
|
||||
$intl['I'] = 'Intensity';
|
||||
$intl['HWF'] = 'Failures';
|
||||
$intl['POOL'] = 'Pool';
|
||||
$intl['POOLS'] = 'Pools';
|
||||
|
||||
$intl['TEMP'] = 'T°c';
|
||||
$intl['FAN'] = 'Fan %';
|
||||
$intl['CPUFREQ'] = 'CPU Freq.';
|
||||
$intl['FREQ'] = 'Base Freq.';
|
||||
$intl['MEMFREQ'] = 'Mem. Freq.';
|
||||
$intl['GPUF'] = 'Curr Freq.';
|
||||
$intl['MEMF'] = 'Mem. Freq.';
|
||||
$intl['KHW'] = 'Efficiency';
|
||||
$intl['POWER'] = 'Power';
|
||||
$intl['PLIM'] = 'P.Limit';
|
||||
$intl['FREQ'] = 'Freq.';
|
||||
$intl['PST'] = 'P-State';
|
||||
|
||||
// pool infos
|
||||
@@ -104,15 +93,8 @@ function translateValue($key,$val,$data=array())
|
||||
case 'NAME':
|
||||
$val = $data['NAME'].' '.$data['VER'];
|
||||
break;
|
||||
case 'CPUFREQ':
|
||||
case 'FREQ':
|
||||
case 'MEMFREQ':
|
||||
case 'GPUF':
|
||||
case 'MEMF':
|
||||
$val = sprintf("%d MHz", $val);
|
||||
break;
|
||||
case 'POWER':
|
||||
$val = sprintf("%d W", round(floatval($val)/1000.0));
|
||||
$val = sprintf("%d MHz", round(floatval($val)/1000.0));
|
||||
break;
|
||||
case 'TS':
|
||||
$val = strftime("%H:%M:%S", (int) $val);
|
||||
@@ -121,9 +103,6 @@ function translateValue($key,$val,$data=array())
|
||||
case 'NETKHS':
|
||||
$val = '<span class="bold">'.$val.'</span> kH/s';
|
||||
break;
|
||||
case 'KHW':
|
||||
$val = $val.' kH/W';
|
||||
break;
|
||||
case 'NAME':
|
||||
case 'POOL';
|
||||
case 'USER':
|
||||
@@ -248,7 +227,7 @@ div#footer {
|
||||
#header h1 { padding: 12px; font-size: 20px; }
|
||||
#footer p { margin: 12px 24px; }
|
||||
|
||||
table.stats { width: 280px; margin: 4px 16px; display: inline-block; vertical-align: top; }
|
||||
table.stats { width: 280px; margin: 4px 16px; display: inline-block; }
|
||||
th.machine { color: darkcyan; padding: 16px 0px 0px 0px; text-align: left; border-bottom: 1px solid gray; }
|
||||
th.gpu { color: white; padding: 3px 3px; font: bolder; text-align: left; background: rgba(65, 65, 65, 0.85); }
|
||||
td.key { width: 99px; max-width: 180px; }
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# sample script to query ccminer API
|
||||
|
||||
my $command = "summary|";
|
||||
|
||||
use Socket;
|
||||
use IO::Socket::INET;
|
||||
|
||||
my $sock = new IO::Socket::INET (
|
||||
PeerAddr => '127.0.0.1',
|
||||
PeerPort => 4068,
|
||||
Proto => 'tcp',
|
||||
ReuseAddr => 1,
|
||||
Timeout => 10,
|
||||
);
|
||||
|
||||
if ($sock) {
|
||||
|
||||
print $sock $command;
|
||||
my $res = "";
|
||||
|
||||
while(<$sock>) {
|
||||
$res .= $_;
|
||||
}
|
||||
|
||||
close($sock);
|
||||
print("$res\n");
|
||||
|
||||
} else {
|
||||
|
||||
print("ccminer socket failed\n");
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
<script src="http://code.highcharts.com/highcharts.js"></script>
|
||||
<script src="http://code.highcharts.com/modules/exporting.js"></script>
|
||||
</head>
|
||||
|
||||
@@ -1,265 +0,0 @@
|
||||
/**
|
||||
* Made to benchmark and test algo switch
|
||||
*
|
||||
* 2015 - tpruvot@github
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "miner.h"
|
||||
#include "algos.h"
|
||||
#include <cuda_runtime.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "compat/pthreads/pthread_barrier.hpp"
|
||||
#endif
|
||||
|
||||
int bench_algo = -1;
|
||||
|
||||
static double algo_hashrates[MAX_GPUS][ALGO_COUNT] = { 0 };
|
||||
static uint32_t algo_throughput[MAX_GPUS][ALGO_COUNT] = { 0 };
|
||||
static int algo_mem_used[MAX_GPUS][ALGO_COUNT] = { 0 };
|
||||
static int device_mem_free[MAX_GPUS] = { 0 };
|
||||
|
||||
static pthread_barrier_t miner_barr;
|
||||
static pthread_barrier_t algo_barr;
|
||||
static pthread_mutex_t bench_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
extern double thr_hashrates[MAX_GPUS];
|
||||
|
||||
void bench_init(int threads)
|
||||
{
|
||||
bench_algo = opt_algo = (enum sha_algos) 0; /* first */
|
||||
applog(LOG_BLUE, "Starting benchmark mode with %s", algo_names[opt_algo]);
|
||||
pthread_barrier_init(&miner_barr, NULL, threads);
|
||||
pthread_barrier_init(&algo_barr, NULL, threads);
|
||||
// required for usage of first algo.
|
||||
for (int n=0; n < opt_n_threads; n++) {
|
||||
device_mem_free[n] = cuda_available_memory(n);
|
||||
}
|
||||
}
|
||||
|
||||
void bench_free()
|
||||
{
|
||||
pthread_barrier_destroy(&miner_barr);
|
||||
pthread_barrier_destroy(&algo_barr);
|
||||
}
|
||||
|
||||
// required to switch algos
|
||||
void algo_free_all(int thr_id)
|
||||
{
|
||||
// only initialized algos will be freed
|
||||
free_allium(thr_id);
|
||||
free_bastion(thr_id);
|
||||
free_bitcore(thr_id);
|
||||
free_blake256(thr_id);
|
||||
free_blake2b(thr_id);
|
||||
free_blake2s(thr_id);
|
||||
free_bmw(thr_id);
|
||||
free_c11(thr_id);
|
||||
free_cryptolight(thr_id);
|
||||
free_cryptonight(thr_id);
|
||||
free_decred(thr_id);
|
||||
free_deep(thr_id);
|
||||
free_equihash(thr_id);
|
||||
free_exosis(thr_id);
|
||||
free_keccak256(thr_id);
|
||||
free_fresh(thr_id);
|
||||
free_fugue256(thr_id);
|
||||
free_groestlcoin(thr_id);
|
||||
#ifdef WITH_HEAVY_ALGO
|
||||
free_heavy(thr_id);
|
||||
#endif
|
||||
free_hmq17(thr_id);
|
||||
free_hsr(thr_id);
|
||||
free_jackpot(thr_id);
|
||||
free_jha(thr_id);
|
||||
free_lbry(thr_id);
|
||||
free_luffa(thr_id);
|
||||
free_lyra2(thr_id);
|
||||
free_lyra2v2(thr_id);
|
||||
free_lyra2v3(thr_id);
|
||||
free_lyra2Z(thr_id);
|
||||
free_myriad(thr_id);
|
||||
free_neoscrypt(thr_id);
|
||||
free_nist5(thr_id);
|
||||
free_pentablake(thr_id);
|
||||
free_phi(thr_id);
|
||||
free_phi2(thr_id);
|
||||
free_polytimos(thr_id);
|
||||
free_quark(thr_id);
|
||||
free_qubit(thr_id);
|
||||
free_skeincoin(thr_id);
|
||||
free_skein2(thr_id);
|
||||
free_skunk(thr_id);
|
||||
free_sha256d(thr_id);
|
||||
free_sha256t(thr_id);
|
||||
free_sha256q(thr_id);
|
||||
free_sia(thr_id);
|
||||
free_sib(thr_id);
|
||||
free_sonoa(thr_id);
|
||||
free_s3(thr_id);
|
||||
free_vanilla(thr_id);
|
||||
free_veltor(thr_id);
|
||||
free_whirl(thr_id);
|
||||
//free_whirlx(thr_id);
|
||||
free_wildkeccak(thr_id);
|
||||
free_x11evo(thr_id);
|
||||
free_x11(thr_id);
|
||||
free_x12(thr_id);
|
||||
free_x13(thr_id);
|
||||
free_x14(thr_id);
|
||||
free_x15(thr_id);
|
||||
free_x16r(thr_id);
|
||||
free_x16s(thr_id);
|
||||
free_x17(thr_id);
|
||||
free_zr5(thr_id);
|
||||
free_scrypt(thr_id);
|
||||
free_scrypt_jane(thr_id);
|
||||
free_timetravel(thr_id);
|
||||
free_tribus(thr_id);
|
||||
free_bitcore(thr_id);
|
||||
}
|
||||
|
||||
// benchmark all algos (called once per mining thread)
|
||||
bool bench_algo_switch_next(int thr_id)
|
||||
{
|
||||
int algo = (int) opt_algo;
|
||||
int prev_algo = algo;
|
||||
int dev_id = device_map[thr_id % MAX_GPUS];
|
||||
int mfree, mused;
|
||||
// doesnt seems enough to prevent device slow down
|
||||
// after some algo switchs
|
||||
bool need_reset = (gpu_threads == 1);
|
||||
|
||||
algo++;
|
||||
|
||||
// skip some duplicated algos
|
||||
if (algo == ALGO_C11) algo++; // same as x11
|
||||
if (algo == ALGO_DMD_GR) algo++; // same as groestl
|
||||
if (algo == ALGO_HEAVY) algo++; // dead
|
||||
if (algo == ALGO_MJOLLNIR) algo++; // same as heavy
|
||||
if (algo == ALGO_KECCAKC) algo++; // same as keccak
|
||||
if (algo == ALGO_WHIRLCOIN) algo++; // same as whirlpool
|
||||
if (algo == ALGO_WHIRLPOOLX) algo++; // disabled
|
||||
// todo: algo switch from RPC 2.0
|
||||
if (algo == ALGO_CRYPTOLIGHT) algo++;
|
||||
if (algo == ALGO_CRYPTONIGHT) algo++;
|
||||
if (algo == ALGO_WILDKECCAK) algo++;
|
||||
if (algo == ALGO_QUARK) algo++; // to fix
|
||||
if (algo == ALGO_LBRY && CUDART_VERSION < 7000) algo++;
|
||||
|
||||
if (device_sm[dev_id] && device_sm[dev_id] < 300) {
|
||||
// incompatible SM 2.1 kernels...
|
||||
if (algo == ALGO_GROESTL) algo++;
|
||||
if (algo == ALGO_MYR_GR) algo++;
|
||||
if (algo == ALGO_NEOSCRYPT) algo++;
|
||||
if (algo == ALGO_WHIRLPOOLX) algo++;
|
||||
}
|
||||
// and unwanted ones...
|
||||
if (algo == ALGO_SCRYPT) algo++;
|
||||
if (algo == ALGO_SCRYPT_JANE) algo++;
|
||||
|
||||
// Set cryptonight variant
|
||||
switch (algo) {
|
||||
case ALGO_MONERO:
|
||||
cryptonight_fork = 7;
|
||||
break;
|
||||
case ALGO_GRAFT:
|
||||
cryptonight_fork = 8;
|
||||
break;
|
||||
case ALGO_STELLITE:
|
||||
cryptonight_fork = 3;
|
||||
break;
|
||||
case ALGO_CRYPTONIGHT:
|
||||
cryptonight_fork = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// free current algo memory and track mem usage
|
||||
mused = cuda_available_memory(thr_id);
|
||||
algo_free_all(thr_id);
|
||||
CUDA_LOG_ERROR();
|
||||
|
||||
// device can take some time to free
|
||||
mfree = cuda_available_memory(thr_id);
|
||||
if (device_mem_free[thr_id] > mfree) {
|
||||
sleep(1);
|
||||
mfree = cuda_available_memory(thr_id);
|
||||
}
|
||||
|
||||
// we need to wait completion on all cards before the switch
|
||||
if (opt_n_threads > 1) {
|
||||
pthread_barrier_wait(&miner_barr);
|
||||
}
|
||||
|
||||
char rate[32] = { 0 };
|
||||
double hashrate = stats_get_speed(thr_id, thr_hashrates[thr_id]);
|
||||
format_hashrate(hashrate, rate);
|
||||
gpulog(LOG_NOTICE, thr_id, "%s hashrate = %s", algo_names[prev_algo], rate);
|
||||
|
||||
// ensure memory leak is still real after the barrier
|
||||
if (device_mem_free[thr_id] > mfree) {
|
||||
mfree = cuda_available_memory(thr_id);
|
||||
}
|
||||
|
||||
// check if there is memory leak
|
||||
if (device_mem_free[thr_id] - mfree > 1) {
|
||||
gpulog(LOG_WARNING, thr_id, "possible %d MB memory leak in %s! %d MB free",
|
||||
(device_mem_free[thr_id] - mfree), algo_names[prev_algo], mfree);
|
||||
cuda_reset_device(thr_id, NULL); // force to free the leak
|
||||
need_reset = false;
|
||||
mfree = cuda_available_memory(thr_id);
|
||||
}
|
||||
// store used memory per algo
|
||||
algo_mem_used[thr_id][opt_algo] = device_mem_free[thr_id] - mused;
|
||||
device_mem_free[thr_id] = mfree;
|
||||
|
||||
// store to dump a table per gpu later
|
||||
algo_hashrates[thr_id][prev_algo] = hashrate;
|
||||
|
||||
// wait the other threads to display logs correctly
|
||||
if (opt_n_threads > 1) {
|
||||
pthread_barrier_wait(&algo_barr);
|
||||
}
|
||||
|
||||
if (algo == ALGO_AUTO)
|
||||
return false; // all algos done
|
||||
|
||||
// mutex primary used for the stats purge
|
||||
pthread_mutex_lock(&bench_lock);
|
||||
stats_purge_all();
|
||||
|
||||
opt_algo = (enum sha_algos) algo;
|
||||
global_hashrate = 0;
|
||||
thr_hashrates[thr_id] = 0; // reset for minmax64
|
||||
pthread_mutex_unlock(&bench_lock);
|
||||
|
||||
if (need_reset)
|
||||
cuda_reset_device(thr_id, NULL);
|
||||
|
||||
if (thr_id == 0)
|
||||
applog(LOG_BLUE, "Benchmark algo %s...", algo_names[algo]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void bench_set_throughput(int thr_id, uint32_t throughput)
|
||||
{
|
||||
algo_throughput[thr_id][opt_algo] = throughput;
|
||||
}
|
||||
|
||||
void bench_display_results()
|
||||
{
|
||||
for (int n=0; n < opt_n_threads; n++)
|
||||
{
|
||||
int dev_id = device_map[n];
|
||||
applog(LOG_BLUE, "Benchmark results for GPU #%d - %s:", dev_id, device_name[dev_id]);
|
||||
for (int i=0; i < ALGO_COUNT-1; i++) {
|
||||
double rate = algo_hashrates[n][i];
|
||||
if (rate == 0.0) continue;
|
||||
applog(LOG_INFO, "%12s : %12.1f kH/s, %5d MB, %8u thr.", algo_names[i],
|
||||
rate / 1024., algo_mem_used[n][i], algo_throughput[n][i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
-100
@@ -1,100 +0,0 @@
|
||||
/**
|
||||
* Wrapper to OpenSSL BIGNUM used by net diff (nBits)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "uint256.h"
|
||||
|
||||
#include <openssl/opensslv.h>
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
#include "compat/bignum_ssl10.hpp"
|
||||
#else
|
||||
#include "bignum.hpp"
|
||||
#endif
|
||||
|
||||
#include "miner.h" // hex2bin
|
||||
|
||||
extern "C" double bn_convert_nbits(const uint32_t nBits)
|
||||
{
|
||||
uint256 bn = CBigNum().SetCompact(nBits).getuint256();
|
||||
return bn.getdouble();
|
||||
}
|
||||
|
||||
// copy the big number to 32-bytes uchar
|
||||
extern "C" void bn_nbits_to_uchar(const uint32_t nBits, unsigned char *target)
|
||||
{
|
||||
char buff[65];
|
||||
uint256 bn = CBigNum().SetCompact(nBits).getuint256();
|
||||
|
||||
snprintf(buff, 65, "%s\n", bn.ToString().c_str()); buff[64] = '\0';
|
||||
hex2bin(target, buff, 32);
|
||||
}
|
||||
|
||||
// unused, but should allow more than 256bits targets
|
||||
#if 0
|
||||
extern "C" double bn_hash_target_ratio(uint32_t* hash, uint32_t* target)
|
||||
{
|
||||
double dhash;
|
||||
|
||||
if (!opt_showdiff)
|
||||
return 0.0;
|
||||
|
||||
CBigNum h(0), t(0);
|
||||
std::vector<unsigned char> vch(32);
|
||||
|
||||
memcpy(&vch[0], (void*) target, 32);
|
||||
t.setvch(vch);
|
||||
memcpy(&vch[0], (void*) hash, 32);
|
||||
h.setvch(vch);
|
||||
|
||||
dhash = h.getuint256().getdouble();
|
||||
if (dhash > 0.)
|
||||
return t.getuint256().getdouble() / dhash;
|
||||
else
|
||||
return dhash;
|
||||
}
|
||||
#endif
|
||||
|
||||
// compute the diff ratio between a found hash and the target
|
||||
extern "C" double bn_hash_target_ratio(uint32_t* hash, uint32_t* target)
|
||||
{
|
||||
uint256 h, t;
|
||||
double dhash;
|
||||
|
||||
if (!opt_showdiff)
|
||||
return 0.0;
|
||||
|
||||
memcpy(&t, (void*) target, 32);
|
||||
memcpy(&h, (void*) hash, 32);
|
||||
|
||||
dhash = h.getdouble();
|
||||
if (dhash > 0.)
|
||||
return t.getdouble() / dhash;
|
||||
else
|
||||
return dhash;
|
||||
}
|
||||
|
||||
// store ratio in work struct
|
||||
extern "C" void bn_store_hash_target_ratio(uint32_t* hash, uint32_t* target, struct work* work, int nonce)
|
||||
{
|
||||
// only if the option is enabled (to reduce cpu usage)
|
||||
if (!opt_showdiff) return;
|
||||
if (nonce < 0 || nonce >= MAX_NONCES) return;
|
||||
|
||||
work->shareratio[nonce] = bn_hash_target_ratio(hash, target);
|
||||
work->sharediff[nonce] = work->targetdiff * work->shareratio[nonce];
|
||||
}
|
||||
|
||||
// new method to save all nonce(s) share diff/ration
|
||||
extern "C" void bn_set_target_ratio(struct work* work, uint32_t* hash, int nonce)
|
||||
{
|
||||
bn_store_hash_target_ratio(hash, work->target, work, nonce);
|
||||
}
|
||||
|
||||
// compat (only store single nonce share diff per work)
|
||||
extern "C" void work_set_target_ratio(struct work* work, uint32_t* hash)
|
||||
{
|
||||
bn_store_hash_target_ratio(hash, work->target, work, work->submit_nonce_id);
|
||||
}
|
||||
|
||||
-584
@@ -1,584 +0,0 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#ifndef BITCOIN_BIGNUM_H
|
||||
#define BITCOIN_BIGNUM_H
|
||||
|
||||
#ifndef PROTOCOL_VERSION
|
||||
#define PROTOCOL_VERSION 70001
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
#include <openssl/bn.h>
|
||||
|
||||
#include "serialize.hpp"
|
||||
|
||||
/** Errors thrown by the bignum class */
|
||||
class bignum_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit bignum_error(const std::string& str) : std::runtime_error(str) {}
|
||||
};
|
||||
|
||||
|
||||
/** RAII encapsulated BN_CTX (OpenSSL bignum context) */
|
||||
class CAutoBN_CTX
|
||||
{
|
||||
protected:
|
||||
BN_CTX* pctx;
|
||||
BN_CTX* operator=(BN_CTX* pnew) { return pctx = pnew; }
|
||||
|
||||
public:
|
||||
CAutoBN_CTX()
|
||||
{
|
||||
pctx = BN_CTX_new();
|
||||
if (pctx == NULL)
|
||||
throw bignum_error("CAutoBN_CTX : BN_CTX_new() returned NULL");
|
||||
}
|
||||
|
||||
~CAutoBN_CTX()
|
||||
{
|
||||
if (pctx != NULL)
|
||||
BN_CTX_free(pctx);
|
||||
}
|
||||
|
||||
operator BN_CTX*() { return pctx; }
|
||||
BN_CTX& operator*() { return *pctx; }
|
||||
BN_CTX** operator&() { return &pctx; }
|
||||
bool operator!() { return (pctx == NULL); }
|
||||
};
|
||||
|
||||
|
||||
/** C++ wrapper for BIGNUM (OpenSSL bignum) */
|
||||
class CBigNum
|
||||
{
|
||||
private:
|
||||
BIGNUM *self = NULL;
|
||||
|
||||
void init()
|
||||
{
|
||||
if (self)
|
||||
BN_clear_free(self);
|
||||
self = BN_new();
|
||||
if (!self)
|
||||
throw bignum_error("CBigNum::init(): BN_new() returned NULL");
|
||||
}
|
||||
|
||||
public:
|
||||
BIGNUM *get() { return self; }
|
||||
const BIGNUM *getc() const { return self; }
|
||||
|
||||
CBigNum()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
CBigNum(const CBigNum& b)
|
||||
{
|
||||
init();
|
||||
if (!BN_copy(self, b.getc()))
|
||||
{
|
||||
BN_clear_free(self);
|
||||
throw bignum_error("CBigNum::CBigNum(const CBigNum&) : BN_copy failed");
|
||||
}
|
||||
}
|
||||
|
||||
CBigNum& operator=(const CBigNum& b)
|
||||
{
|
||||
if (!BN_copy(self, b.getc()))
|
||||
throw bignum_error("CBigNum::operator= : BN_copy failed");
|
||||
return (*this);
|
||||
}
|
||||
|
||||
~CBigNum()
|
||||
{
|
||||
BN_clear_free(self);
|
||||
}
|
||||
|
||||
//CBigNum(char n) is not portable. Use 'signed char' or 'unsigned char'.
|
||||
CBigNum(signed char n) { init(); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(short n) { init(); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(int n) { init(); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(long n) { init(); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(int64 n) { init(); setint64(n); }
|
||||
CBigNum(unsigned char n) { init(); setulong(n); }
|
||||
CBigNum(unsigned short n) { init(); setulong(n); }
|
||||
CBigNum(unsigned int n) { init(); setulong(n); }
|
||||
CBigNum(unsigned long n) { init(); setulong(n); }
|
||||
CBigNum(uint64 n) { init(); setuint64(n); }
|
||||
explicit CBigNum(uint256 n) { init(); setuint256(n); }
|
||||
|
||||
explicit CBigNum(const std::vector<unsigned char>& vch)
|
||||
{
|
||||
init();
|
||||
setvch(vch);
|
||||
}
|
||||
|
||||
void setulong(unsigned long n)
|
||||
{
|
||||
if (!BN_set_word(self, n))
|
||||
throw bignum_error("CBigNum conversion from unsigned long : BN_set_word failed");
|
||||
}
|
||||
|
||||
unsigned long getulong() const
|
||||
{
|
||||
return BN_get_word(self);
|
||||
}
|
||||
|
||||
unsigned int getuint() const
|
||||
{
|
||||
return BN_get_word(self);
|
||||
}
|
||||
|
||||
int getint() const
|
||||
{
|
||||
unsigned long n = BN_get_word(self);
|
||||
if (!BN_is_negative(self))
|
||||
return (n > (unsigned long)std::numeric_limits<int>::max() ? std::numeric_limits<int>::max() : n);
|
||||
else
|
||||
return (n > (unsigned long)std::numeric_limits<int>::max() ? std::numeric_limits<int>::min() : -(int)n);
|
||||
}
|
||||
|
||||
void setint64(int64 sn)
|
||||
{
|
||||
unsigned char pch[sizeof(sn) + 6];
|
||||
unsigned char* p = pch + 4;
|
||||
bool fNegative;
|
||||
uint64 n;
|
||||
|
||||
if (sn < (int64)0)
|
||||
{
|
||||
// Since the minimum signed integer cannot be represented as positive so long as its type is signed, and it's not well-defined what happens if you make it unsigned before negating it, we instead increment the negative integer by 1, convert it, then increment the (now positive) unsigned integer by 1 to compensate
|
||||
n = -(sn + 1);
|
||||
++n;
|
||||
fNegative = true;
|
||||
} else {
|
||||
n = sn;
|
||||
fNegative = false;
|
||||
}
|
||||
|
||||
bool fLeadingZeroes = true;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
unsigned char c = (n >> 56) & 0xff;
|
||||
n <<= 8;
|
||||
if (fLeadingZeroes)
|
||||
{
|
||||
if (c == 0)
|
||||
continue;
|
||||
if (c & 0x80)
|
||||
*p++ = (fNegative ? 0x80 : 0);
|
||||
else if (fNegative)
|
||||
c |= 0x80;
|
||||
fLeadingZeroes = false;
|
||||
}
|
||||
*p++ = c;
|
||||
}
|
||||
unsigned int nSize = p - (pch + 4);
|
||||
pch[0] = (nSize >> 24) & 0xff;
|
||||
pch[1] = (nSize >> 16) & 0xff;
|
||||
pch[2] = (nSize >> 8) & 0xff;
|
||||
pch[3] = (nSize) & 0xff;
|
||||
BN_mpi2bn(pch, p - pch, self);
|
||||
}
|
||||
|
||||
uint64 getuint64()
|
||||
{
|
||||
unsigned int nSize = BN_bn2mpi(self, NULL);
|
||||
if (nSize < 4)
|
||||
return 0;
|
||||
std::vector<unsigned char> vch(nSize);
|
||||
BN_bn2mpi(self, &vch[0]);
|
||||
if (vch.size() > 4)
|
||||
vch[4] &= 0x7f;
|
||||
uint64 n = 0;
|
||||
for (unsigned int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--)
|
||||
((unsigned char*)&n)[i] = vch[j];
|
||||
return n;
|
||||
}
|
||||
|
||||
void setuint64(uint64 n)
|
||||
{
|
||||
unsigned char pch[sizeof(n) + 6];
|
||||
unsigned char* p = pch + 4;
|
||||
bool fLeadingZeroes = true;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
unsigned char c = (n >> 56) & 0xff;
|
||||
n <<= 8;
|
||||
if (fLeadingZeroes)
|
||||
{
|
||||
if (c == 0)
|
||||
continue;
|
||||
if (c & 0x80)
|
||||
*p++ = 0;
|
||||
fLeadingZeroes = false;
|
||||
}
|
||||
*p++ = c;
|
||||
}
|
||||
unsigned int nSize = p - (pch + 4);
|
||||
pch[0] = (nSize >> 24) & 0xff;
|
||||
pch[1] = (nSize >> 16) & 0xff;
|
||||
pch[2] = (nSize >> 8) & 0xff;
|
||||
pch[3] = (nSize) & 0xff;
|
||||
BN_mpi2bn(pch, p - pch, self);
|
||||
}
|
||||
|
||||
void setuint256(uint256 n)
|
||||
{
|
||||
unsigned char pch[sizeof(n) + 6];
|
||||
unsigned char* p = pch + 4;
|
||||
bool fLeadingZeroes = true;
|
||||
unsigned char* pbegin = (unsigned char*)&n;
|
||||
unsigned char* psrc = pbegin + sizeof(n);
|
||||
while (psrc != pbegin)
|
||||
{
|
||||
unsigned char c = *(--psrc);
|
||||
if (fLeadingZeroes)
|
||||
{
|
||||
if (c == 0)
|
||||
continue;
|
||||
if (c & 0x80)
|
||||
*p++ = 0;
|
||||
fLeadingZeroes = false;
|
||||
}
|
||||
*p++ = c;
|
||||
}
|
||||
unsigned int nSize = p - (pch + 4);
|
||||
pch[0] = (nSize >> 24) & 0xff;
|
||||
pch[1] = (nSize >> 16) & 0xff;
|
||||
pch[2] = (nSize >> 8) & 0xff;
|
||||
pch[3] = (nSize >> 0) & 0xff;
|
||||
BN_mpi2bn(pch, p - pch, self);
|
||||
}
|
||||
|
||||
uint256 getuint256()
|
||||
{
|
||||
unsigned int nSize = BN_bn2mpi(self, NULL);
|
||||
if (nSize < 4)
|
||||
return 0;
|
||||
std::vector<unsigned char> vch(nSize);
|
||||
BN_bn2mpi(self, &vch[0]);
|
||||
if (vch.size() > 4)
|
||||
vch[4] &= 0x7f;
|
||||
uint256 n = 0;
|
||||
for (unsigned int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--)
|
||||
((unsigned char*)&n)[i] = vch[j];
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
void setvch(const std::vector<unsigned char>& vch)
|
||||
{
|
||||
std::vector<unsigned char> vch2(vch.size() + 4);
|
||||
unsigned int nSize = vch.size();
|
||||
// BIGNUM's byte stream format expects 4 bytes of
|
||||
// big endian size data info at the front
|
||||
vch2[0] = (nSize >> 24) & 0xff;
|
||||
vch2[1] = (nSize >> 16) & 0xff;
|
||||
vch2[2] = (nSize >> 8) & 0xff;
|
||||
vch2[3] = (nSize >> 0) & 0xff;
|
||||
// swap data to big endian
|
||||
reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4);
|
||||
BN_mpi2bn(&vch2[0], vch2.size(), self);
|
||||
}
|
||||
|
||||
std::vector<unsigned char> getvch() const
|
||||
{
|
||||
unsigned int nSize = BN_bn2mpi(self, NULL);
|
||||
if (nSize <= 4)
|
||||
return std::vector<unsigned char>();
|
||||
std::vector<unsigned char> vch(nSize);
|
||||
BN_bn2mpi(self, &vch[0]);
|
||||
vch.erase(vch.begin(), vch.begin() + 4);
|
||||
reverse(vch.begin(), vch.end());
|
||||
return vch;
|
||||
}
|
||||
|
||||
CBigNum& SetCompact(unsigned int nCompact)
|
||||
{
|
||||
unsigned int nSize = nCompact >> 24;
|
||||
std::vector<unsigned char> vch(4 + nSize);
|
||||
vch[3] = nSize;
|
||||
if (nSize >= 1) vch[4] = (nCompact >> 16) & 0xff;
|
||||
if (nSize >= 2) vch[5] = (nCompact >> 8) & 0xff;
|
||||
if (nSize >= 3) vch[6] = (nCompact >> 0) & 0xff;
|
||||
BN_mpi2bn(&vch[0], vch.size(), self);
|
||||
return *this;
|
||||
}
|
||||
|
||||
unsigned int GetCompact() const
|
||||
{
|
||||
unsigned int nSize = BN_bn2mpi(self, NULL);
|
||||
std::vector<unsigned char> vch(nSize);
|
||||
nSize -= 4;
|
||||
BN_bn2mpi(self, &vch[0]);
|
||||
unsigned int nCompact = nSize << 24;
|
||||
if (nSize >= 1) nCompact |= (vch[4] << 16);
|
||||
if (nSize >= 2) nCompact |= (vch[5] << 8);
|
||||
if (nSize >= 3) nCompact |= (vch[6] << 0);
|
||||
return nCompact;
|
||||
}
|
||||
|
||||
void SetHex(const std::string& str)
|
||||
{
|
||||
// skip 0x
|
||||
const char* psz = str.c_str();
|
||||
while (isspace(*psz))
|
||||
psz++;
|
||||
bool fNegative = false;
|
||||
if (*psz == '-')
|
||||
{
|
||||
fNegative = true;
|
||||
psz++;
|
||||
}
|
||||
if (psz[0] == '0' && tolower(psz[1]) == 'x')
|
||||
psz += 2;
|
||||
while (isspace(*psz))
|
||||
psz++;
|
||||
|
||||
// hex string to bignum
|
||||
static const signed char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
|
||||
*this = 0;
|
||||
while (isxdigit(*psz))
|
||||
{
|
||||
*this <<= 4;
|
||||
int n = phexdigit[(unsigned char)*psz++];
|
||||
*this += n;
|
||||
}
|
||||
if (fNegative)
|
||||
*this = 0 - *this;
|
||||
}
|
||||
|
||||
std::string ToString(int nBase=10) const
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum bnBase = nBase;
|
||||
CBigNum bn0 = 0;
|
||||
std::string str;
|
||||
CBigNum bn = *this;
|
||||
BN_set_negative(bn.get(), false);
|
||||
CBigNum dv;
|
||||
CBigNum rem;
|
||||
if (BN_cmp(bn.getc(), bn0.getc()) == 0)
|
||||
return "0";
|
||||
while (BN_cmp(bn.getc(), bn0.getc()) > 0)
|
||||
{
|
||||
if (!BN_div(dv.get(), rem.get(), bn.getc(), bnBase.getc(), pctx))
|
||||
throw bignum_error("CBigNum::ToString() : BN_div failed");
|
||||
bn = dv;
|
||||
unsigned int c = rem.getulong();
|
||||
str += "0123456789abcdef"[c];
|
||||
}
|
||||
if (BN_is_negative(self))
|
||||
str += "-";
|
||||
reverse(str.begin(), str.end());
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string GetHex() const
|
||||
{
|
||||
return ToString(16);
|
||||
}
|
||||
|
||||
unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const
|
||||
{
|
||||
return ::GetSerializeSize(getvch(), nType, nVersion);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const
|
||||
{
|
||||
::Serialize(s, getvch(), nType, nVersion);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Unserialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION)
|
||||
{
|
||||
std::vector<unsigned char> vch;
|
||||
::Unserialize(s, vch, nType, nVersion);
|
||||
setvch(vch);
|
||||
}
|
||||
|
||||
|
||||
bool operator!() const
|
||||
{
|
||||
return BN_is_zero(self);
|
||||
}
|
||||
|
||||
CBigNum& operator+=(const CBigNum& b)
|
||||
{
|
||||
if (!BN_add(self, self, b.getc()))
|
||||
throw bignum_error("CBigNum::operator+= : BN_add failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator-=(const CBigNum& b)
|
||||
{
|
||||
*this = *this - b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator*=(const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
if (!BN_mul(self, self, b.getc(), pctx))
|
||||
throw bignum_error("CBigNum::operator*= : BN_mul failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator/=(const CBigNum& b)
|
||||
{
|
||||
*this = *this / b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator%=(const CBigNum& b)
|
||||
{
|
||||
*this = *this % b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator<<=(unsigned int shift)
|
||||
{
|
||||
if (!BN_lshift(self, self, shift))
|
||||
throw bignum_error("CBigNum:operator<<= : BN_lshift failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator>>=(unsigned int shift)
|
||||
{
|
||||
// Note: BN_rshift segfaults on 64-bit if 2^shift is greater than the number
|
||||
// if built on ubuntu 9.04 or 9.10, probably depends on version of OpenSSL
|
||||
CBigNum a = 1;
|
||||
a <<= shift;
|
||||
if (BN_cmp(a.getc(), self) > 0)
|
||||
{
|
||||
*this = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (!BN_rshift(self, self, shift))
|
||||
throw bignum_error("CBigNum:operator>>= : BN_rshift failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
CBigNum& operator++()
|
||||
{
|
||||
// prefix operator
|
||||
if (!BN_add(self, self, BN_value_one()))
|
||||
throw bignum_error("CBigNum::operator++ : BN_add failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
const CBigNum operator++(int)
|
||||
{
|
||||
// postfix operator
|
||||
const CBigNum ret = *this;
|
||||
++(*this);
|
||||
return ret;
|
||||
}
|
||||
|
||||
CBigNum& operator--()
|
||||
{
|
||||
// prefix operator
|
||||
CBigNum r;
|
||||
if (!BN_sub(r.get(), self, BN_value_one()))
|
||||
throw bignum_error("CBigNum::operator-- : BN_sub failed");
|
||||
*this = r;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const CBigNum operator--(int)
|
||||
{
|
||||
// postfix operator
|
||||
const CBigNum ret = *this;
|
||||
--(*this);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
friend inline const CBigNum operator-(const CBigNum& a, const CBigNum& b);
|
||||
friend inline const CBigNum operator/(const CBigNum& a, const CBigNum& b);
|
||||
friend inline const CBigNum operator%(const CBigNum& a, const CBigNum& b);
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline const CBigNum operator+(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CBigNum r;
|
||||
if (!BN_add(r.get(), a.getc(), b.getc()))
|
||||
throw bignum_error("CBigNum::operator+ : BN_add failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator-(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CBigNum r;
|
||||
if (!BN_sub(r.get(), a.getc(), b.getc()))
|
||||
throw bignum_error("CBigNum::operator- : BN_sub failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator-(const CBigNum& a)
|
||||
{
|
||||
CBigNum r(a);
|
||||
BN_set_negative(r.get(), !BN_is_negative(r.getc()));
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator*(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum r;
|
||||
if (!BN_mul(r.get(), a.getc(), b.getc(), pctx))
|
||||
throw bignum_error("CBigNum::operator* : BN_mul failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator/(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum r;
|
||||
if (!BN_div(r.get(), NULL, a.getc(), b.getc(), pctx))
|
||||
throw bignum_error("CBigNum::operator/ : BN_div failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator%(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum r;
|
||||
if (!BN_mod(r.get(), a.getc(), b.getc(), pctx))
|
||||
throw bignum_error("CBigNum::operator% : BN_div failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator<<(const CBigNum& a, unsigned int shift)
|
||||
{
|
||||
CBigNum r;
|
||||
if (!BN_lshift(r.get(), a.getc(), shift))
|
||||
throw bignum_error("CBigNum:operator<< : BN_lshift failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator>>(const CBigNum& a, unsigned int shift)
|
||||
{
|
||||
CBigNum r = a;
|
||||
r >>= shift;
|
||||
return r;
|
||||
}
|
||||
|
||||
inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.getc(), b.getc()) == 0); }
|
||||
inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.getc(), b.getc()) != 0); }
|
||||
inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.getc(), b.getc()) <= 0); }
|
||||
inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.getc(), b.getc()) >= 0); }
|
||||
inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.getc(), b.getc()) < 0); }
|
||||
inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.getc(), b.getc()) > 0); }
|
||||
|
||||
#endif
|
||||
-273
@@ -1,273 +0,0 @@
|
||||
/**
|
||||
* Blake2-B CUDA Implementation
|
||||
*
|
||||
* tpruvot@github July 2016
|
||||
*
|
||||
*/
|
||||
|
||||
#include <miner.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <sph/blake2b.h>
|
||||
|
||||
#include <cuda_helper.h>
|
||||
#include <cuda_vector_uint2x4.h>
|
||||
|
||||
#define TPB 512
|
||||
#define NBN 2
|
||||
|
||||
static uint32_t *d_resNonces[MAX_GPUS];
|
||||
|
||||
__device__ uint64_t d_data[10];
|
||||
|
||||
static __constant__ const int8_t blake2b_sigma[12][16] = {
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } ,
|
||||
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } ,
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } ,
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } ,
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } ,
|
||||
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } ,
|
||||
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } ,
|
||||
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } ,
|
||||
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 } ,
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }
|
||||
};
|
||||
|
||||
// host mem align
|
||||
#define A 64
|
||||
|
||||
extern "C" void blake2b_hash(void *output, const void *input)
|
||||
{
|
||||
uint8_t _ALIGN(A) hash[32];
|
||||
blake2b_ctx ctx;
|
||||
|
||||
blake2b_init(&ctx, 32, NULL, 0);
|
||||
blake2b_update(&ctx, input, 80);
|
||||
blake2b_final(&ctx, hash);
|
||||
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
__device__ __forceinline__
|
||||
static void G(const int r, const int i, uint64_t &a, uint64_t &b, uint64_t &c, uint64_t &d, uint64_t const m[16])
|
||||
{
|
||||
a = a + b + m[ blake2b_sigma[r][2*i] ];
|
||||
((uint2*)&d)[0] = SWAPUINT2( ((uint2*)&d)[0] ^ ((uint2*)&a)[0] );
|
||||
c = c + d;
|
||||
((uint2*)&b)[0] = ROR24( ((uint2*)&b)[0] ^ ((uint2*)&c)[0] );
|
||||
a = a + b + m[ blake2b_sigma[r][2*i+1] ];
|
||||
((uint2*)&d)[0] = ROR16( ((uint2*)&d)[0] ^ ((uint2*)&a)[0] );
|
||||
c = c + d;
|
||||
((uint2*)&b)[0] = ROR2( ((uint2*)&b)[0] ^ ((uint2*)&c)[0], 63U);
|
||||
}
|
||||
|
||||
#define ROUND(r) \
|
||||
G(r, 0, v[0], v[4], v[ 8], v[12], m); \
|
||||
G(r, 1, v[1], v[5], v[ 9], v[13], m); \
|
||||
G(r, 2, v[2], v[6], v[10], v[14], m); \
|
||||
G(r, 3, v[3], v[7], v[11], v[15], m); \
|
||||
G(r, 4, v[0], v[5], v[10], v[15], m); \
|
||||
G(r, 5, v[1], v[6], v[11], v[12], m); \
|
||||
G(r, 6, v[2], v[7], v[ 8], v[13], m); \
|
||||
G(r, 7, v[3], v[4], v[ 9], v[14], m);
|
||||
|
||||
__global__
|
||||
//__launch_bounds__(128, 8) /* to force 64 regs */
|
||||
void blake2b_gpu_hash(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce, const uint2 target2)
|
||||
{
|
||||
const uint32_t nonce = (blockDim.x * blockIdx.x + threadIdx.x) + startNonce;
|
||||
|
||||
uint64_t m[16];
|
||||
|
||||
m[0] = d_data[0];
|
||||
m[1] = d_data[1];
|
||||
m[2] = d_data[2];
|
||||
m[3] = d_data[3];
|
||||
m[4] = d_data[4];
|
||||
m[5] = d_data[5];
|
||||
m[6] = d_data[6];
|
||||
m[7] = d_data[7];
|
||||
m[8] = d_data[8];
|
||||
((uint32_t*)m)[18] = AS_U32(&d_data[9]);
|
||||
((uint32_t*)m)[19] = nonce;
|
||||
|
||||
m[10] = m[11] = 0;
|
||||
m[12] = m[13] = 0;
|
||||
m[14] = m[15] = 0;
|
||||
|
||||
uint64_t v[16] = {
|
||||
0x6a09e667f2bdc928, 0xbb67ae8584caa73b, 0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1,
|
||||
0x510e527fade682d1, 0x9b05688c2b3e6c1f, 0x1f83d9abfb41bd6b, 0x5be0cd19137e2179,
|
||||
0x6a09e667f3bcc908, 0xbb67ae8584caa73b, 0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1,
|
||||
0x510e527fade68281, 0x9b05688c2b3e6c1f, 0xe07c265404be4294, 0x5be0cd19137e2179
|
||||
};
|
||||
|
||||
ROUND( 0);
|
||||
ROUND( 1);
|
||||
ROUND( 2);
|
||||
ROUND( 3);
|
||||
ROUND( 4);
|
||||
ROUND( 5);
|
||||
ROUND( 6);
|
||||
ROUND( 7);
|
||||
ROUND( 8);
|
||||
ROUND( 9);
|
||||
ROUND(10);
|
||||
ROUND(11);
|
||||
|
||||
uint2 last = vectorize(v[3] ^ v[11] ^ 0xa54ff53a5f1d36f1);
|
||||
if (last.y <= target2.y && last.x <= target2.x) {
|
||||
resNonce[1] = resNonce[0];
|
||||
resNonce[0] = nonce;
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
uint32_t blake2b_hash_cuda(const int thr_id, const uint32_t threads, const uint32_t startNonce, const uint2 target2, uint32_t &secNonce)
|
||||
{
|
||||
uint32_t resNonces[NBN] = { UINT32_MAX, UINT32_MAX };
|
||||
uint32_t result = UINT32_MAX;
|
||||
|
||||
dim3 grid((threads + TPB-1)/TPB);
|
||||
dim3 block(TPB);
|
||||
|
||||
/* Check error on Ctrl+C or kill to prevent segfaults on exit */
|
||||
if (cudaMemset(d_resNonces[thr_id], 0xff, NBN*sizeof(uint32_t)) != cudaSuccess)
|
||||
return result;
|
||||
|
||||
blake2b_gpu_hash <<<grid, block, 8>>> (threads, startNonce, d_resNonces[thr_id], target2);
|
||||
cudaThreadSynchronize();
|
||||
|
||||
if (cudaSuccess == cudaMemcpy(resNonces, d_resNonces[thr_id], NBN*sizeof(uint32_t), cudaMemcpyDeviceToHost)) {
|
||||
result = resNonces[0];
|
||||
secNonce = resNonces[1];
|
||||
if (secNonce == result) secNonce = UINT32_MAX;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__host__
|
||||
void blake2b_setBlock(uint32_t *data)
|
||||
{
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(d_data, data, 80, 0, cudaMemcpyHostToDevice));
|
||||
}
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
int scanhash_blake2b(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done)
|
||||
{
|
||||
uint32_t _ALIGN(A) endiandata[20];
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
|
||||
int dev_id = device_map[thr_id];
|
||||
int intensity = (device_sm[dev_id] >= 500 && !is_windows()) ? 28 : 25;
|
||||
if (device_sm[dev_id] >= 520 && is_windows()) intensity = 26;
|
||||
if (device_sm[dev_id] < 350) intensity = 22;
|
||||
|
||||
uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
if (!init[thr_id])
|
||||
{
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage (linux)
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
|
||||
CUDA_CALL_OR_RET_X(cudaMalloc(&d_resNonces[thr_id], NBN * sizeof(uint32_t)), -1);
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
for (int i=0; i < 20; i++)
|
||||
be32enc(&endiandata[i], pdata[i]);
|
||||
|
||||
const uint2 target = make_uint2(ptarget[6], ptarget[7]);
|
||||
blake2b_setBlock(endiandata);
|
||||
|
||||
do {
|
||||
work->nonces[0] = blake2b_hash_cuda(thr_id, throughput, pdata[19], target, work->nonces[1]);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce + throughput;
|
||||
|
||||
if (work->nonces[0] != UINT32_MAX)
|
||||
{
|
||||
const uint32_t Htarg = ptarget[7];
|
||||
uint32_t _ALIGN(A) vhash[8];
|
||||
work->valid_nonces = 0;
|
||||
endiandata[19] = work->nonces[0];
|
||||
blake2b_hash(vhash, endiandata);
|
||||
if (vhash[7] <= Htarg && fulltest(vhash, ptarget)) {
|
||||
work_set_target_ratio(work, vhash);
|
||||
work->valid_nonces++;
|
||||
pdata[19] = work->nonces[0] + 1;
|
||||
} else {
|
||||
gpu_increment_reject(thr_id);
|
||||
}
|
||||
|
||||
if (work->nonces[1] != UINT32_MAX) {
|
||||
endiandata[19] = work->nonces[1];
|
||||
blake2b_hash(vhash, endiandata);
|
||||
if (vhash[7] <= Htarg && fulltest(vhash, ptarget)) {
|
||||
if (bn_hash_target_ratio(vhash, ptarget) > work->shareratio[0]) {
|
||||
work->sharediff[1] = work->sharediff[0];
|
||||
work->shareratio[1] = work->shareratio[0];
|
||||
xchg(work->nonces[1], work->nonces[0]);
|
||||
work_set_target_ratio(work, vhash);
|
||||
} else {
|
||||
bn_set_target_ratio(work, vhash, 1);
|
||||
}
|
||||
work->valid_nonces++;
|
||||
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1; // next scan start
|
||||
} else {
|
||||
gpu_increment_reject(thr_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (work->valid_nonces) {
|
||||
work->nonces[0] = cuda_swab32(work->nonces[0]);
|
||||
work->nonces[1] = cuda_swab32(work->nonces[1]);
|
||||
return work->valid_nonces;
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint64_t) throughput + pdata[19] >= max_nonce) {
|
||||
pdata[19] = max_nonce;
|
||||
break;
|
||||
}
|
||||
|
||||
pdata[19] += throughput;
|
||||
|
||||
} while (!work_restart[thr_id].restart);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_blake2b(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
//cudaThreadSynchronize();
|
||||
|
||||
cudaFree(d_resNonces[thr_id]);
|
||||
|
||||
init[thr_id] = false;
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
}
|
||||
+5
-6
@@ -2,19 +2,18 @@
|
||||
"_comment1" : "Possible keys are the long options (ccminer --help)",
|
||||
"_comment2" : "todo: support /* comments */",
|
||||
|
||||
"algo" : "lbry",
|
||||
"intensity": 22,
|
||||
"algo" : "blake",
|
||||
"intensity": 19,
|
||||
|
||||
"api-bind": "127.0.0.1:4068",
|
||||
"statsavg": 20,
|
||||
|
||||
"max-log-rate": 60,
|
||||
"quiet" : false,
|
||||
"debug" : false,
|
||||
"protocol" : false,
|
||||
"cpu-priority" : 3,
|
||||
|
||||
"url" : "stratum+tcp://yiimp.ccminer.org:3334",
|
||||
"user" : "bK2wcSFJv2nnNjFvTN5Q7VX8X8unJktJsa",
|
||||
"pass" : "donate"
|
||||
"url" : "stratum+tcp://stratum.eu.miners-pool.eu:8421",
|
||||
"user" : "ShGCAFrspnLDo414EzUyJm4k5Qr2Kkrmvh",
|
||||
"pass" : "x"
|
||||
}
|
||||
+955
-1789
File diff suppressed because it is too large.
Load diff
+108
-212
@@ -23,23 +23,38 @@
|
||||
<RootNamespace>ccminer</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Label="Configuration">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CLRSupport>false</CLRSupport>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CLRSupport>false</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CLRSupport>false</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CLRSupport>false</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 9.0.props" />
|
||||
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 6.5.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
@@ -53,6 +68,19 @@
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@@ -63,7 +91,6 @@
|
||||
<AdditionalIncludeDirectories>.;compat;compat\curl-for-windows\curl\include;compat\jansson;compat\getopt;compat\pthreads;compat\curl-for-windows\openssl\openssl\include;compat\curl-for-windows\zlib;%(AdditionalIncludeDirectories);$(CudaToolkitIncludeDir)</AdditionalIncludeDirectories>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@@ -81,7 +108,6 @@
|
||||
<PtxAsOptionV>true</PtxAsOptionV>
|
||||
<Keep>true</Keep>
|
||||
<CodeGeneration>compute_50,sm_50</CodeGeneration>
|
||||
<Include>$(NVTOOLSEXT_PATH)\include;..\..\..\Common\C99</Include>
|
||||
</CudaCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -95,7 +121,6 @@
|
||||
<StructMemberAlignment>8Bytes</StructMemberAlignment>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@@ -112,7 +137,7 @@
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
<PtxAsOptionV>true</PtxAsOptionV>
|
||||
<Keep>true</Keep>
|
||||
<CodeGeneration>compute_52,sm_52</CodeGeneration>
|
||||
<CodeGeneration>compute_50,sm_50</CodeGeneration>
|
||||
<Include>$(NVTOOLSEXT_PATH)\include;..\..\..\Common\C99</Include>
|
||||
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
@@ -132,10 +157,9 @@
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;CURL_STATICLIB;USE_WRAPNVML;SCRYPT_KECCAK512;SCRYPT_CHACHA;SCRYPT_CHOOSE_COMPILETIME;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>.;compat;compat\curl-for-windows\curl\include;compat\jansson;compat\getopt;compat\pthreads;compat\curl-for-windows\openssl\openssl\include;compat\curl-for-windows\zlib;%(AdditionalIncludeDirectories);$(CudaToolkitIncludeDir)</AdditionalIncludeDirectories>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
<ExceptionHandling>SyncCThrow</ExceptionHandling>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
@@ -155,13 +179,17 @@
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
<PtxAsOptionV>true</PtxAsOptionV>
|
||||
<Keep>true</Keep>
|
||||
<CodeGeneration>compute_50,sm_50;compute_52,sm_52;compute_30,sm_30</CodeGeneration>
|
||||
<AdditionalOptions>--ptxas-options="-O2" --Wno-deprecated-gpu-targets %(AdditionalOptions)</AdditionalOptions>
|
||||
<Optimization>O2</Optimization>
|
||||
<CodeGeneration>compute_35,sm_35;compute_50,sm_50;compute_52,sm_52</CodeGeneration>
|
||||
<AdditionalOptions>--ptxas-options="-O2" %(AdditionalOptions)</AdditionalOptions>
|
||||
<Defines>
|
||||
</Defines>
|
||||
<Optimization>O3</Optimization>
|
||||
</CudaCompile>
|
||||
<CudaLink>
|
||||
<GPUDebugInfo>false</GPUDebugInfo>
|
||||
<Optimization>O3</Optimization>
|
||||
</CudaLink>
|
||||
<CudaLink>
|
||||
<Optimization>O2</Optimization>
|
||||
</CudaLink>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -170,15 +198,12 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<EnableEnhancedInstructionSet>
|
||||
</EnableEnhancedInstructionSet>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;CURL_STATICLIB;USE_WRAPNVML;SCRYPT_KECCAK512;SCRYPT_CHACHA;SCRYPT_CHOOSE_COMPILETIME;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>.;compat;compat\curl-for-windows\curl\include;compat\jansson;compat\getopt;compat\pthreads;compat\curl-for-windows\openssl\openssl\include;compat\curl-for-windows\zlib;%(AdditionalIncludeDirectories);$(CudaToolkitIncludeDir)</AdditionalIncludeDirectories>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@@ -197,15 +222,13 @@
|
||||
<CInterleavedPTX>false</CInterleavedPTX>
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
<PtxAsOptionV>true</PtxAsOptionV>
|
||||
<Keep>true</Keep>
|
||||
<CodeGeneration>compute_52,sm_52;compute_50,sm_50;compute_35,sm_35;compute_30,sm_30</CodeGeneration>
|
||||
<Include>$(NVTOOLSEXT_PATH)\include</Include>
|
||||
<Optimization>O3</Optimization>
|
||||
<Keep>false</Keep>
|
||||
<CodeGeneration>compute_35,sm_35;compute_50,sm_50;compute_52,sm_52</CodeGeneration>
|
||||
<Include>
|
||||
</Include>
|
||||
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||
<AdditionalOptions>--Wno-deprecated-gpu-targets %(AdditionalOptions)</AdditionalOptions>
|
||||
</CudaCompile>
|
||||
<CudaLink>
|
||||
<Optimization>O3</Optimization>
|
||||
<PerformDeviceLink>false</PerformDeviceLink>
|
||||
</CudaLink>
|
||||
</ItemDefinitionGroup>
|
||||
@@ -222,33 +245,14 @@
|
||||
<ClCompile Include="compat\jansson\strconv.c" />
|
||||
<ClCompile Include="compat\jansson\utf.c" />
|
||||
<ClCompile Include="compat\jansson\value.c" />
|
||||
<ClInclude Include="compat\pthreads\pthread.h" />
|
||||
<ClCompile Include="compat\winansi.c" />
|
||||
<ClCompile Include="ccminer.cpp">
|
||||
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
|
||||
<Optimization Condition="'$(Configuration)'=='Release'">Full</Optimization>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\mman.c" />
|
||||
<ClCompile Include="crypto\wildkeccak-cpu.cpp" />
|
||||
<ClCompile Include="crypto\xmr-rpc.cpp" />
|
||||
<ClCompile Include="crypto\aesb.cpp" />
|
||||
<ClCompile Include="crypto\oaes_lib.cpp" />
|
||||
<ClCompile Include="crypto\cryptolight-cpu.cpp" />
|
||||
<ClCompile Include="crypto\cryptonight-cpu.cpp" />
|
||||
<ClCompile Include="crypto\cpu\c_keccak.c" />
|
||||
<ClCompile Include="equi\blake2\blake2bx.cpp">
|
||||
<EnableEnhancedInstructionSet Condition="'$(Platform)'=='Win32'">StreamingSIMDExtensions</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<ClCompile Include="equi\equi-stratum.cpp" />
|
||||
<ClCompile Include="equi\equi.cpp" />
|
||||
<ClCompile Include="equi\equihash.cpp" />
|
||||
<ClCompile Include="nvapi.cpp" />
|
||||
<ClCompile Include="nvsettings.cpp" />
|
||||
<ClCompile Include="pools.cpp" />
|
||||
<ClCompile Include="scrypt-jane.cpp" />
|
||||
<ClCompile Include="scrypt.cpp" />
|
||||
<ClCompile Include="util.cpp" />
|
||||
<ClCompile Include="bench.cpp" />
|
||||
<ClCompile Include="bignum.cpp" />
|
||||
<ClInclude Include="bignum.hpp" />
|
||||
<ClCompile Include="fuguecoin.cpp" />
|
||||
<ClCompile Include="groestlcoin.cpp" />
|
||||
<ClCompile Include="hashlog.cpp" />
|
||||
@@ -261,78 +265,38 @@
|
||||
<ClCompile Include="myriadgroestl.cpp" />
|
||||
<ClCompile Include="lyra2\Lyra2.c" />
|
||||
<ClCompile Include="lyra2\Sponge.c" />
|
||||
<ClCompile Include="lyra2\Lyra2Z.c" />
|
||||
<ClInclude Include="equi\eqcuda.hpp" />
|
||||
<ClInclude Include="equi\equihash.h" />
|
||||
<ClInclude Include="neoscrypt\neoscrypt.h" />
|
||||
<ClCompile Include="neoscrypt\neoscrypt.cpp" />
|
||||
<ClCompile Include="neoscrypt\neoscrypt-cpu.c" />
|
||||
<ClInclude Include="neoscrypt\cuda_vectors.h" />
|
||||
<ClInclude Include="x11\cuda_x11_simd512_sm2.cuh" />
|
||||
<ClInclude Include="x16\cuda_x16.h" />
|
||||
<CudaCompile Include="Algo256\bmw.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_bmw.cu">
|
||||
<MaxRegCount>76</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptolight.cu" />
|
||||
<CudaCompile Include="crypto\cryptolight-core.cu">
|
||||
<MaxRegCount>64</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptonight.cu" />
|
||||
<CudaCompile Include="crypto\cryptonight-core.cu">
|
||||
<MaxRegCount>64</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptonight-extra.cu">
|
||||
<MaxRegCount>255</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<ClInclude Include="crypto\cn_aes.cuh" />
|
||||
<ClInclude Include="crypto\cn_blake.cuh" />
|
||||
<ClInclude Include="crypto\cn_groestl.cuh" />
|
||||
<ClInclude Include="crypto\cn_jh.cuh" />
|
||||
<ClInclude Include="crypto\cn_keccak.cuh" />
|
||||
<ClInclude Include="crypto\cn_skein.cuh" />
|
||||
<CudaCompile Include="crypto\wildkeccak.cu">
|
||||
<MaxRegCount>128</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="equi\cuda_equi.cu">
|
||||
<CodeGeneration>compute_52,sm_52;compute_50,sm_50;compute_30,sm_30</CodeGeneration>
|
||||
<AdditionalOptions> -Xptxas -dlcm=ca -Xptxas -dscm=cs %(AdditionalOptions)</AdditionalOptions>
|
||||
<MaxRegCount>0</MaxRegCount>
|
||||
<CodeGeneration Condition="'$(Configuration)|$(Platform)'=='Release|x64'">compute_61,sm_61;compute_52,sm_52;compute_50,sm_50;compute_30,sm_30</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="neoscrypt\cuda_neoscrypt.cu">
|
||||
<MaxRegCount>160</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<ClCompile Include="scrypt-jane.cpp" />
|
||||
<ClCompile Include="scrypt.cpp" />
|
||||
<ClCompile Include="sia\sia-rpc.cpp" />
|
||||
<CudaCompile Include="neoscrypt\cuda_neoscrypt.cu" />
|
||||
<ClCompile Include="skein2.cpp" />
|
||||
<ClCompile Include="sph\aes_helper.c" />
|
||||
<ClCompile Include="sph\blake.c" />
|
||||
<ClCompile Include="sph\blake2b.c" />
|
||||
<ClCompile Include="sph\blake2s.c" />
|
||||
<ClCompile Include="sph\bmw.c" />
|
||||
<ClCompile Include="sph\cubehash.c" />
|
||||
<ClCompile Include="sph\echo.c" />
|
||||
<ClCompile Include="sph\fugue.c" />
|
||||
<ClCompile Include="sph\groestl.c" />
|
||||
<ClCompile Include="sph\haval.c" />
|
||||
<ClCompile Include="sph\haval_helper.c">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\jh.c" />
|
||||
<ClCompile Include="sph\keccak.c" />
|
||||
<ClCompile Include="sph\luffa.c" />
|
||||
<ClCompile Include="sph\ripemd.c" />
|
||||
<ClCompile Include="sph\sph_sha2.c" />
|
||||
<ClCompile Include="sph\md_helper.c">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\sha2.c" />
|
||||
<ClCompile Include="sph\sha2big.c" />
|
||||
<ClCompile Include="sph\shabal.c" />
|
||||
<ClCompile Include="sph\shavite.c" />
|
||||
<ClCompile Include="sph\simd.c" />
|
||||
<ClCompile Include="sph\skein.c" />
|
||||
<ClCompile Include="sph\streebog.c" />
|
||||
<ClCompile Include="sph\hamsi.c" />
|
||||
<ClCompile Include="sph\hamsi_helper.c" />
|
||||
<ClCompile Include="sph\whirlpool.c" />
|
||||
<ClCompile Include="x13\sm3.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="compat.h" />
|
||||
@@ -352,29 +316,17 @@
|
||||
<ClInclude Include="compat\sys\time.h" />
|
||||
<ClInclude Include="compat\unistd.h" />
|
||||
<ClInclude Include="compat\winansi.h" />
|
||||
<ClInclude Include="compat\ccminer-config.h" />
|
||||
<ClInclude Include="crypto\cryptolight.h" />
|
||||
<ClInclude Include="crypto\cryptonight.h" />
|
||||
<ClInclude Include="crypto\mman.h" />
|
||||
<ClInclude Include="crypto\wildkeccak.h" />
|
||||
<ClInclude Include="crypto\xmr-rpc.h" />
|
||||
<ClInclude Include="cpuminer-config.h" />
|
||||
<ClInclude Include="cuda_groestlcoin.h" />
|
||||
<ClInclude Include="cuda_helper.h" />
|
||||
<ClInclude Include="cuda_vector_uint2x4.h" />
|
||||
<ClInclude Include="cuda_vector.h" />
|
||||
<ClInclude Include="elist.h" />
|
||||
<ClInclude Include="heavy\heavy.h" />
|
||||
<ClInclude Include="hefty1.h" />
|
||||
<ClInclude Include="algos.h" />
|
||||
<ClInclude Include="miner.h" />
|
||||
<ClInclude Include="nvml.h" />
|
||||
<ClInclude Include="quark\cuda_bmw512_sm3.cuh" />
|
||||
<ClInclude Include="quark\cuda_quark_groestl512_sm2.cuh" />
|
||||
<ClInclude Include="quark\cuda_quark_blake512_sp.cuh" />
|
||||
<ClInclude Include="res\resource.h" />
|
||||
<ClInclude Include="sia\sia-rpc.h" />
|
||||
<ClInclude Include="scrypt\salsa_kernel.h" />
|
||||
<ClInclude Include="sph\blake2b.h" />
|
||||
<ClInclude Include="sph\blake2s.h" />
|
||||
<ClInclude Include="sph\sph_blake.h" />
|
||||
<ClInclude Include="sph\sph_bmw.h" />
|
||||
<ClInclude Include="sph\sph_cubehash.h" />
|
||||
@@ -390,31 +342,29 @@
|
||||
<ClInclude Include="sph\sph_shavite.h" />
|
||||
<ClInclude Include="sph\sph_simd.h" />
|
||||
<ClInclude Include="sph\sph_skein.h" />
|
||||
<ClInclude Include="sph\sph_streebog.h" />
|
||||
<ClInclude Include="sph\sph_hamsi.h" />
|
||||
<ClInclude Include="sph\sph_types.h" />
|
||||
<ClInclude Include="sph\sph_whirlpool.h" />
|
||||
<ClInclude Include="uint256.h" />
|
||||
<ClInclude Include="lyra2\Lyra2.h" />
|
||||
<ClInclude Include="lyra2\Sponge.h" />
|
||||
<ClInclude Include="lyra2\Lyra2Z.h" />
|
||||
<ClInclude Include="quark\groestl_transf_quad.h" />
|
||||
<ClInclude Include="quark\groestl_functions_quad.h" />
|
||||
<ClInclude Include="quark\cuda_quark.h" />
|
||||
<ClInclude Include="x11\cuda_x11.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CudaCompile Include="cuda.cpp" />
|
||||
<CudaCompile Include="cuda_groestlcoin.cu" />
|
||||
<CudaCompile Include="cuda_myriadgroestl.cu" />
|
||||
<CudaCompile Include="cuda_nist5.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\blake.cu" />
|
||||
<CudaCompile Include="scrypt\keccak.cu" />
|
||||
<CudaCompile Include="scrypt\sha256.cu" />
|
||||
<CudaCompile Include="scrypt\salsa_kernel.cu">
|
||||
<CodeGeneration>compute_30,sm_30</CodeGeneration>
|
||||
<CodeGeneration>compute_20,sm_21</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\fermi_kernel.cu">
|
||||
<CodeGeneration>compute_30,sm_30</CodeGeneration>
|
||||
<CodeGeneration>compute_20,sm_21</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\kepler_kernel.cu">
|
||||
<CodeGeneration>compute_30,sm_30</CodeGeneration>
|
||||
@@ -426,17 +376,11 @@
|
||||
<CodeGeneration>compute_35,sm_35;compute_50,sm_50;compute_52,sm_52</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\test_kernel.cu">
|
||||
<CodeGeneration>compute_30,sm_30</CodeGeneration>
|
||||
<CodeGeneration>compute_20,sm_21</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\titan_kernel.cu">
|
||||
<CodeGeneration>compute_35,sm_35;compute_50,sm_50</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="sha256\cuda_sha256d.cu" />
|
||||
<CudaCompile Include="sha256\sha256d.cu" />
|
||||
<CudaCompile Include="sha256\cuda_sha256t.cu" />
|
||||
<CudaCompile Include="sha256\sha256t.cu" />
|
||||
<CudaCompile Include="sha256\cuda_sha256q.cu" />
|
||||
<CudaCompile Include="sha256\sha256q.cu" />
|
||||
<CudaCompile Include="zr5.cu" />
|
||||
<CudaCompile Include="heavy\cuda_blake512.cu">
|
||||
</CudaCompile>
|
||||
@@ -453,46 +397,34 @@
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="heavy\heavy.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="heavy\bastion.cu" />
|
||||
<CudaCompile Include="heavy\cuda_bastion.cu" />
|
||||
<CudaCompile Include="JHA\jha.cu" />
|
||||
<CudaCompile Include="JHA\jackpotcoin.cu" />
|
||||
<CudaCompile Include="JHA\cuda_jha_compactionTest.cu">
|
||||
<AdditionalOptions>-Xptxas "-abi=yes" %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">-Xptxas "-abi=yes" %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">-Xptxas "-abi=yes" %(AdditionalOptions)</AdditionalOptions>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="JHA\cuda_jha_keccak512.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="blake2b.cu" />
|
||||
<CudaCompile Include="JHA\jackpotcoin.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\blake256.cu">
|
||||
<MaxRegCount>64</MaxRegCount>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options="-dlcm=cg" %(AdditionalOptions)</AdditionalOptions>
|
||||
<FastMath>true</FastMath>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\blake2s.cu" />
|
||||
<CudaCompile Include="Algo256\decred.cu">
|
||||
<MaxRegCount>128</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\vanilla.cu" />
|
||||
<CudaCompile Include="Algo256\keccak256.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_blake256.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_bmw256.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_cubehash256.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_fugue256.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_groestl256.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_keccak256.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_keccak256_sm3.cu">
|
||||
<CudaCompile Include="Algo256\cuda_keccak256.cu">
|
||||
<MaxRegCount>92</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_skein256.cu" />
|
||||
<CudaCompile Include="lbry\cuda_sha256_lbry.cu" />
|
||||
<CudaCompile Include="lbry\cuda_sha512_lbry.cu" />
|
||||
<CudaCompile Include="lbry\cuda_lbry_merged.cu" />
|
||||
<CudaCompile Include="lbry\lbry.cu" />
|
||||
<CudaCompile Include="pentablake.cu">
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options="-dlcm=cg" %(AdditionalOptions)</AdditionalOptions>
|
||||
<FastMath>true</FastMath>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\animecoin.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\cuda_bmw512.cu">
|
||||
<MaxRegCount>128</MaxRegCount>
|
||||
</CudaCompile>
|
||||
@@ -509,6 +441,8 @@
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">-Xptxas "-abi=yes" %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">-Xptxas "-abi=yes" %(AdditionalOptions)</AdditionalOptions>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="pluck\pluck.cu" />
|
||||
<CudaCompile Include="pluck\cuda_pluck.cu" />
|
||||
<CudaCompile Include="quark\cuda_quark_groestl512.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\cuda_quark_keccak512.cu">
|
||||
@@ -516,108 +450,70 @@
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\cuda_skein512.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\quarkcoin.cu" />
|
||||
<CudaCompile Include="quark\nist5.cu" />
|
||||
<CudaCompile Include="qubit\deep.cu" />
|
||||
<CudaCompile Include="qubit\luffa.cu" />
|
||||
<CudaCompile Include="qubit\qubit.cu" />
|
||||
<CudaCompile Include="qubit\qubit_luffa512.cu" />
|
||||
<CudaCompile Include="lyra2\allium.cu" />
|
||||
<CudaCompile Include="quark\quarkcoin.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="qubit\deep.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="qubit\doom.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="qubit\qubit.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="qubit\qubit_luffa512.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\lyra2RE.cu" />
|
||||
<CudaCompile Include="lyra2\cuda_lyra2.cu" />
|
||||
<CudaCompile Include="lyra2\lyra2REv2.cu" />
|
||||
<CudaCompile Include="lyra2\cuda_lyra2v2.cu" />
|
||||
<ClInclude Include="lyra2\cuda_lyra2_sm2.cuh" />
|
||||
<ClInclude Include="lyra2\cuda_lyra2_sm5.cuh" />
|
||||
<ClInclude Include="lyra2\cuda_lyra2v2_sm3.cuh" />
|
||||
<CudaCompile Include="lyra2\lyra2REv3.cu" />
|
||||
<CudaCompile Include="lyra2\cuda_lyra2v3.cu" />
|
||||
<ClInclude Include="lyra2\cuda_lyra2v3_sm3.cuh" />
|
||||
<CudaCompile Include="lyra2\lyra2Z.cu" />
|
||||
<CudaCompile Include="lyra2\cuda_lyra2Z.cu" />
|
||||
<ClInclude Include="lyra2\cuda_lyra2Z_sm5.cuh" />
|
||||
<CudaCompile Include="polytimos.cu" />
|
||||
<CudaCompile Include="sia\sia.cu" />
|
||||
<CudaCompile Include="skein.cu">
|
||||
<MaxRegCount>64</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="cuda_skeincoin.cu">
|
||||
<MaxRegCount>48</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="phi\phi.cu" />
|
||||
<CudaCompile Include="phi\phi2.cu" />
|
||||
<CudaCompile Include="phi\cuda_phi2.cu" />
|
||||
<CudaCompile Include="phi\cuda_phi2_cubehash512.cu" />
|
||||
<CudaCompile Include="skunk\skunk.cu" />
|
||||
<CudaCompile Include="skunk\cuda_skunk.cu">
|
||||
<CodeGeneration>compute_50,sm_50;compute_52,sm_52</CodeGeneration>
|
||||
<MaxRegCount>64</MaxRegCount>
|
||||
<CudaCompile Include="x11\cuda_x11_aes.cu">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="skunk\cuda_skunk_streebog.cu" />
|
||||
<ClInclude Include="tribus\cuda_echo512_aes.cuh" />
|
||||
<CudaCompile Include="tribus\cuda_echo512_final.cu">
|
||||
<CodeGeneration>compute_50,sm_50;compute_52,sm_52</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="tribus\tribus.cu" />
|
||||
<ClInclude Include="x11\cuda_x11_aes.cuh" />
|
||||
<CudaCompile Include="x11\cuda_x11_cubehash512.cu" />
|
||||
<CudaCompile Include="x11\cuda_x11_echo.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_luffa512.cu" />
|
||||
<CudaCompile Include="x11\cuda_x11_luffa512_Cubehash.cu">
|
||||
<MaxRegCount>76</MaxRegCount>
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_shavite512.cu">
|
||||
<MaxRegCount>128</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<ClInclude Include="x11\cuda_x11_simd512_func.cuh" />
|
||||
<CudaCompile Include="x11\cuda_x11_simd512.cu">
|
||||
<MaxRegCount>64</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_streebog.cu" />
|
||||
<CudaCompile Include="x11\cuda_streebog_maxwell.cu" />
|
||||
<CudaCompile Include="x11\c11.cu" />
|
||||
<CudaCompile Include="x11\fresh.cu" />
|
||||
<CudaCompile Include="x11\sib.cu" />
|
||||
<CudaCompile Include="x11\fresh.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\s3.cu" />
|
||||
<CudaCompile Include="x11\timetravel.cu" />
|
||||
<CudaCompile Include="x11\bitcore.cu" />
|
||||
<CudaCompile Include="x11\exosis.cu" />
|
||||
<CudaCompile Include="x11\veltor.cu" />
|
||||
<CudaCompile Include="x11\x11.cu" />
|
||||
<CudaCompile Include="x11\x11evo.cu" />
|
||||
<CudaCompile Include="x12\x12.cu" />
|
||||
<CudaCompile Include="x11\simd_functions.cu">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\x11.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x13\cuda_x13_hamsi512.cu">
|
||||
<MaxRegCount>72</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x13\cuda_x13_fugue512.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x13\x13.cu" />
|
||||
<CudaCompile Include="x13\cuda_hsr_sm3.cu" />
|
||||
<CudaCompile Include="x13\hsr.cu" />
|
||||
<CudaCompile Include="x15\x14.cu" />
|
||||
<CudaCompile Include="x15\cuda_x14_shabal512.cu" />
|
||||
<CudaCompile Include="x15\cuda_x15_whirlpool.cu" />
|
||||
<CudaCompile Include="x15\x15.cu" />
|
||||
<CudaCompile Include="x15\whirlpool.cu" />
|
||||
<CudaCompile Include="x15\cuda_x15_whirlpool_sm3.cu" />
|
||||
<CudaCompile Include="x16\x16r.cu" />
|
||||
<CudaCompile Include="x16\x16s.cu" />
|
||||
<CudaCompile Include="x16\cuda_x16_echo512.cu" />
|
||||
<CudaCompile Include="x16\cuda_x16_fugue512.cu" />
|
||||
<CudaCompile Include="x16\cuda_x16_shabal512.cu" />
|
||||
<CudaCompile Include="x16\cuda_x16_simd512_80.cu" />
|
||||
<CudaCompile Include="x16\cuda_x16_echo512_64.cu">
|
||||
<CodeGeneration>compute_50,sm_50;compute_52,sm_52</CodeGeneration>
|
||||
<CudaCompile Include="x13\x13.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\hmq17.cu" />
|
||||
<CudaCompile Include="x17\sonoa.cu" />
|
||||
<CudaCompile Include="x17\x17.cu" />
|
||||
<CudaCompile Include="x17\cuda_x17_haval256.cu">
|
||||
<CudaCompile Include="x15\cuda_x14_shabal512.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x15\cuda_x15_whirlpool.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\cuda_x17_haval512.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\cuda_x17_sha512.cu">
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x15\x14.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x15\x15.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\x17.cu">
|
||||
</CudaCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="res\ccminer.ico" />
|
||||
@@ -630,7 +526,7 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 9.0.targets" />
|
||||
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 6.5.targets" />
|
||||
</ImportGroup>
|
||||
<!-- Copy the required dlls -->
|
||||
<Target Name="AfterBuild">
|
||||
|
||||
+32
-446
@@ -46,9 +46,6 @@
|
||||
<Filter Include="Source Files\CUDA\qubit">
|
||||
<UniqueIdentifier>{f3ed23a2-8ce7-41a5-b051-6da56047dc35}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\skunk">
|
||||
<UniqueIdentifier>{23ed23a2-8e7a-65a2-b051-8aa63047d352}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\x11">
|
||||
<UniqueIdentifier>{dd751f2d-bfd6-42c1-8f9b-cbe94e539353}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -58,9 +55,6 @@
|
||||
<Filter Include="Source Files\CUDA\x15">
|
||||
<UniqueIdentifier>{a2403c22-6777-46ab-a55a-3fcc7386c974}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\x16">
|
||||
<UniqueIdentifier>{55dfae6a-66ba-43e2-8ceb-98ee70cbdf16}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\x17">
|
||||
<UniqueIdentifier>{85dfae6a-66ca-4332-8cec-98ee70cbdf2f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -85,42 +79,6 @@
|
||||
<Filter Include="Source Files\neoscrypt">
|
||||
<UniqueIdentifier>{2037fd0d-e7a2-4da8-956c-150aec726a99}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\lyra2">
|
||||
<UniqueIdentifier>{1613763f-895c-4321-b58b-6f5849868956}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\lbry">
|
||||
<UniqueIdentifier>{3079ea1f-f768-455a-acd6-f517fac535b4}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\sha256">
|
||||
<UniqueIdentifier>{86a896c0-1688-4854-98e3-285d166069a3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\sia">
|
||||
<UniqueIdentifier>{86a896c0-1688-4854-98e0-285d166069a3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\crypto">
|
||||
<UniqueIdentifier>{fea0fce3-c0fe-42f7-aa37-0cbba10b008a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\crypto\xmr">
|
||||
<UniqueIdentifier>{af52b078-ed91-4c6e-b07a-e9243acc85d2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\crypto\bbr">
|
||||
<UniqueIdentifier>{af387eac-e9e6-4e91-a5e8-637b1e7a8d93}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\xmr">
|
||||
<UniqueIdentifier>{0f9aec5e-5409-488f-992a-2c108590d1ac}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\equi">
|
||||
<UniqueIdentifier>{031afae7-2a78-4e32-9738-4b589b6f7ff3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\tribus">
|
||||
<UniqueIdentifier>{1e548d79-c217-4203-989a-a592fe2b2de3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\phi">
|
||||
<UniqueIdentifier>{311e8d79-1612-4f0f-8591-23a592f2b2d3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\x12">
|
||||
<UniqueIdentifier>{xde48d89-fx12-1323-129a-b592fe2b2de3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="compat\jansson\dump.c">
|
||||
@@ -153,9 +111,6 @@
|
||||
<ClCompile Include="ccminer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pools.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crc32.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -165,12 +120,6 @@
|
||||
<ClCompile Include="sph\blake.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\blake2b.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\blake2s.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\bmw.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
@@ -195,6 +144,9 @@
|
||||
<ClCompile Include="sph\luffa.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\md_helper.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\sha2.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
@@ -222,21 +174,12 @@
|
||||
<ClCompile Include="sph\haval.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\ripemd.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\sph_sha2.c">
|
||||
<ClCompile Include="sph\haval_helper.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\sha2big.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\streebog.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="x13\sm3.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="compat\winansi.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -267,18 +210,12 @@
|
||||
<ClCompile Include="compat\jansson\error.c">
|
||||
<Filter>Source Files\jansson</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="compat\pthreads\pthread.h">
|
||||
<Filter>Header Files\compat</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="lyra2\Lyra2.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="lyra2\Sponge.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="lyra2\Lyra2Z.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="scrypt.cpp">
|
||||
<Filter>Source Files\CUDA\scrypt</Filter>
|
||||
</ClCompile>
|
||||
@@ -306,64 +243,10 @@
|
||||
<ClCompile Include="hefty1.c">
|
||||
<Filter>Source Files\CUDA\heavy</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="bench.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="bignum.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="nvapi.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="nvsettings.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sia\sia-rpc.cpp">
|
||||
<Filter>Source Files\sia</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\xmr-rpc.cpp">
|
||||
<Filter>Source Files\crypto</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\aesb.cpp">
|
||||
<Filter>Source Files\crypto\xmr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\cpu\c_keccak.c">
|
||||
<Filter>Source Files\crypto\xmr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\oaes_lib.cpp">
|
||||
<Filter>Source Files\crypto\xmr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\cryptolight-cpu.cpp">
|
||||
<Filter>Source Files\crypto\xmr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\cryptonight-cpu.cpp">
|
||||
<Filter>Source Files\crypto\xmr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\mman.c">
|
||||
<Filter>Source Files\crypto\bbr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\wildkeccak-cpu.cpp">
|
||||
<Filter>Source Files\crypto\bbr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="equi\equi.cpp">
|
||||
<Filter>Source Files\equi</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="equi\equihash.cpp">
|
||||
<Filter>Source Files\equi</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="equi\equi-stratum.cpp">
|
||||
<Filter>Source Files\equi</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="equi\blake2\blake2bx.cpp">
|
||||
<Filter>Source Files\equi</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="algos.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="compat.h">
|
||||
<Filter>Header Files\compat</Filter>
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elist.h">
|
||||
<Filter>Header Files</Filter>
|
||||
@@ -386,8 +269,8 @@
|
||||
<ClInclude Include="compat\stdbool.h">
|
||||
<Filter>Header Files\compat</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="compat\ccminer-config.h">
|
||||
<Filter>Header Files\compat</Filter>
|
||||
<ClInclude Include="cpuminer-config.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="uint256.h">
|
||||
<Filter>Header Files</Filter>
|
||||
@@ -395,18 +278,6 @@
|
||||
<ClInclude Include="cuda_groestlcoin.h">
|
||||
<Filter>Header Files\CUDA</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="quark\cuda_quark.h">
|
||||
<Filter>Header Files\CUDA</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="x11\cuda_x11.h">
|
||||
<Filter>Header Files\CUDA</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sph\blake2b.h">
|
||||
<Filter>Header Files\sph</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sph\blake2s.h">
|
||||
<Filter>Header Files\sph</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sph\sph_blake.h">
|
||||
<Filter>Header Files\sph</Filter>
|
||||
</ClInclude>
|
||||
@@ -452,7 +323,7 @@
|
||||
<ClInclude Include="cuda_helper.h">
|
||||
<Filter>Header Files\CUDA</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="cuda_vector_uint2x4.h">
|
||||
<ClInclude Include="cuda_vector.h">
|
||||
<Filter>Header Files\CUDA</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sph\sph_hamsi.h">
|
||||
@@ -461,9 +332,6 @@
|
||||
<ClInclude Include="sph\sph_shabal.h">
|
||||
<Filter>Header Files\sph</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sph\sph_streebog.h">
|
||||
<Filter>Header Files\sph</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sph\sph_whirlpool.h">
|
||||
<Filter>Header Files\sph</Filter>
|
||||
</ClInclude>
|
||||
@@ -512,9 +380,6 @@
|
||||
<ClInclude Include="lyra2\Lyra2.h">
|
||||
<Filter>Header Files\lyra2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lyra2\Lyra2Z.h">
|
||||
<Filter>Header Files\lyra2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lyra2\Sponge.h">
|
||||
<Filter>Header Files\lyra2</Filter>
|
||||
</ClInclude>
|
||||
@@ -539,78 +404,6 @@
|
||||
<ClInclude Include="hefty1.h">
|
||||
<Filter>Source Files\CUDA\heavy</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="bignum.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lyra2\cuda_lyra2v2_sm3.cuh">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lyra2\cuda_lyra2_sm2.cuh">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lyra2\cuda_lyra2_sm5.cuh">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lyra2\cuda_lyra2Z_sm5.cuh">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="quark\cuda_quark_blake512_sp.cuh">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="quark\cuda_bmw512_sm3.cuh">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="quark\cuda_quark_groestl512_sm2.cuh">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="x11\cuda_x11_simd512_sm2.cuh">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sia\sia-rpc.h">
|
||||
<Filter>Source Files\sia</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\xmr-rpc.h">
|
||||
<Filter>Source Files\crypto</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\mman.h">
|
||||
<Filter>Source Files\crypto\bbr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\wildkeccak.h">
|
||||
<Filter>Source Files\crypto\bbr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cn_aes.cuh">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cn_blake.cuh">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cn_groestl.cuh">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cn_jh.cuh">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cn_keccak.cuh">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cn_skein.cuh">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cryptolight.h">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cryptonight.h">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="equi\eqcuda.hpp">
|
||||
<Filter>Source Files\equi</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="equi\equihash.h">
|
||||
<Filter>Source Files\equi</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="x16\cuda_x16.h">
|
||||
<Filter>Header Files\CUDA</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CudaCompile Include="cuda.cpp">
|
||||
@@ -622,9 +415,6 @@
|
||||
<CudaCompile Include="JHA\cuda_jha_keccak512.cu">
|
||||
<Filter>Source Files\CUDA\JHA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="JHA\jha.cu">
|
||||
<Filter>Source Files\CUDA\JHA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="JHA\jackpotcoin.cu">
|
||||
<Filter>Source Files\CUDA\JHA</Filter>
|
||||
</CudaCompile>
|
||||
@@ -634,6 +424,12 @@
|
||||
<CudaCompile Include="JHA\cuda_jha_compactionTest.cu">
|
||||
<Filter>Source Files\CUDA\JHA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="pluck\pluck.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="pluck\cuda_pluck.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\cuda_jh512.cu">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</CudaCompile>
|
||||
@@ -667,11 +463,8 @@
|
||||
<CudaCompile Include="heavy\heavy.cu">
|
||||
<Filter>Source Files\CUDA\heavy</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="heavy\bastion.cu">
|
||||
<Filter>Source Files\CUDA\heavy</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="heavy\cuda_bastion.cu">
|
||||
<Filter>Source Files\CUDA\heavy</Filter>
|
||||
<CudaCompile Include="quark\animecoin.cu">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\cuda_bmw512.cu">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
@@ -682,16 +475,13 @@
|
||||
<CudaCompile Include="quark\cuda_quark_keccak512.cu">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\nist5.cu">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\quarkcoin.cu">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="qubit\deep.cu">
|
||||
<Filter>Source Files\CUDA\qubit</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="qubit\luffa.cu">
|
||||
<CudaCompile Include="qubit\doom.cu">
|
||||
<Filter>Source Files\CUDA\qubit</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="qubit\qubit.cu">
|
||||
@@ -700,9 +490,12 @@
|
||||
<CudaCompile Include="qubit\qubit_luffa512.cu">
|
||||
<Filter>Source Files\CUDA\qubit</Filter>
|
||||
</CudaCompile>
|
||||
<ClInclude Include="x11\cuda_x11_aes.cuh">
|
||||
<CudaCompile Include="cuda_nist5.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_aes.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</ClInclude>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_cubehash512.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
@@ -721,19 +514,13 @@
|
||||
<CudaCompile Include="x11\cuda_x11_simd512.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<ClInclude Include="x11\cuda_x11_simd512_func.cuh">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</ClInclude>
|
||||
<CudaCompile Include="x11\c11.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\fresh.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\x11.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\x11evo.cu">
|
||||
<CudaCompile Include="x11\simd_functions.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x13\cuda_x13_fugue512.cu">
|
||||
@@ -745,12 +532,6 @@
|
||||
<CudaCompile Include="x13\x13.cu">
|
||||
<Filter>Source Files\CUDA\x13</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x13\cuda_hsr_sm3.cu">
|
||||
<Filter>Source Files\CUDA\x13</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x13\hsr.cu">
|
||||
<Filter>Source Files\CUDA\x13</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="cuda_checkhash.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
@@ -766,108 +547,30 @@
|
||||
<CudaCompile Include="x15\cuda_x15_whirlpool.cu">
|
||||
<Filter>Source Files\CUDA\x15</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x15\whirlpool.cu">
|
||||
<Filter>Source Files\CUDA\x15</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\cuda_x17_haval256.cu">
|
||||
<CudaCompile Include="x17\cuda_x17_haval512.cu">
|
||||
<Filter>Source Files\CUDA\x17</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\cuda_x17_sha512.cu">
|
||||
<Filter>Source Files\CUDA\x17</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\hmq17.cu">
|
||||
<Filter>Source Files\CUDA\x17</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\sonoa.cu">
|
||||
<Filter>Source Files\CUDA\x17</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\x17.cu">
|
||||
<Filter>Source Files\CUDA\x17</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="pentablake.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="polytimos.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="phi\phi.cu">
|
||||
<Filter>Source Files\CUDA\phi</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="phi\phi2.cu">
|
||||
<Filter>Source Files\CUDA\phi</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="phi\cuda_phi2.cu">
|
||||
<Filter>Source Files\CUDA\phi</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="phi\cuda_phi2_cubehash512.cu">
|
||||
<Filter>Source Files\CUDA\phi</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="skunk\skunk.cu">
|
||||
<Filter>Source Files\CUDA\skunk</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="skunk\cuda_skunk.cu">
|
||||
<Filter>Source Files\CUDA\skunk</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="skunk\cuda_skunk_streebog.cu">
|
||||
<Filter>Source Files\CUDA\skunk</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="tribus\tribus.cu">
|
||||
<Filter>Source Files\CUDA\tribus</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="tribus\cuda_echo512_final.cu">
|
||||
<Filter>Source Files\CUDA\tribus</Filter>
|
||||
</CudaCompile>
|
||||
<ClInclude Include="tribus\cuda_echo512_aes.cuh">
|
||||
<Filter>Source Files\CUDA\tribus</Filter>
|
||||
</ClInclude>
|
||||
<CudaCompile Include="x11\sib.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_streebog.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_streebog_maxwell.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\s3.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x12\x12.cu">
|
||||
<Filter>Source Files\CUDA\x12</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\timetravel.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\bitcore.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\exosis.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\veltor.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\blake256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\decred.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\vanilla.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\keccak256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_blake256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_bmw256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_cubehash256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_fugue256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
@@ -877,12 +580,15 @@
|
||||
<CudaCompile Include="Algo256\cuda_keccak256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_keccak256_sm3.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_skein256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\cuda_lyra2.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\lyra2RE.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="zr5.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
@@ -925,126 +631,6 @@
|
||||
<CudaCompile Include="neoscrypt\cuda_neoscrypt.cu">
|
||||
<Filter>Source Files\neoscrypt</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\bmw.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_bmw.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\allium.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\cuda_lyra2.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\cuda_lyra2v2.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\lyra2RE.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\lyra2REv2.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\cuda_lyra2v3.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<ClInclude Include="lyra2\cuda_lyra2v3_sm3.cuh">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</ClInclude>
|
||||
<CudaCompile Include="lyra2\lyra2REv3.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\cuda_lyra2Z.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\lyra2Z.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="blake2b.cu">
|
||||
<Filter>Source Files\CUDA\</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\blake2s.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lbry\cuda_sha256_lbry.cu">
|
||||
<Filter>Source Files\CUDA\lbry</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lbry\cuda_sha512_lbry.cu">
|
||||
<Filter>Source Files\CUDA\lbry</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lbry\cuda_lbry_merged.cu">
|
||||
<Filter>Source Files\CUDA\lbry</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lbry\lbry.cu">
|
||||
<Filter>Source Files\CUDA\lbry</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="sha256\cuda_sha256d.cu">
|
||||
<Filter>Source Files\CUDA\sha256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="sha256\sha256d.cu">
|
||||
<Filter>Source Files\CUDA\sha256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="sha256\cuda_sha256t.cu">
|
||||
<Filter>Source Files\CUDA\sha256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="sha256\sha256t.cu">
|
||||
<Filter>Source Files\CUDA\sha256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="sha256\cuda_sha256q.cu">
|
||||
<Filter>Source Files\CUDA\sha256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="sha256\sha256q.cu">
|
||||
<Filter>Source Files\CUDA\sha256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="sia\sia.cu">
|
||||
<Filter>Source Files\sia</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptolight.cu">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptolight-core.cu">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptonight.cu">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptonight-core.cu">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptonight-extra.cu">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\wildkeccak.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="equi\cuda_equi.cu">
|
||||
<Filter>Source Files\equi</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x15\cuda_x15_whirlpool_sm3.cu">
|
||||
<Filter>Source Files\CUDA\x15</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x16\cuda_x16_echo512.cu">
|
||||
<Filter>Source Files\CUDA\x16</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x16\cuda_x16_echo512_64.cu">
|
||||
<Filter>Source Files\CUDA\x16</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x16\cuda_x16_fugue512.cu">
|
||||
<Filter>Source Files\CUDA\x16</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x16\cuda_x16_shabal512.cu">
|
||||
<Filter>Source Files\CUDA\x16</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x16\cuda_x16_simd512_80.cu">
|
||||
<Filter>Source Files\CUDA\x16</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x16\x16r.cu">
|
||||
<Filter>Source Files\CUDA\x16</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x16\x16s.cu">
|
||||
<Filter>Source Files\CUDA\x16</Filter>
|
||||
</CudaCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="res\ccminer.ico">
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
#ifdef WIN32
|
||||
|
||||
#include <windows.h>
|
||||
#include <time.h>
|
||||
|
||||
#define localtime_r(src, dst) localtime_s(dst, src)
|
||||
extern int opt_priority;
|
||||
|
||||
static __inline void sleep(int secs)
|
||||
{
|
||||
@@ -17,8 +16,6 @@ enum {
|
||||
PRIO_PROCESS = 0,
|
||||
};
|
||||
|
||||
extern int opt_priority;
|
||||
|
||||
static __inline int setpriority(int which, int who, int prio)
|
||||
{
|
||||
switch (opt_priority) {
|
||||
@@ -51,17 +48,6 @@ static __inline int setpriority(int which, int who, int prio)
|
||||
#define strcasecmp(x,y) _stricmp(x,y)
|
||||
typedef int ssize_t;
|
||||
|
||||
__inline int msver(void) {
|
||||
switch (_MSC_VER) {
|
||||
case 1500: return 2008;
|
||||
case 1600: return 2010;
|
||||
case 1700: return 2012;
|
||||
case 1800: return 2013;
|
||||
case 1900: return 2015;
|
||||
default: return (_MSC_VER/100);
|
||||
}
|
||||
}
|
||||
|
||||
#include <stdlib.h>
|
||||
static __inline char * dirname(char *file) {
|
||||
char buffer[_MAX_PATH] = { 0 };
|
||||
|
||||
@@ -1,602 +0,0 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#ifndef BITCOIN_BIGNUM_H
|
||||
#define BITCOIN_BIGNUM_H
|
||||
|
||||
#ifndef PROTOCOL_VERSION
|
||||
#define PROTOCOL_VERSION 70001
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
#include "uint256.h"
|
||||
|
||||
#include <openssl/bn.h>
|
||||
|
||||
#include "serialize.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/** Errors thrown by the bignum class */
|
||||
class bignum_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit bignum_error(const std::string& str) : std::runtime_error(str) {}
|
||||
};
|
||||
|
||||
|
||||
/** RAII encapsulated BN_CTX (OpenSSL bignum context) */
|
||||
class CAutoBN_CTX
|
||||
{
|
||||
protected:
|
||||
BN_CTX* pctx;
|
||||
BN_CTX* operator=(BN_CTX* pnew) { return pctx = pnew; }
|
||||
|
||||
public:
|
||||
CAutoBN_CTX()
|
||||
{
|
||||
pctx = BN_CTX_new();
|
||||
if (pctx == NULL)
|
||||
throw bignum_error("CAutoBN_CTX : BN_CTX_new() returned NULL");
|
||||
}
|
||||
|
||||
~CAutoBN_CTX()
|
||||
{
|
||||
if (pctx != NULL)
|
||||
BN_CTX_free(pctx);
|
||||
}
|
||||
|
||||
operator BN_CTX*() { return pctx; }
|
||||
BN_CTX& operator*() { return *pctx; }
|
||||
BN_CTX** operator&() { return &pctx; }
|
||||
bool operator!() { return (pctx == NULL); }
|
||||
};
|
||||
|
||||
|
||||
/** C++ wrapper for BIGNUM (OpenSSL bignum) */
|
||||
class CBigNum : public BIGNUM
|
||||
{
|
||||
public:
|
||||
CBigNum()
|
||||
{
|
||||
BN_init(this);
|
||||
}
|
||||
|
||||
CBigNum(const CBigNum& b)
|
||||
{
|
||||
BN_init(this);
|
||||
if (!BN_copy(this, &b))
|
||||
{
|
||||
BN_clear_free(this);
|
||||
throw bignum_error("CBigNum::CBigNum(const CBigNum&) : BN_copy failed");
|
||||
}
|
||||
}
|
||||
|
||||
CBigNum& operator=(const CBigNum& b)
|
||||
{
|
||||
if (!BN_copy(this, &b))
|
||||
throw bignum_error("CBigNum::operator= : BN_copy failed");
|
||||
return (*this);
|
||||
}
|
||||
|
||||
~CBigNum()
|
||||
{
|
||||
BN_clear_free(this);
|
||||
}
|
||||
|
||||
//CBigNum(char n) is not portable. Use 'signed char' or 'unsigned char'.
|
||||
CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(int64 n) { BN_init(this); setint64(n); }
|
||||
CBigNum(unsigned char n) { BN_init(this); setulong(n); }
|
||||
CBigNum(unsigned short n) { BN_init(this); setulong(n); }
|
||||
CBigNum(unsigned int n) { BN_init(this); setulong(n); }
|
||||
CBigNum(unsigned long n) { BN_init(this); setulong(n); }
|
||||
CBigNum(uint64 n) { BN_init(this); setuint64(n); }
|
||||
explicit CBigNum(uint256 n) { BN_init(this); setuint256(n); }
|
||||
|
||||
explicit CBigNum(const std::vector<unsigned char>& vch)
|
||||
{
|
||||
BN_init(this);
|
||||
setvch(vch);
|
||||
}
|
||||
|
||||
void setulong(unsigned long n)
|
||||
{
|
||||
if (!BN_set_word(this, n))
|
||||
throw bignum_error("CBigNum conversion from unsigned long : BN_set_word failed");
|
||||
}
|
||||
|
||||
unsigned long getulong() const
|
||||
{
|
||||
return (unsigned long) BN_get_word(this);
|
||||
}
|
||||
|
||||
unsigned int getuint() const
|
||||
{
|
||||
return (unsigned int) BN_get_word(this);
|
||||
}
|
||||
|
||||
int getint() const
|
||||
{
|
||||
unsigned long n = (unsigned long) BN_get_word(this);
|
||||
if (!BN_is_negative(this))
|
||||
return (n > (unsigned long)std::numeric_limits<int>::max() ? std::numeric_limits<int>::max() : n);
|
||||
else
|
||||
return (n > (unsigned long)std::numeric_limits<int>::max() ? std::numeric_limits<int>::min() : -(int)n);
|
||||
}
|
||||
|
||||
void setint64(int64 sn)
|
||||
{
|
||||
unsigned char pch[sizeof(sn) + 6];
|
||||
unsigned char* p = pch + 4;
|
||||
bool fNegative;
|
||||
uint64 n;
|
||||
|
||||
if (sn < 0LL)
|
||||
{
|
||||
// Since the minimum signed integer cannot be represented as positive so long as its type is signed,
|
||||
// and it's not well-defined what happens if you make it unsigned before negating it,
|
||||
// we instead increment the negative integer by 1, convert it, then increment the (now positive) unsigned integer by 1 to compensate
|
||||
n = -(sn + 1);
|
||||
++n;
|
||||
fNegative = true;
|
||||
} else {
|
||||
n = sn;
|
||||
fNegative = false;
|
||||
}
|
||||
|
||||
bool fLeadingZeroes = true;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
unsigned char c = (n >> 56) & 0xff;
|
||||
n <<= 8;
|
||||
if (fLeadingZeroes)
|
||||
{
|
||||
if (c == 0)
|
||||
continue;
|
||||
if (c & 0x80)
|
||||
*p++ = (fNegative ? 0x80 : 0);
|
||||
else if (fNegative)
|
||||
c |= 0x80;
|
||||
fLeadingZeroes = false;
|
||||
}
|
||||
*p++ = c;
|
||||
}
|
||||
unsigned int nSize = (unsigned int) (p - (pch + 4));
|
||||
pch[0] = (nSize >> 24) & 0xff;
|
||||
pch[1] = (nSize >> 16) & 0xff;
|
||||
pch[2] = (nSize >> 8) & 0xff;
|
||||
pch[3] = (nSize) & 0xff;
|
||||
BN_mpi2bn(pch, (int) (p - pch), this);
|
||||
}
|
||||
|
||||
void setuint64(uint64 n)
|
||||
{
|
||||
unsigned char pch[sizeof(n) + 6];
|
||||
unsigned char* p = pch + 4;
|
||||
bool fLeadingZeroes = true;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
unsigned char c = (n >> 56) & 0xff;
|
||||
n <<= 8;
|
||||
if (fLeadingZeroes)
|
||||
{
|
||||
if (c == 0)
|
||||
continue;
|
||||
if (c & 0x80)
|
||||
*p++ = 0;
|
||||
fLeadingZeroes = false;
|
||||
}
|
||||
*p++ = c;
|
||||
}
|
||||
unsigned int nSize = (unsigned int) (p - (pch + 4));
|
||||
pch[0] = (nSize >> 24) & 0xff;
|
||||
pch[1] = (nSize >> 16) & 0xff;
|
||||
pch[2] = (nSize >> 8) & 0xff;
|
||||
pch[3] = (nSize) & 0xff;
|
||||
BN_mpi2bn(pch, (int) (p - pch), this);
|
||||
}
|
||||
|
||||
void setuint256(uint256 n)
|
||||
{
|
||||
unsigned char pch[sizeof(n) + 6];
|
||||
unsigned char* p = pch + 4;
|
||||
bool fLeadingZeroes = true;
|
||||
unsigned char* pbegin = (unsigned char*)&n;
|
||||
unsigned char* psrc = pbegin + sizeof(n);
|
||||
while (psrc != pbegin)
|
||||
{
|
||||
unsigned char c = *(--psrc);
|
||||
if (fLeadingZeroes)
|
||||
{
|
||||
if (c == 0)
|
||||
continue;
|
||||
if (c & 0x80)
|
||||
*p++ = 0;
|
||||
fLeadingZeroes = false;
|
||||
}
|
||||
*p++ = c;
|
||||
}
|
||||
unsigned int nSize = (unsigned int) (p - (pch + 4));
|
||||
pch[0] = (nSize >> 24) & 0xff;
|
||||
pch[1] = (nSize >> 16) & 0xff;
|
||||
pch[2] = (nSize >> 8) & 0xff;
|
||||
pch[3] = (nSize >> 0) & 0xff;
|
||||
BN_mpi2bn(pch, (int) (p - pch), this);
|
||||
}
|
||||
|
||||
uint256 getuint256() const
|
||||
{
|
||||
unsigned int nSize = BN_bn2mpi(this, NULL);
|
||||
if (nSize < 4)
|
||||
return 0;
|
||||
std::vector<unsigned char> vch(nSize);
|
||||
BN_bn2mpi(this, &vch[0]);
|
||||
if (vch.size() > 4)
|
||||
vch[4] &= 0x7f;
|
||||
uint256 n = 0;
|
||||
for (unsigned int i = 0, j = (unsigned int) vch.size()-1; i < sizeof(n) && j >= 4; i++, j--)
|
||||
((unsigned char*)&n)[i] = vch[j];
|
||||
return n;
|
||||
}
|
||||
|
||||
void setvch(const std::vector<unsigned char>& vch)
|
||||
{
|
||||
std::vector<unsigned char> vch2(vch.size() + 4);
|
||||
unsigned int nSize = (unsigned int) vch.size();
|
||||
// BIGNUM's byte stream format expects 4 bytes of
|
||||
// big endian size data info at the front
|
||||
vch2[0] = (nSize >> 24) & 0xff;
|
||||
vch2[1] = (nSize >> 16) & 0xff;
|
||||
vch2[2] = (nSize >> 8) & 0xff;
|
||||
vch2[3] = (nSize >> 0) & 0xff;
|
||||
// swap data to big endian
|
||||
reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4);
|
||||
BN_mpi2bn(&vch2[0], (int) vch2.size(), this);
|
||||
}
|
||||
|
||||
std::vector<unsigned char> getvch() const
|
||||
{
|
||||
unsigned int nSize = BN_bn2mpi(this, NULL);
|
||||
if (nSize <= 4)
|
||||
return std::vector<unsigned char>();
|
||||
std::vector<unsigned char> vch(nSize);
|
||||
BN_bn2mpi(this, &vch[0]);
|
||||
vch.erase(vch.begin(), vch.begin() + 4);
|
||||
reverse(vch.begin(), vch.end());
|
||||
return vch;
|
||||
}
|
||||
|
||||
// The "compact" format is a representation of a whole
|
||||
// number N using an unsigned 32bit number similar to a
|
||||
// floating point format.
|
||||
// The most significant 8 bits are the unsigned exponent of base 256.
|
||||
// This exponent can be thought of as "number of bytes of N".
|
||||
// The lower 23 bits are the mantissa.
|
||||
// Bit number 24 (0x800000) represents the sign of N.
|
||||
// N = (-1^sign) * mantissa * 256^(exponent-3)
|
||||
//
|
||||
// Satoshi's original implementation used BN_bn2mpi() and BN_mpi2bn().
|
||||
// MPI uses the most significant bit of the first byte as sign.
|
||||
// Thus 0x1234560000 is compact (0x05123456)
|
||||
// and 0xc0de000000 is compact (0x0600c0de)
|
||||
// (0x05c0de00) would be -0x40de000000
|
||||
//
|
||||
// Bitcoin only uses this "compact" format for encoding difficulty
|
||||
// targets, which are unsigned 256bit quantities. Thus, all the
|
||||
// complexities of the sign bit and using base 256 are probably an
|
||||
// implementation accident.
|
||||
//
|
||||
// This implementation directly uses shifts instead of going
|
||||
// through an intermediate MPI representation.
|
||||
CBigNum& SetCompact(unsigned int nCompact)
|
||||
{
|
||||
unsigned int nSize = nCompact >> 24;
|
||||
bool fNegative =(nCompact & 0x00800000) != 0;
|
||||
unsigned int nWord = nCompact & 0x007fffff;
|
||||
if (nSize <= 3)
|
||||
{
|
||||
nWord >>= 8*(3-nSize);
|
||||
BN_set_word(this, nWord);
|
||||
}
|
||||
else
|
||||
{
|
||||
BN_set_word(this, nWord);
|
||||
BN_lshift(this, this, 8*(nSize-3));
|
||||
}
|
||||
BN_set_negative(this, fNegative);
|
||||
return *this;
|
||||
}
|
||||
|
||||
unsigned int GetCompact() const
|
||||
{
|
||||
unsigned int nSize = BN_num_bytes(this);
|
||||
unsigned int nCompact = 0;
|
||||
if (nSize <= 3)
|
||||
nCompact = (unsigned int) BN_get_word(this) << 8*(3-nSize);
|
||||
else
|
||||
{
|
||||
CBigNum bn;
|
||||
BN_rshift(&bn, this, 8*(nSize-3));
|
||||
nCompact = (unsigned int) BN_get_word(&bn);
|
||||
}
|
||||
// The 0x00800000 bit denotes the sign.
|
||||
// Thus, if it is already set, divide the mantissa by 256 and increase the exponent.
|
||||
if (nCompact & 0x00800000)
|
||||
{
|
||||
nCompact >>= 8;
|
||||
nSize++;
|
||||
}
|
||||
nCompact |= nSize << 24;
|
||||
nCompact |= (BN_is_negative(this) ? 0x00800000 : 0);
|
||||
return nCompact;
|
||||
}
|
||||
|
||||
void SetHex(const std::string& str)
|
||||
{
|
||||
// skip 0x
|
||||
const char* psz = str.c_str();
|
||||
while (isspace(*psz))
|
||||
psz++;
|
||||
bool fNegative = false;
|
||||
if (*psz == '-')
|
||||
{
|
||||
fNegative = true;
|
||||
psz++;
|
||||
}
|
||||
if (psz[0] == '0' && tolower(psz[1]) == 'x')
|
||||
psz += 2;
|
||||
while (isspace(*psz))
|
||||
psz++;
|
||||
|
||||
// hex string to bignum
|
||||
static const signed char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
|
||||
*this = 0;
|
||||
while (isxdigit(*psz))
|
||||
{
|
||||
*this <<= 4;
|
||||
int n = phexdigit[(unsigned char)*psz++];
|
||||
*this += n;
|
||||
}
|
||||
if (fNegative)
|
||||
*this = 0 - *this;
|
||||
}
|
||||
|
||||
std::string ToString(int nBase=10) const
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum bnBase = nBase;
|
||||
CBigNum bn0 = 0;
|
||||
std::string str;
|
||||
CBigNum bn = *this;
|
||||
BN_set_negative(&bn, false);
|
||||
CBigNum dv;
|
||||
CBigNum rem;
|
||||
if (BN_cmp(&bn, &bn0) == 0)
|
||||
return "0";
|
||||
while (BN_cmp(&bn, &bn0) > 0)
|
||||
{
|
||||
if (!BN_div(&dv, &rem, &bn, &bnBase, pctx))
|
||||
throw bignum_error("CBigNum::ToString() : BN_div failed");
|
||||
bn = dv;
|
||||
unsigned int c = rem.getulong();
|
||||
str += "0123456789abcdef"[c];
|
||||
}
|
||||
if (BN_is_negative(this))
|
||||
str += "-";
|
||||
reverse(str.begin(), str.end());
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string GetHex() const
|
||||
{
|
||||
return ToString(16);
|
||||
}
|
||||
|
||||
unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const
|
||||
{
|
||||
return ::GetSerializeSize(getvch(), nType, nVersion);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const
|
||||
{
|
||||
::Serialize(s, getvch(), nType, nVersion);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Unserialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION)
|
||||
{
|
||||
std::vector<unsigned char> vch;
|
||||
::Unserialize(s, vch, nType, nVersion);
|
||||
setvch(vch);
|
||||
}
|
||||
|
||||
|
||||
bool operator!() const
|
||||
{
|
||||
return BN_is_zero(this);
|
||||
}
|
||||
|
||||
CBigNum& operator+=(const CBigNum& b)
|
||||
{
|
||||
if (!BN_add(this, this, &b))
|
||||
throw bignum_error("CBigNum::operator+= : BN_add failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator-=(const CBigNum& b)
|
||||
{
|
||||
*this = *this - b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator*=(const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
if (!BN_mul(this, this, &b, pctx))
|
||||
throw bignum_error("CBigNum::operator*= : BN_mul failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator/=(const CBigNum& b)
|
||||
{
|
||||
*this = *this / b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator%=(const CBigNum& b)
|
||||
{
|
||||
*this = *this % b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator<<=(unsigned int shift)
|
||||
{
|
||||
if (!BN_lshift(this, this, shift))
|
||||
throw bignum_error("CBigNum:operator<<= : BN_lshift failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator>>=(unsigned int shift)
|
||||
{
|
||||
// Note: BN_rshift segfaults on 64-bit if 2^shift is greater than the number
|
||||
// if built on ubuntu 9.04 or 9.10, probably depends on version of OpenSSL
|
||||
CBigNum a = 1;
|
||||
a <<= shift;
|
||||
if (BN_cmp(&a, this) > 0)
|
||||
{
|
||||
*this = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (!BN_rshift(this, this, shift))
|
||||
throw bignum_error("CBigNum:operator>>= : BN_rshift failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
CBigNum& operator++()
|
||||
{
|
||||
// prefix operator
|
||||
if (!BN_add(this, this, BN_value_one()))
|
||||
throw bignum_error("CBigNum::operator++ : BN_add failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
const CBigNum operator++(int)
|
||||
{
|
||||
// postfix operator
|
||||
const CBigNum ret = *this;
|
||||
++(*this);
|
||||
return ret;
|
||||
}
|
||||
|
||||
CBigNum& operator--()
|
||||
{
|
||||
// prefix operator
|
||||
CBigNum r;
|
||||
if (!BN_sub(&r, this, BN_value_one()))
|
||||
throw bignum_error("CBigNum::operator-- : BN_sub failed");
|
||||
*this = r;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const CBigNum operator--(int)
|
||||
{
|
||||
// postfix operator
|
||||
const CBigNum ret = *this;
|
||||
--(*this);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
friend inline const CBigNum operator-(const CBigNum& a, const CBigNum& b);
|
||||
friend inline const CBigNum operator/(const CBigNum& a, const CBigNum& b);
|
||||
friend inline const CBigNum operator%(const CBigNum& a, const CBigNum& b);
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline const CBigNum operator+(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CBigNum r;
|
||||
if (!BN_add(&r, &a, &b))
|
||||
throw bignum_error("CBigNum::operator+ : BN_add failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator-(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CBigNum r;
|
||||
if (!BN_sub(&r, &a, &b))
|
||||
throw bignum_error("CBigNum::operator- : BN_sub failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator-(const CBigNum& a)
|
||||
{
|
||||
CBigNum r(a);
|
||||
BN_set_negative(&r, !BN_is_negative(&r));
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator*(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum r;
|
||||
if (!BN_mul(&r, &a, &b, pctx))
|
||||
throw bignum_error("CBigNum::operator* : BN_mul failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator/(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum r;
|
||||
if (!BN_div(&r, NULL, &a, &b, pctx))
|
||||
throw bignum_error("CBigNum::operator/ : BN_div failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator%(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum r;
|
||||
if (!BN_mod(&r, &a, &b, pctx))
|
||||
throw bignum_error("CBigNum::operator% : BN_div failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator<<(const CBigNum& a, unsigned int shift)
|
||||
{
|
||||
CBigNum r;
|
||||
if (!BN_lshift(&r, &a, shift))
|
||||
throw bignum_error("CBigNum:operator<< : BN_lshift failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator>>(const CBigNum& a, unsigned int shift)
|
||||
{
|
||||
CBigNum r = a;
|
||||
r >>= shift;
|
||||
return r;
|
||||
}
|
||||
|
||||
inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) == 0); }
|
||||
inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) != 0); }
|
||||
inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) <= 0); }
|
||||
inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) >= 0); }
|
||||
inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) < 0); }
|
||||
inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) > 0); }
|
||||
|
||||
#endif
|
||||
@@ -1,902 +0,0 @@
|
||||
/* crypto/bn/bn.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
*
|
||||
* Portions of the attached software ("Contribution") are developed by
|
||||
* SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
|
||||
*
|
||||
* The Contribution is licensed pursuant to the Eric Young open source
|
||||
* license provided above.
|
||||
*
|
||||
* The binary polynomial arithmetic software is originally written by
|
||||
* Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BN_H
|
||||
#define HEADER_BN_H
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
#include <stdio.h> /* FILE */
|
||||
#endif
|
||||
#include <openssl/ossl_typ.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* These preprocessor symbols control various aspects of the bignum headers and
|
||||
* library code. They're not defined by any "normal" configuration, as they are
|
||||
* intended for development and testing purposes. NB: defining all three can be
|
||||
* useful for debugging application code as well as openssl itself.
|
||||
*
|
||||
* BN_DEBUG - turn on various debugging alterations to the bignum code
|
||||
* BN_DEBUG_RAND - uses random poisoning of unused words to trip up
|
||||
* mismanagement of bignum internals. You must also define BN_DEBUG.
|
||||
*/
|
||||
/* #define BN_DEBUG */
|
||||
/* #define BN_DEBUG_RAND */
|
||||
|
||||
#ifndef OPENSSL_SMALL_FOOTPRINT
|
||||
#define BN_MUL_COMBA
|
||||
#define BN_SQR_COMBA
|
||||
#define BN_RECURSION
|
||||
#endif
|
||||
|
||||
/* This next option uses the C libraries (2 word)/(1 word) function.
|
||||
* If it is not defined, I use my C version (which is slower).
|
||||
* The reason for this flag is that when the particular C compiler
|
||||
* library routine is used, and the library is linked with a different
|
||||
* compiler, the library is missing. This mostly happens when the
|
||||
* library is built with gcc and then linked using normal cc. This would
|
||||
* be a common occurrence because gcc normally produces code that is
|
||||
* 2 times faster than system compilers for the big number stuff.
|
||||
* For machines with only one compiler (or shared libraries), this should
|
||||
* be on. Again this in only really a problem on machines
|
||||
* using "long long's", are 32bit, and are not using my assembler code. */
|
||||
#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \
|
||||
defined(OPENSSL_SYS_WIN32) || defined(linux)
|
||||
# ifndef BN_DIV2W
|
||||
# define BN_DIV2W
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* assuming long is 64bit - this is the DEC Alpha
|
||||
* unsigned long long is only 64 bits :-(, don't define
|
||||
* BN_LLONG for the DEC Alpha */
|
||||
#ifdef SIXTY_FOUR_BIT_LONG
|
||||
#define BN_ULLONG unsigned long long
|
||||
#define BN_ULONG unsigned long
|
||||
#define BN_LONG long
|
||||
#define BN_BITS 128
|
||||
#define BN_BYTES 8
|
||||
#define BN_BITS2 64
|
||||
#define BN_BITS4 32
|
||||
#define BN_MASK (0xffffffffffffffffffffffffffffffffLL)
|
||||
#define BN_MASK2 (0xffffffffffffffffL)
|
||||
#define BN_MASK2l (0xffffffffL)
|
||||
#define BN_MASK2h (0xffffffff00000000L)
|
||||
#define BN_MASK2h1 (0xffffffff80000000L)
|
||||
#define BN_TBIT (0x8000000000000000L)
|
||||
#define BN_DEC_CONV (10000000000000000000UL)
|
||||
#define BN_DEC_FMT1 "%lu"
|
||||
#define BN_DEC_FMT2 "%019lu"
|
||||
#define BN_DEC_NUM 19
|
||||
#define BN_HEX_FMT1 "%lX"
|
||||
#define BN_HEX_FMT2 "%016lX"
|
||||
#endif
|
||||
|
||||
/* This is where the long long data type is 64 bits, but long is 32.
|
||||
* For machines where there are 64bit registers, this is the mode to use.
|
||||
* IRIX, on R4000 and above should use this mode, along with the relevant
|
||||
* assembler code :-). Do NOT define BN_LLONG.
|
||||
*/
|
||||
#ifdef SIXTY_FOUR_BIT
|
||||
#undef BN_LLONG
|
||||
#undef BN_ULLONG
|
||||
#define BN_ULONG unsigned long long
|
||||
#define BN_LONG long long
|
||||
#define BN_BITS 128
|
||||
#define BN_BYTES 8
|
||||
#define BN_BITS2 64
|
||||
#define BN_BITS4 32
|
||||
#define BN_MASK2 (0xffffffffffffffffLL)
|
||||
#define BN_MASK2l (0xffffffffL)
|
||||
#define BN_MASK2h (0xffffffff00000000LL)
|
||||
#define BN_MASK2h1 (0xffffffff80000000LL)
|
||||
#define BN_TBIT (0x8000000000000000LL)
|
||||
#define BN_DEC_CONV (10000000000000000000ULL)
|
||||
#define BN_DEC_FMT1 "%llu"
|
||||
#define BN_DEC_FMT2 "%019llu"
|
||||
#define BN_DEC_NUM 19
|
||||
#define BN_HEX_FMT1 "%llX"
|
||||
#define BN_HEX_FMT2 "%016llX"
|
||||
#endif
|
||||
|
||||
#ifdef THIRTY_TWO_BIT
|
||||
#ifdef BN_LLONG
|
||||
# if defined(_WIN32) && !defined(__GNUC__)
|
||||
# define BN_ULLONG unsigned __int64
|
||||
# define BN_MASK (0xffffffffffffffffI64)
|
||||
# else
|
||||
# define BN_ULLONG unsigned long long
|
||||
# define BN_MASK (0xffffffffffffffffLL)
|
||||
# endif
|
||||
#endif
|
||||
#define BN_ULONG unsigned int
|
||||
#define BN_LONG int
|
||||
#define BN_BITS 64
|
||||
#define BN_BYTES 4
|
||||
#define BN_BITS2 32
|
||||
#define BN_BITS4 16
|
||||
#define BN_MASK2 (0xffffffffL)
|
||||
#define BN_MASK2l (0xffff)
|
||||
#define BN_MASK2h1 (0xffff8000L)
|
||||
#define BN_MASK2h (0xffff0000L)
|
||||
#define BN_TBIT (0x80000000L)
|
||||
#define BN_DEC_CONV (1000000000L)
|
||||
#define BN_DEC_FMT1 "%u"
|
||||
#define BN_DEC_FMT2 "%09u"
|
||||
#define BN_DEC_NUM 9
|
||||
#define BN_HEX_FMT1 "%X"
|
||||
#define BN_HEX_FMT2 "%08X"
|
||||
#endif
|
||||
|
||||
/* 2011-02-22 SMS.
|
||||
* In various places, a size_t variable or a type cast to size_t was
|
||||
* used to perform integer-only operations on pointers. This failed on
|
||||
* VMS with 64-bit pointers (CC /POINTER_SIZE = 64) because size_t is
|
||||
* still only 32 bits. What's needed in these cases is an integer type
|
||||
* with the same size as a pointer, which size_t is not certain to be.
|
||||
* The only fix here is VMS-specific.
|
||||
*/
|
||||
#if defined(OPENSSL_SYS_VMS)
|
||||
# if __INITIAL_POINTER_SIZE == 64
|
||||
# define PTR_SIZE_INT long long
|
||||
# else /* __INITIAL_POINTER_SIZE == 64 */
|
||||
# define PTR_SIZE_INT int
|
||||
# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
|
||||
#else /* defined(OPENSSL_SYS_VMS) */
|
||||
# define PTR_SIZE_INT size_t
|
||||
#endif /* defined(OPENSSL_SYS_VMS) [else] */
|
||||
|
||||
#define BN_DEFAULT_BITS 1280
|
||||
|
||||
#define BN_FLG_MALLOCED 0x01
|
||||
#define BN_FLG_STATIC_DATA 0x02
|
||||
#define BN_FLG_CONSTTIME 0x04 /* avoid leaking exponent information through timing,
|
||||
* BN_mod_exp_mont() will call BN_mod_exp_mont_consttime,
|
||||
* BN_div() will call BN_div_no_branch,
|
||||
* BN_mod_inverse() will call BN_mod_inverse_no_branch.
|
||||
*/
|
||||
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
#define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME /* deprecated name for the flag */
|
||||
/* avoid leaking exponent information through timings
|
||||
* (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime) */
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
#define BN_FLG_FREE 0x8000 /* used for debuging */
|
||||
#endif
|
||||
#define BN_set_flags(b,n) ((b)->flags|=(n))
|
||||
#define BN_get_flags(b,n) ((b)->flags&(n))
|
||||
|
||||
/* get a clone of a BIGNUM with changed flags, for *temporary* use only
|
||||
* (the two BIGNUMs cannot not be used in parallel!) */
|
||||
#define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \
|
||||
(dest)->top=(b)->top, \
|
||||
(dest)->dmax=(b)->dmax, \
|
||||
(dest)->neg=(b)->neg, \
|
||||
(dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \
|
||||
| ((b)->flags & ~BN_FLG_MALLOCED) \
|
||||
| BN_FLG_STATIC_DATA \
|
||||
| (n)))
|
||||
|
||||
/* Already declared in ossl_typ.h */
|
||||
#if 0
|
||||
typedef struct bignum_st BIGNUM;
|
||||
/* Used for temp variables (declaration hidden in bn_lcl.h) */
|
||||
typedef struct bignum_ctx BN_CTX;
|
||||
typedef struct bn_blinding_st BN_BLINDING;
|
||||
typedef struct bn_mont_ctx_st BN_MONT_CTX;
|
||||
typedef struct bn_recp_ctx_st BN_RECP_CTX;
|
||||
typedef struct bn_gencb_st BN_GENCB;
|
||||
#endif
|
||||
|
||||
struct bignum_st
|
||||
{
|
||||
BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */
|
||||
int top; /* Index of last used d +1. */
|
||||
/* The next are internal book keeping for bn_expand. */
|
||||
int dmax; /* Size of the d array. */
|
||||
int neg; /* one if the number is negative */
|
||||
int flags;
|
||||
};
|
||||
|
||||
/* Used for montgomery multiplication */
|
||||
struct bn_mont_ctx_st
|
||||
{
|
||||
int ri; /* number of bits in R */
|
||||
BIGNUM RR; /* used to convert to montgomery form */
|
||||
BIGNUM N; /* The modulus */
|
||||
BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1
|
||||
* (Ni is only stored for bignum algorithm) */
|
||||
BN_ULONG n0[2];/* least significant word(s) of Ni;
|
||||
(type changed with 0.9.9, was "BN_ULONG n0;" before) */
|
||||
int flags;
|
||||
};
|
||||
|
||||
/* Used for reciprocal division/mod functions
|
||||
* It cannot be shared between threads
|
||||
*/
|
||||
struct bn_recp_ctx_st
|
||||
{
|
||||
BIGNUM N; /* the divisor */
|
||||
BIGNUM Nr; /* the reciprocal */
|
||||
int num_bits;
|
||||
int shift;
|
||||
int flags;
|
||||
};
|
||||
|
||||
/* Used for slow "generation" functions. */
|
||||
struct bn_gencb_st
|
||||
{
|
||||
unsigned int ver; /* To handle binary (in)compatibility */
|
||||
void *arg; /* callback-specific data */
|
||||
union
|
||||
{
|
||||
/* if(ver==1) - handles old style callbacks */
|
||||
void (*cb_1)(int, int, void *);
|
||||
/* if(ver==2) - new callback style */
|
||||
int (*cb_2)(int, int, BN_GENCB *);
|
||||
} cb;
|
||||
};
|
||||
/* Wrapper function to make using BN_GENCB easier, */
|
||||
int BN_GENCB_call(BN_GENCB *cb, int a, int b);
|
||||
/* Macro to populate a BN_GENCB structure with an "old"-style callback */
|
||||
#define BN_GENCB_set_old(gencb, callback, cb_arg) { \
|
||||
BN_GENCB *tmp_gencb = (gencb); \
|
||||
tmp_gencb->ver = 1; \
|
||||
tmp_gencb->arg = (cb_arg); \
|
||||
tmp_gencb->cb.cb_1 = (callback); }
|
||||
/* Macro to populate a BN_GENCB structure with a "new"-style callback */
|
||||
#define BN_GENCB_set(gencb, callback, cb_arg) { \
|
||||
BN_GENCB *tmp_gencb = (gencb); \
|
||||
tmp_gencb->ver = 2; \
|
||||
tmp_gencb->arg = (cb_arg); \
|
||||
tmp_gencb->cb.cb_2 = (callback); }
|
||||
|
||||
#define BN_prime_checks 0 /* default: select number of iterations
|
||||
based on the size of the number */
|
||||
|
||||
/* number of Miller-Rabin iterations for an error rate of less than 2^-80
|
||||
* for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook
|
||||
* of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];
|
||||
* original paper: Damgaard, Landrock, Pomerance: Average case error estimates
|
||||
* for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */
|
||||
#define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \
|
||||
(b) >= 850 ? 3 : \
|
||||
(b) >= 650 ? 4 : \
|
||||
(b) >= 550 ? 5 : \
|
||||
(b) >= 450 ? 6 : \
|
||||
(b) >= 400 ? 7 : \
|
||||
(b) >= 350 ? 8 : \
|
||||
(b) >= 300 ? 9 : \
|
||||
(b) >= 250 ? 12 : \
|
||||
(b) >= 200 ? 15 : \
|
||||
(b) >= 150 ? 18 : \
|
||||
/* b >= 100 */ 27)
|
||||
|
||||
#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
|
||||
|
||||
/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */
|
||||
#define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \
|
||||
(((w) == 0) && ((a)->top == 0)))
|
||||
#define BN_is_zero(a) ((a)->top == 0)
|
||||
#define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg)
|
||||
#define BN_is_word(a,w) (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg))
|
||||
#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1))
|
||||
|
||||
#define BN_one(a) (BN_set_word((a),1))
|
||||
#define BN_zero_ex(a) \
|
||||
do { \
|
||||
BIGNUM *_tmp_bn = (a); \
|
||||
_tmp_bn->top = 0; \
|
||||
_tmp_bn->neg = 0; \
|
||||
} while(0)
|
||||
#ifdef OPENSSL_NO_DEPRECATED
|
||||
#define BN_zero(a) BN_zero_ex(a)
|
||||
#else
|
||||
#define BN_zero(a) (BN_set_word((a),0))
|
||||
#endif
|
||||
|
||||
const BIGNUM *BN_value_one(void);
|
||||
char * BN_options(void);
|
||||
BN_CTX *BN_CTX_new(void);
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
void BN_CTX_init(BN_CTX *c);
|
||||
#endif
|
||||
void BN_CTX_free(BN_CTX *c);
|
||||
void BN_CTX_start(BN_CTX *ctx);
|
||||
BIGNUM *BN_CTX_get(BN_CTX *ctx);
|
||||
void BN_CTX_end(BN_CTX *ctx);
|
||||
int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
|
||||
int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom);
|
||||
int BN_rand_range(BIGNUM *rnd, const BIGNUM *range);
|
||||
int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
|
||||
int BN_num_bits(const BIGNUM *a);
|
||||
int BN_num_bits_word(BN_ULONG);
|
||||
BIGNUM *BN_new(void);
|
||||
void BN_init(BIGNUM *);
|
||||
void BN_clear_free(BIGNUM *a);
|
||||
BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
|
||||
void BN_swap(BIGNUM *a, BIGNUM *b);
|
||||
BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret);
|
||||
int BN_bn2bin(const BIGNUM *a, unsigned char *to);
|
||||
BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret);
|
||||
int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
|
||||
int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
||||
int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx);
|
||||
/** BN_set_negative sets sign of a BIGNUM
|
||||
* \param b pointer to the BIGNUM object
|
||||
* \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise
|
||||
*/
|
||||
void BN_set_negative(BIGNUM *b, int n);
|
||||
/** BN_is_negative returns 1 if the BIGNUM is negative
|
||||
* \param a pointer to the BIGNUM object
|
||||
* \return 1 if a < 0 and 0 otherwise
|
||||
*/
|
||||
#define BN_is_negative(a) ((a)->neg != 0)
|
||||
|
||||
int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
|
||||
BN_CTX *ctx);
|
||||
#define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))
|
||||
int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
|
||||
int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
|
||||
int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
|
||||
int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);
|
||||
int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);
|
||||
|
||||
BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
|
||||
BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_mul_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_add_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_sub_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_set_word(BIGNUM *a, BN_ULONG w);
|
||||
BN_ULONG BN_get_word(const BIGNUM *a);
|
||||
|
||||
int BN_cmp(const BIGNUM *a, const BIGNUM *b);
|
||||
void BN_free(BIGNUM *a);
|
||||
int BN_is_bit_set(const BIGNUM *a, int n);
|
||||
int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
|
||||
int BN_lshift1(BIGNUM *r, const BIGNUM *a);
|
||||
int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,BN_CTX *ctx);
|
||||
|
||||
int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m,BN_CTX *ctx);
|
||||
int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont);
|
||||
int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,
|
||||
const BIGNUM *a2, const BIGNUM *p2,const BIGNUM *m,
|
||||
BN_CTX *ctx,BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m,BN_CTX *ctx);
|
||||
|
||||
int BN_mask_bits(BIGNUM *a,int n);
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
int BN_print_fp(FILE *fp, const BIGNUM *a);
|
||||
#endif
|
||||
#ifdef HEADER_BIO_H
|
||||
int BN_print(BIO *fp, const BIGNUM *a);
|
||||
#else
|
||||
int BN_print(void *fp, const BIGNUM *a);
|
||||
#endif
|
||||
int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);
|
||||
int BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
|
||||
int BN_rshift1(BIGNUM *r, const BIGNUM *a);
|
||||
void BN_clear(BIGNUM *a);
|
||||
BIGNUM *BN_dup(const BIGNUM *a);
|
||||
int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_set_bit(BIGNUM *a, int n);
|
||||
int BN_clear_bit(BIGNUM *a, int n);
|
||||
char * BN_bn2hex(const BIGNUM *a);
|
||||
char * BN_bn2dec(const BIGNUM *a);
|
||||
int BN_hex2bn(BIGNUM **a, const char *str);
|
||||
int BN_dec2bn(BIGNUM **a, const char *str);
|
||||
int BN_asc2bn(BIGNUM **a, const char *str);
|
||||
int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx);
|
||||
int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */
|
||||
BIGNUM *BN_mod_inverse(BIGNUM *ret,
|
||||
const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
|
||||
BIGNUM *BN_mod_sqrt(BIGNUM *ret,
|
||||
const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
|
||||
|
||||
void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords);
|
||||
|
||||
/* Deprecated versions */
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe,
|
||||
const BIGNUM *add, const BIGNUM *rem,
|
||||
void (*callback)(int,int,void *),void *cb_arg);
|
||||
int BN_is_prime(const BIGNUM *p,int nchecks,
|
||||
void (*callback)(int,int,void *),
|
||||
BN_CTX *ctx,void *cb_arg);
|
||||
int BN_is_prime_fasttest(const BIGNUM *p,int nchecks,
|
||||
void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg,
|
||||
int do_trial_division);
|
||||
#endif /* !defined(OPENSSL_NO_DEPRECATED) */
|
||||
|
||||
/* Newer versions */
|
||||
int BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add,
|
||||
const BIGNUM *rem, BN_GENCB *cb);
|
||||
int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb);
|
||||
int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx,
|
||||
int do_trial_division, BN_GENCB *cb);
|
||||
|
||||
int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);
|
||||
|
||||
int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
|
||||
const BIGNUM *Xp, const BIGNUM *Xp1, const BIGNUM *Xp2,
|
||||
const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb);
|
||||
int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
|
||||
BIGNUM *Xp1, BIGNUM *Xp2,
|
||||
const BIGNUM *Xp,
|
||||
const BIGNUM *e, BN_CTX *ctx,
|
||||
BN_GENCB *cb);
|
||||
|
||||
BN_MONT_CTX *BN_MONT_CTX_new(void );
|
||||
void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
|
||||
int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,
|
||||
BN_MONT_CTX *mont, BN_CTX *ctx);
|
||||
#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\
|
||||
(r),(a),&((mont)->RR),(mont),(ctx))
|
||||
int BN_from_montgomery(BIGNUM *r,const BIGNUM *a,
|
||||
BN_MONT_CTX *mont, BN_CTX *ctx);
|
||||
void BN_MONT_CTX_free(BN_MONT_CTX *mont);
|
||||
int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *mod,BN_CTX *ctx);
|
||||
BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from);
|
||||
BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,
|
||||
const BIGNUM *mod, BN_CTX *ctx);
|
||||
|
||||
/* BN_BLINDING flags */
|
||||
#define BN_BLINDING_NO_UPDATE 0x00000001
|
||||
#define BN_BLINDING_NO_RECREATE 0x00000002
|
||||
|
||||
BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);
|
||||
void BN_BLINDING_free(BN_BLINDING *b);
|
||||
int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx);
|
||||
int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
|
||||
int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
|
||||
int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);
|
||||
int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *);
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
|
||||
void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
|
||||
#endif
|
||||
CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);
|
||||
unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
|
||||
void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
|
||||
BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
|
||||
const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
|
||||
int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx),
|
||||
BN_MONT_CTX *m_ctx);
|
||||
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
void BN_set_params(int mul,int high,int low,int mont);
|
||||
int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */
|
||||
#endif
|
||||
|
||||
void BN_RECP_CTX_init(BN_RECP_CTX *recp);
|
||||
BN_RECP_CTX *BN_RECP_CTX_new(void);
|
||||
void BN_RECP_CTX_free(BN_RECP_CTX *recp);
|
||||
int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx);
|
||||
int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
|
||||
BN_RECP_CTX *recp,BN_CTX *ctx);
|
||||
int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
|
||||
BN_RECP_CTX *recp, BN_CTX *ctx);
|
||||
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
|
||||
/* Functions for arithmetic over binary polynomials represented by BIGNUMs.
|
||||
*
|
||||
* The BIGNUM::neg property of BIGNUMs representing binary polynomials is
|
||||
* ignored.
|
||||
*
|
||||
* Note that input arguments are not const so that their bit arrays can
|
||||
* be expanded to the appropriate size if needed.
|
||||
*/
|
||||
|
||||
int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); /*r = a + b*/
|
||||
#define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b)
|
||||
int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); /*r=a mod p*/
|
||||
int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *p, BN_CTX *ctx); /* r = (a * b) mod p */
|
||||
int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
BN_CTX *ctx); /* r = (a * a) mod p */
|
||||
int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p,
|
||||
BN_CTX *ctx); /* r = (1 / b) mod p */
|
||||
int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *p, BN_CTX *ctx); /* r = (a / b) mod p */
|
||||
int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *p, BN_CTX *ctx); /* r = (a ^ b) mod p */
|
||||
int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
BN_CTX *ctx); /* r = sqrt(a) mod p */
|
||||
int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
BN_CTX *ctx); /* r^2 + r = a mod p */
|
||||
#define BN_GF2m_cmp(a, b) BN_ucmp((a), (b))
|
||||
/* Some functions allow for representation of the irreducible polynomials
|
||||
* as an unsigned int[], say p. The irreducible f(t) is then of the form:
|
||||
* t^p[0] + t^p[1] + ... + t^p[k]
|
||||
* where m = p[0] > p[1] > ... > p[k] = 0.
|
||||
*/
|
||||
int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]);
|
||||
/* r = a mod p */
|
||||
int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const int p[], BN_CTX *ctx); /* r = (a * b) mod p */
|
||||
int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],
|
||||
BN_CTX *ctx); /* r = (a * a) mod p */
|
||||
int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[],
|
||||
BN_CTX *ctx); /* r = (1 / b) mod p */
|
||||
int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const int p[], BN_CTX *ctx); /* r = (a / b) mod p */
|
||||
int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */
|
||||
int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,
|
||||
const int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */
|
||||
int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,
|
||||
const int p[], BN_CTX *ctx); /* r^2 + r = a mod p */
|
||||
int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);
|
||||
int BN_GF2m_arr2poly(const int p[], BIGNUM *a);
|
||||
|
||||
#endif
|
||||
|
||||
/* faster mod functions for the 'NIST primes'
|
||||
* 0 <= a < p^2 */
|
||||
int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
|
||||
const BIGNUM *BN_get0_nist_prime_192(void);
|
||||
const BIGNUM *BN_get0_nist_prime_224(void);
|
||||
const BIGNUM *BN_get0_nist_prime_256(void);
|
||||
const BIGNUM *BN_get0_nist_prime_384(void);
|
||||
const BIGNUM *BN_get0_nist_prime_521(void);
|
||||
|
||||
/* library internal functions */
|
||||
|
||||
#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\
|
||||
(a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2))
|
||||
#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))
|
||||
BIGNUM *bn_expand2(BIGNUM *a, int words);
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */
|
||||
#endif
|
||||
|
||||
/* Bignum consistency macros
|
||||
* There is one "API" macro, bn_fix_top(), for stripping leading zeroes from
|
||||
* bignum data after direct manipulations on the data. There is also an
|
||||
* "internal" macro, bn_check_top(), for verifying that there are no leading
|
||||
* zeroes. Unfortunately, some auditing is required due to the fact that
|
||||
* bn_fix_top() has become an overabused duct-tape because bignum data is
|
||||
* occasionally passed around in an inconsistent state. So the following
|
||||
* changes have been made to sort this out;
|
||||
* - bn_fix_top()s implementation has been moved to bn_correct_top()
|
||||
* - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and
|
||||
* bn_check_top() is as before.
|
||||
* - if BN_DEBUG *is* defined;
|
||||
* - bn_check_top() tries to pollute unused words even if the bignum 'top' is
|
||||
* consistent. (ed: only if BN_DEBUG_RAND is defined)
|
||||
* - bn_fix_top() maps to bn_check_top() rather than "fixing" anything.
|
||||
* The idea is to have debug builds flag up inconsistent bignums when they
|
||||
* occur. If that occurs in a bn_fix_top(), we examine the code in question; if
|
||||
* the use of bn_fix_top() was appropriate (ie. it follows directly after code
|
||||
* that manipulates the bignum) it is converted to bn_correct_top(), and if it
|
||||
* was not appropriate, we convert it permanently to bn_check_top() and track
|
||||
* down the cause of the bug. Eventually, no internal code should be using the
|
||||
* bn_fix_top() macro. External applications and libraries should try this with
|
||||
* their own code too, both in terms of building against the openssl headers
|
||||
* with BN_DEBUG defined *and* linking with a version of OpenSSL built with it
|
||||
* defined. This not only improves external code, it provides more test
|
||||
* coverage for openssl's own code.
|
||||
*/
|
||||
|
||||
#ifdef BN_DEBUG
|
||||
|
||||
/* We only need assert() when debugging */
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef BN_DEBUG_RAND
|
||||
/* To avoid "make update" cvs wars due to BN_DEBUG, use some tricks */
|
||||
#ifndef RAND_pseudo_bytes
|
||||
int RAND_pseudo_bytes(unsigned char *buf,int num);
|
||||
#define BN_DEBUG_TRIX
|
||||
#endif
|
||||
#define bn_pollute(a) \
|
||||
do { \
|
||||
const BIGNUM *_bnum1 = (a); \
|
||||
if(_bnum1->top < _bnum1->dmax) { \
|
||||
unsigned char _tmp_char; \
|
||||
/* We cast away const without the compiler knowing, any \
|
||||
* *genuinely* constant variables that aren't mutable \
|
||||
* wouldn't be constructed with top!=dmax. */ \
|
||||
BN_ULONG *_not_const; \
|
||||
memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \
|
||||
RAND_pseudo_bytes(&_tmp_char, 1); \
|
||||
memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \
|
||||
(_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \
|
||||
} \
|
||||
} while(0)
|
||||
#ifdef BN_DEBUG_TRIX
|
||||
#undef RAND_pseudo_bytes
|
||||
#endif
|
||||
#else
|
||||
#define bn_pollute(a)
|
||||
#endif
|
||||
#define bn_check_top(a) \
|
||||
do { \
|
||||
const BIGNUM *_bnum2 = (a); \
|
||||
if (_bnum2 != NULL) { \
|
||||
assert((_bnum2->top == 0) || \
|
||||
(_bnum2->d[_bnum2->top - 1] != 0)); \
|
||||
bn_pollute(_bnum2); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define bn_fix_top(a) bn_check_top(a)
|
||||
|
||||
#define bn_check_size(bn, bits) bn_wcheck_size(bn, ((bits+BN_BITS2-1))/BN_BITS2)
|
||||
#define bn_wcheck_size(bn, words) \
|
||||
do { \
|
||||
const BIGNUM *_bnum2 = (bn); \
|
||||
assert(words <= (_bnum2)->dmax && words >= (_bnum2)->top); \
|
||||
} while(0)
|
||||
|
||||
#else /* !BN_DEBUG */
|
||||
|
||||
#define bn_pollute(a)
|
||||
#define bn_check_top(a)
|
||||
#define bn_fix_top(a) bn_correct_top(a)
|
||||
#define bn_check_size(bn, bits)
|
||||
#define bn_wcheck_size(bn, words)
|
||||
|
||||
#endif
|
||||
|
||||
#define bn_correct_top(a) \
|
||||
{ \
|
||||
BN_ULONG *ftl; \
|
||||
int tmp_top = (a)->top; \
|
||||
if (tmp_top > 0) \
|
||||
{ \
|
||||
for (ftl= &((a)->d[tmp_top-1]); tmp_top > 0; tmp_top--) \
|
||||
if (*(ftl--)) break; \
|
||||
(a)->top = tmp_top; \
|
||||
} \
|
||||
bn_pollute(a); \
|
||||
}
|
||||
|
||||
BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
|
||||
BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
|
||||
void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);
|
||||
BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
|
||||
BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num);
|
||||
BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num);
|
||||
|
||||
/* Primes from RFC 2409 */
|
||||
BIGNUM *get_rfc2409_prime_768(BIGNUM *bn);
|
||||
BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn);
|
||||
|
||||
/* Primes from RFC 3526 */
|
||||
BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_2048(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn);
|
||||
|
||||
int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_BN_strings(void);
|
||||
|
||||
/* Error codes for the BN functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define BN_F_BNRAND 127
|
||||
#define BN_F_BN_BLINDING_CONVERT_EX 100
|
||||
#define BN_F_BN_BLINDING_CREATE_PARAM 128
|
||||
#define BN_F_BN_BLINDING_INVERT_EX 101
|
||||
#define BN_F_BN_BLINDING_NEW 102
|
||||
#define BN_F_BN_BLINDING_UPDATE 103
|
||||
#define BN_F_BN_BN2DEC 104
|
||||
#define BN_F_BN_BN2HEX 105
|
||||
#define BN_F_BN_CTX_GET 116
|
||||
#define BN_F_BN_CTX_NEW 106
|
||||
#define BN_F_BN_CTX_START 129
|
||||
#define BN_F_BN_DIV 107
|
||||
#define BN_F_BN_DIV_NO_BRANCH 138
|
||||
#define BN_F_BN_DIV_RECP 130
|
||||
#define BN_F_BN_EXP 123
|
||||
#define BN_F_BN_EXPAND2 108
|
||||
#define BN_F_BN_EXPAND_INTERNAL 120
|
||||
#define BN_F_BN_GF2M_MOD 131
|
||||
#define BN_F_BN_GF2M_MOD_EXP 132
|
||||
#define BN_F_BN_GF2M_MOD_MUL 133
|
||||
#define BN_F_BN_GF2M_MOD_SOLVE_QUAD 134
|
||||
#define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135
|
||||
#define BN_F_BN_GF2M_MOD_SQR 136
|
||||
#define BN_F_BN_GF2M_MOD_SQRT 137
|
||||
#define BN_F_BN_MOD_EXP2_MONT 118
|
||||
#define BN_F_BN_MOD_EXP_MONT 109
|
||||
#define BN_F_BN_MOD_EXP_MONT_CONSTTIME 124
|
||||
#define BN_F_BN_MOD_EXP_MONT_WORD 117
|
||||
#define BN_F_BN_MOD_EXP_RECP 125
|
||||
#define BN_F_BN_MOD_EXP_SIMPLE 126
|
||||
#define BN_F_BN_MOD_INVERSE 110
|
||||
#define BN_F_BN_MOD_INVERSE_NO_BRANCH 139
|
||||
#define BN_F_BN_MOD_LSHIFT_QUICK 119
|
||||
#define BN_F_BN_MOD_MUL_RECIPROCAL 111
|
||||
#define BN_F_BN_MOD_SQRT 121
|
||||
#define BN_F_BN_MPI2BN 112
|
||||
#define BN_F_BN_NEW 113
|
||||
#define BN_F_BN_RAND 114
|
||||
#define BN_F_BN_RAND_RANGE 122
|
||||
#define BN_F_BN_USUB 115
|
||||
|
||||
/* Reason codes. */
|
||||
#define BN_R_ARG2_LT_ARG3 100
|
||||
#define BN_R_BAD_RECIPROCAL 101
|
||||
#define BN_R_BIGNUM_TOO_LONG 114
|
||||
#define BN_R_CALLED_WITH_EVEN_MODULUS 102
|
||||
#define BN_R_DIV_BY_ZERO 103
|
||||
#define BN_R_ENCODING_ERROR 104
|
||||
#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105
|
||||
#define BN_R_INPUT_NOT_REDUCED 110
|
||||
#define BN_R_INVALID_LENGTH 106
|
||||
#define BN_R_INVALID_RANGE 115
|
||||
#define BN_R_NOT_A_SQUARE 111
|
||||
#define BN_R_NOT_INITIALIZED 107
|
||||
#define BN_R_NO_INVERSE 108
|
||||
#define BN_R_NO_SOLUTION 116
|
||||
#define BN_R_P_IS_NOT_PRIME 112
|
||||
#define BN_R_TOO_MANY_ITERATIONS 113
|
||||
#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,611 +0,0 @@
|
||||
/* crypto/crypto.h */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
* ECDH support in OpenSSL originally developed by
|
||||
* SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CRYPTO_H
|
||||
#define HEADER_CRYPTO_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <openssl/stack.h>
|
||||
#include <openssl/safestack.h>
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/ossl_typ.h>
|
||||
|
||||
#ifdef CHARSET_EBCDIC
|
||||
#include <openssl/ebcdic.h>
|
||||
#endif
|
||||
|
||||
/* Resolve problems on some operating systems with symbol names that clash
|
||||
one way or another */
|
||||
#include <openssl/symhacks.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Backward compatibility to SSLeay */
|
||||
/* This is more to be used to check the correct DLL is being used
|
||||
* in the MS world. */
|
||||
#define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER
|
||||
#define SSLEAY_VERSION 0
|
||||
/* #define SSLEAY_OPTIONS 1 no longer supported */
|
||||
#define SSLEAY_CFLAGS 2
|
||||
#define SSLEAY_BUILT_ON 3
|
||||
#define SSLEAY_PLATFORM 4
|
||||
#define SSLEAY_DIR 5
|
||||
|
||||
/* Already declared in ossl_typ.h */
|
||||
#if 0
|
||||
typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
|
||||
/* Called when a new object is created */
|
||||
typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
/* Called when an object is free()ed */
|
||||
typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
/* Called when we need to dup an object */
|
||||
typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
|
||||
int idx, long argl, void *argp);
|
||||
#endif
|
||||
|
||||
/* A generic structure to pass assorted data in a expandable way */
|
||||
typedef struct openssl_item_st
|
||||
{
|
||||
int code;
|
||||
void *value; /* Not used for flag attributes */
|
||||
size_t value_size; /* Max size of value for output, length for input */
|
||||
size_t *value_length; /* Returned length of value for output */
|
||||
} OPENSSL_ITEM;
|
||||
|
||||
|
||||
/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock
|
||||
* names in cryptlib.c
|
||||
*/
|
||||
|
||||
#define CRYPTO_LOCK_ERR 1
|
||||
#define CRYPTO_LOCK_EX_DATA 2
|
||||
#define CRYPTO_LOCK_X509 3
|
||||
#define CRYPTO_LOCK_X509_INFO 4
|
||||
#define CRYPTO_LOCK_X509_PKEY 5
|
||||
#define CRYPTO_LOCK_X509_CRL 6
|
||||
#define CRYPTO_LOCK_X509_REQ 7
|
||||
#define CRYPTO_LOCK_DSA 8
|
||||
#define CRYPTO_LOCK_RSA 9
|
||||
#define CRYPTO_LOCK_EVP_PKEY 10
|
||||
#define CRYPTO_LOCK_X509_STORE 11
|
||||
#define CRYPTO_LOCK_SSL_CTX 12
|
||||
#define CRYPTO_LOCK_SSL_CERT 13
|
||||
#define CRYPTO_LOCK_SSL_SESSION 14
|
||||
#define CRYPTO_LOCK_SSL_SESS_CERT 15
|
||||
#define CRYPTO_LOCK_SSL 16
|
||||
#define CRYPTO_LOCK_SSL_METHOD 17
|
||||
#define CRYPTO_LOCK_RAND 18
|
||||
#define CRYPTO_LOCK_RAND2 19
|
||||
#define CRYPTO_LOCK_MALLOC 20
|
||||
#define CRYPTO_LOCK_BIO 21
|
||||
#define CRYPTO_LOCK_GETHOSTBYNAME 22
|
||||
#define CRYPTO_LOCK_GETSERVBYNAME 23
|
||||
#define CRYPTO_LOCK_READDIR 24
|
||||
#define CRYPTO_LOCK_RSA_BLINDING 25
|
||||
#define CRYPTO_LOCK_DH 26
|
||||
#define CRYPTO_LOCK_MALLOC2 27
|
||||
#define CRYPTO_LOCK_DSO 28
|
||||
#define CRYPTO_LOCK_DYNLOCK 29
|
||||
#define CRYPTO_LOCK_ENGINE 30
|
||||
#define CRYPTO_LOCK_UI 31
|
||||
#define CRYPTO_LOCK_ECDSA 32
|
||||
#define CRYPTO_LOCK_EC 33
|
||||
#define CRYPTO_LOCK_ECDH 34
|
||||
#define CRYPTO_LOCK_BN 35
|
||||
#define CRYPTO_LOCK_EC_PRE_COMP 36
|
||||
#define CRYPTO_LOCK_STORE 37
|
||||
#define CRYPTO_LOCK_COMP 38
|
||||
#define CRYPTO_LOCK_FIPS 39
|
||||
#define CRYPTO_LOCK_FIPS2 40
|
||||
#define CRYPTO_NUM_LOCKS 41
|
||||
|
||||
#define CRYPTO_LOCK 1
|
||||
#define CRYPTO_UNLOCK 2
|
||||
#define CRYPTO_READ 4
|
||||
#define CRYPTO_WRITE 8
|
||||
|
||||
#ifndef OPENSSL_NO_LOCKING
|
||||
#ifndef CRYPTO_w_lock
|
||||
#define CRYPTO_w_lock(type) \
|
||||
CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
|
||||
#define CRYPTO_w_unlock(type) \
|
||||
CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
|
||||
#define CRYPTO_r_lock(type) \
|
||||
CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
|
||||
#define CRYPTO_r_unlock(type) \
|
||||
CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
|
||||
#define CRYPTO_add(addr,amount,type) \
|
||||
CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
|
||||
#endif
|
||||
#else
|
||||
#define CRYPTO_w_lock(a)
|
||||
#define CRYPTO_w_unlock(a)
|
||||
#define CRYPTO_r_lock(a)
|
||||
#define CRYPTO_r_unlock(a)
|
||||
#define CRYPTO_add(a,b,c) ((*(a))+=(b))
|
||||
#endif
|
||||
|
||||
/* Some applications as well as some parts of OpenSSL need to allocate
|
||||
and deallocate locks in a dynamic fashion. The following typedef
|
||||
makes this possible in a type-safe manner. */
|
||||
/* struct CRYPTO_dynlock_value has to be defined by the application. */
|
||||
typedef struct
|
||||
{
|
||||
int references;
|
||||
struct CRYPTO_dynlock_value *data;
|
||||
} CRYPTO_dynlock;
|
||||
|
||||
|
||||
/* The following can be used to detect memory leaks in the SSLeay library.
|
||||
* It used, it turns on malloc checking */
|
||||
|
||||
#define CRYPTO_MEM_CHECK_OFF 0x0 /* an enume */
|
||||
#define CRYPTO_MEM_CHECK_ON 0x1 /* a bit */
|
||||
#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */
|
||||
#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */
|
||||
|
||||
/* The following are bit values to turn on or off options connected to the
|
||||
* malloc checking functionality */
|
||||
|
||||
/* Adds time to the memory checking information */
|
||||
#define V_CRYPTO_MDEBUG_TIME 0x1 /* a bit */
|
||||
/* Adds thread number to the memory checking information */
|
||||
#define V_CRYPTO_MDEBUG_THREAD 0x2 /* a bit */
|
||||
|
||||
#define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)
|
||||
|
||||
|
||||
/* predec of the BIO type */
|
||||
typedef struct bio_st BIO_dummy;
|
||||
|
||||
struct crypto_ex_data_st
|
||||
{
|
||||
STACK_OF(void) *sk;
|
||||
int dummy; /* gcc is screwing up this data structure :-( */
|
||||
};
|
||||
DECLARE_STACK_OF(void)
|
||||
|
||||
/* This stuff is basically class callback functions
|
||||
* The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */
|
||||
|
||||
typedef struct crypto_ex_data_func_st
|
||||
{
|
||||
long argl; /* Arbitary long */
|
||||
void *argp; /* Arbitary void * */
|
||||
CRYPTO_EX_new *new_func;
|
||||
CRYPTO_EX_free *free_func;
|
||||
CRYPTO_EX_dup *dup_func;
|
||||
} CRYPTO_EX_DATA_FUNCS;
|
||||
|
||||
DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
|
||||
|
||||
/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA
|
||||
* entry.
|
||||
*/
|
||||
|
||||
#define CRYPTO_EX_INDEX_BIO 0
|
||||
#define CRYPTO_EX_INDEX_SSL 1
|
||||
#define CRYPTO_EX_INDEX_SSL_CTX 2
|
||||
#define CRYPTO_EX_INDEX_SSL_SESSION 3
|
||||
#define CRYPTO_EX_INDEX_X509_STORE 4
|
||||
#define CRYPTO_EX_INDEX_X509_STORE_CTX 5
|
||||
#define CRYPTO_EX_INDEX_RSA 6
|
||||
#define CRYPTO_EX_INDEX_DSA 7
|
||||
#define CRYPTO_EX_INDEX_DH 8
|
||||
#define CRYPTO_EX_INDEX_ENGINE 9
|
||||
#define CRYPTO_EX_INDEX_X509 10
|
||||
#define CRYPTO_EX_INDEX_UI 11
|
||||
#define CRYPTO_EX_INDEX_ECDSA 12
|
||||
#define CRYPTO_EX_INDEX_ECDH 13
|
||||
#define CRYPTO_EX_INDEX_COMP 14
|
||||
#define CRYPTO_EX_INDEX_STORE 15
|
||||
|
||||
/* Dynamically assigned indexes start from this value (don't use directly, use
|
||||
* via CRYPTO_ex_data_new_class). */
|
||||
#define CRYPTO_EX_INDEX_USER 100
|
||||
|
||||
|
||||
/* This is the default callbacks, but we can have others as well:
|
||||
* this is needed in Win32 where the application malloc and the
|
||||
* library malloc may not be the same.
|
||||
*/
|
||||
#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\
|
||||
malloc, realloc, free)
|
||||
|
||||
#if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD
|
||||
# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */
|
||||
# define CRYPTO_MDEBUG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Set standard debugging functions (not done by default
|
||||
* unless CRYPTO_MDEBUG is defined) */
|
||||
#define CRYPTO_malloc_debug_init() do {\
|
||||
CRYPTO_set_mem_debug_functions(\
|
||||
CRYPTO_dbg_malloc,\
|
||||
CRYPTO_dbg_realloc,\
|
||||
CRYPTO_dbg_free,\
|
||||
CRYPTO_dbg_set_options,\
|
||||
CRYPTO_dbg_get_options);\
|
||||
} while(0)
|
||||
|
||||
int CRYPTO_mem_ctrl(int mode);
|
||||
int CRYPTO_is_mem_check_on(void);
|
||||
|
||||
/* for applications */
|
||||
#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)
|
||||
#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)
|
||||
|
||||
/* for library-internal use */
|
||||
#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE)
|
||||
#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
|
||||
#define is_MemCheck_on() CRYPTO_is_mem_check_on()
|
||||
|
||||
#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
|
||||
#define OPENSSL_strdup(str) CRYPTO_strdup((str),__FILE__,__LINE__)
|
||||
#define OPENSSL_realloc(addr,num) \
|
||||
CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
|
||||
#define OPENSSL_realloc_clean(addr,old_num,num) \
|
||||
CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)
|
||||
#define OPENSSL_remalloc(addr,num) \
|
||||
CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
|
||||
#define OPENSSL_freeFunc CRYPTO_free
|
||||
#define OPENSSL_free(addr) CRYPTO_free(addr)
|
||||
|
||||
#define OPENSSL_malloc_locked(num) \
|
||||
CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
|
||||
#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)
|
||||
|
||||
|
||||
const char *SSLeay_version(int type);
|
||||
unsigned long SSLeay(void);
|
||||
|
||||
int OPENSSL_issetugid(void);
|
||||
|
||||
/* An opaque type representing an implementation of "ex_data" support */
|
||||
typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL;
|
||||
/* Return an opaque pointer to the current "ex_data" implementation */
|
||||
const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);
|
||||
/* Sets the "ex_data" implementation to be used (if it's not too late) */
|
||||
int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
|
||||
/* Get a new "ex_data" class, and return the corresponding "class_index" */
|
||||
int CRYPTO_ex_data_new_class(void);
|
||||
/* Within a given class, get/register a new index */
|
||||
int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
|
||||
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
|
||||
CRYPTO_EX_free *free_func);
|
||||
/* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given
|
||||
* class (invokes whatever per-class callbacks are applicable) */
|
||||
int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
|
||||
int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
|
||||
CRYPTO_EX_DATA *from);
|
||||
void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
|
||||
/* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index
|
||||
* (relative to the class type involved) */
|
||||
int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
|
||||
void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx);
|
||||
/* This function cleans up all "ex_data" state. It mustn't be called under
|
||||
* potential race-conditions. */
|
||||
void CRYPTO_cleanup_all_ex_data(void);
|
||||
|
||||
int CRYPTO_get_new_lockid(char *name);
|
||||
|
||||
int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */
|
||||
void CRYPTO_lock(int mode, int type,const char *file,int line);
|
||||
void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
|
||||
const char *file,int line));
|
||||
void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file,
|
||||
int line);
|
||||
void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
|
||||
const char *file, int line));
|
||||
int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type,
|
||||
const char *file,int line);
|
||||
|
||||
/* Don't use this structure directly. */
|
||||
typedef struct crypto_threadid_st
|
||||
{
|
||||
void *ptr;
|
||||
unsigned long val;
|
||||
} CRYPTO_THREADID;
|
||||
/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */
|
||||
void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val);
|
||||
void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr);
|
||||
int CRYPTO_THREADID_set_callback(void (*threadid_func)(CRYPTO_THREADID *));
|
||||
void (*CRYPTO_THREADID_get_callback(void))(CRYPTO_THREADID *);
|
||||
void CRYPTO_THREADID_current(CRYPTO_THREADID *id);
|
||||
int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b);
|
||||
void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src);
|
||||
unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id);
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
void CRYPTO_set_id_callback(unsigned long (*func)(void));
|
||||
unsigned long (*CRYPTO_get_id_callback(void))(void);
|
||||
unsigned long CRYPTO_thread_id(void);
|
||||
#endif
|
||||
|
||||
const char *CRYPTO_get_lock_name(int type);
|
||||
int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
|
||||
int line);
|
||||
|
||||
int CRYPTO_get_new_dynlockid(void);
|
||||
void CRYPTO_destroy_dynlockid(int i);
|
||||
struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
|
||||
void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line));
|
||||
void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line));
|
||||
void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line));
|
||||
struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line);
|
||||
void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line);
|
||||
void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line);
|
||||
|
||||
/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions --
|
||||
* call the latter last if you need different functions */
|
||||
int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *));
|
||||
int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
|
||||
int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int),
|
||||
void *(*r)(void *,size_t,const char *,int),
|
||||
void (*f)(void *));
|
||||
int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int),
|
||||
void (*free_func)(void *));
|
||||
int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
|
||||
void (*r)(void *,void *,int,const char *,int,int),
|
||||
void (*f)(void *,int),
|
||||
void (*so)(long),
|
||||
long (*go)(void));
|
||||
void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
|
||||
void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
|
||||
void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int),
|
||||
void *(**r)(void *, size_t,const char *,int),
|
||||
void (**f)(void *));
|
||||
void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int),
|
||||
void (**f)(void *));
|
||||
void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
|
||||
void (**r)(void *,void *,int,const char *,int,int),
|
||||
void (**f)(void *,int),
|
||||
void (**so)(long),
|
||||
long (**go)(void));
|
||||
|
||||
void *CRYPTO_malloc_locked(int num, const char *file, int line);
|
||||
void CRYPTO_free_locked(void *ptr);
|
||||
void *CRYPTO_malloc(int num, const char *file, int line);
|
||||
char *CRYPTO_strdup(const char *str, const char *file, int line);
|
||||
void CRYPTO_free(void *ptr);
|
||||
void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
|
||||
void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file,
|
||||
int line);
|
||||
void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
|
||||
|
||||
void OPENSSL_cleanse(void *ptr, size_t len);
|
||||
|
||||
void CRYPTO_set_mem_debug_options(long bits);
|
||||
long CRYPTO_get_mem_debug_options(void);
|
||||
|
||||
#define CRYPTO_push_info(info) \
|
||||
CRYPTO_push_info_(info, __FILE__, __LINE__);
|
||||
int CRYPTO_push_info_(const char *info, const char *file, int line);
|
||||
int CRYPTO_pop_info(void);
|
||||
int CRYPTO_remove_all_info(void);
|
||||
|
||||
|
||||
/* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;
|
||||
* used as default in CRYPTO_MDEBUG compilations): */
|
||||
/* The last argument has the following significance:
|
||||
*
|
||||
* 0: called before the actual memory allocation has taken place
|
||||
* 1: called after the actual memory allocation has taken place
|
||||
*/
|
||||
void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
|
||||
void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
|
||||
void CRYPTO_dbg_free(void *addr,int before_p);
|
||||
/* Tell the debugging code about options. By default, the following values
|
||||
* apply:
|
||||
*
|
||||
* 0: Clear all options.
|
||||
* V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option.
|
||||
* V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option.
|
||||
* V_CRYPTO_MDEBUG_ALL (3): 1 + 2
|
||||
*/
|
||||
void CRYPTO_dbg_set_options(long bits);
|
||||
long CRYPTO_dbg_get_options(void);
|
||||
|
||||
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
void CRYPTO_mem_leaks_fp(FILE *);
|
||||
#endif
|
||||
void CRYPTO_mem_leaks(struct bio_st *bio);
|
||||
/* unsigned long order, char *file, int line, int num_bytes, char *addr */
|
||||
typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
|
||||
void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
|
||||
|
||||
/* die if we have to */
|
||||
void OpenSSLDie(const char *file,int line,const char *assertion);
|
||||
#define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))
|
||||
|
||||
unsigned long *OPENSSL_ia32cap_loc(void);
|
||||
#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
|
||||
int OPENSSL_isservice(void);
|
||||
|
||||
int FIPS_mode(void);
|
||||
int FIPS_mode_set(int r);
|
||||
|
||||
void OPENSSL_init(void);
|
||||
|
||||
#define fips_md_init(alg) fips_md_init_ctx(alg, alg)
|
||||
|
||||
#ifdef OPENSSL_FIPS
|
||||
#define fips_md_init_ctx(alg, cx) \
|
||||
int alg##_Init(cx##_CTX *c) \
|
||||
{ \
|
||||
if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \
|
||||
"Low level API call to digest " #alg " forbidden in FIPS mode!"); \
|
||||
return private_##alg##_Init(c); \
|
||||
} \
|
||||
int private_##alg##_Init(cx##_CTX *c)
|
||||
|
||||
#define fips_cipher_abort(alg) \
|
||||
if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \
|
||||
"Low level API call to cipher " #alg " forbidden in FIPS mode!")
|
||||
|
||||
#else
|
||||
#define fips_md_init_ctx(alg, cx) \
|
||||
int alg##_Init(cx##_CTX *c)
|
||||
#define fips_cipher_abort(alg) while(0)
|
||||
#endif
|
||||
|
||||
/* CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal. It
|
||||
* takes an amount of time dependent on |len|, but independent of the contents
|
||||
* of |a| and |b|. Unlike memcmp, it cannot be used to put elements into a
|
||||
* defined order as the return value when a != b is undefined, other than to be
|
||||
* non-zero. */
|
||||
int CRYPTO_memcmp(const void *a, const void *b, size_t len);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_CRYPTO_strings(void);
|
||||
|
||||
/* Error codes for the CRYPTO functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100
|
||||
#define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103
|
||||
#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101
|
||||
#define CRYPTO_F_CRYPTO_SET_EX_DATA 102
|
||||
#define CRYPTO_F_DEF_ADD_INDEX 104
|
||||
#define CRYPTO_F_DEF_GET_CLASS 105
|
||||
#define CRYPTO_F_FIPS_MODE_SET 109
|
||||
#define CRYPTO_F_INT_DUP_EX_DATA 106
|
||||
#define CRYPTO_F_INT_FREE_EX_DATA 107
|
||||
#define CRYPTO_F_INT_NEW_EX_DATA 108
|
||||
|
||||
/* Reason codes. */
|
||||
#define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED 101
|
||||
#define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,89 +0,0 @@
|
||||
#ifndef HEADER_OPENSSLV_H
|
||||
#define HEADER_OPENSSLV_H
|
||||
|
||||
/* Numeric release version identifier:
|
||||
* MNNFFPPS: major minor fix patch status
|
||||
* The status nibble has one of the values 0 for development, 1 to e for betas
|
||||
* 1 to 14, and f for release. The patch level is exactly that.
|
||||
* For example:
|
||||
* 0.9.3-dev 0x00903000
|
||||
* 0.9.3-beta1 0x00903001
|
||||
* 0.9.3-beta2-dev 0x00903002
|
||||
* 0.9.3-beta2 0x00903002 (same as ...beta2-dev)
|
||||
* 0.9.3 0x0090300f
|
||||
* 0.9.3a 0x0090301f
|
||||
* 0.9.4 0x0090400f
|
||||
* 1.2.3z 0x102031af
|
||||
*
|
||||
* For continuity reasons (because 0.9.5 is already out, and is coded
|
||||
* 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level
|
||||
* part is slightly different, by setting the highest bit. This means
|
||||
* that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start
|
||||
* with 0x0090600S...
|
||||
*
|
||||
* (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)
|
||||
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
|
||||
* major minor fix final patch/beta)
|
||||
*/
|
||||
#define OPENSSL_VERSION_NUMBER 0x1000109fL
|
||||
#ifdef OPENSSL_FIPS
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1i-fips 6 Aug 2014"
|
||||
#else
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1i 6 Aug 2014"
|
||||
#endif
|
||||
#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
|
||||
|
||||
|
||||
/* The macros below are to be used for shared library (.so, .dll, ...)
|
||||
* versioning. That kind of versioning works a bit differently between
|
||||
* operating systems. The most usual scheme is to set a major and a minor
|
||||
* number, and have the runtime loader check that the major number is equal
|
||||
* to what it was at application link time, while the minor number has to
|
||||
* be greater or equal to what it was at application link time. With this
|
||||
* scheme, the version number is usually part of the file name, like this:
|
||||
*
|
||||
* libcrypto.so.0.9
|
||||
*
|
||||
* Some unixen also make a softlink with the major verson number only:
|
||||
*
|
||||
* libcrypto.so.0
|
||||
*
|
||||
* On Tru64 and IRIX 6.x it works a little bit differently. There, the
|
||||
* shared library version is stored in the file, and is actually a series
|
||||
* of versions, separated by colons. The rightmost version present in the
|
||||
* library when linking an application is stored in the application to be
|
||||
* matched at run time. When the application is run, a check is done to
|
||||
* see if the library version stored in the application matches any of the
|
||||
* versions in the version string of the library itself.
|
||||
* This version string can be constructed in any way, depending on what
|
||||
* kind of matching is desired. However, to implement the same scheme as
|
||||
* the one used in the other unixen, all compatible versions, from lowest
|
||||
* to highest, should be part of the string. Consecutive builds would
|
||||
* give the following versions strings:
|
||||
*
|
||||
* 3.0
|
||||
* 3.0:3.1
|
||||
* 3.0:3.1:3.2
|
||||
* 4.0
|
||||
* 4.0:4.1
|
||||
*
|
||||
* Notice how version 4 is completely incompatible with version, and
|
||||
* therefore give the breach you can see.
|
||||
*
|
||||
* There may be other schemes as well that I haven't yet discovered.
|
||||
*
|
||||
* So, here's the way it works here: first of all, the library version
|
||||
* number doesn't need at all to match the overall OpenSSL version.
|
||||
* However, it's nice and more understandable if it actually does.
|
||||
* The current library version is stored in the macro SHLIB_VERSION_NUMBER,
|
||||
* which is just a piece of text in the format "M.m.e" (Major, minor, edit).
|
||||
* For the sake of Tru64, IRIX, and any other OS that behaves in similar ways,
|
||||
* we need to keep a history of version numbers, which is done in the
|
||||
* macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and
|
||||
* should only keep the versions that are binary compatible with the current.
|
||||
*/
|
||||
#define SHLIB_VERSION_HISTORY ""
|
||||
#define SHLIB_VERSION_NUMBER "1.0.0"
|
||||
|
||||
|
||||
#endif /* HEADER_OPENSSLV_H */
|
||||
@@ -1,202 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_OPENSSL_TYPES_H
|
||||
#define HEADER_OPENSSL_TYPES_H
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#ifdef NO_ASN1_TYPEDEFS
|
||||
#define ASN1_INTEGER ASN1_STRING
|
||||
#define ASN1_ENUMERATED ASN1_STRING
|
||||
#define ASN1_BIT_STRING ASN1_STRING
|
||||
#define ASN1_OCTET_STRING ASN1_STRING
|
||||
#define ASN1_PRINTABLESTRING ASN1_STRING
|
||||
#define ASN1_T61STRING ASN1_STRING
|
||||
#define ASN1_IA5STRING ASN1_STRING
|
||||
#define ASN1_UTCTIME ASN1_STRING
|
||||
#define ASN1_GENERALIZEDTIME ASN1_STRING
|
||||
#define ASN1_TIME ASN1_STRING
|
||||
#define ASN1_GENERALSTRING ASN1_STRING
|
||||
#define ASN1_UNIVERSALSTRING ASN1_STRING
|
||||
#define ASN1_BMPSTRING ASN1_STRING
|
||||
#define ASN1_VISIBLESTRING ASN1_STRING
|
||||
#define ASN1_UTF8STRING ASN1_STRING
|
||||
#define ASN1_BOOLEAN int
|
||||
#define ASN1_NULL int
|
||||
#else
|
||||
typedef struct asn1_string_st ASN1_INTEGER;
|
||||
typedef struct asn1_string_st ASN1_ENUMERATED;
|
||||
typedef struct asn1_string_st ASN1_BIT_STRING;
|
||||
typedef struct asn1_string_st ASN1_OCTET_STRING;
|
||||
typedef struct asn1_string_st ASN1_PRINTABLESTRING;
|
||||
typedef struct asn1_string_st ASN1_T61STRING;
|
||||
typedef struct asn1_string_st ASN1_IA5STRING;
|
||||
typedef struct asn1_string_st ASN1_GENERALSTRING;
|
||||
typedef struct asn1_string_st ASN1_UNIVERSALSTRING;
|
||||
typedef struct asn1_string_st ASN1_BMPSTRING;
|
||||
typedef struct asn1_string_st ASN1_UTCTIME;
|
||||
typedef struct asn1_string_st ASN1_TIME;
|
||||
typedef struct asn1_string_st ASN1_GENERALIZEDTIME;
|
||||
typedef struct asn1_string_st ASN1_VISIBLESTRING;
|
||||
typedef struct asn1_string_st ASN1_UTF8STRING;
|
||||
typedef struct asn1_string_st ASN1_STRING;
|
||||
typedef int ASN1_BOOLEAN;
|
||||
typedef int ASN1_NULL;
|
||||
#endif
|
||||
|
||||
typedef struct ASN1_ITEM_st ASN1_ITEM;
|
||||
typedef struct asn1_pctx_st ASN1_PCTX;
|
||||
|
||||
#ifdef OPENSSL_SYS_WIN32
|
||||
#undef X509_NAME
|
||||
#undef X509_EXTENSIONS
|
||||
#undef X509_CERT_PAIR
|
||||
#undef PKCS7_ISSUER_AND_SERIAL
|
||||
#undef OCSP_REQUEST
|
||||
#undef OCSP_RESPONSE
|
||||
#endif
|
||||
|
||||
#ifdef BIGNUM
|
||||
#undef BIGNUM
|
||||
#endif
|
||||
typedef struct bignum_st BIGNUM;
|
||||
typedef struct bignum_ctx BN_CTX;
|
||||
typedef struct bn_blinding_st BN_BLINDING;
|
||||
typedef struct bn_mont_ctx_st BN_MONT_CTX;
|
||||
typedef struct bn_recp_ctx_st BN_RECP_CTX;
|
||||
typedef struct bn_gencb_st BN_GENCB;
|
||||
|
||||
typedef struct buf_mem_st BUF_MEM;
|
||||
|
||||
typedef struct evp_cipher_st EVP_CIPHER;
|
||||
typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
|
||||
typedef struct env_md_st EVP_MD;
|
||||
typedef struct env_md_ctx_st EVP_MD_CTX;
|
||||
typedef struct evp_pkey_st EVP_PKEY;
|
||||
|
||||
typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;
|
||||
|
||||
typedef struct evp_pkey_method_st EVP_PKEY_METHOD;
|
||||
typedef struct evp_pkey_ctx_st EVP_PKEY_CTX;
|
||||
|
||||
typedef struct dh_st DH;
|
||||
typedef struct dh_method DH_METHOD;
|
||||
|
||||
typedef struct dsa_st DSA;
|
||||
typedef struct dsa_method DSA_METHOD;
|
||||
|
||||
typedef struct rsa_st RSA;
|
||||
typedef struct rsa_meth_st RSA_METHOD;
|
||||
|
||||
typedef struct rand_meth_st RAND_METHOD;
|
||||
|
||||
typedef struct ecdh_method ECDH_METHOD;
|
||||
typedef struct ecdsa_method ECDSA_METHOD;
|
||||
|
||||
typedef struct x509_st X509;
|
||||
typedef struct X509_algor_st X509_ALGOR;
|
||||
typedef struct X509_crl_st X509_CRL;
|
||||
typedef struct x509_crl_method_st X509_CRL_METHOD;
|
||||
typedef struct x509_revoked_st X509_REVOKED;
|
||||
typedef struct X509_name_st X509_NAME;
|
||||
typedef struct X509_pubkey_st X509_PUBKEY;
|
||||
typedef struct x509_store_st X509_STORE;
|
||||
typedef struct x509_store_ctx_st X509_STORE_CTX;
|
||||
|
||||
typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO;
|
||||
|
||||
typedef struct v3_ext_ctx X509V3_CTX;
|
||||
typedef struct conf_st CONF;
|
||||
|
||||
typedef struct store_st STORE;
|
||||
typedef struct store_method_st STORE_METHOD;
|
||||
|
||||
typedef struct ui_st UI;
|
||||
typedef struct ui_method_st UI_METHOD;
|
||||
|
||||
typedef struct st_ERR_FNS ERR_FNS;
|
||||
|
||||
typedef struct engine_st ENGINE;
|
||||
typedef struct ssl_st SSL;
|
||||
typedef struct ssl_ctx_st SSL_CTX;
|
||||
|
||||
typedef struct X509_POLICY_NODE_st X509_POLICY_NODE;
|
||||
typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;
|
||||
typedef struct X509_POLICY_TREE_st X509_POLICY_TREE;
|
||||
typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;
|
||||
|
||||
typedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID;
|
||||
typedef struct DIST_POINT_st DIST_POINT;
|
||||
typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;
|
||||
typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;
|
||||
|
||||
/* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */
|
||||
#define DECLARE_PKCS12_STACK_OF(type) /* Nothing */
|
||||
#define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */
|
||||
|
||||
typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
|
||||
/* Callback types for crypto.h */
|
||||
typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
|
||||
int idx, long argl, void *argp);
|
||||
|
||||
typedef struct ocsp_req_ctx_st OCSP_REQ_CTX;
|
||||
typedef struct ocsp_response_st OCSP_RESPONSE;
|
||||
typedef struct ocsp_responder_id_st OCSP_RESPID;
|
||||
|
||||
#endif /* def HEADER_OPENSSL_TYPES_H */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,108 +0,0 @@
|
||||
/* crypto/stack/stack.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_STACK_H
|
||||
#define HEADER_STACK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct stack_st
|
||||
{
|
||||
int num;
|
||||
char **data;
|
||||
int sorted;
|
||||
|
||||
int num_alloc;
|
||||
int (*comp)(const void *, const void *);
|
||||
} _STACK; /* Use STACK_OF(...) instead */
|
||||
|
||||
#define M_sk_num(sk) ((sk) ? (sk)->num:-1)
|
||||
#define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL)
|
||||
|
||||
int sk_num(const _STACK *);
|
||||
void *sk_value(const _STACK *, int);
|
||||
|
||||
void *sk_set(_STACK *, int, void *);
|
||||
|
||||
_STACK *sk_new(int (*cmp)(const void *, const void *));
|
||||
_STACK *sk_new_null(void);
|
||||
void sk_free(_STACK *);
|
||||
void sk_pop_free(_STACK *st, void (*func)(void *));
|
||||
int sk_insert(_STACK *sk, void *data, int where);
|
||||
void *sk_delete(_STACK *st, int loc);
|
||||
void *sk_delete_ptr(_STACK *st, void *p);
|
||||
int sk_find(_STACK *st, void *data);
|
||||
int sk_find_ex(_STACK *st, void *data);
|
||||
int sk_push(_STACK *st, void *data);
|
||||
int sk_unshift(_STACK *st, void *data);
|
||||
void *sk_shift(_STACK *st);
|
||||
void *sk_pop(_STACK *st);
|
||||
void sk_zero(_STACK *st);
|
||||
int (*sk_set_cmp_func(_STACK *sk, int (*c)(const void *, const void *)))
|
||||
(const void *, const void *);
|
||||
_STACK *sk_dup(_STACK *st);
|
||||
void sk_sort(_STACK *st);
|
||||
int sk_is_sorted(const _STACK *st);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,481 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_SYMHACKS_H
|
||||
#define HEADER_SYMHACKS_H
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
/* Hacks to solve the problem with linkers incapable of handling very long
|
||||
symbol names. In the case of VMS, the limit is 31 characters on VMS for
|
||||
VAX. */
|
||||
/* Note that this affects util/libeay.num and util/ssleay.num... you may
|
||||
change those manually, but that's not recommended, as those files are
|
||||
controlled centrally and updated on Unix, and the central definition
|
||||
may disagree with yours, which in turn may come with shareable library
|
||||
incompatibilities. */
|
||||
#ifdef OPENSSL_SYS_VMS
|
||||
|
||||
/* Hack a long name in crypto/ex_data.c */
|
||||
#undef CRYPTO_get_ex_data_implementation
|
||||
#define CRYPTO_get_ex_data_implementation CRYPTO_get_ex_data_impl
|
||||
#undef CRYPTO_set_ex_data_implementation
|
||||
#define CRYPTO_set_ex_data_implementation CRYPTO_set_ex_data_impl
|
||||
|
||||
/* Hack a long name in crypto/asn1/a_mbstr.c */
|
||||
#undef ASN1_STRING_set_default_mask_asc
|
||||
#define ASN1_STRING_set_default_mask_asc ASN1_STRING_set_def_mask_asc
|
||||
|
||||
#if 0 /* No longer needed, since safestack macro magic does the job */
|
||||
/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */
|
||||
#undef i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO
|
||||
#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO i2d_ASN1_SET_OF_PKCS7_SIGINF
|
||||
#undef d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO
|
||||
#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO d2i_ASN1_SET_OF_PKCS7_SIGINF
|
||||
#endif
|
||||
|
||||
#if 0 /* No longer needed, since safestack macro magic does the job */
|
||||
/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */
|
||||
#undef i2d_ASN1_SET_OF_PKCS7_RECIP_INFO
|
||||
#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO i2d_ASN1_SET_OF_PKCS7_RECINF
|
||||
#undef d2i_ASN1_SET_OF_PKCS7_RECIP_INFO
|
||||
#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO d2i_ASN1_SET_OF_PKCS7_RECINF
|
||||
#endif
|
||||
|
||||
#if 0 /* No longer needed, since safestack macro magic does the job */
|
||||
/* Hack the names created with DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) */
|
||||
#undef i2d_ASN1_SET_OF_ACCESS_DESCRIPTION
|
||||
#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION i2d_ASN1_SET_OF_ACC_DESC
|
||||
#undef d2i_ASN1_SET_OF_ACCESS_DESCRIPTION
|
||||
#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION d2i_ASN1_SET_OF_ACC_DESC
|
||||
#endif
|
||||
|
||||
/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */
|
||||
#undef PEM_read_NETSCAPE_CERT_SEQUENCE
|
||||
#define PEM_read_NETSCAPE_CERT_SEQUENCE PEM_read_NS_CERT_SEQ
|
||||
#undef PEM_write_NETSCAPE_CERT_SEQUENCE
|
||||
#define PEM_write_NETSCAPE_CERT_SEQUENCE PEM_write_NS_CERT_SEQ
|
||||
#undef PEM_read_bio_NETSCAPE_CERT_SEQUENCE
|
||||
#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE PEM_read_bio_NS_CERT_SEQ
|
||||
#undef PEM_write_bio_NETSCAPE_CERT_SEQUENCE
|
||||
#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE PEM_write_bio_NS_CERT_SEQ
|
||||
#undef PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE
|
||||
#define PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE PEM_write_cb_bio_NS_CERT_SEQ
|
||||
|
||||
/* Hack the names created with DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO) */
|
||||
#undef PEM_read_PKCS8_PRIV_KEY_INFO
|
||||
#define PEM_read_PKCS8_PRIV_KEY_INFO PEM_read_P8_PRIV_KEY_INFO
|
||||
#undef PEM_write_PKCS8_PRIV_KEY_INFO
|
||||
#define PEM_write_PKCS8_PRIV_KEY_INFO PEM_write_P8_PRIV_KEY_INFO
|
||||
#undef PEM_read_bio_PKCS8_PRIV_KEY_INFO
|
||||
#define PEM_read_bio_PKCS8_PRIV_KEY_INFO PEM_read_bio_P8_PRIV_KEY_INFO
|
||||
#undef PEM_write_bio_PKCS8_PRIV_KEY_INFO
|
||||
#define PEM_write_bio_PKCS8_PRIV_KEY_INFO PEM_write_bio_P8_PRIV_KEY_INFO
|
||||
#undef PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO
|
||||
#define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO PEM_wrt_cb_bio_P8_PRIV_KEY_INFO
|
||||
|
||||
/* Hack other PEM names */
|
||||
#undef PEM_write_bio_PKCS8PrivateKey_nid
|
||||
#define PEM_write_bio_PKCS8PrivateKey_nid PEM_write_bio_PKCS8PrivKey_nid
|
||||
|
||||
/* Hack some long X509 names */
|
||||
#undef X509_REVOKED_get_ext_by_critical
|
||||
#define X509_REVOKED_get_ext_by_critical X509_REVOKED_get_ext_by_critic
|
||||
#undef X509_policy_tree_get0_user_policies
|
||||
#define X509_policy_tree_get0_user_policies X509_pcy_tree_get0_usr_policies
|
||||
#undef X509_policy_node_get0_qualifiers
|
||||
#define X509_policy_node_get0_qualifiers X509_pcy_node_get0_qualifiers
|
||||
#undef X509_STORE_CTX_get_explicit_policy
|
||||
#define X509_STORE_CTX_get_explicit_policy X509_STORE_CTX_get_expl_policy
|
||||
#undef X509_STORE_CTX_get0_current_issuer
|
||||
#define X509_STORE_CTX_get0_current_issuer X509_STORE_CTX_get0_cur_issuer
|
||||
|
||||
/* Hack some long CRYPTO names */
|
||||
#undef CRYPTO_set_dynlock_destroy_callback
|
||||
#define CRYPTO_set_dynlock_destroy_callback CRYPTO_set_dynlock_destroy_cb
|
||||
#undef CRYPTO_set_dynlock_create_callback
|
||||
#define CRYPTO_set_dynlock_create_callback CRYPTO_set_dynlock_create_cb
|
||||
#undef CRYPTO_set_dynlock_lock_callback
|
||||
#define CRYPTO_set_dynlock_lock_callback CRYPTO_set_dynlock_lock_cb
|
||||
#undef CRYPTO_get_dynlock_lock_callback
|
||||
#define CRYPTO_get_dynlock_lock_callback CRYPTO_get_dynlock_lock_cb
|
||||
#undef CRYPTO_get_dynlock_destroy_callback
|
||||
#define CRYPTO_get_dynlock_destroy_callback CRYPTO_get_dynlock_destroy_cb
|
||||
#undef CRYPTO_get_dynlock_create_callback
|
||||
#define CRYPTO_get_dynlock_create_callback CRYPTO_get_dynlock_create_cb
|
||||
#undef CRYPTO_set_locked_mem_ex_functions
|
||||
#define CRYPTO_set_locked_mem_ex_functions CRYPTO_set_locked_mem_ex_funcs
|
||||
#undef CRYPTO_get_locked_mem_ex_functions
|
||||
#define CRYPTO_get_locked_mem_ex_functions CRYPTO_get_locked_mem_ex_funcs
|
||||
|
||||
/* Hack some long SSL names */
|
||||
#undef SSL_CTX_set_default_verify_paths
|
||||
#define SSL_CTX_set_default_verify_paths SSL_CTX_set_def_verify_paths
|
||||
#undef SSL_get_ex_data_X509_STORE_CTX_idx
|
||||
#define SSL_get_ex_data_X509_STORE_CTX_idx SSL_get_ex_d_X509_STORE_CTX_idx
|
||||
#undef SSL_add_file_cert_subjects_to_stack
|
||||
#define SSL_add_file_cert_subjects_to_stack SSL_add_file_cert_subjs_to_stk
|
||||
#undef SSL_add_dir_cert_subjects_to_stack
|
||||
#define SSL_add_dir_cert_subjects_to_stack SSL_add_dir_cert_subjs_to_stk
|
||||
#undef SSL_CTX_use_certificate_chain_file
|
||||
#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file
|
||||
#undef SSL_CTX_set_cert_verify_callback
|
||||
#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb
|
||||
#undef SSL_CTX_set_default_passwd_cb_userdata
|
||||
#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud
|
||||
#undef SSL_COMP_get_compression_methods
|
||||
#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods
|
||||
#undef ssl_add_clienthello_renegotiate_ext
|
||||
#define ssl_add_clienthello_renegotiate_ext ssl_add_clienthello_reneg_ext
|
||||
#undef ssl_add_serverhello_renegotiate_ext
|
||||
#define ssl_add_serverhello_renegotiate_ext ssl_add_serverhello_reneg_ext
|
||||
#undef ssl_parse_clienthello_renegotiate_ext
|
||||
#define ssl_parse_clienthello_renegotiate_ext ssl_parse_clienthello_reneg_ext
|
||||
#undef ssl_parse_serverhello_renegotiate_ext
|
||||
#define ssl_parse_serverhello_renegotiate_ext ssl_parse_serverhello_reneg_ext
|
||||
#undef SSL_srp_server_param_with_username
|
||||
#define SSL_srp_server_param_with_username SSL_srp_server_param_with_un
|
||||
#undef SSL_CTX_set_srp_client_pwd_callback
|
||||
#define SSL_CTX_set_srp_client_pwd_callback SSL_CTX_set_srp_client_pwd_cb
|
||||
#undef SSL_CTX_set_srp_verify_param_callback
|
||||
#define SSL_CTX_set_srp_verify_param_callback SSL_CTX_set_srp_vfy_param_cb
|
||||
#undef SSL_CTX_set_srp_username_callback
|
||||
#define SSL_CTX_set_srp_username_callback SSL_CTX_set_srp_un_cb
|
||||
#undef ssl_add_clienthello_use_srtp_ext
|
||||
#define ssl_add_clienthello_use_srtp_ext ssl_add_clihello_use_srtp_ext
|
||||
#undef ssl_add_serverhello_use_srtp_ext
|
||||
#define ssl_add_serverhello_use_srtp_ext ssl_add_serhello_use_srtp_ext
|
||||
#undef ssl_parse_clienthello_use_srtp_ext
|
||||
#define ssl_parse_clienthello_use_srtp_ext ssl_parse_clihello_use_srtp_ext
|
||||
#undef ssl_parse_serverhello_use_srtp_ext
|
||||
#define ssl_parse_serverhello_use_srtp_ext ssl_parse_serhello_use_srtp_ext
|
||||
#undef SSL_CTX_set_next_protos_advertised_cb
|
||||
#define SSL_CTX_set_next_protos_advertised_cb SSL_CTX_set_next_protos_adv_cb
|
||||
#undef SSL_CTX_set_next_proto_select_cb
|
||||
#define SSL_CTX_set_next_proto_select_cb SSL_CTX_set_next_proto_sel_cb
|
||||
#undef ssl3_cbc_record_digest_supported
|
||||
#define ssl3_cbc_record_digest_supported ssl3_cbc_record_digest_support
|
||||
#undef ssl_check_clienthello_tlsext_late
|
||||
#define ssl_check_clienthello_tlsext_late ssl_check_clihello_tlsext_late
|
||||
#undef ssl_check_clienthello_tlsext_early
|
||||
#define ssl_check_clienthello_tlsext_early ssl_check_clihello_tlsext_early
|
||||
|
||||
/* Hack some long ENGINE names */
|
||||
#undef ENGINE_get_default_BN_mod_exp_crt
|
||||
#define ENGINE_get_default_BN_mod_exp_crt ENGINE_get_def_BN_mod_exp_crt
|
||||
#undef ENGINE_set_default_BN_mod_exp_crt
|
||||
#define ENGINE_set_default_BN_mod_exp_crt ENGINE_set_def_BN_mod_exp_crt
|
||||
#undef ENGINE_set_load_privkey_function
|
||||
#define ENGINE_set_load_privkey_function ENGINE_set_load_privkey_fn
|
||||
#undef ENGINE_get_load_privkey_function
|
||||
#define ENGINE_get_load_privkey_function ENGINE_get_load_privkey_fn
|
||||
#undef ENGINE_unregister_pkey_asn1_meths
|
||||
#define ENGINE_unregister_pkey_asn1_meths ENGINE_unreg_pkey_asn1_meths
|
||||
#undef ENGINE_register_all_pkey_asn1_meths
|
||||
#define ENGINE_register_all_pkey_asn1_meths ENGINE_reg_all_pkey_asn1_meths
|
||||
#undef ENGINE_set_default_pkey_asn1_meths
|
||||
#define ENGINE_set_default_pkey_asn1_meths ENGINE_set_def_pkey_asn1_meths
|
||||
#undef ENGINE_get_pkey_asn1_meth_engine
|
||||
#define ENGINE_get_pkey_asn1_meth_engine ENGINE_get_pkey_asn1_meth_eng
|
||||
#undef ENGINE_set_load_ssl_client_cert_function
|
||||
#define ENGINE_set_load_ssl_client_cert_function \
|
||||
ENGINE_set_ld_ssl_clnt_cert_fn
|
||||
#undef ENGINE_get_ssl_client_cert_function
|
||||
#define ENGINE_get_ssl_client_cert_function ENGINE_get_ssl_client_cert_fn
|
||||
|
||||
/* Hack some long OCSP names */
|
||||
#undef OCSP_REQUEST_get_ext_by_critical
|
||||
#define OCSP_REQUEST_get_ext_by_critical OCSP_REQUEST_get_ext_by_crit
|
||||
#undef OCSP_BASICRESP_get_ext_by_critical
|
||||
#define OCSP_BASICRESP_get_ext_by_critical OCSP_BASICRESP_get_ext_by_crit
|
||||
#undef OCSP_SINGLERESP_get_ext_by_critical
|
||||
#define OCSP_SINGLERESP_get_ext_by_critical OCSP_SINGLERESP_get_ext_by_crit
|
||||
|
||||
/* Hack some long DES names */
|
||||
#undef _ossl_old_des_ede3_cfb64_encrypt
|
||||
#define _ossl_old_des_ede3_cfb64_encrypt _ossl_odes_ede3_cfb64_encrypt
|
||||
#undef _ossl_old_des_ede3_ofb64_encrypt
|
||||
#define _ossl_old_des_ede3_ofb64_encrypt _ossl_odes_ede3_ofb64_encrypt
|
||||
|
||||
/* Hack some long EVP names */
|
||||
#undef OPENSSL_add_all_algorithms_noconf
|
||||
#define OPENSSL_add_all_algorithms_noconf OPENSSL_add_all_algo_noconf
|
||||
#undef OPENSSL_add_all_algorithms_conf
|
||||
#define OPENSSL_add_all_algorithms_conf OPENSSL_add_all_algo_conf
|
||||
#undef EVP_PKEY_meth_set_verify_recover
|
||||
#define EVP_PKEY_meth_set_verify_recover EVP_PKEY_meth_set_vrfy_recover
|
||||
|
||||
/* Hack some long EC names */
|
||||
#undef EC_GROUP_set_point_conversion_form
|
||||
#define EC_GROUP_set_point_conversion_form EC_GROUP_set_point_conv_form
|
||||
#undef EC_GROUP_get_point_conversion_form
|
||||
#define EC_GROUP_get_point_conversion_form EC_GROUP_get_point_conv_form
|
||||
#undef EC_GROUP_clear_free_all_extra_data
|
||||
#define EC_GROUP_clear_free_all_extra_data EC_GROUP_clr_free_all_xtra_data
|
||||
#undef EC_KEY_set_public_key_affine_coordinates
|
||||
#define EC_KEY_set_public_key_affine_coordinates \
|
||||
EC_KEY_set_pub_key_aff_coords
|
||||
#undef EC_POINT_set_Jprojective_coordinates_GFp
|
||||
#define EC_POINT_set_Jprojective_coordinates_GFp \
|
||||
EC_POINT_set_Jproj_coords_GFp
|
||||
#undef EC_POINT_get_Jprojective_coordinates_GFp
|
||||
#define EC_POINT_get_Jprojective_coordinates_GFp \
|
||||
EC_POINT_get_Jproj_coords_GFp
|
||||
#undef EC_POINT_set_affine_coordinates_GFp
|
||||
#define EC_POINT_set_affine_coordinates_GFp EC_POINT_set_affine_coords_GFp
|
||||
#undef EC_POINT_get_affine_coordinates_GFp
|
||||
#define EC_POINT_get_affine_coordinates_GFp EC_POINT_get_affine_coords_GFp
|
||||
#undef EC_POINT_set_compressed_coordinates_GFp
|
||||
#define EC_POINT_set_compressed_coordinates_GFp EC_POINT_set_compr_coords_GFp
|
||||
#undef EC_POINT_set_affine_coordinates_GF2m
|
||||
#define EC_POINT_set_affine_coordinates_GF2m EC_POINT_set_affine_coords_GF2m
|
||||
#undef EC_POINT_get_affine_coordinates_GF2m
|
||||
#define EC_POINT_get_affine_coordinates_GF2m EC_POINT_get_affine_coords_GF2m
|
||||
#undef EC_POINT_set_compressed_coordinates_GF2m
|
||||
#define EC_POINT_set_compressed_coordinates_GF2m \
|
||||
EC_POINT_set_compr_coords_GF2m
|
||||
#undef ec_GF2m_simple_group_clear_finish
|
||||
#define ec_GF2m_simple_group_clear_finish ec_GF2m_simple_grp_clr_finish
|
||||
#undef ec_GF2m_simple_group_check_discriminant
|
||||
#define ec_GF2m_simple_group_check_discriminant ec_GF2m_simple_grp_chk_discrim
|
||||
#undef ec_GF2m_simple_point_clear_finish
|
||||
#define ec_GF2m_simple_point_clear_finish ec_GF2m_simple_pt_clr_finish
|
||||
#undef ec_GF2m_simple_point_set_to_infinity
|
||||
#define ec_GF2m_simple_point_set_to_infinity ec_GF2m_simple_pt_set_to_inf
|
||||
#undef ec_GF2m_simple_points_make_affine
|
||||
#define ec_GF2m_simple_points_make_affine ec_GF2m_simple_pts_make_affine
|
||||
#undef ec_GF2m_simple_point_set_affine_coordinates
|
||||
#define ec_GF2m_simple_point_set_affine_coordinates \
|
||||
ec_GF2m_smp_pt_set_af_coords
|
||||
#undef ec_GF2m_simple_point_get_affine_coordinates
|
||||
#define ec_GF2m_simple_point_get_affine_coordinates \
|
||||
ec_GF2m_smp_pt_get_af_coords
|
||||
#undef ec_GF2m_simple_set_compressed_coordinates
|
||||
#define ec_GF2m_simple_set_compressed_coordinates \
|
||||
ec_GF2m_smp_set_compr_coords
|
||||
#undef ec_GFp_simple_group_set_curve_GFp
|
||||
#define ec_GFp_simple_group_set_curve_GFp ec_GFp_simple_grp_set_curve_GFp
|
||||
#undef ec_GFp_simple_group_get_curve_GFp
|
||||
#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp
|
||||
#undef ec_GFp_simple_group_clear_finish
|
||||
#define ec_GFp_simple_group_clear_finish ec_GFp_simple_grp_clear_finish
|
||||
#undef ec_GFp_simple_group_set_generator
|
||||
#define ec_GFp_simple_group_set_generator ec_GFp_simple_grp_set_generator
|
||||
#undef ec_GFp_simple_group_get0_generator
|
||||
#define ec_GFp_simple_group_get0_generator ec_GFp_simple_grp_gt0_generator
|
||||
#undef ec_GFp_simple_group_get_cofactor
|
||||
#define ec_GFp_simple_group_get_cofactor ec_GFp_simple_grp_get_cofactor
|
||||
#undef ec_GFp_simple_point_clear_finish
|
||||
#define ec_GFp_simple_point_clear_finish ec_GFp_simple_pt_clear_finish
|
||||
#undef ec_GFp_simple_point_set_to_infinity
|
||||
#define ec_GFp_simple_point_set_to_infinity ec_GFp_simple_pt_set_to_inf
|
||||
#undef ec_GFp_simple_points_make_affine
|
||||
#define ec_GFp_simple_points_make_affine ec_GFp_simple_pts_make_affine
|
||||
#undef ec_GFp_simple_set_Jprojective_coordinates_GFp
|
||||
#define ec_GFp_simple_set_Jprojective_coordinates_GFp \
|
||||
ec_GFp_smp_set_Jproj_coords_GFp
|
||||
#undef ec_GFp_simple_get_Jprojective_coordinates_GFp
|
||||
#define ec_GFp_simple_get_Jprojective_coordinates_GFp \
|
||||
ec_GFp_smp_get_Jproj_coords_GFp
|
||||
#undef ec_GFp_simple_point_set_affine_coordinates_GFp
|
||||
#define ec_GFp_simple_point_set_affine_coordinates_GFp \
|
||||
ec_GFp_smp_pt_set_af_coords_GFp
|
||||
#undef ec_GFp_simple_point_get_affine_coordinates_GFp
|
||||
#define ec_GFp_simple_point_get_affine_coordinates_GFp \
|
||||
ec_GFp_smp_pt_get_af_coords_GFp
|
||||
#undef ec_GFp_simple_set_compressed_coordinates_GFp
|
||||
#define ec_GFp_simple_set_compressed_coordinates_GFp \
|
||||
ec_GFp_smp_set_compr_coords_GFp
|
||||
#undef ec_GFp_simple_point_set_affine_coordinates
|
||||
#define ec_GFp_simple_point_set_affine_coordinates \
|
||||
ec_GFp_smp_pt_set_af_coords
|
||||
#undef ec_GFp_simple_point_get_affine_coordinates
|
||||
#define ec_GFp_simple_point_get_affine_coordinates \
|
||||
ec_GFp_smp_pt_get_af_coords
|
||||
#undef ec_GFp_simple_set_compressed_coordinates
|
||||
#define ec_GFp_simple_set_compressed_coordinates \
|
||||
ec_GFp_smp_set_compr_coords
|
||||
#undef ec_GFp_simple_group_check_discriminant
|
||||
#define ec_GFp_simple_group_check_discriminant ec_GFp_simple_grp_chk_discrim
|
||||
|
||||
/* Hack som long STORE names */
|
||||
#undef STORE_method_set_initialise_function
|
||||
#define STORE_method_set_initialise_function STORE_meth_set_initialise_fn
|
||||
#undef STORE_method_set_cleanup_function
|
||||
#define STORE_method_set_cleanup_function STORE_meth_set_cleanup_fn
|
||||
#undef STORE_method_set_generate_function
|
||||
#define STORE_method_set_generate_function STORE_meth_set_generate_fn
|
||||
#undef STORE_method_set_modify_function
|
||||
#define STORE_method_set_modify_function STORE_meth_set_modify_fn
|
||||
#undef STORE_method_set_revoke_function
|
||||
#define STORE_method_set_revoke_function STORE_meth_set_revoke_fn
|
||||
#undef STORE_method_set_delete_function
|
||||
#define STORE_method_set_delete_function STORE_meth_set_delete_fn
|
||||
#undef STORE_method_set_list_start_function
|
||||
#define STORE_method_set_list_start_function STORE_meth_set_list_start_fn
|
||||
#undef STORE_method_set_list_next_function
|
||||
#define STORE_method_set_list_next_function STORE_meth_set_list_next_fn
|
||||
#undef STORE_method_set_list_end_function
|
||||
#define STORE_method_set_list_end_function STORE_meth_set_list_end_fn
|
||||
#undef STORE_method_set_update_store_function
|
||||
#define STORE_method_set_update_store_function STORE_meth_set_update_store_fn
|
||||
#undef STORE_method_set_lock_store_function
|
||||
#define STORE_method_set_lock_store_function STORE_meth_set_lock_store_fn
|
||||
#undef STORE_method_set_unlock_store_function
|
||||
#define STORE_method_set_unlock_store_function STORE_meth_set_unlock_store_fn
|
||||
#undef STORE_method_get_initialise_function
|
||||
#define STORE_method_get_initialise_function STORE_meth_get_initialise_fn
|
||||
#undef STORE_method_get_cleanup_function
|
||||
#define STORE_method_get_cleanup_function STORE_meth_get_cleanup_fn
|
||||
#undef STORE_method_get_generate_function
|
||||
#define STORE_method_get_generate_function STORE_meth_get_generate_fn
|
||||
#undef STORE_method_get_modify_function
|
||||
#define STORE_method_get_modify_function STORE_meth_get_modify_fn
|
||||
#undef STORE_method_get_revoke_function
|
||||
#define STORE_method_get_revoke_function STORE_meth_get_revoke_fn
|
||||
#undef STORE_method_get_delete_function
|
||||
#define STORE_method_get_delete_function STORE_meth_get_delete_fn
|
||||
#undef STORE_method_get_list_start_function
|
||||
#define STORE_method_get_list_start_function STORE_meth_get_list_start_fn
|
||||
#undef STORE_method_get_list_next_function
|
||||
#define STORE_method_get_list_next_function STORE_meth_get_list_next_fn
|
||||
#undef STORE_method_get_list_end_function
|
||||
#define STORE_method_get_list_end_function STORE_meth_get_list_end_fn
|
||||
#undef STORE_method_get_update_store_function
|
||||
#define STORE_method_get_update_store_function STORE_meth_get_update_store_fn
|
||||
#undef STORE_method_get_lock_store_function
|
||||
#define STORE_method_get_lock_store_function STORE_meth_get_lock_store_fn
|
||||
#undef STORE_method_get_unlock_store_function
|
||||
#define STORE_method_get_unlock_store_function STORE_meth_get_unlock_store_fn
|
||||
|
||||
/* Hack some long TS names */
|
||||
#undef TS_RESP_CTX_set_status_info_cond
|
||||
#define TS_RESP_CTX_set_status_info_cond TS_RESP_CTX_set_stat_info_cond
|
||||
#undef TS_RESP_CTX_set_clock_precision_digits
|
||||
#define TS_RESP_CTX_set_clock_precision_digits TS_RESP_CTX_set_clk_prec_digits
|
||||
#undef TS_CONF_set_clock_precision_digits
|
||||
#define TS_CONF_set_clock_precision_digits TS_CONF_set_clk_prec_digits
|
||||
|
||||
/* Hack some long CMS names */
|
||||
#undef CMS_RecipientInfo_ktri_get0_algs
|
||||
#define CMS_RecipientInfo_ktri_get0_algs CMS_RecipInfo_ktri_get0_algs
|
||||
#undef CMS_RecipientInfo_ktri_get0_signer_id
|
||||
#define CMS_RecipientInfo_ktri_get0_signer_id CMS_RecipInfo_ktri_get0_sigr_id
|
||||
#undef CMS_OtherRevocationInfoFormat_it
|
||||
#define CMS_OtherRevocationInfoFormat_it CMS_OtherRevocInfoFormat_it
|
||||
#undef CMS_KeyAgreeRecipientIdentifier_it
|
||||
#define CMS_KeyAgreeRecipientIdentifier_it CMS_KeyAgreeRecipIdentifier_it
|
||||
#undef CMS_OriginatorIdentifierOrKey_it
|
||||
#define CMS_OriginatorIdentifierOrKey_it CMS_OriginatorIdOrKey_it
|
||||
#undef cms_SignerIdentifier_get0_signer_id
|
||||
#define cms_SignerIdentifier_get0_signer_id cms_SignerId_get0_signer_id
|
||||
|
||||
/* Hack some long DTLS1 names */
|
||||
#undef dtls1_retransmit_buffered_messages
|
||||
#define dtls1_retransmit_buffered_messages dtls1_retransmit_buffered_msgs
|
||||
|
||||
/* Hack some long SRP names */
|
||||
#undef SRP_generate_server_master_secret
|
||||
#define SRP_generate_server_master_secret SRP_gen_server_master_secret
|
||||
#undef SRP_generate_client_master_secret
|
||||
#define SRP_generate_client_master_secret SRP_gen_client_master_secret
|
||||
|
||||
/* Hack some long UI names */
|
||||
#undef UI_method_get_prompt_constructor
|
||||
#define UI_method_get_prompt_constructor UI_method_get_prompt_constructr
|
||||
#undef UI_method_set_prompt_constructor
|
||||
#define UI_method_set_prompt_constructor UI_method_set_prompt_constructr
|
||||
|
||||
#endif /* defined OPENSSL_SYS_VMS */
|
||||
|
||||
|
||||
/* Case insensitive linking causes problems.... */
|
||||
#if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2)
|
||||
#undef ERR_load_CRYPTO_strings
|
||||
#define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings
|
||||
#undef OCSP_crlID_new
|
||||
#define OCSP_crlID_new OCSP_crlID2_new
|
||||
|
||||
#undef d2i_ECPARAMETERS
|
||||
#define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS
|
||||
#undef i2d_ECPARAMETERS
|
||||
#define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS
|
||||
#undef d2i_ECPKPARAMETERS
|
||||
#define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS
|
||||
#undef i2d_ECPKPARAMETERS
|
||||
#define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS
|
||||
|
||||
/* These functions do not seem to exist! However, I'm paranoid...
|
||||
Original command in x509v3.h:
|
||||
These functions are being redefined in another directory,
|
||||
and clash when the linker is case-insensitive, so let's
|
||||
hide them a little, by giving them an extra 'o' at the
|
||||
beginning of the name... */
|
||||
#undef X509v3_cleanup_extensions
|
||||
#define X509v3_cleanup_extensions oX509v3_cleanup_extensions
|
||||
#undef X509v3_add_extension
|
||||
#define X509v3_add_extension oX509v3_add_extension
|
||||
#undef X509v3_add_netscape_extensions
|
||||
#define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions
|
||||
#undef X509v3_add_standard_extensions
|
||||
#define X509v3_add_standard_extensions oX509v3_add_standard_extensions
|
||||
|
||||
/* This one clashes with CMS_data_create */
|
||||
#undef cms_Data_create
|
||||
#define cms_Data_create priv_cms_Data_create
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* ! defined HEADER_VMS_IDHACKS_H */
|
||||
+31
-28
@@ -54,39 +54,42 @@ static const char rcsid[]="$Id: getopt_long.c,v 1.1 2009/10/16 19:50:28 rodney E
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#include <err.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
/* Windows needs warnx(). We change the definition though:
|
||||
* 1. (another) global is defined, opterrmsg, which holds the error message
|
||||
* 2. errors are always printed out on stderr w/o the program name
|
||||
* Note that opterrmsg always gets set no matter what opterr is set to. The
|
||||
* error message will not be printed if opterr is 0 as usual.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
char opterrmsg[128]; /* last error message is stored here */
|
||||
|
||||
static void warnx(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
if (fmt != NULL)
|
||||
_vsnprintf(opterrmsg, 128, fmt, ap);
|
||||
else
|
||||
opterrmsg[0]='\0';
|
||||
va_end(ap);
|
||||
fprintf(stderr, opterrmsg);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
/* Windows needs warnx(). We change the definition though:
|
||||
* 1. (another) global is defined, opterrmsg, which holds the error message
|
||||
* 2. errors are always printed out on stderr w/o the program name
|
||||
* Note that opterrmsg always gets set no matter what opterr is set to. The
|
||||
* error message will not be printed if opterr is 0 as usual.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
char opterrmsg[128]; /* last error message is stored here */
|
||||
|
||||
static void warnx(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
if (fmt != NULL)
|
||||
_vsnprintf(opterrmsg, 128, fmt, ap);
|
||||
else
|
||||
opterrmsg[0]='\0';
|
||||
va_end(ap);
|
||||
fprintf(stderr, opterrmsg);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
#endif /*_WIN32*/
|
||||
|
||||
#define REPLACE_GETOPT /* use this getopt as the system getopt(3) */
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define inline __inline
|
||||
#if !defined(HAVE_STRUCT_TIMESPEC) && _MSC_VER >= 1900
|
||||
#define HAVE_STRUCT_TIMESPEC
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Binary file not shown.
+192
-1196
File diff suppressed because it is too large.
Load diff
@@ -1,371 +1,2 @@
|
||||
#pragma once
|
||||
|
||||
#define NVAPI_INTERNAL
|
||||
#include "nvapi.h"
|
||||
|
||||
NvAPI_Status nvapi_dll_init();
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU8 valid;
|
||||
NvU8 count;
|
||||
struct
|
||||
{
|
||||
NvU32 pstate; // Assumption
|
||||
NvU32 unknown1[2];
|
||||
NvU32 min_power;
|
||||
NvU32 unknown2[2];
|
||||
NvU32 def_power;
|
||||
NvU32 unknown3[2];
|
||||
NvU32 max_power;
|
||||
NvU32 unknown4; // 0
|
||||
} entries[4];
|
||||
} NVAPI_GPU_POWER_INFO;
|
||||
#define NVAPI_GPU_POWER_INFO_VER MAKE_NVAPI_VERSION(NVAPI_GPU_POWER_INFO, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 flags;
|
||||
struct {
|
||||
NvU32 unknown1;
|
||||
NvU32 unknown2;
|
||||
NvU32 power; // percent * 1000
|
||||
NvU32 unknown4;
|
||||
} entries[4];
|
||||
} NVAPI_GPU_POWER_STATUS;
|
||||
#define NVAPI_GPU_POWER_STATUS_VER MAKE_NVAPI_VERSION(NVAPI_GPU_POWER_STATUS, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 count;
|
||||
struct {
|
||||
NvU32 unknown1;
|
||||
NvU32 unknown2;
|
||||
NvU32 power; // unsure ?? 85536 to 95055 on 1080, 104825+ on 970
|
||||
NvU32 unknown4;
|
||||
} entries[4];
|
||||
} NVAPI_GPU_POWER_TOPO;
|
||||
#define NVAPI_GPU_POWER_TOPO_VER MAKE_NVAPI_VERSION(NVAPI_GPU_POWER_TOPO, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 flags;
|
||||
struct {
|
||||
NvU32 controller;
|
||||
NvU32 unknown;
|
||||
NvS32 min_temp;
|
||||
NvS32 def_temp;
|
||||
NvS32 max_temp;
|
||||
NvU32 defaultFlags;
|
||||
} entries[4];
|
||||
} NVAPI_GPU_THERMAL_INFO;
|
||||
#define NVAPI_GPU_THERMAL_INFO_VER MAKE_NVAPI_VERSION(NVAPI_GPU_THERMAL_INFO, 2)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 flags;
|
||||
struct {
|
||||
NvU32 controller;
|
||||
NvU32 value;
|
||||
NvU32 flags;
|
||||
} entries[4];
|
||||
} NVAPI_GPU_THERMAL_LIMIT;
|
||||
#define NVAPI_GPU_THERMAL_LIMIT_VER MAKE_NVAPI_VERSION(NVAPI_GPU_THERMAL_LIMIT, 2)
|
||||
|
||||
// Maxwell gpu core voltage reading
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 flags;
|
||||
NvU32 count; // unsure
|
||||
NvU32 unknown;
|
||||
NvU32 value_uV;
|
||||
NvU32 buf1[30];
|
||||
} NVAPI_VOLT_STATUS; // 140 bytes (1-008c)
|
||||
#define NVAPI_VOLT_STATUS_VER MAKE_NVAPI_VERSION(NVAPI_VOLT_STATUS, 1)
|
||||
|
||||
// Pascal gpu core voltage reading
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 flags;
|
||||
NvU32 nul[8];
|
||||
NvU32 value_uV;
|
||||
NvU32 buf1[8];
|
||||
} NVAPI_VOLTAGE_STATUS; // 76 bytes (1-004c)
|
||||
#define NVAPI_VOLTAGE_STATUS_VER MAKE_NVAPI_VERSION(NVAPI_VOLTAGE_STATUS, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 numClocks; // unsure
|
||||
NvU32 nul[8];
|
||||
struct {
|
||||
NvU32 a;
|
||||
NvU32 clockType;
|
||||
NvU32 c;
|
||||
NvU32 d;
|
||||
NvU32 e;
|
||||
NvU32 f;
|
||||
NvU32 g;
|
||||
NvU32 h;
|
||||
NvU32 i;
|
||||
NvU32 j;
|
||||
NvS32 rangeMax;
|
||||
NvS32 rangeMin;
|
||||
NvS32 tempMax; // ? unsure
|
||||
NvU32 n;
|
||||
NvU32 o;
|
||||
NvU32 p;
|
||||
NvU32 q;
|
||||
NvU32 r;
|
||||
} entries[32]; // NVAPI_MAX_GPU_CLOCKS ?
|
||||
} NVAPI_CLOCKS_RANGE; // 2344 bytes
|
||||
#define NVAPI_CLOCKS_RANGE_VER MAKE_NVAPI_VERSION(NVAPI_CLOCKS_RANGE, 1)
|
||||
|
||||
// seems to return a clock table mask
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 mask[4]; // 80 bits mask
|
||||
NvU32 buf0[8];
|
||||
struct {
|
||||
NvU32 a;
|
||||
NvU32 b;
|
||||
NvU32 c;
|
||||
NvU32 d;
|
||||
NvU32 memDelta; // 1 for mem
|
||||
NvU32 gpuDelta; // 1 for gpu
|
||||
} clocks[80 + 23];
|
||||
NvU32 buf1[916];
|
||||
} NVAPI_CLOCK_MASKS; // 6188 bytes
|
||||
#define NVAPI_CLOCK_MASKS_VER MAKE_NVAPI_VERSION(NVAPI_CLOCK_MASKS, 1)
|
||||
|
||||
// contains the gpu/mem clocks deltas
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 mask[4]; // 80 bits mask (could be 8x 32bits)
|
||||
NvU32 buf0[12];
|
||||
struct {
|
||||
NvU32 a;
|
||||
NvU32 b;
|
||||
NvU32 c;
|
||||
NvU32 d;
|
||||
NvU32 e;
|
||||
NvS32 freqDelta; // 84000 = +84MHz
|
||||
NvU32 g;
|
||||
NvU32 h;
|
||||
NvU32 i;
|
||||
} gpuDeltas[80];
|
||||
NvU32 memFilled[23]; // maybe only 4 max
|
||||
NvS32 memDeltas[23];
|
||||
NvU32 buf1[1529];
|
||||
} NVAPI_CLOCK_TABLE; // 9248 bytes
|
||||
#define NVAPI_CLOCK_TABLE_VER MAKE_NVAPI_VERSION(NVAPI_CLOCK_TABLE, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 mask[4]; // 80 bits mask
|
||||
NvU32 buf0[12];
|
||||
struct {
|
||||
NvU32 a; // 0
|
||||
NvU32 freq_kHz;
|
||||
NvU32 volt_uV;
|
||||
NvU32 d;
|
||||
NvU32 e;
|
||||
NvU32 f;
|
||||
NvU32 g;
|
||||
} gpuEntries[80];
|
||||
struct {
|
||||
NvU32 a; // 1 for idle values ?
|
||||
NvU32 freq_kHz;
|
||||
NvU32 volt_uV;
|
||||
NvU32 d;
|
||||
NvU32 e;
|
||||
NvU32 f;
|
||||
NvU32 g;
|
||||
} memEntries[23];
|
||||
NvU32 buf1[1064];
|
||||
} NVAPI_VFP_CURVE; // 7208 bytes (1-1c28)
|
||||
#define NVAPI_VFP_CURVE_VER MAKE_NVAPI_VERSION(NVAPI_VFP_CURVE, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvS32 percent;
|
||||
NvU32 pad[8];
|
||||
} NVAPI_VOLTBOOST_PERCENT; // 40 bytes (1-0028)
|
||||
#define NVAPI_VOLTBOOST_PERCENT_VER MAKE_NVAPI_VERSION(NVAPI_VOLTBOOST_PERCENT, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 flags;
|
||||
NvU32 filled; // 1
|
||||
struct {
|
||||
NvU32 volt_uV;
|
||||
NvU32 unknown;
|
||||
} entries[128];
|
||||
// some empty tables then...
|
||||
NvU32 buf1[3888];
|
||||
} NVAPI_VOLTAGES_TABLE; // 16588 bytes (1-40cc)
|
||||
#define NVAPI_VOLTAGES_TABLE_VER MAKE_NVAPI_VERSION(NVAPI_VOLTAGES_TABLE, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 val1; // 7
|
||||
NvU32 val2; // 0x3F (63.)
|
||||
NvU32 pad[16];
|
||||
} NVAPI_GPU_PERF_INFO; // 76 bytes (1-004c)
|
||||
#define NVAPI_GPU_PERF_INFO_VER MAKE_NVAPI_VERSION(NVAPI_GPU_PERF_INFO, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 flags; // 0
|
||||
NvU64 timeRef; // increment with time
|
||||
NvU64 val1; // seen 1 4 5 while mining, 16 else
|
||||
NvU64 val2; // seen 7 and 3
|
||||
NvU64 values[3]; // increment with time
|
||||
NvU32 pad[326]; // empty
|
||||
} NVAPI_GPU_PERF_STATUS; // 1360 bytes (1-0550)
|
||||
#define NVAPI_GPU_PERF_STATUS_VER MAKE_NVAPI_VERSION(NVAPI_GPU_PERF_STATUS, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 val1; // 4
|
||||
NvU32 val2; // 2 or 0
|
||||
NvU32 val3; // 2
|
||||
NvU32 val4; // 3
|
||||
NV_GPU_PERF_PSTATE_ID pStateId;
|
||||
NvU32 val6; // 0 or 2
|
||||
NvU32 val7; // 4
|
||||
NvU32 val8; // 0
|
||||
NvU32 memFreq1; // 405000.
|
||||
NvU32 memFreq2; // 405000.
|
||||
NvU32 memFreqMin;// 101250.
|
||||
NvU32 memFreqMax;// 486000.
|
||||
NvU32 zeros[3];
|
||||
NvU32 gpuFreq1; // 696000. Unsure about those
|
||||
NvU32 gpuFreq2; // 696000.
|
||||
NvU32 gpuFreqMin;// 174000.
|
||||
NvU32 gpuFreqMax;// 658000.
|
||||
NvU32 pad[2697];
|
||||
} NVAPI_GPU_PERF_CLOCKS; // 10868 bytes (2-2a74)
|
||||
#define NVAPI_GPU_PERF_CLOCKS_VER MAKE_NVAPI_VERSION(NVAPI_GPU_PERF_CLOCKS, 2)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 level;
|
||||
NvU32 count;
|
||||
NvU32 pad[339]; // (4-0558)
|
||||
} NVAPI_COOLER_SETTINGS;
|
||||
#define NVAPI_COOLER_SETTINGS_VER MAKE_NVAPI_VERSION(NVAPI_COOLER_SETTINGS, 4)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 level; // 0 = auto ?
|
||||
NvU32 count; // 1
|
||||
NvU32 pad[38]; // (1-00a4)
|
||||
} NVAPI_COOLER_LEVEL;
|
||||
#define NVAPI_COOLER_LEVEL_VER MAKE_NVAPI_VERSION(NVAPI_COOLER_LEVEL, 1)
|
||||
|
||||
NvAPI_Status NvAPI_DLL_GetInterfaceVersionString(NvAPI_ShortString string);
|
||||
|
||||
NvAPI_Status NvAPI_DLL_PerfPoliciesGetInfo(NvPhysicalGpuHandle, NVAPI_GPU_PERF_INFO*); // 409D9841 1-004c
|
||||
NvAPI_Status NvAPI_DLL_PerfPoliciesGetStatus(NvPhysicalGpuHandle, NVAPI_GPU_PERF_STATUS*); // 3D358A0C 1-0550
|
||||
|
||||
NvAPI_Status NvAPI_DLL_ClientPowerPoliciesGetInfo(NvPhysicalGpuHandle, NVAPI_GPU_POWER_INFO*);
|
||||
NvAPI_Status NvAPI_DLL_ClientPowerPoliciesGetStatus(NvPhysicalGpuHandle, NVAPI_GPU_POWER_STATUS*);
|
||||
NvAPI_Status NvAPI_DLL_ClientPowerPoliciesSetStatus(NvPhysicalGpuHandle, NVAPI_GPU_POWER_STATUS*);
|
||||
NvAPI_Status NvAPI_DLL_ClientPowerTopologyGetStatus(NvPhysicalGpuHandle, NVAPI_GPU_POWER_TOPO*); // EDCF624E 1-0048
|
||||
|
||||
NvAPI_Status NvAPI_DLL_ClientThermalPoliciesGetInfo(NvPhysicalGpuHandle, NVAPI_GPU_THERMAL_INFO*);
|
||||
NvAPI_Status NvAPI_DLL_ClientThermalPoliciesGetLimit(NvPhysicalGpuHandle, NVAPI_GPU_THERMAL_LIMIT*);
|
||||
NvAPI_Status NvAPI_DLL_ClientThermalPoliciesSetLimit(NvPhysicalGpuHandle, NVAPI_GPU_THERMAL_LIMIT*);
|
||||
|
||||
// Pascal GTX only
|
||||
NvAPI_Status NvAPI_DLL_GetClockBoostRanges(NvPhysicalGpuHandle, NVAPI_CLOCKS_RANGE*);
|
||||
NvAPI_Status NvAPI_DLL_GetClockBoostMask(NvPhysicalGpuHandle, NVAPI_CLOCK_MASKS*); // 0x507B4B59
|
||||
NvAPI_Status NvAPI_DLL_GetClockBoostTable(NvPhysicalGpuHandle, NVAPI_CLOCK_TABLE*); // 0x23F1B133
|
||||
NvAPI_Status NvAPI_DLL_SetClockBoostTable(NvPhysicalGpuHandle, NVAPI_CLOCK_TABLE*); // 0x0733E009
|
||||
NvAPI_Status NvAPI_DLL_GetVFPCurve(NvPhysicalGpuHandle, NVAPI_VFP_CURVE*); // 0x21537AD4
|
||||
NvAPI_Status NvAPI_DLL_GetCurrentVoltage(NvPhysicalGpuHandle, NVAPI_VOLTAGE_STATUS*); // 0x465F9BCF 1-004c
|
||||
NvAPI_Status NvAPI_DLL_GetCoreVoltageBoostPercent(NvPhysicalGpuHandle, NVAPI_VOLTBOOST_PERCENT*);
|
||||
NvAPI_Status NvAPI_DLL_SetCoreVoltageBoostPercent(NvPhysicalGpuHandle, NVAPI_VOLTBOOST_PERCENT*);
|
||||
|
||||
// Maxwell only
|
||||
NvAPI_Status NvAPI_DLL_GetVoltageDomainsStatus(NvPhysicalGpuHandle, NVAPI_VOLT_STATUS*); // 0xC16C7E2C
|
||||
NvAPI_Status NvAPI_DLL_GetVoltages(NvPhysicalGpuHandle, NVAPI_VOLTAGES_TABLE*); // 0x7D656244 1-40CC
|
||||
NvAPI_Status NvAPI_DLL_GetVoltageStep(NvPhysicalGpuHandle, NVAPI_VOLT_STATUS*); // 0x28766157 1-008C unsure of the name
|
||||
|
||||
NvAPI_Status NvAPI_DLL_GetCoolerSettings(NvPhysicalGpuHandle, uint32_t, NVAPI_COOLER_SETTINGS*); // 0xDA141340 4-0558
|
||||
NvAPI_Status NvAPI_DLL_SetCoolerLevels(NvPhysicalGpuHandle, uint32_t, NVAPI_COOLER_LEVEL*); // 0x891FA0AE 1-00A4
|
||||
NvAPI_Status NvAPI_DLL_RestoreCoolerSettings(NvPhysicalGpuHandle, NVAPI_COOLER_SETTINGS*, uint32_t);
|
||||
|
||||
NvAPI_Status NvAPI_DLL_GetSerialNumber(NvPhysicalGpuHandle, NvAPI_ShortString serial);
|
||||
|
||||
NvAPI_Status NvAPI_DLL_GetPerfClocks(NvPhysicalGpuHandle, uint32_t num, NVAPI_GPU_PERF_CLOCKS* pClocks); // 2-2A74
|
||||
//NvAPI_Status NvAPI_DLL_SetPerfClocks(NvPhysicalGpuHandle, uint32_t num, NVAPI_GPU_PERF_CLOCKS* pClocks); // error
|
||||
|
||||
//invalid..
|
||||
//NvAPI_Status NvAPI_DLL_GetPstateClientLimits(NvPhysicalGpuHandle, NV_GPU_PERF_PSTATE_ID, uint32_t* pLimits);
|
||||
//NvAPI_Status NvAPI_DLL_SetPstateClientLimits(NvPhysicalGpuHandle, NV_GPU_PERF_PSTATE_ID, uint32_t* pLimits);
|
||||
|
||||
NvAPI_Status NvAPI_DLL_SetPstates20v1(NvPhysicalGpuHandle handle, NV_GPU_PERF_PSTATES20_INFO_V1 *pSet);
|
||||
NvAPI_Status NvAPI_DLL_SetPstates20v2(NvPhysicalGpuHandle handle, NV_GPU_PERF_PSTATES20_INFO_V2 *pSet);
|
||||
|
||||
NvAPI_Status NvAPI_DLL_Unload();
|
||||
|
||||
#define NV_ASSERT(x) { NvAPI_Status ret = x; if(ret != NVAPI_OK) return ret; }
|
||||
|
||||
// to reduce stack size, allow to reuse a mem buffer
|
||||
#define NV_INIT_STRUCT_ON(TYPE, var, mem) { \
|
||||
var = (TYPE*) mem; \
|
||||
memset(var, 0, sizeof(TYPE)); \
|
||||
var->version = TYPE##_VER; \
|
||||
}
|
||||
|
||||
// alloc a struct, need free(var)
|
||||
#define NV_INIT_STRUCT_ALLOC(TYPE, var) { \
|
||||
var = (TYPE*) calloc(1, TYPE##_VER & 0xFFFF); \
|
||||
if (var) var->version = TYPE##_VER; \
|
||||
}
|
||||
|
||||
//! Used in NvAPI_I2CReadEx()
|
||||
typedef struct
|
||||
{
|
||||
NvU32 version;
|
||||
NvU32 displayMask; // Display Mask of the concerned display.
|
||||
NvU8 bIsDDCPort; // indicates either the DDC port (TRUE) or the communication port (FALSE) of the concerned display.
|
||||
NvU8 i2cDevAddress; // address of the I2C slave. The address should be shifted left by one. 0x50 -> 0xA0.
|
||||
NvU8* pbI2cRegAddress; // I2C target register address. May be NULL, which indicates no register address should be sent.
|
||||
NvU32 regAddrSize; // size in bytes of target register address. If pbI2cRegAddress is NULL, this field must be 0.
|
||||
NvU8* pbData; // buffer of data which is to be read or written (depending on the command).
|
||||
NvU32 cbRead; // bytes to read ??? seems required on write too
|
||||
NvU32 cbSize; // full size of the data buffer, pbData, to be read or written.
|
||||
NV_I2C_SPEED i2cSpeedKhz; // target speed of the transaction in (kHz) (Chosen from the enum NV_I2C_SPEED).
|
||||
NvU8 portId; // portid on which device is connected (remember to set bIsPortIdSet if this value is set)
|
||||
NvU32 bIsPortIdSet; // set this flag on if and only if portid value is set
|
||||
|
||||
} NV_I2C_INFO_EX;
|
||||
#define NV_I2C_INFO_EX_VER MAKE_NVAPI_VERSION(NV_I2C_INFO_EX,3)
|
||||
/*
|
||||
sample evga x64 call (struct of 0x40 bytes)
|
||||
ReadEx
|
||||
$ ==> 40 00 03 00 00 00 00 00 00 40 00 00 00 00 00 00
|
||||
$+10 58 F9 2B 00 00 00 00 00 01 00 00 00 00 00 00 00
|
||||
$+20 C0 F9 2B 00 00 00 00 00 02 00 00 00 FF FF 00 00
|
||||
$+30 00 00 00 00 02 00 00 00 01 00 00 00 00 00 00 00
|
||||
|
||||
$ ==> 40 00 03 00 00 00 00 00 00 10 00 00 00 00 00 00
|
||||
$+10 68 F9 2B 00 00 00 00 00 01 00 00 00 00 00 00 00
|
||||
$+20 C0 F9 2B 00 00 00 00 00 01 00 00 00 FF FF 00 00
|
||||
$+30 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00
|
||||
00000000002BF968 > 75 83 CF 3F 01 00 00 00
|
||||
00000000002BF9C0 > 0
|
||||
|
||||
WriteEx
|
||||
$ ==> 40 00 03 00 00 00 00 00 00 8C 00 00 00 00 00 00
|
||||
$+10 30 F9 2B 00 00 00 00 00 01 00 00 00 00 00 00 00
|
||||
$+20 38 F9 2B 00 00 00 00 00 02 00 00 00 FF FF 00 00
|
||||
$+30 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00
|
||||
00000000002BF930 > D1 00 00 00 00 00 00 00
|
||||
00000000002BF938 > 38 00 00 00 00 00 00 00
|
||||
*/
|
||||
|
||||
NvAPI_Status NvAPI_DLL_I2CReadEx(NvPhysicalGpuHandle, NV_I2C_INFO_EX*, NvU32*);
|
||||
NvAPI_Status NvAPI_DLL_I2CWriteEx(NvPhysicalGpuHandle, NV_I2C_INFO_EX*, NvU32*);
|
||||
/* todo: stripped version... or not */
|
||||
#include "nvapi.h"
|
||||
@@ -1,36 +1,3 @@
|
||||
/************************************************************************************************************************************\
|
||||
|* *|
|
||||
|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *|
|
||||
|* *|
|
||||
|* NOTICE TO USER: *|
|
||||
|* *|
|
||||
|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *|
|
||||
|* *|
|
||||
|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *|
|
||||
|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *|
|
||||
|* Otherwise, you have no rights to use or access this software in any manner. *|
|
||||
|* *|
|
||||
|* If not covered by the applicable NVIDIA software license agreement: *|
|
||||
|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *|
|
||||
|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *|
|
||||
|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *|
|
||||
|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *|
|
||||
|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *|
|
||||
|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *|
|
||||
|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
|
||||
|* *|
|
||||
|* U.S. Government End Users. *|
|
||||
|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
|
||||
|* consisting of "commercial computer software" and "commercial computer software documentation" *|
|
||||
|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *|
|
||||
|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
|
||||
|* all U.S. Government End Users acquire the software with only those rights set forth herein. *|
|
||||
|* *|
|
||||
|* Any use of this software in individual and commercial software must include, *|
|
||||
|* in the user documentation and internal comments to the code, *|
|
||||
|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *|
|
||||
|* *|
|
||||
\************************************************************************************************************************************/
|
||||
#pragma once
|
||||
#include"nvapi_lite_salstart.h"
|
||||
#pragma pack(push,8)
|
||||
@@ -53,7 +20,6 @@ extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* 64-bit types for compilers that support them, plus some obsolete variants */
|
||||
#if defined(__GNUC__) || defined(__arm) || defined(__IAR_SYSTEMS_ICC__) || defined(__ghs__) || defined(_WIN64)
|
||||
typedef unsigned long long NvU64; /* 0 to 18446744073709551615 */
|
||||
@@ -70,7 +36,6 @@ typedef signed long NvS32; /* -2147483648 to 2147483647 */
|
||||
typedef signed int NvS32; /* -2147483648 to 2147483647 */
|
||||
#endif
|
||||
|
||||
#ifndef __unix
|
||||
// mac os 32-bit still needs this
|
||||
#if ( (defined(macintosh) && defined(__LP64__) && (__NVAPI_RESERVED0__)) || \
|
||||
(!defined(macintosh) && defined(__NVAPI_RESERVED0__)) )
|
||||
@@ -78,22 +43,12 @@ typedef unsigned int NvU32; /* 0 to 4294967295 */
|
||||
#else
|
||||
typedef unsigned long NvU32; /* 0 to 4294967295 */
|
||||
#endif
|
||||
#else
|
||||
typedef unsigned int NvU32; /* 0 to 4294967295 */
|
||||
#endif
|
||||
|
||||
typedef unsigned long temp_NvU32; /* 0 to 4294967295 */
|
||||
typedef signed short NvS16;
|
||||
typedef unsigned short NvU16;
|
||||
typedef unsigned char NvU8;
|
||||
typedef signed char NvS8;
|
||||
|
||||
/* Boolean type */
|
||||
typedef NvU8 NvBool;
|
||||
#define NV_TRUE ((NvBool)(0 == 0))
|
||||
#define NV_FALSE ((NvBool)(0 != 0))
|
||||
|
||||
|
||||
typedef struct _NV_RECT
|
||||
{
|
||||
NvU32 left;
|
||||
@@ -344,20 +299,11 @@ typedef enum _NvAPI_Status
|
||||
NVAPI_TIMEOUT = -191, //!< Requested operation timed out
|
||||
NVAPI_GPU_WORKSTATION_FEATURE_INCOMPLETE = -192, //!< The requested workstation feature set has incomplete driver internal allocation resources
|
||||
NVAPI_STEREO_INIT_ACTIVATION_NOT_DONE = -193, //!< Call failed because InitActivation was not called.
|
||||
NVAPI_SYNC_NOT_ACTIVE = -194, //!< The requested action cannot be performed without Sync being enabled.
|
||||
NVAPI_SYNC_MASTER_NOT_FOUND = -195, //!< The requested action cannot be performed without Sync Master being enabled.
|
||||
NVAPI_INVALID_SYNC_TOPOLOGY = -196, //!< Invalid displays passed in the NV_GSYNC_DISPLAY pointer.
|
||||
NVAPI_SYNC_NOT_ACTIVE = -194, //!< The requested action cannot be performed without Sync being enabled.
|
||||
NVAPI_SYNC_MASTER_NOT_FOUND = -195, //!< The requested action cannot be performed without Sync Master being enabled.
|
||||
NVAPI_INVALID_SYNC_TOPOLOGY = -196, //!< Invalid displays passed in the NV_GSYNC_DISPLAY pointer.
|
||||
NVAPI_ECID_SIGN_ALGO_UNSUPPORTED = -197, //!< The specified signing algorithm is not supported. Either an incorrect value was entered or the current installed driver/hardware does not support the input value.
|
||||
NVAPI_ECID_KEY_VERIFICATION_FAILED = -198, //!< The encrypted public key verification has failed.
|
||||
NVAPI_FIRMWARE_OUT_OF_DATE = -199, //!< The device's firmware is out of date.
|
||||
NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED = -200, //!< The device's firmware is not supported.
|
||||
NVAPI_LICENSE_CALLER_AUTHENTICATION_FAILED = -201, //!< The caller is not authorized to modify the License.
|
||||
NVAPI_D3D_DEVICE_NOT_REGISTERED = -202, //!< The user tried to use a deferred context without registering the device first
|
||||
NVAPI_RESOURCE_NOT_ACQUIRED = -203, //!< Head or SourceId was not reserved for the VR Display before doing the Modeset.
|
||||
NVAPI_TIMING_NOT_SUPPORTED = -204, //!< Provided timing is not supported.
|
||||
NVAPI_HDCP_ENCRYPTION_FAILED = -205, //!< HDCP Encryption Failed for the device. Would be applicable when the device is HDCP Capable.
|
||||
NVAPI_PCLK_LIMITATION_FAILED = -206, //!< Provided mode is over sink device pclk limitation.
|
||||
NVAPI_NO_CONNECTOR_FOUND = -207, //!< No connector on GPU found.
|
||||
NVAPI_ECID_KEY_VERIFICATION_FAILED = -198, //!< The encrypted public key verification has failed.
|
||||
} NvAPI_Status;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -406,23 +352,9 @@ typedef struct
|
||||
|
||||
} NV_DISPLAY_DRIVER_MEMORY_INFO_V2;
|
||||
|
||||
//! \ingroup driverapi
|
||||
//! Used in NvAPI_GPU_GetMemoryInfo().
|
||||
typedef struct
|
||||
{
|
||||
NvU32 version; //!< Version info
|
||||
NvU32 dedicatedVideoMemory; //!< Size(in kb) of the physical framebuffer.
|
||||
NvU32 availableDedicatedVideoMemory; //!< Size(in kb) of the available physical framebuffer for allocating video memory surfaces.
|
||||
NvU32 systemVideoMemory; //!< Size(in kb) of system memory the driver allocates at load time.
|
||||
NvU32 sharedSystemMemory; //!< Size(in kb) of shared system memory that driver is allowed to commit for surfaces across all allocations.
|
||||
NvU32 curAvailableDedicatedVideoMemory; //!< Size(in kb) of the current available physical framebuffer for allocating video memory surfaces.
|
||||
NvU32 dedicatedVideoMemoryEvictionsSize; //!< Size(in kb) of the total size of memory released as a result of the evictions.
|
||||
NvU32 dedicatedVideoMemoryEvictionCount; //!< Indicates the number of eviction events that caused an allocation to be removed from dedicated video memory to free GPU
|
||||
//!< video memory to make room for other allocations.
|
||||
} NV_DISPLAY_DRIVER_MEMORY_INFO_V3;
|
||||
|
||||
//! \ingroup driverapi
|
||||
typedef NV_DISPLAY_DRIVER_MEMORY_INFO_V3 NV_DISPLAY_DRIVER_MEMORY_INFO;
|
||||
typedef NV_DISPLAY_DRIVER_MEMORY_INFO_V2 NV_DISPLAY_DRIVER_MEMORY_INFO;
|
||||
|
||||
//! \ingroup driverapi
|
||||
//! Macro for constructing the version field of NV_DISPLAY_DRIVER_MEMORY_INFO_V1
|
||||
@@ -433,11 +365,7 @@ typedef NV_DISPLAY_DRIVER_MEMORY_INFO_V3 NV_DISPLAY_DRIVER_MEMORY_INFO;
|
||||
#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER_2 MAKE_NVAPI_VERSION(NV_DISPLAY_DRIVER_MEMORY_INFO_V2,2)
|
||||
|
||||
//! \ingroup driverapi
|
||||
//! Macro for constructing the version field of NV_DISPLAY_DRIVER_MEMORY_INFO_V3
|
||||
#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER_3 MAKE_NVAPI_VERSION(NV_DISPLAY_DRIVER_MEMORY_INFO_V3,3)
|
||||
|
||||
//! \ingroup driverapi
|
||||
#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER NV_DISPLAY_DRIVER_MEMORY_INFO_VER_3
|
||||
#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER NV_DISPLAY_DRIVER_MEMORY_INFO_VER_2
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +1,3 @@
|
||||
/************************************************************************************************************************************\
|
||||
|* *|
|
||||
|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *|
|
||||
|* *|
|
||||
|* NOTICE TO USER: *|
|
||||
|* *|
|
||||
|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *|
|
||||
|* *|
|
||||
|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *|
|
||||
|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *|
|
||||
|* Otherwise, you have no rights to use or access this software in any manner. *|
|
||||
|* *|
|
||||
|* If not covered by the applicable NVIDIA software license agreement: *|
|
||||
|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *|
|
||||
|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *|
|
||||
|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *|
|
||||
|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *|
|
||||
|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *|
|
||||
|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *|
|
||||
|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
|
||||
|* *|
|
||||
|* U.S. Government End Users. *|
|
||||
|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
|
||||
|* consisting of "commercial computer software" and "commercial computer software documentation" *|
|
||||
|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *|
|
||||
|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
|
||||
|* all U.S. Government End Users acquire the software with only those rights set forth herein. *|
|
||||
|* *|
|
||||
|* Any use of this software in individual and commercial software must include, *|
|
||||
|* in the user documentation and internal comments to the code, *|
|
||||
|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *|
|
||||
|* *|
|
||||
\************************************************************************************************************************************/
|
||||
#pragma once
|
||||
#include"nvapi_lite_salstart.h"
|
||||
#include"nvapi_lite_common.h"
|
||||
@@ -62,10 +29,6 @@ typedef enum
|
||||
//! argument (D3D_FEATURE_LEVEL supported by the device) that the function fills in. This argument
|
||||
//! can contain -1 (NVAPI_DEVICE_FEATURE_LEVEL_NULL), if the requested featureLevel is less than DirecX 10.0.
|
||||
//!
|
||||
//! NOTE: When NvAPI_D3D11_CreateDevice is called with 10+ feature level we have an issue on few set of
|
||||
//! tesla hardware (G80/G84/G86/G92/G94/G96) which does not support all feature level 10+ functionality
|
||||
//! e.g. calling driver with mismatch between RenderTarget and Depth Buffer. App developers should
|
||||
//! take into consideration such limitation when using NVAPI on such tesla hardwares.
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
|
||||
@@ -1,36 +1,3 @@
|
||||
/************************************************************************************************************************************\
|
||||
|* *|
|
||||
|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *|
|
||||
|* *|
|
||||
|* NOTICE TO USER: *|
|
||||
|* *|
|
||||
|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *|
|
||||
|* *|
|
||||
|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *|
|
||||
|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *|
|
||||
|* Otherwise, you have no rights to use or access this software in any manner. *|
|
||||
|* *|
|
||||
|* If not covered by the applicable NVIDIA software license agreement: *|
|
||||
|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *|
|
||||
|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *|
|
||||
|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *|
|
||||
|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *|
|
||||
|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *|
|
||||
|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *|
|
||||
|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
|
||||
|* *|
|
||||
|* U.S. Government End Users. *|
|
||||
|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
|
||||
|* consisting of "commercial computer software" and "commercial computer software documentation" *|
|
||||
|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *|
|
||||
|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
|
||||
|* all U.S. Government End Users acquire the software with only those rights set forth herein. *|
|
||||
|* *|
|
||||
|* Any use of this software in individual and commercial software must include, *|
|
||||
|* in the user documentation and internal comments to the code, *|
|
||||
|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *|
|
||||
|* *|
|
||||
\************************************************************************************************************************************/
|
||||
#ifndef __NVAPI_EMPTY_SAL
|
||||
#ifdef __nvapi_undef__ecount
|
||||
#undef __ecount
|
||||
|
||||
@@ -1,37 +1,3 @@
|
||||
/************************************************************************************************************************************\
|
||||
|* *|
|
||||
|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *|
|
||||
|* *|
|
||||
|* NOTICE TO USER: *|
|
||||
|* *|
|
||||
|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *|
|
||||
|* *|
|
||||
|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *|
|
||||
|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *|
|
||||
|* Otherwise, you have no rights to use or access this software in any manner. *|
|
||||
|* *|
|
||||
|* If not covered by the applicable NVIDIA software license agreement: *|
|
||||
|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *|
|
||||
|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *|
|
||||
|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *|
|
||||
|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *|
|
||||
|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *|
|
||||
|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *|
|
||||
|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
|
||||
|* *|
|
||||
|* U.S. Government End Users. *|
|
||||
|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
|
||||
|* consisting of "commercial computer software" and "commercial computer software documentation" *|
|
||||
|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *|
|
||||
|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
|
||||
|* all U.S. Government End Users acquire the software with only those rights set forth herein. *|
|
||||
|* *|
|
||||
|* Any use of this software in individual and commercial software must include, *|
|
||||
|* in the user documentation and internal comments to the code, *|
|
||||
|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *|
|
||||
|* *|
|
||||
\************************************************************************************************************************************/
|
||||
|
||||
// ====================================================
|
||||
// SAL related support
|
||||
// ====================================================
|
||||
|
||||
@@ -1,37 +1,3 @@
|
||||
/************************************************************************************************************************************\
|
||||
|* *|
|
||||
|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *|
|
||||
|* *|
|
||||
|* NOTICE TO USER: *|
|
||||
|* *|
|
||||
|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *|
|
||||
|* *|
|
||||
|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *|
|
||||
|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *|
|
||||
|* Otherwise, you have no rights to use or access this software in any manner. *|
|
||||
|* *|
|
||||
|* If not covered by the applicable NVIDIA software license agreement: *|
|
||||
|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *|
|
||||
|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *|
|
||||
|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *|
|
||||
|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *|
|
||||
|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *|
|
||||
|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *|
|
||||
|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
|
||||
|* *|
|
||||
|* U.S. Government End Users. *|
|
||||
|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
|
||||
|* consisting of "commercial computer software" and "commercial computer software documentation" *|
|
||||
|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *|
|
||||
|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
|
||||
|* all U.S. Government End Users acquire the software with only those rights set forth herein. *|
|
||||
|* *|
|
||||
|* Any use of this software in individual and commercial software must include, *|
|
||||
|* in the user documentation and internal comments to the code, *|
|
||||
|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *|
|
||||
|* *|
|
||||
\************************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include"nvapi_lite_salstart.h"
|
||||
#include"nvapi_lite_common.h"
|
||||
@@ -127,7 +93,6 @@ typedef enum _NVAPI_D3D_SETRESOURCEHINT_CATEGORY
|
||||
|
||||
//
|
||||
// NVAPI_D3D_SRH_SLI_APP_CONTROLLED_INTERFRAME_CONTENT_SYNC:
|
||||
// NVAPI_D3D_SRH_SLI_ASK_FOR_BROADCAST_USING:
|
||||
|
||||
|
||||
//! \ingroup dx
|
||||
@@ -136,15 +101,9 @@ typedef enum _NVAPI_D3D_SETRESOURCEHINT_CATEGORY
|
||||
//! Default value: 0 \n
|
||||
//! Explanation: If the value is 1, the driver will not track any rendering operations that would mark this resource as dirty,
|
||||
//! avoiding any form of synchronization across frames rendered in parallel in multiple GPUs in AFR mode.
|
||||
//!
|
||||
//! NVAPI_D3D_SRH_SLI_ASK_FOR_BROADCAST_USAGE: Valid values : 0 or 1 \n
|
||||
//! Default value: 0 \n
|
||||
//! Explanation: If the value is 1, the driver will try to perform operations which involved target resource in broadcast,
|
||||
//! where its possible. Hint is static and must be set before resource starts using.
|
||||
typedef enum _NVAPI_D3D_SETRESOURCEHINT_SLI
|
||||
{
|
||||
NVAPI_D3D_SRH_SLI_APP_CONTROLLED_INTERFRAME_CONTENT_SYNC = 1,
|
||||
NVAPI_D3D_SRH_SLI_ASK_FOR_BROADCAST_USAGE = 2
|
||||
NVAPI_D3D_SRH_SLI_APP_CONTROLLED_INTERFRAME_CONTENT_SYNC = 1
|
||||
} NVAPI_D3D_SETRESOURCEHINT_SLI;
|
||||
|
||||
//! \ingroup dx
|
||||
|
||||
@@ -1,37 +1,3 @@
|
||||
/************************************************************************************************************************************\
|
||||
|* *|
|
||||
|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *|
|
||||
|* *|
|
||||
|* NOTICE TO USER: *|
|
||||
|* *|
|
||||
|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *|
|
||||
|* *|
|
||||
|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *|
|
||||
|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *|
|
||||
|* Otherwise, you have no rights to use or access this software in any manner. *|
|
||||
|* *|
|
||||
|* If not covered by the applicable NVIDIA software license agreement: *|
|
||||
|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *|
|
||||
|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *|
|
||||
|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *|
|
||||
|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *|
|
||||
|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *|
|
||||
|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *|
|
||||
|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
|
||||
|* *|
|
||||
|* U.S. Government End Users. *|
|
||||
|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
|
||||
|* consisting of "commercial computer software" and "commercial computer software documentation" *|
|
||||
|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *|
|
||||
|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
|
||||
|* all U.S. Government End Users acquire the software with only those rights set forth herein. *|
|
||||
|* *|
|
||||
|* Any use of this software in individual and commercial software must include, *|
|
||||
|* in the user documentation and internal comments to the code, *|
|
||||
|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *|
|
||||
|* *|
|
||||
\************************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include"nvapi_lite_salstart.h"
|
||||
#include"nvapi_lite_common.h"
|
||||
|
||||
@@ -1,37 +1,3 @@
|
||||
/************************************************************************************************************************************\
|
||||
|* *|
|
||||
|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *|
|
||||
|* *|
|
||||
|* NOTICE TO USER: *|
|
||||
|* *|
|
||||
|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *|
|
||||
|* *|
|
||||
|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *|
|
||||
|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *|
|
||||
|* Otherwise, you have no rights to use or access this software in any manner. *|
|
||||
|* *|
|
||||
|* If not covered by the applicable NVIDIA software license agreement: *|
|
||||
|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *|
|
||||
|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *|
|
||||
|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *|
|
||||
|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *|
|
||||
|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *|
|
||||
|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *|
|
||||
|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
|
||||
|* *|
|
||||
|* U.S. Government End Users. *|
|
||||
|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
|
||||
|* consisting of "commercial computer software" and "commercial computer software documentation" *|
|
||||
|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *|
|
||||
|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
|
||||
|* all U.S. Government End Users acquire the software with only those rights set forth herein. *|
|
||||
|* *|
|
||||
|* Any use of this software in individual and commercial software must include, *|
|
||||
|* in the user documentation and internal comments to the code, *|
|
||||
|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *|
|
||||
|* *|
|
||||
\************************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include"nvapi_lite_salstart.h"
|
||||
#include"nvapi_lite_common.h"
|
||||
|
||||
Binary file not shown.
@@ -37,10 +37,6 @@
|
||||
#if !defined( PTHREAD_H )
|
||||
#define PTHREAD_H
|
||||
|
||||
#if !defined(HAVE_STRUCT_TIMESPEC) && _MSC_VER >= 1900
|
||||
#define HAVE_STRUCT_TIMESPEC
|
||||
#endif
|
||||
|
||||
/*
|
||||
* See the README file for an explanation of the pthreads-win32 version
|
||||
* numbering scheme and how the DLL is named etc.
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/**
|
||||
* Meant to improve clang 4 / macos compatibility (untested)
|
||||
*/
|
||||
|
||||
#ifndef PTHREAD_BARRIER_H_
|
||||
#define PTHREAD_BARRIER_H_
|
||||
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
typedef int pthread_barrierattr_t;
|
||||
typedef struct
|
||||
{
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
int count;
|
||||
int tripCount;
|
||||
} pthread_barrier_t;
|
||||
|
||||
|
||||
int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count)
|
||||
{
|
||||
if(count == 0)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if(pthread_mutex_init(&barrier->mutex, 0) < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(pthread_cond_init(&barrier->cond, 0) < 0)
|
||||
{
|
||||
pthread_mutex_destroy(&barrier->mutex);
|
||||
return -1;
|
||||
}
|
||||
barrier->tripCount = count;
|
||||
barrier->count = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_barrier_destroy(pthread_barrier_t *barrier)
|
||||
{
|
||||
pthread_cond_destroy(&barrier->cond);
|
||||
pthread_mutex_destroy(&barrier->mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_barrier_wait(pthread_barrier_t *barrier)
|
||||
{
|
||||
pthread_mutex_lock(&barrier->mutex);
|
||||
++(barrier->count);
|
||||
if(barrier->count >= barrier->tripCount)
|
||||
{
|
||||
barrier->count = 0;
|
||||
pthread_cond_broadcast(&barrier->cond);
|
||||
pthread_mutex_unlock(&barrier->mutex);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pthread_cond_wait(&barrier->cond, &(barrier->mutex));
|
||||
pthread_mutex_unlock(&barrier->mutex);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // PTHREAD_BARRIER_H_
|
||||
@@ -1,347 +1,310 @@
|
||||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
|
||||
scriptversion=2012-10-14.11; # UTC
|
||||
|
||||
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
nl='
|
||||
'
|
||||
|
||||
# We need space, tab and new line, in precisely that order. Quoting is
|
||||
# there to prevent tools from complaining about whitespace usage.
|
||||
IFS=" "" $nl"
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file lazy
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts. If the determined conversion
|
||||
# type is listed in (the comma separated) LAZY, no conversion will
|
||||
# take place.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv/,$2, in
|
||||
*,$file_conv,*)
|
||||
;;
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_cl_dashL linkdir
|
||||
# Make cl look for libraries in LINKDIR
|
||||
func_cl_dashL ()
|
||||
{
|
||||
func_file_conv "$1"
|
||||
if test -z "$lib_path"; then
|
||||
lib_path=$file
|
||||
else
|
||||
lib_path="$lib_path;$file"
|
||||
fi
|
||||
linker_opts="$linker_opts -LIBPATH:$file"
|
||||
}
|
||||
|
||||
# func_cl_dashl library
|
||||
# Do a library search-path lookup for cl
|
||||
func_cl_dashl ()
|
||||
{
|
||||
lib=$1
|
||||
found=no
|
||||
save_IFS=$IFS
|
||||
IFS=';'
|
||||
for dir in $lib_path $LIB
|
||||
do
|
||||
IFS=$save_IFS
|
||||
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.dll.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/$lib.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/lib$lib.a"; then
|
||||
found=yes
|
||||
lib=$dir/lib$lib.a
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$save_IFS
|
||||
|
||||
if test "$found" != yes; then
|
||||
lib=$lib.lib
|
||||
fi
|
||||
}
|
||||
|
||||
# func_cl_wrapper cl arg...
|
||||
# Adjust compile command to suit cl
|
||||
func_cl_wrapper ()
|
||||
{
|
||||
# Assume a capable shell
|
||||
lib_path=
|
||||
shared=:
|
||||
linker_opts=
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.[oO][bB][jJ])
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fo"$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fe"$file"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
-I)
|
||||
eat=1
|
||||
func_file_conv "$2" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-I*)
|
||||
func_file_conv "${1#-I}" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-l)
|
||||
eat=1
|
||||
func_cl_dashl "$2"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-l*)
|
||||
func_cl_dashl "${1#-l}"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-L)
|
||||
eat=1
|
||||
func_cl_dashL "$2"
|
||||
;;
|
||||
-L*)
|
||||
func_cl_dashL "${1#-L}"
|
||||
;;
|
||||
-static)
|
||||
shared=false
|
||||
;;
|
||||
-Wl,*)
|
||||
arg=${1#-Wl,}
|
||||
save_ifs="$IFS"; IFS=','
|
||||
for flag in $arg; do
|
||||
IFS="$save_ifs"
|
||||
linker_opts="$linker_opts $flag"
|
||||
done
|
||||
IFS="$save_ifs"
|
||||
;;
|
||||
-Xlinker)
|
||||
eat=1
|
||||
linker_opts="$linker_opts $2"
|
||||
;;
|
||||
-*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||
func_file_conv "$1"
|
||||
set x "$@" -Tp"$file"
|
||||
shift
|
||||
;;
|
||||
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||
func_file_conv "$1" mingw
|
||||
set x "$@" "$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
if test -n "$linker_opts"; then
|
||||
linker_opts="-link$linker_opts"
|
||||
fi
|
||||
exec "$@" $linker_opts
|
||||
exit 1
|
||||
}
|
||||
|
||||
eat=
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Wrapper for compilers which do not understand '-c -o'.
|
||||
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
arguments, and rename the output as expected.
|
||||
|
||||
If you are trying to build a whole package this is not the
|
||||
right script to run: please start by reading the file 'INSTALL'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
|
||||
func_cl_wrapper "$@" # Doesn't return...
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
# So we strip '-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
ofile=$2
|
||||
;;
|
||||
*)
|
||||
set x "$@" -o "$2"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no '-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# '.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$@"
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
|
||||
scriptversion=2012-01-04.17; # UTC
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free
|
||||
# Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
nl='
|
||||
'
|
||||
|
||||
# We need space, tab and new line, in precisely that order. Quoting is
|
||||
# there to prevent tools from complaining about whitespace usage.
|
||||
IFS=" "" $nl"
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file lazy
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts. If the determined conversion
|
||||
# type is listed in (the comma separated) LAZY, no conversion will
|
||||
# take place.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv/,$2, in
|
||||
*,$file_conv,*)
|
||||
;;
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_cl_wrapper cl arg...
|
||||
# Adjust compile command to suit cl
|
||||
func_cl_wrapper ()
|
||||
{
|
||||
# Assume a capable shell
|
||||
lib_path=
|
||||
shared=:
|
||||
linker_opts=
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.[oO][bB][jJ])
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fo"$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fe"$file"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
-I*)
|
||||
func_file_conv "${1#-I}" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-l*)
|
||||
lib=${1#-l}
|
||||
found=no
|
||||
save_IFS=$IFS
|
||||
IFS=';'
|
||||
for dir in $lib_path $LIB
|
||||
do
|
||||
IFS=$save_IFS
|
||||
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||
found=yes
|
||||
set x "$@" "$dir/$lib.dll.lib"
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/$lib.lib"; then
|
||||
found=yes
|
||||
set x "$@" "$dir/$lib.lib"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$save_IFS
|
||||
|
||||
test "$found" != yes && set x "$@" "$lib.lib"
|
||||
shift
|
||||
;;
|
||||
-L*)
|
||||
func_file_conv "${1#-L}"
|
||||
if test -z "$lib_path"; then
|
||||
lib_path=$file
|
||||
else
|
||||
lib_path="$lib_path;$file"
|
||||
fi
|
||||
linker_opts="$linker_opts -LIBPATH:$file"
|
||||
;;
|
||||
-static)
|
||||
shared=false
|
||||
;;
|
||||
-Wl,*)
|
||||
arg=${1#-Wl,}
|
||||
save_ifs="$IFS"; IFS=','
|
||||
for flag in $arg; do
|
||||
IFS="$save_ifs"
|
||||
linker_opts="$linker_opts $flag"
|
||||
done
|
||||
IFS="$save_ifs"
|
||||
;;
|
||||
-Xlinker)
|
||||
eat=1
|
||||
linker_opts="$linker_opts $2"
|
||||
;;
|
||||
-*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||
func_file_conv "$1"
|
||||
set x "$@" -Tp"$file"
|
||||
shift
|
||||
;;
|
||||
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||
func_file_conv "$1" mingw
|
||||
set x "$@" "$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
if test -n "$linker_opts"; then
|
||||
linker_opts="-link$linker_opts"
|
||||
fi
|
||||
exec "$@" $linker_opts
|
||||
exit 1
|
||||
}
|
||||
|
||||
eat=
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Wrapper for compilers which do not understand '-c -o'.
|
||||
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
arguments, and rename the output as expected.
|
||||
|
||||
If you are trying to build a whole package this is not the
|
||||
right script to run: please start by reading the file 'INSTALL'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
|
||||
func_cl_wrapper "$@" # Doesn't return...
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
# So we strip '-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
ofile=$2
|
||||
;;
|
||||
*)
|
||||
set x "$@" -o "$2"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no '-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# '.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$@"
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
+301
-333
@@ -1,12 +1,14 @@
|
||||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright 1992-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
||||
# Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2013-06-10'
|
||||
timestamp='2008-01-23'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
@@ -15,23 +17,27 @@ timestamp='2013-06-10'
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that
|
||||
# program. This Exception is an additional permission under section 7
|
||||
# of the GNU General Public License, version 3 ("GPLv3").
|
||||
#
|
||||
# Originally written by Per Bothner.
|
||||
#
|
||||
# You can get the latest version of this script from:
|
||||
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
|
||||
#
|
||||
# Please send patches with a ChangeLog entry to config-patches@gnu.org.
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
|
||||
# Originally written by Per Bothner <per@bothner.com>.
|
||||
# Please send patches to <config-patches@gnu.org>. Submit a context
|
||||
# diff and a properly formatted ChangeLog entry.
|
||||
#
|
||||
# This script attempts to guess a canonical system name similar to
|
||||
# config.sub. If it succeeds, it prints the system name on stdout, and
|
||||
# exits with 0. Otherwise, it exits with 1.
|
||||
#
|
||||
# The plan is that this can be called by configure scripts if you
|
||||
# don't specify an explicit build system type.
|
||||
|
||||
me=`echo "$0" | sed -e 's,.*/,,'`
|
||||
|
||||
usage="\
|
||||
@@ -50,7 +56,8 @@ version="\
|
||||
GNU config.guess ($timestamp)
|
||||
|
||||
Originally written by Per Bothner.
|
||||
Copyright 1992-2013 Free Software Foundation, Inc.
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
|
||||
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
@@ -132,33 +139,12 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
|
||||
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
|
||||
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
|
||||
|
||||
case "${UNAME_SYSTEM}" in
|
||||
Linux|GNU|GNU/*)
|
||||
# If the system lacks a compiler, then just pick glibc.
|
||||
# We could probably try harder.
|
||||
LIBC=gnu
|
||||
|
||||
eval $set_cc_for_build
|
||||
cat <<-EOF > $dummy.c
|
||||
#include <features.h>
|
||||
#if defined(__UCLIBC__)
|
||||
LIBC=uclibc
|
||||
#elif defined(__dietlibc__)
|
||||
LIBC=dietlibc
|
||||
#else
|
||||
LIBC=gnu
|
||||
#endif
|
||||
EOF
|
||||
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
|
||||
;;
|
||||
esac
|
||||
|
||||
# Note: order is significant - the case branches are not exclusive.
|
||||
|
||||
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
*:NetBSD:*:*)
|
||||
# NetBSD (nbsd) targets should (where applicable) match one or
|
||||
# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
|
||||
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
|
||||
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
|
||||
# switched to ELF, *-*-netbsd* would select the old
|
||||
# object file format. This provides both forward
|
||||
@@ -184,7 +170,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
|
||||
eval $set_cc_for_build
|
||||
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
|
||||
| grep -q __ELF__
|
||||
| grep __ELF__ >/dev/null
|
||||
then
|
||||
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
|
||||
# Return netbsd for either. FIX?
|
||||
@@ -194,7 +180,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
os=netbsd
|
||||
os=netbsd
|
||||
;;
|
||||
esac
|
||||
# The OS release
|
||||
@@ -215,10 +201,6 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
|
||||
echo "${machine}-${os}${release}"
|
||||
exit ;;
|
||||
*:Bitrig:*:*)
|
||||
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
|
||||
echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
|
||||
exit ;;
|
||||
*:OpenBSD:*:*)
|
||||
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
|
||||
echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
|
||||
@@ -241,7 +223,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
|
||||
;;
|
||||
*5.*)
|
||||
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
|
||||
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
|
||||
;;
|
||||
esac
|
||||
# According to Compaq, /usr/sbin/psrinfo has been available on
|
||||
@@ -287,10 +269,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
# A Xn.n version is an unreleased experimental baselevel.
|
||||
# 1.2 uses "1.2" for uname -r.
|
||||
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
|
||||
# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
|
||||
exitcode=$?
|
||||
trap '' 0
|
||||
exit $exitcode ;;
|
||||
exit ;;
|
||||
Alpha\ *:Windows_NT*:*)
|
||||
# How do we know it's Interix rather than the generic POSIX subsystem?
|
||||
# Should we change UNAME_MACHINE based on the output of uname instead
|
||||
@@ -316,12 +295,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
echo s390-ibm-zvmoe
|
||||
exit ;;
|
||||
*:OS400:*:*)
|
||||
echo powerpc-ibm-os400
|
||||
echo powerpc-ibm-os400
|
||||
exit ;;
|
||||
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
|
||||
echo arm-acorn-riscix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
arm*:riscos:*:*|arm*:RISCOS:*:*)
|
||||
arm:riscos:*:*|arm:RISCOS:*:*)
|
||||
echo arm-unknown-riscos
|
||||
exit ;;
|
||||
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
|
||||
@@ -345,33 +324,14 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
case `/usr/bin/uname -p` in
|
||||
sparc) echo sparc-icl-nx7; exit ;;
|
||||
esac ;;
|
||||
s390x:SunOS:*:*)
|
||||
echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit ;;
|
||||
sun4H:SunOS:5.*:*)
|
||||
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit ;;
|
||||
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
|
||||
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit ;;
|
||||
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
|
||||
echo i386-pc-auroraux${UNAME_RELEASE}
|
||||
exit ;;
|
||||
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
|
||||
eval $set_cc_for_build
|
||||
SUN_ARCH="i386"
|
||||
# If there is a compiler, see if it is configured for 64-bit objects.
|
||||
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
|
||||
# This test works for both compilers.
|
||||
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
|
||||
if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
|
||||
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
|
||||
grep IS_64BIT_ARCH >/dev/null
|
||||
then
|
||||
SUN_ARCH="x86_64"
|
||||
fi
|
||||
fi
|
||||
echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit ;;
|
||||
sun4*:SunOS:6*:*)
|
||||
# According to config.sub, this is the proper way to canonicalize
|
||||
@@ -415,23 +375,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
# MiNT. But MiNT is downward compatible to TOS, so this should
|
||||
# be no problem.
|
||||
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
|
||||
echo m68k-atari-mint${UNAME_RELEASE}
|
||||
echo m68k-atari-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
|
||||
echo m68k-atari-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
exit ;;
|
||||
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
|
||||
echo m68k-atari-mint${UNAME_RELEASE}
|
||||
echo m68k-atari-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
|
||||
echo m68k-milan-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
echo m68k-milan-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
|
||||
echo m68k-hades-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
echo m68k-hades-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
|
||||
echo m68k-unknown-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
echo m68k-unknown-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
m68k:machten:*:*)
|
||||
echo m68k-apple-machten${UNAME_RELEASE}
|
||||
exit ;;
|
||||
@@ -501,8 +461,8 @@ EOF
|
||||
echo m88k-motorola-sysv3
|
||||
exit ;;
|
||||
AViiON:dgux:*:*)
|
||||
# DG/UX returns AViiON for all architectures
|
||||
UNAME_PROCESSOR=`/usr/bin/uname -p`
|
||||
# DG/UX returns AViiON for all architectures
|
||||
UNAME_PROCESSOR=`/usr/bin/uname -p`
|
||||
if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
|
||||
then
|
||||
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
|
||||
@@ -515,7 +475,7 @@ EOF
|
||||
else
|
||||
echo i586-dg-dgux${UNAME_RELEASE}
|
||||
fi
|
||||
exit ;;
|
||||
exit ;;
|
||||
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
|
||||
echo m88k-dolphin-sysv3
|
||||
exit ;;
|
||||
@@ -572,7 +532,7 @@ EOF
|
||||
echo rs6000-ibm-aix3.2
|
||||
fi
|
||||
exit ;;
|
||||
*:AIX:*:[4567])
|
||||
*:AIX:*:[456])
|
||||
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
|
||||
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
|
||||
IBM_ARCH=rs6000
|
||||
@@ -615,52 +575,52 @@ EOF
|
||||
9000/[678][0-9][0-9])
|
||||
if [ -x /usr/bin/getconf ]; then
|
||||
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
|
||||
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
|
||||
case "${sc_cpu_version}" in
|
||||
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
|
||||
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
|
||||
532) # CPU_PA_RISC2_0
|
||||
case "${sc_kernel_bits}" in
|
||||
32) HP_ARCH="hppa2.0n" ;;
|
||||
64) HP_ARCH="hppa2.0w" ;;
|
||||
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
|
||||
case "${sc_cpu_version}" in
|
||||
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
|
||||
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
|
||||
532) # CPU_PA_RISC2_0
|
||||
case "${sc_kernel_bits}" in
|
||||
32) HP_ARCH="hppa2.0n" ;;
|
||||
64) HP_ARCH="hppa2.0w" ;;
|
||||
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
|
||||
esac ;;
|
||||
esac
|
||||
esac ;;
|
||||
esac
|
||||
fi
|
||||
if [ "${HP_ARCH}" = "" ]; then
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
|
||||
#define _HPUX_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#define _HPUX_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
#if defined(_SC_KERNEL_BITS)
|
||||
long bits = sysconf(_SC_KERNEL_BITS);
|
||||
#endif
|
||||
long cpu = sysconf (_SC_CPU_VERSION);
|
||||
int main ()
|
||||
{
|
||||
#if defined(_SC_KERNEL_BITS)
|
||||
long bits = sysconf(_SC_KERNEL_BITS);
|
||||
#endif
|
||||
long cpu = sysconf (_SC_CPU_VERSION);
|
||||
|
||||
switch (cpu)
|
||||
{
|
||||
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
|
||||
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
|
||||
case CPU_PA_RISC2_0:
|
||||
#if defined(_SC_KERNEL_BITS)
|
||||
switch (bits)
|
||||
{
|
||||
case 64: puts ("hppa2.0w"); break;
|
||||
case 32: puts ("hppa2.0n"); break;
|
||||
default: puts ("hppa2.0"); break;
|
||||
} break;
|
||||
#else /* !defined(_SC_KERNEL_BITS) */
|
||||
puts ("hppa2.0"); break;
|
||||
#endif
|
||||
default: puts ("hppa1.0"); break;
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
switch (cpu)
|
||||
{
|
||||
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
|
||||
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
|
||||
case CPU_PA_RISC2_0:
|
||||
#if defined(_SC_KERNEL_BITS)
|
||||
switch (bits)
|
||||
{
|
||||
case 64: puts ("hppa2.0w"); break;
|
||||
case 32: puts ("hppa2.0n"); break;
|
||||
default: puts ("hppa2.0"); break;
|
||||
} break;
|
||||
#else /* !defined(_SC_KERNEL_BITS) */
|
||||
puts ("hppa2.0"); break;
|
||||
#endif
|
||||
default: puts ("hppa1.0"); break;
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
EOF
|
||||
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
|
||||
test -z "$HP_ARCH" && HP_ARCH=hppa
|
||||
@@ -680,7 +640,7 @@ EOF
|
||||
# => hppa64-hp-hpux11.23
|
||||
|
||||
if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
|
||||
grep -q __LP64__
|
||||
grep __LP64__ >/dev/null
|
||||
then
|
||||
HP_ARCH="hppa2.0w"
|
||||
else
|
||||
@@ -751,22 +711,22 @@ EOF
|
||||
exit ;;
|
||||
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
|
||||
echo c1-convex-bsd
|
||||
exit ;;
|
||||
exit ;;
|
||||
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
|
||||
if getsysinfo -f scalar_acc
|
||||
then echo c32-convex-bsd
|
||||
else echo c2-convex-bsd
|
||||
fi
|
||||
exit ;;
|
||||
exit ;;
|
||||
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
|
||||
echo c34-convex-bsd
|
||||
exit ;;
|
||||
exit ;;
|
||||
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
|
||||
echo c38-convex-bsd
|
||||
exit ;;
|
||||
exit ;;
|
||||
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
|
||||
echo c4-convex-bsd
|
||||
exit ;;
|
||||
exit ;;
|
||||
CRAY*Y-MP:*:*:*)
|
||||
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
|
||||
exit ;;
|
||||
@@ -790,14 +750,14 @@ EOF
|
||||
exit ;;
|
||||
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
|
||||
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
|
||||
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
|
||||
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit ;;
|
||||
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
|
||||
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit ;;
|
||||
5000:UNIX_System_V:4.*:*)
|
||||
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
|
||||
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
|
||||
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit ;;
|
||||
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
|
||||
@@ -809,39 +769,34 @@ EOF
|
||||
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
|
||||
exit ;;
|
||||
*:FreeBSD:*:*)
|
||||
UNAME_PROCESSOR=`/usr/bin/uname -p`
|
||||
case ${UNAME_PROCESSOR} in
|
||||
case ${UNAME_MACHINE} in
|
||||
pc98)
|
||||
echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
|
||||
amd64)
|
||||
echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
|
||||
*)
|
||||
echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
|
||||
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
|
||||
esac
|
||||
exit ;;
|
||||
i*:CYGWIN*:*)
|
||||
echo ${UNAME_MACHINE}-pc-cygwin
|
||||
exit ;;
|
||||
*:MINGW64*:*)
|
||||
echo ${UNAME_MACHINE}-pc-mingw64
|
||||
exit ;;
|
||||
*:MINGW*:*)
|
||||
echo ${UNAME_MACHINE}-pc-mingw32
|
||||
exit ;;
|
||||
i*:MSYS*:*)
|
||||
echo ${UNAME_MACHINE}-pc-msys
|
||||
exit ;;
|
||||
i*:windows32*:*)
|
||||
# uname -m includes "-pc" on this system.
|
||||
echo ${UNAME_MACHINE}-mingw32
|
||||
# uname -m includes "-pc" on this system.
|
||||
echo ${UNAME_MACHINE}-mingw32
|
||||
exit ;;
|
||||
i*:PW*:*)
|
||||
echo ${UNAME_MACHINE}-pc-pw32
|
||||
exit ;;
|
||||
*:Interix*:*)
|
||||
case ${UNAME_MACHINE} in
|
||||
*:Interix*:[3456]*)
|
||||
case ${UNAME_MACHINE} in
|
||||
x86)
|
||||
echo i586-pc-interix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
authenticamd | genuineintel | EM64T)
|
||||
EM64T | authenticamd)
|
||||
echo x86_64-unknown-interix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
IA64)
|
||||
@@ -851,9 +806,6 @@ EOF
|
||||
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
|
||||
echo i${UNAME_MACHINE}-pc-mks
|
||||
exit ;;
|
||||
8664:Windows_NT:*)
|
||||
echo x86_64-pc-mks
|
||||
exit ;;
|
||||
i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
|
||||
# How do we know it's Interix rather than the generic POSIX subsystem?
|
||||
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
|
||||
@@ -874,21 +826,100 @@ EOF
|
||||
exit ;;
|
||||
*:GNU:*:*)
|
||||
# the GNU system
|
||||
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
|
||||
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
|
||||
exit ;;
|
||||
*:GNU/*:*:*)
|
||||
# other systems with GNU libc and userland
|
||||
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
|
||||
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
|
||||
exit ;;
|
||||
i*86:Minix:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-minix
|
||||
exit ;;
|
||||
aarch64:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
arm*:Linux:*:*)
|
||||
eval $set_cc_for_build
|
||||
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
|
||||
| grep -q __ARM_EABI__
|
||||
then
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
else
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
|
||||
fi
|
||||
exit ;;
|
||||
aarch64_be:Linux:*:*)
|
||||
UNAME_MACHINE=aarch64_be
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
avr32*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
cris:Linux:*:*)
|
||||
echo cris-axis-linux-gnu
|
||||
exit ;;
|
||||
crisv32:Linux:*:*)
|
||||
echo crisv32-axis-linux-gnu
|
||||
exit ;;
|
||||
frv:Linux:*:*)
|
||||
echo frv-unknown-linux-gnu
|
||||
exit ;;
|
||||
ia64:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
m32r*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
m68*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
mips:Linux:*:*)
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
#undef CPU
|
||||
#undef mips
|
||||
#undef mipsel
|
||||
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
|
||||
CPU=mipsel
|
||||
#else
|
||||
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
|
||||
CPU=mips
|
||||
#else
|
||||
CPU=
|
||||
#endif
|
||||
#endif
|
||||
EOF
|
||||
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
|
||||
/^CPU/{
|
||||
s: ::g
|
||||
p
|
||||
}'`"
|
||||
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
|
||||
;;
|
||||
mips64:Linux:*:*)
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
#undef CPU
|
||||
#undef mips64
|
||||
#undef mips64el
|
||||
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
|
||||
CPU=mips64el
|
||||
#else
|
||||
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
|
||||
CPU=mips64
|
||||
#else
|
||||
CPU=
|
||||
#endif
|
||||
#endif
|
||||
EOF
|
||||
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
|
||||
/^CPU/{
|
||||
s: ::g
|
||||
p
|
||||
}'`"
|
||||
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
|
||||
;;
|
||||
or32:Linux:*:*)
|
||||
echo or32-unknown-linux-gnu
|
||||
exit ;;
|
||||
ppc:Linux:*:*)
|
||||
echo powerpc-unknown-linux-gnu
|
||||
exit ;;
|
||||
ppc64:Linux:*:*)
|
||||
echo powerpc64-unknown-linux-gnu
|
||||
exit ;;
|
||||
alpha:Linux:*:*)
|
||||
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
|
||||
@@ -899,132 +930,106 @@ EOF
|
||||
EV6) UNAME_MACHINE=alphaev6 ;;
|
||||
EV67) UNAME_MACHINE=alphaev67 ;;
|
||||
EV68*) UNAME_MACHINE=alphaev68 ;;
|
||||
esac
|
||||
objdump --private-headers /bin/sh | grep -q ld.so.1
|
||||
if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
exit ;;
|
||||
arc:Linux:*:* | arceb:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
exit ;;
|
||||
arm*:Linux:*:*)
|
||||
eval $set_cc_for_build
|
||||
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
|
||||
| grep -q __ARM_EABI__
|
||||
then
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
else
|
||||
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
|
||||
| grep -q __ARM_PCS_VFP
|
||||
then
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
|
||||
else
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
|
||||
fi
|
||||
fi
|
||||
exit ;;
|
||||
avr32*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
exit ;;
|
||||
cris:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-axis-linux-${LIBC}
|
||||
exit ;;
|
||||
crisv32:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-axis-linux-${LIBC}
|
||||
exit ;;
|
||||
frv:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
exit ;;
|
||||
hexagon:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
exit ;;
|
||||
i*86:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-linux-${LIBC}
|
||||
exit ;;
|
||||
ia64:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
exit ;;
|
||||
m32r*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
exit ;;
|
||||
m68*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
exit ;;
|
||||
mips:Linux:*:* | mips64:Linux:*:*)
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
#undef CPU
|
||||
#undef ${UNAME_MACHINE}
|
||||
#undef ${UNAME_MACHINE}el
|
||||
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
|
||||
CPU=${UNAME_MACHINE}el
|
||||
#else
|
||||
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
|
||||
CPU=${UNAME_MACHINE}
|
||||
#else
|
||||
CPU=
|
||||
#endif
|
||||
#endif
|
||||
EOF
|
||||
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
|
||||
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
|
||||
;;
|
||||
or1k:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
exit ;;
|
||||
or32:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
exit ;;
|
||||
padre:Linux:*:*)
|
||||
echo sparc-unknown-linux-${LIBC}
|
||||
exit ;;
|
||||
parisc64:Linux:*:* | hppa64:Linux:*:*)
|
||||
echo hppa64-unknown-linux-${LIBC}
|
||||
esac
|
||||
objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
|
||||
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
|
||||
exit ;;
|
||||
parisc:Linux:*:* | hppa:Linux:*:*)
|
||||
# Look for CPU level
|
||||
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
|
||||
PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
|
||||
PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
|
||||
*) echo hppa-unknown-linux-${LIBC} ;;
|
||||
PA7*) echo hppa1.1-unknown-linux-gnu ;;
|
||||
PA8*) echo hppa2.0-unknown-linux-gnu ;;
|
||||
*) echo hppa-unknown-linux-gnu ;;
|
||||
esac
|
||||
exit ;;
|
||||
ppc64:Linux:*:*)
|
||||
echo powerpc64-unknown-linux-${LIBC}
|
||||
exit ;;
|
||||
ppc:Linux:*:*)
|
||||
echo powerpc-unknown-linux-${LIBC}
|
||||
exit ;;
|
||||
ppc64le:Linux:*:*)
|
||||
echo powerpc64le-unknown-linux-${LIBC}
|
||||
exit ;;
|
||||
ppcle:Linux:*:*)
|
||||
echo powerpcle-unknown-linux-${LIBC}
|
||||
parisc64:Linux:*:* | hppa64:Linux:*:*)
|
||||
echo hppa64-unknown-linux-gnu
|
||||
exit ;;
|
||||
s390:Linux:*:* | s390x:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
|
||||
echo ${UNAME_MACHINE}-ibm-linux
|
||||
exit ;;
|
||||
sh64*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
sh*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
sparc:Linux:*:* | sparc64:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
exit ;;
|
||||
tile*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
vax:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-dec-linux-${LIBC}
|
||||
echo ${UNAME_MACHINE}-dec-linux-gnu
|
||||
exit ;;
|
||||
x86_64:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
echo x86_64-unknown-linux-gnu
|
||||
exit ;;
|
||||
xtensa*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
i*86:Linux:*:*)
|
||||
# The BFD linker knows what the default object file format is, so
|
||||
# first see if it will tell us. cd to the root directory to prevent
|
||||
# problems with other programs or directories called `ld' in the path.
|
||||
# Set LC_ALL=C to ensure ld outputs messages in English.
|
||||
ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
|
||||
| sed -ne '/supported targets:/!d
|
||||
s/[ ][ ]*/ /g
|
||||
s/.*supported targets: *//
|
||||
s/ .*//
|
||||
p'`
|
||||
case "$ld_supported_targets" in
|
||||
elf32-i386)
|
||||
TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
|
||||
;;
|
||||
a.out-i386-linux)
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
|
||||
exit ;;
|
||||
coff-i386)
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
|
||||
exit ;;
|
||||
"")
|
||||
# Either a pre-BFD a.out linker (linux-gnuoldld) or
|
||||
# one that does not give us useful --help.
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
|
||||
exit ;;
|
||||
esac
|
||||
# Determine whether the default compiler is a.out or elf
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
#include <features.h>
|
||||
#ifdef __ELF__
|
||||
# ifdef __GLIBC__
|
||||
# if __GLIBC__ >= 2
|
||||
LIBC=gnu
|
||||
# else
|
||||
LIBC=gnulibc1
|
||||
# endif
|
||||
# else
|
||||
LIBC=gnulibc1
|
||||
# endif
|
||||
#else
|
||||
#if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
|
||||
LIBC=gnu
|
||||
#else
|
||||
LIBC=gnuaout
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __dietlibc__
|
||||
LIBC=dietlibc
|
||||
#endif
|
||||
EOF
|
||||
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
|
||||
/^LIBC/{
|
||||
s: ::g
|
||||
p
|
||||
}'`"
|
||||
test x"${LIBC}" != x && {
|
||||
echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
|
||||
exit
|
||||
}
|
||||
test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
|
||||
;;
|
||||
i*86:DYNIX/ptx:4*:*)
|
||||
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
|
||||
# earlier versions are messed up and put the nodename in both
|
||||
@@ -1032,11 +1037,11 @@ EOF
|
||||
echo i386-sequent-sysv4
|
||||
exit ;;
|
||||
i*86:UNIX_SV:4.2MP:2.*)
|
||||
# Unixware is an offshoot of SVR4, but it has its own version
|
||||
# number series starting with 2...
|
||||
# I am not positive that other SVR4 systems won't match this,
|
||||
# Unixware is an offshoot of SVR4, but it has its own version
|
||||
# number series starting with 2...
|
||||
# I am not positive that other SVR4 systems won't match this,
|
||||
# I just have to hope. -- rms.
|
||||
# Use sysv4.2uw... so that sysv4* matches it.
|
||||
# Use sysv4.2uw... so that sysv4* matches it.
|
||||
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
|
||||
exit ;;
|
||||
i*86:OS/2:*:*)
|
||||
@@ -1053,7 +1058,7 @@ EOF
|
||||
i*86:syllable:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-syllable
|
||||
exit ;;
|
||||
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
|
||||
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
|
||||
echo i386-unknown-lynxos${UNAME_RELEASE}
|
||||
exit ;;
|
||||
i*86:*DOS:*:*)
|
||||
@@ -1068,7 +1073,7 @@ EOF
|
||||
fi
|
||||
exit ;;
|
||||
i*86:*:5:[678]*)
|
||||
# UnixWare 7.x, OpenUNIX and OpenServer 6.
|
||||
# UnixWare 7.x, OpenUNIX and OpenServer 6.
|
||||
case `/bin/uname -X | grep "^Machine"` in
|
||||
*486*) UNAME_MACHINE=i486 ;;
|
||||
*Pentium) UNAME_MACHINE=i586 ;;
|
||||
@@ -1096,13 +1101,10 @@ EOF
|
||||
exit ;;
|
||||
pc:*:*:*)
|
||||
# Left here for compatibility:
|
||||
# uname -m prints for DJGPP always 'pc', but it prints nothing about
|
||||
# the processor, so we play safe by assuming i586.
|
||||
# Note: whatever this is, it MUST be the same as what config.sub
|
||||
# prints for the "djgpp" host, or else GDB configury will decide that
|
||||
# this is a cross-build.
|
||||
echo i586-pc-msdosdjgpp
|
||||
exit ;;
|
||||
# uname -m prints for DJGPP always 'pc', but it prints nothing about
|
||||
# the processor, so we play safe by assuming i386.
|
||||
echo i386-pc-msdosdjgpp
|
||||
exit ;;
|
||||
Intel:Mach:3*:*)
|
||||
echo i386-pc-mach3
|
||||
exit ;;
|
||||
@@ -1137,18 +1139,8 @@ EOF
|
||||
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
|
||||
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
|
||||
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& { echo i486-ncr-sysv4; exit; } ;;
|
||||
NCR*:*:4.2:* | MPRAS*:*:4.2:*)
|
||||
OS_REL='.3'
|
||||
test -r /etc/.relid \
|
||||
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& { echo i486-ncr-sysv4.3${OS_REL}; exit; }
|
||||
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
|
||||
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; }
|
||||
/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
|
||||
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& { echo i486-ncr-sysv4; exit; } ;;
|
||||
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
|
||||
echo m68k-unknown-lynxos${UNAME_RELEASE}
|
||||
exit ;;
|
||||
@@ -1161,7 +1153,7 @@ EOF
|
||||
rs6000:LynxOS:2.*:*)
|
||||
echo rs6000-unknown-lynxos${UNAME_RELEASE}
|
||||
exit ;;
|
||||
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
|
||||
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
|
||||
echo powerpc-unknown-lynxos${UNAME_RELEASE}
|
||||
exit ;;
|
||||
SM[BE]S:UNIX_SV:*:*)
|
||||
@@ -1181,10 +1173,10 @@ EOF
|
||||
echo ns32k-sni-sysv
|
||||
fi
|
||||
exit ;;
|
||||
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
|
||||
# says <Richard.M.Bartel@ccMail.Census.GOV>
|
||||
echo i586-unisys-sysv4
|
||||
exit ;;
|
||||
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
|
||||
# says <Richard.M.Bartel@ccMail.Census.GOV>
|
||||
echo i586-unisys-sysv4
|
||||
exit ;;
|
||||
*:UNIX_System_V:4*:FTX*)
|
||||
# From Gerald Hewes <hewes@openmarket.com>.
|
||||
# How about differentiating between stratus architectures? -djm
|
||||
@@ -1210,11 +1202,11 @@ EOF
|
||||
exit ;;
|
||||
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
|
||||
if [ -d /usr/nec ]; then
|
||||
echo mips-nec-sysv${UNAME_RELEASE}
|
||||
echo mips-nec-sysv${UNAME_RELEASE}
|
||||
else
|
||||
echo mips-unknown-sysv${UNAME_RELEASE}
|
||||
echo mips-unknown-sysv${UNAME_RELEASE}
|
||||
fi
|
||||
exit ;;
|
||||
exit ;;
|
||||
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
|
||||
echo powerpc-be-beos
|
||||
exit ;;
|
||||
@@ -1224,12 +1216,6 @@ EOF
|
||||
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
|
||||
echo i586-pc-beos
|
||||
exit ;;
|
||||
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
|
||||
echo i586-pc-haiku
|
||||
exit ;;
|
||||
x86_64:Haiku:*:*)
|
||||
echo x86_64-unknown-haiku
|
||||
exit ;;
|
||||
SX-4:SUPER-UX:*:*)
|
||||
echo sx4-nec-superux${UNAME_RELEASE}
|
||||
exit ;;
|
||||
@@ -1256,21 +1242,9 @@ EOF
|
||||
exit ;;
|
||||
*:Darwin:*:*)
|
||||
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
|
||||
eval $set_cc_for_build
|
||||
if test "$UNAME_PROCESSOR" = unknown ; then
|
||||
UNAME_PROCESSOR=powerpc
|
||||
fi
|
||||
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
|
||||
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
|
||||
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
|
||||
grep IS_64BIT_ARCH >/dev/null
|
||||
then
|
||||
case $UNAME_PROCESSOR in
|
||||
i386) UNAME_PROCESSOR=x86_64 ;;
|
||||
powerpc) UNAME_PROCESSOR=powerpc64 ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
case $UNAME_PROCESSOR in
|
||||
unknown) UNAME_PROCESSOR=powerpc ;;
|
||||
esac
|
||||
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
|
||||
exit ;;
|
||||
*:procnto*:*:* | *:QNX:[0123456789]*:*)
|
||||
@@ -1284,10 +1258,7 @@ EOF
|
||||
*:QNX:*:4*)
|
||||
echo i386-pc-qnx
|
||||
exit ;;
|
||||
NEO-?:NONSTOP_KERNEL:*:*)
|
||||
echo neo-tandem-nsk${UNAME_RELEASE}
|
||||
exit ;;
|
||||
NSE-*:NONSTOP_KERNEL:*:*)
|
||||
NSE-?:NONSTOP_KERNEL:*:*)
|
||||
echo nse-tandem-nsk${UNAME_RELEASE}
|
||||
exit ;;
|
||||
NSR-?:NONSTOP_KERNEL:*:*)
|
||||
@@ -1332,13 +1303,13 @@ EOF
|
||||
echo pdp10-unknown-its
|
||||
exit ;;
|
||||
SEI:*:*:SEIUX)
|
||||
echo mips-sei-seiux${UNAME_RELEASE}
|
||||
echo mips-sei-seiux${UNAME_RELEASE}
|
||||
exit ;;
|
||||
*:DragonFly:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
|
||||
exit ;;
|
||||
*:*VMS:*:*)
|
||||
UNAME_MACHINE=`(uname -p) 2>/dev/null`
|
||||
UNAME_MACHINE=`(uname -p) 2>/dev/null`
|
||||
case "${UNAME_MACHINE}" in
|
||||
A*) echo alpha-dec-vms ; exit ;;
|
||||
I*) echo ia64-dec-vms ; exit ;;
|
||||
@@ -1353,14 +1324,11 @@ EOF
|
||||
i*86:rdos:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-rdos
|
||||
exit ;;
|
||||
i*86:AROS:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-aros
|
||||
exit ;;
|
||||
x86_64:VMkernel:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-esx
|
||||
exit ;;
|
||||
esac
|
||||
|
||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
|
||||
|
||||
eval $set_cc_for_build
|
||||
cat >$dummy.c <<EOF
|
||||
#ifdef _SEQUENT_
|
||||
@@ -1378,11 +1346,11 @@ main ()
|
||||
#include <sys/param.h>
|
||||
printf ("m68k-sony-newsos%s\n",
|
||||
#ifdef NEWSOS4
|
||||
"4"
|
||||
"4"
|
||||
#else
|
||||
""
|
||||
""
|
||||
#endif
|
||||
); exit (0);
|
||||
); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
+3
-14
@@ -1,10 +1,10 @@
|
||||
AC_INIT([ccminer], [2.3.1], [], [ccminer], [http://github.com/tpruvot/ccminer])
|
||||
AC_INIT([ccminer], [1.6.4])
|
||||
|
||||
AC_PREREQ([2.59c])
|
||||
AC_CANONICAL_SYSTEM
|
||||
AC_CONFIG_SRCDIR([ccminer.cpp])
|
||||
AM_INIT_AUTOMAKE([foreign subdir-objects])
|
||||
AC_CONFIG_HEADERS([ccminer-config.h])
|
||||
AC_CONFIG_HEADERS([cpuminer-config.h])
|
||||
|
||||
dnl Make sure anyone changing configure.ac/Makefile.am has a clue
|
||||
AM_MAINTAINER_MODE
|
||||
@@ -63,10 +63,6 @@ case $target in
|
||||
PTHREAD_FLAGS=""
|
||||
WS2_LIBS="-lws2_32"
|
||||
;;
|
||||
*86*-apple-darwin*)
|
||||
have_osx=true
|
||||
PTHREAD_FLAGS=""
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_CHECK_LIB(jansson, json_loads, request_jansson=false, request_jansson=true)
|
||||
@@ -76,13 +72,11 @@ AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS="-lpthread",
|
||||
AC_CHECK_LIB([pthreadGC], [pthread_create], PTHREAD_LIBS="-lpthreadGC"
|
||||
))))
|
||||
|
||||
AC_CHECK_LIB([z],[gzopen], [], [])
|
||||
AC_CHECK_LIB([ssl],[SSL_free], [], [AC_MSG_ERROR([OpenSSL library required])])
|
||||
AC_CHECK_LIB([ssl],[SSL_library_init], [], [AC_MSG_ERROR([OpenSSL library required])])
|
||||
AC_CHECK_LIB([crypto],[EVP_DigestFinal_ex], [], [AC_MSG_ERROR([OpenSSL library required])])
|
||||
|
||||
AM_CONDITIONAL([WANT_JANSSON], [test x$request_jansson = xtrue])
|
||||
AM_CONDITIONAL([HAVE_WINDOWS], [test x$have_win32 = xtrue])
|
||||
AM_CONDITIONAL([HAVE_OSX], [test x$have_osx = xtrue])
|
||||
AM_CONDITIONAL([ARCH_x86], [test x$have_x86 = xtrue])
|
||||
AM_CONDITIONAL([ARCH_x86_64], [test x$have_x86_64 = xtrue])
|
||||
|
||||
@@ -116,11 +110,6 @@ else
|
||||
SUFFIX=""
|
||||
fi
|
||||
|
||||
if test x$have_osx = xtrue
|
||||
then
|
||||
SUFFIX=""
|
||||
fi
|
||||
|
||||
dnl Setup CUDA paths
|
||||
AC_ARG_WITH([cuda],
|
||||
[ --with-cuda=PATH prefix where cuda is installed [default=/usr/local/cuda]])
|
||||
|
||||
+7
-3
@@ -1,7 +1,11 @@
|
||||
# To change the cuda arch, edit Makefile.am and run ./build.sh
|
||||
# possible additional CUDA_CFLAGS
|
||||
#-gencode=arch=compute_50,code=\"sm_50,compute_50\"
|
||||
#-gencode=arch=compute_35,code=\"sm_35,compute_35\"
|
||||
#-gencode=arch=compute_30,code=\"sm_30,compute_30\"
|
||||
|
||||
#--ptxas-options=\"-v -dlcm=cg\""
|
||||
|
||||
extracflags="-march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16"
|
||||
|
||||
CUDA_CFLAGS="-O3 -lineno -Xcompiler -Wall -D_FORCE_INLINES" \
|
||||
./configure CXXFLAGS="-O3 $extracflags" --with-cuda=/usr/local/cuda --with-nvml=libnvidia-ml.so
|
||||
CUDA_CFLAGS="-O3 -lineno -Xcompiler -Wall" ./configure CXXFLAGS="-O3 $extracflags" --with-cuda=/usr/local/cuda --with-nvml=libnvidia-ml.so
|
||||
|
||||
@@ -1,188 +1,191 @@
|
||||
/* CONFIG ONLY FOR MS VC++ BUILD */
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
/* #undef CRAY_STACKSEG_END */
|
||||
|
||||
/* Define to 1 if using `alloca.c'. */
|
||||
/* #undef C_ALLOCA */
|
||||
|
||||
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||
#define HAVE_ALLOCA 1
|
||||
|
||||
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
|
||||
*/
|
||||
#define HAVE_ALLOCA_H 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `be32dec', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_BE32DEC 0
|
||||
|
||||
/* Define to 1 if you have the declaration of `be32enc', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_BE32ENC 0
|
||||
|
||||
/* Define to 1 if you have the declaration of `le32dec', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_LE32DEC 0
|
||||
|
||||
/* Define to 1 if you have the declaration of `le32enc', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_LE32ENC 0
|
||||
|
||||
/* Define to 1 if you have the `getopt_long' function. */
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `crypto' library (-lcrypto). */
|
||||
#define HAVE_LIBCRYPTO 1
|
||||
|
||||
/* Define to 1 if you have a functional curl library. */
|
||||
#define HAVE_LIBCURL 1
|
||||
|
||||
/* Define to 1 if you have the `ssl' library (-lssl). */
|
||||
#define HAVE_LIBSSL 1
|
||||
|
||||
/* Define to 1 if you have the `z' library (-lz). */
|
||||
#define HAVE_LIBZ 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <syslog.h> header file. */
|
||||
/* #undef HAVE_SYSLOG_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/endian.h> header file. */
|
||||
/* #undef HAVE_SYS_ENDIAN_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/sysctl.h> header file. */
|
||||
#define HAVE_SYS_SYSCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Defined if libcurl supports AsynchDNS */
|
||||
/* #undef LIBCURL_FEATURE_ASYNCHDNS */
|
||||
|
||||
/* Defined if libcurl supports IDN */
|
||||
#define LIBCURL_FEATURE_IDN 1
|
||||
|
||||
/* Defined if libcurl supports IPv6 */
|
||||
#define LIBCURL_FEATURE_IPV6 1
|
||||
|
||||
/* Defined if libcurl supports KRB4 */
|
||||
/* #undef LIBCURL_FEATURE_KRB4 */
|
||||
|
||||
/* Defined if libcurl supports libz */
|
||||
#define LIBCURL_FEATURE_LIBZ 1
|
||||
|
||||
/* Defined if libcurl supports NTLM */
|
||||
#define LIBCURL_FEATURE_NTLM 1
|
||||
|
||||
/* Defined if libcurl supports SSL */
|
||||
#define LIBCURL_FEATURE_SSL 1
|
||||
|
||||
/* Defined if libcurl supports SSPI */
|
||||
/* #undef LIBCURL_FEATURE_SSPI */
|
||||
|
||||
/* Defined if libcurl supports DICT */
|
||||
/* #undef LIBCURL_PROTOCOL_DICT */
|
||||
|
||||
/* Defined if libcurl supports FILE */
|
||||
#define LIBCURL_PROTOCOL_FILE 1
|
||||
|
||||
/* Defined if libcurl supports FTP */
|
||||
#define LIBCURL_PROTOCOL_FTP 1
|
||||
|
||||
/* Defined if libcurl supports FTPS */
|
||||
#define LIBCURL_PROTOCOL_FTPS 1
|
||||
|
||||
/* Defined if libcurl supports HTTP */
|
||||
#define LIBCURL_PROTOCOL_HTTP 1
|
||||
|
||||
/* Defined if libcurl supports HTTPS */
|
||||
#define LIBCURL_PROTOCOL_HTTPS 1
|
||||
|
||||
/* Defined if libcurl supports IMAP */
|
||||
/* #undef LIBCURL_PROTOCOL_IMAP */
|
||||
|
||||
/* Defined if libcurl supports LDAP */
|
||||
/* #undef LIBCURL_PROTOCOL_LDAP */
|
||||
|
||||
/* Defined if libcurl supports POP3 */
|
||||
/* #undef LIBCURL_PROTOCOL_POP3 */
|
||||
|
||||
/* Defined if libcurl supports RTSP */
|
||||
/* #undef LIBCURL_PROTOCOL_RTSP */
|
||||
|
||||
/* Defined if libcurl supports SMTP */
|
||||
/* #undef LIBCURL_PROTOCOL_SMTP */
|
||||
|
||||
/* Defined if libcurl supports TELNET */
|
||||
/* #undef LIBCURL_PROTOCOL_TELNET */
|
||||
|
||||
/* Defined if libcurl supports TFTP */
|
||||
/* #undef LIBCURL_PROTOCOL_TFTP */
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
/* #undef NO_MINUS_C_MINUS_O */
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "ccminer"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT ""
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "ccminer"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL "http://github.com/tpruvot/ccminer"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "2.3.1"
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at runtime.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
/* #undef STACK_DIRECTION */
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define curl_free() as free() if our version of curl lacks curl_free. */
|
||||
/* #undef curl_free */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
//#define size_t unsigned int
|
||||
|
||||
#if !defined(HAVE_STRUCT_TIMESPEC) && _MSC_VER >= 1900
|
||||
#define HAVE_STRUCT_TIMESPEC
|
||||
#endif
|
||||
/* cpuminer-config.h. Generated from cpuminer-config.h.in by configure. */
|
||||
/* cpuminer-config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
/* #undef CRAY_STACKSEG_END */
|
||||
|
||||
/* Define to 1 if using `alloca.c'. */
|
||||
/* #undef C_ALLOCA */
|
||||
|
||||
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||
#define HAVE_ALLOCA 1
|
||||
|
||||
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
|
||||
*/
|
||||
#define HAVE_ALLOCA_H 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `be32dec', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_BE32DEC 0
|
||||
|
||||
/* Define to 1 if you have the declaration of `be32enc', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_BE32ENC 0
|
||||
|
||||
/* Define to 1 if you have the declaration of `le32dec', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_LE32DEC 0
|
||||
|
||||
/* Define to 1 if you have the declaration of `le32enc', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_LE32ENC 0
|
||||
|
||||
/* Define to 1 if you have the `getopt_long' function. */
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `crypto' library (-lcrypto). */
|
||||
#define HAVE_LIBCRYPTO 1
|
||||
|
||||
/* Define to 1 if you have a functional curl library. */
|
||||
#define HAVE_LIBCURL 1
|
||||
|
||||
/* Define to 1 if you have the `ssl' library (-lssl). */
|
||||
#define HAVE_LIBSSL 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <syslog.h> header file. */
|
||||
/* #undef HAVE_SYSLOG_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/endian.h> header file. */
|
||||
/* #undef HAVE_SYS_ENDIAN_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/sysctl.h> header file. */
|
||||
#define HAVE_SYS_SYSCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Defined if libcurl supports AsynchDNS */
|
||||
/* #undef LIBCURL_FEATURE_ASYNCHDNS */
|
||||
|
||||
/* Defined if libcurl supports IDN */
|
||||
#define LIBCURL_FEATURE_IDN 1
|
||||
|
||||
/* Defined if libcurl supports IPv6 */
|
||||
#define LIBCURL_FEATURE_IPV6 1
|
||||
|
||||
/* Defined if libcurl supports KRB4 */
|
||||
/* #undef LIBCURL_FEATURE_KRB4 */
|
||||
|
||||
/* Defined if libcurl supports libz */
|
||||
#define LIBCURL_FEATURE_LIBZ 1
|
||||
|
||||
/* Defined if libcurl supports NTLM */
|
||||
#define LIBCURL_FEATURE_NTLM 1
|
||||
|
||||
/* Defined if libcurl supports SSL */
|
||||
#define LIBCURL_FEATURE_SSL 1
|
||||
|
||||
/* Defined if libcurl supports SSPI */
|
||||
/* #undef LIBCURL_FEATURE_SSPI */
|
||||
|
||||
/* Defined if libcurl supports DICT */
|
||||
/* #undef LIBCURL_PROTOCOL_DICT */
|
||||
|
||||
/* Defined if libcurl supports FILE */
|
||||
#define LIBCURL_PROTOCOL_FILE 1
|
||||
|
||||
/* Defined if libcurl supports FTP */
|
||||
#define LIBCURL_PROTOCOL_FTP 1
|
||||
|
||||
/* Defined if libcurl supports FTPS */
|
||||
#define LIBCURL_PROTOCOL_FTPS 1
|
||||
|
||||
/* Defined if libcurl supports HTTP */
|
||||
#define LIBCURL_PROTOCOL_HTTP 1
|
||||
|
||||
/* Defined if libcurl supports HTTPS */
|
||||
/* #undef LIBCURL_PROTOCOL_HTTPS */
|
||||
|
||||
/* Defined if libcurl supports IMAP */
|
||||
/* #undef LIBCURL_PROTOCOL_IMAP */
|
||||
|
||||
/* Defined if libcurl supports LDAP */
|
||||
/* #undef LIBCURL_PROTOCOL_LDAP */
|
||||
|
||||
/* Defined if libcurl supports POP3 */
|
||||
/* #undef LIBCURL_PROTOCOL_POP3 */
|
||||
|
||||
/* Defined if libcurl supports RTSP */
|
||||
/* #undef LIBCURL_PROTOCOL_RTSP */
|
||||
|
||||
/* Defined if libcurl supports SMTP */
|
||||
/* #undef LIBCURL_PROTOCOL_SMTP */
|
||||
|
||||
/* Defined if libcurl supports TELNET */
|
||||
/* #undef LIBCURL_PROTOCOL_TELNET */
|
||||
|
||||
/* Defined if libcurl supports TFTP */
|
||||
/* #undef LIBCURL_PROTOCOL_TFTP */
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
/* #undef NO_MINUS_C_MINUS_O */
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "ccminer"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT ""
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "ccminer"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "ccminer 1.6.4"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "ccminer"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL "http://github.com/tpruvot/ccminer"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.6.4"
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at runtime.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
/* #undef STACK_DIRECTION */
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.6.4"
|
||||
|
||||
/* Define curl_free() as free() if our version of curl lacks curl_free. */
|
||||
/* #undef curl_free */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
//#define size_t unsigned int
|
||||
-170
@@ -1,170 +0,0 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation.
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its operation, including, but not limited to, correctness
|
||||
and fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define TABLE_ALIGN 32
|
||||
#define WPOLY 0x011b
|
||||
#define N_COLS 4
|
||||
#define AES_BLOCK_SIZE 16
|
||||
#define RC_LENGTH (5 * (AES_BLOCK_SIZE / 4 - 2))
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define ALIGN __declspec(align(TABLE_ALIGN))
|
||||
#elif defined(__GNUC__)
|
||||
#define ALIGN __attribute__ ((aligned(16)))
|
||||
#else
|
||||
#define ALIGN
|
||||
#endif
|
||||
|
||||
#define rf1(r,c) (r)
|
||||
#define word_in(x,c) (*((uint32_t*)(x)+(c)))
|
||||
#define word_out(x,c,v) (*((uint32_t*)(x)+(c)) = (v))
|
||||
|
||||
#define s(x,c) x[c]
|
||||
#define si(y,x,c) (s(y,c) = word_in(x, c))
|
||||
#define so(y,x,c) word_out(y, c, s(x,c))
|
||||
#define state_in(y,x) si(y,x,0); si(y,x,1); si(y,x,2); si(y,x,3)
|
||||
#define state_out(y,x) so(y,x,0); so(y,x,1); so(y,x,2); so(y,x,3)
|
||||
#define round(y,x,k) \
|
||||
y[0] = (k)[0] ^ (t_fn[0][x[0] & 0xff] ^ t_fn[1][(x[1] >> 8) & 0xff] ^ t_fn[2][(x[2] >> 16) & 0xff] ^ t_fn[3][x[3] >> 24]); \
|
||||
y[1] = (k)[1] ^ (t_fn[0][x[1] & 0xff] ^ t_fn[1][(x[2] >> 8) & 0xff] ^ t_fn[2][(x[3] >> 16) & 0xff] ^ t_fn[3][x[0] >> 24]); \
|
||||
y[2] = (k)[2] ^ (t_fn[0][x[2] & 0xff] ^ t_fn[1][(x[3] >> 8) & 0xff] ^ t_fn[2][(x[0] >> 16) & 0xff] ^ t_fn[3][x[1] >> 24]); \
|
||||
y[3] = (k)[3] ^ (t_fn[0][x[3] & 0xff] ^ t_fn[1][(x[0] >> 8) & 0xff] ^ t_fn[2][(x[1] >> 16) & 0xff] ^ t_fn[3][x[2] >> 24]);
|
||||
#define to_byte(x) ((x) & 0xff)
|
||||
#define bval(x,n) to_byte((x) >> (8 * (n)))
|
||||
|
||||
#define fwd_var(x,r,c)\
|
||||
( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\
|
||||
: r == 1 ? ( c == 0 ? s(x,1) : c == 1 ? s(x,2) : c == 2 ? s(x,3) : s(x,0))\
|
||||
: r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\
|
||||
: ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2)))
|
||||
|
||||
#define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,n),fwd_var,rf1,c))
|
||||
|
||||
#define sb_data(w) {\
|
||||
w(0x63), w(0x7c), w(0x77), w(0x7b), w(0xf2), w(0x6b), w(0x6f), w(0xc5),\
|
||||
w(0x30), w(0x01), w(0x67), w(0x2b), w(0xfe), w(0xd7), w(0xab), w(0x76),\
|
||||
w(0xca), w(0x82), w(0xc9), w(0x7d), w(0xfa), w(0x59), w(0x47), w(0xf0),\
|
||||
w(0xad), w(0xd4), w(0xa2), w(0xaf), w(0x9c), w(0xa4), w(0x72), w(0xc0),\
|
||||
w(0xb7), w(0xfd), w(0x93), w(0x26), w(0x36), w(0x3f), w(0xf7), w(0xcc),\
|
||||
w(0x34), w(0xa5), w(0xe5), w(0xf1), w(0x71), w(0xd8), w(0x31), w(0x15),\
|
||||
w(0x04), w(0xc7), w(0x23), w(0xc3), w(0x18), w(0x96), w(0x05), w(0x9a),\
|
||||
w(0x07), w(0x12), w(0x80), w(0xe2), w(0xeb), w(0x27), w(0xb2), w(0x75),\
|
||||
w(0x09), w(0x83), w(0x2c), w(0x1a), w(0x1b), w(0x6e), w(0x5a), w(0xa0),\
|
||||
w(0x52), w(0x3b), w(0xd6), w(0xb3), w(0x29), w(0xe3), w(0x2f), w(0x84),\
|
||||
w(0x53), w(0xd1), w(0x00), w(0xed), w(0x20), w(0xfc), w(0xb1), w(0x5b),\
|
||||
w(0x6a), w(0xcb), w(0xbe), w(0x39), w(0x4a), w(0x4c), w(0x58), w(0xcf),\
|
||||
w(0xd0), w(0xef), w(0xaa), w(0xfb), w(0x43), w(0x4d), w(0x33), w(0x85),\
|
||||
w(0x45), w(0xf9), w(0x02), w(0x7f), w(0x50), w(0x3c), w(0x9f), w(0xa8),\
|
||||
w(0x51), w(0xa3), w(0x40), w(0x8f), w(0x92), w(0x9d), w(0x38), w(0xf5),\
|
||||
w(0xbc), w(0xb6), w(0xda), w(0x21), w(0x10), w(0xff), w(0xf3), w(0xd2),\
|
||||
w(0xcd), w(0x0c), w(0x13), w(0xec), w(0x5f), w(0x97), w(0x44), w(0x17),\
|
||||
w(0xc4), w(0xa7), w(0x7e), w(0x3d), w(0x64), w(0x5d), w(0x19), w(0x73),\
|
||||
w(0x60), w(0x81), w(0x4f), w(0xdc), w(0x22), w(0x2a), w(0x90), w(0x88),\
|
||||
w(0x46), w(0xee), w(0xb8), w(0x14), w(0xde), w(0x5e), w(0x0b), w(0xdb),\
|
||||
w(0xe0), w(0x32), w(0x3a), w(0x0a), w(0x49), w(0x06), w(0x24), w(0x5c),\
|
||||
w(0xc2), w(0xd3), w(0xac), w(0x62), w(0x91), w(0x95), w(0xe4), w(0x79),\
|
||||
w(0xe7), w(0xc8), w(0x37), w(0x6d), w(0x8d), w(0xd5), w(0x4e), w(0xa9),\
|
||||
w(0x6c), w(0x56), w(0xf4), w(0xea), w(0x65), w(0x7a), w(0xae), w(0x08),\
|
||||
w(0xba), w(0x78), w(0x25), w(0x2e), w(0x1c), w(0xa6), w(0xb4), w(0xc6),\
|
||||
w(0xe8), w(0xdd), w(0x74), w(0x1f), w(0x4b), w(0xbd), w(0x8b), w(0x8a),\
|
||||
w(0x70), w(0x3e), w(0xb5), w(0x66), w(0x48), w(0x03), w(0xf6), w(0x0e),\
|
||||
w(0x61), w(0x35), w(0x57), w(0xb9), w(0x86), w(0xc1), w(0x1d), w(0x9e),\
|
||||
w(0xe1), w(0xf8), w(0x98), w(0x11), w(0x69), w(0xd9), w(0x8e), w(0x94),\
|
||||
w(0x9b), w(0x1e), w(0x87), w(0xe9), w(0xce), w(0x55), w(0x28), w(0xdf),\
|
||||
w(0x8c), w(0xa1), w(0x89), w(0x0d), w(0xbf), w(0xe6), w(0x42), w(0x68),\
|
||||
w(0x41), w(0x99), w(0x2d), w(0x0f), w(0xb0), w(0x54), w(0xbb), w(0x16) }
|
||||
|
||||
#define rc_data(w) {\
|
||||
w(0x01), w(0x02), w(0x04), w(0x08), w(0x10),w(0x20), w(0x40), w(0x80),\
|
||||
w(0x1b), w(0x36) }
|
||||
|
||||
#define bytes2word(b0, b1, b2, b3) (((uint32_t)(b3) << 24) | \
|
||||
((uint32_t)(b2) << 16) | ((uint32_t)(b1) << 8) | (b0))
|
||||
|
||||
#define h0(x) (x)
|
||||
#define w0(p) bytes2word(p, 0, 0, 0)
|
||||
#define w1(p) bytes2word(0, p, 0, 0)
|
||||
#define w2(p) bytes2word(0, 0, p, 0)
|
||||
#define w3(p) bytes2word(0, 0, 0, p)
|
||||
|
||||
#define u0(p) bytes2word(f2(p), p, p, f3(p))
|
||||
#define u1(p) bytes2word(f3(p), f2(p), p, p)
|
||||
#define u2(p) bytes2word(p, f3(p), f2(p), p)
|
||||
#define u3(p) bytes2word(p, p, f3(p), f2(p))
|
||||
|
||||
#define v0(p) bytes2word(fe(p), f9(p), fd(p), fb(p))
|
||||
#define v1(p) bytes2word(fb(p), fe(p), f9(p), fd(p))
|
||||
#define v2(p) bytes2word(fd(p), fb(p), fe(p), f9(p))
|
||||
#define v3(p) bytes2word(f9(p), fd(p), fb(p), fe(p))
|
||||
|
||||
#define f2(x) ((x<<1) ^ (((x>>7) & 1) * WPOLY))
|
||||
#define f4(x) ((x<<2) ^ (((x>>6) & 1) * WPOLY) ^ (((x>>6) & 2) * WPOLY))
|
||||
#define f8(x) ((x<<3) ^ (((x>>5) & 1) * WPOLY) ^ (((x>>5) & 2) * WPOLY) ^ (((x>>5) & 4) * WPOLY))
|
||||
#define f3(x) (f2(x) ^ x)
|
||||
#define f9(x) (f8(x) ^ x)
|
||||
#define fb(x) (f8(x) ^ f2(x) ^ x)
|
||||
#define fd(x) (f8(x) ^ f4(x) ^ x)
|
||||
#define fe(x) (f8(x) ^ f4(x) ^ f2(x))
|
||||
|
||||
#define t_dec(m,n) t_##m##n
|
||||
#define t_set(m,n) t_##m##n
|
||||
#define t_use(m,n) t_##m##n
|
||||
|
||||
#define d_4(t,n,b,e,f,g,h) ALIGN const t n[4][256] = { b(e), b(f), b(g), b(h) }
|
||||
|
||||
#define four_tables(x,tab,vf,rf,c) \
|
||||
(tab[0][bval(vf(x,0,c),rf(0,c))] \
|
||||
^ tab[1][bval(vf(x,1,c),rf(1,c))] \
|
||||
^ tab[2][bval(vf(x,2,c),rf(2,c))] \
|
||||
^ tab[3][bval(vf(x,3,c),rf(3,c))])
|
||||
|
||||
d_4(uint32_t, t_dec(f,n), sb_data, u0, u1, u2, u3);
|
||||
|
||||
void aesb_single_round(const uint8_t *in, uint8_t *out, uint8_t *expandedKey)
|
||||
{
|
||||
round(((uint32_t*) out), ((uint32_t*) in), ((uint32_t*) expandedKey));
|
||||
}
|
||||
|
||||
void aesb_pseudo_round_mut(uint8_t *val, uint8_t *expandedKey)
|
||||
{
|
||||
uint32_t b1[4];
|
||||
round(b1, ((uint32_t*) val), ((const uint32_t *) expandedKey));
|
||||
round(((uint32_t*) val), b1, ((const uint32_t *) expandedKey) + 1 * N_COLS);
|
||||
round(b1, ((uint32_t*) val), ((const uint32_t *) expandedKey) + 2 * N_COLS);
|
||||
round(((uint32_t*) val), b1, ((const uint32_t *) expandedKey) + 3 * N_COLS);
|
||||
round(b1, ((uint32_t*) val), ((const uint32_t *) expandedKey) + 4 * N_COLS);
|
||||
round(((uint32_t*) val), b1, ((const uint32_t *) expandedKey) + 5 * N_COLS);
|
||||
round(b1, ((uint32_t*) val), ((const uint32_t *) expandedKey) + 6 * N_COLS);
|
||||
round(((uint32_t*) val), b1, ((const uint32_t *) expandedKey) + 7 * N_COLS);
|
||||
round(b1, ((uint32_t*) val), ((const uint32_t *) expandedKey) + 8 * N_COLS);
|
||||
round(((uint32_t*) val), b1, ((const uint32_t *) expandedKey) + 9 * N_COLS);
|
||||
}
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
@@ -1,990 +0,0 @@
|
||||
|
||||
#define N_COLS 4
|
||||
#define WPOLY 0x011b
|
||||
/*
|
||||
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,
|
||||
0xecadad41U, 0x67d4d4b3U, 0xfda2a25fU, 0xeaafaf45U, 0xbf9c9c23U, 0xf7a4a453U, 0x967272e4U, 0x5bc0c09bU,
|
||||
0xc2b7b775U, 0x1cfdfde1U, 0xae93933dU, 0x6a26264cU, 0x5a36366cU, 0x413f3f7eU, 0x02f7f7f5U, 0x4fcccc83U,
|
||||
0x5c343468U, 0xf4a5a551U, 0x34e5e5d1U, 0x08f1f1f9U, 0x937171e2U, 0x73d8d8abU, 0x53313162U, 0x3f15152aU,
|
||||
0x0c040408U, 0x52c7c795U, 0x65232346U, 0x5ec3c39dU, 0x28181830U, 0xa1969637U, 0x0f05050aU, 0xb59a9a2fU,
|
||||
0x0907070eU, 0x36121224U, 0x9b80801bU, 0x3de2e2dfU, 0x26ebebcdU, 0x6927274eU, 0xcdb2b27fU, 0x9f7575eaU,
|
||||
0x1b090912U, 0x9e83831dU, 0x742c2c58U, 0x2e1a1a34U, 0x2d1b1b36U, 0xb26e6edcU, 0xee5a5ab4U, 0xfba0a05bU,
|
||||
0xf65252a4U, 0x4d3b3b76U, 0x61d6d6b7U, 0xceb3b37dU, 0x7b292952U, 0x3ee3e3ddU, 0x712f2f5eU, 0x97848413U,
|
||||
0xf55353a6U, 0x68d1d1b9U, 0x00000000U, 0x2cededc1U, 0x60202040U, 0x1ffcfce3U, 0xc8b1b179U, 0xed5b5bb6U,
|
||||
0xbe6a6ad4U, 0x46cbcb8dU, 0xd9bebe67U, 0x4b393972U, 0xde4a4a94U, 0xd44c4c98U, 0xe85858b0U, 0x4acfcf85U,
|
||||
0x6bd0d0bbU, 0x2aefefc5U, 0xe5aaaa4fU, 0x16fbfbedU, 0xc5434386U, 0xd74d4d9aU, 0x55333366U, 0x94858511U,
|
||||
0xcf45458aU, 0x10f9f9e9U, 0x06020204U, 0x817f7ffeU, 0xf05050a0U, 0x443c3c78U, 0xba9f9f25U, 0xe3a8a84bU,
|
||||
0xf35151a2U, 0xfea3a35dU, 0xc0404080U, 0x8a8f8f05U, 0xad92923fU, 0xbc9d9d21U, 0x48383870U, 0x04f5f5f1U,
|
||||
0xdfbcbc63U, 0xc1b6b677U, 0x75dadaafU, 0x63212142U, 0x30101020U, 0x1affffe5U, 0x0ef3f3fdU, 0x6dd2d2bfU,
|
||||
0x4ccdcd81U, 0x140c0c18U, 0x35131326U, 0x2fececc3U, 0xe15f5fbeU, 0xa2979735U, 0xcc444488U, 0x3917172eU,
|
||||
0x57c4c493U, 0xf2a7a755U, 0x827e7efcU, 0x473d3d7aU, 0xac6464c8U, 0xe75d5dbaU, 0x2b191932U, 0x957373e6U,
|
||||
0xa06060c0U, 0x98818119U, 0xd14f4f9eU, 0x7fdcdca3U, 0x66222244U, 0x7e2a2a54U, 0xab90903bU, 0x8388880bU,
|
||||
0xca46468cU, 0x29eeeec7U, 0xd3b8b86bU, 0x3c141428U, 0x79dedea7U, 0xe25e5ebcU, 0x1d0b0b16U, 0x76dbdbadU,
|
||||
0x3be0e0dbU, 0x56323264U, 0x4e3a3a74U, 0x1e0a0a14U, 0xdb494992U, 0x0a06060cU, 0x6c242448U, 0xe45c5cb8U,
|
||||
0x5dc2c29fU, 0x6ed3d3bdU, 0xefacac43U, 0xa66262c4U, 0xa8919139U, 0xa4959531U, 0x37e4e4d3U, 0x8b7979f2U,
|
||||
0x32e7e7d5U, 0x43c8c88bU, 0x5937376eU, 0xb76d6ddaU, 0x8c8d8d01U, 0x64d5d5b1U, 0xd24e4e9cU, 0xe0a9a949U,
|
||||
0xb46c6cd8U, 0xfa5656acU, 0x07f4f4f3U, 0x25eaeacfU, 0xaf6565caU, 0x8e7a7af4U, 0xe9aeae47U, 0x18080810U,
|
||||
0xd5baba6fU, 0x887878f0U, 0x6f25254aU, 0x722e2e5cU, 0x241c1c38U, 0xf1a6a657U, 0xc7b4b473U, 0x51c6c697U,
|
||||
0x23e8e8cbU, 0x7cdddda1U, 0x9c7474e8U, 0x211f1f3eU, 0xdd4b4b96U, 0xdcbdbd61U, 0x868b8b0dU, 0x858a8a0fU,
|
||||
0x907070e0U, 0x423e3e7cU, 0xc4b5b571U, 0xaa6666ccU, 0xd8484890U, 0x05030306U, 0x01f6f6f7U, 0x120e0e1cU,
|
||||
0xa36161c2U, 0x5f35356aU, 0xf95757aeU, 0xd0b9b969U, 0x91868617U, 0x58c1c199U, 0x271d1d3aU, 0xb99e9e27U,
|
||||
0x38e1e1d9U, 0x13f8f8ebU, 0xb398982bU, 0x33111122U, 0xbb6969d2U, 0x70d9d9a9U, 0x898e8e07U, 0xa7949433U,
|
||||
0xb69b9b2dU, 0x221e1e3cU, 0x92878715U, 0x20e9e9c9U, 0x49cece87U, 0xff5555aaU, 0x78282850U, 0x7adfdfa5U,
|
||||
0x8f8c8c03U, 0xf8a1a159U, 0x80898909U, 0x170d0d1aU, 0xdabfbf65U, 0x31e6e6d7U, 0xc6424284U, 0xb86868d0U,
|
||||
0xc3414182U, 0xb0999929U, 0x772d2d5aU, 0x110f0f1eU, 0xcbb0b07bU, 0xfc5454a8U, 0xd6bbbb6dU, 0x3a16162cU,
|
||||
|
||||
0x6363c6a5U, 0x7c7cf884U, 0x7777ee99U, 0x7b7bf68dU, 0xf2f2ff0dU, 0x6b6bd6bdU, 0x6f6fdeb1U, 0xc5c59154U,
|
||||
0x30306050U, 0x01010203U, 0x6767cea9U, 0x2b2b567dU, 0xfefee719U, 0xd7d7b562U, 0xabab4de6U, 0x7676ec9aU,
|
||||
0xcaca8f45U, 0x82821f9dU, 0xc9c98940U, 0x7d7dfa87U, 0xfafaef15U, 0x5959b2ebU, 0x47478ec9U, 0xf0f0fb0bU,
|
||||
0xadad41ecU, 0xd4d4b367U, 0xa2a25ffdU, 0xafaf45eaU, 0x9c9c23bfU, 0xa4a453f7U, 0x7272e496U, 0xc0c09b5bU,
|
||||
0xb7b775c2U, 0xfdfde11cU, 0x93933daeU, 0x26264c6aU, 0x36366c5aU, 0x3f3f7e41U, 0xf7f7f502U, 0xcccc834fU,
|
||||
0x3434685cU, 0xa5a551f4U, 0xe5e5d134U, 0xf1f1f908U, 0x7171e293U, 0xd8d8ab73U, 0x31316253U, 0x15152a3fU,
|
||||
0x0404080cU, 0xc7c79552U, 0x23234665U, 0xc3c39d5eU, 0x18183028U, 0x969637a1U, 0x05050a0fU, 0x9a9a2fb5U,
|
||||
0x07070e09U, 0x12122436U, 0x80801b9bU, 0xe2e2df3dU, 0xebebcd26U, 0x27274e69U, 0xb2b27fcdU, 0x7575ea9fU,
|
||||
0x0909121bU, 0x83831d9eU, 0x2c2c5874U, 0x1a1a342eU, 0x1b1b362dU, 0x6e6edcb2U, 0x5a5ab4eeU, 0xa0a05bfbU,
|
||||
0x5252a4f6U, 0x3b3b764dU, 0xd6d6b761U, 0xb3b37dceU, 0x2929527bU, 0xe3e3dd3eU, 0x2f2f5e71U, 0x84841397U,
|
||||
0x5353a6f5U, 0xd1d1b968U, 0x00000000U, 0xededc12cU, 0x20204060U, 0xfcfce31fU, 0xb1b179c8U, 0x5b5bb6edU,
|
||||
0x6a6ad4beU, 0xcbcb8d46U, 0xbebe67d9U, 0x3939724bU, 0x4a4a94deU, 0x4c4c98d4U, 0x5858b0e8U, 0xcfcf854aU,
|
||||
0xd0d0bb6bU, 0xefefc52aU, 0xaaaa4fe5U, 0xfbfbed16U, 0x434386c5U, 0x4d4d9ad7U, 0x33336655U, 0x85851194U,
|
||||
0x45458acfU, 0xf9f9e910U, 0x02020406U, 0x7f7ffe81U, 0x5050a0f0U, 0x3c3c7844U, 0x9f9f25baU, 0xa8a84be3U,
|
||||
0x5151a2f3U, 0xa3a35dfeU, 0x404080c0U, 0x8f8f058aU, 0x92923fadU, 0x9d9d21bcU, 0x38387048U, 0xf5f5f104U,
|
||||
0xbcbc63dfU, 0xb6b677c1U, 0xdadaaf75U, 0x21214263U, 0x10102030U, 0xffffe51aU, 0xf3f3fd0eU, 0xd2d2bf6dU,
|
||||
0xcdcd814cU, 0x0c0c1814U, 0x13132635U, 0xececc32fU, 0x5f5fbee1U, 0x979735a2U, 0x444488ccU, 0x17172e39U,
|
||||
0xc4c49357U, 0xa7a755f2U, 0x7e7efc82U, 0x3d3d7a47U, 0x6464c8acU, 0x5d5dbae7U, 0x1919322bU, 0x7373e695U,
|
||||
0x6060c0a0U, 0x81811998U, 0x4f4f9ed1U, 0xdcdca37fU, 0x22224466U, 0x2a2a547eU, 0x90903babU, 0x88880b83U,
|
||||
0x46468ccaU, 0xeeeec729U, 0xb8b86bd3U, 0x1414283cU, 0xdedea779U, 0x5e5ebce2U, 0x0b0b161dU, 0xdbdbad76U,
|
||||
0xe0e0db3bU, 0x32326456U, 0x3a3a744eU, 0x0a0a141eU, 0x494992dbU, 0x06060c0aU, 0x2424486cU, 0x5c5cb8e4U,
|
||||
0xc2c29f5dU, 0xd3d3bd6eU, 0xacac43efU, 0x6262c4a6U, 0x919139a8U, 0x959531a4U, 0xe4e4d337U, 0x7979f28bU,
|
||||
0xe7e7d532U, 0xc8c88b43U, 0x37376e59U, 0x6d6ddab7U, 0x8d8d018cU, 0xd5d5b164U, 0x4e4e9cd2U, 0xa9a949e0U,
|
||||
0x6c6cd8b4U, 0x5656acfaU, 0xf4f4f307U, 0xeaeacf25U, 0x6565caafU, 0x7a7af48eU, 0xaeae47e9U, 0x08081018U,
|
||||
0xbaba6fd5U, 0x7878f088U, 0x25254a6fU, 0x2e2e5c72U, 0x1c1c3824U, 0xa6a657f1U, 0xb4b473c7U, 0xc6c69751U,
|
||||
0xe8e8cb23U, 0xdddda17cU, 0x7474e89cU, 0x1f1f3e21U, 0x4b4b96ddU, 0xbdbd61dcU, 0x8b8b0d86U, 0x8a8a0f85U,
|
||||
0x7070e090U, 0x3e3e7c42U, 0xb5b571c4U, 0x6666ccaaU, 0x484890d8U, 0x03030605U, 0xf6f6f701U, 0x0e0e1c12U,
|
||||
0x6161c2a3U, 0x35356a5fU, 0x5757aef9U, 0xb9b969d0U, 0x86861791U, 0xc1c19958U, 0x1d1d3a27U, 0x9e9e27b9U,
|
||||
0xe1e1d938U, 0xf8f8eb13U, 0x98982bb3U, 0x11112233U, 0x6969d2bbU, 0xd9d9a970U, 0x8e8e0789U, 0x949433a7U,
|
||||
0x9b9b2db6U, 0x1e1e3c22U, 0x87871592U, 0xe9e9c920U, 0xcece8749U, 0x5555aaffU, 0x28285078U, 0xdfdfa57aU,
|
||||
0x8c8c038fU, 0xa1a159f8U, 0x89890980U, 0x0d0d1a17U, 0xbfbf65daU, 0xe6e6d731U, 0x424284c6U, 0x6868d0b8U,
|
||||
0x414182c3U, 0x999929b0U, 0x2d2d5a77U, 0x0f0f1e11U, 0xb0b07bcbU, 0x5454a8fcU, 0xbbbb6dd6U, 0x16162c3aU,
|
||||
|
||||
0x63c6a563U, 0x7cf8847cU, 0x77ee9977U, 0x7bf68d7bU, 0xf2ff0df2U, 0x6bd6bd6bU, 0x6fdeb16fU, 0xc59154c5U,
|
||||
0x30605030U, 0x01020301U, 0x67cea967U, 0x2b567d2bU, 0xfee719feU, 0xd7b562d7U, 0xab4de6abU, 0x76ec9a76U,
|
||||
0xca8f45caU, 0x821f9d82U, 0xc98940c9U, 0x7dfa877dU, 0xfaef15faU, 0x59b2eb59U, 0x478ec947U, 0xf0fb0bf0U,
|
||||
0xad41ecadU, 0xd4b367d4U, 0xa25ffda2U, 0xaf45eaafU, 0x9c23bf9cU, 0xa453f7a4U, 0x72e49672U, 0xc09b5bc0U,
|
||||
0xb775c2b7U, 0xfde11cfdU, 0x933dae93U, 0x264c6a26U, 0x366c5a36U, 0x3f7e413fU, 0xf7f502f7U, 0xcc834fccU,
|
||||
0x34685c34U, 0xa551f4a5U, 0xe5d134e5U, 0xf1f908f1U, 0x71e29371U, 0xd8ab73d8U, 0x31625331U, 0x152a3f15U,
|
||||
0x04080c04U, 0xc79552c7U, 0x23466523U, 0xc39d5ec3U, 0x18302818U, 0x9637a196U, 0x050a0f05U, 0x9a2fb59aU,
|
||||
0x070e0907U, 0x12243612U, 0x801b9b80U, 0xe2df3de2U, 0xebcd26ebU, 0x274e6927U, 0xb27fcdb2U, 0x75ea9f75U,
|
||||
0x09121b09U, 0x831d9e83U, 0x2c58742cU, 0x1a342e1aU, 0x1b362d1bU, 0x6edcb26eU, 0x5ab4ee5aU, 0xa05bfba0U,
|
||||
0x52a4f652U, 0x3b764d3bU, 0xd6b761d6U, 0xb37dceb3U, 0x29527b29U, 0xe3dd3ee3U, 0x2f5e712fU, 0x84139784U,
|
||||
0x53a6f553U, 0xd1b968d1U, 0x00000000U, 0xedc12cedU, 0x20406020U, 0xfce31ffcU, 0xb179c8b1U, 0x5bb6ed5bU,
|
||||
0x6ad4be6aU, 0xcb8d46cbU, 0xbe67d9beU, 0x39724b39U, 0x4a94de4aU, 0x4c98d44cU, 0x58b0e858U, 0xcf854acfU,
|
||||
0xd0bb6bd0U, 0xefc52aefU, 0xaa4fe5aaU, 0xfbed16fbU, 0x4386c543U, 0x4d9ad74dU, 0x33665533U, 0x85119485U,
|
||||
0x458acf45U, 0xf9e910f9U, 0x02040602U, 0x7ffe817fU, 0x50a0f050U, 0x3c78443cU, 0x9f25ba9fU, 0xa84be3a8U,
|
||||
0x51a2f351U, 0xa35dfea3U, 0x4080c040U, 0x8f058a8fU, 0x923fad92U, 0x9d21bc9dU, 0x38704838U, 0xf5f104f5U,
|
||||
0xbc63dfbcU, 0xb677c1b6U, 0xdaaf75daU, 0x21426321U, 0x10203010U, 0xffe51affU, 0xf3fd0ef3U, 0xd2bf6dd2U,
|
||||
0xcd814ccdU, 0x0c18140cU, 0x13263513U, 0xecc32fecU, 0x5fbee15fU, 0x9735a297U, 0x4488cc44U, 0x172e3917U,
|
||||
0xc49357c4U, 0xa755f2a7U, 0x7efc827eU, 0x3d7a473dU, 0x64c8ac64U, 0x5dbae75dU, 0x19322b19U, 0x73e69573U,
|
||||
0x60c0a060U, 0x81199881U, 0x4f9ed14fU, 0xdca37fdcU, 0x22446622U, 0x2a547e2aU, 0x903bab90U, 0x880b8388U,
|
||||
0x468cca46U, 0xeec729eeU, 0xb86bd3b8U, 0x14283c14U, 0xdea779deU, 0x5ebce25eU, 0x0b161d0bU, 0xdbad76dbU,
|
||||
0xe0db3be0U, 0x32645632U, 0x3a744e3aU, 0x0a141e0aU, 0x4992db49U, 0x060c0a06U, 0x24486c24U, 0x5cb8e45cU,
|
||||
0xc29f5dc2U, 0xd3bd6ed3U, 0xac43efacU, 0x62c4a662U, 0x9139a891U, 0x9531a495U, 0xe4d337e4U, 0x79f28b79U,
|
||||
0xe7d532e7U, 0xc88b43c8U, 0x376e5937U, 0x6ddab76dU, 0x8d018c8dU, 0xd5b164d5U, 0x4e9cd24eU, 0xa949e0a9U,
|
||||
0x6cd8b46cU, 0x56acfa56U, 0xf4f307f4U, 0xeacf25eaU, 0x65caaf65U, 0x7af48e7aU, 0xae47e9aeU, 0x08101808U,
|
||||
0xba6fd5baU, 0x78f08878U, 0x254a6f25U, 0x2e5c722eU, 0x1c38241cU, 0xa657f1a6U, 0xb473c7b4U, 0xc69751c6U,
|
||||
0xe8cb23e8U, 0xdda17cddU, 0x74e89c74U, 0x1f3e211fU, 0x4b96dd4bU, 0xbd61dcbdU, 0x8b0d868bU, 0x8a0f858aU,
|
||||
0x70e09070U, 0x3e7c423eU, 0xb571c4b5U, 0x66ccaa66U, 0x4890d848U, 0x03060503U, 0xf6f701f6U, 0x0e1c120eU,
|
||||
0x61c2a361U, 0x356a5f35U, 0x57aef957U, 0xb969d0b9U, 0x86179186U, 0xc19958c1U, 0x1d3a271dU, 0x9e27b99eU,
|
||||
0xe1d938e1U, 0xf8eb13f8U, 0x982bb398U, 0x11223311U, 0x69d2bb69U, 0xd9a970d9U, 0x8e07898eU, 0x9433a794U,
|
||||
0x9b2db69bU, 0x1e3c221eU, 0x87159287U, 0xe9c920e9U, 0xce8749ceU, 0x55aaff55U, 0x28507828U, 0xdfa57adfU,
|
||||
0x8c038f8cU, 0xa159f8a1U, 0x89098089U, 0x0d1a170dU, 0xbf65dabfU, 0xe6d731e6U, 0x4284c642U, 0x68d0b868U,
|
||||
0x4182c341U, 0x9929b099U, 0x2d5a772dU, 0x0f1e110fU, 0xb07bcbb0U, 0x54a8fc54U, 0xbb6dd6bbU, 0x162c3a16U,
|
||||
|
||||
0xc6a56363U, 0xf8847c7cU, 0xee997777U, 0xf68d7b7bU, 0xff0df2f2U, 0xd6bd6b6bU, 0xdeb16f6fU, 0x9154c5c5U,
|
||||
0x60503030U, 0x02030101U, 0xcea96767U, 0x567d2b2bU, 0xe719fefeU, 0xb562d7d7U, 0x4de6ababU, 0xec9a7676U,
|
||||
0x8f45cacaU, 0x1f9d8282U, 0x8940c9c9U, 0xfa877d7dU, 0xef15fafaU, 0xb2eb5959U, 0x8ec94747U, 0xfb0bf0f0U,
|
||||
0x41ecadadU, 0xb367d4d4U, 0x5ffda2a2U, 0x45eaafafU, 0x23bf9c9cU, 0x53f7a4a4U, 0xe4967272U, 0x9b5bc0c0U,
|
||||
0x75c2b7b7U, 0xe11cfdfdU, 0x3dae9393U, 0x4c6a2626U, 0x6c5a3636U, 0x7e413f3fU, 0xf502f7f7U, 0x834fccccU,
|
||||
0x685c3434U, 0x51f4a5a5U, 0xd134e5e5U, 0xf908f1f1U, 0xe2937171U, 0xab73d8d8U, 0x62533131U, 0x2a3f1515U,
|
||||
0x080c0404U, 0x9552c7c7U, 0x46652323U, 0x9d5ec3c3U, 0x30281818U, 0x37a19696U, 0x0a0f0505U, 0x2fb59a9aU,
|
||||
0x0e090707U, 0x24361212U, 0x1b9b8080U, 0xdf3de2e2U, 0xcd26ebebU, 0x4e692727U, 0x7fcdb2b2U, 0xea9f7575U,
|
||||
0x121b0909U, 0x1d9e8383U, 0x58742c2cU, 0x342e1a1aU, 0x362d1b1bU, 0xdcb26e6eU, 0xb4ee5a5aU, 0x5bfba0a0U,
|
||||
0xa4f65252U, 0x764d3b3bU, 0xb761d6d6U, 0x7dceb3b3U, 0x527b2929U, 0xdd3ee3e3U, 0x5e712f2fU, 0x13978484U,
|
||||
0xa6f55353U, 0xb968d1d1U, 0x00000000U, 0xc12cededU, 0x40602020U, 0xe31ffcfcU, 0x79c8b1b1U, 0xb6ed5b5bU,
|
||||
0xd4be6a6aU, 0x8d46cbcbU, 0x67d9bebeU, 0x724b3939U, 0x94de4a4aU, 0x98d44c4cU, 0xb0e85858U, 0x854acfcfU,
|
||||
0xbb6bd0d0U, 0xc52aefefU, 0x4fe5aaaaU, 0xed16fbfbU, 0x86c54343U, 0x9ad74d4dU, 0x66553333U, 0x11948585U,
|
||||
0x8acf4545U, 0xe910f9f9U, 0x04060202U, 0xfe817f7fU, 0xa0f05050U, 0x78443c3cU, 0x25ba9f9fU, 0x4be3a8a8U,
|
||||
0xa2f35151U, 0x5dfea3a3U, 0x80c04040U, 0x058a8f8fU, 0x3fad9292U, 0x21bc9d9dU, 0x70483838U, 0xf104f5f5U,
|
||||
0x63dfbcbcU, 0x77c1b6b6U, 0xaf75dadaU, 0x42632121U, 0x20301010U, 0xe51affffU, 0xfd0ef3f3U, 0xbf6dd2d2U,
|
||||
0x814ccdcdU, 0x18140c0cU, 0x26351313U, 0xc32fececU, 0xbee15f5fU, 0x35a29797U, 0x88cc4444U, 0x2e391717U,
|
||||
0x9357c4c4U, 0x55f2a7a7U, 0xfc827e7eU, 0x7a473d3dU, 0xc8ac6464U, 0xbae75d5dU, 0x322b1919U, 0xe6957373U,
|
||||
0xc0a06060U, 0x19988181U, 0x9ed14f4fU, 0xa37fdcdcU, 0x44662222U, 0x547e2a2aU, 0x3bab9090U, 0x0b838888U,
|
||||
0x8cca4646U, 0xc729eeeeU, 0x6bd3b8b8U, 0x283c1414U, 0xa779dedeU, 0xbce25e5eU, 0x161d0b0bU, 0xad76dbdbU,
|
||||
0xdb3be0e0U, 0x64563232U, 0x744e3a3aU, 0x141e0a0aU, 0x92db4949U, 0x0c0a0606U, 0x486c2424U, 0xb8e45c5cU,
|
||||
0x9f5dc2c2U, 0xbd6ed3d3U, 0x43efacacU, 0xc4a66262U, 0x39a89191U, 0x31a49595U, 0xd337e4e4U, 0xf28b7979U,
|
||||
0xd532e7e7U, 0x8b43c8c8U, 0x6e593737U, 0xdab76d6dU, 0x018c8d8dU, 0xb164d5d5U, 0x9cd24e4eU, 0x49e0a9a9U,
|
||||
0xd8b46c6cU, 0xacfa5656U, 0xf307f4f4U, 0xcf25eaeaU, 0xcaaf6565U, 0xf48e7a7aU, 0x47e9aeaeU, 0x10180808U,
|
||||
0x6fd5babaU, 0xf0887878U, 0x4a6f2525U, 0x5c722e2eU, 0x38241c1cU, 0x57f1a6a6U, 0x73c7b4b4U, 0x9751c6c6U,
|
||||
0xcb23e8e8U, 0xa17cddddU, 0xe89c7474U, 0x3e211f1fU, 0x96dd4b4bU, 0x61dcbdbdU, 0x0d868b8bU, 0x0f858a8aU,
|
||||
0xe0907070U, 0x7c423e3eU, 0x71c4b5b5U, 0xccaa6666U, 0x90d84848U, 0x06050303U, 0xf701f6f6U, 0x1c120e0eU,
|
||||
0xc2a36161U, 0x6a5f3535U, 0xaef95757U, 0x69d0b9b9U, 0x17918686U, 0x9958c1c1U, 0x3a271d1dU, 0x27b99e9eU,
|
||||
0xd938e1e1U, 0xeb13f8f8U, 0x2bb39898U, 0x22331111U, 0xd2bb6969U, 0xa970d9d9U, 0x07898e8eU, 0x33a79494U,
|
||||
0x2db69b9bU, 0x3c221e1eU, 0x15928787U, 0xc920e9e9U, 0x8749ceceU, 0xaaff5555U, 0x50782828U, 0xa57adfdfU,
|
||||
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_U64(addr) *((uint64_t*)(addr))
|
||||
#define AS_UINT2(addr) *((uint2*)(addr))
|
||||
#define AS_UINT4(addr) *((uint4*)(addr))
|
||||
#define AS_UL2(addr) *((ulonglong2*)(addr))
|
||||
|
||||
#define t_fn0(x) (sharedMemory[x])
|
||||
#define t_fn1(x) (sharedMemory[0x100U | (x)])
|
||||
#define t_fn2(x) (sharedMemory[0x200U | (x)])
|
||||
#define t_fn3(x) (sharedMemory[0x300U | (x)])
|
||||
|
||||
#define round(shared, out, x, k) \
|
||||
out[0] = (k)[0] ^ (t_fn0(x[0] & 0xff) ^ t_fn1((x[1] >> 8) & 0xff) ^ t_fn2((x[2] >> 16) & 0xff) ^ t_fn3((x[3] >> 24) & 0xff)); \
|
||||
out[1] = (k)[1] ^ (t_fn0(x[1] & 0xff) ^ t_fn1((x[2] >> 8) & 0xff) ^ t_fn2((x[3] >> 16) & 0xff) ^ t_fn3((x[0] >> 24) & 0xff)); \
|
||||
out[2] = (k)[2] ^ (t_fn0(x[2] & 0xff) ^ t_fn1((x[3] >> 8) & 0xff) ^ t_fn2((x[0] >> 16) & 0xff) ^ t_fn3((x[1] >> 24) & 0xff)); \
|
||||
out[3] = (k)[3] ^ (t_fn0(x[3] & 0xff) ^ t_fn1((x[0] >> 8) & 0xff) ^ t_fn2((x[1] >> 16) & 0xff) ^ t_fn3((x[2] >> 24) & 0xff));
|
||||
|
||||
#define round_u4(shared, out, in, k) \
|
||||
((uint32_t*)out)[0] = (k)[0] ^ t_fn0(in[0].x) ^ t_fn1(in[1].y) ^ t_fn2(in[2].z) ^ t_fn3(in[3].w); \
|
||||
((uint32_t*)out)[1] = (k)[1] ^ t_fn0(in[1].x) ^ t_fn1(in[2].y) ^ t_fn2(in[3].z) ^ t_fn3(in[0].w); \
|
||||
((uint32_t*)out)[2] = (k)[2] ^ t_fn0(in[2].x) ^ t_fn1(in[3].y) ^ t_fn2(in[0].z) ^ t_fn3(in[1].w); \
|
||||
((uint32_t*)out)[3] = (k)[3] ^ t_fn0(in[3].x) ^ t_fn1(in[0].y) ^ t_fn2(in[1].z) ^ t_fn3(in[2].w);
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
#define __byte_perm(a,b,c) a
|
||||
#endif
|
||||
|
||||
#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[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)
|
||||
{
|
||||
asm("// aes_single_round");
|
||||
out[0] = expandedKey[0] ^ SHARED_0(in[0]) ^ SHARED_1(in[1]) ^ SHARED_2(in[2]) ^ SHARED_3(in[3]);
|
||||
out[1] = expandedKey[1] ^ SHARED_0(in[1]) ^ SHARED_1(in[2]) ^ SHARED_2(in[3]) ^ SHARED_3(in[0]);
|
||||
out[2] = expandedKey[2] ^ SHARED_0(in[2]) ^ SHARED_1(in[3]) ^ SHARED_2(in[0]) ^ SHARED_3(in[1]);
|
||||
out[3] = expandedKey[3] ^ SHARED_0(in[3]) ^ SHARED_1(in[0]) ^ SHARED_2(in[1]) ^ SHARED_3(in[2]);
|
||||
}
|
||||
|
||||
//
|
||||
#ifdef _WIN64
|
||||
/* do a mul.wide.u32 to prevent a shl + cvt 32 to 64 on ld.shared [ptr] */
|
||||
#define OFF8_0(x) (x & 0xFFu) * sizeof(uint32_t)
|
||||
#define OFF8_1(x) __byte_perm(x, 0x01, 0x5541) * sizeof(uint32_t)
|
||||
#define OFF8_2(x) __byte_perm(x, 0x02, 0x5542) * sizeof(uint32_t)
|
||||
#define OFF8_3(x) __byte_perm(x, 0x03, 0x5543) * sizeof(uint32_t)
|
||||
#else
|
||||
#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
|
||||
#endif
|
||||
|
||||
#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]); \
|
||||
out[1] = (k)[1] ^ SHARED_0(in[1]) ^ SHARED_1(in[2]) ^ SHARED_2(in[3]) ^ SHARED_3(in[0]); \
|
||||
out[2] = (k)[2] ^ SHARED_0(in[2]) ^ SHARED_1(in[3]) ^ SHARED_2(in[0]) ^ SHARED_3(in[1]); \
|
||||
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, uint32_t const * expandedKey)
|
||||
{
|
||||
asm("// aes_pseudo_round_mut");
|
||||
uint32_t b[4];
|
||||
round_perm(sharedMemory, b, val, expandedKey);
|
||||
round_perm(sharedMemory, val, b, expandedKey + (1 * N_COLS));
|
||||
round_perm(sharedMemory, b, val, expandedKey + (2 * N_COLS));
|
||||
round_perm(sharedMemory, val, b, expandedKey + (3 * N_COLS));
|
||||
round_perm(sharedMemory, b, val, expandedKey + (4 * N_COLS));
|
||||
round_perm(sharedMemory, val, b, expandedKey + (5 * N_COLS));
|
||||
round_perm(sharedMemory, b, val, expandedKey + (6 * N_COLS));
|
||||
round_perm(sharedMemory, val, b, expandedKey + (7 * N_COLS));
|
||||
round_perm(sharedMemory, b, val, expandedKey + (8 * N_COLS));
|
||||
round_perm(sharedMemory, val, b, expandedKey + (9 * N_COLS));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#define round_perm4(in, k) {\
|
||||
uint4 tmp; \
|
||||
tmp.x = SHARED_0(in.x) ^ SHARED_1(in.y) ^ SHARED_2(in.z) ^ SHARED_3(in.w); \
|
||||
tmp.y = SHARED_0(in.y) ^ SHARED_1(in.z) ^ SHARED_2(in.w) ^ SHARED_3(in.x); \
|
||||
tmp.z = SHARED_0(in.z) ^ SHARED_1(in.w) ^ SHARED_2(in.x) ^ SHARED_3(in.y); \
|
||||
tmp.w = SHARED_0(in.w) ^ SHARED_1(in.x) ^ SHARED_2(in.y) ^ SHARED_3(in.z); \
|
||||
val = tmp ^ key[k]; \
|
||||
}
|
||||
|
||||
__device__ __forceinline__
|
||||
void cn_aes_pseudo_round_mut_uint4(uint32_t * const sharedMemory, uint4 &val, uint4 const key[10])
|
||||
{
|
||||
asm("// aes_pseudo_round_mut_uint4");
|
||||
round_perm4(val, 0);
|
||||
round_perm4(val, 1);
|
||||
round_perm4(val, 2);
|
||||
round_perm4(val, 3);
|
||||
round_perm4(val, 4);
|
||||
round_perm4(val, 5);
|
||||
round_perm4(val, 6);
|
||||
round_perm4(val, 7);
|
||||
round_perm4(val, 8);
|
||||
round_perm4(val, 9);
|
||||
}
|
||||
|
||||
/*
|
||||
__device__ __forceinline__
|
||||
void cn_aes_gpu_init2(uint32_t* sharedMemory)
|
||||
{
|
||||
#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 << 2U) // ensure offsets aligned (16) to vector
|
||||
#pragma unroll 8
|
||||
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
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if(threadIdx.x < 4) {
|
||||
#if 0
|
||||
for (uint32_t i = 0; i < 1024; i += 4)
|
||||
sharedMemory[threadIdx.x + i] = d_t_fn[threadIdx.x + i];
|
||||
#else
|
||||
#define thrX (threadIdx.x << 2U) // ensure offsets aligned (16) to vector
|
||||
#pragma unroll 64
|
||||
for (uint32_t i = 0; i < 1024; i += 16U)
|
||||
AS_UINT4(&sharedMemory[i + thrX]) = AS_UINT4(&d_t_fn[i + thrX]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
__device__ __forceinline__
|
||||
void cn_aes_gpu_init(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;
|
||||
}
|
||||
}
|
||||
|
||||
__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;
|
||||
}
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
//#include <cuda_helper.h>
|
||||
|
||||
typedef struct {
|
||||
uint32_t h[8], s[4], t[2];
|
||||
int buflen, nullt;
|
||||
uint8_t buf[64];
|
||||
} blake_state;
|
||||
|
||||
#define U8TO32(p) \
|
||||
(((uint32_t)((p)[0]) << 24) | ((uint32_t)((p)[1]) << 16) | \
|
||||
((uint32_t)((p)[2]) << 8) | ((uint32_t)((p)[3]) ))
|
||||
|
||||
#define U32TO8(p, v) \
|
||||
(p)[0] = (uint8_t)((v) >> 24); (p)[1] = (uint8_t)((v) >> 16); \
|
||||
(p)[2] = (uint8_t)((v) >> 8); (p)[3] = (uint8_t)((v) );
|
||||
|
||||
#define BLAKE_ROT(x,n) ROTR32(x, n)
|
||||
#define BLAKE_G(a,b,c,d,e) \
|
||||
v[a] += (m[d_blake_sigma[i][e]] ^ d_blake_cst[d_blake_sigma[i][e+1]]) + v[b]; \
|
||||
v[d] = BLAKE_ROT(v[d] ^ v[a],16); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = BLAKE_ROT(v[b] ^ v[c],12); \
|
||||
v[a] += (m[d_blake_sigma[i][e+1]] ^ d_blake_cst[d_blake_sigma[i][e]]) + v[b]; \
|
||||
v[d] = BLAKE_ROT(v[d] ^ v[a], 8); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = BLAKE_ROT(v[b] ^ v[c], 7);
|
||||
|
||||
__constant__ uint8_t d_blake_sigma[14][16] = {
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
|
||||
{14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3},
|
||||
{11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4},
|
||||
{7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8},
|
||||
{9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13},
|
||||
{2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9},
|
||||
{12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11},
|
||||
{13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10},
|
||||
{6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5},
|
||||
{10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0},
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
|
||||
{14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3},
|
||||
{11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4},
|
||||
{7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8}
|
||||
};
|
||||
|
||||
__constant__ uint32_t d_blake_cst[16] = {
|
||||
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
|
||||
0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
|
||||
0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
|
||||
0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917
|
||||
};
|
||||
|
||||
__device__
|
||||
void cn_blake_compress(blake_state * __restrict__ S, const uint8_t * __restrict__ block)
|
||||
{
|
||||
uint32_t v[16], m[16], i;
|
||||
|
||||
for (i = 0; i < 16; ++i) m[i] = U8TO32(block + i * 4);
|
||||
for (i = 0; i < 8; ++i) v[i] = S->h[i];
|
||||
v[ 8] = S->s[0] ^ 0x243F6A88;
|
||||
v[ 9] = S->s[1] ^ 0x85A308D3;
|
||||
v[10] = S->s[2] ^ 0x13198A2E;
|
||||
v[11] = S->s[3] ^ 0x03707344;
|
||||
v[12] = 0xA4093822;
|
||||
v[13] = 0x299F31D0;
|
||||
v[14] = 0x082EFA98;
|
||||
v[15] = 0xEC4E6C89;
|
||||
|
||||
if (S->nullt == 0) {
|
||||
v[12] ^= S->t[0];
|
||||
v[13] ^= S->t[0];
|
||||
v[14] ^= S->t[1];
|
||||
v[15] ^= S->t[1];
|
||||
}
|
||||
|
||||
for (i = 0; i < 14; ++i) {
|
||||
BLAKE_G(0, 4, 8, 12, 0);
|
||||
BLAKE_G(1, 5, 9, 13, 2);
|
||||
BLAKE_G(2, 6, 10, 14, 4);
|
||||
BLAKE_G(3, 7, 11, 15, 6);
|
||||
BLAKE_G(3, 4, 9, 14, 14);
|
||||
BLAKE_G(2, 7, 8, 13, 12);
|
||||
BLAKE_G(0, 5, 10, 15, 8);
|
||||
BLAKE_G(1, 6, 11, 12, 10);
|
||||
}
|
||||
|
||||
for (i = 0; i < 16; ++i) S->h[i % 8] ^= v[i];
|
||||
for (i = 0; i < 8; ++i) S->h[i] ^= S->s[i % 4];
|
||||
}
|
||||
|
||||
__device__ void cn_blake_update(blake_state * __restrict__ S, const uint8_t * __restrict__ data, uint64_t datalen)
|
||||
{
|
||||
int left = S->buflen >> 3;
|
||||
int fill = 64 - left;
|
||||
|
||||
if (left && (((datalen >> 3) & 0x3F) >= (unsigned) fill)) {
|
||||
memcpy((void *) (S->buf + left), (void *) data, fill);
|
||||
S->t[0] += 512;
|
||||
if (S->t[0] == 0) S->t[1]++;
|
||||
cn_blake_compress(S, S->buf);
|
||||
data += fill;
|
||||
datalen -= (fill << 3);
|
||||
left = 0;
|
||||
}
|
||||
|
||||
while (datalen >= 512) {
|
||||
S->t[0] += 512;
|
||||
if (S->t[0] == 0) S->t[1]++;
|
||||
cn_blake_compress(S, data);
|
||||
data += 64;
|
||||
datalen -= 512;
|
||||
}
|
||||
|
||||
if (datalen > 0) {
|
||||
memcpy((void *) (S->buf + left), (void *) data, datalen >> 3);
|
||||
S->buflen = (left << 3) + datalen;
|
||||
} else {
|
||||
S->buflen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_blake_final(blake_state * __restrict__ S, uint8_t * __restrict__ digest)
|
||||
{
|
||||
const uint8_t padding[] = {
|
||||
0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
||||
uint8_t pa = 0x81, pb = 0x01;
|
||||
uint8_t msglen[8];
|
||||
uint32_t lo = S->t[0] + S->buflen, hi = S->t[1];
|
||||
if (lo < (unsigned) S->buflen) hi++;
|
||||
U32TO8(msglen + 0, hi);
|
||||
U32TO8(msglen + 4, lo);
|
||||
|
||||
if (S->buflen == 440) {
|
||||
S->t[0] -= 8;
|
||||
cn_blake_update(S, &pa, 8);
|
||||
} else {
|
||||
if (S->buflen < 440) {
|
||||
if (S->buflen == 0) S->nullt = 1;
|
||||
S->t[0] -= 440 - S->buflen;
|
||||
cn_blake_update(S, padding, 440 - S->buflen);
|
||||
} else {
|
||||
S->t[0] -= 512 - S->buflen;
|
||||
cn_blake_update(S, padding, 512 - S->buflen);
|
||||
S->t[0] -= 440;
|
||||
cn_blake_update(S, padding + 1, 440);
|
||||
S->nullt = 1;
|
||||
}
|
||||
cn_blake_update(S, &pb, 8);
|
||||
S->t[0] -= 8;
|
||||
}
|
||||
S->t[0] -= 64;
|
||||
cn_blake_update(S, msglen, 64);
|
||||
|
||||
U32TO8(digest + 0, S->h[0]);
|
||||
U32TO8(digest + 4, S->h[1]);
|
||||
U32TO8(digest + 8, S->h[2]);
|
||||
U32TO8(digest + 12, S->h[3]);
|
||||
U32TO8(digest + 16, S->h[4]);
|
||||
U32TO8(digest + 20, S->h[5]);
|
||||
U32TO8(digest + 24, S->h[6]);
|
||||
U32TO8(digest + 28, S->h[7]);
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_blake(const uint8_t * __restrict__ in, uint64_t inlen, uint32_t * out)
|
||||
{
|
||||
blake_state bs;
|
||||
blake_state *S = (blake_state *)&bs;
|
||||
|
||||
S->h[0] = 0x6A09E667; S->h[1] = 0xBB67AE85; S->h[2] = 0x3C6EF372;
|
||||
S->h[3] = 0xA54FF53A; S->h[4] = 0x510E527F; S->h[5] = 0x9B05688C;
|
||||
S->h[6] = 0x1F83D9AB; S->h[7] = 0x5BE0CD19;
|
||||
S->t[0] = S->t[1] = S->buflen = S->nullt = 0;
|
||||
S->s[0] = S->s[1] = S->s[2] = S->s[3] = 0;
|
||||
|
||||
cn_blake_update(S, (uint8_t *)in, inlen * 8);
|
||||
cn_blake_final(S, (uint8_t *)out);
|
||||
}
|
||||
@@ -1,348 +0,0 @@
|
||||
|
||||
#define GROESTL_ROWS 8
|
||||
#define GROESTL_LENGTHFIELDLEN GROESTL_ROWS
|
||||
#define GROESTL_COLS512 8
|
||||
#define GROESTL_SIZE512 (GROESTL_ROWS*GROESTL_COLS512)
|
||||
#define GROESTL_ROUNDS512 10
|
||||
#define GROESTL_HASH_BIT_LEN 256
|
||||
|
||||
#define GROESTL_ROTL32(v, n) ROTL32(v, n)
|
||||
|
||||
#define li_32(h) 0x##h##u
|
||||
#define GROESTL_EXT_BYTE(var,n) ((uint8_t)((uint32_t)(var) >> (8*n)))
|
||||
#define u32BIG(a) \
|
||||
((GROESTL_ROTL32(a,8) & li_32(00FF00FF)) | \
|
||||
(GROESTL_ROTL32(a,24) & li_32(FF00FF00)))
|
||||
|
||||
typedef struct {
|
||||
uint32_t chaining[GROESTL_SIZE512/sizeof(uint32_t)];
|
||||
uint32_t block_counter1, block_counter2;
|
||||
BitSequence buffer[GROESTL_SIZE512];
|
||||
int buf_ptr;
|
||||
int bits_in_last_byte;
|
||||
} groestlHashState;
|
||||
|
||||
__constant__ uint32_t d_groestl_T[512] = {
|
||||
0xa5f432c6, 0xc6a597f4, 0x84976ff8, 0xf884eb97, 0x99b05eee, 0xee99c7b0, 0x8d8c7af6, 0xf68df78c, 0x0d17e8ff, 0xff0de517, 0xbddc0ad6, 0xd6bdb7dc, 0xb1c816de, 0xdeb1a7c8, 0x54fc6d91, 0x915439fc,
|
||||
0x50f09060, 0x6050c0f0, 0x03050702, 0x02030405, 0xa9e02ece, 0xcea987e0, 0x7d87d156, 0x567dac87, 0x192bcce7, 0xe719d52b, 0x62a613b5, 0xb56271a6, 0xe6317c4d, 0x4de69a31, 0x9ab559ec, 0xec9ac3b5,
|
||||
0x45cf408f, 0x8f4505cf, 0x9dbca31f, 0x1f9d3ebc, 0x40c04989, 0x894009c0, 0x879268fa, 0xfa87ef92, 0x153fd0ef, 0xef15c53f, 0xeb2694b2, 0xb2eb7f26, 0xc940ce8e, 0x8ec90740, 0x0b1de6fb, 0xfb0bed1d,
|
||||
0xec2f6e41, 0x41ec822f, 0x67a91ab3, 0xb3677da9, 0xfd1c435f, 0x5ffdbe1c, 0xea256045, 0x45ea8a25, 0xbfdaf923, 0x23bf46da, 0xf7025153, 0x53f7a602, 0x96a145e4, 0xe496d3a1, 0x5bed769b, 0x9b5b2ded,
|
||||
0xc25d2875, 0x75c2ea5d, 0x1c24c5e1, 0xe11cd924, 0xaee9d43d, 0x3dae7ae9, 0x6abef24c, 0x4c6a98be, 0x5aee826c, 0x6c5ad8ee, 0x41c3bd7e, 0x7e41fcc3, 0x0206f3f5, 0xf502f106, 0x4fd15283, 0x834f1dd1,
|
||||
0x5ce48c68, 0x685cd0e4, 0xf4075651, 0x51f4a207, 0x345c8dd1, 0xd134b95c, 0x0818e1f9, 0xf908e918, 0x93ae4ce2, 0xe293dfae, 0x73953eab, 0xab734d95, 0x53f59762, 0x6253c4f5, 0x3f416b2a, 0x2a3f5441,
|
||||
0x0c141c08, 0x080c1014, 0x52f66395, 0x955231f6, 0x65afe946, 0x46658caf, 0x5ee27f9d, 0x9d5e21e2, 0x28784830, 0x30286078, 0xa1f8cf37, 0x37a16ef8, 0x0f111b0a, 0x0a0f1411, 0xb5c4eb2f, 0x2fb55ec4,
|
||||
0x091b150e, 0x0e091c1b, 0x365a7e24, 0x2436485a, 0x9bb6ad1b, 0x1b9b36b6, 0x3d4798df, 0xdf3da547, 0x266aa7cd, 0xcd26816a, 0x69bbf54e, 0x4e699cbb, 0xcd4c337f, 0x7fcdfe4c, 0x9fba50ea, 0xea9fcfba,
|
||||
0x1b2d3f12, 0x121b242d, 0x9eb9a41d, 0x1d9e3ab9, 0x749cc458, 0x5874b09c, 0x2e724634, 0x342e6872, 0x2d774136, 0x362d6c77, 0xb2cd11dc, 0xdcb2a3cd, 0xee299db4, 0xb4ee7329, 0xfb164d5b, 0x5bfbb616,
|
||||
0xf601a5a4, 0xa4f65301, 0x4dd7a176, 0x764decd7, 0x61a314b7, 0xb76175a3, 0xce49347d, 0x7dcefa49, 0x7b8ddf52, 0x527ba48d, 0x3e429fdd, 0xdd3ea142, 0x7193cd5e, 0x5e71bc93, 0x97a2b113, 0x139726a2,
|
||||
0xf504a2a6, 0xa6f55704, 0x68b801b9, 0xb96869b8, 0, 0, 0x2c74b5c1, 0xc12c9974, 0x60a0e040, 0x406080a0, 0x1f21c2e3, 0xe31fdd21, 0xc8433a79, 0x79c8f243, 0xed2c9ab6, 0xb6ed772c,
|
||||
0xbed90dd4, 0xd4beb3d9, 0x46ca478d, 0x8d4601ca, 0xd9701767, 0x67d9ce70, 0x4bddaf72, 0x724be4dd, 0xde79ed94, 0x94de3379, 0xd467ff98, 0x98d42b67, 0xe82393b0, 0xb0e87b23, 0x4ade5b85, 0x854a11de,
|
||||
0x6bbd06bb, 0xbb6b6dbd, 0x2a7ebbc5, 0xc52a917e, 0xe5347b4f, 0x4fe59e34, 0x163ad7ed, 0xed16c13a, 0xc554d286, 0x86c51754, 0xd762f89a, 0x9ad72f62, 0x55ff9966, 0x6655ccff, 0x94a7b611, 0x119422a7,
|
||||
0xcf4ac08a, 0x8acf0f4a, 0x1030d9e9, 0xe910c930, 0x060a0e04, 0x0406080a, 0x819866fe, 0xfe81e798, 0xf00baba0, 0xa0f05b0b, 0x44ccb478, 0x7844f0cc, 0xbad5f025, 0x25ba4ad5, 0xe33e754b, 0x4be3963e,
|
||||
0xf30eaca2, 0xa2f35f0e, 0xfe19445d, 0x5dfeba19, 0xc05bdb80, 0x80c01b5b, 0x8a858005, 0x058a0a85, 0xadecd33f, 0x3fad7eec, 0xbcdffe21, 0x21bc42df, 0x48d8a870, 0x7048e0d8, 0x040cfdf1, 0xf104f90c,
|
||||
0xdf7a1963, 0x63dfc67a, 0xc1582f77, 0x77c1ee58, 0x759f30af, 0xaf75459f, 0x63a5e742, 0x426384a5, 0x30507020, 0x20304050, 0x1a2ecbe5, 0xe51ad12e, 0x0e12effd, 0xfd0ee112, 0x6db708bf, 0xbf6d65b7,
|
||||
0x4cd45581, 0x814c19d4, 0x143c2418, 0x1814303c, 0x355f7926, 0x26354c5f, 0x2f71b2c3, 0xc32f9d71, 0xe13886be, 0xbee16738, 0xa2fdc835, 0x35a26afd, 0xcc4fc788, 0x88cc0b4f, 0x394b652e, 0x2e395c4b,
|
||||
0x57f96a93, 0x93573df9, 0xf20d5855, 0x55f2aa0d, 0x829d61fc, 0xfc82e39d, 0x47c9b37a, 0x7a47f4c9, 0xacef27c8, 0xc8ac8bef, 0xe73288ba, 0xbae76f32, 0x2b7d4f32, 0x322b647d, 0x95a442e6, 0xe695d7a4,
|
||||
0xa0fb3bc0, 0xc0a09bfb, 0x98b3aa19, 0x199832b3, 0xd168f69e, 0x9ed12768, 0x7f8122a3, 0xa37f5d81, 0x66aaee44, 0x446688aa, 0x7e82d654, 0x547ea882, 0xabe6dd3b, 0x3bab76e6, 0x839e950b, 0xb83169e,
|
||||
0xca45c98c, 0x8cca0345, 0x297bbcc7, 0xc729957b, 0xd36e056b, 0x6bd3d66e, 0x3c446c28, 0x283c5044, 0x798b2ca7, 0xa779558b, 0xe23d81bc, 0xbce2633d, 0x1d273116, 0x161d2c27, 0x769a37ad, 0xad76419a,
|
||||
0x3b4d96db, 0xdb3bad4d, 0x56fa9e64, 0x6456c8fa, 0x4ed2a674, 0x744ee8d2, 0x1e223614, 0x141e2822, 0xdb76e492, 0x92db3f76, 0x0a1e120c, 0x0c0a181e, 0x6cb4fc48, 0x486c90b4, 0xe4378fb8, 0xb8e46b37,
|
||||
0x5de7789f, 0x9f5d25e7, 0x6eb20fbd, 0xbd6e61b2, 0xef2a6943, 0x43ef862a, 0xa6f135c4, 0xc4a693f1, 0xa8e3da39, 0x39a872e3, 0xa4f7c631, 0x31a462f7, 0x37598ad3, 0xd337bd59, 0x8b8674f2, 0xf28bff86,
|
||||
0x325683d5, 0xd532b156, 0x43c54e8b, 0x8b430dc5, 0x59eb856e, 0x6e59dceb, 0xb7c218da, 0xdab7afc2, 0x8c8f8e01, 0x018c028f, 0x64ac1db1, 0xb16479ac, 0xd26df19c, 0x9cd2236d, 0xe03b7249, 0x49e0923b,
|
||||
0xb4c71fd8, 0xd8b4abc7, 0xfa15b9ac, 0xacfa4315, 0x0709faf3, 0xf307fd09, 0x256fa0cf, 0xcf25856f, 0xafea20ca, 0xcaaf8fea, 0x8e897df4, 0xf48ef389, 0xe9206747, 0x47e98e20, 0x18283810, 0x10182028,
|
||||
0xd5640b6f, 0x6fd5de64, 0x888373f0, 0xf088fb83, 0x6fb1fb4a, 0x4a6f94b1, 0x7296ca5c, 0x5c72b896, 0x246c5438, 0x3824706c, 0xf1085f57, 0x57f1ae08, 0xc7522173, 0x73c7e652, 0x51f36497, 0x975135f3,
|
||||
0x2365aecb, 0xcb238d65, 0x7c8425a1, 0xa17c5984, 0x9cbf57e8, 0xe89ccbbf, 0x21635d3e, 0x3e217c63, 0xdd7cea96, 0x96dd377c, 0xdc7f1e61, 0x61dcc27f, 0x86919c0d, 0x0d861a91, 0x85949b0f, 0xf851e94,
|
||||
0x90ab4be0, 0xe090dbab, 0x42c6ba7c, 0x7c42f8c6, 0xc4572671, 0x71c4e257, 0xaae529cc, 0xccaa83e5, 0xd873e390, 0x90d83b73, 0x050f0906, 0x06050c0f, 0x0103f4f7, 0xf701f503, 0x12362a1c, 0x1c123836,
|
||||
0xa3fe3cc2, 0xc2a39ffe, 0x5fe18b6a, 0x6a5fd4e1, 0xf910beae, 0xaef94710, 0xd06b0269, 0x69d0d26b, 0x91a8bf17, 0x17912ea8, 0x58e87199, 0x995829e8, 0x2769533a, 0x3a277469, 0xb9d0f727, 0x27b94ed0,
|
||||
0x384891d9, 0xd938a948, 0x1335deeb, 0xeb13cd35, 0xb3cee52b, 0x2bb356ce, 0x33557722, 0x22334455, 0xbbd604d2, 0xd2bbbfd6, 0x709039a9, 0xa9704990, 0x89808707, 0x07890e80, 0xa7f2c133, 0x33a766f2,
|
||||
0xb6c1ec2d, 0x2db65ac1, 0x22665a3c, 0x3c227866, 0x92adb815, 0x15922aad, 0x2060a9c9, 0xc9208960, 0x49db5c87, 0x874915db, 0xff1ab0aa, 0xaaff4f1a, 0x7888d850, 0x5078a088, 0x7a8e2ba5, 0xa57a518e,
|
||||
0x8f8a8903, 0x038f068a, 0xf8134a59, 0x59f8b213, 0x809b9209, 0x0980129b, 0x1739231a, 0x1a173439, 0xda751065, 0x65daca75, 0x315384d7, 0xd731b553, 0xc651d584, 0x84c61351, 0xb8d303d0, 0xd0b8bbd3,
|
||||
0xc35edc82, 0x82c31f5e, 0xb0cbe229, 0x29b052cb, 0x7799c35a, 0x5a77b499, 0x11332d1e, 0x1e113c33, 0xcb463d7b, 0x7bcbf646, 0xfc1fb7a8, 0xa8fc4b1f, 0xd6610c6d, 0x6dd6da61, 0x3a4e622c, 0x2c3a584e
|
||||
};
|
||||
|
||||
#define GROESTL_ROTATE_COLUMN_DOWN(v1, v2, amount_bytes, temp_var) { \
|
||||
temp_var = (v1<<(8*amount_bytes))|(v2>>(8*(4-amount_bytes))); \
|
||||
v2 = (v2<<(8*amount_bytes))|(v1>>(8*(4-amount_bytes))); \
|
||||
v1 = temp_var; \
|
||||
}
|
||||
|
||||
#define GROESTL_COLUMN(x,y,i, c0,c1,c2,c3,c4,c5,c6,c7, tv1,tv2,tu,tl,t) \
|
||||
tu = d_groestl_T[2*(uint32_t)x[4*c0+0]]; \
|
||||
tl = d_groestl_T[2*(uint32_t)x[4*c0+0]+1]; \
|
||||
tv1 = d_groestl_T[2*(uint32_t)x[4*c1+1]]; \
|
||||
tv2 = d_groestl_T[2*(uint32_t)x[4*c1+1]+1]; \
|
||||
GROESTL_ROTATE_COLUMN_DOWN(tv1,tv2,1,t) \
|
||||
tu ^= tv1; \
|
||||
tl ^= tv2; \
|
||||
tv1 = d_groestl_T[2*(uint32_t)x[4*c2+2]]; \
|
||||
tv2 = d_groestl_T[2*(uint32_t)x[4*c2+2]+1]; \
|
||||
GROESTL_ROTATE_COLUMN_DOWN(tv1,tv2,2,t) \
|
||||
tu ^= tv1; \
|
||||
tl ^= tv2; \
|
||||
tv1 = d_groestl_T[2*(uint32_t)x[4*c3+3]]; \
|
||||
tv2 = d_groestl_T[2*(uint32_t)x[4*c3+3]+1]; \
|
||||
GROESTL_ROTATE_COLUMN_DOWN(tv1,tv2,3,t) \
|
||||
tu ^= tv1; \
|
||||
tl ^= tv2; \
|
||||
tl ^= d_groestl_T[2*(uint32_t)x[4*c4+0]]; \
|
||||
tu ^= d_groestl_T[2*(uint32_t)x[4*c4+0]+1]; \
|
||||
tv1 = d_groestl_T[2*(uint32_t)x[4*c5+1]]; \
|
||||
tv2 = d_groestl_T[2*(uint32_t)x[4*c5+1]+1]; \
|
||||
GROESTL_ROTATE_COLUMN_DOWN(tv1,tv2,1,t) \
|
||||
tl ^= tv1; \
|
||||
tu ^= tv2; \
|
||||
tv1 = d_groestl_T[2*(uint32_t)x[4*c6+2]]; \
|
||||
tv2 = d_groestl_T[2*(uint32_t)x[4*c6+2]+1]; \
|
||||
GROESTL_ROTATE_COLUMN_DOWN(tv1,tv2,2,t) \
|
||||
tl ^= tv1; \
|
||||
tu ^= tv2; \
|
||||
tv1 = d_groestl_T[2*(uint32_t)x[4*c7+3]]; \
|
||||
tv2 = d_groestl_T[2*(uint32_t)x[4*c7+3]+1]; \
|
||||
GROESTL_ROTATE_COLUMN_DOWN(tv1,tv2,3,t) \
|
||||
tl ^= tv1; \
|
||||
tu ^= tv2; \
|
||||
y[i] = tu; \
|
||||
y[i+1] = tl;
|
||||
|
||||
__device__
|
||||
void cn_groestl_RND512P(uint8_t * __restrict__ x, uint32_t * __restrict__ y, uint32_t r)
|
||||
{
|
||||
uint32_t temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp;
|
||||
uint32_t* x32 = (uint32_t*)x;
|
||||
x32[ 0] ^= 0x00000000^r;
|
||||
x32[ 2] ^= 0x00000010^r;
|
||||
x32[ 4] ^= 0x00000020^r;
|
||||
x32[ 6] ^= 0x00000030^r;
|
||||
x32[ 8] ^= 0x00000040^r;
|
||||
x32[10] ^= 0x00000050^r;
|
||||
x32[12] ^= 0x00000060^r;
|
||||
x32[14] ^= 0x00000070^r;
|
||||
GROESTL_COLUMN(x,y, 0, 0, 2, 4, 6, 9, 11, 13, 15, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
GROESTL_COLUMN(x,y, 2, 2, 4, 6, 8, 11, 13, 15, 1, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
GROESTL_COLUMN(x,y, 4, 4, 6, 8, 10, 13, 15, 1, 3, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
GROESTL_COLUMN(x,y, 6, 6, 8, 10, 12, 15, 1, 3, 5, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
GROESTL_COLUMN(x,y, 8, 8, 10, 12, 14, 1, 3, 5, 7, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
GROESTL_COLUMN(x,y,10, 10, 12, 14, 0, 3, 5, 7, 9, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
GROESTL_COLUMN(x,y,12, 12, 14, 0, 2, 5, 7, 9, 11, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
GROESTL_COLUMN(x,y,14, 14, 0, 2, 4, 7, 9, 11, 13, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_groestl_RND512Q(uint8_t * __restrict__ x, uint32_t * __restrict__ y, uint32_t r)
|
||||
{
|
||||
uint32_t temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp;
|
||||
uint32_t* x32 = (uint32_t*)x;
|
||||
x32[ 0] = ~x32[ 0];
|
||||
x32[ 1] ^= 0xffffffff^r;
|
||||
x32[ 2] = ~x32[ 2];
|
||||
x32[ 3] ^= 0xefffffff^r;
|
||||
x32[ 4] = ~x32[ 4];
|
||||
x32[ 5] ^= 0xdfffffff^r;
|
||||
x32[ 6] = ~x32[ 6];
|
||||
x32[ 7] ^= 0xcfffffff^r;
|
||||
x32[ 8] = ~x32[ 8];
|
||||
x32[ 9] ^= 0xbfffffff^r;
|
||||
x32[10] = ~x32[10];
|
||||
x32[11] ^= 0xafffffff^r;
|
||||
x32[12] = ~x32[12];
|
||||
x32[13] ^= 0x9fffffff^r;
|
||||
x32[14] = ~x32[14];
|
||||
x32[15] ^= 0x8fffffff^r;
|
||||
GROESTL_COLUMN(x,y, 0, 2, 6, 10, 14, 1, 5, 9, 13, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
GROESTL_COLUMN(x,y, 2, 4, 8, 12, 0, 3, 7, 11, 15, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
GROESTL_COLUMN(x,y, 4, 6, 10, 14, 2, 5, 9, 13, 1, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
GROESTL_COLUMN(x,y, 6, 8, 12, 0, 4, 7, 11, 15, 3, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
GROESTL_COLUMN(x,y, 8, 10, 14, 2, 6, 9, 13, 1, 5, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
GROESTL_COLUMN(x,y,10, 12, 0, 4, 8, 11, 15, 3, 7, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
GROESTL_COLUMN(x,y,12, 14, 2, 6, 10, 13, 1, 5, 9, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
GROESTL_COLUMN(x,y,14, 0, 4, 8, 12, 15, 3, 7, 11, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp);
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_groestl_F512(uint32_t * __restrict__ h, const uint32_t * __restrict__ m)
|
||||
{
|
||||
int i;
|
||||
uint32_t Ptmp[2*GROESTL_COLS512];
|
||||
uint32_t Qtmp[2*GROESTL_COLS512];
|
||||
uint32_t y[2*GROESTL_COLS512];
|
||||
uint32_t z[2*GROESTL_COLS512];
|
||||
|
||||
for (i = 0; i < 2*GROESTL_COLS512; i++) {
|
||||
z[i] = m[i];
|
||||
Ptmp[i] = h[i]^m[i];
|
||||
}
|
||||
|
||||
cn_groestl_RND512Q((uint8_t*)z, y, 0x00000000);
|
||||
cn_groestl_RND512Q((uint8_t*)y, z, 0x01000000);
|
||||
cn_groestl_RND512Q((uint8_t*)z, y, 0x02000000);
|
||||
cn_groestl_RND512Q((uint8_t*)y, z, 0x03000000);
|
||||
cn_groestl_RND512Q((uint8_t*)z, y, 0x04000000);
|
||||
cn_groestl_RND512Q((uint8_t*)y, z, 0x05000000);
|
||||
cn_groestl_RND512Q((uint8_t*)z, y, 0x06000000);
|
||||
cn_groestl_RND512Q((uint8_t*)y, z, 0x07000000);
|
||||
cn_groestl_RND512Q((uint8_t*)z, y, 0x08000000);
|
||||
cn_groestl_RND512Q((uint8_t*)y, Qtmp, 0x09000000);
|
||||
|
||||
cn_groestl_RND512P((uint8_t*)Ptmp, y, 0x00000000);
|
||||
cn_groestl_RND512P((uint8_t*)y, z, 0x00000001);
|
||||
cn_groestl_RND512P((uint8_t*)z, y, 0x00000002);
|
||||
cn_groestl_RND512P((uint8_t*)y, z, 0x00000003);
|
||||
cn_groestl_RND512P((uint8_t*)z, y, 0x00000004);
|
||||
cn_groestl_RND512P((uint8_t*)y, z, 0x00000005);
|
||||
cn_groestl_RND512P((uint8_t*)z, y, 0x00000006);
|
||||
cn_groestl_RND512P((uint8_t*)y, z, 0x00000007);
|
||||
cn_groestl_RND512P((uint8_t*)z, y, 0x00000008);
|
||||
cn_groestl_RND512P((uint8_t*)y, Ptmp, 0x00000009);
|
||||
|
||||
for (i = 0; i < 2*GROESTL_COLS512; i++)
|
||||
h[i] ^= Ptmp[i]^Qtmp[i];
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_groestl_outputtransformation(groestlHashState *ctx)
|
||||
{
|
||||
int j;
|
||||
uint32_t temp[2*GROESTL_COLS512];
|
||||
uint32_t y[2*GROESTL_COLS512];
|
||||
uint32_t z[2*GROESTL_COLS512];
|
||||
|
||||
for (j = 0; j < 2*GROESTL_COLS512; j++)
|
||||
temp[j] = ctx->chaining[j];
|
||||
|
||||
cn_groestl_RND512P((uint8_t*)temp, y, 0x00000000);
|
||||
cn_groestl_RND512P((uint8_t*)y, z, 0x00000001);
|
||||
cn_groestl_RND512P((uint8_t*)z, y, 0x00000002);
|
||||
cn_groestl_RND512P((uint8_t*)y, z, 0x00000003);
|
||||
cn_groestl_RND512P((uint8_t*)z, y, 0x00000004);
|
||||
cn_groestl_RND512P((uint8_t*)y, z, 0x00000005);
|
||||
cn_groestl_RND512P((uint8_t*)z, y, 0x00000006);
|
||||
cn_groestl_RND512P((uint8_t*)y, z, 0x00000007);
|
||||
cn_groestl_RND512P((uint8_t*)z, y, 0x00000008);
|
||||
cn_groestl_RND512P((uint8_t*)y, temp, 0x00000009);
|
||||
|
||||
for (j = 0; j < 2*GROESTL_COLS512; j++)
|
||||
ctx->chaining[j] ^= temp[j];
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_groestl_transform(groestlHashState * __restrict__ ctx,
|
||||
const uint8_t * __restrict__ input, int msglen)
|
||||
{
|
||||
for (; msglen >= GROESTL_SIZE512; msglen -= GROESTL_SIZE512, input += GROESTL_SIZE512) {
|
||||
cn_groestl_F512(ctx->chaining,(uint32_t*)input);
|
||||
ctx->block_counter1++;
|
||||
if (ctx->block_counter1 == 0) ctx->block_counter2++;
|
||||
}
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_groestl_final(groestlHashState* __restrict__ ctx, BitSequence* __restrict__ output)
|
||||
{
|
||||
int i, j = 0, hashbytelen = GROESTL_HASH_BIT_LEN/8;
|
||||
uint8_t *s = (BitSequence*)ctx->chaining;
|
||||
|
||||
if (ctx->bits_in_last_byte) {
|
||||
ctx->buffer[(int)ctx->buf_ptr-1] &= ((1<<ctx->bits_in_last_byte)-1)<<(8-ctx->bits_in_last_byte);
|
||||
ctx->buffer[(int)ctx->buf_ptr-1] ^= 0x1<<(7-ctx->bits_in_last_byte);
|
||||
ctx->bits_in_last_byte = 0;
|
||||
}
|
||||
else ctx->buffer[(int)ctx->buf_ptr++] = 0x80;
|
||||
|
||||
if (ctx->buf_ptr > GROESTL_SIZE512-GROESTL_LENGTHFIELDLEN) {
|
||||
while (ctx->buf_ptr < GROESTL_SIZE512) {
|
||||
ctx->buffer[(int)ctx->buf_ptr++] = 0;
|
||||
}
|
||||
cn_groestl_transform(ctx, ctx->buffer, GROESTL_SIZE512);
|
||||
ctx->buf_ptr = 0;
|
||||
}
|
||||
while (ctx->buf_ptr < GROESTL_SIZE512-GROESTL_LENGTHFIELDLEN) {
|
||||
ctx->buffer[(int)ctx->buf_ptr++] = 0;
|
||||
}
|
||||
|
||||
ctx->block_counter1++;
|
||||
if (ctx->block_counter1 == 0) ctx->block_counter2++;
|
||||
ctx->buf_ptr = GROESTL_SIZE512;
|
||||
|
||||
while (ctx->buf_ptr > GROESTL_SIZE512-(int)sizeof(uint32_t)) {
|
||||
ctx->buffer[(int)--ctx->buf_ptr] = (uint8_t)ctx->block_counter1;
|
||||
ctx->block_counter1 >>= 8;
|
||||
}
|
||||
while (ctx->buf_ptr > GROESTL_SIZE512-GROESTL_LENGTHFIELDLEN) {
|
||||
ctx->buffer[(int)--ctx->buf_ptr] = (uint8_t)ctx->block_counter2;
|
||||
ctx->block_counter2 >>= 8;
|
||||
}
|
||||
cn_groestl_transform(ctx, ctx->buffer, GROESTL_SIZE512);
|
||||
cn_groestl_outputtransformation(ctx);
|
||||
|
||||
for (i = GROESTL_SIZE512-hashbytelen; i < GROESTL_SIZE512; i++,j++) {
|
||||
output[j] = s[i];
|
||||
}
|
||||
#if 0
|
||||
for (i = 0; i < GROESTL_COLS512; i++) {
|
||||
ctx->chaining[i] = 0;
|
||||
}
|
||||
for (i = 0; i < GROESTL_SIZE512; i++) {
|
||||
ctx->buffer[i] = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_groestl_update(groestlHashState* __restrict__ ctx,
|
||||
const BitSequence* __restrict__ input, DataLength databitlen)
|
||||
{
|
||||
int index = 0;
|
||||
int msglen = (int)(databitlen/8);
|
||||
int rem = (int)(databitlen%8);
|
||||
|
||||
if (ctx->buf_ptr) {
|
||||
while (ctx->buf_ptr < GROESTL_SIZE512 && index < msglen) {
|
||||
ctx->buffer[(int)ctx->buf_ptr++] = input[index++];
|
||||
}
|
||||
if (ctx->buf_ptr < GROESTL_SIZE512) {
|
||||
if (rem) {
|
||||
ctx->bits_in_last_byte = rem;
|
||||
ctx->buffer[(int)ctx->buf_ptr++] = input[index];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->buf_ptr = 0;
|
||||
cn_groestl_transform(ctx, ctx->buffer, GROESTL_SIZE512);
|
||||
}
|
||||
|
||||
cn_groestl_transform(ctx, input+index, msglen-index);
|
||||
index += ((msglen-index)/GROESTL_SIZE512)*GROESTL_SIZE512;
|
||||
|
||||
while (index < msglen) {
|
||||
ctx->buffer[(int)ctx->buf_ptr++] = input[index++];
|
||||
}
|
||||
|
||||
if (rem) {
|
||||
ctx->bits_in_last_byte = rem;
|
||||
ctx->buffer[(int)ctx->buf_ptr++] = input[index];
|
||||
}
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_groestl_init(groestlHashState* ctx)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for(;i<(GROESTL_SIZE512/sizeof(uint32_t));i++)
|
||||
ctx->chaining[i] = 0;
|
||||
|
||||
ctx->chaining[2*GROESTL_COLS512-1] = u32BIG((uint32_t)GROESTL_HASH_BIT_LEN);
|
||||
ctx->buf_ptr = 0;
|
||||
ctx->block_counter1 = 0;
|
||||
ctx->block_counter2 = 0;
|
||||
ctx->bits_in_last_byte = 0;
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_groestl(const uint8_t * __restrict__ data, DataLength len, uint32_t * hashval)
|
||||
{
|
||||
DataLength databitlen = len << 3;
|
||||
groestlHashState context;
|
||||
|
||||
cn_groestl_init(&context);
|
||||
cn_groestl_update(&context, (BitSequence*) data, databitlen);
|
||||
cn_groestl_final(&context, (BitSequence*) hashval);
|
||||
}
|
||||
@@ -1,296 +0,0 @@
|
||||
|
||||
typedef struct {
|
||||
int hashbitlen;
|
||||
unsigned long long databitlen;
|
||||
unsigned long long datasize_in_buffer;
|
||||
uint64_t x[8][2];
|
||||
unsigned char buffer[64];
|
||||
} jhHashState;
|
||||
|
||||
__constant__ unsigned char d_JH256_H0[512] = {
|
||||
0xeb, 0x98, 0xa3, 0x41, 0x2c, 0x20, 0xd3, 0xeb, 0x92, 0xcd, 0xbe, 0x7b, 0x9c, 0xb2, 0x45, 0xc1,
|
||||
0x1c, 0x93, 0x51, 0x91, 0x60, 0xd4, 0xc7, 0xfa, 0x26, 0x0, 0x82, 0xd6, 0x7e, 0x50, 0x8a, 0x3,
|
||||
0xa4, 0x23, 0x9e, 0x26, 0x77, 0x26, 0xb9, 0x45, 0xe0, 0xfb, 0x1a, 0x48, 0xd4, 0x1a, 0x94, 0x77,
|
||||
0xcd, 0xb5, 0xab, 0x26, 0x2, 0x6b, 0x17, 0x7a, 0x56, 0xf0, 0x24, 0x42, 0xf, 0xff, 0x2f, 0xa8,
|
||||
0x71, 0xa3, 0x96, 0x89, 0x7f, 0x2e, 0x4d, 0x75, 0x1d, 0x14, 0x49, 0x8, 0xf7, 0x7d, 0xe2, 0x62,
|
||||
0x27, 0x76, 0x95, 0xf7, 0x76, 0x24, 0x8f, 0x94, 0x87, 0xd5, 0xb6, 0x57, 0x47, 0x80, 0x29, 0x6c,
|
||||
0x5c, 0x5e, 0x27, 0x2d, 0xac, 0x8e, 0xd, 0x6c, 0x51, 0x84, 0x50, 0xc6, 0x57, 0x5, 0x7a, 0xf,
|
||||
0x7b, 0xe4, 0xd3, 0x67, 0x70, 0x24, 0x12, 0xea, 0x89, 0xe3, 0xab, 0x13, 0xd3, 0x1c, 0xd7, 0x69
|
||||
};
|
||||
|
||||
__constant__ unsigned char d_E8_rc[42][32] = {
|
||||
{0x72, 0xd5, 0xde, 0xa2, 0xdf, 0x15, 0xf8, 0x67, 0x7b, 0x84, 0x15, 0xa, 0xb7, 0x23, 0x15, 0x57, 0x81, 0xab, 0xd6, 0x90, 0x4d, 0x5a, 0x87, 0xf6, 0x4e, 0x9f, 0x4f, 0xc5, 0xc3, 0xd1, 0x2b, 0x40},
|
||||
{0xea, 0x98, 0x3a, 0xe0, 0x5c, 0x45, 0xfa, 0x9c, 0x3, 0xc5, 0xd2, 0x99, 0x66, 0xb2, 0x99, 0x9a, 0x66, 0x2, 0x96, 0xb4, 0xf2, 0xbb, 0x53, 0x8a, 0xb5, 0x56, 0x14, 0x1a, 0x88, 0xdb, 0xa2, 0x31},
|
||||
{0x3, 0xa3, 0x5a, 0x5c, 0x9a, 0x19, 0xe, 0xdb, 0x40, 0x3f, 0xb2, 0xa, 0x87, 0xc1, 0x44, 0x10, 0x1c, 0x5, 0x19, 0x80, 0x84, 0x9e, 0x95, 0x1d, 0x6f, 0x33, 0xeb, 0xad, 0x5e, 0xe7, 0xcd, 0xdc},
|
||||
{0x10, 0xba, 0x13, 0x92, 0x2, 0xbf, 0x6b, 0x41, 0xdc, 0x78, 0x65, 0x15, 0xf7, 0xbb, 0x27, 0xd0, 0xa, 0x2c, 0x81, 0x39, 0x37, 0xaa, 0x78, 0x50, 0x3f, 0x1a, 0xbf, 0xd2, 0x41, 0x0, 0x91, 0xd3},
|
||||
{0x42, 0x2d, 0x5a, 0xd, 0xf6, 0xcc, 0x7e, 0x90, 0xdd, 0x62, 0x9f, 0x9c, 0x92, 0xc0, 0x97, 0xce, 0x18, 0x5c, 0xa7, 0xb, 0xc7, 0x2b, 0x44, 0xac, 0xd1, 0xdf, 0x65, 0xd6, 0x63, 0xc6, 0xfc, 0x23},
|
||||
{0x97, 0x6e, 0x6c, 0x3, 0x9e, 0xe0, 0xb8, 0x1a, 0x21, 0x5, 0x45, 0x7e, 0x44, 0x6c, 0xec, 0xa8, 0xee, 0xf1, 0x3, 0xbb, 0x5d, 0x8e, 0x61, 0xfa, 0xfd, 0x96, 0x97, 0xb2, 0x94, 0x83, 0x81, 0x97},
|
||||
{0x4a, 0x8e, 0x85, 0x37, 0xdb, 0x3, 0x30, 0x2f, 0x2a, 0x67, 0x8d, 0x2d, 0xfb, 0x9f, 0x6a, 0x95, 0x8a, 0xfe, 0x73, 0x81, 0xf8, 0xb8, 0x69, 0x6c, 0x8a, 0xc7, 0x72, 0x46, 0xc0, 0x7f, 0x42, 0x14},
|
||||
{0xc5, 0xf4, 0x15, 0x8f, 0xbd, 0xc7, 0x5e, 0xc4, 0x75, 0x44, 0x6f, 0xa7, 0x8f, 0x11, 0xbb, 0x80, 0x52, 0xde, 0x75, 0xb7, 0xae, 0xe4, 0x88, 0xbc, 0x82, 0xb8, 0x0, 0x1e, 0x98, 0xa6, 0xa3, 0xf4},
|
||||
{0x8e, 0xf4, 0x8f, 0x33, 0xa9, 0xa3, 0x63, 0x15, 0xaa, 0x5f, 0x56, 0x24, 0xd5, 0xb7, 0xf9, 0x89, 0xb6, 0xf1, 0xed, 0x20, 0x7c, 0x5a, 0xe0, 0xfd, 0x36, 0xca, 0xe9, 0x5a, 0x6, 0x42, 0x2c, 0x36},
|
||||
{0xce, 0x29, 0x35, 0x43, 0x4e, 0xfe, 0x98, 0x3d, 0x53, 0x3a, 0xf9, 0x74, 0x73, 0x9a, 0x4b, 0xa7, 0xd0, 0xf5, 0x1f, 0x59, 0x6f, 0x4e, 0x81, 0x86, 0xe, 0x9d, 0xad, 0x81, 0xaf, 0xd8, 0x5a, 0x9f},
|
||||
{0xa7, 0x5, 0x6, 0x67, 0xee, 0x34, 0x62, 0x6a, 0x8b, 0xb, 0x28, 0xbe, 0x6e, 0xb9, 0x17, 0x27, 0x47, 0x74, 0x7, 0x26, 0xc6, 0x80, 0x10, 0x3f, 0xe0, 0xa0, 0x7e, 0x6f, 0xc6, 0x7e, 0x48, 0x7b},
|
||||
{0xd, 0x55, 0xa, 0xa5, 0x4a, 0xf8, 0xa4, 0xc0, 0x91, 0xe3, 0xe7, 0x9f, 0x97, 0x8e, 0xf1, 0x9e, 0x86, 0x76, 0x72, 0x81, 0x50, 0x60, 0x8d, 0xd4, 0x7e, 0x9e, 0x5a, 0x41, 0xf3, 0xe5, 0xb0, 0x62},
|
||||
{0xfc, 0x9f, 0x1f, 0xec, 0x40, 0x54, 0x20, 0x7a, 0xe3, 0xe4, 0x1a, 0x0, 0xce, 0xf4, 0xc9, 0x84, 0x4f, 0xd7, 0x94, 0xf5, 0x9d, 0xfa, 0x95, 0xd8, 0x55, 0x2e, 0x7e, 0x11, 0x24, 0xc3, 0x54, 0xa5},
|
||||
{0x5b, 0xdf, 0x72, 0x28, 0xbd, 0xfe, 0x6e, 0x28, 0x78, 0xf5, 0x7f, 0xe2, 0xf, 0xa5, 0xc4, 0xb2, 0x5, 0x89, 0x7c, 0xef, 0xee, 0x49, 0xd3, 0x2e, 0x44, 0x7e, 0x93, 0x85, 0xeb, 0x28, 0x59, 0x7f},
|
||||
{0x70, 0x5f, 0x69, 0x37, 0xb3, 0x24, 0x31, 0x4a, 0x5e, 0x86, 0x28, 0xf1, 0x1d, 0xd6, 0xe4, 0x65, 0xc7, 0x1b, 0x77, 0x4, 0x51, 0xb9, 0x20, 0xe7, 0x74, 0xfe, 0x43, 0xe8, 0x23, 0xd4, 0x87, 0x8a},
|
||||
{0x7d, 0x29, 0xe8, 0xa3, 0x92, 0x76, 0x94, 0xf2, 0xdd, 0xcb, 0x7a, 0x9, 0x9b, 0x30, 0xd9, 0xc1, 0x1d, 0x1b, 0x30, 0xfb, 0x5b, 0xdc, 0x1b, 0xe0, 0xda, 0x24, 0x49, 0x4f, 0xf2, 0x9c, 0x82, 0xbf},
|
||||
{0xa4, 0xe7, 0xba, 0x31, 0xb4, 0x70, 0xbf, 0xff, 0xd, 0x32, 0x44, 0x5, 0xde, 0xf8, 0xbc, 0x48, 0x3b, 0xae, 0xfc, 0x32, 0x53, 0xbb, 0xd3, 0x39, 0x45, 0x9f, 0xc3, 0xc1, 0xe0, 0x29, 0x8b, 0xa0},
|
||||
{0xe5, 0xc9, 0x5, 0xfd, 0xf7, 0xae, 0x9, 0xf, 0x94, 0x70, 0x34, 0x12, 0x42, 0x90, 0xf1, 0x34, 0xa2, 0x71, 0xb7, 0x1, 0xe3, 0x44, 0xed, 0x95, 0xe9, 0x3b, 0x8e, 0x36, 0x4f, 0x2f, 0x98, 0x4a},
|
||||
{0x88, 0x40, 0x1d, 0x63, 0xa0, 0x6c, 0xf6, 0x15, 0x47, 0xc1, 0x44, 0x4b, 0x87, 0x52, 0xaf, 0xff, 0x7e, 0xbb, 0x4a, 0xf1, 0xe2, 0xa, 0xc6, 0x30, 0x46, 0x70, 0xb6, 0xc5, 0xcc, 0x6e, 0x8c, 0xe6},
|
||||
{0xa4, 0xd5, 0xa4, 0x56, 0xbd, 0x4f, 0xca, 0x0, 0xda, 0x9d, 0x84, 0x4b, 0xc8, 0x3e, 0x18, 0xae, 0x73, 0x57, 0xce, 0x45, 0x30, 0x64, 0xd1, 0xad, 0xe8, 0xa6, 0xce, 0x68, 0x14, 0x5c, 0x25, 0x67},
|
||||
{0xa3, 0xda, 0x8c, 0xf2, 0xcb, 0xe, 0xe1, 0x16, 0x33, 0xe9, 0x6, 0x58, 0x9a, 0x94, 0x99, 0x9a, 0x1f, 0x60, 0xb2, 0x20, 0xc2, 0x6f, 0x84, 0x7b, 0xd1, 0xce, 0xac, 0x7f, 0xa0, 0xd1, 0x85, 0x18},
|
||||
{0x32, 0x59, 0x5b, 0xa1, 0x8d, 0xdd, 0x19, 0xd3, 0x50, 0x9a, 0x1c, 0xc0, 0xaa, 0xa5, 0xb4, 0x46, 0x9f, 0x3d, 0x63, 0x67, 0xe4, 0x4, 0x6b, 0xba, 0xf6, 0xca, 0x19, 0xab, 0xb, 0x56, 0xee, 0x7e},
|
||||
{0x1f, 0xb1, 0x79, 0xea, 0xa9, 0x28, 0x21, 0x74, 0xe9, 0xbd, 0xf7, 0x35, 0x3b, 0x36, 0x51, 0xee, 0x1d, 0x57, 0xac, 0x5a, 0x75, 0x50, 0xd3, 0x76, 0x3a, 0x46, 0xc2, 0xfe, 0xa3, 0x7d, 0x70, 0x1},
|
||||
{0xf7, 0x35, 0xc1, 0xaf, 0x98, 0xa4, 0xd8, 0x42, 0x78, 0xed, 0xec, 0x20, 0x9e, 0x6b, 0x67, 0x79, 0x41, 0x83, 0x63, 0x15, 0xea, 0x3a, 0xdb, 0xa8, 0xfa, 0xc3, 0x3b, 0x4d, 0x32, 0x83, 0x2c, 0x83},
|
||||
{0xa7, 0x40, 0x3b, 0x1f, 0x1c, 0x27, 0x47, 0xf3, 0x59, 0x40, 0xf0, 0x34, 0xb7, 0x2d, 0x76, 0x9a, 0xe7, 0x3e, 0x4e, 0x6c, 0xd2, 0x21, 0x4f, 0xfd, 0xb8, 0xfd, 0x8d, 0x39, 0xdc, 0x57, 0x59, 0xef},
|
||||
{0x8d, 0x9b, 0xc, 0x49, 0x2b, 0x49, 0xeb, 0xda, 0x5b, 0xa2, 0xd7, 0x49, 0x68, 0xf3, 0x70, 0xd, 0x7d, 0x3b, 0xae, 0xd0, 0x7a, 0x8d, 0x55, 0x84, 0xf5, 0xa5, 0xe9, 0xf0, 0xe4, 0xf8, 0x8e, 0x65},
|
||||
{0xa0, 0xb8, 0xa2, 0xf4, 0x36, 0x10, 0x3b, 0x53, 0xc, 0xa8, 0x7, 0x9e, 0x75, 0x3e, 0xec, 0x5a, 0x91, 0x68, 0x94, 0x92, 0x56, 0xe8, 0x88, 0x4f, 0x5b, 0xb0, 0x5c, 0x55, 0xf8, 0xba, 0xbc, 0x4c},
|
||||
{0xe3, 0xbb, 0x3b, 0x99, 0xf3, 0x87, 0x94, 0x7b, 0x75, 0xda, 0xf4, 0xd6, 0x72, 0x6b, 0x1c, 0x5d, 0x64, 0xae, 0xac, 0x28, 0xdc, 0x34, 0xb3, 0x6d, 0x6c, 0x34, 0xa5, 0x50, 0xb8, 0x28, 0xdb, 0x71},
|
||||
{0xf8, 0x61, 0xe2, 0xf2, 0x10, 0x8d, 0x51, 0x2a, 0xe3, 0xdb, 0x64, 0x33, 0x59, 0xdd, 0x75, 0xfc, 0x1c, 0xac, 0xbc, 0xf1, 0x43, 0xce, 0x3f, 0xa2, 0x67, 0xbb, 0xd1, 0x3c, 0x2, 0xe8, 0x43, 0xb0},
|
||||
{0x33, 0xa, 0x5b, 0xca, 0x88, 0x29, 0xa1, 0x75, 0x7f, 0x34, 0x19, 0x4d, 0xb4, 0x16, 0x53, 0x5c, 0x92, 0x3b, 0x94, 0xc3, 0xe, 0x79, 0x4d, 0x1e, 0x79, 0x74, 0x75, 0xd7, 0xb6, 0xee, 0xaf, 0x3f},
|
||||
{0xea, 0xa8, 0xd4, 0xf7, 0xbe, 0x1a, 0x39, 0x21, 0x5c, 0xf4, 0x7e, 0x9, 0x4c, 0x23, 0x27, 0x51, 0x26, 0xa3, 0x24, 0x53, 0xba, 0x32, 0x3c, 0xd2, 0x44, 0xa3, 0x17, 0x4a, 0x6d, 0xa6, 0xd5, 0xad},
|
||||
{0xb5, 0x1d, 0x3e, 0xa6, 0xaf, 0xf2, 0xc9, 0x8, 0x83, 0x59, 0x3d, 0x98, 0x91, 0x6b, 0x3c, 0x56, 0x4c, 0xf8, 0x7c, 0xa1, 0x72, 0x86, 0x60, 0x4d, 0x46, 0xe2, 0x3e, 0xcc, 0x8, 0x6e, 0xc7, 0xf6},
|
||||
{0x2f, 0x98, 0x33, 0xb3, 0xb1, 0xbc, 0x76, 0x5e, 0x2b, 0xd6, 0x66, 0xa5, 0xef, 0xc4, 0xe6, 0x2a, 0x6, 0xf4, 0xb6, 0xe8, 0xbe, 0xc1, 0xd4, 0x36, 0x74, 0xee, 0x82, 0x15, 0xbc, 0xef, 0x21, 0x63},
|
||||
{0xfd, 0xc1, 0x4e, 0xd, 0xf4, 0x53, 0xc9, 0x69, 0xa7, 0x7d, 0x5a, 0xc4, 0x6, 0x58, 0x58, 0x26, 0x7e, 0xc1, 0x14, 0x16, 0x6, 0xe0, 0xfa, 0x16, 0x7e, 0x90, 0xaf, 0x3d, 0x28, 0x63, 0x9d, 0x3f},
|
||||
{0xd2, 0xc9, 0xf2, 0xe3, 0x0, 0x9b, 0xd2, 0xc, 0x5f, 0xaa, 0xce, 0x30, 0xb7, 0xd4, 0xc, 0x30, 0x74, 0x2a, 0x51, 0x16, 0xf2, 0xe0, 0x32, 0x98, 0xd, 0xeb, 0x30, 0xd8, 0xe3, 0xce, 0xf8, 0x9a},
|
||||
{0x4b, 0xc5, 0x9e, 0x7b, 0xb5, 0xf1, 0x79, 0x92, 0xff, 0x51, 0xe6, 0x6e, 0x4, 0x86, 0x68, 0xd3, 0x9b, 0x23, 0x4d, 0x57, 0xe6, 0x96, 0x67, 0x31, 0xcc, 0xe6, 0xa6, 0xf3, 0x17, 0xa, 0x75, 0x5},
|
||||
{0xb1, 0x76, 0x81, 0xd9, 0x13, 0x32, 0x6c, 0xce, 0x3c, 0x17, 0x52, 0x84, 0xf8, 0x5, 0xa2, 0x62, 0xf4, 0x2b, 0xcb, 0xb3, 0x78, 0x47, 0x15, 0x47, 0xff, 0x46, 0x54, 0x82, 0x23, 0x93, 0x6a, 0x48},
|
||||
{0x38, 0xdf, 0x58, 0x7, 0x4e, 0x5e, 0x65, 0x65, 0xf2, 0xfc, 0x7c, 0x89, 0xfc, 0x86, 0x50, 0x8e, 0x31, 0x70, 0x2e, 0x44, 0xd0, 0xb, 0xca, 0x86, 0xf0, 0x40, 0x9, 0xa2, 0x30, 0x78, 0x47, 0x4e},
|
||||
{0x65, 0xa0, 0xee, 0x39, 0xd1, 0xf7, 0x38, 0x83, 0xf7, 0x5e, 0xe9, 0x37, 0xe4, 0x2c, 0x3a, 0xbd, 0x21, 0x97, 0xb2, 0x26, 0x1, 0x13, 0xf8, 0x6f, 0xa3, 0x44, 0xed, 0xd1, 0xef, 0x9f, 0xde, 0xe7},
|
||||
{0x8b, 0xa0, 0xdf, 0x15, 0x76, 0x25, 0x92, 0xd9, 0x3c, 0x85, 0xf7, 0xf6, 0x12, 0xdc, 0x42, 0xbe, 0xd8, 0xa7, 0xec, 0x7c, 0xab, 0x27, 0xb0, 0x7e, 0x53, 0x8d, 0x7d, 0xda, 0xaa, 0x3e, 0xa8, 0xde},
|
||||
{0xaa, 0x25, 0xce, 0x93, 0xbd, 0x2, 0x69, 0xd8, 0x5a, 0xf6, 0x43, 0xfd, 0x1a, 0x73, 0x8, 0xf9, 0xc0, 0x5f, 0xef, 0xda, 0x17, 0x4a, 0x19, 0xa5, 0x97, 0x4d, 0x66, 0x33, 0x4c, 0xfd, 0x21, 0x6a},
|
||||
{0x35, 0xb4, 0x98, 0x31, 0xdb, 0x41, 0x15, 0x70, 0xea, 0x1e, 0xf, 0xbb, 0xed, 0xcd, 0x54, 0x9b, 0x9a, 0xd0, 0x63, 0xa1, 0x51, 0x97, 0x40, 0x72, 0xf6, 0x75, 0x9d, 0xbf, 0x91, 0x47, 0x6f, 0xe2}
|
||||
};
|
||||
|
||||
#define JH_SWAP1(x) (x) = ((((x) & 0x5555555555555555ULL) << 1) | (((x) & 0xaaaaaaaaaaaaaaaaULL) >> 1));
|
||||
#define JH_SWAP2(x) (x) = ((((x) & 0x3333333333333333ULL) << 2) | (((x) & 0xccccccccccccccccULL) >> 2));
|
||||
#define JH_SWAP4(x) (x) = ((((x) & 0x0f0f0f0f0f0f0f0fULL) << 4) | (((x) & 0xf0f0f0f0f0f0f0f0ULL) >> 4));
|
||||
#define JH_SWAP8(x) (x) = ((((x) & 0x00ff00ff00ff00ffULL) << 8) | (((x) & 0xff00ff00ff00ff00ULL) >> 8));
|
||||
#define JH_SWAP16(x) (x) = ((((x) & 0x0000ffff0000ffffULL) << 16) | (((x) & 0xffff0000ffff0000ULL) >> 16));
|
||||
#define JH_SWAP32(x) (x) = (((x) << 32) | ((x) >> 32));
|
||||
|
||||
#define JH_L(m0,m1,m2,m3,m4,m5,m6,m7) \
|
||||
(m4) ^= (m1); \
|
||||
(m5) ^= (m2); \
|
||||
(m6) ^= (m0) ^ (m3); \
|
||||
(m7) ^= (m0); \
|
||||
(m0) ^= (m5); \
|
||||
(m1) ^= (m6); \
|
||||
(m2) ^= (m4) ^ (m7); \
|
||||
(m3) ^= (m4);
|
||||
|
||||
#define JH_SS(m0,m1,m2,m3,m4,m5,m6,m7,cc0,cc1) \
|
||||
m3 = ~(m3); \
|
||||
m7 = ~(m7); \
|
||||
m0 ^= ((~(m2)) & (cc0)); \
|
||||
m4 ^= ((~(m6)) & (cc1)); \
|
||||
temp0 = (cc0) ^ ((m0) & (m1));\
|
||||
temp1 = (cc1) ^ ((m4) & (m5));\
|
||||
m0 ^= ((m2) & (m3)); \
|
||||
m4 ^= ((m6) & (m7)); \
|
||||
m3 ^= ((~(m1)) & (m2)); \
|
||||
m7 ^= ((~(m5)) & (m6)); \
|
||||
m1 ^= ((m0) & (m2)); \
|
||||
m5 ^= ((m4) & (m6)); \
|
||||
m2 ^= ((m0) & (~(m3))); \
|
||||
m6 ^= ((m4) & (~(m7))); \
|
||||
m0 ^= ((m1) | (m3)); \
|
||||
m4 ^= ((m5) | (m7)); \
|
||||
m3 ^= ((m1) & (m2)); \
|
||||
m7 ^= ((m5) & (m6)); \
|
||||
m1 ^= (temp0 & (m0)); \
|
||||
m5 ^= (temp1 & (m4)); \
|
||||
m2 ^= temp0; \
|
||||
m6 ^= temp1;
|
||||
|
||||
__device__
|
||||
void cn_jh_E8(jhHashState *state)
|
||||
{
|
||||
uint64_t i,roundnumber,temp0,temp1;
|
||||
|
||||
for (roundnumber = 0; roundnumber < 42; roundnumber = roundnumber+7)
|
||||
{
|
||||
for (i = 0; i < 2; i++) {
|
||||
JH_SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],
|
||||
((uint64_t *)d_E8_rc[roundnumber+0])[i],((uint64_t *)d_E8_rc[roundnumber+0])[i+2] );
|
||||
JH_L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]);
|
||||
JH_SWAP1(state->x[1][i]); JH_SWAP1(state->x[3][i]); JH_SWAP1(state->x[5][i]); JH_SWAP1(state->x[7][i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
JH_SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],
|
||||
((uint64_t *)d_E8_rc[roundnumber+1])[i],((uint64_t *)d_E8_rc[roundnumber+1])[i+2] );
|
||||
JH_L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]);
|
||||
JH_SWAP2(state->x[1][i]); JH_SWAP2(state->x[3][i]); JH_SWAP2(state->x[5][i]); JH_SWAP2(state->x[7][i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
JH_SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],
|
||||
((uint64_t *)d_E8_rc[roundnumber+2])[i],((uint64_t *)d_E8_rc[roundnumber+2])[i+2] );
|
||||
JH_L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]);
|
||||
JH_SWAP4(state->x[1][i]); JH_SWAP4(state->x[3][i]); JH_SWAP4(state->x[5][i]); JH_SWAP4(state->x[7][i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
JH_SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],
|
||||
((uint64_t *)d_E8_rc[roundnumber+3])[i],((uint64_t *)d_E8_rc[roundnumber+3])[i+2] );
|
||||
JH_L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]);
|
||||
JH_SWAP8(state->x[1][i]); JH_SWAP8(state->x[3][i]); JH_SWAP8(state->x[5][i]); JH_SWAP8(state->x[7][i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
JH_SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],
|
||||
((uint64_t *)d_E8_rc[roundnumber+4])[i],((uint64_t *)d_E8_rc[roundnumber+4])[i+2] );
|
||||
JH_L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]);
|
||||
JH_SWAP16(state->x[1][i]); JH_SWAP16(state->x[3][i]); JH_SWAP16(state->x[5][i]); JH_SWAP16(state->x[7][i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
JH_SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],
|
||||
((uint64_t *)d_E8_rc[roundnumber+5])[i],((uint64_t *)d_E8_rc[roundnumber+5])[i+2] );
|
||||
JH_L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]);
|
||||
JH_SWAP32(state->x[1][i]); JH_SWAP32(state->x[3][i]); JH_SWAP32(state->x[5][i]); JH_SWAP32(state->x[7][i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
JH_SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],
|
||||
((uint64_t *)d_E8_rc[roundnumber+6])[i],((uint64_t *)d_E8_rc[roundnumber+6])[i+2] );
|
||||
JH_L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]);
|
||||
}
|
||||
|
||||
for (i = 1; i < 8; i = i+2) {
|
||||
temp0 = state->x[i][0]; state->x[i][0] = state->x[i][1]; state->x[i][1] = temp0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_jh_F8(jhHashState *state)
|
||||
{
|
||||
uint64_t i;
|
||||
for (i = 0; i < 8; i++) {
|
||||
state->x[i >> 1][i & 1] ^= ((uint64_t *)state->buffer)[i];
|
||||
}
|
||||
|
||||
cn_jh_E8(state);
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
state->x[(8+i) >> 1][(8+i) & 1] ^= ((uint64_t *)state->buffer)[i];
|
||||
}
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_jh_update(jhHashState * __restrict__ state, const uint8_t * __restrict__ data, DataLength databitlen)
|
||||
{
|
||||
DataLength index;
|
||||
|
||||
state->databitlen += databitlen;
|
||||
index = 0;
|
||||
|
||||
if ( (state->datasize_in_buffer > 0 ) && (( state->datasize_in_buffer + databitlen) < 512) )
|
||||
{
|
||||
if ( (databitlen & 7) == 0 ) {
|
||||
memcpy(state->buffer + (state->datasize_in_buffer >> 3), data, 64-(state->datasize_in_buffer >> 3));
|
||||
}
|
||||
else memcpy(state->buffer + (state->datasize_in_buffer >> 3), data, 64-(state->datasize_in_buffer >> 3)+1);
|
||||
state->datasize_in_buffer += databitlen;
|
||||
databitlen = 0;
|
||||
}
|
||||
|
||||
if ( (state->datasize_in_buffer > 0 ) && (( state->datasize_in_buffer + databitlen) >= 512) )
|
||||
{
|
||||
memcpy( state->buffer + (state->datasize_in_buffer >> 3), data, 64-(state->datasize_in_buffer >> 3) );
|
||||
index = 64-(state->datasize_in_buffer >> 3);
|
||||
databitlen = databitlen - (512 - state->datasize_in_buffer);
|
||||
cn_jh_F8(state);
|
||||
state->datasize_in_buffer = 0;
|
||||
}
|
||||
|
||||
for ( ; databitlen >= 512; index = index+64, databitlen = databitlen - 512) {
|
||||
memcpy(state->buffer, data+index, 64);
|
||||
cn_jh_F8(state);
|
||||
}
|
||||
|
||||
if ( databitlen > 0) {
|
||||
if ((databitlen & 7) == 0)
|
||||
memcpy(state->buffer, data+index, (databitlen & 0x1ff) >> 3);
|
||||
else
|
||||
memcpy(state->buffer, data+index, ((databitlen & 0x1ff) >> 3)+1);
|
||||
state->datasize_in_buffer = databitlen;
|
||||
}
|
||||
}
|
||||
|
||||
/* pad the message, process the padded block(s), truncate the hash value H to obtain the message digest */
|
||||
__device__
|
||||
void cn_jh_final(jhHashState * __restrict__ state, uint8_t * __restrict__ hashval)
|
||||
{
|
||||
unsigned int i;
|
||||
//uint32_t *bufptr = (uint32_t *)state->buffer;
|
||||
|
||||
if ( (state->databitlen & 0x1ff) == 0 ) {
|
||||
/* pad the message when databitlen is multiple of 512 bits, then process the padded block */
|
||||
memset(state->buffer, 0, 64);
|
||||
//for( i = 0; i < 16; i++ ) *(bufptr+i) = 0x00000000;
|
||||
state->buffer[0] = 0x80;
|
||||
state->buffer[63] = state->databitlen & 0xff;
|
||||
state->buffer[62] = (state->databitlen >> 8) & 0xff;
|
||||
state->buffer[61] = (state->databitlen >> 16) & 0xff;
|
||||
state->buffer[60] = (state->databitlen >> 24) & 0xff;
|
||||
state->buffer[59] = (state->databitlen >> 32) & 0xff;
|
||||
state->buffer[58] = (state->databitlen >> 40) & 0xff;
|
||||
state->buffer[57] = (state->databitlen >> 48) & 0xff;
|
||||
state->buffer[56] = (state->databitlen >> 56) & 0xff;
|
||||
cn_jh_F8(state);
|
||||
|
||||
} else {
|
||||
|
||||
/* set the rest of the bytes in the buffer to 0 */
|
||||
if ( (state->datasize_in_buffer & 7) == 0) {
|
||||
for (i = (state->databitlen & 0x1ff) >> 3; i < 64; i++) state->buffer[i] = 0;
|
||||
} else {
|
||||
for (i = ((state->databitlen & 0x1ff) >> 3)+1; i < 64; i++) state->buffer[i] = 0;
|
||||
}
|
||||
|
||||
/*pad and process the partial block when databitlen is not multiple of 512 bits, then hash the padded blocks*/
|
||||
state->buffer[((state->databitlen & 0x1ff) >> 3)] |= 1 << (7- (state->databitlen & 7));
|
||||
|
||||
cn_jh_F8(state);
|
||||
memset(state->buffer, 0, 64);
|
||||
//for( i = 0; i < 16; i++ ) *(bufptr+i) = 0x00000000;
|
||||
state->buffer[63] = state->databitlen & 0xff;
|
||||
state->buffer[62] = (state->databitlen >> 8) & 0xff;
|
||||
state->buffer[61] = (state->databitlen >> 16) & 0xff;
|
||||
state->buffer[60] = (state->databitlen >> 24) & 0xff;
|
||||
state->buffer[59] = (state->databitlen >> 32) & 0xff;
|
||||
state->buffer[58] = (state->databitlen >> 40) & 0xff;
|
||||
state->buffer[57] = (state->databitlen >> 48) & 0xff;
|
||||
state->buffer[56] = (state->databitlen >> 56) & 0xff;
|
||||
cn_jh_F8(state);
|
||||
}
|
||||
|
||||
memcpy(hashval, ((unsigned char*)state->x) + 64 + 32, 32);
|
||||
//MEMCPY4(hashval, ((unsigned char*)state->x) + 64 + 32, 8);
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_jh_init(jhHashState *state, int hashbitlen)
|
||||
{
|
||||
state->databitlen = 0;
|
||||
state->datasize_in_buffer = 0;
|
||||
state->hashbitlen = hashbitlen;
|
||||
memcpy(state->x, d_JH256_H0, 128);
|
||||
//MEMCPY8(state->x, d_JH256_H0, 128 / 8);
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_jh(const uint8_t * __restrict__ data, DataLength len, uint32_t * hashval)
|
||||
{
|
||||
const int hashbitlen = 256;
|
||||
DataLength databitlen = len << 3;
|
||||
jhHashState state;
|
||||
|
||||
cn_jh_init(&state, hashbitlen);
|
||||
cn_jh_update(&state, data, databitlen);
|
||||
cn_jh_final(&state, (uint8_t*) hashval);
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
__constant__ uint64_t keccakf_rndc[24] = {
|
||||
0x0000000000000001, 0x0000000000008082, 0x800000000000808a,
|
||||
0x8000000080008000, 0x000000000000808b, 0x0000000080000001,
|
||||
0x8000000080008081, 0x8000000000008009, 0x000000000000008a,
|
||||
0x0000000000000088, 0x0000000080008009, 0x000000008000000a,
|
||||
0x000000008000808b, 0x800000000000008b, 0x8000000000008089,
|
||||
0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
|
||||
0x000000000000800a, 0x800000008000000a, 0x8000000080008081,
|
||||
0x8000000000008080, 0x0000000080000001, 0x8000000080008008
|
||||
};
|
||||
|
||||
#if __CUDA_ARCH__ >= 350
|
||||
__forceinline__ __device__ uint64_t cuda_rotl64(const uint64_t value, const int offset)
|
||||
{
|
||||
uint2 result;
|
||||
if(offset >= 32)
|
||||
{
|
||||
asm("shf.l.wrap.b32 %0, %1, %2, %3;" : "=r"(result.x) : "r"(__double2loint(__longlong_as_double(value))), "r"(__double2hiint(__longlong_as_double(value))), "r"(offset));
|
||||
asm("shf.l.wrap.b32 %0, %1, %2, %3;" : "=r"(result.y) : "r"(__double2hiint(__longlong_as_double(value))), "r"(__double2loint(__longlong_as_double(value))), "r"(offset));
|
||||
}
|
||||
else
|
||||
{
|
||||
asm("shf.l.wrap.b32 %0, %1, %2, %3;" : "=r"(result.x) : "r"(__double2hiint(__longlong_as_double(value))), "r"(__double2loint(__longlong_as_double(value))), "r"(offset));
|
||||
asm("shf.l.wrap.b32 %0, %1, %2, %3;" : "=r"(result.y) : "r"(__double2loint(__longlong_as_double(value))), "r"(__double2hiint(__longlong_as_double(value))), "r"(offset));
|
||||
}
|
||||
return __double_as_longlong(__hiloint2double(result.y, result.x));
|
||||
}
|
||||
#define rotl64_1(x, y) (cuda_rotl64((x), (y)))
|
||||
#else
|
||||
#define rotl64_1(x, y) ((x) << (y) | ((x) >> (64 - (y))))
|
||||
#endif
|
||||
|
||||
#define rotl64_2(x, y) rotl64_1(((x) >> 32) | ((x) << 32), (y))
|
||||
#define bitselect(a, b, c) ((a) ^ ((c) & ((b) ^ (a))))
|
||||
|
||||
__device__ __forceinline__
|
||||
void cn_keccakf2(uint64_t *s)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
for(i = 0; i < 24; ++i)
|
||||
{
|
||||
uint64_t bc[5], tmpxor[5], tmp1, tmp2;
|
||||
|
||||
tmpxor[0] = s[0] ^ s[5] ^ s[10] ^ s[15] ^ s[20];
|
||||
tmpxor[1] = s[1] ^ s[6] ^ s[11] ^ s[16] ^ s[21];
|
||||
tmpxor[2] = s[2] ^ s[7] ^ s[12] ^ s[17] ^ s[22];
|
||||
tmpxor[3] = s[3] ^ s[8] ^ s[13] ^ s[18] ^ s[23];
|
||||
tmpxor[4] = s[4] ^ s[9] ^ s[14] ^ s[19] ^ s[24];
|
||||
|
||||
bc[0] = tmpxor[0] ^ rotl64_1(tmpxor[2], 1);
|
||||
bc[1] = tmpxor[1] ^ rotl64_1(tmpxor[3], 1);
|
||||
bc[2] = tmpxor[2] ^ rotl64_1(tmpxor[4], 1);
|
||||
bc[3] = tmpxor[3] ^ rotl64_1(tmpxor[0], 1);
|
||||
bc[4] = tmpxor[4] ^ rotl64_1(tmpxor[1], 1);
|
||||
|
||||
tmp1 = s[1] ^ bc[0];
|
||||
|
||||
s[0] ^= bc[4];
|
||||
s[1] = rotl64_2(s[6] ^ bc[0], 12);
|
||||
s[6] = rotl64_1(s[9] ^ bc[3], 20);
|
||||
s[9] = rotl64_2(s[22] ^ bc[1], 29);
|
||||
s[22] = rotl64_2(s[14] ^ bc[3], 7);
|
||||
s[14] = rotl64_1(s[20] ^ bc[4], 18);
|
||||
s[20] = rotl64_2(s[2] ^ bc[1], 30);
|
||||
s[2] = rotl64_2(s[12] ^ bc[1], 11);
|
||||
s[12] = rotl64_1(s[13] ^ bc[2], 25);
|
||||
s[13] = rotl64_1(s[19] ^ bc[3], 8);
|
||||
s[19] = rotl64_2(s[23] ^ bc[2], 24);
|
||||
s[23] = rotl64_2(s[15] ^ bc[4], 9);
|
||||
s[15] = rotl64_1(s[4] ^ bc[3], 27);
|
||||
s[4] = rotl64_1(s[24] ^ bc[3], 14);
|
||||
s[24] = rotl64_1(s[21] ^ bc[0], 2);
|
||||
s[21] = rotl64_2(s[8] ^ bc[2], 23);
|
||||
s[8] = rotl64_2(s[16] ^ bc[0], 13);
|
||||
s[16] = rotl64_2(s[5] ^ bc[4], 4);
|
||||
s[5] = rotl64_1(s[3] ^ bc[2], 28);
|
||||
s[3] = rotl64_1(s[18] ^ bc[2], 21);
|
||||
s[18] = rotl64_1(s[17] ^ bc[1], 15);
|
||||
s[17] = rotl64_1(s[11] ^ bc[0], 10);
|
||||
s[11] = rotl64_1(s[7] ^ bc[1], 6);
|
||||
s[7] = rotl64_1(s[10] ^ bc[4], 3);
|
||||
s[10] = rotl64_1(tmp1, 1);
|
||||
|
||||
tmp1 = s[0]; tmp2 = s[1]; s[0] = bitselect(s[0] ^ s[2], s[0], s[1]); s[1] = bitselect(s[1] ^ s[3], s[1], s[2]); s[2] = bitselect(s[2] ^ s[4], s[2], s[3]); s[3] = bitselect(s[3] ^ tmp1, s[3], s[4]); s[4] = bitselect(s[4] ^ tmp2, s[4], tmp1);
|
||||
tmp1 = s[5]; tmp2 = s[6]; s[5] = bitselect(s[5] ^ s[7], s[5], s[6]); s[6] = bitselect(s[6] ^ s[8], s[6], s[7]); s[7] = bitselect(s[7] ^ s[9], s[7], s[8]); s[8] = bitselect(s[8] ^ tmp1, s[8], s[9]); s[9] = bitselect(s[9] ^ tmp2, s[9], tmp1);
|
||||
tmp1 = s[10]; tmp2 = s[11]; s[10] = bitselect(s[10] ^ s[12], s[10], s[11]); s[11] = bitselect(s[11] ^ s[13], s[11], s[12]); s[12] = bitselect(s[12] ^ s[14], s[12], s[13]); s[13] = bitselect(s[13] ^ tmp1, s[13], s[14]); s[14] = bitselect(s[14] ^ tmp2, s[14], tmp1);
|
||||
tmp1 = s[15]; tmp2 = s[16]; s[15] = bitselect(s[15] ^ s[17], s[15], s[16]); s[16] = bitselect(s[16] ^ s[18], s[16], s[17]); s[17] = bitselect(s[17] ^ s[19], s[17], s[18]); s[18] = bitselect(s[18] ^ tmp1, s[18], s[19]); s[19] = bitselect(s[19] ^ tmp2, s[19], tmp1);
|
||||
tmp1 = s[20]; tmp2 = s[21]; s[20] = bitselect(s[20] ^ s[22], s[20], s[21]); s[21] = bitselect(s[21] ^ s[23], s[21], s[22]); s[22] = bitselect(s[22] ^ s[24], s[22], s[23]); s[23] = bitselect(s[23] ^ tmp1, s[23], s[24]); s[24] = bitselect(s[24] ^ tmp2, s[24], tmp1);
|
||||
s[0] ^= keccakf_rndc[i];
|
||||
}
|
||||
}
|
||||
|
||||
__device__ __forceinline__
|
||||
void cn_keccakf(uint64_t *s)
|
||||
{
|
||||
uint64_t bc[5], tmpxor[5], tmp1, tmp2;
|
||||
|
||||
tmpxor[0] = s[0] ^ s[5];
|
||||
tmpxor[1] = s[1] ^ s[6] ^ 0x8000000000000000ULL;
|
||||
tmpxor[2] = s[2] ^ s[7];
|
||||
tmpxor[3] = s[3] ^ s[8];
|
||||
tmpxor[4] = s[4] ^ s[9];
|
||||
|
||||
bc[0] = tmpxor[0] ^ rotl64_1(tmpxor[2], 1);
|
||||
bc[1] = tmpxor[1] ^ rotl64_1(tmpxor[3], 1);
|
||||
bc[2] = tmpxor[2] ^ rotl64_1(tmpxor[4], 1);
|
||||
bc[3] = tmpxor[3] ^ rotl64_1(tmpxor[0], 1);
|
||||
bc[4] = tmpxor[4] ^ rotl64_1(tmpxor[1], 1);
|
||||
|
||||
tmp1 = s[1] ^ bc[0];
|
||||
|
||||
s[0] ^= bc[4];
|
||||
s[1] = rotl64_2(s[6] ^ bc[0], 12);
|
||||
s[6] = rotl64_1(s[9] ^ bc[3], 20);
|
||||
s[9] = rotl64_2(bc[1], 29);
|
||||
s[22] = rotl64_2(bc[3], 7);
|
||||
s[14] = rotl64_1(bc[4], 18);
|
||||
s[20] = rotl64_2(s[2] ^ bc[1], 30);
|
||||
s[2] = rotl64_2(bc[1], 11);
|
||||
s[12] = rotl64_1(bc[2], 25);
|
||||
s[13] = rotl64_1(bc[3], 8);
|
||||
s[19] = rotl64_2(bc[2], 24);
|
||||
s[23] = rotl64_2(bc[4], 9);
|
||||
s[15] = rotl64_1(s[4] ^ bc[3], 27);
|
||||
s[4] = rotl64_1(bc[3], 14);
|
||||
s[24] = rotl64_1(bc[0], 2);
|
||||
s[21] = rotl64_2(s[8] ^ bc[2], 23);
|
||||
s[8] = rotl64_2(0x8000000000000000ULL ^ bc[0], 13);
|
||||
s[16] = rotl64_2(s[5] ^ bc[4], 4);
|
||||
s[5] = rotl64_1(s[3] ^ bc[2], 28);
|
||||
s[3] = rotl64_1(bc[2], 21);
|
||||
s[18] = rotl64_1(bc[1], 15);
|
||||
s[17] = rotl64_1(bc[0], 10);
|
||||
s[11] = rotl64_1(s[7] ^ bc[1], 6);
|
||||
s[7] = rotl64_1(bc[4], 3);
|
||||
s[10] = rotl64_1(tmp1, 1);
|
||||
|
||||
tmp1 = s[0]; tmp2 = s[1]; s[0] = bitselect(s[0] ^ s[2], s[0], s[1]); s[1] = bitselect(s[1] ^ s[3], s[1], s[2]); s[2] = bitselect(s[2] ^ s[4], s[2], s[3]); s[3] = bitselect(s[3] ^ tmp1, s[3], s[4]); s[4] = bitselect(s[4] ^ tmp2, s[4], tmp1);
|
||||
tmp1 = s[5]; tmp2 = s[6]; s[5] = bitselect(s[5] ^ s[7], s[5], s[6]); s[6] = bitselect(s[6] ^ s[8], s[6], s[7]); s[7] = bitselect(s[7] ^ s[9], s[7], s[8]); s[8] = bitselect(s[8] ^ tmp1, s[8], s[9]); s[9] = bitselect(s[9] ^ tmp2, s[9], tmp1);
|
||||
tmp1 = s[10]; tmp2 = s[11]; s[10] = bitselect(s[10] ^ s[12], s[10], s[11]); s[11] = bitselect(s[11] ^ s[13], s[11], s[12]); s[12] = bitselect(s[12] ^ s[14], s[12], s[13]); s[13] = bitselect(s[13] ^ tmp1, s[13], s[14]); s[14] = bitselect(s[14] ^ tmp2, s[14], tmp1);
|
||||
tmp1 = s[15]; tmp2 = s[16]; s[15] = bitselect(s[15] ^ s[17], s[15], s[16]); s[16] = bitselect(s[16] ^ s[18], s[16], s[17]); s[17] = bitselect(s[17] ^ s[19], s[17], s[18]); s[18] = bitselect(s[18] ^ tmp1, s[18], s[19]); s[19] = bitselect(s[19] ^ tmp2, s[19], tmp1);
|
||||
tmp1 = s[20]; tmp2 = s[21]; s[20] = bitselect(s[20] ^ s[22], s[20], s[21]); s[21] = bitselect(s[21] ^ s[23], s[21], s[22]); s[22] = bitselect(s[22] ^ s[24], s[22], s[23]); s[23] = bitselect(s[23] ^ tmp1, s[23], s[24]); s[24] = bitselect(s[24] ^ tmp2, s[24], tmp1);
|
||||
s[0] ^= 0x0000000000000001;
|
||||
|
||||
for(int i = 1; i < 24; ++i)
|
||||
{
|
||||
tmpxor[0] = s[0] ^ s[5] ^ s[10] ^ s[15] ^ s[20];
|
||||
tmpxor[1] = s[1] ^ s[6] ^ s[11] ^ s[16] ^ s[21];
|
||||
tmpxor[2] = s[2] ^ s[7] ^ s[12] ^ s[17] ^ s[22];
|
||||
tmpxor[3] = s[3] ^ s[8] ^ s[13] ^ s[18] ^ s[23];
|
||||
tmpxor[4] = s[4] ^ s[9] ^ s[14] ^ s[19] ^ s[24];
|
||||
|
||||
bc[0] = tmpxor[0] ^ rotl64_1(tmpxor[2], 1);
|
||||
bc[1] = tmpxor[1] ^ rotl64_1(tmpxor[3], 1);
|
||||
bc[2] = tmpxor[2] ^ rotl64_1(tmpxor[4], 1);
|
||||
bc[3] = tmpxor[3] ^ rotl64_1(tmpxor[0], 1);
|
||||
bc[4] = tmpxor[4] ^ rotl64_1(tmpxor[1], 1);
|
||||
|
||||
tmp1 = s[1] ^ bc[0];
|
||||
|
||||
s[0] ^= bc[4];
|
||||
s[1] = rotl64_2(s[6] ^ bc[0], 12);
|
||||
s[6] = rotl64_1(s[9] ^ bc[3], 20);
|
||||
s[9] = rotl64_2(s[22] ^ bc[1], 29);
|
||||
s[22] = rotl64_2(s[14] ^ bc[3], 7);
|
||||
s[14] = rotl64_1(s[20] ^ bc[4], 18);
|
||||
s[20] = rotl64_2(s[2] ^ bc[1], 30);
|
||||
s[2] = rotl64_2(s[12] ^ bc[1], 11);
|
||||
s[12] = rotl64_1(s[13] ^ bc[2], 25);
|
||||
s[13] = rotl64_1(s[19] ^ bc[3], 8);
|
||||
s[19] = rotl64_2(s[23] ^ bc[2], 24);
|
||||
s[23] = rotl64_2(s[15] ^ bc[4], 9);
|
||||
s[15] = rotl64_1(s[4] ^ bc[3], 27);
|
||||
s[4] = rotl64_1(s[24] ^ bc[3], 14);
|
||||
s[24] = rotl64_1(s[21] ^ bc[0], 2);
|
||||
s[21] = rotl64_2(s[8] ^ bc[2], 23);
|
||||
s[8] = rotl64_2(s[16] ^ bc[0], 13);
|
||||
s[16] = rotl64_2(s[5] ^ bc[4], 4);
|
||||
s[5] = rotl64_1(s[3] ^ bc[2], 28);
|
||||
s[3] = rotl64_1(s[18] ^ bc[2], 21);
|
||||
s[18] = rotl64_1(s[17] ^ bc[1], 15);
|
||||
s[17] = rotl64_1(s[11] ^ bc[0], 10);
|
||||
s[11] = rotl64_1(s[7] ^ bc[1], 6);
|
||||
s[7] = rotl64_1(s[10] ^ bc[4], 3);
|
||||
s[10] = rotl64_1(tmp1, 1);
|
||||
|
||||
tmp1 = s[0]; tmp2 = s[1]; s[0] = bitselect(s[0] ^ s[2], s[0], s[1]); s[1] = bitselect(s[1] ^ s[3], s[1], s[2]); s[2] = bitselect(s[2] ^ s[4], s[2], s[3]); s[3] = bitselect(s[3] ^ tmp1, s[3], s[4]); s[4] = bitselect(s[4] ^ tmp2, s[4], tmp1);
|
||||
tmp1 = s[5]; tmp2 = s[6]; s[5] = bitselect(s[5] ^ s[7], s[5], s[6]); s[6] = bitselect(s[6] ^ s[8], s[6], s[7]); s[7] = bitselect(s[7] ^ s[9], s[7], s[8]); s[8] = bitselect(s[8] ^ tmp1, s[8], s[9]); s[9] = bitselect(s[9] ^ tmp2, s[9], tmp1);
|
||||
tmp1 = s[10]; tmp2 = s[11]; s[10] = bitselect(s[10] ^ s[12], s[10], s[11]); s[11] = bitselect(s[11] ^ s[13], s[11], s[12]); s[12] = bitselect(s[12] ^ s[14], s[12], s[13]); s[13] = bitselect(s[13] ^ tmp1, s[13], s[14]); s[14] = bitselect(s[14] ^ tmp2, s[14], tmp1);
|
||||
tmp1 = s[15]; tmp2 = s[16]; s[15] = bitselect(s[15] ^ s[17], s[15], s[16]); s[16] = bitselect(s[16] ^ s[18], s[16], s[17]); s[17] = bitselect(s[17] ^ s[19], s[17], s[18]); s[18] = bitselect(s[18] ^ tmp1, s[18], s[19]); s[19] = bitselect(s[19] ^ tmp2, s[19], tmp1);
|
||||
tmp1 = s[20]; tmp2 = s[21]; s[20] = bitselect(s[20] ^ s[22], s[20], s[21]); s[21] = bitselect(s[21] ^ s[23], s[21], s[22]); s[22] = bitselect(s[22] ^ s[24], s[22], s[23]); s[23] = bitselect(s[23] ^ tmp1, s[23], s[24]); s[24] = bitselect(s[24] ^ tmp2, s[24], tmp1);
|
||||
s[0] ^= keccakf_rndc[i];
|
||||
}
|
||||
}
|
||||
|
||||
__device__ __forceinline__
|
||||
void cn_keccak(const uint32_t * __restrict__ in, uint64_t * __restrict__ md)
|
||||
{
|
||||
uint64_t st[25];
|
||||
|
||||
MEMCPY4(st, in, 19);
|
||||
MEMSET8(&st[10], 0x00, 15);
|
||||
st[9] = (st[9] & 0x00000000FFFFFFFFULL) | 0x0000000100000000ULL;
|
||||
st[16] = 0x8000000000000000ULL;
|
||||
|
||||
cn_keccakf(st);
|
||||
|
||||
MEMCPY8(md, st, 25);
|
||||
return;
|
||||
}
|
||||
@@ -1,319 +0,0 @@
|
||||
typedef unsigned int uint_t; /* native unsigned integer */
|
||||
|
||||
#define SKEIN_MODIFIER_WORDS ( 2) /* number of modifier (tweak) words */
|
||||
|
||||
#define SKEIN_256_STATE_WORDS ( 4)
|
||||
#define SKEIN_512_STATE_WORDS ( 8)
|
||||
|
||||
#define SKEIN_256_STATE_BYTES ( 8*SKEIN_256_STATE_WORDS)
|
||||
#define SKEIN_512_STATE_BYTES ( 8*SKEIN_512_STATE_WORDS)
|
||||
|
||||
#define SKEIN_256_STATE_BITS (64*SKEIN_256_STATE_WORDS)
|
||||
#define SKEIN_512_STATE_BITS (64*SKEIN_512_STATE_WORDS)
|
||||
|
||||
#define SKEIN_256_BLOCK_BYTES ( 8*SKEIN_256_STATE_WORDS)
|
||||
#define SKEIN_512_BLOCK_BYTES ( 8*SKEIN_512_STATE_WORDS)
|
||||
|
||||
#define SKEIN_MK_64(hi32,lo32) ((lo32) + (((uint64_t) (hi32)) << 32))
|
||||
#define SKEIN_KS_PARITY SKEIN_MK_64(0x1BD11BDA,0xA9FC1A22)
|
||||
|
||||
#define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* offset 64 because it's the second word */
|
||||
|
||||
#define SKEIN_T1_POS_FIRST SKEIN_T1_BIT(126) /* bits 126 : first block flag */
|
||||
#define SKEIN_T1_POS_BIT_PAD SKEIN_T1_BIT(119) /* bit 119 : partial final input byte */
|
||||
#define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* bit 127 : final block flag */
|
||||
#define SKEIN_T1_POS_BLK_TYPE SKEIN_T1_BIT(120) /* bits 120..125: type field */
|
||||
|
||||
#define SKEIN_T1_FLAG_FIRST (((uint64_t) 1 ) << SKEIN_T1_POS_FIRST)
|
||||
#define SKEIN_T1_FLAG_BIT_PAD (((uint64_t) 1 ) << SKEIN_T1_POS_BIT_PAD)
|
||||
#define SKEIN_T1_FLAG_FINAL (((uint64_t) 1 ) << SKEIN_T1_POS_FINAL)
|
||||
|
||||
#define SKEIN_BLK_TYPE_MSG (48) /* message processing */
|
||||
#define SKEIN_BLK_TYPE_OUT (63) /* output stage */
|
||||
|
||||
#define SKEIN_T1_BLK_TYPE(T) (((uint64_t) (SKEIN_BLK_TYPE_##T)) << SKEIN_T1_POS_BLK_TYPE)
|
||||
|
||||
#define SKEIN_T1_BLK_TYPE_MSG SKEIN_T1_BLK_TYPE(MSG) /* message processing */
|
||||
#define SKEIN_T1_BLK_TYPE_OUT SKEIN_T1_BLK_TYPE(OUT) /* output stage */
|
||||
|
||||
#define SKEIN_T1_BLK_TYPE_OUT_FINAL (SKEIN_T1_BLK_TYPE_OUT | SKEIN_T1_FLAG_FINAL)
|
||||
|
||||
#define Skein_Set_Tweak(ctxPtr,TWK_NUM,tVal) {(ctxPtr)->h.T[TWK_NUM] = (tVal);}
|
||||
|
||||
#define Skein_Set_T0(ctxPtr,T0) Skein_Set_Tweak(ctxPtr,0,T0)
|
||||
#define Skein_Set_T1(ctxPtr,T1) Skein_Set_Tweak(ctxPtr,1,T1)
|
||||
|
||||
#define Skein_Set_T0_T1(ctxPtr,T0,T1) { \
|
||||
Skein_Set_T0(ctxPtr,(T0)); \
|
||||
Skein_Set_T1(ctxPtr,(T1)); }
|
||||
|
||||
#define Skein_Start_New_Type(ctxPtr,BLK_TYPE) \
|
||||
{ Skein_Set_T0_T1(ctxPtr,0,SKEIN_T1_FLAG_FIRST | SKEIN_T1_BLK_TYPE_##BLK_TYPE); (ctxPtr)->h.bCnt=0; }
|
||||
|
||||
#define Skein_Set_Bit_Pad_Flag(hdr) { (hdr).T[1] |= SKEIN_T1_FLAG_BIT_PAD; }
|
||||
|
||||
#define KW_TWK_BASE (0)
|
||||
#define KW_KEY_BASE (3)
|
||||
#define ks (kw + KW_KEY_BASE)
|
||||
#define ts (kw + KW_TWK_BASE)
|
||||
|
||||
#define R512(p0,p1,p2,p3,p4,p5,p6,p7,R512ROT,rNum) \
|
||||
X##p0 += X##p1; X##p1 = ROTL64(X##p1,R512ROT##_0); X##p1 ^= X##p0; \
|
||||
X##p2 += X##p3; X##p3 = ROTL64(X##p3,R512ROT##_1); X##p3 ^= X##p2; \
|
||||
X##p4 += X##p5; X##p5 = ROTL64(X##p5,R512ROT##_2); X##p5 ^= X##p4; \
|
||||
X##p6 += X##p7; X##p7 = ROTL64(X##p7,R512ROT##_3); X##p7 ^= X##p6;
|
||||
|
||||
#define I512(R) \
|
||||
X0 += ks[((R)+1) % 9]; \
|
||||
X1 += ks[((R)+2) % 9]; \
|
||||
X2 += ks[((R)+3) % 9]; \
|
||||
X3 += ks[((R)+4) % 9]; \
|
||||
X4 += ks[((R)+5) % 9]; \
|
||||
X5 += ks[((R)+6) % 9] + ts[((R)+1) % 3]; \
|
||||
X6 += ks[((R)+7) % 9] + ts[((R)+2) % 3]; \
|
||||
X7 += ks[((R)+8) % 9] + (R)+1;
|
||||
|
||||
|
||||
#define R512_8_rounds(R) \
|
||||
R512(0,1,2,3,4,5,6,7,R_512_0,8*(R)+ 1); \
|
||||
R512(2,1,4,7,6,5,0,3,R_512_1,8*(R)+ 2); \
|
||||
R512(4,1,6,3,0,5,2,7,R_512_2,8*(R)+ 3); \
|
||||
R512(6,1,0,7,2,5,4,3,R_512_3,8*(R)+ 4); \
|
||||
I512(2*(R)); \
|
||||
R512(0,1,2,3,4,5,6,7,R_512_4,8*(R)+ 5); \
|
||||
R512(2,1,4,7,6,5,0,3,R_512_5,8*(R)+ 6); \
|
||||
R512(4,1,6,3,0,5,2,7,R_512_6,8*(R)+ 7); \
|
||||
R512(6,1,0,7,2,5,4,3,R_512_7,8*(R)+ 8); \
|
||||
I512(2*(R)+1);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t hashBitLen;
|
||||
size_t bCnt;
|
||||
uint64_t T[SKEIN_MODIFIER_WORDS];
|
||||
} Skein_Ctxt_Hdr_t;
|
||||
|
||||
typedef struct {
|
||||
Skein_Ctxt_Hdr_t h;
|
||||
uint64_t X[SKEIN_256_STATE_WORDS];
|
||||
uint8_t b[SKEIN_256_BLOCK_BYTES];
|
||||
} Skein_256_Ctxt_t;
|
||||
|
||||
typedef struct {
|
||||
Skein_Ctxt_Hdr_t h;
|
||||
uint64_t X[SKEIN_512_STATE_WORDS];
|
||||
uint8_t b[SKEIN_512_BLOCK_BYTES];
|
||||
} Skein_512_Ctxt_t;
|
||||
|
||||
typedef struct {
|
||||
uint_t statebits;
|
||||
union {
|
||||
Skein_Ctxt_Hdr_t h;
|
||||
Skein_256_Ctxt_t ctx_256;
|
||||
Skein_512_Ctxt_t ctx_512;
|
||||
} u;
|
||||
} skeinHashState;
|
||||
|
||||
__device__
|
||||
void cn_skein_init(skeinHashState *state, size_t hashBitLen)
|
||||
{
|
||||
const uint64_t SKEIN_512_IV_256[] =
|
||||
{
|
||||
SKEIN_MK_64(0xCCD044A1,0x2FDB3E13),
|
||||
SKEIN_MK_64(0xE8359030,0x1A79A9EB),
|
||||
SKEIN_MK_64(0x55AEA061,0x4F816E6F),
|
||||
SKEIN_MK_64(0x2A2767A4,0xAE9B94DB),
|
||||
SKEIN_MK_64(0xEC06025E,0x74DD7683),
|
||||
SKEIN_MK_64(0xE7A436CD,0xC4746251),
|
||||
SKEIN_MK_64(0xC36FBAF9,0x393AD185),
|
||||
SKEIN_MK_64(0x3EEDBA18,0x33EDFC13)
|
||||
};
|
||||
|
||||
Skein_512_Ctxt_t *ctx = &state->u.ctx_512;
|
||||
|
||||
ctx->h.hashBitLen = hashBitLen;
|
||||
|
||||
memcpy(ctx->X, SKEIN_512_IV_256, sizeof(ctx->X));
|
||||
|
||||
Skein_Start_New_Type(ctx, MSG);
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_skein_processblock(Skein_512_Ctxt_t * __restrict__ ctx, const uint8_t * __restrict__ blkPtr, size_t blkCnt, size_t byteCntAdd)
|
||||
{
|
||||
enum {
|
||||
R_512_0_0=46, R_512_0_1=36, R_512_0_2=19, R_512_0_3=37,
|
||||
R_512_1_0=33, R_512_1_1=27, R_512_1_2=14, R_512_1_3=42,
|
||||
R_512_2_0=17, R_512_2_1=49, R_512_2_2=36, R_512_2_3=39,
|
||||
R_512_3_0=44, R_512_3_1= 9, R_512_3_2=54, R_512_3_3=56,
|
||||
R_512_4_0=39, R_512_4_1=30, R_512_4_2=34, R_512_4_3=24,
|
||||
R_512_5_0=13, R_512_5_1=50, R_512_5_2=10, R_512_5_3=17,
|
||||
R_512_6_0=25, R_512_6_1=29, R_512_6_2=39, R_512_6_3=43,
|
||||
R_512_7_0= 8, R_512_7_1=35, R_512_7_2=56, R_512_7_3=22
|
||||
};
|
||||
uint64_t X0,X1,X2,X3,X4,X5,X6,X7;
|
||||
uint64_t w[SKEIN_512_STATE_WORDS];
|
||||
uint64_t kw[SKEIN_512_STATE_WORDS+4];
|
||||
|
||||
ts[0] = ctx->h.T[0];
|
||||
ts[1] = ctx->h.T[1];
|
||||
|
||||
do {
|
||||
|
||||
ts[0] += byteCntAdd;
|
||||
|
||||
ks[0] = ctx->X[0];
|
||||
ks[1] = ctx->X[1];
|
||||
ks[2] = ctx->X[2];
|
||||
ks[3] = ctx->X[3];
|
||||
ks[4] = ctx->X[4];
|
||||
ks[5] = ctx->X[5];
|
||||
ks[6] = ctx->X[6];
|
||||
ks[7] = ctx->X[7];
|
||||
ks[8] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^
|
||||
ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ SKEIN_KS_PARITY;
|
||||
|
||||
ts[2] = ts[0] ^ ts[1];
|
||||
|
||||
memcpy(w, blkPtr, SKEIN_512_STATE_WORDS << 3);
|
||||
|
||||
X0 = w[0] + ks[0];
|
||||
X1 = w[1] + ks[1];
|
||||
X2 = w[2] + ks[2];
|
||||
X3 = w[3] + ks[3];
|
||||
X4 = w[4] + ks[4];
|
||||
X5 = w[5] + ks[5] + ts[0];
|
||||
X6 = w[6] + ks[6] + ts[1];
|
||||
X7 = w[7] + ks[7];
|
||||
|
||||
blkPtr += SKEIN_512_BLOCK_BYTES;
|
||||
|
||||
R512_8_rounds( 0);
|
||||
R512_8_rounds( 1);
|
||||
R512_8_rounds( 2);
|
||||
R512_8_rounds( 3);
|
||||
R512_8_rounds( 4);
|
||||
R512_8_rounds( 5);
|
||||
R512_8_rounds( 6);
|
||||
R512_8_rounds( 7);
|
||||
R512_8_rounds( 8);
|
||||
|
||||
ctx->X[0] = X0 ^ w[0];
|
||||
ctx->X[1] = X1 ^ w[1];
|
||||
ctx->X[2] = X2 ^ w[2];
|
||||
ctx->X[3] = X3 ^ w[3];
|
||||
ctx->X[4] = X4 ^ w[4];
|
||||
ctx->X[5] = X5 ^ w[5];
|
||||
ctx->X[6] = X6 ^ w[6];
|
||||
ctx->X[7] = X7 ^ w[7];
|
||||
|
||||
ts[1] &= ~SKEIN_T1_FLAG_FIRST;
|
||||
} while (--blkCnt);
|
||||
|
||||
ctx->h.T[0] = ts[0];
|
||||
ctx->h.T[1] = ts[1];
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_skein_block(Skein_512_Ctxt_t * __restrict__ ctx, const uint8_t * __restrict__ msg, size_t msgByteCnt)
|
||||
{
|
||||
size_t n;
|
||||
|
||||
if (msgByteCnt + ctx->h.bCnt > SKEIN_512_BLOCK_BYTES)
|
||||
{
|
||||
if (ctx->h.bCnt) {
|
||||
|
||||
n = SKEIN_512_BLOCK_BYTES - ctx->h.bCnt;
|
||||
|
||||
if (n) {
|
||||
|
||||
memcpy(&ctx->b[ctx->h.bCnt],msg,n);
|
||||
msgByteCnt -= n;
|
||||
msg += n;
|
||||
ctx->h.bCnt += n;
|
||||
}
|
||||
|
||||
cn_skein_processblock(ctx, ctx->b, 1, SKEIN_512_BLOCK_BYTES);
|
||||
ctx->h.bCnt = 0;
|
||||
}
|
||||
|
||||
if (msgByteCnt > SKEIN_512_BLOCK_BYTES) {
|
||||
|
||||
n = (msgByteCnt - 1) / SKEIN_512_BLOCK_BYTES;
|
||||
cn_skein_processblock(ctx, msg, n, SKEIN_512_BLOCK_BYTES);
|
||||
msgByteCnt -= n * SKEIN_512_BLOCK_BYTES;
|
||||
msg += n * SKEIN_512_BLOCK_BYTES;
|
||||
}
|
||||
}
|
||||
|
||||
if (msgByteCnt) {
|
||||
|
||||
memcpy(&ctx->b[ctx->h.bCnt],msg,msgByteCnt);
|
||||
ctx->h.bCnt += msgByteCnt;
|
||||
}
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_skein_update(skeinHashState * __restrict__ state, const uint8_t * __restrict__ data, DataLength databitlen)
|
||||
{
|
||||
if ((databitlen & 7) == 0) {
|
||||
cn_skein_block(&state->u.ctx_512, data, databitlen >> 3);
|
||||
}
|
||||
else {
|
||||
size_t bCnt = (databitlen >> 3) + 1;
|
||||
uint8_t b,mask;
|
||||
|
||||
mask = (uint8_t) (1u << (7 - (databitlen & 7)));
|
||||
b = (uint8_t) ((data[bCnt-1] & (0-mask)) | mask);
|
||||
|
||||
cn_skein_block(&state->u.ctx_512, data, bCnt - 1);
|
||||
cn_skein_block(&state->u.ctx_512, &b, 1);
|
||||
|
||||
Skein_Set_Bit_Pad_Flag(state->u.h);
|
||||
}
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_skein_final(skeinHashState * __restrict__ state, uint8_t * __restrict__ hashVal)
|
||||
{
|
||||
uint64_t X[SKEIN_512_STATE_WORDS];
|
||||
Skein_512_Ctxt_t *ctx = (Skein_512_Ctxt_t *)&state->u.ctx_512;
|
||||
const int byteCnt = (ctx->h.hashBitLen + 7) >> 3;
|
||||
|
||||
ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL;
|
||||
|
||||
if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES)
|
||||
{
|
||||
memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_512_BLOCK_BYTES - ctx->h.bCnt);
|
||||
}
|
||||
|
||||
cn_skein_processblock(ctx, ctx->b, 1, ctx->h.bCnt);
|
||||
|
||||
memset(ctx->b, 0, sizeof(ctx->b));
|
||||
memcpy(X, ctx->X, sizeof(X));
|
||||
|
||||
for (int i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++)
|
||||
{
|
||||
int n = byteCnt - i*SKEIN_512_BLOCK_BYTES;
|
||||
if (n > SKEIN_512_BLOCK_BYTES) n = SKEIN_512_BLOCK_BYTES;
|
||||
((uint64_t *)ctx->b)[0] = (uint64_t)i;
|
||||
Skein_Start_New_Type(ctx, OUT_FINAL);
|
||||
cn_skein_processblock(ctx, ctx->b, 1, sizeof(uint64_t));
|
||||
memcpy(hashVal + (i*SKEIN_512_BLOCK_BYTES), ctx->X, n);
|
||||
memcpy(ctx->X, X, sizeof(X)); // restore the counter mode key for next time
|
||||
}
|
||||
}
|
||||
|
||||
__device__
|
||||
void cn_skein(const uint8_t * __restrict__ data, DataLength len, uint32_t * hashval)
|
||||
{
|
||||
int hashbitlen = 256;
|
||||
DataLength databitlen = len << 3;
|
||||
skeinHashState state;
|
||||
|
||||
state.statebits = 64*SKEIN_512_STATE_WORDS;
|
||||
|
||||
cn_skein_init(&state, hashbitlen);
|
||||
cn_skein_update(&state, data, databitlen);
|
||||
cn_skein_final(&state, (uint8_t*) hashval);
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
// keccak.c
|
||||
// 19-Nov-11 Markku-Juhani O. Saarinen <mjos@iki.fi>
|
||||
// A baseline Keccak (3rd round) implementation.
|
||||
|
||||
#include "c_keccak.h"
|
||||
|
||||
const uint64_t keccakf_rndc[24] =
|
||||
{
|
||||
0x0000000000000001, 0x0000000000008082, 0x800000000000808a,
|
||||
0x8000000080008000, 0x000000000000808b, 0x0000000080000001,
|
||||
0x8000000080008081, 0x8000000000008009, 0x000000000000008a,
|
||||
0x0000000000000088, 0x0000000080008009, 0x000000008000000a,
|
||||
0x000000008000808b, 0x800000000000008b, 0x8000000000008089,
|
||||
0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
|
||||
0x000000000000800a, 0x800000008000000a, 0x8000000080008081,
|
||||
0x8000000000008080, 0x0000000080000001, 0x8000000080008008
|
||||
};
|
||||
|
||||
const int keccakf_rotc[24] =
|
||||
{
|
||||
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14,
|
||||
27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44
|
||||
};
|
||||
|
||||
const int keccakf_piln[24] =
|
||||
{
|
||||
10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4,
|
||||
15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1
|
||||
};
|
||||
|
||||
// update the state with given number of rounds
|
||||
|
||||
void keccakf(uint64_t st[25], int rounds)
|
||||
{
|
||||
int i, j, round;
|
||||
uint64_t t, bc[5];
|
||||
|
||||
for (round = 0; round < rounds; ++round) {
|
||||
|
||||
// Theta
|
||||
bc[0] = st[0] ^ st[5] ^ st[10] ^ st[15] ^ st[20];
|
||||
bc[1] = st[1] ^ st[6] ^ st[11] ^ st[16] ^ st[21];
|
||||
bc[2] = st[2] ^ st[7] ^ st[12] ^ st[17] ^ st[22];
|
||||
bc[3] = st[3] ^ st[8] ^ st[13] ^ st[18] ^ st[23];
|
||||
bc[4] = st[4] ^ st[9] ^ st[14] ^ st[19] ^ st[24];
|
||||
|
||||
for (i = 0; i < 5; ++i) {
|
||||
t = bc[(i + 4) % 5] ^ ROTL64(bc[(i + 1) % 5], 1);
|
||||
st[i ] ^= t;
|
||||
st[i + 5] ^= t;
|
||||
st[i + 10] ^= t;
|
||||
st[i + 15] ^= t;
|
||||
st[i + 20] ^= t;
|
||||
}
|
||||
|
||||
// Rho Pi
|
||||
t = st[1];
|
||||
for (i = 0; i < 24; ++i) {
|
||||
bc[0] = st[keccakf_piln[i]];
|
||||
st[keccakf_piln[i]] = ROTL64(t, keccakf_rotc[i]);
|
||||
t = bc[0];
|
||||
}
|
||||
|
||||
// Chi
|
||||
for (j = 0; j < 25; j += 5) {
|
||||
bc[0] = st[j ];
|
||||
bc[1] = st[j + 1];
|
||||
bc[2] = st[j + 2];
|
||||
bc[3] = st[j + 3];
|
||||
bc[4] = st[j + 4];
|
||||
st[j ] ^= (~bc[1]) & bc[2];
|
||||
st[j + 1] ^= (~bc[2]) & bc[3];
|
||||
st[j + 2] ^= (~bc[3]) & bc[4];
|
||||
st[j + 3] ^= (~bc[4]) & bc[0];
|
||||
st[j + 4] ^= (~bc[0]) & bc[1];
|
||||
}
|
||||
|
||||
// Iota
|
||||
st[0] ^= keccakf_rndc[round];
|
||||
}
|
||||
}
|
||||
|
||||
// compute a keccak hash (md) of given byte length from "in"
|
||||
typedef uint64_t state_t[25];
|
||||
|
||||
int keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen)
|
||||
{
|
||||
state_t st;
|
||||
uint8_t temp[144];
|
||||
int i, rsiz, rsizw;
|
||||
|
||||
rsiz = sizeof(state_t) == mdlen ? HASH_DATA_AREA : 200 - 2 * mdlen;
|
||||
rsizw = rsiz / 8;
|
||||
|
||||
memset(st, 0, sizeof(st));
|
||||
|
||||
for ( ; inlen >= rsiz; inlen -= rsiz, in += rsiz) {
|
||||
for (i = 0; i < rsizw; i++)
|
||||
st[i] ^= ((uint64_t *) in)[i];
|
||||
keccakf(st, KECCAK_ROUNDS);
|
||||
}
|
||||
|
||||
// last block and padding
|
||||
memcpy(temp, in, inlen);
|
||||
temp[inlen++] = 1;
|
||||
memset(temp + inlen, 0, rsiz - inlen);
|
||||
temp[rsiz - 1] |= 0x80;
|
||||
|
||||
for (i = 0; i < rsizw; i++)
|
||||
st[i] ^= ((uint64_t *) temp)[i];
|
||||
|
||||
keccakf(st, KECCAK_ROUNDS);
|
||||
|
||||
memcpy(md, st, mdlen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void keccak1600(const uint8_t *in, int inlen, uint8_t *md)
|
||||
{
|
||||
keccak(in, inlen, md, sizeof(state_t));
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
// keccak.h
|
||||
// 19-Nov-11 Markku-Juhani O. Saarinen <mjos@iki.fi>
|
||||
|
||||
#ifndef KECCAK_H
|
||||
#define KECCAK_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef KECCAK_ROUNDS
|
||||
#define KECCAK_ROUNDS 24
|
||||
#endif
|
||||
|
||||
#ifndef ROTL64
|
||||
#define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y))))
|
||||
#endif
|
||||
|
||||
#ifndef HASH_SIZE
|
||||
#define HASH_SIZE 32
|
||||
#endif
|
||||
|
||||
#ifndef HASH_DATA_AREA
|
||||
#define HASH_DATA_AREA 136
|
||||
#endif
|
||||
|
||||
// compute a keccak hash (md) of given byte length from "in"
|
||||
int keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen);
|
||||
|
||||
// update the state
|
||||
void keccakf(uint64_t st[25], int norounds);
|
||||
|
||||
void keccak1600(const uint8_t *in, int inlen, uint8_t *md);
|
||||
|
||||
#endif
|
||||
@@ -1,351 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "cryptolight.h"
|
||||
#define LONG_SHL_IDX 18
|
||||
#define LONG_LOOPS32 0x40000
|
||||
|
||||
#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 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];
|
||||
|
||||
cn_aes_gpu_init(sharedMemory);
|
||||
|
||||
const int thread = (blockDim.x * blockIdx.x + threadIdx.x) >> 3;
|
||||
const int sub = (threadIdx.x & 7) << 2;
|
||||
|
||||
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];
|
||||
|
||||
// copy 160 bytes
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 40; i += 4)
|
||||
AS_UINT4(&key[i]) = AS_UINT4(ctx_key1 + thread * 40 + i);
|
||||
|
||||
AS_UINT2(&text[0]) = AS_UINT2(&ctx_state[oft]);
|
||||
AS_UINT2(&text[2]) = AS_UINT2(&ctx_state[oft + 2]);
|
||||
|
||||
__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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------
|
||||
|
||||
__global__
|
||||
void cryptolight_old_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();
|
||||
|
||||
#if 0 && __CUDA_ARCH__ >= 300
|
||||
|
||||
const int thread = (blockDim.x * blockIdx.x + threadIdx.x) >> 2;
|
||||
const int sub = threadIdx.x & 3;
|
||||
|
||||
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 << LONG_SHL_IDX];
|
||||
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] & 0xFFFF0;
|
||||
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] & 0xFFFF0]);
|
||||
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] & 0xFFFF0;
|
||||
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] & 0xFFFF0]);
|
||||
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;
|
||||
}
|
||||
|
||||
if(bfactor > 0)
|
||||
{
|
||||
ctx_a[sub] = a;
|
||||
ctx_b[sub] = b;
|
||||
}
|
||||
}
|
||||
|
||||
#else // __CUDA_ARCH__ < 300
|
||||
|
||||
const int 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 int 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);
|
||||
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]);
|
||||
}
|
||||
|
||||
if (bfactor > 0) {
|
||||
AS_UINT4(ctx_a) = A;
|
||||
AS_UINT4(ctx_b) = B;
|
||||
}
|
||||
}
|
||||
#endif // __CUDA_ARCH__ >= 300
|
||||
}
|
||||
|
||||
__device__ __forceinline__ void store_variant1(uint32_t* long_state)
|
||||
{
|
||||
uint4* Z = (uint4*) long_state;
|
||||
const uint32_t tmp = (Z->z >> 24); // __byte_perm(src, 0, 0x7773);
|
||||
const uint32_t index = (((tmp >> 3) & 6u) | (tmp & 1u)) << 1;
|
||||
Z->z = (Z->z & 0x00ffffffu) | ((tmp ^ ((0x75310u >> index) & 0x30u)) << 24);
|
||||
}
|
||||
|
||||
#define MUL_SUM_XOR_DST_1(a,c,dst,tweak) { \
|
||||
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 ^ tweak; }
|
||||
|
||||
__global__
|
||||
void cryptolight_gpu_phase2(const uint32_t threads, const uint16_t bfactor, const uint32_t partidx,
|
||||
uint32_t * __restrict__ d_long_state, uint32_t * __restrict__ d_ctx_a, uint32_t * __restrict__ d_ctx_b,
|
||||
uint64_t * __restrict__ d_tweak)
|
||||
{
|
||||
__shared__ __align__(16) uint32_t sharedMemory[1024];
|
||||
cn_aes_gpu_init(sharedMemory);
|
||||
__syncthreads();
|
||||
|
||||
const uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
if (thread < threads)
|
||||
{
|
||||
const uint32_t batchsize = ITER >> (2 + 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 tweak = d_tweak[thread];
|
||||
|
||||
void * ctx_a = (void*)(&d_ctx_a[thread << 2]);
|
||||
void * ctx_b = (void*)(&d_ctx_b[thread << 2]);
|
||||
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++)
|
||||
{
|
||||
uint32_t c[4];
|
||||
uint32_t j = (A.x >> 2) & E2I_MASK2;
|
||||
cn_aes_single_round(sharedMemory, &long_state[j], c, a);
|
||||
XOR_BLOCKS_DST(c, b, &long_state[j]);
|
||||
store_variant1(&long_state[j]);
|
||||
MUL_SUM_XOR_DST_1(c, a, &long_state[(c[0] >> 2) & E2I_MASK2], tweak);
|
||||
|
||||
j = (A.x >> 2) & E2I_MASK2;
|
||||
cn_aes_single_round(sharedMemory, &long_state[j], b, a);
|
||||
XOR_BLOCKS_DST(b, c, &long_state[j]);
|
||||
store_variant1(&long_state[j]);
|
||||
MUL_SUM_XOR_DST_1(b, a, &long_state[(b[0] >> 2) & E2I_MASK2], tweak);
|
||||
}
|
||||
if (bfactor) {
|
||||
AS_UINT4(ctx_a) = A;
|
||||
AS_UINT4(ctx_b) = B;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__global__
|
||||
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];
|
||||
|
||||
cn_aes_gpu_init(sharedMemory);
|
||||
|
||||
const int thread = (blockDim.x * blockIdx.x + threadIdx.x) >> 3;
|
||||
const int sub = (threadIdx.x & 7) << 2;
|
||||
|
||||
if(thread < threads)
|
||||
{
|
||||
const int long_oft = (thread << LONG_SHL_IDX) + sub;
|
||||
const int oft = thread * 50 + sub + 16;
|
||||
uint32_t __align__(16) key[40];
|
||||
uint32_t __align__(16) text[4];
|
||||
|
||||
#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)
|
||||
{
|
||||
#pragma unroll
|
||||
for(int j = 0; j < 4; j++)
|
||||
text[j] ^= long_state[long_oft + i + j];
|
||||
|
||||
cn_aes_pseudo_round_mut(sharedMemory, text, key);
|
||||
}
|
||||
|
||||
AS_UINT2(&ctx_state[oft + 0]) = AS_UINT2(&text[0]);
|
||||
AS_UINT2(&ctx_state[oft + 2]) = AS_UINT2(&text[2]);
|
||||
}
|
||||
}
|
||||
|
||||
extern int device_bfactor[MAX_GPUS];
|
||||
|
||||
__host__
|
||||
void cryptolight_core_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, int variant, uint64_t *d_ctx_tweak)
|
||||
{
|
||||
dim3 grid(blocks);
|
||||
dim3 block(threads);
|
||||
dim3 block4(threads << 2);
|
||||
dim3 block8(threads << 3);
|
||||
|
||||
const int bfactor = device_bfactor[thr_id];
|
||||
const int bsleep = bfactor ? 100 : 0;
|
||||
|
||||
int i, partcount = 1 << bfactor;
|
||||
int dev_id = device_map[thr_id];
|
||||
|
||||
cryptolight_core_gpu_phase1 <<<grid, block8 >>>(blocks*threads, d_long_state, d_ctx_state, d_ctx_key1);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
if(partcount > 1) usleep(bsleep);
|
||||
|
||||
for(i = 0; i < partcount; i++)
|
||||
{
|
||||
dim3 b = device_sm[dev_id] >= 300 ? block4 : block;
|
||||
if (variant == 0)
|
||||
cryptolight_old_gpu_phase2 <<<grid, b>>> (blocks*threads, bfactor, i, d_long_state, d_ctx_a, d_ctx_b);
|
||||
else
|
||||
cryptolight_gpu_phase2 <<<grid, b>>> (blocks*threads, bfactor, i, d_long_state, d_ctx_a, d_ctx_b, d_ctx_tweak);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
if(partcount > 1) usleep(bsleep);
|
||||
}
|
||||
|
||||
cryptolight_core_gpu_phase3 <<<grid, block8 >>>(blocks*threads, d_long_state, d_ctx_state, d_ctx_key2);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
}
|
||||
@@ -1,246 +0,0 @@
|
||||
#include <miner.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include "oaes_lib.h"
|
||||
#include "cryptolight.h"
|
||||
|
||||
extern "C" {
|
||||
#include <sph/sph_blake.h>
|
||||
#include <sph/sph_groestl.h>
|
||||
#include <sph/sph_jh.h>
|
||||
#include <sph/sph_skein.h>
|
||||
#include "cpu/c_keccak.h"
|
||||
}
|
||||
|
||||
struct cryptonight_ctx {
|
||||
uint8_t long_state[MEMORY];
|
||||
union cn_slow_hash_state state;
|
||||
uint8_t text[INIT_SIZE_BYTE];
|
||||
uint8_t a[AES_BLOCK_SIZE];
|
||||
uint8_t b[AES_BLOCK_SIZE];
|
||||
uint8_t c[AES_BLOCK_SIZE];
|
||||
oaes_ctx* aes_ctx;
|
||||
};
|
||||
|
||||
static void do_blake_hash(const void* input, int len, void* output)
|
||||
{
|
||||
uchar hash[32];
|
||||
sph_blake256_context ctx;
|
||||
sph_blake256_set_rounds(14);
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, input, len);
|
||||
sph_blake256_close(&ctx, hash);
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
|
||||
static void do_groestl_hash(const void* input, int len, void* output)
|
||||
{
|
||||
uchar hash[32];
|
||||
sph_groestl256_context ctx;
|
||||
sph_groestl256_init(&ctx);
|
||||
sph_groestl256(&ctx, input, len);
|
||||
sph_groestl256_close(&ctx, hash);
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
|
||||
static void do_jh_hash(const void* input, int len, void* output)
|
||||
{
|
||||
uchar hash[64];
|
||||
sph_jh256_context ctx;
|
||||
sph_jh256_init(&ctx);
|
||||
sph_jh256(&ctx, input, len);
|
||||
sph_jh256_close(&ctx, hash);
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
|
||||
static void do_skein_hash(const void* input, int len, void* output)
|
||||
{
|
||||
uchar hash[32];
|
||||
sph_skein256_context ctx;
|
||||
sph_skein256_init(&ctx);
|
||||
sph_skein256(&ctx, input, len);
|
||||
sph_skein256_close(&ctx, hash);
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
|
||||
// todo: use sph if possible
|
||||
static void keccak_hash_permutation(union hash_state *state) {
|
||||
keccakf((uint64_t*)state, 24);
|
||||
}
|
||||
|
||||
static void keccak_hash_process(union hash_state *state, const uint8_t *buf, int count) {
|
||||
keccak1600(buf, (int)count, (uint8_t*)state);
|
||||
}
|
||||
|
||||
extern "C" int fast_aesb_single_round(const uint8_t *in, uint8_t*out, const uint8_t *expandedKey);
|
||||
extern "C" int aesb_single_round(const uint8_t *in, uint8_t*out, const uint8_t *expandedKey);
|
||||
extern "C" int aesb_pseudo_round_mut(uint8_t *val, uint8_t *expandedKey);
|
||||
extern "C" int fast_aesb_pseudo_round_mut(uint8_t *val, uint8_t *expandedKey);
|
||||
|
||||
static void (* const extra_hashes[4])(const void*, int, void *) = {
|
||||
do_blake_hash, do_groestl_hash, do_jh_hash, do_skein_hash
|
||||
};
|
||||
|
||||
static uint64_t mul128(uint64_t multiplier, uint64_t multiplicand, uint64_t* product_hi)
|
||||
{
|
||||
// multiplier = ab = a * 2^32 + b
|
||||
// multiplicand = cd = c * 2^32 + d
|
||||
// ab * cd = a * c * 2^64 + (a * d + b * c) * 2^32 + b * d
|
||||
uint64_t a = hi_dword(multiplier);
|
||||
uint64_t b = lo_dword(multiplier);
|
||||
uint64_t c = hi_dword(multiplicand);
|
||||
uint64_t d = lo_dword(multiplicand);
|
||||
|
||||
uint64_t ac = a * c;
|
||||
uint64_t ad = a * d;
|
||||
uint64_t bc = b * c;
|
||||
uint64_t bd = b * d;
|
||||
|
||||
uint64_t adbc = ad + bc;
|
||||
uint64_t adbc_carry = adbc < ad ? 1 : 0;
|
||||
|
||||
// multiplier * multiplicand = product_hi * 2^64 + product_lo
|
||||
uint64_t product_lo = bd + (adbc << 32);
|
||||
uint64_t product_lo_carry = product_lo < bd ? 1 : 0;
|
||||
*product_hi = ac + (adbc >> 32) + (adbc_carry << 32) + product_lo_carry;
|
||||
|
||||
return product_lo;
|
||||
}
|
||||
|
||||
static size_t e2i(const uint8_t* a) {
|
||||
//const uint32_t mask = (MEMORY / AES_BLOCK_SIZE - 1);
|
||||
//return (*((uint64_t*) a) / AES_BLOCK_SIZE) & mask;
|
||||
return *((uint64_t*) a) & 0xFFFF0; /* mask * AES_BLOCK_SIZE */
|
||||
}
|
||||
|
||||
static void mul(const uint8_t* a, const uint8_t* b, uint8_t* res) {
|
||||
((uint64_t*) res)[1] = mul128(((uint64_t*) a)[0], ((uint64_t*) b)[0], (uint64_t*) res);
|
||||
}
|
||||
|
||||
static void sum_half_blocks(uint8_t* a, const uint8_t* b) {
|
||||
((uint64_t*) a)[0] += ((uint64_t*) b)[0];
|
||||
((uint64_t*) a)[1] += ((uint64_t*) b)[1];
|
||||
}
|
||||
|
||||
static void sum_half_blocks_dst(const uint8_t* a, const uint8_t* b, uint8_t* dst) {
|
||||
((uint64_t*) dst)[0] = ((uint64_t*) a)[0] + ((uint64_t*) b)[0];
|
||||
((uint64_t*) dst)[1] = ((uint64_t*) a)[1] + ((uint64_t*) b)[1];
|
||||
}
|
||||
|
||||
static void mul_sum_dst(const uint8_t* a, const uint8_t* b, const uint8_t* c, uint8_t* dst) {
|
||||
((uint64_t*) dst)[1] = mul128(((uint64_t*) a)[0], ((uint64_t*) b)[0], (uint64_t*) dst) + ((uint64_t*) c)[1];
|
||||
((uint64_t*) dst)[0] += ((uint64_t*) c)[0];
|
||||
}
|
||||
|
||||
static void mul_sum_xor_dst(const uint8_t* a, uint8_t* c, uint8_t* dst, const int variant, const uint64_t tweak) {
|
||||
uint64_t hi, lo = 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] = variant ? lo ^ tweak : lo;
|
||||
}
|
||||
|
||||
static void copy_block(uint8_t* dst, const uint8_t* src) {
|
||||
((uint64_t*) dst)[0] = ((uint64_t*) src)[0];
|
||||
((uint64_t*) dst)[1] = ((uint64_t*) src)[1];
|
||||
}
|
||||
|
||||
static void xor_blocks(uint8_t* a, const uint8_t* b) {
|
||||
((uint64_t*) a)[0] ^= ((uint64_t*) b)[0];
|
||||
((uint64_t*) a)[1] ^= ((uint64_t*) b)[1];
|
||||
}
|
||||
|
||||
static void xor_blocks_dst(const uint8_t* a, const uint8_t* b, uint8_t* dst) {
|
||||
((uint64_t*) dst)[0] = ((uint64_t*) a)[0] ^ ((uint64_t*) b)[0];
|
||||
((uint64_t*) dst)[1] = ((uint64_t*) a)[1] ^ ((uint64_t*) b)[1];
|
||||
}
|
||||
|
||||
static void cryptolight_store_variant(void* state, int variant) {
|
||||
if (variant == 1) {
|
||||
// use variant 1 like monero since june 2018
|
||||
const uint8_t tmp = ((const uint8_t*)(state))[11];
|
||||
const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1;
|
||||
((uint8_t*)(state))[11] = tmp ^ ((0x75310 >> index) & 0x30);
|
||||
}
|
||||
}
|
||||
|
||||
static void cryptolight_hash_ctx(void* output, const void* input, const int len, struct cryptonight_ctx* ctx, const int variant)
|
||||
{
|
||||
size_t i, j;
|
||||
|
||||
keccak_hash_process(&ctx->state.hs, (const uint8_t*) input, len);
|
||||
ctx->aes_ctx = (oaes_ctx*) oaes_alloc();
|
||||
memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE);
|
||||
|
||||
const uint64_t tweak = variant ? *((uint64_t*) (((uint8_t*)input) + 35)) ^ ctx->state.hs.w[24] : 0;
|
||||
|
||||
oaes_key_import_data(ctx->aes_ctx, ctx->state.hs.b, AES_KEY_SIZE);
|
||||
for (i = 0; likely(i < MEMORY); i += INIT_SIZE_BYTE) {
|
||||
#undef RND
|
||||
#define RND(p) aesb_pseudo_round_mut(&ctx->text[AES_BLOCK_SIZE * p], ctx->aes_ctx->key->exp_data);
|
||||
RND(0);
|
||||
RND(1);
|
||||
RND(2);
|
||||
RND(3);
|
||||
RND(4);
|
||||
RND(5);
|
||||
RND(6);
|
||||
RND(7);
|
||||
memcpy(&ctx->long_state[i], ctx->text, INIT_SIZE_BYTE);
|
||||
}
|
||||
|
||||
xor_blocks_dst(&ctx->state.k[0], &ctx->state.k[32], ctx->a);
|
||||
xor_blocks_dst(&ctx->state.k[16], &ctx->state.k[48], ctx->b);
|
||||
|
||||
for (i = 0; likely(i < ITER / 4); ++i) {
|
||||
j = e2i(ctx->a);
|
||||
aesb_single_round(&ctx->long_state[j], ctx->c, ctx->a);
|
||||
xor_blocks_dst(ctx->c, ctx->b, &ctx->long_state[j]);
|
||||
cryptolight_store_variant(&ctx->long_state[j], variant);
|
||||
mul_sum_xor_dst(ctx->c, ctx->a, &ctx->long_state[e2i(ctx->c)], variant, tweak);
|
||||
|
||||
j = e2i(ctx->a);
|
||||
aesb_single_round(&ctx->long_state[j], ctx->b, ctx->a);
|
||||
xor_blocks_dst(ctx->b, ctx->c, &ctx->long_state[j]);
|
||||
cryptolight_store_variant(&ctx->long_state[j], variant);
|
||||
mul_sum_xor_dst(ctx->b, ctx->a, &ctx->long_state[e2i(ctx->b)], variant, tweak);
|
||||
}
|
||||
|
||||
memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE);
|
||||
oaes_key_import_data(ctx->aes_ctx, &ctx->state.hs.b[32], AES_KEY_SIZE);
|
||||
for (i = 0; likely(i < MEMORY); i += INIT_SIZE_BYTE) {
|
||||
#undef RND
|
||||
#define RND(p) xor_blocks(&ctx->text[p * AES_BLOCK_SIZE], &ctx->long_state[i + p * AES_BLOCK_SIZE]); \
|
||||
aesb_pseudo_round_mut(&ctx->text[p * AES_BLOCK_SIZE], ctx->aes_ctx->key->exp_data);
|
||||
RND(0);
|
||||
RND(1);
|
||||
RND(2);
|
||||
RND(3);
|
||||
RND(4);
|
||||
RND(5);
|
||||
RND(6);
|
||||
RND(7);
|
||||
}
|
||||
memcpy(ctx->state.init, ctx->text, INIT_SIZE_BYTE);
|
||||
keccak_hash_permutation(&ctx->state.hs);
|
||||
|
||||
int extra_algo = ctx->state.hs.b[0] & 3;
|
||||
extra_hashes[extra_algo](&ctx->state, 200, output);
|
||||
if (opt_debug) applog(LOG_DEBUG, "extra algo=%d", extra_algo);
|
||||
|
||||
oaes_free((OAES_CTX **) &ctx->aes_ctx);
|
||||
}
|
||||
|
||||
void cryptolight_hash_variant(void* output, const void* input, int len, int variant)
|
||||
{
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*)malloc(sizeof(struct cryptonight_ctx));
|
||||
cryptolight_hash_ctx(output, input, len, ctx, variant);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
void cryptolight_hash(void* output, const void* input)
|
||||
{
|
||||
cryptolight_hash_variant(output, input, 76, 1);
|
||||
}
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
|
||||
#include "cryptolight.h"
|
||||
|
||||
extern char *device_config[MAX_GPUS]; // -l 32x16
|
||||
|
||||
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 uint32_t *d_ctx_key1[MAX_GPUS];
|
||||
static uint32_t *d_ctx_key2[MAX_GPUS];
|
||||
static uint32_t *d_ctx_text[MAX_GPUS];
|
||||
static uint64_t *d_ctx_tweak[MAX_GPUS];
|
||||
static uint32_t *d_ctx_a[MAX_GPUS];
|
||||
static uint32_t *d_ctx_b[MAX_GPUS];
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_cryptolight(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done, int variant)
|
||||
{
|
||||
int res = 0;
|
||||
uint32_t throughput = 0;
|
||||
|
||||
uint32_t *ptarget = work->target;
|
||||
uint8_t *pdata = (uint8_t*) work->data;
|
||||
uint32_t *nonceptr = (uint32_t*) (&pdata[39]);
|
||||
const uint32_t first_nonce = *nonceptr;
|
||||
uint32_t nonce = first_nonce;
|
||||
int dev_id = device_map[thr_id];
|
||||
|
||||
if(opt_benchmark) {
|
||||
ptarget[7] = 0x00ff;
|
||||
}
|
||||
|
||||
if(!init[thr_id])
|
||||
{
|
||||
if (!device_config[thr_id] && strcmp(device_name[dev_id], "TITAN V") == 0) {
|
||||
device_config[thr_id] = strdup("80x32");
|
||||
}
|
||||
|
||||
if (device_config[thr_id]) {
|
||||
sscanf(device_config[thr_id], "%ux%u", &cn_blocks, &cn_threads);
|
||||
throughput = cuda_default_throughput(thr_id, cn_blocks*cn_threads);
|
||||
gpulog(LOG_INFO, thr_id, "Using %u x %u kernel launch config, %u threads",
|
||||
cn_blocks, cn_threads, throughput);
|
||||
} else {
|
||||
throughput = cuda_default_throughput(thr_id, cn_blocks*cn_threads);
|
||||
if (throughput != cn_blocks*cn_threads && cn_threads) {
|
||||
cn_blocks = throughput / cn_threads;
|
||||
throughput = cn_threads * cn_blocks;
|
||||
}
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u threads (%ux%u)",
|
||||
throughput2intensity(throughput), throughput, cn_blocks, cn_threads);
|
||||
}
|
||||
|
||||
if(sizeof(size_t) == 4 && throughput > UINT32_MAX / MEMORY) {
|
||||
gpulog(LOG_ERR, thr_id, "THE 32bit VERSION CAN'T ALLOCATE MORE THAN 4GB OF MEMORY!");
|
||||
gpulog(LOG_ERR, thr_id, "PLEASE REDUCE THE NUMBER OF THREADS OR BLOCKS");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
cudaSetDevice(device_map[thr_id]);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
cudaDeviceSetCacheConfig(cudaFuncCachePreferL1);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
|
||||
const size_t alloc = MEMORY * throughput;
|
||||
cryptonight_extra_init(thr_id);
|
||||
|
||||
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);
|
||||
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__);
|
||||
cudaMalloc(&d_ctx_key2[thr_id], 40 * sizeof(uint32_t) * throughput);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
cudaMalloc(&d_ctx_text[thr_id], 32 * sizeof(uint32_t) * throughput);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
cudaMalloc(&d_ctx_a[thr_id], 4 * sizeof(uint32_t) * throughput);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
cudaMalloc(&d_ctx_b[thr_id], 4 * sizeof(uint32_t) * throughput);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
cudaMalloc(&d_ctx_tweak[thr_id], sizeof(uint64_t) * throughput);
|
||||
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
throughput = cn_blocks*cn_threads;
|
||||
|
||||
do
|
||||
{
|
||||
const uint32_t Htarg = ptarget[7];
|
||||
uint32_t resNonces[2] = { UINT32_MAX, UINT32_MAX };
|
||||
|
||||
cryptonight_extra_setData(thr_id, pdata, ptarget);
|
||||
cryptonight_extra_prepare(thr_id, throughput, nonce, d_ctx_state[thr_id], d_ctx_a[thr_id], d_ctx_b[thr_id], d_ctx_key1[thr_id], d_ctx_key2[thr_id], variant, d_ctx_tweak[thr_id]);
|
||||
cryptolight_core_hash(thr_id, cn_blocks, cn_threads, d_long_state[thr_id], d_ctx_state[thr_id], d_ctx_a[thr_id], d_ctx_b[thr_id], d_ctx_key1[thr_id], d_ctx_key2[thr_id], variant, d_ctx_tweak[thr_id]);
|
||||
cryptonight_extra_final(thr_id, throughput, nonce, resNonces, d_ctx_state[thr_id]);
|
||||
|
||||
*hashes_done = nonce - first_nonce + throughput;
|
||||
|
||||
if(resNonces[0] != UINT32_MAX)
|
||||
{
|
||||
uint32_t vhash[8];
|
||||
uint32_t tempdata[19];
|
||||
uint32_t *tempnonceptr = (uint32_t*)(((char*)tempdata) + 39);
|
||||
memcpy(tempdata, pdata, 76);
|
||||
*tempnonceptr = resNonces[0];
|
||||
cryptolight_hash_variant(vhash, tempdata, 76, variant);
|
||||
if(vhash[7] <= Htarg && fulltest(vhash, ptarget))
|
||||
{
|
||||
res = 1;
|
||||
work->nonces[0] = resNonces[0];
|
||||
work_set_target_ratio(work, vhash);
|
||||
// second nonce
|
||||
if(resNonces[1] != UINT32_MAX)
|
||||
{
|
||||
*tempnonceptr = resNonces[1];
|
||||
cryptolight_hash_variant(vhash, tempdata, 76, variant);
|
||||
if(vhash[7] <= Htarg && fulltest(vhash, ptarget)) {
|
||||
res++;
|
||||
work->nonces[1] = resNonces[1];
|
||||
} else if (vhash[7] > Htarg) {
|
||||
gpu_increment_reject(thr_id);
|
||||
}
|
||||
}
|
||||
goto done;
|
||||
} else if (vhash[7] > Htarg) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for nonce %08x does not validate on CPU!", resNonces[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint64_t) throughput + nonce >= max_nonce - 127) {
|
||||
nonce = max_nonce;
|
||||
break;
|
||||
}
|
||||
|
||||
nonce += throughput;
|
||||
gpulog(LOG_DEBUG, thr_id, "nonce %08x", nonce);
|
||||
|
||||
} while (!work_restart[thr_id].restart && max_nonce > (uint64_t)throughput + nonce);
|
||||
|
||||
done:
|
||||
gpulog(LOG_DEBUG, thr_id, "nonce %08x exit", nonce);
|
||||
work->valid_nonces = res;
|
||||
*nonceptr = nonce;
|
||||
return res;
|
||||
}
|
||||
|
||||
void free_cryptolight(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaFree(d_long_state[thr_id]);
|
||||
cudaFree(d_ctx_state[thr_id]);
|
||||
cudaFree(d_ctx_key1[thr_id]);
|
||||
cudaFree(d_ctx_key2[thr_id]);
|
||||
cudaFree(d_ctx_text[thr_id]);
|
||||
cudaFree(d_ctx_tweak[thr_id]);
|
||||
cudaFree(d_ctx_a[thr_id]);
|
||||
cudaFree(d_ctx_b[thr_id]);
|
||||
|
||||
cryptonight_extra_free(thr_id);
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
|
||||
init[thr_id] = false;
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
#pragma once
|
||||
#include <cuda_runtime.h>
|
||||
#include <miner.h>
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
/* avoid red underlining */
|
||||
#define __CUDA_ARCH__ 520
|
||||
struct uint3 {
|
||||
unsigned int x, y, z;
|
||||
};
|
||||
struct uint3 threadIdx;
|
||||
struct uint3 blockIdx;
|
||||
struct uint3 blockDim;
|
||||
#define atomicExch(p,y) (*p) = y
|
||||
#define __funnelshift_r(a,b,c) 1
|
||||
#define __syncthreads()
|
||||
#define __threadfence_block()
|
||||
#define asm(x)
|
||||
#define __shfl(a,b,c) 1
|
||||
#define __umul64hi(a,b) a*b
|
||||
#endif
|
||||
|
||||
#define MEMORY (1UL << 20) /* 1 MiB - 1048576 */
|
||||
#define ITER (1UL << 19) /* 512k */
|
||||
#define E2I_MASK1 0xFFFF0 /* MEMORY / AES_BLOCK_SIZE - 1 = 0xFFFF */
|
||||
#define E2I_MASK2 0x3FFFC /* 0xFFFF0 >> 2 */
|
||||
|
||||
#define AES_BLOCK_SIZE 16
|
||||
#define AES_KEY_SIZE 32
|
||||
#define INIT_SIZE_BLK 8
|
||||
#define INIT_SIZE_BYTE (INIT_SIZE_BLK * AES_BLOCK_SIZE) // 128 B
|
||||
|
||||
#define AES_RKEY_LEN 4
|
||||
#define AES_COL_LEN 4
|
||||
#define AES_ROUND_BASE 7
|
||||
|
||||
#ifndef HASH_SIZE
|
||||
#define HASH_SIZE 32
|
||||
#endif
|
||||
|
||||
#ifndef HASH_DATA_AREA
|
||||
#define HASH_DATA_AREA 136
|
||||
#endif
|
||||
|
||||
#define hi_dword(x) (x >> 32)
|
||||
#define lo_dword(x) (x & 0xFFFFFFFF)
|
||||
|
||||
#define C32(x) ((uint32_t)(x ## U))
|
||||
#define T32(x) ((x) & C32(0xFFFFFFFF))
|
||||
|
||||
#ifndef ROTL64
|
||||
#if __CUDA_ARCH__ >= 350
|
||||
__forceinline__ __device__ uint64_t cuda_ROTL64(const uint64_t value, const int offset) {
|
||||
uint2 result;
|
||||
if(offset >= 32) {
|
||||
asm("shf.l.wrap.b32 %0, %1, %2, %3;" : "=r"(result.x) : "r"(__double2loint(__longlong_as_double(value))), "r"(__double2hiint(__longlong_as_double(value))), "r"(offset));
|
||||
asm("shf.l.wrap.b32 %0, %1, %2, %3;" : "=r"(result.y) : "r"(__double2hiint(__longlong_as_double(value))), "r"(__double2loint(__longlong_as_double(value))), "r"(offset));
|
||||
} else {
|
||||
asm("shf.l.wrap.b32 %0, %1, %2, %3;" : "=r"(result.x) : "r"(__double2hiint(__longlong_as_double(value))), "r"(__double2loint(__longlong_as_double(value))), "r"(offset));
|
||||
asm("shf.l.wrap.b32 %0, %1, %2, %3;" : "=r"(result.y) : "r"(__double2loint(__longlong_as_double(value))), "r"(__double2hiint(__longlong_as_double(value))), "r"(offset));
|
||||
}
|
||||
return __double_as_longlong(__hiloint2double(result.y, result.x));
|
||||
}
|
||||
#define ROTL64(x, n) (cuda_ROTL64(x, n))
|
||||
#else
|
||||
#define ROTL64(x, n) (((x) << (n)) | ((x) >> (64 - (n))))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ROTL32
|
||||
#if __CUDA_ARCH__ < 350
|
||||
#define ROTL32(x, n) T32(((x) << (n)) | ((x) >> (32 - (n))))
|
||||
#else
|
||||
#define ROTL32(x, n) __funnelshift_l( (x), (x), (n) )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ROTR32
|
||||
#if __CUDA_ARCH__ < 350
|
||||
#define ROTR32(x, n) (((x) >> (n)) | ((x) << (32 - (n))))
|
||||
#else
|
||||
#define ROTR32(x, n) __funnelshift_r( (x), (x), (n) )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define MEMSET8(dst,what,cnt) { \
|
||||
int i_memset8; \
|
||||
uint64_t *out_memset8 = (uint64_t *)(dst); \
|
||||
for( i_memset8 = 0; i_memset8 < cnt; i_memset8++ ) \
|
||||
out_memset8[i_memset8] = (what); }
|
||||
|
||||
#define MEMSET4(dst,what,cnt) { \
|
||||
int i_memset4; \
|
||||
uint32_t *out_memset4 = (uint32_t *)(dst); \
|
||||
for( i_memset4 = 0; i_memset4 < cnt; i_memset4++ ) \
|
||||
out_memset4[i_memset4] = (what); }
|
||||
|
||||
#define MEMCPY8(dst,src,cnt) { \
|
||||
int i_memcpy8; \
|
||||
uint64_t *in_memcpy8 = (uint64_t *)(src); \
|
||||
uint64_t *out_memcpy8 = (uint64_t *)(dst); \
|
||||
for( i_memcpy8 = 0; i_memcpy8 < cnt; i_memcpy8++ ) \
|
||||
out_memcpy8[i_memcpy8] = in_memcpy8[i_memcpy8]; }
|
||||
|
||||
#define MEMCPY4(dst,src,cnt) { \
|
||||
int i_memcpy4; \
|
||||
uint32_t *in_memcpy4 = (uint32_t *)(src); \
|
||||
uint32_t *out_memcpy4 = (uint32_t *)(dst); \
|
||||
for( i_memcpy4 = 0; i_memcpy4 < cnt; i_memcpy4++ ) \
|
||||
out_memcpy4[i_memcpy4] = in_memcpy4[i_memcpy4]; }
|
||||
|
||||
#define XOR_BLOCKS_DST(x,y,z) { \
|
||||
((uint64_t *)z)[0] = ((uint64_t *)(x))[0] ^ ((uint64_t *)(y))[0]; \
|
||||
((uint64_t *)z)[1] = ((uint64_t *)(x))[1] ^ ((uint64_t *)(y))[1]; }
|
||||
|
||||
union hash_state {
|
||||
uint8_t b[200];
|
||||
uint64_t w[25];
|
||||
};
|
||||
|
||||
union cn_slow_hash_state {
|
||||
union hash_state hs;
|
||||
struct {
|
||||
uint8_t k[64];
|
||||
uint8_t init[INIT_SIZE_BYTE];
|
||||
};
|
||||
};
|
||||
|
||||
static inline void exit_if_cudaerror(int thr_id, const char *src, int line)
|
||||
{
|
||||
cudaError_t err = cudaGetLastError();
|
||||
if(err != cudaSuccess) {
|
||||
gpulog(LOG_ERR, thr_id, "%s %s line %d", cudaGetErrorString(err), src, line);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void cryptolight_core_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, int variant, uint64_t *d_ctx_tweak);
|
||||
|
||||
void cryptonight_extra_setData(int thr_id, const void *data, const void *ptarget);
|
||||
void cryptonight_extra_init(int thr_id/*, uint32_t threads*/);
|
||||
void cryptonight_extra_free(int thr_id);
|
||||
void cryptonight_extra_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, int variant, uint64_t *d_ctx_tweak);
|
||||
void cryptonight_extra_final(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *resNonces, uint32_t *d_ctx_state);
|
||||
@@ -1,316 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <cuda.h>
|
||||
#include <cuda_runtime.h>
|
||||
|
||||
#if CUDA_VERSION >= 9000 && __CUDA_ARCH__ >= 300
|
||||
#undef __shfl
|
||||
#define __shfl(var, srcLane, width) __shfl_sync(0xFFFFFFFFu, var, srcLane, width)
|
||||
#endif
|
||||
|
||||
#include "cryptonight.h"
|
||||
|
||||
#define LONG_SHL32 19 // 1<<19 (uint32_t* index)
|
||||
#define LONG_SHL64 18 // 1<<18 (uint64_t* index)
|
||||
#define LONG_LOOPS32 0x80000U
|
||||
|
||||
#include "cn_aes.cuh"
|
||||
|
||||
__global__
|
||||
void cryptonight_gpu_phase1(const uint32_t threads, uint32_t * __restrict__ d_long_state,
|
||||
uint32_t * __restrict__ ctx_state, uint32_t * __restrict__ ctx_key1)
|
||||
{
|
||||
__shared__ uint32_t sharedMemory[1024];
|
||||
|
||||
const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x) >> 3;
|
||||
if(thread < threads)
|
||||
{
|
||||
cn_aes_gpu_init(sharedMemory);
|
||||
__syncthreads();
|
||||
|
||||
const uint32_t sub = (threadIdx.x & 0x7U) << 2;
|
||||
uint32_t *longstate = &d_long_state[(thread << LONG_SHL32) + sub];
|
||||
uint32_t __align__(8) key[40];
|
||||
MEMCPY8(key, &ctx_key1[thread * 40U], 20);
|
||||
uint32_t __align__(8) text[4];
|
||||
MEMCPY8(text, &ctx_state[thread * 50U + sub + 16U], 2);
|
||||
|
||||
for(int i = 0; i < LONG_LOOPS32; i += 32)
|
||||
{
|
||||
cn_aes_pseudo_round_mut(sharedMemory, text, key);
|
||||
MEMCPY8(&longstate[i], text, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------
|
||||
|
||||
__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;
|
||||
}
|
||||
|
||||
static __forceinline__ __device__ void operator += (ulonglong2 &a, const ulonglong2 b) {
|
||||
a.x += b.x; a.y += b.y;
|
||||
}
|
||||
|
||||
static __forceinline__ __device__ ulonglong2 operator ^ (const ulonglong2 &a, const ulonglong2 &b) {
|
||||
return make_ulonglong2(a.x ^ b.x, a.y ^ b.y);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ void MUL_SUM_XOR_DST_0(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;
|
||||
}
|
||||
|
||||
__global__
|
||||
#if __CUDA_ARCH__ >= 500
|
||||
//__launch_bounds__(128,12) /* force 40 regs to allow -l ...x32 */
|
||||
#endif
|
||||
void cryptonight_gpu_phase2(const uint32_t threads, const uint16_t bfactor, const uint32_t partidx,
|
||||
uint64_t * __restrict__ d_long_state, uint32_t * __restrict__ d_ctx_a, uint32_t * __restrict__ d_ctx_b)
|
||||
{
|
||||
__shared__ __align__(16) uint32_t sharedMemory[1024];
|
||||
cn_aes_gpu_init(sharedMemory);
|
||||
__syncthreads();
|
||||
|
||||
const uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
|
||||
if (thread < threads)
|
||||
{
|
||||
const uint32_t batchsize = ITER >> (2 + bfactor);
|
||||
const uint32_t start = partidx * batchsize;
|
||||
const uint32_t end = start + batchsize;
|
||||
|
||||
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);
|
||||
|
||||
uint64_t * long_state = &d_long_state[thread << LONG_SHL64];
|
||||
for (int i = start; i < end; i++) // end = 262144
|
||||
{
|
||||
uint4 C;
|
||||
|
||||
uint32_t j = (A.x & E2I_MASK) >> 3;
|
||||
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_0((AS_UL2(&C)).x, A, &long_state[(C.x & E2I_MASK) >> 3]);
|
||||
|
||||
j = (A.x & E2I_MASK) >> 3;
|
||||
cn_aes_single_round_b((uint8_t*)sharedMemory, &long_state[j], A, &B);
|
||||
AS_UINT4(&long_state[j]) = C ^ B;
|
||||
MUL_SUM_XOR_DST_0((AS_UL2(&B)).x, A, &long_state[(B.x & E2I_MASK) >> 3]);
|
||||
}
|
||||
|
||||
if (bfactor) {
|
||||
AS_UINT4(ctx_a) = A;
|
||||
AS_UINT4(ctx_b) = B;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------
|
||||
|
||||
__device__ __forceinline__ void store_variant1(uint64_t* long_state, uint4 Z)
|
||||
{
|
||||
const uint32_t tmp = (Z.z >> 24); // __byte_perm(src, 0, 0x7773);
|
||||
const uint32_t index = (((tmp >> 3) & 6u) | (tmp & 1u)) << 1;
|
||||
Z.z = (Z.z & 0x00ffffffu) | ((tmp ^ ((0x75310u >> index) & 0x30u)) << 24);
|
||||
AS_UINT4(long_state) = Z;
|
||||
}
|
||||
|
||||
__device__ __forceinline__ void store_variant2(uint64_t* long_state, uint4 Z)
|
||||
{
|
||||
const uint32_t tmp = (Z.z >> 24); // __byte_perm(src, 0, 0x7773);
|
||||
const uint32_t index = (((tmp >> 4) & 6u) | (tmp & 1u)) << 1;
|
||||
Z.z = (Z.z & 0x00ffffffu) | ((tmp ^ ((0x75312u >> index) & 0x30u)) << 24);
|
||||
AS_UINT4(long_state) = Z;
|
||||
}
|
||||
|
||||
__device__ __forceinline__ void MUL_SUM_XOR_DST_1(const uint64_t m, uint4 &a, void* far_dst, uint64_t tweak)
|
||||
{
|
||||
ulonglong2 d = AS_UL2(far_dst);
|
||||
ulonglong2 p = cuda_mul128(m, d.x);
|
||||
p += AS_UL2(&a);
|
||||
AS_UL2(&a) = p ^ d;
|
||||
p.y = p.y ^ tweak;
|
||||
AS_UL2(far_dst) = p;
|
||||
}
|
||||
|
||||
__global__
|
||||
void monero_gpu_phase2(const uint32_t threads, const uint16_t bfactor, const uint32_t partidx,
|
||||
uint64_t * __restrict__ d_long_state, uint32_t * __restrict__ d_ctx_a, uint32_t * __restrict__ d_ctx_b,
|
||||
uint64_t * __restrict__ d_tweak)
|
||||
{
|
||||
__shared__ __align__(16) uint32_t sharedMemory[1024];
|
||||
cn_aes_gpu_init(sharedMemory);
|
||||
__syncthreads();
|
||||
|
||||
const uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
if (thread < threads)
|
||||
{
|
||||
const uint32_t batchsize = ITER >> (2 + bfactor);
|
||||
const uint32_t start = partidx * batchsize;
|
||||
const uint32_t end = start + batchsize;
|
||||
uint64_t tweak = d_tweak[thread];
|
||||
|
||||
void * ctx_a = (void*)(&d_ctx_a[thread << 2]);
|
||||
void * ctx_b = (void*)(&d_ctx_b[thread << 2]);
|
||||
uint4 A = AS_UINT4(ctx_a); // ld.global.u32.v4
|
||||
uint4 B = AS_UINT4(ctx_b);
|
||||
|
||||
uint64_t * long_state = &d_long_state[thread << LONG_SHL64];
|
||||
for (int i = start; i < end; i++) // end = 262144
|
||||
{
|
||||
uint4 C;
|
||||
uint32_t j = (A.x & E2I_MASK) >> 3;
|
||||
cn_aes_single_round_b((uint8_t*)sharedMemory, &long_state[j], A, &C);
|
||||
store_variant1(&long_state[j], C ^ B); // st.global
|
||||
MUL_SUM_XOR_DST_1((AS_UL2(&C)).x, A, &long_state[(C.x & E2I_MASK) >> 3], tweak);
|
||||
|
||||
j = (A.x & E2I_MASK) >> 3;
|
||||
cn_aes_single_round_b((uint8_t*)sharedMemory, &long_state[j], A, &B);
|
||||
store_variant1(&long_state[j], C ^ B);
|
||||
MUL_SUM_XOR_DST_1((AS_UL2(&B)).x, A, &long_state[(B.x & E2I_MASK) >> 3], tweak);
|
||||
}
|
||||
if (bfactor) {
|
||||
AS_UINT4(ctx_a) = A;
|
||||
AS_UINT4(ctx_b) = B;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------
|
||||
|
||||
__global__
|
||||
void stellite_gpu_phase2(const uint32_t threads, const uint16_t bfactor, const uint32_t partidx,
|
||||
uint64_t * __restrict__ d_long_state, uint32_t * __restrict__ d_ctx_a, uint32_t * __restrict__ d_ctx_b,
|
||||
uint64_t * __restrict__ d_tweak)
|
||||
{
|
||||
__shared__ __align__(16) uint32_t sharedMemory[1024];
|
||||
cn_aes_gpu_init(sharedMemory);
|
||||
__syncthreads();
|
||||
|
||||
const uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
if (thread < threads)
|
||||
{
|
||||
const uint32_t batchsize = ITER >> (2 + bfactor);
|
||||
const uint32_t start = partidx * batchsize;
|
||||
const uint32_t end = start + batchsize;
|
||||
uint64_t tweak = d_tweak[thread];
|
||||
|
||||
void * ctx_a = (void*)(&d_ctx_a[thread << 2]);
|
||||
void * ctx_b = (void*)(&d_ctx_b[thread << 2]);
|
||||
uint4 A = AS_UINT4(ctx_a); // ld.global.u32.v4
|
||||
uint4 B = AS_UINT4(ctx_b);
|
||||
|
||||
uint64_t * long_state = &d_long_state[thread << LONG_SHL64];
|
||||
for (int i = start; i < end; i++) // end = 262144
|
||||
{
|
||||
uint4 C;
|
||||
uint32_t j = (A.x & E2I_MASK) >> 3;
|
||||
cn_aes_single_round_b((uint8_t*)sharedMemory, &long_state[j], A, &C);
|
||||
store_variant2(&long_state[j], C ^ B); // st.global
|
||||
MUL_SUM_XOR_DST_1((AS_UL2(&C)).x, A, &long_state[(C.x & E2I_MASK) >> 3], tweak);
|
||||
|
||||
j = (A.x & E2I_MASK) >> 3;
|
||||
cn_aes_single_round_b((uint8_t*)sharedMemory, &long_state[j], A, &B);
|
||||
store_variant2(&long_state[j], C ^ B);
|
||||
MUL_SUM_XOR_DST_1((AS_UL2(&B)).x, A, &long_state[(B.x & E2I_MASK) >> 3], tweak);
|
||||
}
|
||||
if (bfactor) {
|
||||
AS_UINT4(ctx_a) = A;
|
||||
AS_UINT4(ctx_b) = B;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------
|
||||
|
||||
__global__
|
||||
void cryptonight_gpu_phase3(const uint32_t threads, const uint32_t * __restrict__ d_long_state,
|
||||
uint32_t * __restrict__ d_ctx_state, const uint32_t * __restrict__ d_ctx_key2)
|
||||
{
|
||||
__shared__ uint32_t sharedMemory[1024];
|
||||
|
||||
cn_aes_gpu_init(sharedMemory);
|
||||
__syncthreads();
|
||||
|
||||
const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x) >> 3;
|
||||
|
||||
if(thread < threads)
|
||||
{
|
||||
const int sub = (threadIdx.x & 7) << 2;
|
||||
const uint32_t *longstate = &d_long_state[(thread << LONG_SHL32) + sub];
|
||||
uint32_t key[40], text[4];
|
||||
MEMCPY8(key, d_ctx_key2 + thread * 40, 20);
|
||||
MEMCPY8(text, d_ctx_state + thread * 50 + sub + 16, 2);
|
||||
|
||||
for(int i = 0; i < LONG_LOOPS32; i += 32)
|
||||
{
|
||||
#pragma unroll
|
||||
for(int j = 0; j < 4; ++j)
|
||||
text[j] ^= longstate[i + j];
|
||||
|
||||
cn_aes_pseudo_round_mut(sharedMemory, text, key);
|
||||
}
|
||||
|
||||
MEMCPY8(d_ctx_state + thread * 50 + sub + 16, text, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------
|
||||
|
||||
extern int device_bfactor[MAX_GPUS];
|
||||
|
||||
__host__
|
||||
void cryptonight_core_cuda(int thr_id, uint32_t blocks, uint32_t threads, uint64_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, int variant, uint64_t *d_ctx_tweak)
|
||||
{
|
||||
dim3 grid(blocks);
|
||||
dim3 block(threads);
|
||||
dim3 block4(threads << 2);
|
||||
dim3 block8(threads << 3);
|
||||
|
||||
const uint16_t bfactor = (uint16_t) device_bfactor[thr_id];
|
||||
const uint32_t partcount = 1U << bfactor;
|
||||
const uint32_t throughput = (uint32_t) (blocks*threads);
|
||||
|
||||
const int bsleep = bfactor ? 100 : 0;
|
||||
const int dev_id = device_map[thr_id];
|
||||
|
||||
cryptonight_gpu_phase1 <<<grid, block8>>> (throughput, (uint32_t*) d_long_state, d_ctx_state, d_ctx_key1);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
if(partcount > 1) usleep(bsleep);
|
||||
|
||||
for (uint32_t i = 0; i < partcount; i++)
|
||||
{
|
||||
dim3 b = device_sm[dev_id] >= 300 ? block4 : block;
|
||||
if (variant == 0)
|
||||
cryptonight_gpu_phase2 <<<grid, b>>> (throughput, bfactor, i, d_long_state, d_ctx_a, d_ctx_b);
|
||||
else if (variant == 1 || cryptonight_fork == 8)
|
||||
monero_gpu_phase2 <<<grid, b>>> (throughput, bfactor, i, d_long_state, d_ctx_a, d_ctx_b, d_ctx_tweak);
|
||||
else if (variant == 2 && cryptonight_fork == 3)
|
||||
stellite_gpu_phase2 <<<grid, b>>> (throughput, bfactor, i, d_long_state, d_ctx_a, d_ctx_b, d_ctx_tweak);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
if(partcount > 1) usleep(bsleep);
|
||||
}
|
||||
//cudaDeviceSynchronize();
|
||||
//exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
cryptonight_gpu_phase3 <<<grid, block8>>> (throughput, (uint32_t*) d_long_state, d_ctx_state, d_ctx_key2);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
}
|
||||
@@ -1,269 +0,0 @@
|
||||
#include <miner.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include "oaes_lib.h"
|
||||
#include "cryptonight.h"
|
||||
|
||||
extern "C" {
|
||||
#include <sph/sph_blake.h>
|
||||
#include <sph/sph_groestl.h>
|
||||
#include <sph/sph_jh.h>
|
||||
#include <sph/sph_skein.h>
|
||||
#include "cpu/c_keccak.h"
|
||||
}
|
||||
|
||||
struct cryptonight_ctx {
|
||||
uint8_t long_state[MEMORY];
|
||||
union cn_slow_hash_state state;
|
||||
uint8_t text[INIT_SIZE_BYTE];
|
||||
uint8_t a[AES_BLOCK_SIZE];
|
||||
uint8_t b[AES_BLOCK_SIZE];
|
||||
uint8_t c[AES_BLOCK_SIZE];
|
||||
oaes_ctx* aes_ctx;
|
||||
};
|
||||
|
||||
static void do_blake_hash(const void* input, size_t len, void* output)
|
||||
{
|
||||
uchar hash[32];
|
||||
sph_blake256_context ctx;
|
||||
sph_blake256_set_rounds(14);
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, input, len);
|
||||
sph_blake256_close(&ctx, hash);
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
|
||||
static void do_groestl_hash(const void* input, size_t len, void* output)
|
||||
{
|
||||
uchar hash[32];
|
||||
sph_groestl256_context ctx;
|
||||
sph_groestl256_init(&ctx);
|
||||
sph_groestl256(&ctx, input, len);
|
||||
sph_groestl256_close(&ctx, hash);
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
|
||||
static void do_jh_hash(const void* input, size_t len, void* output)
|
||||
{
|
||||
uchar hash[64];
|
||||
sph_jh256_context ctx;
|
||||
sph_jh256_init(&ctx);
|
||||
sph_jh256(&ctx, input, len);
|
||||
sph_jh256_close(&ctx, hash);
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
|
||||
static void do_skein_hash(const void* input, size_t len, void* output)
|
||||
{
|
||||
uchar hash[32];
|
||||
sph_skein256_context ctx;
|
||||
sph_skein256_init(&ctx);
|
||||
sph_skein256(&ctx, input, len);
|
||||
sph_skein256_close(&ctx, hash);
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
|
||||
// todo: use sph if possible
|
||||
static void keccak_hash_permutation(union hash_state *state) {
|
||||
keccakf((uint64_t*)state, 24);
|
||||
}
|
||||
|
||||
static void keccak_hash_process(union hash_state *state, const uint8_t *buf, size_t count) {
|
||||
keccak1600(buf, (int)count, (uint8_t*)state);
|
||||
}
|
||||
|
||||
extern "C" int fast_aesb_single_round(const uint8_t *in, uint8_t*out, const uint8_t *expandedKey);
|
||||
extern "C" int aesb_single_round(const uint8_t *in, uint8_t*out, const uint8_t *expandedKey);
|
||||
extern "C" int aesb_pseudo_round_mut(uint8_t *val, uint8_t *expandedKey);
|
||||
extern "C" int fast_aesb_pseudo_round_mut(uint8_t *val, uint8_t *expandedKey);
|
||||
|
||||
static void (* const extra_hashes[4])(const void*, size_t, void *) = {
|
||||
do_blake_hash, do_groestl_hash, do_jh_hash, do_skein_hash
|
||||
};
|
||||
|
||||
static uint64_t mul128(uint64_t multiplier, uint64_t multiplicand, uint64_t* product_hi)
|
||||
{
|
||||
// multiplier = ab = a * 2^32 + b
|
||||
// multiplicand = cd = c * 2^32 + d
|
||||
// ab * cd = a * c * 2^64 + (a * d + b * c) * 2^32 + b * d
|
||||
uint64_t a = hi_dword(multiplier);
|
||||
uint64_t b = lo_dword(multiplier);
|
||||
uint64_t c = hi_dword(multiplicand);
|
||||
uint64_t d = lo_dword(multiplicand);
|
||||
|
||||
uint64_t ac = a * c;
|
||||
uint64_t ad = a * d;
|
||||
uint64_t bc = b * c;
|
||||
uint64_t bd = b * d;
|
||||
|
||||
uint64_t adbc = ad + bc;
|
||||
uint64_t adbc_carry = adbc < ad ? 1 : 0;
|
||||
|
||||
// multiplier * multiplicand = product_hi * 2^64 + product_lo
|
||||
uint64_t product_lo = bd + (adbc << 32);
|
||||
uint64_t product_lo_carry = product_lo < bd ? 1 : 0;
|
||||
*product_hi = ac + (adbc >> 32) + (adbc_carry << 32) + product_lo_carry;
|
||||
|
||||
return product_lo;
|
||||
}
|
||||
|
||||
static size_t e2i(const uint8_t* a) {
|
||||
return (*((uint64_t*) a) / AES_BLOCK_SIZE) & (MEMORY / AES_BLOCK_SIZE - 1);
|
||||
}
|
||||
|
||||
static void mul(const uint8_t* a, const uint8_t* b, uint8_t* res) {
|
||||
((uint64_t*) res)[1] = mul128(((uint64_t*) a)[0], ((uint64_t*) b)[0], (uint64_t*) res);
|
||||
}
|
||||
|
||||
static void sum_half_blocks(uint8_t* a, const uint8_t* b) {
|
||||
((uint64_t*) a)[0] += ((uint64_t*) b)[0];
|
||||
((uint64_t*) a)[1] += ((uint64_t*) b)[1];
|
||||
}
|
||||
|
||||
static void sum_half_blocks_dst(const uint8_t* a, const uint8_t* b, uint8_t* dst) {
|
||||
((uint64_t*) dst)[0] = ((uint64_t*) a)[0] + ((uint64_t*) b)[0];
|
||||
((uint64_t*) dst)[1] = ((uint64_t*) a)[1] + ((uint64_t*) b)[1];
|
||||
}
|
||||
|
||||
static void mul_sum_dst(const uint8_t* a, const uint8_t* b, const uint8_t* c, uint8_t* dst) {
|
||||
((uint64_t*) dst)[1] = mul128(((uint64_t*) a)[0], ((uint64_t*) b)[0], (uint64_t*) dst) + ((uint64_t*) c)[1];
|
||||
((uint64_t*) dst)[0] += ((uint64_t*) c)[0];
|
||||
}
|
||||
|
||||
static void mul_sum_xor_dst(const uint8_t* a, uint8_t* c, uint8_t* dst, const int variant, const uint64_t tweak) {
|
||||
uint64_t hi, lo = 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] = variant ? lo ^ tweak : lo;
|
||||
}
|
||||
|
||||
static void copy_block(uint8_t* dst, const uint8_t* src) {
|
||||
((uint64_t*) dst)[0] = ((uint64_t*) src)[0];
|
||||
((uint64_t*) dst)[1] = ((uint64_t*) src)[1];
|
||||
}
|
||||
|
||||
static void xor_blocks(uint8_t* a, const uint8_t* b) {
|
||||
((uint64_t*) a)[0] ^= ((uint64_t*) b)[0];
|
||||
((uint64_t*) a)[1] ^= ((uint64_t*) b)[1];
|
||||
}
|
||||
|
||||
static void xor_blocks_dst(const uint8_t* a, const uint8_t* b, uint8_t* dst) {
|
||||
((uint64_t*) dst)[0] = ((uint64_t*) a)[0] ^ ((uint64_t*) b)[0];
|
||||
((uint64_t*) dst)[1] = ((uint64_t*) a)[1] ^ ((uint64_t*) b)[1];
|
||||
}
|
||||
|
||||
static void cryptonight_store_variant(void* state, int variant) {
|
||||
if (variant == 1 || cryptonight_fork == 8) {
|
||||
// monero and graft
|
||||
const uint8_t tmp = ((const uint8_t*)(state))[11];
|
||||
const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1;
|
||||
((uint8_t*)(state))[11] = tmp ^ ((0x75310 >> index) & 0x30);
|
||||
} else if (variant == 2 && cryptonight_fork == 3) {
|
||||
// stellite
|
||||
const uint8_t tmp = ((const uint8_t*)(state))[11];
|
||||
const uint8_t index = (((tmp >> 4) & 6) | (tmp & 1)) << 1;
|
||||
((uint8_t*)(state))[11] = tmp ^ ((0x75312 >> index) & 0x30);
|
||||
}
|
||||
}
|
||||
|
||||
static void cryptonight_hash_ctx(void* output, const void* input, const size_t len, struct cryptonight_ctx* ctx, const int variant)
|
||||
{
|
||||
size_t i, j;
|
||||
|
||||
keccak_hash_process(&ctx->state.hs, (const uint8_t*) input, len);
|
||||
ctx->aes_ctx = (oaes_ctx*) oaes_alloc();
|
||||
memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE);
|
||||
|
||||
const uint64_t tweak = variant ? *((uint64_t*) (((uint8_t*)input) + 35)) ^ ctx->state.hs.w[24] : 0;
|
||||
|
||||
oaes_key_import_data(ctx->aes_ctx, ctx->state.hs.b, AES_KEY_SIZE);
|
||||
for (i = 0; likely(i < MEMORY); i += INIT_SIZE_BYTE) {
|
||||
#undef RND
|
||||
#define RND(p) aesb_pseudo_round_mut(&ctx->text[AES_BLOCK_SIZE * p], ctx->aes_ctx->key->exp_data);
|
||||
RND(0);
|
||||
RND(1);
|
||||
RND(2);
|
||||
RND(3);
|
||||
RND(4);
|
||||
RND(5);
|
||||
RND(6);
|
||||
RND(7);
|
||||
memcpy(&ctx->long_state[i], ctx->text, INIT_SIZE_BYTE);
|
||||
}
|
||||
|
||||
xor_blocks_dst(&ctx->state.k[0], &ctx->state.k[32], ctx->a);
|
||||
xor_blocks_dst(&ctx->state.k[16], &ctx->state.k[48], ctx->b);
|
||||
|
||||
for (i = 0; likely(i < ITER / 4); ++i) {
|
||||
j = e2i(ctx->a) * AES_BLOCK_SIZE;
|
||||
aesb_single_round(&ctx->long_state[j], ctx->c, ctx->a);
|
||||
xor_blocks_dst(ctx->c, ctx->b, &ctx->long_state[j]);
|
||||
cryptonight_store_variant(&ctx->long_state[j], variant);
|
||||
mul_sum_xor_dst(ctx->c, ctx->a, &ctx->long_state[e2i(ctx->c) * AES_BLOCK_SIZE], variant, tweak);
|
||||
|
||||
j = e2i(ctx->a) * AES_BLOCK_SIZE;
|
||||
aesb_single_round(&ctx->long_state[j], ctx->b, ctx->a);
|
||||
xor_blocks_dst(ctx->b, ctx->c, &ctx->long_state[j]);
|
||||
cryptonight_store_variant(&ctx->long_state[j], variant);
|
||||
mul_sum_xor_dst(ctx->b, ctx->a, &ctx->long_state[e2i(ctx->b) * AES_BLOCK_SIZE], variant, tweak);
|
||||
}
|
||||
|
||||
memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE);
|
||||
oaes_key_import_data(ctx->aes_ctx, &ctx->state.hs.b[32], AES_KEY_SIZE);
|
||||
for (i = 0; likely(i < MEMORY); i += INIT_SIZE_BYTE) {
|
||||
#undef RND
|
||||
#define RND(p) xor_blocks(&ctx->text[p * AES_BLOCK_SIZE], &ctx->long_state[i + p * AES_BLOCK_SIZE]); \
|
||||
aesb_pseudo_round_mut(&ctx->text[p * AES_BLOCK_SIZE], ctx->aes_ctx->key->exp_data);
|
||||
RND(0);
|
||||
RND(1);
|
||||
RND(2);
|
||||
RND(3);
|
||||
RND(4);
|
||||
RND(5);
|
||||
RND(6);
|
||||
RND(7);
|
||||
}
|
||||
memcpy(ctx->state.init, ctx->text, INIT_SIZE_BYTE);
|
||||
keccak_hash_permutation(&ctx->state.hs);
|
||||
|
||||
int extra_algo = ctx->state.hs.b[0] & 3;
|
||||
extra_hashes[extra_algo](&ctx->state, 200, output);
|
||||
if (opt_debug) applog(LOG_DEBUG, "extra algo=%d", extra_algo);
|
||||
|
||||
oaes_free((OAES_CTX **) &ctx->aes_ctx);
|
||||
}
|
||||
|
||||
void cryptonight_hash_variant(void* output, const void* input, size_t len, int variant)
|
||||
{
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*)malloc(sizeof(struct cryptonight_ctx));
|
||||
cryptonight_hash_ctx(output, input, len, ctx, variant);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
void cryptonight_hash(void* output, const void* input)
|
||||
{
|
||||
cryptonight_fork = 1;
|
||||
cryptonight_hash_variant(output, input, 76, 0);
|
||||
}
|
||||
|
||||
void graft_hash(void* output, const void* input)
|
||||
{
|
||||
cryptonight_fork = 8;
|
||||
cryptonight_hash_variant(output, input, 76, 1);
|
||||
}
|
||||
|
||||
void monero_hash(void* output, const void* input)
|
||||
{
|
||||
cryptonight_fork = 7;
|
||||
cryptonight_hash_variant(output, input, 76, 1);
|
||||
}
|
||||
|
||||
void stellite_hash(void* output, const void* input)
|
||||
{
|
||||
cryptonight_fork = 3;
|
||||
cryptonight_hash_variant(output, input, 76, 2);
|
||||
}
|
||||
|
||||
@@ -1,212 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <miner.h>
|
||||
#include <cuda_helper.h>
|
||||
|
||||
#include "cryptonight.h"
|
||||
|
||||
static uint32_t *d_input[MAX_GPUS];
|
||||
static uint32_t *d_target[MAX_GPUS];
|
||||
static uint32_t *d_result[MAX_GPUS];
|
||||
|
||||
typedef uint8_t BitSequence;
|
||||
typedef uint32_t DataLength;
|
||||
#include "cn_keccak.cuh"
|
||||
#include "cn_blake.cuh"
|
||||
#include "cn_groestl.cuh"
|
||||
#include "cn_jh.cuh"
|
||||
#include "cn_skein.cuh"
|
||||
|
||||
__constant__ uint8_t d_sub_byte[16][16] = {
|
||||
{0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76},
|
||||
{0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0},
|
||||
{0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15},
|
||||
{0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75},
|
||||
{0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84},
|
||||
{0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf},
|
||||
{0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8},
|
||||
{0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2},
|
||||
{0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73},
|
||||
{0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb},
|
||||
{0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79},
|
||||
{0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08},
|
||||
{0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a},
|
||||
{0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e},
|
||||
{0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf},
|
||||
{0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16}
|
||||
};
|
||||
|
||||
__device__ __forceinline__
|
||||
void cryptonight_aes_set_key(uint32_t * __restrict__ key, const uint32_t * __restrict__ data)
|
||||
{
|
||||
const uint32_t aes_gf[10] = {
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36
|
||||
};
|
||||
|
||||
MEMCPY4(key, data, 8);
|
||||
#pragma unroll
|
||||
for(int i = 8; i < 40; i++)
|
||||
{
|
||||
uint8_t temp[4];
|
||||
*(uint32_t *)temp = key[i - 1];
|
||||
|
||||
if(i % 8 == 0) {
|
||||
*(uint32_t *)temp = ROTR32(*(uint32_t *)temp, 8);
|
||||
for(int j = 0; j < 4; j++)
|
||||
temp[j] = d_sub_byte[(temp[j] >> 4) & 0x0f][temp[j] & 0x0f];
|
||||
*(uint32_t *)temp ^= aes_gf[i / 8 - 1];
|
||||
}
|
||||
else if(i % 8 == 4) {
|
||||
#pragma unroll
|
||||
for(int j = 0; j < 4; j++)
|
||||
temp[j] = d_sub_byte[(temp[j] >> 4) & 0x0f][temp[j] & 0x0f];
|
||||
}
|
||||
|
||||
key[i] = key[(i - 8)] ^ *(uint32_t *)temp;
|
||||
}
|
||||
}
|
||||
|
||||
__global__
|
||||
void cryptonight_extra_gpu_prepare(const uint32_t threads, const 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,
|
||||
uint32_t * __restrict__ d_ctx_key1, uint32_t * __restrict__ d_ctx_key2, int variant, uint64_t * d_ctx_tweak)
|
||||
{
|
||||
const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if(thread < threads)
|
||||
{
|
||||
uint64_t ctx_state[25];
|
||||
uint32_t ctx_a[4];
|
||||
uint32_t ctx_b[4];
|
||||
uint32_t ctx_key1[40];
|
||||
uint32_t ctx_key2[40];
|
||||
uint32_t input[19];
|
||||
|
||||
MEMCPY4(input, d_input, 19);
|
||||
|
||||
uint32_t nonce = startNonce + thread;
|
||||
*(((uint8_t *)input) + 39) = nonce & 0xff;
|
||||
*(((uint8_t *)input) + 40) = (nonce >> 8) & 0xff;
|
||||
*(((uint8_t *)input) + 41) = (nonce >> 16) & 0xff;
|
||||
*(((uint8_t *)input) + 42) = (nonce >> 24) & 0xff;
|
||||
|
||||
cn_keccak(input, ctx_state);
|
||||
MEMCPY4(&d_ctx_state[thread * 50U], ctx_state, 50);
|
||||
|
||||
cryptonight_aes_set_key(ctx_key1, (uint32_t*)(&ctx_state[0]));
|
||||
cryptonight_aes_set_key(ctx_key2, (uint32_t*)(&ctx_state[4]));
|
||||
MEMCPY4(&d_ctx_key1[thread * 40U], ctx_key1, 40);
|
||||
MEMCPY4(&d_ctx_key2[thread * 40U], ctx_key2, 40);
|
||||
|
||||
XOR_BLOCKS_DST(&ctx_state[0], &ctx_state[4], ctx_a);
|
||||
XOR_BLOCKS_DST(&ctx_state[2], &ctx_state[6], ctx_b);
|
||||
MEMCPY4(&d_ctx_a[thread * 4U], ctx_a, 4);
|
||||
MEMCPY4(&d_ctx_b[thread * 4U], ctx_b, 4);
|
||||
|
||||
if (variant) {
|
||||
uint2 tweak = AS_UINT2(&ctx_state[24]);
|
||||
//tweak.x ^= (input[8] >> 24) | (input[9] << 8);
|
||||
tweak.x ^= __byte_perm(input[8], input[ 9], 0x6543);
|
||||
tweak.y ^= __byte_perm(input[9], input[10], 0x6543);
|
||||
MEMCPY4(&d_ctx_tweak[thread], &tweak, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__global__
|
||||
void cryptonight_extra_gpu_final(const uint32_t threads, uint32_t startNonce, const uint32_t * __restrict__ d_target,
|
||||
uint32_t * __restrict__ resNonces, uint32_t * __restrict__ d_ctx_state)
|
||||
{
|
||||
const uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
if(thread < threads)
|
||||
{
|
||||
uint32_t *ctx_state = &d_ctx_state[thread * 50U];
|
||||
uint32_t hash[8];
|
||||
uint32_t state[50];
|
||||
|
||||
#pragma unroll 25
|
||||
for(int i = 0; i < 50; i+=2)
|
||||
AS_UINT2(&state[i]) = AS_UINT2(&ctx_state[i]);
|
||||
|
||||
cn_keccakf2((uint64_t *)state);
|
||||
|
||||
int branch = ((uint8_t *)state)[0] & 0x03;
|
||||
if(branch == 0)
|
||||
cn_blake((const uint8_t *)state, 200, hash);
|
||||
if(branch == 1)
|
||||
cn_groestl((const uint8_t *)state, 200, hash);
|
||||
if(branch == 2)
|
||||
cn_jh((const uint8_t *)state, 200, hash);
|
||||
if(branch == 3)
|
||||
cn_skein((const uint8_t *)state, 200, hash);
|
||||
|
||||
if(hash[7] <= d_target[1] && hash[6] <= d_target[0])
|
||||
{
|
||||
const uint32_t nonce = startNonce + thread;
|
||||
uint32_t tmp = atomicExch(resNonces, nonce);
|
||||
if(tmp != UINT32_MAX)
|
||||
resNonces[1] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void cryptonight_extra_setData(int thr_id, const void *data, const void *ptarget)
|
||||
{
|
||||
uint32_t *pTargetIn = (uint32_t*) ptarget;
|
||||
cudaMemcpy(d_input[thr_id], data, 20 * sizeof(uint32_t), cudaMemcpyHostToDevice);
|
||||
cudaMemcpy(d_target[thr_id], &pTargetIn[6], 2 * sizeof(uint32_t), cudaMemcpyHostToDevice);
|
||||
cudaMemset(d_result[thr_id], 0xFF, 2 * sizeof(uint32_t));
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
__host__
|
||||
void cryptonight_extra_init(int thr_id)
|
||||
{
|
||||
cudaMalloc(&d_input[thr_id], 20 * sizeof(uint32_t));
|
||||
cudaMalloc(&d_target[thr_id], 2 * sizeof(uint32_t));
|
||||
cudaMalloc(&d_result[thr_id], 2 * sizeof(uint32_t));
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
__host__
|
||||
void cryptonight_extra_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, int variant, uint64_t *d_ctx_tweak)
|
||||
{
|
||||
uint32_t threadsperblock = 128;
|
||||
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
cryptonight_extra_gpu_prepare <<<grid, block>>> (threads, d_input[thr_id], startNonce, d_ctx_state, d_ctx_a, d_ctx_b, d_ctx_key1, d_ctx_key2, variant, d_ctx_tweak);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
__host__
|
||||
void cryptonight_extra_final(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *resNonces, uint32_t *d_ctx_state)
|
||||
{
|
||||
uint32_t threadsperblock = 128;
|
||||
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
cryptonight_extra_gpu_final <<<grid, block>>> (threads, startNonce, d_target[thr_id], d_result[thr_id], d_ctx_state);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
cudaMemcpy(resNonces, d_result[thr_id], 2 * sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
__host__
|
||||
void cryptonight_extra_free(int thr_id)
|
||||
{
|
||||
if (d_input[thr_id]) {
|
||||
cudaFree(d_input[thr_id]);
|
||||
cudaFree(d_target[thr_id]);
|
||||
cudaFree(d_result[thr_id]);
|
||||
d_input[thr_id] = NULL;
|
||||
}
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
|
||||
#include "cryptonight.h"
|
||||
|
||||
extern char *device_config[MAX_GPUS]; // -l 32x16
|
||||
|
||||
static __thread uint32_t cn_blocks;
|
||||
static __thread uint32_t cn_threads;
|
||||
|
||||
// used for gpu intensity on algo init
|
||||
static __thread bool gpu_init_shown = false;
|
||||
#define gpulog_init(p,thr,fmt, ...) if (!gpu_init_shown) \
|
||||
gpulog(p, thr, fmt, ##__VA_ARGS__)
|
||||
|
||||
static uint64_t *d_long_state[MAX_GPUS];
|
||||
static uint32_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];
|
||||
static uint64_t *d_ctx_tweak[MAX_GPUS];
|
||||
static uint32_t *d_ctx_a[MAX_GPUS];
|
||||
static uint32_t *d_ctx_b[MAX_GPUS];
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_cryptonight(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done, int variant)
|
||||
{
|
||||
int res = 0;
|
||||
uint32_t throughput = 0;
|
||||
|
||||
uint32_t *ptarget = work->target;
|
||||
uint8_t *pdata = (uint8_t*) work->data;
|
||||
uint32_t *nonceptr = (uint32_t*) (&pdata[39]);
|
||||
const uint32_t first_nonce = *nonceptr;
|
||||
uint32_t nonce = first_nonce;
|
||||
int dev_id = device_map[thr_id];
|
||||
|
||||
if(opt_benchmark) {
|
||||
ptarget[7] = 0x00ff;
|
||||
}
|
||||
|
||||
if(!init[thr_id])
|
||||
{
|
||||
int mem = cuda_available_memory(thr_id);
|
||||
int mul = device_sm[dev_id] >= 300 ? 4 : 1; // see cryptonight-core.cu
|
||||
cn_threads = device_sm[dev_id] >= 600 ? 16 : 8; // real TPB is x4 on SM3+
|
||||
cn_blocks = device_mpcount[dev_id] * 4;
|
||||
if (cn_blocks*cn_threads*2.2 > mem) cn_blocks = device_mpcount[dev_id] * 2;
|
||||
|
||||
if (!opt_quiet)
|
||||
gpulog_init(LOG_INFO, thr_id, "%s, %d MB available, %hd SMX", device_name[dev_id],
|
||||
mem, device_mpcount[dev_id]);
|
||||
|
||||
if (!device_config[thr_id]) {
|
||||
if(strcmp(device_name[dev_id], "TITAN V") == 0)
|
||||
device_config[thr_id] = strdup("80x24");
|
||||
if(strstr(device_name[dev_id], "V100"))
|
||||
device_config[thr_id] = strdup("80x24");
|
||||
}
|
||||
|
||||
if (device_config[thr_id]) {
|
||||
int res = sscanf(device_config[thr_id], "%ux%u", &cn_blocks, &cn_threads);
|
||||
throughput = cuda_default_throughput(thr_id, cn_blocks*cn_threads);
|
||||
gpulog_init(LOG_INFO, thr_id, "Using %ux%u(x%d) kernel launch config, %u threads",
|
||||
cn_blocks, cn_threads, mul, throughput);
|
||||
} else {
|
||||
throughput = cuda_default_throughput(thr_id, cn_blocks*cn_threads);
|
||||
if (throughput != cn_blocks*cn_threads && cn_threads) {
|
||||
cn_blocks = throughput / cn_threads;
|
||||
throughput = cn_threads * cn_blocks;
|
||||
}
|
||||
gpulog_init(LOG_INFO, thr_id, "%u threads (%g) with %u blocks",// of %ux%d",
|
||||
throughput, throughput2intensity(throughput), cn_blocks);//, cn_threads, mul);
|
||||
}
|
||||
|
||||
if(sizeof(size_t) == 4 && throughput > UINT32_MAX / MEMORY) {
|
||||
gpulog(LOG_ERR, thr_id, "THE 32bit VERSION CAN'T ALLOCATE MORE THAN 4GB OF MEMORY!");
|
||||
gpulog(LOG_ERR, thr_id, "PLEASE REDUCE THE NUMBER OF THREADS OR BLOCKS");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
cudaDeviceSetCacheConfig(cudaFuncCachePreferL1);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
|
||||
const size_t alloc = MEMORY * size_t(throughput);
|
||||
cryptonight_extra_init(thr_id);
|
||||
|
||||
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);
|
||||
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__);
|
||||
cudaMalloc(&d_ctx_key2[thr_id], 40 * sizeof(uint32_t) * throughput);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
cudaMalloc(&d_ctx_text[thr_id], 32 * sizeof(uint32_t) * throughput);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
cudaMalloc(&d_ctx_a[thr_id], 4 * sizeof(uint32_t) * throughput);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
cudaMalloc(&d_ctx_b[thr_id], 4 * sizeof(uint32_t) * throughput);
|
||||
exit_if_cudaerror(thr_id, __FUNCTION__, __LINE__);
|
||||
cudaMalloc(&d_ctx_tweak[thr_id], sizeof(uint64_t) * throughput);
|
||||
exit_if_cudaerror(thr_id, __FILE__, __LINE__);
|
||||
|
||||
gpu_init_shown = true;
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
throughput = cn_blocks*cn_threads;
|
||||
|
||||
do
|
||||
{
|
||||
const uint32_t Htarg = ptarget[7];
|
||||
uint32_t resNonces[2] = { UINT32_MAX, UINT32_MAX };
|
||||
|
||||
cryptonight_extra_setData(thr_id, pdata, ptarget);
|
||||
cryptonight_extra_prepare(thr_id, throughput, nonce, d_ctx_state[thr_id], d_ctx_a[thr_id], d_ctx_b[thr_id], d_ctx_key1[thr_id], d_ctx_key2[thr_id], variant, d_ctx_tweak[thr_id]);
|
||||
cryptonight_core_cuda(thr_id, cn_blocks, cn_threads, d_long_state[thr_id], d_ctx_state[thr_id], d_ctx_a[thr_id], d_ctx_b[thr_id], d_ctx_key1[thr_id], d_ctx_key2[thr_id], variant, d_ctx_tweak[thr_id]);
|
||||
cryptonight_extra_final(thr_id, throughput, nonce, resNonces, d_ctx_state[thr_id]);
|
||||
|
||||
*hashes_done = nonce - first_nonce + throughput;
|
||||
|
||||
if(resNonces[0] != UINT32_MAX)
|
||||
{
|
||||
uint32_t vhash[8];
|
||||
uint32_t tempdata[19];
|
||||
uint32_t *tempnonceptr = (uint32_t*)(((char*)tempdata) + 39);
|
||||
memcpy(tempdata, pdata, 76);
|
||||
*tempnonceptr = resNonces[0];
|
||||
cryptonight_hash_variant(vhash, tempdata, 76, variant);
|
||||
if(vhash[7] <= Htarg && fulltest(vhash, ptarget))
|
||||
{
|
||||
res = 1;
|
||||
work->nonces[0] = resNonces[0];
|
||||
work_set_target_ratio(work, vhash);
|
||||
// second nonce
|
||||
if(resNonces[1] != UINT32_MAX)
|
||||
{
|
||||
*tempnonceptr = resNonces[1];
|
||||
cryptonight_hash_variant(vhash, tempdata, 76, variant);
|
||||
if(vhash[7] <= Htarg && fulltest(vhash, ptarget)) {
|
||||
res++;
|
||||
work->nonces[1] = resNonces[1];
|
||||
} else {
|
||||
gpu_increment_reject(thr_id);
|
||||
}
|
||||
}
|
||||
goto done;
|
||||
} else if (vhash[7] > Htarg) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for nonce %08x does not validate on CPU!", resNonces[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint64_t) throughput + nonce >= max_nonce - 127) {
|
||||
nonce = max_nonce;
|
||||
break;
|
||||
}
|
||||
|
||||
nonce += throughput;
|
||||
gpulog(LOG_DEBUG, thr_id, "nonce %08x", nonce);
|
||||
|
||||
} while (!work_restart[thr_id].restart && max_nonce > (uint64_t)throughput + nonce);
|
||||
|
||||
done:
|
||||
gpulog(LOG_DEBUG, thr_id, "nonce %08x exit", nonce);
|
||||
work->valid_nonces = res;
|
||||
*nonceptr = nonce;
|
||||
return res;
|
||||
}
|
||||
|
||||
void free_cryptonight(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaFree(d_long_state[thr_id]);
|
||||
cudaFree(d_ctx_state[thr_id]);
|
||||
cudaFree(d_ctx_key1[thr_id]);
|
||||
cudaFree(d_ctx_key2[thr_id]);
|
||||
cudaFree(d_ctx_text[thr_id]);
|
||||
cudaFree(d_ctx_tweak[thr_id]);
|
||||
cudaFree(d_ctx_a[thr_id]);
|
||||
cudaFree(d_ctx_b[thr_id]);
|
||||
|
||||
cryptonight_extra_free(thr_id);
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
|
||||
init[thr_id] = false;
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
#pragma once
|
||||
#include <cuda_runtime.h>
|
||||
#include <miner.h>
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
/* avoid red underlining */
|
||||
#define __CUDA_ARCH__ 520
|
||||
struct uint3 {
|
||||
unsigned int x, y, z;
|
||||
};
|
||||
struct uint3 threadIdx;
|
||||
struct uint3 blockIdx;
|
||||
struct uint3 blockDim;
|
||||
#define atomicExch(p,y) (*p) = y
|
||||
#define __funnelshift_r(a,b,c) 1
|
||||
#define __syncthreads()
|
||||
#define __threadfence_block()
|
||||
#define asm(x)
|
||||
#define __shfl(a,b,c) 1
|
||||
#define __umul64hi(a,b) a*b
|
||||
#endif
|
||||
|
||||
#define MEMORY (1U << 21) // 2 MiB / 2097152 B
|
||||
#define ITER (1U << 20) // 1048576
|
||||
#define E2I_MASK 0x1FFFF0u
|
||||
|
||||
#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
|
||||
|
||||
#define AES_RKEY_LEN 4
|
||||
#define AES_COL_LEN 4
|
||||
#define AES_ROUND_BASE 7
|
||||
|
||||
#ifndef HASH_SIZE
|
||||
#define HASH_SIZE 32
|
||||
#endif
|
||||
|
||||
#ifndef HASH_DATA_AREA
|
||||
#define HASH_DATA_AREA 136
|
||||
#endif
|
||||
|
||||
#define hi_dword(x) (x >> 32)
|
||||
#define lo_dword(x) (x & 0xFFFFFFFF)
|
||||
|
||||
#define C32(x) ((uint32_t)(x ## U))
|
||||
#define T32(x) ((x) & C32(0xFFFFFFFF))
|
||||
|
||||
#ifndef ROTL64
|
||||
#if __CUDA_ARCH__ >= 350
|
||||
__forceinline__ __device__ uint64_t cuda_ROTL64(const uint64_t value, const int offset) {
|
||||
uint2 result;
|
||||
if(offset >= 32) {
|
||||
asm("shf.l.wrap.b32 %0, %1, %2, %3;" : "=r"(result.x) : "r"(__double2loint(__longlong_as_double(value))), "r"(__double2hiint(__longlong_as_double(value))), "r"(offset));
|
||||
asm("shf.l.wrap.b32 %0, %1, %2, %3;" : "=r"(result.y) : "r"(__double2hiint(__longlong_as_double(value))), "r"(__double2loint(__longlong_as_double(value))), "r"(offset));
|
||||
} else {
|
||||
asm("shf.l.wrap.b32 %0, %1, %2, %3;" : "=r"(result.x) : "r"(__double2hiint(__longlong_as_double(value))), "r"(__double2loint(__longlong_as_double(value))), "r"(offset));
|
||||
asm("shf.l.wrap.b32 %0, %1, %2, %3;" : "=r"(result.y) : "r"(__double2loint(__longlong_as_double(value))), "r"(__double2hiint(__longlong_as_double(value))), "r"(offset));
|
||||
}
|
||||
return __double_as_longlong(__hiloint2double(result.y, result.x));
|
||||
}
|
||||
#define ROTL64(x, n) (cuda_ROTL64(x, n))
|
||||
#else
|
||||
#define ROTL64(x, n) (((x) << (n)) | ((x) >> (64 - (n))))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ROTL32
|
||||
#if __CUDA_ARCH__ < 350
|
||||
#define ROTL32(x, n) T32(((x) << (n)) | ((x) >> (32 - (n))))
|
||||
#else
|
||||
#define ROTL32(x, n) __funnelshift_l( (x), (x), (n) )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ROTR32
|
||||
#if __CUDA_ARCH__ < 350
|
||||
#define ROTR32(x, n) (((x) >> (n)) | ((x) << (32 - (n))))
|
||||
#else
|
||||
#define ROTR32(x, n) __funnelshift_r( (x), (x), (n) )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define MEMSET8(dst,what,cnt) { \
|
||||
int i_memset8; \
|
||||
uint64_t *out_memset8 = (uint64_t *)(dst); \
|
||||
for( i_memset8 = 0; i_memset8 < cnt; i_memset8++ ) \
|
||||
out_memset8[i_memset8] = (what); }
|
||||
|
||||
#define MEMSET4(dst,what,cnt) { \
|
||||
int i_memset4; \
|
||||
uint32_t *out_memset4 = (uint32_t *)(dst); \
|
||||
for( i_memset4 = 0; i_memset4 < cnt; i_memset4++ ) \
|
||||
out_memset4[i_memset4] = (what); }
|
||||
|
||||
#define MEMCPY8(dst,src,cnt) { \
|
||||
int i_memcpy8; \
|
||||
uint64_t *in_memcpy8 = (uint64_t *)(src); \
|
||||
uint64_t *out_memcpy8 = (uint64_t *)(dst); \
|
||||
for( i_memcpy8 = 0; i_memcpy8 < cnt; i_memcpy8++ ) \
|
||||
out_memcpy8[i_memcpy8] = in_memcpy8[i_memcpy8]; }
|
||||
|
||||
#define MEMCPY4(dst,src,cnt) { \
|
||||
int i_memcpy4; \
|
||||
uint32_t *in_memcpy4 = (uint32_t *)(src); \
|
||||
uint32_t *out_memcpy4 = (uint32_t *)(dst); \
|
||||
for( i_memcpy4 = 0; i_memcpy4 < cnt; i_memcpy4++ ) \
|
||||
out_memcpy4[i_memcpy4] = in_memcpy4[i_memcpy4]; }
|
||||
|
||||
#define XOR_BLOCKS_DST(x,y,z) { \
|
||||
((uint64_t *)z)[0] = ((uint64_t *)(x))[0] ^ ((uint64_t *)(y))[0]; \
|
||||
((uint64_t *)z)[1] = ((uint64_t *)(x))[1] ^ ((uint64_t *)(y))[1]; }
|
||||
|
||||
#define E2I(x) ((size_t)(((*((uint64_t*)(x)) >> 4) & 0x1ffff)))
|
||||
|
||||
union hash_state {
|
||||
uint8_t b[200];
|
||||
uint64_t w[25];
|
||||
};
|
||||
|
||||
union cn_slow_hash_state {
|
||||
union hash_state hs;
|
||||
struct {
|
||||
uint8_t k[64];
|
||||
uint8_t init[INIT_SIZE_BYTE];
|
||||
};
|
||||
};
|
||||
|
||||
static inline void exit_if_cudaerror(int thr_id, const char *src, int line)
|
||||
{
|
||||
cudaError_t err = cudaGetLastError();
|
||||
if(err != cudaSuccess) {
|
||||
gpulog(LOG_ERR, thr_id, "%s %s line %d", cudaGetErrorString(err), src, line);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
void cryptonight_core_cuda(int thr_id, uint32_t blocks, uint32_t threads, uint64_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, int variant, uint64_t *d_ctx_tweak);
|
||||
|
||||
void cryptonight_extra_setData(int thr_id, const void *data, const void *ptarget);
|
||||
void cryptonight_extra_init(int thr_id);
|
||||
void cryptonight_extra_free(int thr_id);
|
||||
void cryptonight_extra_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, int variant, uint64_t *d_ctx_tweak);
|
||||
void cryptonight_extra_final(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *resnonce, uint32_t *d_ctx_state);
|
||||
@@ -1,573 +0,0 @@
|
||||
#ifndef UINT128_C_H
|
||||
#define UINT128_C_H
|
||||
|
||||
struct __uint128 {
|
||||
uint64_t Hi;
|
||||
uint64_t Lo;
|
||||
};
|
||||
typedef struct __uint128 uint128;
|
||||
|
||||
void Increment(uint128 * N)
|
||||
{
|
||||
uint64_t T = (N->Lo + 1);
|
||||
N->Hi += ((N->Lo ^T) & N->Lo) >> 63;
|
||||
N->Lo = T;
|
||||
}
|
||||
|
||||
void Decrement(uint128 * N)
|
||||
{
|
||||
uint64_t T = (N->Lo - 1);
|
||||
N->Hi -= ((T ^ N->Lo) & T) >> 63;
|
||||
N->Lo = T;
|
||||
}
|
||||
|
||||
void Add(uint128 * Ans, uint128 N, uint128 M)
|
||||
{
|
||||
uint64_t C = (((N.Lo & M.Lo) & 1) + (N.Lo >> 1) + (M.Lo >> 1)) >> 63;
|
||||
Ans->Hi = N.Hi + M.Hi + C;
|
||||
Ans->Lo = N.Lo + M.Lo;
|
||||
}
|
||||
|
||||
void Subtract(uint128 * Ans, uint128 N, uint128 M)
|
||||
{
|
||||
Ans->Lo = N.Lo - M.Lo;
|
||||
uint64_t C = (((Ans->Lo & M.Lo) & 1) + (M.Lo >> 1) + (Ans->Lo >> 1)) >> 63;
|
||||
Ans->Hi = N.Hi - (M.Hi + C);
|
||||
}
|
||||
|
||||
void inc128(uint128 N, uint128* A)
|
||||
{
|
||||
A->Lo = (N.Lo + 1);
|
||||
A->Hi = N.Hi + (((N.Lo ^ A->Lo) & N.Lo) >> 63);
|
||||
}
|
||||
|
||||
void dec128(uint128 N, uint128* A)
|
||||
{
|
||||
A->Lo = N.Lo - 1;
|
||||
A->Hi = N.Hi - (((A->Lo ^ N.Lo) & A->Lo) >> 63);
|
||||
}
|
||||
|
||||
void add128(uint128 N, uint128 M, uint128* A)
|
||||
{
|
||||
uint64_t C = (((N.Lo & M.Lo) & 1) + (N.Lo >> 1) + (M.Lo >> 1)) >> 63;
|
||||
A->Hi = N.Hi + M.Hi + C;
|
||||
A->Lo = N.Lo + M.Lo;
|
||||
}
|
||||
|
||||
void sub128(uint128 N, uint128 M, uint128* A)
|
||||
{
|
||||
A->Lo = N.Lo - M.Lo;
|
||||
uint64_t C = (((A->Lo & M.Lo) & 1) + (M.Lo >> 1) + (A->Lo >> 1)) >> 63;
|
||||
A->Hi = N.Hi - (M.Hi + C);
|
||||
}
|
||||
|
||||
void mult64to128(uint64_t u, uint64_t v, uint64_t * h, uint64_t *l)
|
||||
{
|
||||
uint64_t u1 = (u & 0xffffffff);
|
||||
uint64_t v1 = (v & 0xffffffff);
|
||||
uint64_t t = (u1 * v1);
|
||||
uint64_t w3 = (t & 0xffffffff);
|
||||
uint64_t k = (t >> 32);
|
||||
|
||||
u >>= 32;
|
||||
t = (u * v1) + k;
|
||||
k = (t & 0xffffffff);
|
||||
uint64_t w1 = (t >> 32);
|
||||
|
||||
v >>= 32;
|
||||
t = (u1 * v) + k;
|
||||
k = (t >> 32);
|
||||
|
||||
*h = (u * v) + w1 + k;
|
||||
*l = (t << 32) + w3;
|
||||
}
|
||||
|
||||
void mult128(uint128 N, uint128 M, uint128 * Ans)
|
||||
{
|
||||
mult64to128(N.Lo, M.Lo, &Ans->Hi, &Ans->Lo);
|
||||
Ans->Hi += (N.Hi * M.Lo) + (N.Lo * M.Hi);
|
||||
}
|
||||
|
||||
void mult128to256(uint128 N, uint128 M, uint128 * H, uint128 * L)
|
||||
{
|
||||
mult64to128(N.Hi, M.Hi, &H->Hi, &H->Lo);
|
||||
mult64to128(N.Lo, M.Lo, &L->Hi, &L->Lo);
|
||||
|
||||
uint128 T;
|
||||
mult64to128(N.Hi, M.Lo, &T.Hi, &T.Lo);
|
||||
L->Hi += T.Lo;
|
||||
if(L->Hi < T.Lo) // if L->Hi overflowed
|
||||
{
|
||||
Increment(H);
|
||||
}
|
||||
H->Lo += T.Hi;
|
||||
if(H->Lo < T.Hi) // if H->Lo overflowed
|
||||
{
|
||||
++H->Hi;
|
||||
}
|
||||
|
||||
mult64to128(N.Lo, M.Hi, &T.Hi, &T.Lo);
|
||||
L->Hi += T.Lo;
|
||||
if(L->Hi < T.Lo) // if L->Hi overflowed
|
||||
{
|
||||
Increment(H);
|
||||
}
|
||||
H->Lo += T.Hi;
|
||||
if(H->Lo < T.Hi) // if H->Lo overflowed
|
||||
{
|
||||
++H->Hi;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sqr64to128(uint64_t r, uint64_t * h, uint64_t *l)
|
||||
{
|
||||
uint64_t r1 = (r & 0xffffffff);
|
||||
uint64_t t = (r1 * r1);
|
||||
uint64_t w3 = (t & 0xffffffff);
|
||||
uint64_t k = (t >> 32);
|
||||
|
||||
r >>= 32;
|
||||
uint64_t m = (r * r1);
|
||||
t = m + k;
|
||||
uint64_t w2 = (t & 0xffffffff);
|
||||
uint64_t w1 = (t >> 32);
|
||||
|
||||
t = m + w2;
|
||||
k = (t >> 32);
|
||||
*h = (r * r) + w1 + k;
|
||||
*l = (t << 32) + w3;
|
||||
}
|
||||
|
||||
void sqr128(uint128 R, uint128 * Ans)
|
||||
{
|
||||
sqr64to128(R.Lo, &Ans->Hi, &Ans->Lo);
|
||||
Ans->Hi += (R.Hi * R.Lo) << 1;
|
||||
}
|
||||
|
||||
void sqr128to256(uint128 R, uint128 * H, uint128 * L)
|
||||
{
|
||||
sqr64to128(R.Hi, &H->Hi, &H->Lo);
|
||||
sqr64to128(R.Lo, &L->Hi, &L->Lo);
|
||||
|
||||
uint128 T;
|
||||
mult64to128(R.Hi, R.Lo, &T.Hi, &T.Lo);
|
||||
|
||||
H->Hi += (T.Hi >> 63);
|
||||
T.Hi = (T.Hi << 1) | (T.Lo >> 63); // Shift Left 1 bit
|
||||
T.Lo <<= 1;
|
||||
|
||||
L->Hi += T.Lo;
|
||||
if(L->Hi < T.Lo) // if L->Hi overflowed
|
||||
{
|
||||
Increment(H);
|
||||
}
|
||||
|
||||
H->Lo += T.Hi;
|
||||
if(H->Lo < T.Hi) // if H->Lo overflowed
|
||||
{
|
||||
++H->Hi;
|
||||
}
|
||||
}
|
||||
|
||||
void shiftleft128(uint128 N, size_t S, uint128 * A)
|
||||
{
|
||||
uint64_t M1, M2;
|
||||
S &= 127;
|
||||
|
||||
M1 = ((((S + 127) | S) & 64) >> 6) - 1llu;
|
||||
M2 = (S >> 6) - 1llu;
|
||||
S &= 63;
|
||||
A->Hi = (N.Lo << S) & (~M2);
|
||||
A->Lo = (N.Lo << S) & M2;
|
||||
A->Hi |= ((N.Hi << S) | ((N.Lo >> (64 - S)) & M1)) & M2;
|
||||
|
||||
/*
|
||||
S &= 127;
|
||||
|
||||
if(S != 0)
|
||||
{
|
||||
if(S > 64)
|
||||
{
|
||||
A.Hi = N.Lo << (S - 64);
|
||||
A.Lo = 0;
|
||||
}
|
||||
else if(S < 64)
|
||||
{
|
||||
A.Hi = (N.Hi << S) | (N.Lo >> (64 - S));
|
||||
A.Lo = N.Lo << S;
|
||||
}
|
||||
else
|
||||
{
|
||||
A.Hi = N.Lo;
|
||||
A.Lo = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
A.Hi = N.Hi;
|
||||
A.Lo = N.Lo;
|
||||
}
|
||||
//*/
|
||||
}
|
||||
|
||||
void shiftright128(uint128 N, size_t S, uint128 * A)
|
||||
{
|
||||
uint64_t M1, M2;
|
||||
S &= 127;
|
||||
|
||||
M1 = ((((S + 127) | S) & 64) >> 6) - 1llu;
|
||||
M2 = (S >> 6) - 1llu;
|
||||
S &= 63;
|
||||
A->Lo = (N.Hi >> S) & (~M2);
|
||||
A->Hi = (N.Hi >> S) & M2;
|
||||
A->Lo |= ((N.Lo >> S) | ((N.Hi << (64 - S)) & M1)) & M2;
|
||||
|
||||
/*
|
||||
S &= 127;
|
||||
|
||||
if(S != 0)
|
||||
{
|
||||
if(S > 64)
|
||||
{
|
||||
A.Hi = N.Hi >> (S - 64);
|
||||
A.Lo = 0;
|
||||
}
|
||||
else if(S < 64)
|
||||
{
|
||||
A.Lo = (N.Lo >> S) | (N.Hi << (64 - S));
|
||||
A.Hi = N.Hi >> S;
|
||||
}
|
||||
else
|
||||
{
|
||||
A.Lo = N.Hi;
|
||||
A.Hi = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
A.Hi = N.Hi;
|
||||
A.Lo = N.Lo;
|
||||
}
|
||||
//*/
|
||||
}
|
||||
|
||||
|
||||
void not128(uint128 N, uint128 * A)
|
||||
{
|
||||
A->Hi = ~N.Hi;
|
||||
A->Lo = ~N.Lo;
|
||||
}
|
||||
|
||||
void or128(uint128 N1, uint128 N2, uint128 * A)
|
||||
{
|
||||
A->Hi = N1.Hi | N2.Hi;
|
||||
A->Lo = N1.Lo | N2.Lo;
|
||||
}
|
||||
|
||||
void and128(uint128 N1, uint128 N2, uint128 * A)
|
||||
{
|
||||
A->Hi = N1.Hi & N2.Hi;
|
||||
A->Lo = N1.Lo & N2.Lo;
|
||||
}
|
||||
|
||||
void xor128(uint128 N1, uint128 N2, uint128 * A)
|
||||
{
|
||||
A->Hi = N1.Hi ^ N2.Hi;
|
||||
A->Lo = N1.Lo ^ N2.Lo;
|
||||
}
|
||||
|
||||
size_t nlz64(uint64_t N)
|
||||
{
|
||||
uint64_t I;
|
||||
size_t C;
|
||||
|
||||
I = ~N;
|
||||
C = ((I ^ (I + 1)) & I) >> 63;
|
||||
|
||||
I = (N >> 32) + 0xffffffff;
|
||||
I = ((I & 0x100000000) ^ 0x100000000) >> 27;
|
||||
C += I; N <<= I;
|
||||
|
||||
I = (N >> 48) + 0xffff;
|
||||
I = ((I & 0x10000) ^ 0x10000) >> 12;
|
||||
C += I; N <<= I;
|
||||
|
||||
I = (N >> 56) + 0xff;
|
||||
I = ((I & 0x100) ^ 0x100) >> 5;
|
||||
C += I; N <<= I;
|
||||
|
||||
I = (N >> 60) + 0xf;
|
||||
I = ((I & 0x10) ^ 0x10) >> 2;
|
||||
C += I; N <<= I;
|
||||
|
||||
I = (N >> 62) + 3;
|
||||
I = ((I & 4) ^ 4) >> 1;
|
||||
C += I; N <<= I;
|
||||
|
||||
C += (N >> 63) ^ 1;
|
||||
|
||||
return C;
|
||||
}
|
||||
|
||||
size_t ntz64(uint64_t N)
|
||||
{
|
||||
uint64_t I = ~N;
|
||||
size_t C = ((I ^ (I + 1)) & I) >> 63;
|
||||
|
||||
I = (N & 0xffffffff) + 0xffffffff;
|
||||
I = ((I & 0x100000000) ^ 0x100000000) >> 27;
|
||||
C += I; N >>= I;
|
||||
|
||||
I = (N & 0xffff) + 0xffff;
|
||||
I = ((I & 0x10000) ^ 0x10000) >> 12;
|
||||
C += I; N >>= I;
|
||||
|
||||
I = (N & 0xff) + 0xff;
|
||||
I = ((I & 0x100) ^ 0x100) >> 5;
|
||||
C += I; N >>= I;
|
||||
|
||||
I = (N & 0xf) + 0xf;
|
||||
I = ((I & 0x10) ^ 0x10) >> 2;
|
||||
C += I; N >>= I;
|
||||
|
||||
I = (N & 3) + 3;
|
||||
I = ((I & 4) ^ 4) >> 1;
|
||||
C += I; N >>= I;
|
||||
|
||||
C += ((N & 1) ^ 1);
|
||||
|
||||
return C;
|
||||
}
|
||||
|
||||
size_t popcnt64(uint64_t V)
|
||||
{
|
||||
// http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
|
||||
V -= ((V >> 1) & 0x5555555555555555);
|
||||
V = (V & 0x3333333333333333) + ((V >> 2) & 0x3333333333333333);
|
||||
return ((V + (V >> 4) & 0xF0F0F0F0F0F0F0F) * 0x101010101010101) >> 56;
|
||||
}
|
||||
|
||||
size_t popcnt128(uint128 N)
|
||||
{
|
||||
return popcnt64(N.Hi) + popcnt64(N.Lo);
|
||||
}
|
||||
|
||||
|
||||
size_t nlz128(uint128 N)
|
||||
{
|
||||
return (N.Hi == 0) ? nlz64(N.Lo) + 64 : nlz64(N.Hi);
|
||||
}
|
||||
|
||||
size_t ntz128(uint128 N)
|
||||
{
|
||||
return (N.Lo == 0) ? ntz64(N.Hi) + 64 : ntz64(N.Lo);
|
||||
}
|
||||
int compare128(uint128 N1, uint128 N2)
|
||||
{
|
||||
return (((N1.Hi > N2.Hi) || ((N1.Hi == N2.Hi) && (N1.Lo > N2.Lo))) ? 1 : 0)
|
||||
- (((N1.Hi < N2.Hi) || ((N1.Hi == N2.Hi) && (N1.Lo < N2.Lo))) ? 1 : 0);
|
||||
}
|
||||
|
||||
void bindivmod128(uint128 M, uint128 N, uint128 * Q, uint128 *R)
|
||||
{
|
||||
Q->Hi = Q->Lo = 0;
|
||||
size_t Shift = nlz128(N) - nlz128(M);
|
||||
shiftleft128(N, Shift, &N);
|
||||
|
||||
do
|
||||
{
|
||||
shiftleft128(*Q, (size_t)1, Q);
|
||||
if(compare128(M, N) >= 0)
|
||||
{
|
||||
sub128(M, N, &M);
|
||||
Q->Lo |= 1;
|
||||
}
|
||||
|
||||
shiftright128(N, 1, &N);
|
||||
}while(Shift-- != 0);
|
||||
|
||||
R->Hi = M.Hi;
|
||||
R->Lo = M.Lo;
|
||||
}
|
||||
|
||||
void divmod128by64(const uint64_t u1, const uint64_t u0, uint64_t v, uint64_t * q, uint64_t * r)
|
||||
{
|
||||
const uint64_t b = 1ll << 32;
|
||||
uint64_t un1, un0, vn1, vn0, q1, q0, un32, un21, un10, rhat, left, right;
|
||||
size_t s;
|
||||
|
||||
s = nlz64(v);
|
||||
v <<= s;
|
||||
vn1 = v >> 32;
|
||||
vn0 = v & 0xffffffff;
|
||||
|
||||
if (s > 0)
|
||||
{
|
||||
un32 = (u1 << s) | (u0 >> (64 - s));
|
||||
un10 = u0 << s;
|
||||
}
|
||||
else
|
||||
{
|
||||
un32 = u1;
|
||||
un10 = u0;
|
||||
}
|
||||
|
||||
un1 = un10 >> 32;
|
||||
un0 = un10 & 0xffffffff;
|
||||
|
||||
q1 = un32 / vn1;
|
||||
rhat = un32 % vn1;
|
||||
|
||||
left = q1 * vn0;
|
||||
right = (rhat << 32) + un1;
|
||||
again1:
|
||||
if ((q1 >= b) || (left > right))
|
||||
{
|
||||
--q1;
|
||||
rhat += vn1;
|
||||
if (rhat < b)
|
||||
{
|
||||
left -= vn0;
|
||||
right = (rhat << 32) | un1;
|
||||
goto again1;
|
||||
}
|
||||
}
|
||||
|
||||
un21 = (un32 << 32) + (un1 - (q1 * v));
|
||||
|
||||
q0 = un21 / vn1;
|
||||
rhat = un21 % vn1;
|
||||
|
||||
left = q0 * vn0;
|
||||
right = (rhat << 32) | un0;
|
||||
again2:
|
||||
if ((q0 >= b) || (left > right))
|
||||
{
|
||||
--q0;
|
||||
rhat += vn1;
|
||||
if (rhat < b)
|
||||
{
|
||||
left -= vn0;
|
||||
right = (rhat << 32) | un0;
|
||||
goto again2;
|
||||
}
|
||||
}
|
||||
|
||||
*r = ((un21 << 32) + (un0 - (q0 * v))) >> s;
|
||||
*q = (q1 << 32) | q0;
|
||||
}
|
||||
|
||||
static void divmod128by128(uint128 M, uint128 N, uint128 * Q, uint128 * R)
|
||||
{
|
||||
if (N.Hi == 0)
|
||||
{
|
||||
if (M.Hi < N.Lo)
|
||||
{
|
||||
divmod128by64(M.Hi, M.Lo, N.Lo, &Q->Lo, &R->Lo);
|
||||
Q->Hi = 0;
|
||||
R->Hi = 0;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Q->Hi = M.Hi / N.Lo;
|
||||
R->Hi = M.Hi % N.Lo;
|
||||
divmod128by64(R->Hi, M.Lo, N.Lo, &Q->Lo, &R->Lo);
|
||||
R->Hi = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t n = nlz64(N.Hi);
|
||||
|
||||
uint128 v1;
|
||||
shiftleft128(N, n, &v1);
|
||||
|
||||
uint128 u1;
|
||||
shiftright128(M, 1, &u1);
|
||||
|
||||
uint128 q1;
|
||||
divmod128by64(u1.Hi, u1.Lo, v1.Hi, &q1.Hi, &q1.Lo);
|
||||
q1.Hi = 0;
|
||||
shiftright128(q1, 63 - n, &q1);
|
||||
|
||||
if ((q1.Hi | q1.Lo) != 0)
|
||||
{
|
||||
dec128(q1, &q1);
|
||||
}
|
||||
|
||||
Q->Hi = q1.Hi;
|
||||
Q->Lo = q1.Lo;
|
||||
mult128(q1, N, &q1);
|
||||
sub128(M, q1, R);
|
||||
|
||||
if (compare128(*R, N) >= 0)
|
||||
{
|
||||
inc128(*Q, Q);
|
||||
sub128(*R, N, R);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void divmod128(uint128 M, uint128 N, uint128 * Q, uint128 * R)
|
||||
{
|
||||
size_t Nlz, Mlz, Ntz;
|
||||
int C;
|
||||
|
||||
Nlz = nlz128(N);
|
||||
Mlz = nlz128(M);
|
||||
Ntz = ntz128(N);
|
||||
|
||||
if(Nlz == 128)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if((M.Hi | N.Hi) == 0)
|
||||
{
|
||||
Q->Hi = R->Hi = 0;
|
||||
Q->Lo = M.Lo / N.Lo;
|
||||
R->Lo = M.Lo % N.Lo;
|
||||
return;
|
||||
}
|
||||
else if(Nlz == 127)
|
||||
{
|
||||
*Q = M;
|
||||
R->Hi = R->Lo = 0;
|
||||
return;
|
||||
}
|
||||
else if((Ntz + Nlz) == 127)
|
||||
{
|
||||
shiftright128(M, Ntz, Q);
|
||||
dec128(N, &N);
|
||||
and128(N, M, R);
|
||||
return;
|
||||
}
|
||||
|
||||
C = compare128(M, N);
|
||||
if(C < 0)
|
||||
{
|
||||
Q->Hi = Q->Lo = 0;
|
||||
*R = M;
|
||||
return;
|
||||
}
|
||||
else if(C == 0)
|
||||
{
|
||||
Q->Hi = R->Hi = R->Lo = 0;
|
||||
Q->Lo = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if((Nlz - Mlz) > 5)
|
||||
{
|
||||
divmod128by128(M, N, Q, R);
|
||||
}
|
||||
else
|
||||
{
|
||||
bindivmod128(M, N, Q, R);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
-180
@@ -1,180 +0,0 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <errno.h>
|
||||
#include <io.h>
|
||||
|
||||
#include "mman.h"
|
||||
|
||||
#ifndef FILE_MAP_EXECUTE
|
||||
#define FILE_MAP_EXECUTE 0x0020
|
||||
#endif /* FILE_MAP_EXECUTE */
|
||||
|
||||
static int __map_mman_error(const DWORD err, const int deferr)
|
||||
{
|
||||
if (err == 0)
|
||||
return 0;
|
||||
//TODO: implement
|
||||
return err;
|
||||
}
|
||||
|
||||
static DWORD __map_mmap_prot_page(const int prot)
|
||||
{
|
||||
DWORD protect = 0;
|
||||
|
||||
if (prot == PROT_NONE)
|
||||
return protect;
|
||||
|
||||
if ((prot & PROT_EXEC) != 0)
|
||||
{
|
||||
protect = ((prot & PROT_WRITE) != 0) ?
|
||||
PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ;
|
||||
}
|
||||
else
|
||||
{
|
||||
protect = ((prot & PROT_WRITE) != 0) ?
|
||||
PAGE_READWRITE : PAGE_READONLY;
|
||||
}
|
||||
|
||||
return protect;
|
||||
}
|
||||
|
||||
static DWORD __map_mmap_prot_file(const int prot)
|
||||
{
|
||||
DWORD desiredAccess = 0;
|
||||
|
||||
if (prot == PROT_NONE)
|
||||
return desiredAccess;
|
||||
|
||||
if ((prot & PROT_READ) != 0)
|
||||
desiredAccess |= FILE_MAP_READ;
|
||||
if ((prot & PROT_WRITE) != 0)
|
||||
desiredAccess |= FILE_MAP_WRITE;
|
||||
if ((prot & PROT_EXEC) != 0)
|
||||
desiredAccess |= FILE_MAP_EXECUTE;
|
||||
|
||||
return desiredAccess;
|
||||
}
|
||||
|
||||
void* mmap(void *addr, size_t len, int prot, int flags, int fildes, OffsetType off)
|
||||
{
|
||||
HANDLE fm, h;
|
||||
|
||||
void * map = MAP_FAILED;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4293)
|
||||
#endif
|
||||
|
||||
const DWORD dwFileOffsetLow = (sizeof(OffsetType) <= sizeof(DWORD)) ?
|
||||
(DWORD)off : (DWORD)(off & 0xFFFFFFFFL);
|
||||
const DWORD dwFileOffsetHigh = (sizeof(OffsetType) <= sizeof(DWORD)) ?
|
||||
(DWORD)0 : (DWORD)((off >> 32) & 0xFFFFFFFFL);
|
||||
const DWORD protect = __map_mmap_prot_page(prot);
|
||||
const DWORD desiredAccess = __map_mmap_prot_file(prot);
|
||||
|
||||
const OffsetType maxSize = off + (OffsetType)len;
|
||||
|
||||
const DWORD dwMaxSizeLow = (sizeof(OffsetType) <= sizeof(DWORD)) ?
|
||||
(DWORD)maxSize : (DWORD)(maxSize & 0xFFFFFFFFL);
|
||||
const DWORD dwMaxSizeHigh = (sizeof(OffsetType) <= sizeof(DWORD)) ?
|
||||
(DWORD)0 : (DWORD)((maxSize >> 32) & 0xFFFFFFFFL);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
errno = 0;
|
||||
|
||||
if (len == 0
|
||||
/* Unsupported flag combinations */
|
||||
|| (flags & MAP_FIXED) != 0
|
||||
/* Usupported protection combinations */
|
||||
|| prot == PROT_EXEC)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
h = ((flags & MAP_ANONYMOUS) == 0) ?
|
||||
(HANDLE)_get_osfhandle(fildes) : INVALID_HANDLE_VALUE;
|
||||
|
||||
if ((flags & MAP_ANONYMOUS) == 0 && h == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
errno = EBADF;
|
||||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
fm = CreateFileMapping(h, NULL, protect, dwMaxSizeHigh, dwMaxSizeLow, NULL);
|
||||
|
||||
if (fm == NULL)
|
||||
{
|
||||
errno = __map_mman_error(GetLastError(), EPERM);
|
||||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
map = MapViewOfFile(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len);
|
||||
|
||||
CloseHandle(fm);
|
||||
|
||||
if (map == NULL)
|
||||
{
|
||||
errno = __map_mman_error(GetLastError(), EPERM);
|
||||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
int munmap(void *addr, size_t len)
|
||||
{
|
||||
if (UnmapViewOfFile(addr))
|
||||
return 0;
|
||||
|
||||
errno = __map_mman_error(GetLastError(), EPERM);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _mprotect(void *addr, size_t len, int prot)
|
||||
{
|
||||
DWORD newProtect = __map_mmap_prot_page(prot);
|
||||
DWORD oldProtect = 0;
|
||||
|
||||
if (VirtualProtect(addr, len, newProtect, &oldProtect))
|
||||
return 0;
|
||||
|
||||
errno = __map_mman_error(GetLastError(), EPERM);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int msync(void *addr, size_t len, int flags)
|
||||
{
|
||||
if (FlushViewOfFile(addr, len))
|
||||
return 0;
|
||||
|
||||
errno = __map_mman_error(GetLastError(), EPERM);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mlock(const void *addr, size_t len)
|
||||
{
|
||||
if (VirtualLock((LPVOID)addr, len))
|
||||
return 0;
|
||||
|
||||
errno = __map_mman_error(GetLastError(), EPERM);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int munlock(const void *addr, size_t len)
|
||||
{
|
||||
if (VirtualUnlock((LPVOID)addr, len))
|
||||
return 0;
|
||||
|
||||
errno = __map_mman_error(GetLastError(), EPERM);
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* sys/mman.h
|
||||
* mman-win32
|
||||
*/
|
||||
|
||||
#ifndef _SYS_MMAN_H_
|
||||
#define _SYS_MMAN_H_
|
||||
|
||||
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
|
||||
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
|
||||
#endif
|
||||
|
||||
/* All the headers include this file. */
|
||||
#ifndef _MSC_VER
|
||||
#include <_mingw.h>
|
||||
#endif
|
||||
|
||||
/* Determine offset type */
|
||||
#include <stdint.h>
|
||||
#if defined(_WIN64)
|
||||
typedef int64_t OffsetType;
|
||||
#else
|
||||
typedef uint32_t OffsetType;
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PROT_NONE 0
|
||||
#define PROT_READ 1
|
||||
#define PROT_WRITE 2
|
||||
#define PROT_EXEC 4
|
||||
|
||||
#define MAP_FILE 0
|
||||
#define MAP_SHARED 1
|
||||
#define MAP_PRIVATE 2
|
||||
#define MAP_TYPE 0xf
|
||||
#define MAP_FIXED 0x10
|
||||
#define MAP_ANONYMOUS 0x20
|
||||
#define MAP_ANON MAP_ANONYMOUS
|
||||
|
||||
#define MAP_FAILED ((void *)-1)
|
||||
|
||||
/* Flags for msync. */
|
||||
#define MS_ASYNC 1
|
||||
#define MS_SYNC 2
|
||||
#define MS_INVALIDATE 4
|
||||
|
||||
void* mmap(void *addr, size_t len, int prot, int flags, int fildes, OffsetType off);
|
||||
int munmap(void *addr, size_t len);
|
||||
int _mprotect(void *addr, size_t len, int prot);
|
||||
int msync(void *addr, size_t len, int flags);
|
||||
int mlock(const void *addr, size_t len);
|
||||
int munlock(const void *addr, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_MMAN_H_ */
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* ---------------------------------------------------------------------------
|
||||
* OpenAES License
|
||||
* ---------------------------------------------------------------------------
|
||||
* Copyright (c) 2012, Nabil S. Al Ramli, www.nalramli.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _OAES_CONFIG_H
|
||||
#define _OAES_CONFIG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//#ifndef OAES_HAVE_ISAAC
|
||||
//#define OAES_HAVE_ISAAC 1
|
||||
//#endif // OAES_HAVE_ISAAC
|
||||
|
||||
//#ifndef OAES_DEBUG
|
||||
//#define OAES_DEBUG 0
|
||||
//#endif // OAES_DEBUG
|
||||
//#define OAES_DEBUG 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _OAES_CONFIG_H
|
||||
-1447
File diff suppressed because it is too large.
Load diff
@@ -1,214 +0,0 @@
|
||||
/*
|
||||
* ---------------------------------------------------------------------------
|
||||
* OpenAES License
|
||||
* ---------------------------------------------------------------------------
|
||||
* Copyright (c) 2012, Nabil S. Al Ramli, www.nalramli.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _OAES_LIB_H
|
||||
#define _OAES_LIB_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef OAES_SHARED
|
||||
# ifdef oaes_lib_EXPORTS
|
||||
# define OAES_API __declspec(dllexport)
|
||||
# else
|
||||
# define OAES_API __declspec(dllimport)
|
||||
# endif
|
||||
# else
|
||||
# define OAES_API
|
||||
# endif
|
||||
#else
|
||||
# define OAES_API
|
||||
#endif // WIN32
|
||||
|
||||
#define OAES_VERSION "0.8.1"
|
||||
#define OAES_BLOCK_SIZE 16
|
||||
|
||||
typedef void OAES_CTX;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
OAES_RET_FIRST = 0,
|
||||
OAES_RET_SUCCESS = 0,
|
||||
OAES_RET_UNKNOWN,
|
||||
OAES_RET_ARG1,
|
||||
OAES_RET_ARG2,
|
||||
OAES_RET_ARG3,
|
||||
OAES_RET_ARG4,
|
||||
OAES_RET_ARG5,
|
||||
OAES_RET_NOKEY,
|
||||
OAES_RET_MEM,
|
||||
OAES_RET_BUF,
|
||||
OAES_RET_HEADER,
|
||||
OAES_RET_COUNT
|
||||
} OAES_RET;
|
||||
|
||||
/*
|
||||
* oaes_set_option() takes one of these values for its [option] parameter
|
||||
* some options accept either an optional or a required [value] parameter
|
||||
*/
|
||||
// no option
|
||||
#define OAES_OPTION_NONE 0
|
||||
// enable ECB mode, disable CBC mode
|
||||
#define OAES_OPTION_ECB 1
|
||||
// enable CBC mode, disable ECB mode
|
||||
// value is optional, may pass uint8_t iv[OAES_BLOCK_SIZE] to specify
|
||||
// the value of the initialization vector, iv
|
||||
#define OAES_OPTION_CBC 2
|
||||
|
||||
#ifdef OAES_DEBUG
|
||||
typedef int ( * oaes_step_cb ) (
|
||||
const uint8_t state[OAES_BLOCK_SIZE],
|
||||
const char * step_name,
|
||||
int step_count,
|
||||
void * user_data );
|
||||
// enable state stepping mode
|
||||
// value is required, must pass oaes_step_cb to receive the state at each step
|
||||
#define OAES_OPTION_STEP_ON 4
|
||||
// disable state stepping mode
|
||||
#define OAES_OPTION_STEP_OFF 8
|
||||
#endif // OAES_DEBUG
|
||||
|
||||
typedef uint16_t OAES_OPTION;
|
||||
|
||||
typedef struct _oaes_key
|
||||
{
|
||||
size_t data_len;
|
||||
uint8_t *data;
|
||||
size_t exp_data_len;
|
||||
uint8_t *exp_data;
|
||||
size_t num_keys;
|
||||
size_t key_base;
|
||||
} oaes_key;
|
||||
|
||||
typedef struct _oaes_ctx
|
||||
{
|
||||
#ifdef OAES_HAVE_ISAAC
|
||||
randctx * rctx;
|
||||
#endif // OAES_HAVE_ISAAC
|
||||
|
||||
#ifdef OAES_DEBUG
|
||||
oaes_step_cb step_cb;
|
||||
#endif // OAES_DEBUG
|
||||
|
||||
oaes_key * key;
|
||||
OAES_OPTION options;
|
||||
uint8_t iv[OAES_BLOCK_SIZE];
|
||||
} oaes_ctx;
|
||||
/*
|
||||
* // usage:
|
||||
*
|
||||
* OAES_CTX * ctx = oaes_alloc();
|
||||
* .
|
||||
* .
|
||||
* .
|
||||
* {
|
||||
* oaes_gen_key_xxx( ctx );
|
||||
* {
|
||||
* oaes_key_export( ctx, _buf, &_buf_len );
|
||||
* // or
|
||||
* oaes_key_export_data( ctx, _buf, &_buf_len );\
|
||||
* }
|
||||
* }
|
||||
* // or
|
||||
* {
|
||||
* oaes_key_import( ctx, _buf, _buf_len );
|
||||
* // or
|
||||
* oaes_key_import_data( ctx, _buf, _buf_len );
|
||||
* }
|
||||
* .
|
||||
* .
|
||||
* .
|
||||
* oaes_encrypt( ctx, m, m_len, c, &c_len );
|
||||
* .
|
||||
* .
|
||||
* .
|
||||
* oaes_decrypt( ctx, c, c_len, m, &m_len );
|
||||
* .
|
||||
* .
|
||||
* .
|
||||
* oaes_free( &ctx );
|
||||
*/
|
||||
|
||||
OAES_API OAES_CTX * oaes_alloc(void);
|
||||
|
||||
OAES_API OAES_RET oaes_free( OAES_CTX ** ctx );
|
||||
|
||||
OAES_API OAES_RET oaes_set_option( OAES_CTX * ctx,
|
||||
OAES_OPTION option, const void * value );
|
||||
|
||||
OAES_API OAES_RET oaes_key_gen_128( OAES_CTX * ctx );
|
||||
|
||||
OAES_API OAES_RET oaes_key_gen_192( OAES_CTX * ctx );
|
||||
|
||||
OAES_API OAES_RET oaes_key_gen_256( OAES_CTX * ctx );
|
||||
|
||||
// export key with header information
|
||||
// set data == NULL to get the required data_len
|
||||
OAES_API OAES_RET oaes_key_export( OAES_CTX * ctx,
|
||||
uint8_t * data, size_t * data_len );
|
||||
|
||||
// directly export the data from key
|
||||
// set data == NULL to get the required data_len
|
||||
OAES_API OAES_RET oaes_key_export_data( OAES_CTX * ctx,
|
||||
uint8_t * data, size_t * data_len );
|
||||
|
||||
// import key with header information
|
||||
OAES_API OAES_RET oaes_key_import( OAES_CTX * ctx,
|
||||
const uint8_t * data, size_t data_len );
|
||||
|
||||
// directly import data into key
|
||||
OAES_API OAES_RET oaes_key_import_data( OAES_CTX * ctx,
|
||||
const uint8_t * data, size_t data_len );
|
||||
|
||||
// set c == NULL to get the required c_len
|
||||
OAES_API OAES_RET oaes_encrypt( OAES_CTX * ctx,
|
||||
const uint8_t * m, size_t m_len, uint8_t * c, size_t * c_len );
|
||||
|
||||
// set m == NULL to get the required m_len
|
||||
OAES_API OAES_RET oaes_decrypt( OAES_CTX * ctx,
|
||||
const uint8_t * c, size_t c_len, uint8_t * m, size_t * m_len );
|
||||
|
||||
// set buf == NULL to get the required buf_len
|
||||
OAES_API OAES_RET oaes_sprintf(
|
||||
char * buf, size_t * buf_len, const uint8_t * data, size_t data_len );
|
||||
|
||||
OAES_API OAES_RET oaes_encryption_round( const uint8_t * key, uint8_t * c );
|
||||
|
||||
OAES_API OAES_RET oaes_pseudo_encrypt_ecb( OAES_CTX * ctx, uint8_t * c );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _OAES_LIB_H
|
||||
@@ -1,376 +0,0 @@
|
||||
// Memory-hard extension of keccak for PoW
|
||||
// Copyright (c) 2012-2013 The Cryptonote developers
|
||||
// Copyright (c) 2014 The Boolberry developers
|
||||
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
// Modified for CPUminer by Lucas Jones
|
||||
// Adapted for ccminer by Tanguy Pruvot - 2016
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <emmintrin.h>
|
||||
#include <openssl/opensslv.h>
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
#include "compat/bignum_ssl10.hpp"
|
||||
#else
|
||||
#include "bignum.hpp"
|
||||
#endif
|
||||
#include "int128_c.h"
|
||||
#else
|
||||
#include <x86intrin.h>
|
||||
#endif
|
||||
|
||||
#include <miner.h>
|
||||
|
||||
#include "xmr-rpc.h"
|
||||
|
||||
extern uint64_t* pscratchpad_buff;
|
||||
|
||||
struct reciprocal_value64 {
|
||||
uint64_t m;
|
||||
uint8_t sh1, sh2;
|
||||
};
|
||||
|
||||
static inline int fls64(uint64_t x)
|
||||
{
|
||||
#if defined(_WIN64)
|
||||
unsigned long bitpos = 0;
|
||||
_BitScanReverse64(&bitpos, x);
|
||||
return (int) (bitpos + 1);
|
||||
#elif defined(WIN32)
|
||||
unsigned long hipos = 0, bitpos = 0;
|
||||
uint32_t hi = x >> 32;
|
||||
_BitScanReverse(&hipos, hi);
|
||||
if (!hipos) {
|
||||
_BitScanReverse(&bitpos, (uint32_t) x);
|
||||
}
|
||||
return (int) hipos ? hipos + 33 : bitpos + 1;
|
||||
#else
|
||||
/*
|
||||
* AMD64 says BSRQ won't clobber the dest reg if x==0; Intel64 says the
|
||||
* dest reg is undefined if x==0, but their CPU architect says its
|
||||
* value is written to set it to the same as before.
|
||||
*/
|
||||
register long bitpos = -1;
|
||||
asm("bsrq %1,%0" : "+r" (bitpos) : "rm" (x));
|
||||
return bitpos + 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline struct reciprocal_value64 reciprocal_val64(uint64_t d)
|
||||
{
|
||||
struct reciprocal_value64 R;
|
||||
int l;
|
||||
|
||||
l = fls64(d - 1);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
uint128 v1;
|
||||
v1.Lo = (1ULL << l) - d;v1.Hi=0;
|
||||
uint128 v2;
|
||||
v2.Hi = 1; v2.Lo = 0;
|
||||
|
||||
uint128 v;
|
||||
mult128(v1,v2,&v);
|
||||
divmod128by64(v.Hi,v.Lo,d,&v.Hi,&v.Lo);
|
||||
Increment(&v);
|
||||
R.m = (uint64_t)v.Hi;
|
||||
#else
|
||||
__uint128_t m;
|
||||
m = (((__uint128_t)1 << 64) * ((1ULL << l) - d));
|
||||
m /= d;
|
||||
++m;
|
||||
R.m = (uint64_t)m;
|
||||
#endif
|
||||
|
||||
R.sh1 = min(l, 1);
|
||||
R.sh2 = max(l - 1, 0);
|
||||
|
||||
return R;
|
||||
}
|
||||
|
||||
static inline uint64_t reciprocal_divide64(uint64_t a, struct reciprocal_value64 R)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
uint128 v;
|
||||
mult64to128(a,R.m,&v.Hi,&v.Lo);
|
||||
uint64_t t = v.Hi;
|
||||
#else
|
||||
uint64_t t = (uint64_t)(((__uint128_t)a * R.m) >> 64);
|
||||
#endif
|
||||
return (t + ((a - t) >> R.sh1)) >> R.sh2;
|
||||
}
|
||||
|
||||
static inline uint64_t reciprocal_remainder64(uint64_t A, uint64_t B, struct reciprocal_value64 R)
|
||||
{
|
||||
uint64_t div, mod;
|
||||
|
||||
div = reciprocal_divide64(A, R);
|
||||
mod = A - (uint64_t) (div * B);
|
||||
if (mod >= B) mod -= B;
|
||||
return mod;
|
||||
}
|
||||
|
||||
//#define UNROLL_SCR_MIX
|
||||
|
||||
static inline uint64_t rotl641(uint64_t x) { return((x << 1) | (x >> 63)); }
|
||||
static inline uint64_t rotl64_1(uint64_t x, uint64_t y) { return((x << y) | (x >> (64 - y))); }
|
||||
static inline uint64_t rotl64_2(uint64_t x, uint64_t y) { return(rotl64_1((x >> 32) | (x << 32), y)); }
|
||||
static inline uint64_t bitselect(uint64_t a, uint64_t b, uint64_t c) { return(a ^ (c & (b ^ a))); }
|
||||
|
||||
static inline void keccakf_mul(uint64_t *s)
|
||||
{
|
||||
uint64_t bc[5], t[5];
|
||||
uint64_t tmp1, tmp2;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < 5; i++)
|
||||
t[i] = s[i + 0] ^ s[i + 5] ^ s[i + 10] * s[i + 15] * s[i + 20];
|
||||
|
||||
bc[0] = t[0] ^ rotl641(t[2]);
|
||||
bc[1] = t[1] ^ rotl641(t[3]);
|
||||
bc[2] = t[2] ^ rotl641(t[4]);
|
||||
bc[3] = t[3] ^ rotl641(t[0]);
|
||||
bc[4] = t[4] ^ rotl641(t[1]);
|
||||
|
||||
tmp1 = s[1] ^ bc[0];
|
||||
|
||||
s[ 0] ^= bc[4];
|
||||
s[ 1] = rotl64_1(s[ 6] ^ bc[0], 44);
|
||||
s[ 6] = rotl64_1(s[ 9] ^ bc[3], 20);
|
||||
s[ 9] = rotl64_1(s[22] ^ bc[1], 61);
|
||||
s[22] = rotl64_1(s[14] ^ bc[3], 39);
|
||||
s[14] = rotl64_1(s[20] ^ bc[4], 18);
|
||||
s[20] = rotl64_1(s[ 2] ^ bc[1], 62);
|
||||
s[ 2] = rotl64_1(s[12] ^ bc[1], 43);
|
||||
s[12] = rotl64_1(s[13] ^ bc[2], 25);
|
||||
s[13] = rotl64_1(s[19] ^ bc[3], 8);
|
||||
s[19] = rotl64_1(s[23] ^ bc[2], 56);
|
||||
s[23] = rotl64_1(s[15] ^ bc[4], 41);
|
||||
s[15] = rotl64_1(s[ 4] ^ bc[3], 27);
|
||||
s[ 4] = rotl64_1(s[24] ^ bc[3], 14);
|
||||
s[24] = rotl64_1(s[21] ^ bc[0], 2);
|
||||
s[21] = rotl64_1(s[ 8] ^ bc[2], 55);
|
||||
s[ 8] = rotl64_1(s[16] ^ bc[0], 45);
|
||||
s[16] = rotl64_1(s[ 5] ^ bc[4], 36);
|
||||
s[ 5] = rotl64_1(s[ 3] ^ bc[2], 28);
|
||||
s[ 3] = rotl64_1(s[18] ^ bc[2], 21);
|
||||
s[18] = rotl64_1(s[17] ^ bc[1], 15);
|
||||
s[17] = rotl64_1(s[11] ^ bc[0], 10);
|
||||
s[11] = rotl64_1(s[ 7] ^ bc[1], 6);
|
||||
s[ 7] = rotl64_1(s[10] ^ bc[4], 3);
|
||||
s[10] = rotl64_1(tmp1, 1);
|
||||
|
||||
tmp1 = s[0]; tmp2 = s[1]; s[0] = bitselect(s[0] ^ s[2], s[0], s[1]); s[1] = bitselect(s[1] ^ s[3], s[1], s[2]); s[2] = bitselect(s[2] ^ s[4], s[2], s[3]); s[3] = bitselect(s[3] ^ tmp1, s[3], s[4]); s[4] = bitselect(s[4] ^ tmp2, s[4], tmp1);
|
||||
tmp1 = s[5]; tmp2 = s[6]; s[5] = bitselect(s[5] ^ s[7], s[5], s[6]); s[6] = bitselect(s[6] ^ s[8], s[6], s[7]); s[7] = bitselect(s[7] ^ s[9], s[7], s[8]); s[8] = bitselect(s[8] ^ tmp1, s[8], s[9]); s[9] = bitselect(s[9] ^ tmp2, s[9], tmp1);
|
||||
tmp1 = s[10]; tmp2 = s[11]; s[10] = bitselect(s[10] ^ s[12], s[10], s[11]); s[11] = bitselect(s[11] ^ s[13], s[11], s[12]); s[12] = bitselect(s[12] ^ s[14], s[12], s[13]); s[13] = bitselect(s[13] ^ tmp1, s[13], s[14]); s[14] = bitselect(s[14] ^ tmp2, s[14], tmp1);
|
||||
tmp1 = s[15]; tmp2 = s[16]; s[15] = bitselect(s[15] ^ s[17], s[15], s[16]); s[16] = bitselect(s[16] ^ s[18], s[16], s[17]); s[17] = bitselect(s[17] ^ s[19], s[17], s[18]); s[18] = bitselect(s[18] ^ tmp1, s[18], s[19]); s[19] = bitselect(s[19] ^ tmp2, s[19], tmp1);
|
||||
tmp1 = s[20]; tmp2 = s[21]; s[20] = bitselect(s[20] ^ s[22], s[20], s[21]); s[21] = bitselect(s[21] ^ s[23], s[21], s[22]); s[22] = bitselect(s[22] ^ s[24], s[22], s[23]); s[23] = bitselect(s[23] ^ tmp1, s[23], s[24]); s[24] = bitselect(s[24] ^ tmp2, s[24], tmp1);
|
||||
|
||||
s[0] ^= 0x0000000000000001ULL;
|
||||
}
|
||||
|
||||
static inline void keccakf_mul_last(uint64_t *s)
|
||||
{
|
||||
uint64_t bc[5], xormul[5];
|
||||
uint64_t tmp1, tmp2;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < 5; i++)
|
||||
xormul[i] = s[i + 0] ^ s[i + 5] ^ s[i + 10] * s[i + 15] * s[i + 20];
|
||||
|
||||
bc[0] = xormul[0] ^ rotl641(xormul[2]);
|
||||
bc[1] = xormul[1] ^ rotl641(xormul[3]);
|
||||
bc[2] = xormul[2] ^ rotl641(xormul[4]);
|
||||
bc[3] = xormul[3] ^ rotl641(xormul[0]);
|
||||
bc[4] = xormul[4] ^ rotl641(xormul[1]);
|
||||
|
||||
s[0] ^= bc[4];
|
||||
s[1] = rotl64_2(s[6] ^ bc[0], 12);
|
||||
s[2] = rotl64_2(s[12] ^ bc[1], 11);
|
||||
s[4] = rotl64_1(s[24] ^ bc[3], 14);
|
||||
s[3] = rotl64_1(s[18] ^ bc[2], 21);
|
||||
|
||||
tmp1 = s[0]; tmp2 = s[1]; s[0] = bitselect(s[0] ^ s[2], s[0], s[1]); s[1] = bitselect(s[1] ^ s[3], s[1], s[2]); s[2] = bitselect(s[2] ^ s[4], s[2], s[3]); s[3] = bitselect(s[3] ^ tmp1, s[3], s[4]);
|
||||
s[0] ^= 0x0000000000000001ULL;
|
||||
}
|
||||
|
||||
struct reciprocal_value64 cached_recip;
|
||||
static uint64_t cached_scr_size = 0;
|
||||
|
||||
static inline void scr_mix(uint64_t *st, uint64_t scr_size, struct reciprocal_value64 recip)
|
||||
{
|
||||
#define KK_MIXIN_SIZE 24
|
||||
uint64_t _ALIGN(128) idx[KK_MIXIN_SIZE];
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define pscr pscratchpad_buff
|
||||
int x;
|
||||
|
||||
// non-optimized 64bit operations
|
||||
for (x = 0; x < KK_MIXIN_SIZE; x++) {
|
||||
idx[x] = reciprocal_remainder64(st[x], scr_size, recip) << 2;
|
||||
}
|
||||
if (idx[7] > scr_size*4) {
|
||||
applog(LOG_WARNING, "Wrong remainder64 returned by the cpu hash %016llx > %016llx",
|
||||
(unsigned long long) idx[7], (unsigned long long) scr_size*4);
|
||||
return;
|
||||
}
|
||||
for(x = 0; x < KK_MIXIN_SIZE; x += 4) {
|
||||
st[x + 0] ^= pscr[idx[x] + 0] ^ pscr[idx[x + 1] + 0] ^ pscr[idx[x + 2] + 0] ^ pscr[idx[x + 3] + 0];
|
||||
st[x + 1] ^= pscr[idx[x] + 1] ^ pscr[idx[x + 1] + 1] ^ pscr[idx[x + 2] + 1] ^ pscr[idx[x + 3] + 1];
|
||||
st[x + 2] ^= pscr[idx[x] + 2] ^ pscr[idx[x + 1] + 2] ^ pscr[idx[x + 2] + 2] ^ pscr[idx[x + 3] + 2];
|
||||
st[x + 3] ^= pscr[idx[x] + 3] ^ pscr[idx[x + 1] + 3] ^ pscr[idx[x + 2] + 3] ^ pscr[idx[x + 3] + 3];
|
||||
}
|
||||
return;
|
||||
|
||||
#elif !defined(UNROLL_SCR_MIX)
|
||||
|
||||
#pragma GCC ivdep
|
||||
for(int x = 0; x < 3; ++x)
|
||||
{
|
||||
__m128i *st0, *st1, *st2, *st3;
|
||||
|
||||
idx[0] = reciprocal_remainder64(st[(x << 3) + 0], scr_size, recip) << 2;
|
||||
idx[1] = reciprocal_remainder64(st[(x << 3) + 1], scr_size, recip) << 2;
|
||||
idx[2] = reciprocal_remainder64(st[(x << 3) + 2], scr_size, recip) << 2;
|
||||
idx[3] = reciprocal_remainder64(st[(x << 3) + 3], scr_size, recip) << 2;
|
||||
idx[4] = reciprocal_remainder64(st[(x << 3) + 4], scr_size, recip) << 2;
|
||||
idx[5] = reciprocal_remainder64(st[(x << 3) + 5], scr_size, recip) << 2;
|
||||
idx[6] = reciprocal_remainder64(st[(x << 3) + 6], scr_size, recip) << 2;
|
||||
idx[7] = reciprocal_remainder64(st[(x << 3) + 7], scr_size, recip) << 2;
|
||||
|
||||
for(int y = 0; y < 8; y++) _mm_prefetch((const char*) (&pscratchpad_buff[idx[y]]), _MM_HINT_T1);
|
||||
|
||||
st0 = (__m128i *)&st[(x << 3) + 0];
|
||||
st1 = (__m128i *)&st[(x << 3) + 2];
|
||||
st2 = (__m128i *)&st[(x << 3) + 4];
|
||||
st3 = (__m128i *)&st[(x << 3) + 6];
|
||||
|
||||
*st0 = _mm_xor_si128(*st0, *((__m128i *)&pscratchpad_buff[idx[0]]));
|
||||
*st0 = _mm_xor_si128(*st0, *((__m128i *)&pscratchpad_buff[idx[1]]));
|
||||
*st0 = _mm_xor_si128(*st0, *((__m128i *)&pscratchpad_buff[idx[2]]));
|
||||
*st0 = _mm_xor_si128(*st0, *((__m128i *)&pscratchpad_buff[idx[3]]));
|
||||
|
||||
*st1 = _mm_xor_si128(*st1, *((__m128i *)&pscratchpad_buff[idx[0] + 2]));
|
||||
*st1 = _mm_xor_si128(*st1, *((__m128i *)&pscratchpad_buff[idx[1] + 2]));
|
||||
*st1 = _mm_xor_si128(*st1, *((__m128i *)&pscratchpad_buff[idx[2] + 2]));
|
||||
*st1 = _mm_xor_si128(*st1, *((__m128i *)&pscratchpad_buff[idx[3] + 2]));
|
||||
|
||||
*st2 = _mm_xor_si128(*st2, *((__m128i *)&pscratchpad_buff[idx[4]]));
|
||||
*st2 = _mm_xor_si128(*st2, *((__m128i *)&pscratchpad_buff[idx[5]]));
|
||||
*st2 = _mm_xor_si128(*st2, *((__m128i *)&pscratchpad_buff[idx[6]]));
|
||||
*st2 = _mm_xor_si128(*st2, *((__m128i *)&pscratchpad_buff[idx[7]]));
|
||||
|
||||
*st3 = _mm_xor_si128(*st3, *((__m128i *)&pscratchpad_buff[idx[4] + 2]));
|
||||
*st3 = _mm_xor_si128(*st3, *((__m128i *)&pscratchpad_buff[idx[5] + 2]));
|
||||
*st3 = _mm_xor_si128(*st3, *((__m128i *)&pscratchpad_buff[idx[6] + 2]));
|
||||
*st3 = _mm_xor_si128(*st3, *((__m128i *)&pscratchpad_buff[idx[7] + 2]));
|
||||
}
|
||||
|
||||
#else
|
||||
#warning using AVX2 optimizations
|
||||
|
||||
idx[ 0] = reciprocal_remainder64(st[0], scr_size, recip) << 2;
|
||||
idx[ 1] = reciprocal_remainder64(st[1], scr_size, recip) << 2;
|
||||
idx[ 2] = reciprocal_remainder64(st[2], scr_size, recip) << 2;
|
||||
idx[ 3] = reciprocal_remainder64(st[3], scr_size, recip) << 2;
|
||||
idx[ 4] = reciprocal_remainder64(st[4], scr_size, recip) << 2;
|
||||
idx[ 5] = reciprocal_remainder64(st[5], scr_size, recip) << 2;
|
||||
idx[ 6] = reciprocal_remainder64(st[6], scr_size, recip) << 2;
|
||||
idx[ 7] = reciprocal_remainder64(st[7], scr_size, recip) << 2;
|
||||
|
||||
for(int y = 0; y < 8; y++) _mm_prefetch(&pscratchpad_buff[idx[y]], _MM_HINT_T1);
|
||||
|
||||
idx[ 8] = reciprocal_remainder64(st[8], scr_size, recip) << 2;
|
||||
idx[ 9] = reciprocal_remainder64(st[9], scr_size, recip) << 2;
|
||||
idx[10] = reciprocal_remainder64(st[10], scr_size, recip) << 2;
|
||||
idx[11] = reciprocal_remainder64(st[11], scr_size, recip) << 2;
|
||||
idx[12] = reciprocal_remainder64(st[12], scr_size, recip) << 2;
|
||||
idx[13] = reciprocal_remainder64(st[13], scr_size, recip) << 2;
|
||||
idx[14] = reciprocal_remainder64(st[14], scr_size, recip) << 2;
|
||||
idx[15] = reciprocal_remainder64(st[15], scr_size, recip) << 2;
|
||||
|
||||
for(int y = 8; y < 16; ++y) _mm_prefetch(&pscratchpad_buff[idx[y]], _MM_HINT_T1);
|
||||
|
||||
idx[16] = reciprocal_remainder64(st[16], scr_size, recip) << 2;
|
||||
idx[17] = reciprocal_remainder64(st[17], scr_size, recip) << 2;
|
||||
idx[18] = reciprocal_remainder64(st[18], scr_size, recip) << 2;
|
||||
idx[19] = reciprocal_remainder64(st[19], scr_size, recip) << 2;
|
||||
idx[20] = reciprocal_remainder64(st[20], scr_size, recip) << 2;
|
||||
idx[21] = reciprocal_remainder64(st[21], scr_size, recip) << 2;
|
||||
idx[22] = reciprocal_remainder64(st[22], scr_size, recip) << 2;
|
||||
idx[23] = reciprocal_remainder64(st[23], scr_size, recip) << 2;
|
||||
|
||||
for(int y = 16; y < 24; ++y) _mm_prefetch(&pscratchpad_buff[idx[y]], _MM_HINT_T1);
|
||||
|
||||
__m256i *st0 = (__m256i *)&st[0];
|
||||
|
||||
for(int x = 0; x < 6; ++x)
|
||||
{
|
||||
*st0 = _mm256_xor_si256(*st0, *((__m256i *)&pscratchpad_buff[idx[(x << 2) + 0]]));
|
||||
*st0 = _mm256_xor_si256(*st0, *((__m256i *)&pscratchpad_buff[idx[(x << 2) + 1]]));
|
||||
*st0 = _mm256_xor_si256(*st0, *((__m256i *)&pscratchpad_buff[idx[(x << 2) + 2]]));
|
||||
*st0 = _mm256_xor_si256(*st0, *((__m256i *)&pscratchpad_buff[idx[(x << 2) + 3]]));
|
||||
++st0;
|
||||
}
|
||||
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
static void wild_keccak_hash_dbl(uint8_t * __restrict md, const uint8_t * __restrict in)
|
||||
{
|
||||
uint64_t _ALIGN(32) st[25];
|
||||
uint64_t scr_size, i;
|
||||
struct reciprocal_value64 recip;
|
||||
|
||||
scr_size = scratchpad_size >> 2;
|
||||
if (scr_size == cached_scr_size)
|
||||
recip = cached_recip;
|
||||
else {
|
||||
cached_recip = recip = reciprocal_val64(scr_size);
|
||||
cached_scr_size = scr_size;
|
||||
}
|
||||
|
||||
// Wild Keccak #1
|
||||
memcpy(st, in, 88);
|
||||
st[10] = (st[10] & 0x00000000000000FFULL) | 0x0000000000000100ULL;
|
||||
memset(&st[11], 0, 112);
|
||||
st[16] |= 0x8000000000000000ULL;
|
||||
|
||||
for(i = 0; i < 23; i++) {
|
||||
keccakf_mul(st);
|
||||
scr_mix(st, scr_size, recip);
|
||||
}
|
||||
|
||||
keccakf_mul_last(st);
|
||||
|
||||
// Wild Keccak #2
|
||||
memset(&st[4], 0x00, 168);
|
||||
st[ 4] = 0x0000000000000001ULL;
|
||||
st[16] = 0x8000000000000000ULL;
|
||||
|
||||
for(i = 0; i < 23; i++) {
|
||||
keccakf_mul(st);
|
||||
scr_mix(st, scr_size, recip);
|
||||
}
|
||||
|
||||
keccakf_mul_last(st);
|
||||
|
||||
memcpy(md, st, 32);
|
||||
return;
|
||||
}
|
||||
|
||||
void wildkeccak_hash(void* output, const void* input, uint64_t* scratchpad, uint64_t ssize)
|
||||
{
|
||||
if (scratchpad) pscratchpad_buff = scratchpad;
|
||||
if (!scratchpad_size) scratchpad_size = ssize;
|
||||
wild_keccak_hash_dbl((uint8_t*)output, (uint8_t*)input);
|
||||
}
|
||||
@@ -1,381 +0,0 @@
|
||||
// WildKeccak CUDA Kernel, Code based on Linux Wolf0 bbr-miner implementation from 2014
|
||||
// Adapted to ccminer 2.0 - tpruvot 2016-2017
|
||||
//
|
||||
// NOTE FOR SP: this ccminer version is licensed under GPLv3 Licence
|
||||
|
||||
extern "C" {
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
}
|
||||
|
||||
#include <miner.h>
|
||||
#include <cuda_helper.h>
|
||||
#include <cuda_vector_uint2x4.h> // todo
|
||||
|
||||
#include "wildkeccak.h"
|
||||
|
||||
extern char *device_config[MAX_GPUS]; // -l
|
||||
extern uint64_t* pscratchpad_buff;
|
||||
|
||||
static uint64_t* d_input[MAX_GPUS];
|
||||
static uint32_t* d_retnonce[MAX_GPUS];
|
||||
static ulonglong4* d_scratchpad[MAX_GPUS];
|
||||
|
||||
static uint64_t* h_scratchpad[MAX_GPUS] = { 0 };
|
||||
static cudaStream_t bufpad_stream[MAX_GPUS] = { 0 };
|
||||
static cudaStream_t kernel_stream[MAX_GPUS] = { 0 };
|
||||
|
||||
uint64_t scratchpad_size = 0;
|
||||
|
||||
uint32_t WK_CUDABlocks = 64;
|
||||
uint32_t WK_CUDAThreads = 256;
|
||||
|
||||
#define st0 vst0.x
|
||||
#define st1 vst0.y
|
||||
#define st2 vst0.z
|
||||
#define st3 vst0.w
|
||||
|
||||
#define st4 vst4.x
|
||||
#define st5 vst4.y
|
||||
#define st6 vst4.z
|
||||
#define st7 vst4.w
|
||||
|
||||
#define st8 vst8.x
|
||||
#define st9 vst8.y
|
||||
#define st10 vst8.z
|
||||
#define st11 vst8.w
|
||||
|
||||
#define st12 vst12.x
|
||||
#define st13 vst12.y
|
||||
#define st14 vst12.z
|
||||
#define st15 vst12.w
|
||||
|
||||
#define st16 vst16.x
|
||||
#define st17 vst16.y
|
||||
#define st18 vst16.z
|
||||
#define st19 vst16.w
|
||||
|
||||
#define st20 vst20.x
|
||||
#define st21 vst20.y
|
||||
#define st22 vst20.z
|
||||
#define st23 vst20.w
|
||||
|
||||
#if __CUDA_ARCH__ >= 320
|
||||
|
||||
__device__ __forceinline__ uint64_t cuda_rotl641(const uint64_t value)
|
||||
{
|
||||
uint2 result;
|
||||
asm("shf.l.wrap.b32 %0, %1, %2, 1U;" : "=r"(result.x)
|
||||
: "r"(__double2hiint(__longlong_as_double(value))), "r"(__double2loint(__longlong_as_double(value))));
|
||||
asm("shf.l.wrap.b32 %0, %1, %2, 1U;" : "=r"(result.y)
|
||||
: "r"(__double2loint(__longlong_as_double(value))), "r"(__double2hiint(__longlong_as_double(value))));
|
||||
return __double_as_longlong(__hiloint2double(result.y, result.x));
|
||||
}
|
||||
|
||||
#else
|
||||
__noinline__ __device__ uint64_t cuda_rotl641(const uint64_t x) { return((x << 1) | (x >> 63)); }
|
||||
#endif
|
||||
|
||||
__noinline__ __device__ uint64_t bitselect(const uint64_t a, const uint64_t b, const uint64_t c) { return(a ^ (c & (b ^ a))); }
|
||||
|
||||
#define ROTL641(x) (cuda_rotl641(x))
|
||||
|
||||
#define RND() \
|
||||
bc[0] = st0 ^ st5 ^ st10 * st15 * st20 ^ ROTL641(st2 ^ st7 ^ st12 * st17 * st22); \
|
||||
bc[1] = st1 ^ st6 ^ st11 * st16 * st21 ^ ROTL641(st3 ^ st8 ^ st13 * st18 * st23); \
|
||||
bc[2] = st2 ^ st7 ^ st12 * st17 * st22 ^ ROTL641(st4 ^ st9 ^ st14 * st19 * st24); \
|
||||
bc[3] = st3 ^ st8 ^ st13 * st18 * st23 ^ ROTL641(st0 ^ st5 ^ st10 * st15 * st20); \
|
||||
bc[4] = st4 ^ st9 ^ st14 * st19 * st24 ^ ROTL641(st1 ^ st6 ^ st11 * st16 * st21); \
|
||||
tmp1 = st1 ^ bc[0]; \
|
||||
\
|
||||
st0 ^= bc[4]; \
|
||||
st1 = ROTL64(st6 ^ bc[0], 44); \
|
||||
st6 = ROTL64(st9 ^ bc[3], 20); \
|
||||
st9 = ROTL64(st22 ^ bc[1], 61); \
|
||||
st22 = ROTL64(st14 ^ bc[3], 39); \
|
||||
st14 = ROTL64(st20 ^ bc[4], 18); \
|
||||
st20 = ROTL64(st2 ^ bc[1], 62); \
|
||||
st2 = ROTL64(st12 ^ bc[1], 43); \
|
||||
st12 = ROTL64(st13 ^ bc[2], 25); \
|
||||
st13 = ROTL64(st19 ^ bc[3], 8); \
|
||||
st19 = ROTL64(st23 ^ bc[2], 56); \
|
||||
st23 = ROTL64(st15 ^ bc[4], 41); \
|
||||
st15 = ROTL64(st4 ^ bc[3], 27); \
|
||||
st4 = ROTL64(st24 ^ bc[3], 14); \
|
||||
st24 = ROTL64(st21 ^ bc[0], 2); \
|
||||
st21 = ROTL64(st8 ^ bc[2], 55); \
|
||||
st8 = ROTL64(st16 ^ bc[0], 45); \
|
||||
st16 = ROTL64(st5 ^ bc[4], 36); \
|
||||
st5 = ROTL64(st3 ^ bc[2], 28); \
|
||||
st3 = ROTL64(st18 ^ bc[2], 21); \
|
||||
st18 = ROTL64(st17 ^ bc[1], 15); \
|
||||
st17 = ROTL64(st11 ^ bc[0], 10); \
|
||||
st11 = ROTL64(st7 ^ bc[1], 6); \
|
||||
st7 = ROTL64(st10 ^ bc[4], 3); \
|
||||
st10 = ROTL641(tmp1); \
|
||||
\
|
||||
tmp1 = st0; tmp2 = st1; st0 = bitselect(st0 ^ st2, st0, st1); st1 = bitselect(st1 ^ st3, st1, st2); \
|
||||
st2 = bitselect(st2 ^ st4, st2, st3); st3 = bitselect(st3 ^ tmp1, st3, st4); st4 = bitselect(st4 ^ tmp2, st4, tmp1); \
|
||||
tmp1 = st5; tmp2 = st6; st5 = bitselect(st5 ^ st7, st5, st6); st6 = bitselect(st6 ^ st8, st6, st7); \
|
||||
st7 = bitselect(st7 ^ st9, st7, st8); st8 = bitselect(st8 ^ tmp1, st8, st9); st9 = bitselect(st9 ^ tmp2, st9, tmp1); \
|
||||
tmp1 = st10; tmp2 = st11; st10 = bitselect(st10 ^ st12, st10, st11); st11 = bitselect(st11 ^ st13, st11, st12); \
|
||||
st12 = bitselect(st12 ^ st14, st12, st13); st13 = bitselect(st13 ^ tmp1, st13, st14); st14 = bitselect(st14 ^ tmp2, st14, tmp1); \
|
||||
tmp1 = st15; tmp2 = st16; st15 = bitselect(st15 ^ st17, st15, st16); st16 = bitselect(st16 ^ st18, st16, st17); \
|
||||
st17 = bitselect(st17 ^ st19, st17, st18); st18 = bitselect(st18 ^ tmp1, st18, st19); st19 = bitselect(st19 ^ tmp2, st19, tmp1); \
|
||||
tmp1 = st20; tmp2 = st21; st20 = bitselect(st20 ^ st22, st20, st21); st21 = bitselect(st21 ^ st23, st21, st22); \
|
||||
st22 = bitselect(st22 ^ st24, st22, st23); st23 = bitselect(st23 ^ tmp1, st23, st24); st24 = bitselect(st24 ^ tmp2, st24, tmp1); \
|
||||
st0 ^= 1;
|
||||
|
||||
#define LASTRND1() \
|
||||
bc[0] = st0 ^ st5 ^ st10 * st15 * st20 ^ ROTL64(st2 ^ st7 ^ st12 * st17 * st22, 1); \
|
||||
bc[1] = st1 ^ st6 ^ st11 * st16 * st21 ^ ROTL64(st3 ^ st8 ^ st13 * st18 * st23, 1); \
|
||||
bc[2] = st2 ^ st7 ^ st12 * st17 * st22 ^ ROTL64(st4 ^ st9 ^ st14 * st19 * st24, 1); \
|
||||
bc[3] = st3 ^ st8 ^ st13 * st18 * st23 ^ ROTL64(st0 ^ st5 ^ st10 * st15 * st20, 1); \
|
||||
bc[4] = st4 ^ st9 ^ st14 * st19 * st24 ^ ROTL64(st1 ^ st6 ^ st11 * st16 * st21, 1); \
|
||||
\
|
||||
st0 ^= bc[4]; \
|
||||
st1 = ROTL64(st6 ^ bc[0], 44); \
|
||||
st2 = ROTL64(st12 ^ bc[1], 43); \
|
||||
st4 = ROTL64(st24 ^ bc[3], 14); \
|
||||
st3 = ROTL64(st18 ^ bc[2], 21); \
|
||||
\
|
||||
tmp1 = st0; st0 = bitselect(st0 ^ st2, st0, st1); st1 = bitselect(st1 ^ st3, st1, st2); st2 = bitselect(st2 ^ st4, st2, st3); st3 = bitselect(st3 ^ tmp1, st3, st4); \
|
||||
st0 ^= 1;
|
||||
|
||||
#define LASTRND2() \
|
||||
bc[2] = st2 ^ st7 ^ st12 * st17 * st22 ^ ROTL64(st4 ^ st9 ^ st14 * st19 * st24, 1); \
|
||||
bc[3] = st3 ^ st8 ^ st13 * st18 * st23 ^ ROTL64(st0 ^ st5 ^ st10 * st15 * st20, 1); \
|
||||
bc[4] = st4 ^ st9 ^ st14 * st19 * st24 ^ ROTL64(st1 ^ st6 ^ st11 * st16 * st21, 1); \
|
||||
\
|
||||
st0 ^= bc[4]; \
|
||||
st4 = ROTL64(st24 ^ bc[3], 14); \
|
||||
st3 = ROTL64(st18 ^ bc[2], 21); \
|
||||
st3 = bitselect(st3 ^ st0, st3, st4);
|
||||
|
||||
__device__ ulonglong4 operator^(const ulonglong4 &a, const ulonglong4 &b)
|
||||
{
|
||||
return(make_ulonglong4(a.x ^ b.x, a.y ^ b.y, a.z ^ b.z, a.w ^ b.w));
|
||||
}
|
||||
|
||||
#define MIX(vst) vst = vst ^ scratchpad[vst.x % scr_size] ^ scratchpad[vst.y % scr_size] ^ scratchpad[vst.z % scr_size] ^ scratchpad[vst.w % scr_size];
|
||||
|
||||
#define MIX_ALL MIX(vst0); MIX(vst4); MIX(vst8); MIX(vst12); MIX(vst16); MIX(vst20);
|
||||
|
||||
__global__
|
||||
void wk(uint32_t* __restrict__ retnonce, const uint64_t* __restrict__ input, const ulonglong4* __restrict__ scratchpad,
|
||||
const uint32_t scr_size, const uint32_t target, uint64_t startNonce)
|
||||
{
|
||||
ulonglong4 vst0, vst4, vst8, vst12, vst16, vst20;
|
||||
uint64_t bc[5];
|
||||
uint64_t st24, tmp1, tmp2;
|
||||
|
||||
const uint64_t nonce = startNonce + (blockDim.x * blockIdx.x) + threadIdx.x;
|
||||
vst0 = make_ulonglong4((nonce << 8) + (input[0] & 0xFF), input[1] & 0xFFFFFFFFFFFFFF00ULL, input[2], input[3]);
|
||||
vst4 = make_ulonglong4(input[4], input[5], input[6], input[7]);
|
||||
vst8 = make_ulonglong4(input[8], input[9], (input[10] & 0xFF) | 0x100, 0);
|
||||
vst12 = make_ulonglong4(0, 0, 0, 0);
|
||||
vst16 = make_ulonglong4(0x8000000000000000ULL, 0, 0, 0);
|
||||
vst20 = make_ulonglong4(0, 0, 0, 0);
|
||||
st24 = 0;
|
||||
|
||||
RND();
|
||||
MIX_ALL;
|
||||
|
||||
for(int i = 0; i < 22; i++) {
|
||||
RND();
|
||||
MIX_ALL;
|
||||
}
|
||||
|
||||
LASTRND1();
|
||||
|
||||
vst4 = make_ulonglong4(1, 0, 0, 0);
|
||||
vst8 = make_ulonglong4(0, 0, 0, 0);
|
||||
vst12 = make_ulonglong4(0, 0, 0, 0);
|
||||
vst16 = make_ulonglong4(0x8000000000000000ULL, 0, 0, 0);
|
||||
vst20 = make_ulonglong4(0, 0, 0, 0);
|
||||
st24 = 0;
|
||||
|
||||
RND();
|
||||
MIX_ALL;
|
||||
|
||||
#pragma unroll
|
||||
for(int i = 0; i < 22; i++) {
|
||||
RND();
|
||||
MIX_ALL;
|
||||
}
|
||||
|
||||
LASTRND2();
|
||||
|
||||
if((st3 >> 32) <= target) {
|
||||
retnonce[0] = (uint32_t) nonce;
|
||||
retnonce[1] = retnonce[0];
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void wildkeccak_kernel(const int thr_id, const uint32_t threads, const uint32_t startNounce, const uint2 target, uint32_t *resNonces)
|
||||
{
|
||||
CUDA_SAFE_CALL(cudaMemsetAsync(d_retnonce[thr_id], 0xff, 2 * sizeof(uint32_t), kernel_stream[thr_id]));
|
||||
|
||||
const uint32_t threadsperblock = WK_CUDAThreads;
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
wk <<<grid, block, 0, kernel_stream[thr_id]>>> (d_retnonce[thr_id], d_input[thr_id], d_scratchpad[thr_id],
|
||||
(uint32_t)(scratchpad_size >> 2), target.y, startNounce);
|
||||
|
||||
cudaMemcpyAsync(resNonces, d_retnonce[thr_id], 2*sizeof(uint32_t), cudaMemcpyDeviceToHost, kernel_stream[thr_id]);
|
||||
}
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_wildkeccak(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done)
|
||||
{
|
||||
uint32_t *ptarget = work->target;
|
||||
uint32_t throughput = 0;
|
||||
uint64_t n, nonce, first;
|
||||
uint8_t *pdata = (uint8_t*) work->data;
|
||||
memcpy(&first, &pdata[1], 8);
|
||||
n = nonce = first;
|
||||
|
||||
if (!scratchpad_size || !h_scratchpad[thr_id]) {
|
||||
if (h_scratchpad[thr_id])
|
||||
applog(LOG_ERR, "Scratchpad size is not set!");
|
||||
work->data[0] = 0; // invalidate
|
||||
sleep(1);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
if (!init[thr_id]) {
|
||||
|
||||
if (device_config[thr_id]) {
|
||||
sscanf(device_config[thr_id], "%ux%u", &WK_CUDABlocks, &WK_CUDAThreads);
|
||||
gpulog(LOG_INFO, thr_id, "Using %u x %u kernel launch config, %u threads",
|
||||
WK_CUDABlocks, WK_CUDAThreads, throughput);
|
||||
} else {
|
||||
throughput = cuda_default_throughput(thr_id, WK_CUDABlocks*WK_CUDAThreads);
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
}
|
||||
|
||||
cudaSetDevice(device_map[thr_id]);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage (linux)
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
cudaDeviceSetCacheConfig(cudaFuncCachePreferL1);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_input[thr_id], 88));
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_retnonce[thr_id], 2*sizeof(uint32_t)));
|
||||
|
||||
int status = (int) cudaMalloc(&d_scratchpad[thr_id], WILD_KECCAK_SCRATCHPAD_BUFFSIZE);
|
||||
if (status != cudaSuccess) {
|
||||
gpulog(LOG_ERR, thr_id, "Unable to allocate device memory, %u MB, err %d",
|
||||
(uint32_t) (WILD_KECCAK_SCRATCHPAD_BUFFSIZE/(1024*1024)), status);
|
||||
exit(-ENOMEM);
|
||||
}
|
||||
|
||||
cudaStreamCreate(&bufpad_stream[thr_id]);
|
||||
cudaStreamCreate(&kernel_stream[thr_id]);
|
||||
|
||||
CUDA_SAFE_CALL(cudaMemcpyAsync(d_scratchpad[thr_id], h_scratchpad[thr_id], scratchpad_size << 3, cudaMemcpyHostToDevice, bufpad_stream[thr_id]));
|
||||
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
throughput = WK_CUDABlocks * WK_CUDAThreads;
|
||||
|
||||
cudaMemcpy(d_input[thr_id], pdata, 88, cudaMemcpyHostToDevice);
|
||||
// cudaMemset(d_retnonce[thr_id], 0xFF, 2*sizeof(uint32_t));
|
||||
|
||||
if (h_scratchpad[thr_id]) {
|
||||
cudaStreamSynchronize(bufpad_stream[thr_id]);
|
||||
}
|
||||
|
||||
do {
|
||||
// const uint32_t blocks = WK_CUDABlocks, threads = WK_CUDAThreads;
|
||||
// const dim3 block(blocks);
|
||||
// const dim3 thread(threads);
|
||||
uint32_t h_retnonce[2] = { UINT32_MAX, UINT32_MAX };
|
||||
uint2 target = make_uint2(ptarget[6], ptarget[7]);
|
||||
|
||||
wildkeccak_kernel(thr_id, throughput, (uint32_t) nonce, target, h_retnonce);
|
||||
/*
|
||||
wk <<<block, thread, 0, kernel_stream[thr_id]>>> (d_retnonce[thr_id], d_input[thr_id], d_scratchpad[thr_id],
|
||||
(uint32_t)(scratchpad_size >> 2), nonce, ptarget[7]);
|
||||
*/
|
||||
|
||||
*hashes_done = (unsigned long) (n - first + throughput);
|
||||
|
||||
cudaStreamSynchronize(kernel_stream[thr_id]);
|
||||
if(h_retnonce[0] != UINT32_MAX) {
|
||||
uint8_t _ALIGN(64) cpuhash[32];
|
||||
uint32_t* vhash = (uint32_t*) cpuhash;
|
||||
uint64_t nonce64;
|
||||
memcpy(&pdata[1], &h_retnonce[0], sizeof(uint32_t));
|
||||
memcpy(&nonce64, &pdata[1], 8);
|
||||
wildkeccak_hash(cpuhash, pdata, pscratchpad_buff, scratchpad_size);
|
||||
if (!cpuhash[31] && vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) {
|
||||
work_set_target_ratio(work, vhash);
|
||||
//applog_hex(pdata, 84);
|
||||
//applog_hex(cpuhash, 32);
|
||||
//applog_hex(ptarget, 32);
|
||||
memcpy(work->nonces, &nonce64, 8);
|
||||
if (n + throughput > max_nonce) {
|
||||
*hashes_done = (unsigned long) (max_nonce - first);
|
||||
}
|
||||
work->valid_nonces = 1;
|
||||
return 1;
|
||||
} else if (vhash[7] > ptarget[7]) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for nonce %08x does not validate on CPU!", h_retnonce[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (n + throughput >= max_nonce) {
|
||||
n = max_nonce;
|
||||
break;
|
||||
}
|
||||
|
||||
n += throughput;
|
||||
nonce += throughput;
|
||||
|
||||
} while(!work_restart[thr_id].restart);
|
||||
|
||||
*hashes_done = (unsigned long) (n - first + 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wildkeccak_scratchpad_need_update(uint64_t* pscratchpad_buff)
|
||||
{
|
||||
for(int i = 0; i < opt_n_threads; i++) {
|
||||
h_scratchpad[i] = pscratchpad_buff;
|
||||
if (init[i]) {
|
||||
gpulog(LOG_DEBUG, i, "Starting scratchpad update...");
|
||||
cudaMemcpyAsync(d_scratchpad[i], h_scratchpad[i], scratchpad_size << 3, cudaMemcpyHostToDevice, bufpad_stream[i]);
|
||||
work_restart[i].restart = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void free_wildkeccak(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaThreadSynchronize();
|
||||
|
||||
cudaFree(d_scratchpad[thr_id]);
|
||||
cudaFree(d_input[thr_id]);
|
||||
cudaFree(d_retnonce[thr_id]);
|
||||
|
||||
cudaStreamDestroy(bufpad_stream[thr_id]);
|
||||
cudaStreamDestroy(kernel_stream[thr_id]);
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
|
||||
init[thr_id] = false;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
#define WILD_KECCAK_SCRATCHPAD_BUFFSIZE 1ULL << 29
|
||||
#define WILD_KECCAK_ADDENDUMS_ARRAY_SIZE 10
|
||||
|
||||
extern uint64_t scratchpad_size;
|
||||
|
||||
extern uint32_t WK_CUDABlocks, WK_CUDAThreads;
|
||||
|
||||
void wildkeccak_scratchpad_need_update(uint64_t* pscratchpad_buff);
|
||||
|
||||
-1334
File diff suppressed because it is too large.
Load diff
@@ -1,41 +0,0 @@
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
#include "wildkeccak.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define _PACKED _ALIGN(4)
|
||||
#else
|
||||
#define _PACKED __attribute__((__packed__))
|
||||
#endif
|
||||
|
||||
struct _PACKED scratchpad_hi {
|
||||
unsigned char prevhash[32];
|
||||
uint64_t height;
|
||||
};
|
||||
|
||||
struct _PACKED addendums_array_entry {
|
||||
struct scratchpad_hi prev_hi;
|
||||
uint64_t add_size;
|
||||
};
|
||||
|
||||
|
||||
struct _PACKED scratchpad_file_header {
|
||||
struct scratchpad_hi current_hi;
|
||||
struct addendums_array_entry add_arr[WILD_KECCAK_ADDENDUMS_ARRAY_SIZE];
|
||||
uint64_t scratchpad_size;
|
||||
};
|
||||
|
||||
|
||||
bool rpc2_job_decode(const json_t *job, struct work *work);
|
||||
bool rpc2_stratum_job(struct stratum_ctx *sctx, json_t *id, json_t *params);
|
||||
bool rpc2_stratum_gen_work(struct stratum_ctx *sctx, struct work *work);
|
||||
bool rpc2_stratum_submit(struct pool_infos *pool, struct work *work);
|
||||
|
||||
int rpc2_stratum_thread_stuff(struct pool_infos* pool);
|
||||
|
||||
bool rpc2_login_decode(const json_t *val);
|
||||
|
||||
void rpc2_init();
|
||||
|
||||
void GetScratchpad();
|
||||
@@ -1,9 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <map>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
// include thrust
|
||||
#ifndef __cplusplus
|
||||
#include <thrust/version.h>
|
||||
@@ -15,44 +18,37 @@
|
||||
#endif
|
||||
|
||||
#include "miner.h"
|
||||
#include "nvml.h"
|
||||
|
||||
#include "cuda_runtime.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* miner.h functions are declared in C type, not C++ */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// CUDA Devices on the System
|
||||
int cuda_num_devices()
|
||||
{
|
||||
int version = 0, GPU_N = 0;
|
||||
int version;
|
||||
cudaError_t err = cudaDriverGetVersion(&version);
|
||||
if (err != cudaSuccess) {
|
||||
if (err != cudaSuccess)
|
||||
{
|
||||
applog(LOG_ERR, "Unable to query CUDA driver version! Is an nVidia driver installed?");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (version < CUDART_VERSION) {
|
||||
applog(LOG_ERR, "Your system does not support CUDA %d.%d API!",
|
||||
CUDART_VERSION / 1000, (CUDART_VERSION % 1000) / 10);
|
||||
int maj = version / 1000, min = version % 100; // same as in deviceQuery sample
|
||||
if (maj < 5 || (maj == 5 && min < 5))
|
||||
{
|
||||
applog(LOG_ERR, "Driver does not support CUDA %d.%d API! Update your nVidia driver!", 5, 5);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int GPU_N;
|
||||
err = cudaGetDeviceCount(&GPU_N);
|
||||
if (err != cudaSuccess) {
|
||||
if (err != cudaSuccess)
|
||||
{
|
||||
applog(LOG_ERR, "Unable to query number of CUDA devices! Is an nVidia driver installed?");
|
||||
exit(1);
|
||||
}
|
||||
return GPU_N;
|
||||
}
|
||||
|
||||
int cuda_version()
|
||||
{
|
||||
return (int) CUDART_VERSION;
|
||||
}
|
||||
|
||||
void cuda_devicenames()
|
||||
{
|
||||
cudaError_t err;
|
||||
@@ -64,66 +60,31 @@ void cuda_devicenames()
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (opt_n_threads)
|
||||
GPU_N = min(MAX_GPUS, opt_n_threads);
|
||||
for (int i=0; i < GPU_N; i++)
|
||||
{
|
||||
char vendorname[32] = { 0 };
|
||||
int dev_id = device_map[i];
|
||||
cudaDeviceProp props;
|
||||
cudaGetDeviceProperties(&props, dev_id);
|
||||
cudaGetDeviceProperties(&props, device_map[i]);
|
||||
|
||||
device_sm[dev_id] = (props.major * 100 + props.minor * 10);
|
||||
device_mpcount[dev_id] = (short) props.multiProcessorCount;
|
||||
|
||||
if (device_name[dev_id]) {
|
||||
free(device_name[dev_id]);
|
||||
device_name[dev_id] = NULL;
|
||||
}
|
||||
#ifdef USE_WRAPNVML
|
||||
if (gpu_vendor((uint8_t)props.pciBusID, vendorname) > 0 && strlen(vendorname)) {
|
||||
device_name[dev_id] = (char*) calloc(1, strlen(vendorname) + strlen(props.name) + 2);
|
||||
if (!strncmp(props.name, "GeForce ", 8))
|
||||
sprintf(device_name[dev_id], "%s %s", vendorname, &props.name[8]);
|
||||
else
|
||||
sprintf(device_name[dev_id], "%s %s", vendorname, props.name);
|
||||
} else
|
||||
#endif
|
||||
device_name[dev_id] = strdup(props.name);
|
||||
device_name[i] = strdup(props.name);
|
||||
device_sm[i] = (props.major * 100 + props.minor * 10);
|
||||
}
|
||||
}
|
||||
|
||||
void cuda_print_devices()
|
||||
{
|
||||
int ngpus = cuda_num_devices();
|
||||
cuda_devicenames();
|
||||
for (int n=0; n < ngpus; n++) {
|
||||
int dev_id = device_map[n % MAX_GPUS];
|
||||
int m = device_map[n];
|
||||
cudaDeviceProp props;
|
||||
cudaGetDeviceProperties(&props, dev_id);
|
||||
if (!opt_n_threads || n < opt_n_threads) {
|
||||
fprintf(stderr, "GPU #%d: SM %d.%d %s @ %.0f MHz (MEM %.0f)\n", dev_id,
|
||||
props.major, props.minor, device_name[dev_id],
|
||||
(double) props.clockRate/1000,
|
||||
(double) props.memoryClockRate/1000);
|
||||
#ifdef USE_WRAPNVML
|
||||
if (opt_debug) nvml_print_device_info(dev_id);
|
||||
#ifdef WIN32
|
||||
if (opt_debug) {
|
||||
unsigned int devNum = nvapi_devnum(dev_id);
|
||||
nvapi_pstateinfo(devNum);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
cudaGetDeviceProperties(&props, m);
|
||||
if (!opt_n_threads || n < opt_n_threads)
|
||||
fprintf(stderr, "GPU #%d: SM %d.%d %s\n", m, props.major, props.minor, props.name);
|
||||
}
|
||||
}
|
||||
|
||||
void cuda_shutdown()
|
||||
{
|
||||
// require gpu init first
|
||||
//if (thr_info != NULL)
|
||||
// cudaDeviceSynchronize();
|
||||
cudaDeviceSynchronize();
|
||||
cudaDeviceReset();
|
||||
}
|
||||
|
||||
@@ -162,120 +123,19 @@ int cuda_finddevice(char *name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// since 1.7
|
||||
uint32_t cuda_default_throughput(int thr_id, uint32_t defcount)
|
||||
uint32_t device_intensity(int thr_id, const char *func, uint32_t defcount)
|
||||
{
|
||||
//int dev_id = device_map[thr_id % MAX_GPUS];
|
||||
uint32_t throughput = gpus_intensity[thr_id] ? gpus_intensity[thr_id] : defcount;
|
||||
if (gpu_threads > 1 && throughput == defcount) throughput /= (gpu_threads-1);
|
||||
if (api_thr_id != -1) api_set_throughput(thr_id, throughput);
|
||||
//gpulog(LOG_INFO, thr_id, "throughput %u", throughput);
|
||||
api_set_throughput(thr_id, throughput);
|
||||
return throughput;
|
||||
}
|
||||
|
||||
// since 1.8.3
|
||||
double throughput2intensity(uint32_t throughput)
|
||||
{
|
||||
double intensity = 0.;
|
||||
uint32_t ws = throughput;
|
||||
uint8_t i = 0;
|
||||
while (ws > 1 && i++ < 32)
|
||||
ws = ws >> 1;
|
||||
intensity = (double) i;
|
||||
if (i && ((1U << i) < throughput)) {
|
||||
intensity += ((double) (throughput-(1U << i)) / (1U << i));
|
||||
}
|
||||
return intensity;
|
||||
}
|
||||
|
||||
// if we use 2 threads on the same gpu, we need to reinit the threads
|
||||
void cuda_reset_device(int thr_id, bool *init)
|
||||
{
|
||||
int dev_id = device_map[thr_id % MAX_GPUS];
|
||||
cudaSetDevice(dev_id);
|
||||
if (init != NULL) {
|
||||
// with init array, its meant to be used in algo's scan code...
|
||||
for (int i=0; i < MAX_GPUS; i++) {
|
||||
if (device_map[i] == dev_id) {
|
||||
init[i] = false;
|
||||
}
|
||||
}
|
||||
// force exit from algo's scan loops/function
|
||||
restart_threads();
|
||||
cudaDeviceSynchronize();
|
||||
while (cudaStreamQuery(NULL) == cudaErrorNotReady)
|
||||
usleep(1000);
|
||||
}
|
||||
cudaDeviceReset();
|
||||
if (opt_cudaschedule >= 0) {
|
||||
cudaSetDeviceFlags((unsigned)(opt_cudaschedule & cudaDeviceScheduleMask));
|
||||
} else {
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
}
|
||||
cudaDeviceSynchronize();
|
||||
}
|
||||
|
||||
// return free memory in megabytes
|
||||
int cuda_available_memory(int thr_id)
|
||||
{
|
||||
int dev_id = device_map[thr_id % MAX_GPUS];
|
||||
#if defined(_WIN32) && defined(USE_WRAPNVML)
|
||||
uint64_t tot64 = 0, free64 = 0;
|
||||
// cuda (6.5) one can crash on pascal and dont handle 8GB
|
||||
nvapiMemGetInfo(dev_id, &free64, &tot64);
|
||||
return (int) (free64 / (1024));
|
||||
#else
|
||||
size_t mtotal = 0, mfree = 0;
|
||||
cudaSetDevice(dev_id);
|
||||
cudaDeviceSynchronize();
|
||||
cudaMemGetInfo(&mfree, &mtotal);
|
||||
return (int) (mfree / (1024 * 1024));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Check (and reset) last cuda error, and report it in logs
|
||||
void cuda_log_lasterror(int thr_id, const char* func, int line)
|
||||
{
|
||||
cudaError_t err = cudaGetLastError();
|
||||
if (err != cudaSuccess && !opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "%s:%d %s", func, line, cudaGetErrorString(err));
|
||||
}
|
||||
|
||||
// Clear any cuda error in non-cuda unit (.c/.cpp)
|
||||
void cuda_clear_lasterror()
|
||||
{
|
||||
cudaGetLastError();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
int cuda_gpu_info(struct cgpu_info *gpu)
|
||||
{
|
||||
cudaDeviceProp props;
|
||||
if (cudaGetDeviceProperties(&props, gpu->gpu_id) == cudaSuccess) {
|
||||
gpu->gpu_clock = (uint32_t) props.clockRate;
|
||||
gpu->gpu_memclock = (uint32_t) props.memoryClockRate;
|
||||
gpu->gpu_mem = (uint64_t) (props.totalGlobalMem / 1024); // kB
|
||||
#if defined(_WIN32) && defined(USE_WRAPNVML)
|
||||
// required to get mem size > 4GB (size_t too small for bytes on 32bit)
|
||||
nvapiMemGetInfo(gpu->gpu_id, &gpu->gpu_memfree, &gpu->gpu_mem); // kB
|
||||
#endif
|
||||
gpu->gpu_mem = gpu->gpu_mem / 1024; // MB
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Zeitsynchronisations-Routine von cudaminer mit CPU sleep
|
||||
// Note: if you disable all of these calls, CPU usage will hit 100%
|
||||
typedef struct { double value[8]; } tsumarray;
|
||||
cudaError_t MyStreamSynchronize(cudaStream_t stream, int situation, int thr_id)
|
||||
{
|
||||
cudaError_t result = cudaSuccess;
|
||||
if (abort_flag)
|
||||
return result;
|
||||
if (situation >= 0)
|
||||
{
|
||||
static std::map<int, tsumarray> tsum;
|
||||
@@ -301,10 +161,36 @@ cudaError_t MyStreamSynchronize(cudaStream_t stream, int situation, int thr_id)
|
||||
return result;
|
||||
}
|
||||
|
||||
int cuda_gpu_clocks(struct cgpu_info *gpu)
|
||||
{
|
||||
cudaDeviceProp props;
|
||||
if (cudaGetDeviceProperties(&props, gpu->gpu_id) == cudaSuccess) {
|
||||
gpu->gpu_clock = props.clockRate;
|
||||
gpu->gpu_memclock = props.memoryClockRate;
|
||||
gpu->gpu_mem = props.totalGlobalMem;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// if we use 2 threads on the same gpu, we need to reinit the threads
|
||||
void cuda_reset_device(int thr_id, bool *init)
|
||||
{
|
||||
int dev_id = device_map[thr_id];
|
||||
for (int i=0; i < MAX_GPUS; i++) {
|
||||
if (device_map[i] == dev_id) {
|
||||
init[i] = false;
|
||||
}
|
||||
}
|
||||
restart_threads();
|
||||
cudaDeviceSynchronize();
|
||||
cudaDeviceReset();
|
||||
}
|
||||
|
||||
void cudaReportHardwareFailure(int thr_id, cudaError_t err, const char* func)
|
||||
{
|
||||
struct cgpu_info *gpu = &thr_info[thr_id].gpu;
|
||||
gpu->hw_errors++;
|
||||
gpulog(LOG_ERR, thr_id, "%s %s", func, cudaGetErrorString(err));
|
||||
applog(LOG_ERR, "GPU #%d: %s %s", device_map[thr_id], func, cudaGetErrorString(err));
|
||||
sleep(1);
|
||||
}
|
||||
+4
-79
@@ -11,27 +11,14 @@
|
||||
__constant__ uint32_t pTarget[8]; // 32 bytes
|
||||
|
||||
// store MAX_GPUS device arrays of 8 nonces
|
||||
static uint32_t* h_resNonces[MAX_GPUS] = { NULL };
|
||||
static uint32_t* d_resNonces[MAX_GPUS] = { NULL };
|
||||
static __thread bool init_done = false;
|
||||
static uint32_t* h_resNonces[MAX_GPUS];
|
||||
static uint32_t* d_resNonces[MAX_GPUS];
|
||||
|
||||
__host__
|
||||
void cuda_check_cpu_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
CUDA_CALL_OR_RET(cudaMallocHost(&h_resNonces[thr_id], 32));
|
||||
CUDA_CALL_OR_RET(cudaMalloc(&d_resNonces[thr_id], 32));
|
||||
CUDA_SAFE_CALL(cudaMallocHost(&h_resNonces[thr_id], 32));
|
||||
init_done = true;
|
||||
}
|
||||
|
||||
__host__
|
||||
void cuda_check_cpu_free(int thr_id)
|
||||
{
|
||||
if (!init_done) return;
|
||||
cudaFree(d_resNonces[thr_id]);
|
||||
cudaFreeHost(h_resNonces[thr_id]);
|
||||
d_resNonces[thr_id] = NULL;
|
||||
h_resNonces[thr_id] = NULL;
|
||||
init_done = false;
|
||||
}
|
||||
|
||||
// Target Difficulty
|
||||
@@ -100,21 +87,6 @@ void cuda_checkhash_64(uint32_t threads, uint32_t startNounce, uint32_t *hash, u
|
||||
}
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(512, 4)
|
||||
void cuda_checkhash_32(uint32_t threads, uint32_t startNounce, uint32_t *hash, uint32_t *resNonces)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
uint32_t *inpHash = &hash[thread << 3];
|
||||
|
||||
if (resNonces[0] == UINT32_MAX) {
|
||||
if (hashbelowtarget(inpHash, pTarget))
|
||||
resNonces[0] = (startNounce + thread);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
uint32_t cuda_check_hash(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_inputHash)
|
||||
{
|
||||
@@ -125,14 +97,6 @@ uint32_t cuda_check_hash(int thr_id, uint32_t threads, uint32_t startNounce, uin
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
if (bench_algo >= 0) // dont interrupt the global benchmark
|
||||
return UINT32_MAX;
|
||||
|
||||
if (!init_done) {
|
||||
applog(LOG_ERR, "missing call to cuda_check_cpu_init");
|
||||
return UINT32_MAX;
|
||||
}
|
||||
|
||||
cuda_checkhash_64 <<<grid, block>>> (threads, startNounce, d_inputHash, d_resNonces[thr_id]);
|
||||
cudaThreadSynchronize();
|
||||
|
||||
@@ -140,31 +104,6 @@ uint32_t cuda_check_hash(int thr_id, uint32_t threads, uint32_t startNounce, uin
|
||||
return h_resNonces[thr_id][0];
|
||||
}
|
||||
|
||||
__host__
|
||||
uint32_t cuda_check_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_inputHash)
|
||||
{
|
||||
cudaMemset(d_resNonces[thr_id], 0xff, sizeof(uint32_t));
|
||||
|
||||
const uint32_t threadsperblock = 512;
|
||||
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
if (bench_algo >= 0) // dont interrupt the global benchmark
|
||||
return UINT32_MAX;
|
||||
|
||||
if (!init_done) {
|
||||
applog(LOG_ERR, "missing call to cuda_check_cpu_init");
|
||||
return UINT32_MAX;
|
||||
}
|
||||
|
||||
cuda_checkhash_32 <<<grid, block>>> (threads, startNounce, d_inputHash, d_resNonces[thr_id]);
|
||||
cudaThreadSynchronize();
|
||||
|
||||
cudaMemcpy(h_resNonces[thr_id], d_resNonces[thr_id], sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
return h_resNonces[thr_id][0];
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
__global__ __launch_bounds__(512, 4)
|
||||
@@ -191,18 +130,13 @@ uint32_t cuda_check_hash_suppl(int thr_id, uint32_t threads, uint32_t startNounc
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
if (!init_done) {
|
||||
applog(LOG_ERR, "missing call to cuda_check_cpu_init");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// first element stores the count of found nonces
|
||||
cudaMemset(d_resNonces[thr_id], 0, sizeof(uint32_t));
|
||||
|
||||
cuda_checkhash_64_suppl <<<grid, block>>> (startNounce, d_inputHash, d_resNonces[thr_id]);
|
||||
cudaThreadSynchronize();
|
||||
|
||||
cudaMemcpy(h_resNonces[thr_id], d_resNonces[thr_id], 32, cudaMemcpyDeviceToHost);
|
||||
cudaMemcpy(h_resNonces[thr_id], d_resNonces[thr_id], 8*sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
rescnt = h_resNonces[thr_id][0];
|
||||
if (rescnt > numNonce) {
|
||||
if (numNonce <= rescnt) {
|
||||
@@ -246,15 +180,6 @@ uint32_t cuda_check_hash_branch(int thr_id, uint32_t threads, uint32_t startNoun
|
||||
const uint32_t threadsperblock = 256;
|
||||
|
||||
uint32_t result = UINT32_MAX;
|
||||
|
||||
if (bench_algo >= 0) // dont interrupt the global benchmark
|
||||
return result;
|
||||
|
||||
if (!init_done) {
|
||||
applog(LOG_ERR, "missing call to cuda_check_cpu_init");
|
||||
return result;
|
||||
}
|
||||
|
||||
cudaMemset(d_resNonces[thr_id], 0xff, sizeof(uint32_t));
|
||||
|
||||
dim3 grid((threads + threadsperblock-1)/threadsperblock);
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* Helper to trace gpu computed data with --cputest
|
||||
*
|
||||
* Sample usage in an algo scan cuda unit :
|
||||
*
|
||||
* #define _DEBUG
|
||||
* #define _DEBUG_PREFIX "x11-"
|
||||
* #include "cuda_debug.cuh"
|
||||
*
|
||||
* TRACE64("luffa", d_hash);
|
||||
* or
|
||||
* TRACE("luffa")
|
||||
*
|
||||
* Dont forget to link the scan function in util.cpp (do_gpu_tests)
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
//#include "cuda_helper.h"
|
||||
|
||||
#ifndef _DEBUG_PREFIX
|
||||
#define _DEBUG_PREFIX ""
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define TRACE64(algo, d_buf) { \
|
||||
if (max_nonce == 1 && pdata[19] <= 1 && !opt_benchmark) { \
|
||||
uint32_t oft = 0; \
|
||||
uint32_t* debugbuf = NULL; \
|
||||
cudaMallocHost(&debugbuf, 16*sizeof(uint32_t)); \
|
||||
cudaMemcpy(debugbuf, d_buf[thr_id] + oft, 16*sizeof(uint32_t), cudaMemcpyDeviceToHost); \
|
||||
printf(_DEBUG_PREFIX "%s %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x\n", \
|
||||
algo, \
|
||||
swab32(debugbuf[0]), swab32(debugbuf[1]), swab32(debugbuf[2]), swab32(debugbuf[3]), \
|
||||
swab32(debugbuf[4]), swab32(debugbuf[5]), swab32(debugbuf[6]), swab32(debugbuf[7]), \
|
||||
swab32(debugbuf[8]), swab32(debugbuf[9]), swab32(debugbuf[10]),swab32(debugbuf[11]), \
|
||||
swab32(debugbuf[12]),swab32(debugbuf[13]),swab32(debugbuf[14]),swab32(debugbuf[15])); \
|
||||
cudaFreeHost(debugbuf); \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define TRACE64(algo, d_buf) {}
|
||||
#endif
|
||||
|
||||
// simplified default
|
||||
#define TRACE(algo) TRACE64(algo, d_hash)
|
||||
|
||||
+3
-4
@@ -1,9 +1,8 @@
|
||||
#ifndef _CUDA_FUGUE256_H
|
||||
#define _CUDA_FUGUE256_H
|
||||
#ifndef _CUDA_FUGUE512_H
|
||||
#define _CUDA_FUGUE512_H
|
||||
|
||||
void fugue256_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, void *outputHashes, uint32_t *nounce);
|
||||
void fugue256_cpu_hash(int thr_id, uint32_t threads, int startNounce, void *outputHashes, uint32_t *nounce);
|
||||
void fugue256_cpu_setBlock(int thr_id, void *data, void *pTargetIn);
|
||||
void fugue256_cpu_init(int thr_id, uint32_t threads);
|
||||
void fugue256_cpu_free(int thr_id);
|
||||
|
||||
#endif
|
||||
+21
-23
@@ -5,11 +5,6 @@
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
#define __CUDA_ARCH__ 500
|
||||
#define __byte_perm(x,y,n) x
|
||||
#endif
|
||||
|
||||
#include "miner.h"
|
||||
|
||||
__constant__ uint32_t pTarget[8]; // Single GPU
|
||||
@@ -90,8 +85,9 @@ void groestlcoin_gpu_hash_quad(uint32_t threads, uint32_t startNounce, uint32_t
|
||||
}
|
||||
}
|
||||
|
||||
if(rc && resNounce[0] > nounce)
|
||||
resNounce[0] = nounce;
|
||||
if(rc == true)
|
||||
if(resNounce[0] > nounce)
|
||||
resNounce[0] = nounce;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -103,20 +99,15 @@ void groestlcoin_cpu_init(int thr_id, uint32_t threads)
|
||||
// to check if the binary supports SM3+
|
||||
cuda_get_arch(thr_id);
|
||||
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_resultNonce[thr_id], sizeof(uint32_t)));
|
||||
}
|
||||
|
||||
__host__
|
||||
void groestlcoin_cpu_free(int thr_id)
|
||||
{
|
||||
cudaFree(d_resultNonce[thr_id]);
|
||||
cudaMalloc(&d_resultNonce[thr_id], sizeof(uint32_t));
|
||||
}
|
||||
|
||||
__host__
|
||||
void groestlcoin_cpu_setBlock(int thr_id, void *data, void *pTargetIn)
|
||||
{
|
||||
uint32_t msgBlock[32] = { 0 };
|
||||
uint32_t msgBlock[32];
|
||||
|
||||
memset(msgBlock, 0, sizeof(uint32_t) * 32);
|
||||
memcpy(&msgBlock[0], data, 80);
|
||||
|
||||
// Erweitere die Nachricht auf den Nachrichtenblock (padding)
|
||||
@@ -128,14 +119,18 @@ void groestlcoin_cpu_setBlock(int thr_id, void *data, void *pTargetIn)
|
||||
// auf der GPU ausgeführt)
|
||||
|
||||
// Blockheader setzen (korrekte Nonce und Hefty Hash fehlen da drin noch)
|
||||
cudaMemcpyToSymbol(groestlcoin_gpu_msg, msgBlock, 128);
|
||||
cudaMemcpyToSymbol( groestlcoin_gpu_msg,
|
||||
msgBlock,
|
||||
128);
|
||||
|
||||
cudaMemset(d_resultNonce[thr_id], 0xFF, sizeof(uint32_t));
|
||||
cudaMemcpyToSymbol(pTarget, pTargetIn, 32);
|
||||
cudaMemcpyToSymbol( pTarget,
|
||||
pTargetIn,
|
||||
sizeof(uint32_t) * 8 );
|
||||
}
|
||||
|
||||
__host__
|
||||
void groestlcoin_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *resNonce)
|
||||
void groestlcoin_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, void *outputHashes, uint32_t *nounce)
|
||||
{
|
||||
uint32_t threadsperblock = 256;
|
||||
|
||||
@@ -143,21 +138,24 @@ void groestlcoin_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, ui
|
||||
// mit den Quad Funktionen brauchen wir jetzt 4 threads pro Hash, daher Faktor 4 bei der Blockzahl
|
||||
int factor = 4;
|
||||
|
||||
// berechne wie viele Thread Blocks wir brauchen
|
||||
// berechne wie viele Thread Blocks wir brauchen
|
||||
dim3 grid(factor*((threads + threadsperblock-1)/threadsperblock));
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
// Größe des dynamischen Shared Memory Bereichs
|
||||
size_t shared_size = 0;
|
||||
|
||||
int dev_id = device_map[thr_id];
|
||||
if (device_sm[dev_id] < 300 || cuda_arch[dev_id] < 300) {
|
||||
gpulog(LOG_ERR, thr_id, "Sorry, This algo is not supported by this GPU arch (SM 3.0 required)");
|
||||
printf("Sorry, This algo is not supported by this GPU arch (SM 3.0 required)");
|
||||
proper_exit(EXIT_CODE_CUDA_ERROR);
|
||||
}
|
||||
|
||||
cudaMemset(d_resultNonce[thr_id], 0xFF, sizeof(uint32_t));
|
||||
groestlcoin_gpu_hash_quad <<<grid, block>>> (threads, startNounce, d_resultNonce[thr_id]);
|
||||
groestlcoin_gpu_hash_quad<<<grid, block, shared_size>>>(threads, startNounce, d_resultNonce[thr_id]);
|
||||
|
||||
// Strategisches Sleep Kommando zur Senkung der CPU Last
|
||||
// MyStreamSynchronize(NULL, 0, thr_id);
|
||||
MyStreamSynchronize(NULL, 0, thr_id);
|
||||
|
||||
cudaMemcpy(resNonce, d_resultNonce[thr_id], sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
cudaMemcpy(nounce, d_resultNonce[thr_id], sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
}
|
||||
Loaded 100 of 299 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user