Skip to content

Commit

Permalink
miner-burst-1.170820
Browse files Browse the repository at this point in the history
* Optimization of the algorithm
- Removed support for burstdev pool (poolV2)
- "ShowMsg" parameter was deleted
- "ShowUpdates" parameter was deleted
- "SendBestOnly" parameter was deleted
- "UseFastRcv" parameter was deleted
+ Added statistics file stat.csv (height; baseTarget; deadline)
* bugs fixed
  • Loading branch information
Blagodarenko committed Aug 20, 2017
1 parent 1525412 commit 140756a
Show file tree
Hide file tree
Showing 36 changed files with 7,999 additions and 1,226 deletions.
484 changes: 262 additions & 222 deletions miner.cpp

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions miner.h
Expand Up @@ -19,6 +19,7 @@ using namespace rapidjson;

#pragma comment(lib,"Ws2_32.lib")
#include <ws2tcpip.h>
#include <mswsock.h> // Need for SO_UPDATE_CONNECT_CONTEXT

#include "curses.h"
//#include "panel.h"
Expand Down Expand Up @@ -52,12 +53,12 @@ HANDLE hHeap;

bool exit_flag = false;
#ifdef __AVX2__
char const *const version = "v1.170603_AVX2";
char const *const version = "v1.170820_AVX2";
#else
#ifdef __AVX__
char const *const version = "v1.170603_AVX";
char const *const version = "v1.170820_AVX";
#else
char const *const version = "v1.170603";
char const *const version = "v1.170820";
#endif
#endif

Expand Down Expand Up @@ -91,22 +92,22 @@ volatile int stopThreads = 0;
size_t miner_mode = 0; // ðåæèì ìàéíåðà. 0=ñîëî, 1=ïóë
size_t cache_size = 100000; // ðàçìåð êýøà ÷òåíèÿ ïëîòîâ
std::vector<std::string> paths_dir; // ïóòè
bool show_msg = false; // Ïîêàçàòü îáùåíèå ñ ñåðâåðîì â îòïðàâùèêå
bool show_updates = false; // Ïîêàçàòü îáùåíèå ñ ñåðâåðîì â àïäåéòåðå
//bool show_msg = false; // Ïîêàçàòü îáùåíèå ñ ñåðâåðîì â îòïðàâùèêå
//bool show_updates = false; // Ïîêàçàòü îáùåíèå ñ ñåðâåðîì â àïäåéòåðå
FILE * fp_Log = nullptr; // óêàçàòåëü íà ëîã-ôàéë
size_t send_interval = 100; // âðåìÿ îæèäàíèÿ ìåæäó îòïðàâêàìè
size_t update_interval = 1000; // âðåìÿ îæèäàíèÿ ìåæäó àïäåéòàìè
short win_size_x = 80;
short win_size_y = 60;
bool use_fast_rcv = false;
//bool use_fast_rcv = false;
bool use_debug = false;
bool enable_proxy = false;
bool send_best_only = true;
//bool send_best_only = true;
bool use_wakeup = false;
bool use_log = true; // Âåñòè ëîã
bool use_boost = false; // Èñïîëüçîâàòü ïîâûøåííûé ïðèîðèòåò äëÿ ïîòîêîâ
bool show_winner = false; // ïîêàçûâàòü ïîáåäèòåëÿ
//short can_generate = 1; // 0 - disable; 1 - can start generate; 2 - already run generate
//short can_generate = 0; // 0 - disable; 1 - can start generate; 2 - already run generator


SYSTEMTIME cur_time; // Òåêóùåå âðåìÿ
Expand Down
2 changes: 1 addition & 1 deletion miner.vcxproj
Expand Up @@ -175,7 +175,7 @@
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
<BrowseInformation>true</BrowseInformation>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
<OmitFramePointers>true</OmitFramePointers>
Expand Down
2 changes: 2 additions & 0 deletions mshabal256_avx2.c
Expand Up @@ -44,6 +44,7 @@ extern "C" {
const unsigned char *buf6, const unsigned char *buf7,
size_t num)
{
_mm256_zeroupper();
union {
u32 words[64 * MSHABAL256_FACTOR];
__m256i data[16];
Expand Down Expand Up @@ -235,6 +236,7 @@ extern "C" {
_mm256_storeu_si256((__m256i *)sc->state + j + 28, C[j]);
}

_mm256_zeroupper();
#undef M
}

Expand Down
50 changes: 1 addition & 49 deletions mshabal_avx1.c
Expand Up @@ -222,7 +222,7 @@ extern "C" {
_mm_storeu_si128((__m128i *)sc->state + j + 12, B[j]);
_mm_storeu_si128((__m128i *)sc->state + j + 28, C[j]);
}

// _mm256_zeroupper();
#undef M
}

Expand Down Expand Up @@ -265,53 +265,6 @@ extern "C" {
sc->out_size = out_size;
}



static const mshabal_u32 A_init_256[] = {
C32(0x52F84552), C32(0xE54B7999), C32(0x2D8EE3EC), C32(0xB9645191),
C32(0xE0078B86), C32(0xBB7C44C9), C32(0xD2B5C1CA), C32(0xB0D2EB8C),
C32(0x14CE5A45), C32(0x22AF50DC), C32(0xEFFDBC6B), C32(0xEB21B74A)
};

static const mshabal_u32 B_init_256[] = {
C32(0xB555C6EE), C32(0x3E710596), C32(0xA72A652F), C32(0x9301515F),
C32(0xDA28C1FA), C32(0x696FD868), C32(0x9CB6BF72), C32(0x0AFE4002),
C32(0xA6E03615), C32(0x5138C1D4), C32(0xBE216306), C32(0xB38B8890),
C32(0x3EA8B96B), C32(0x3299ACE4), C32(0x30924DD4), C32(0x55CB34A5)
};

