Skip to content

Commit

Permalink
Fix issue with not getting new blocks.
Browse files Browse the repository at this point in the history
Fix GUI.
Update binaries to 1.6beta2.
  • Loading branch information
Belgarion committed Jul 5, 2019
1 parent 65c0681 commit bad56da
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 41 deletions.
4 changes: 2 additions & 2 deletions binaries/_README.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The MD5HASH for these executables are:

mochimo-winminer.exe 74ef3147f4b211b28bfc1f015e043e28
update-monitor.exe 116da5c35cce64d2b6b726cc34b9aa2e
mochimo-winminer.exe 7f63110c4688fce3dfe64f3872bbcaa5
update-monitor.exe 26a50d1b70a1e98a45ae69976cfbf1b9


This software is offered with no warranty, and is subject to the terms and conditions of the license, which can be found here:
Expand Down
Binary file modified binaries/mochimo-winminer.exe
Binary file not shown.
Binary file modified binaries/update-monitor.exe
Binary file not shown.
4 changes: 3 additions & 1 deletion winminer_v1/updatemonitor/updatemonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ int main(int argc, char **argv)
if (*ip == 0) {
/* No more IPs in core list, wait 100ms before next check*/
Sleep(100);
j = 0;
continue;
}
set_bnum(Cblocknum, ip);
Expand All @@ -71,7 +72,8 @@ int main(int argc, char **argv)
continue;
}
if(now >= update) {
intervalmultiplier *= 2;
//intervalmultiplier *= 2;
intervalmultiplier = 2;
printf("\nIntra-Block update.");
} else {
intervalmultiplier = 1;
Expand Down
98 changes: 87 additions & 11 deletions winminer_v1/winminer/algo/peach/cuda_peach.cu
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include "peach.h"
#include "nighthash.cu"
#include "../../helpers.h"
#include "cuda_peach.h"

byte *trigg_gen(byte *in);

Expand Down Expand Up @@ -262,16 +264,9 @@ __global__ void cuda_find_peach(uint32_t threads, uint8_t *g_map,

extern "C" {

typedef struct __peach_cuda_ctx {
byte init, curr_seed[16], next_seed[16];
byte *seed, *d_seed;
byte *input, *d_map;
int32_t *d_found;
cudaStream_t stream;
} PeachCudaCTX;

/* Max 63 GPUs Supported */
PeachCudaCTX ctx[64];
PeachCudaCTX peach_ctx[64];
PeachCudaCTX *ctx = peach_ctx;
dim3 grid(512);
dim3 block(256);
uint32_t threads = 131072;
Expand Down Expand Up @@ -496,7 +491,7 @@ __host__ void cuda_peach(byte *bt, uint32_t *hps, byte *runflag)
/* Check if GPU has finished */
cudaSetDevice(i);
if(cudaStreamQuery(ctx[i].stream) == cudaSuccess) {
printf("gpu completed, threads: %d\n", threads);
//printf("gpu completed, threads: %d\n", threads);
cudaMemcpy(found, ctx[i].d_found, 4, cudaMemcpyDeviceToHost);
if(*found==1) { /* SOLVED A BLOCK! */
cudaMemcpy(ctx[i].seed, ctx[i].d_seed, 16, cudaMemcpyDeviceToHost);
Expand All @@ -509,7 +504,7 @@ __host__ void cuda_peach(byte *bt, uint32_t *hps, byte *runflag)
cudaMemcpyHostToDevice, ctx[i].stream);
cudaStreamSynchronize(ctx[i].stream);
/* Start GPU round */
printf("starting new gpu round\n");
//printf("starting new gpu round\n");
cuda_find_peach<<<grid, block, 0, ctx[i].stream>>>(threads,
ctx[i].d_map, ctx[i].d_found, ctx[i].d_seed);
if (cudaCheckError("cuda_peach()", i, __FILE__)) {
Expand Down Expand Up @@ -544,4 +539,85 @@ __host__ void cuda_peach(byte *bt, uint32_t *hps, byte *runflag)
}



__host__ int32_t cuda_peach2(byte *bt, uint32_t *hps)
{
int i;
uint64_t lastnHaiku, nHaiku = 0;
time_t seconds = time(NULL);
for (i = 0; i < nGPU; i++) {
/* Prepare next seed for GPU... */
if (ctx[i].next_seed[0] == 0) {
/* ... generate first GPU seed (and expand as Haiku) */
trigg_gen(ctx[i].next_seed);

/* ... and prepare round data */
memcpy(ctx[i].input, bt, 92);
memcpy(ctx[i].input + 92, ctx[i].next_seed, 16);
}
/* Check if GPU has finished */
cudaSetDevice(i);
if (cudaStreamQuery(ctx[i].stream) == cudaSuccess) {
//printf("gpu completed, threads: %d\n", threads);
// Calculate per GPU HPS
ctx[i].t_end = timestamp_ms();
double tdiff = (ctx[i].t_end - ctx[i].t_start) / 1000.0;
ctx[i].hps_index = (ctx[i].hps_index + 1) % 3;
ctx[i].hps[ctx[i].hps_index] = threads / tdiff;
uint32_t shps = 0;
for (int j = 0; j < 3; j++) {
shps += ctx[i].hps[j];
}
ctx[i].ahps = shps / 3;
// End per GPU HPS

cudaMemcpy(found, ctx[i].d_found, 4, cudaMemcpyDeviceToHost);
if (*found == 1) { /* SOLVED A BLOCK! */
cudaMemcpy(ctx[i].seed, ctx[i].d_seed, 16, cudaMemcpyDeviceToHost);
memcpy(bt + 92, ctx[i].curr_seed, 16);
memcpy(bt + 92 + 16, ctx[i].seed, 16);
return 1;
}
/* Send new GPU round Data */
cudaMemcpyToSymbolAsync(c_input, ctx[i].input, 108, 0,
cudaMemcpyHostToDevice, ctx[i].stream);
cudaStreamSynchronize(ctx[i].stream);
/* Start GPU round */
//printf("starting new gpu round\n");
ctx[i].t_start = timestamp_ms();
cuda_find_peach << <grid, block, 0, ctx[i].stream >> > (threads,
ctx[i].d_map, ctx[i].d_found, ctx[i].d_seed);
if (cudaCheckError("cuda_peach()", i, __FILE__)) {
printf("CUDA ERROR\n");
}

/* Add to haiku count */
nHaiku += threads;

/* Store round vars aside for checks next loop */
memcpy(ctx[i].curr_seed, ctx[i].next_seed, 16);

ctx[i].next_seed[0] = 0;
}

/* Waiting on GPU? ... */
if (cudaCheckError("cuda_peach()", i, __FILE__)) {
return 0;
}
}

/* Chill a bit if nothing is happening */
if (lastnHaiku == nHaiku) msleep(1);
else lastnHaiku = nHaiku;


seconds = time(NULL) - seconds;
if (seconds == 0) seconds = 1;
nHaiku /= seconds;
*hps = (uint32_t)nHaiku;

return 0;
}


}
15 changes: 15 additions & 0 deletions winminer_v1/winminer/algo/peach/cuda_peach.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,19 @@ extern "C" {
int init_cuda_peach(byte difficulty, byte *prevhash, byte *blocknumber);
void free_cuda_peach();
void cuda_peach(byte *bt, uint32_t *hps, byte *runflag);
int32_t cuda_peach2(byte *bt, uint32_t *hps);

typedef struct __peach_cuda_ctx {
byte init, curr_seed[16], next_seed[16];
byte *seed, *d_seed;
byte *input, *d_map;
int32_t *d_found;
cudaStream_t stream;
int64_t t_start, t_end;
uint32_t hps[3];
uint8_t hps_index;
uint32_t ahps;
} PeachCudaCTX;

extern PeachCudaCTX peach_ctx[64];
}
2 changes: 1 addition & 1 deletion winminer_v1/winminer/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
snprintf(buf, 200, "Devices: CUDA: %d, OpenCL: %d", num_cuda, num_opencl);
put_text(hDc, 139, 148, buf);

snprintf(buf, 200, "Haikurate: % 10llu MH/s", haikurate);
snprintf(buf, 200, "Haikurate: % 10llu kH/s", haikurate);
put_text(hDc, 139, 164, buf);


Expand Down
23 changes: 23 additions & 0 deletions winminer_v1/winminer/helpers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <Windows.h>
#include "helpers.h"


int64_t timediff(SYSTEMTIME t1, SYSTEMTIME t2) {
FILETIME ft1, ft2;
SystemTimeToFileTime(&t1, &ft1);
SystemTimeToFileTime(&t2, &ft2);
ULARGE_INTEGER *u1, *u2;
u1 = (ULARGE_INTEGER*)&ft1;
u2 = (ULARGE_INTEGER*)&ft2;
return u2->QuadPart - u1->QuadPart;
}

int64_t timestamp_ms() {
SYSTEMTIME t1;
GetSystemTime(&t1);
FILETIME ft1;
SystemTimeToFileTime(&t1, &ft1);
ULARGE_INTEGER *u1 = (ULARGE_INTEGER*)&ft1;
// FILETIME is in 100ns intervals, divide by 10000 to get milliseconds.
return u1->QuadPart / 10000;
}
4 changes: 4 additions & 0 deletions winminer_v1/winminer/helpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once
#include <stdint.h>

int64_t timestamp_ms();
59 changes: 34 additions & 25 deletions winminer_v1/winminer/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,47 +87,58 @@ int miner(char *blockin, char *blockout, char *addrfile, Compute_Type ct)
printf("\nDetected %d compatible GPUs", initGPU);
for (htime = time(NULL), hcount = 0; ; ) {
if (!Running) break;
cuda_peach((byte*)&bt, (uint32_t*)&hps, &Running);
//cuda_peach((byte*)&bt, (uint32_t*)&hps, &Running);
int32_t solved = cuda_peach2((byte*)&bt, (uint32_t*)&hps);

// Block validation check
if (peach(&bt, get32(bt.difficulty), NULL, 1)) {
byte *bt_bytes = (byte*)&bt;
char hex[124 * 4];
for (int i = 0; i < 124; i++) {
sprintf(hex + i * 4, "%03i", bt_bytes[i]);
if (solved) {
// Block validation check
if (peach(&bt, get32(bt.difficulty), NULL, 1)) {
byte *bt_bytes = (byte*)&bt;
char hex[124 * 4];
for (int i = 0; i < 124; i++) {
sprintf(hex + i * 4, "%03i", bt_bytes[i]);
}

printf("!!!!CUDA Peach solved block is not valid!!!!!\n");
printf("CPU BT -> %s\n", hex);
Sleep(5000);
free_cuda_peach();
break;
}

printf("!!!!CUDA Peach solved block is not valid!!!!!\n");
printf("CPU BT -> %s\n", hex);
Sleep(5000);
free_cuda_peach();
break;
}
// Print Haiku
char phaiku[256];
trigg_expand2(bt.nonce, (byte*)phaiku);
printf("\n%s\n\n", phaiku);
//haiku = trigg_generate_gpu(bt.mroot, (uint32_t*)&hcount, ct);

// Print Haiku
char phaiku[256];
trigg_expand2(bt.nonce, (byte*)phaiku);
printf("\n%s\n\n", phaiku);
//haiku = trigg_generate_gpu(bt.mroot, (uint32_t*)&hcount, ct);

printf("\n\n\n\nBLOCK SOLVED!!!!!\n\n\n\n");
printf("\n\n\n\nBLOCK SOLVED!!!!!\n\n\n\n");
}

etime = (time(NULL) - htime);
if (etime >= 10) {
hps = hcount / etime;
hcount = 0;
htime = time(NULL);
loopcount++;
printf("\n\nStatus (solving): HPS: %luM/h Now Solving: 0x%s Diff: %d TX Count: %lu Blocks Solved: %d\n",

hps = 0;
for (int i = 0; i < initGPU; i++) {
printf("GPU %d: %d H/s\n", i, peach_ctx[i].ahps);
hps += peach_ctx[i].ahps;
}

printf("\n\nStatus (solving): HPS: %lu H/s Now Solving: 0x%s Diff: %d TX Count: %lu Blocks Solved: %d\n",
(unsigned long)hps, bnum2hex(bt.bnum), bt.difficulty[0], (unsigned long)get32(bt.tcount), solvedblocks);

set_status("solving");
haikurate = hps;
haikurate = hps / 1000;
current_block = *((uint64_t*)bt.bnum);
current_diff = bt.difficulty[0];
tx_count = (uint64_t)get32(bt.tcount);
blocks_solved = solvedblocks;
}
if (haiku != NULL) break;
if (solved) break;
if (exists("restart.lck")) {
printf("\nNetwork Block Update Detected, Downloading new block to mine.");
set_status("updating block");
Expand All @@ -140,8 +151,6 @@ int miner(char *blockin, char *blockout, char *addrfile, Compute_Type ct)
Running = 0;
}
Sleep(1);

break; // TODO: FIX THIS
}
//trigg_free_gpu(ct);
free_cuda_peach();
Expand Down
2 changes: 1 addition & 1 deletion winminer_v1/winminer/winminer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "algo/trigg/trigg.h"
#include "config.h"

#define WINMINER_VERSION "1.6b1"
#define WINMINER_VERSION "1.6b2"

static const word32 v24trigger[2] = { V24TRIGGER, 0 };

Expand Down
2 changes: 2 additions & 0 deletions winminer_v1/winminer/winminer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
<ClInclude Include="crypto\wots\wots.h" />
<ClInclude Include="gui.h" />
<ClInclude Include="gpu_wrapper.h" />
<ClInclude Include="helpers.h" />
<ClInclude Include="helper_cuda.h" />
<ClInclude Include="helper_string.h" />
<ClInclude Include="miner.h" />
Expand Down Expand Up @@ -205,6 +206,7 @@
</ClCompile>
<ClCompile Include="gui.cpp" />
<ClCompile Include="gpu_wrapper.cpp" />
<ClCompile Include="helpers.cpp" />
<ClCompile Include="miner.cpp" />
<ClCompile Include="algo\trigg\trigg_cl.cpp" />
<ClCompile Include="sleep.cpp" />
Expand Down

0 comments on commit bad56da

Please sign in to comment.