Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jonano614 committed Jul 11, 2018
2 parents dad774e + 1c4b948 commit 883ae6e
Show file tree
Hide file tree
Showing 66 changed files with 2,308 additions and 789 deletions.
32 changes: 17 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/**/*.o
/**/*~
/.vs/
/GpuMiner.VC.db
/GpuMiner/x64/
/packages/
/x64/
/GpuMiner.VC.VC.opendb
GpuMiner/GpuMiner.vcxproj.user
GpuMiner/version.aps
/params.txt
/GpuMiner/Release/
/Release/
/Debug/
/GpuMiner/Debug/
/**/*.o
/**/*~
/.vs/
/GpuMiner.VC.db
/GpuMiner/x64/
/packages/
/x64/
/GpuMiner.VC.VC.opendb
GpuMiner/GpuMiner.vcxproj.user
GpuMiner/version.aps
/params.txt
/GpuMiner/Release/
/Release/
/Debug/
/GpuMiner/Debug/
GpuMiner/GpuMiner.xcodeproj/project.xcworkspace
mac/GpuMiner.xcodeproj/project.xcworkspace
4 changes: 2 additions & 2 deletions GpuMiner.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GpuMiner", "GpuMiner\GpuMiner.vcxproj", "{F28FA0B5-F3B9-45B1-9271-6D4B23A19695}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DaggerGpuMiner", "GpuMiner\GpuMiner.vcxproj", "{F28FA0B5-F3B9-45B1-9271-6D4B23A19695}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
1 change: 0 additions & 1 deletion GpuMiner/CL/CLMiner_kernel.cl
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ __kernel void search_nonce(ulong startNonce,
}
++nonce;
#endif

}

if(minH < targetH || (minH == targetH && minG <= targetG))
Expand Down
15 changes: 8 additions & 7 deletions GpuMiner/Core/Common.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/*
This file is taken from ethminer project.
*/
/*
* Evgeniy Sukhomlinov
* 2018
*/
// ethminer -- Ethereum miner with OpenCL, CUDA and stratum support.
// Copyright 2018 ethminer Authors.
// Licensed under GNU General Public License, Version 3. See the LICENSE file.

/// @file
/// Very common stuff (i.e. that every other header needs except vector_ref.h).

// Modified by Evgeniy Sukhomlinov 2018

#pragma once

Expand Down
25 changes: 20 additions & 5 deletions GpuMiner/Core/CommonData.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
/*
This file is taken from ethminer project.
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Evgeniy Sukhomlinov
* 2018
*/
/** @file CommonData.cpp
* @author Gav Wood <i@gavwood.com>
* @date 2014
*/

// Modified by Evgeniy Sukhomlinov 2018

#include "CommonData.h"
#include <cstdlib>
Expand Down
27 changes: 21 additions & 6 deletions GpuMiner/Core/CommonData.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
/*
This file is taken from ethminer project.
This file is part of cpp-ethereum.
Shared algorithms and data types.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Evgeniy Sukhomlinov
* 2018
*/
/** @file CommonData.h
* @author Gav Wood <i@gavwood.com>
* @date 2014
*
* Shared algorithms and data types.
*/

// Modified by Evgeniy Sukhomlinov 2018

#pragma once

Expand Down
25 changes: 20 additions & 5 deletions GpuMiner/Core/Exceptions.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
/*
This file is taken from ethminer project.
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Evgeniy Sukhomlinov
* 2018
*/
/** @file Exceptions.h
* @author Gav Wood <i@gavwood.com>
* @date 2014
*/

// Modified by Evgeniy Sukhomlinov 2018

#pragma once

Expand Down
108 changes: 55 additions & 53 deletions GpuMiner/Core/Farm.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
/*
This file is taken from ethminer project.
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Evgeniy Sukhomlinov
* 2018
*/

#pragma once
// Modified by Evgeniy Sukhomlinov 2018

#include "Farm.h"

using namespace XDag;

Farm::Farm(XTaskProcessor* taskProcessor, boost::asio::io_service &io_service) :
_io_strand(io_service),
_hashrateTimer(io_service)
{
_taskProcessor = taskProcessor;
}

/**
* @brief Start a number of miners.
*/
Expand Down Expand Up @@ -66,21 +82,12 @@ bool Farm::Start()
// package.
m->StartWorking();
}
_isMining = true;
_isMining.store(true, std::memory_order_relaxed);
_progressJustStarted = true;

