Skip to content

Commit

Permalink
Merge pull request #53 from Asherda/master
Browse files Browse the repository at this point in the history
MSVC compilation support
  • Loading branch information
Asherda committed Dec 14, 2019
2 parents e1c65c8 + 66183ce commit 956abcc
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
@@ -1,7 +1,7 @@
stages:
- build
variables:
VERSION: 0.7.2
VERSION: 0.8.0
POST_MESSAGE: "Pipeline Trigger: ${CI_PIPELINE_SOURCE}\n
Branch: ${CI_COMMIT_REF_NAME}\n
Commit: ${CI_COMMIT_SHA}\n
Expand Down
2 changes: 1 addition & 1 deletion doc/Linux/Readme.txt
@@ -1,4 +1,4 @@
VerusCoin nheqminer v0.7.2
VerusCoin nheqminer v0.8.0
Using VerusHash v2.0

This software needs to be run on a terminal.
Expand Down
2 changes: 1 addition & 1 deletion doc/Mac/Readme.txt
@@ -1,4 +1,4 @@
VerusCoin nheqminer v0.7.2
VerusCoin nheqminer v0.8.0
Using VerusHash v2.0

This software needs to be run on a terminal. To find it, open the Applications folder, then open the Utilities folder and finally open the Terminal application. The terminal can also be found using spotlight and searching for “terminal”.
Expand Down
2 changes: 1 addition & 1 deletion doc/Windows/Readme.txt
@@ -1,4 +1,4 @@
VerusCoin nheqminer v0.7.2
VerusCoin nheqminer v0.8.0
Using VerusHash v2.0

This software needs to be run on a terminal. From the start menu, type cmd and press enter to open a command prompt.
Expand Down
33 changes: 27 additions & 6 deletions nheqminer/crypto/verus_clhash.cpp
Expand Up @@ -32,8 +32,10 @@ int __cpuverusoptimized = 0x80;
#if defined(__arm__) || defined(__aarch64__)
#include "crypto/SSE2NEON.h"
#else
#ifndef _WIN32
#include <x86intrin.h>
#endif
#endif

#include "../../cpu_verushash/cpu_verushash.hpp"

Expand Down Expand Up @@ -150,15 +152,22 @@ __m128i _mm_loadl_epi64(__m128i *a)
#endif