static const mshabal_u32 C_init_256[] = {
C32(0xB405F031), C32(0xC4233EBA), C32(0xB3733979), C32(0xC0DD9D55),
C32(0xC51C28AE), C32(0xA327B8E1), C32(0x56C56167), C32(0xED614433),
C32(0x88B59D60), C32(0x60E2CEBA), C32(0x758B4B8B), C32(0x83E82A7F),
C32(0xBC968828), C32(0xE6E00BF7), C32(0xBA839E55), C32(0x9B491C60)
};


void avx1_mshabal_init2(mshabal_context *cc, unsigned out_size)
{
//for (unsigned u = 0; u < 176; u++) cc->state[u] = 0;

memset(cc->buf0, 0, sizeof cc->buf0);
memset(cc->buf1, 0, sizeof cc->buf1);
memset(cc->buf2, 0, sizeof cc->buf2);
memset(cc->buf3, 0, sizeof cc->buf3);

for (unsigned u = 0; u < 176; u = u + 12 + 16 + 16)
{
memcpy(cc->state + u, A_init_256, sizeof(u32) * 12);
memcpy(cc->state + u + 12, B_init_256, sizeof(u32) * 16);
memcpy(cc->state + u + 12 + 16, C_init_256, sizeof(u32) * 16);
}

cc->Wlow = 1;
cc->Whigh = 0;
cc->ptr = 0;
//cc->Whigh = cc->Wlow = C32(0xFFFFFFFF);
cc->out_size = out_size;
}



/* see shabal_small.h */
void avx1_mshabal(mshabal_context *sc, const void *data0, const void *data1,
Expand Down Expand Up @@ -435,7 +388,6 @@ extern "C" {
out = (u32*)dst3;
for (z = 0; z < out_size_w32; z++) out[(size_t)z] = sc->state[off + (size_t)(z << 2) + 3];
}
_mm256_zeroupper();
}
//#pragma optimize("", on)

Expand Down
42 changes: 26 additions & 16 deletions rapidjson/allocators.h
Expand Up @@ -179,9 +179,10 @@ class MemoryPoolAllocator {

size = RAPIDJSON_ALIGN(size);
if (chunkHead_ == 0 || chunkHead_->size + size > chunkHead_->capacity)
AddChunk(chunk_capacity_ > size ? chunk_capacity_ : size);
if (!AddChunk(chunk_capacity_ > size ? chunk_capacity_ : size))
return NULL;

void *buffer = reinterpret_cast<char *>(chunkHead_ + 1) + chunkHead_->size;
void *buffer = reinterpret_cast<char *>(chunkHead_) + RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + chunkHead_->size;
chunkHead_->size += size;
return buffer;
}
Expand All @@ -194,26 +195,30 @@ class MemoryPoolAllocator {
if (newSize == 0)
return NULL;

originalSize = RAPIDJSON_ALIGN(originalSize);
newSize = RAPIDJSON_ALIGN(newSize);

// Do not shrink if new size is smaller than original
if (originalSize >= newSize)
return originalPtr;

// Simply expand it if it is the last allocation and there is sufficient space
if (originalPtr == (char *)(chunkHead_ + 1) + chunkHead_->size - originalSize) {
if (originalPtr == reinterpret_cast<char *>(chunkHead_) + RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + chunkHead_->size - originalSize) {
size_t increment = static_cast<size_t>(newSize - originalSize);
increment = RAPIDJSON_ALIGN(increment);
if (chunkHead_->size + increment <= chunkHead_->capacity) {
chunkHead_->size += increment;
return originalPtr;
}
}

// Realloc process: allocate and copy memory, do not free original buffer.
void* newBuffer = Malloc(newSize);
RAPIDJSON_ASSERT(newBuffer != 0); // Do not handle out-of-memory explicitly.
if (originalSize)
std::memcpy(newBuffer, originalPtr, originalSize);
return newBuffer;
if (void* newBuffer = Malloc(newSize)) {
if (originalSize)
std::memcpy(newBuffer, originalPtr, originalSize);
return newBuffer;
}
else
return NULL;
}

//! Frees a memory block (concept Allocator)
Expand All @@ -227,15 +232,20 @@ class MemoryPoolAllocator {

//! Creates a new chunk.
/*! \param capacity Capacity of the chunk in bytes.
\return true if success.
*/
void AddChunk(size_t capacity) {
bool AddChunk(size_t capacity) {
if (!baseAllocator_)
ownBaseAllocator_ = baseAllocator_ = RAPIDJSON_NEW(BaseAllocator());
ChunkHeader* chunk = reinterpret_cast<ChunkHeader*>(baseAllocator_->Malloc(sizeof(ChunkHeader) + capacity));
chunk->capacity = capacity;
chunk->size = 0;
chunk->next = chunkHead_;
chunkHead_ = chunk;
ownBaseAllocator_ = baseAllocator_ = RAPIDJSON_NEW(BaseAllocator)();
if (ChunkHeader* chunk = reinterpret_cast<ChunkHeader*>(baseAllocator_->Malloc(RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + capacity))) {
chunk->capacity = capacity;
chunk->size = 0;
chunk->next = chunkHead_;
chunkHead_ = chunk;
return true;
}
else
return false;
}

static const int kDefaultChunkCapacity = 64 * 1024; //!< Default chunk capacity.
Expand Down

0 comments on commit 140756a

Please sign in to comment.