Skip to content
This repository was archived by the owner on Oct 21, 2019. It is now read-only.

Commit b19a12f

Browse files
author
nicehashdev
committed
Fixes & improvements
Faster DAG copying on CUDA
1 parent d156ee0 commit b19a12f

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

ethminer/MinerAux.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,12 +1018,13 @@ class MinerCLI
10181018

10191019
try
10201020
{
1021-
boost::array<char, 1> recv_buf;
1021+
boost::array<char, 16> recv_buf;
10221022
boost::system::error_code error;
10231023
size_t s = api_socket->receive_from(boost::asio::buffer(recv_buf), remote_endpoint, 0, error);
10241024
if (error && error != boost::asio::error::would_block)
10251025
throw boost::system::system_error(error);
1026-
if (s != 1) return 0;
1026+
if (s < 1) return 0;
1027+
//std::cout << "API received " << s << std::endl;
10271028
return (int)recv_buf.at(0);
10281029
}
10291030
catch (std::exception& e)
@@ -1058,6 +1059,7 @@ class MinerCLI
10581059
api_socket = new boost::asio::ip::udp::socket(m_io_service, endpoint);
10591060
boost::asio::socket_base::non_blocking_io nb(true);
10601061
api_socket->io_control(nb);
1062+
minelog << "API port " << m_apiPort << " bound";
10611063
}
10621064
catch (std::exception& e)
10631065
{
@@ -1166,6 +1168,7 @@ class MinerCLI
11661168
double spd = 0;
11671169
if (mp.ms > 0) spd = (double)mp.hashes / (mp.ms * 1000);
11681170
api_socket->send_to(boost::asio::buffer((void*)&spd, sizeof(spd)), remote_endpoint);
1171+
//std::cout << "API replied "<< std::endl;
11691172
}
11701173
}
11711174
if (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - tp).count() < m_farmRecheckPeriod)

libethash-cuda/ethash_cuda_miner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ bool ethash_cuda_miner::init(ethash_light_t _light, uint8_t const* _lightData, u
271271

272272
if (_cpyToHost)
273273
{
274-
uint8_t* memoryDAG = new uint8_t[dagSize];
274+
uint8_t* memoryDAG = nullptr; // = new uint8_t[dagSize];
275+
CUDA_SAFE_CALL(cudaHostAlloc(&memoryDAG, dagSize, 0));
275276
if (!memoryDAG) throw std::runtime_error("Failed to init host memory for DAG, not enough memory?");
276277

277278
cout << "Copying DAG from GPU #" << m_device << " to host" << endl;

libethcore/EthashCUDAMiner.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ void EthashCUDAMiner::workLoop()
180180
// free DAG if already existing
181181
if (s_dagInHostMemory && *s_dagSeed != w.seedHash)
182182
{
183-
delete[] s_dagInHostMemory;
183+
//delete[] s_dagInHostMemory;
184+
CUDA_SAFE_CALL(cudaFreeHost((void*)s_dagInHostMemory));
184185
s_dagInHostMemory = nullptr;
185186

186187
cout << "Freeing DAG from host" << endl;
@@ -212,7 +213,8 @@ void EthashCUDAMiner::workLoop()
212213
if (s_dagLoadIndex >= s_numInstances && s_dagInHostMemory)
213214
{
214215
// all devices have loaded DAG, we can free now
215-
delete[] s_dagInHostMemory;
216+
//delete[] s_dagInHostMemory;
217+
CUDA_SAFE_CALL(cudaFreeHost((void*)s_dagInHostMemory));
216218
s_dagInHostMemory = nullptr;
217219

218220
cout << "Freeing DAG from host" << endl;

0 commit comments

Comments
 (0)