// multiply the length and the some key, no modulo
static inline __attribute__((always_inline)) __m128i lazyLengthHash(uint64_t keylength, uint64_t length) {

#ifdef _MSC_VER
static __forceinline __m128i lazyLengthHash(uint64_t keylength, uint64_t length) {
#else
static inline __attribute__((always_inline)) __m128i lazyLengthHash(uint64_t keylength, uint64_t length) {
#endif
const __m128i lengthvector = _mm_set_epi64x(keylength,length);
const __m128i clprod1 = _mm_clmulepi64_si128( lengthvector, lengthvector, 0x10);
return clprod1;
}

// modulo reduction to 64-bit value. The high 64 bits contain garbage, see precompReduction64
static inline __attribute__((always_inline)) __m128i precompReduction64_si128( __m128i A) {
#ifdef _MSC_VER
static __forceinline __m128i precompReduction64_si128( __m128i A) {
#else
static inline __attribute__((always_inline)) __m128i precompReduction64_si128( __m128i A) {
#endif
//const __m128i C = _mm_set_epi64x(1U,(1U<<4)+(1U<<3)+(1U<<1)+(1U<<0)); // C is the irreducible poly. (64,4,3,1,0)
const __m128i C = _mm_cvtsi64_si128((1U<<4)+(1U<<3)+(1U<<1)+(1U<<0));
__m128i Q2 = _mm_clmulepi64_si128( A, C, 0x01);
Expand All @@ -169,11 +178,19 @@ static inline __attribute__((always_inline)) __m128i precompReduction64_si128( _
return final;/// WARNING: HIGH 64 BITS CONTAIN GARBAGE
}

static inline __attribute__((always_inline)) uint64_t precompReduction64( __m128i A) {
#ifdef _MSC_VER
static __forceinline uint64_t precompReduction64( __m128i A) {
#else
static inline __attribute__((always_inline)) uint64_t precompReduction64( __m128i A) {
#endif
return _mm_cvtsi128_si64(precompReduction64_si128(A));
}

static inline __attribute__((always_inline)) void fixupkey(__m128i **pMoveScratch, verusclhash_descr *pdesc) {
#ifdef _MSC_VER
static __forceinline void fixupkey(__m128i **pMoveScratch, verusclhash_descr *pdesc) {
#else
static inline __attribute__((always_inline)) void fixupkey(__m128i **pMoveScratch, verusclhash_descr *pdesc) {
#endif
uint32_t ofs = pdesc->keySizeInBytes >> 4;
for (__m128i *pfixup = *pMoveScratch; pfixup; pfixup = *++pMoveScratch)
{
Expand All @@ -182,7 +199,11 @@ static inline __attribute__((always_inline)) void fixupkey(__m128i **pMoveScratc
}
}

static inline __attribute__((always_inline)) void haraka512_keyed_local(unsigned char *out, const unsigned char *in, const u128 *rc) {
#ifdef _MSC_VER
static __forceinline void haraka512_keyed_local(unsigned char *out, const unsigned char *in, const u128 *rc) {
#else
static inline __attribute__((always_inline)) void haraka512_keyed_local(unsigned char *out, const unsigned char *in, const u128 *rc) {
#endif
u128 s[4], tmp;

s[0] = LOAD(in);
Expand Down
16 changes: 15 additions & 1 deletion nheqminer/crypto/verus_clhash.h
Expand Up @@ -30,7 +30,7 @@
#ifdef _WIN32
#undef __cpuid
#include <intrin.h>
#endif
#else

#if defined(__arm__) || defined(__aarch64__)
#include "crypto/SSE2NEON.h"
Expand All @@ -40,6 +40,7 @@
#include <cpuid.h>
#include <x86intrin.h>
#endif // !WIN32
#endif

#include <boost/thread.hpp>
#include "tinyformat.h"
Expand Down Expand Up @@ -118,6 +119,18 @@ inline bool IsCPUVerusOptimized()
#else
if (__cpuverusoptimized & 0x80)
{
#ifdef _MSC_VER
#define bit_AVX (1 << 28)
#define bit_AES (1 << 25)
#define bit_PCLMUL (1 << 1)
// https://insufficientlycomplicated.wordpress.com/2011/11/07/detecting-intel-advanced-vector-extensions-avx-in-visual-studio/
// bool cpuAVXSuport = cpuInfo[2] & (1 << 28) || false;

int cpuInfo[4];
__cpuid(cpuInfo, 1);
__cpuverusoptimized = ((cpuInfo[2] & (bit_AVX | bit_AES | bit_PCLMUL)) == (bit_AVX | bit_AES | bit_PCLMUL));

#else
unsigned int eax,ebx,ecx,edx;
if (!__get_cpuid(1,&eax,&ebx,&ecx,&edx))
{
Expand All @@ -127,6 +140,7 @@ inline bool IsCPUVerusOptimized()
{
__cpuverusoptimized = ((ecx & (bit_AVX | bit_AES | bit_PCLMUL)) == (bit_AVX | bit_AES | bit_PCLMUL));
}
#endif
}
#endif
return __cpuverusoptimized;
Expand Down
2 changes: 1 addition & 1 deletion nheqminer/version.h
Expand Up @@ -34,7 +34,7 @@ static const int BIP0031_VERSION = 60000;
//! "mempool" command, enhanced "getdata" behavior starts with this version
static const int MEMPOOL_GD_VERSION = 60002;

#define STANDALONE_MINER_VERSION "0.7.2"
#define STANDALONE_MINER_VERSION "0.8.0"

// uncomment to use with ZCash address
//#define ZCASH_POOL
Expand Down

0 comments on commit 956abcc

Please sign in to comment.