Skip to content

Commit

Permalink
Speed optimizations #1 in SHA512 kernel. Added a dev-feeding donation…
Browse files Browse the repository at this point in the history
… that's easy to tweak.
  • Loading branch information
dave-andersen committed Jan 11, 2014
1 parent 14da03c commit 7a5d65a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/gpuhash.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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++) {


Expand Down Expand Up @@ -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]));
}
Expand Down
58 changes: 56 additions & 2 deletions src/main_poolminer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<boost::shared_mutex> lock(_mutex_master);
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
}
}
}

Expand Down

0 comments on commit 7a5d65a

Please sign in to comment.