X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fkernel_worker.cpp;h=2980952072963412684e182090ca352a8a7a11e1;hb=5b098a8ec26ef68b65dd42a04246418a871e9cd9;hp=3ffb080c55653a101f0e785ac941cb7e0832ed43;hpb=cced1188176cb38cb5939a77b95712e2782cb0e1;p=novacoin.git diff --git a/src/kernel_worker.cpp b/src/kernel_worker.cpp index 3ffb080..2980952 100644 --- a/src/kernel_worker.cpp +++ b/src/kernel_worker.cpp @@ -10,6 +10,11 @@ using namespace std; #ifdef USE_ASM +#ifdef _MSC_VER +#include +#define __builtin_bswap32 _byteswap_ulong +#endif + #if defined(__i386__) || defined(__x86_64__) #include #endif @@ -139,9 +144,15 @@ void KernelWorker::Do_8way() bnTargetPerCoinDay.SetCompact(nBits); uint256 nMaxTarget = (bnTargetPerCoinDay * bnValueIn * nStakeMaxAge / COIN / nOneDay).getuint256(); +#ifdef _MSC_VER + __declspec(align(16)) uint32_t blocks1[8 * 16]; + __declspec(align(16)) uint32_t blocks2[8 * 16]; + __declspec(align(16)) uint32_t candidates[8 * 8]; +#else uint32_t blocks1[8 * 16] __attribute__((aligned(16))); uint32_t blocks2[8 * 16] __attribute__((aligned(16))); uint32_t candidates[8 * 8] __attribute__((aligned(16))); +#endif vector vRow = vector(8); uint32_t *pnKernel = (uint32_t *) kernel; @@ -210,9 +221,15 @@ void KernelWorker::Do_4way() bnTargetPerCoinDay.SetCompact(nBits); uint256 nMaxTarget = (bnTargetPerCoinDay * bnValueIn * nStakeMaxAge / COIN / nOneDay).getuint256(); +#ifdef _MSC_VER + __declspec(align(16)) uint32_t blocks1[4 * 16]; + __declspec(align(16)) uint32_t blocks2[4 * 16]; + __declspec(align(16)) uint32_t candidates[4 * 8]; +#else uint32_t blocks1[4 * 16] __attribute__((aligned(16))); uint32_t blocks2[4 * 16] __attribute__((aligned(16))); uint32_t candidates[4 * 8] __attribute__((aligned(16))); +#endif vector vRow = vector(4); uint32_t *pnKernel = (uint32_t *) kernel; @@ -315,9 +332,16 @@ void KernelWorker::Do_generic() solutions.push_back(std::pair(*pnHashProofOfStake, nTimeTx)); } #else + +#ifdef _MSC_VER + __declspec(align(16)) uint32_t block1[16]; + __declspec(align(16)) uint32_t block2[16]; + __declspec(align(16)) uint32_t candidate[8]; +#else uint32_t block1[16] __attribute__((aligned(16))); uint32_t block2[16] __attribute__((aligned(16))); uint32_t candidate[8] __attribute__((aligned(16))); +#endif memcpy(&block1[7], &block1_suffix[0], 36); // sha256 padding memcpy(&block2[8], &block2_suffix[0], 32); @@ -390,7 +414,7 @@ vector >& KernelWorker::GetSolutions() #ifdef USE_ASM #ifdef __x86_64__ -bool ScanKernelBackward_8way(unsigned char *kernel, uint32_t nBits, uint32_t nInputTxTime, int64_t nValueIn, std::pair &SearchInterval, std::pair &solution) +bool ScanKernelBackward_8Way(unsigned char *kernel, uint32_t nBits, uint32_t nInputTxTime, int64_t nValueIn, std::pair &SearchInterval, std::pair &solution) { CBigNum bnTargetPerCoinDay; bnTargetPerCoinDay.SetCompact(nBits); @@ -400,9 +424,15 @@ bool ScanKernelBackward_8way(unsigned char *kernel, uint32_t nBits, uint32_t nIn // Get maximum possible target to filter out the majority of obviously insufficient hashes uint256 nMaxTarget = (bnTargetPerCoinDay * bnValueIn * nStakeMaxAge / COIN / nOneDay).getuint256(); +#ifdef _MSC_VER + __declspec(align(16)) uint32_t blocks1[8 * 16]; + __declspec(align(16)) uint32_t blocks2[8 * 16]; + __declspec(align(16)) uint32_t candidates[8 * 8]; +#else uint32_t blocks1[8 * 16] __attribute__((aligned(16))); uint32_t blocks2[8 * 16] __attribute__((aligned(16))); uint32_t candidates[8 * 8] __attribute__((aligned(16))); +#endif vector vRow = vector(8); uint32_t *pnKernel = (uint32_t *) kernel; @@ -421,7 +451,7 @@ bool ScanKernelBackward_8way(unsigned char *kernel, uint32_t nBits, uint32_t nIn // Search forward in time from the given timestamp // Stopping search in case of shutting down - for (uint32_t nTimeTx=SearchInterval.first, nMaxTarget32 = nMaxTarget.Get32(7); nTimeTxSearchInterval.second && !fShutdown; nTimeTx -=8) { sha256_init_8way(blocks2); sha256_init_8way(candidates); @@ -479,9 +509,15 @@ bool ScanKernelBackward_4Way(unsigned char *kernel, uint32_t nBits, uint32_t nIn // Get maximum possible target to filter out the majority of obviously insufficient hashes uint256 nMaxTarget = (bnTargetPerCoinDay * bnValueIn * nStakeMaxAge / COIN / nOneDay).getuint256(); +#ifdef _MSC_VER + __declspec(align(16)) uint32_t blocks1[4 * 16]; + __declspec(align(16)) uint32_t blocks2[4 * 16]; + __declspec(align(16)) uint32_t candidates[4 * 8]; +#else uint32_t blocks1[4 * 16] __attribute__((aligned(16))); uint32_t blocks2[4 * 16] __attribute__((aligned(16))); uint32_t candidates[4 * 8] __attribute__((aligned(16))); +#endif vector vRow = vector(4); uint32_t *pnKernel = (uint32_t *) kernel; @@ -500,7 +536,7 @@ bool ScanKernelBackward_4Way(unsigned char *kernel, uint32_t nBits, uint32_t nIn // Search forward in time from the given timestamp // Stopping search in case of shutting down - for (uint32_t nTimeTx=SearchInterval.first, nMaxTarget32 = nMaxTarget.Get32(7); nTimeTxSearchInterval.second && !fShutdown; nTimeTx -=4) { sha256_init_4way(blocks2); sha256_init_4way(candidates);