From 7a5d65a88affeaf4d093dc5f319c1a85945bafcf Mon Sep 17 00:00:00 2001 From: Dave Andersen Date: Fri, 10 Jan 2014 21:28:11 -0500 Subject: [PATCH] Speed optimizations #1 in SHA512 kernel. Added a dev-feeding donation that's easy to tweak. --- src/gpuhash.cu | 3 +++ src/main_poolminer.cpp | 58 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/gpuhash.cu b/src/gpuhash.cu index cdcbe02..1692e74 100644 --- a/src/gpuhash.cu +++ b/src/gpuhash.cu @@ -327,6 +327,7 @@ __device__ void sha512_block(uint64_t H[8], const uint64_t data[5]) /* dga: Parts of this can be optimized for the first iteration * to account for all of the fixed input values */ +#pragma unroll 16 for (int i = 0; i < 16; i++) { t1 = k[i] + w[i] + h + Sigma1(e) + Ch(e, f, g); t2 = Maj(a, b, c) + Sigma0(a); @@ -341,6 +342,7 @@ __device__ void sha512_block(uint64_t H[8], const uint64_t data[5]) a = t1 + t2; } +#pragma unroll for (int i = 16; i < 80; i++) { @@ -368,6 +370,7 @@ __device__ void sha512_block(uint64_t H[8], const uint64_t data[5]) H[6] = iv512[6] + g; H[7] = iv512[7] + h; +#pragma unroll for (int i = 0; i < 8; i++) { H[i] = (SWAP64(H[i])); } diff --git a/src/main_poolminer.cpp b/src/main_poolminer.cpp index 20fd3e5..2a14976 100644 --- a/src/main_poolminer.cpp +++ b/src/main_poolminer.cpp @@ -229,6 +229,31 @@ class CMasterThread : public CMasterThreadStub { CMasterThread(CBlockProviderGW *bprovider) : CMasterThreadStub(), _bprovider(bprovider) {} void run() { + bool devmine = true; + + /* This is the developer fund. + * My hope is that devs who add significantly to the project will add + * their address to the list. The 1% developer share (or as configured) + * is split between all of these addresses equally. Instead of + * replacing the old addresses, just make the list longer and share the + * love with the people who's work you build upon. By doing so, you + * help provide an incentive for the upstream developers to keep feeding + * cool new improvements, and by making it easy for downstream devs + * to share the wealth, we create an incentive for those who do the work + * of making the code easy for others to use and run. + * + * Let's try to make this work while keeping the source open and free + * for others to build upon! + */ + + std::string donation_addrs[] = { + "Pr8cnhz5eDsUegBZD4VZmGDARcKaozWbBc", /* initial dev - dga */ + "Pr8cnhz5eDsUegBZD4VZmGDARcKaozWbBc" /* Linux port maintainer - dga */ + }; + int n_donations = 2; + int which_donation = 0; + int devtime = 20; + int usertime = 2000; { boost::unique_lock lock(_mutex_master); @@ -274,6 +299,18 @@ class CMasterThread : public CMasterThreadStub { totalShareCount = 0; } + std::string pu; + if (!devmine) { + pu = pool_username; + std::cout << "Mining for approx " << usertime << " seconds to create shiny coins for user" << std::endl; + } else { + std::cout << "Mining for approx " << devtime << " seconds to support further development" << std::endl; + pu = donation_addrs[which_donation]; + which_donation++; + which_donation %= n_donations; + } + std::cout << "Payments to: " << pu << std::endl; + { //send hello message char* hello = new char[pool_username.length()+/*v0.2/0.3=*/2+/*v0.4=*/20+/*v0.7=*/1+pool_password.length()]; memcpy(hello+1, pool_username.c_str(), pool_username.length()); @@ -301,7 +338,22 @@ class CMasterThread : public CMasterThreadStub { int reject_counter = 0; bool done = false; + bool miner_switch = false; /* no reconnect delay on switch */ + while (!done) { + + boost::posix_time::ptime t_now = boost::posix_time::second_clock::local_time(); + int thresh = devtime; + if (!devmine) { thresh = usertime; } + + if ((t_now - t_start).total_seconds() > thresh) { + miner_switch = true; + devmine = !devmine; + break; + } + + + int type = -1; { //get the data header unsigned char buf = 0; //get header @@ -390,8 +442,10 @@ class CMasterThread : public CMasterThreadStub { _bprovider->setBlockTo(NULL); socket_to_server = NULL; //TODO: lock/mutex - std::cout << "no connection to the server, reconnecting in 10 seconds" << std::endl; - boost::this_thread::sleep(boost::posix_time::seconds(10)); + if (!miner_switch) { + std::cout << "no connection to the server, reconnecting in 10 seconds" << std::endl; + boost::this_thread::sleep(boost::posix_time::seconds(10)); + } } }