if(!_hashrateTimer)
{
_hashrateTimer = new boost::asio::deadline_timer(_io_service, boost::posix_time::milliseconds(1000));
_hashrateTimer->async_wait(boost::bind(&Farm::ProcessHashRate, this, boost::asio::placeholders::error));
if(_serviceThread.joinable())
{
_io_service.reset();
}
else
{
_serviceThread = std::thread { boost::bind(&boost::asio::io_service::run, &_io_service) };
}
}
// Start hashrate collector
_hashrateTimer.expires_from_now(boost::posix_time::milliseconds(1000));
_hashrateTimer.async_wait(_io_strand.wrap(boost::bind(&Farm::ProcessHashRate, this, boost::asio::placeholders::error)));

return true;
}
Expand All @@ -97,44 +104,34 @@ void Farm::Stop()
m->StopWorking();
}
_miners.clear();
_isMining = false;
}

_io_service.stop();
if(_serviceThread.joinable())
{
_serviceThread.join();
_isMining.store(false, std::memory_order_relaxed);
}

if(_hashrateTimer)
{
_hashrateTimer->cancel();
_hashrateTimer = nullptr;
}
_hashrateTimer.cancel();
_lastProgresses.clear();
}

void Farm::CollectHashRate()
{
auto now = std::chrono::steady_clock::now();

Guard l(_minerWorkLock);
WorkingProgress p;
Guard l2(_minerWorkLock);
p.ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - _lastStart).count();
//Collect
for(auto const& i : _miners)
p.ms = std::chrono::duration_cast<std::chrono::milliseconds>(now - _lastStart).count();
_lastStart = now;

// Collect & Reset
for(auto const& m : _miners)
{
uint64_t minerHashCount = i->HashCount();
uint64_t minerHashCount = m->HashCount();
m->ResetHashCount();
p.hashes += minerHashCount;
p.minersHashes.push_back(minerHashCount);
}

//Reset
for(auto const& i : _miners)
{
i->ResetHashCount();
}
_lastStart = std::chrono::steady_clock::now();

if(p.hashes > 0)
if((p.hashes > 0 || !_progressJustStarted) && IsMining())
{
_progressJustStarted = false;
_lastProgresses.push_back(p);
}

Expand All @@ -154,12 +151,17 @@ void Farm::ProcessHashRate(const boost::system::error_code& ec)
{
if(!ec)
{
if(!IsMining())
{
return;
}

CollectHashRate();
}

// Restart timer
_hashrateTimer->expires_at(_hashrateTimer->expires_at() + boost::posix_time::milliseconds(1000));
_hashrateTimer->async_wait(boost::bind(&Farm::ProcessHashRate, this, boost::asio::placeholders::error));
// Resubmit timer only if actually mining
_hashrateTimer.expires_from_now(boost::posix_time::milliseconds(1000));
_hashrateTimer.async_wait(_io_strand.wrap(boost::bind(&Farm::ProcessHashRate, this, boost::asio::placeholders::error)));
}
}

/**
Expand Down Expand Up @@ -190,10 +192,10 @@ WorkingProgress const& Farm::MiningProgress(bool hwmon) const
for(auto const& i : _miners)
{
p.minersHashes.push_back(0);
if(hwmon)
{
p.minerMonitors.push_back(i->Hwmon());
}
//if(hwmon)
//{
// p.minerMonitors.push_back(i->Hwmon());
//}
}

for(auto const& cp : _lastProgresses)
Expand Down
36 changes: 26 additions & 10 deletions GpuMiner/Core/Farm.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
/*
This file is taken from ethminer project.
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Evgeniy Sukhomlinov
* 2018
*/
/** @file Farm.h
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/

// Modified by Evgeniy Sukhomlinov 2018

#pragma once

Expand Down Expand Up @@ -34,7 +49,7 @@ namespace XDag
std::function<Miner*(unsigned, XTaskProcessor*)> Create;
};

Farm(XTaskProcessor* taskProcessor) { _taskProcessor = taskProcessor; }
Farm(XTaskProcessor* taskProcessor, boost::asio::io_service & io_service);
~Farm()
{
Stop();
Expand Down Expand Up @@ -63,7 +78,7 @@ namespace XDag

bool IsMining() const
{
return _isMining;
return _isMining.load(std::memory_order_relaxed);
}

/**
Expand Down Expand Up @@ -106,10 +121,11 @@ namespace XDag

std::chrono::steady_clock::time_point _lastStart;
uint32_t _hashrateSmoothInterval = 10000;
std::thread _serviceThread; ///< The IO service thread.
boost::asio::io_service _io_service;
boost::asio::deadline_timer *_hashrateTimer = nullptr;

boost::asio::io_service::strand _io_strand;
boost::asio::deadline_timer _hashrateTimer;
std::vector<WorkingProgress> _lastProgresses;
bool _progressJustStarted;

std::chrono::steady_clock::time_point _farm_launched = std::chrono::steady_clock::now();
};
Expand Down

0 comments on commit 883ae6e

Please sign in to comment.