Browse Source

fixed multiple GPU support

cl-refactor
Jan Willem Penterman 10 years ago
parent
commit
dcb0cc96ab
  1. 19
      ethminer/MinerAux.h
  2. 36
      libethash-cuda/ethash_cuda_miner.cpp
  3. 1
      libethash-cuda/ethash_cuda_miner.h
  4. 5
      libethcore/EthashCUDAMiner.cpp
  5. 1
      libethcore/EthashCUDAMiner.h

19
ethminer/MinerAux.h

@ -375,23 +375,24 @@ public:
else if (m_minerType == MinerType::CUDA)
{
#if ETH_ETHASHCUDA || !ETH_TRUE
if (m_cudaDeviceCount == 0)
{
m_cudaDevices[0] = 0;
m_cudaDeviceCount = 1;
}
EthashCUDAMiner::setDevices(m_cudaDevices, m_cudaDeviceCount);
m_miningThreads = m_cudaDeviceCount;
EthashCUDAMiner::setNumInstances(m_miningThreads);
if (!EthashCUDAMiner::configureGPU(
m_localWorkSize,
m_globalWorkSizeMultiplier,
m_numStreams,
m_openclDevice,
m_extraGPUMemory,
m_cudaHighCPULoad,
m_currentBlock
))
exit(1);
if (m_cudaDeviceCount != 0)
{
EthashCUDAMiner::setDevices(m_cudaDevices, m_cudaDeviceCount);
m_miningThreads = m_cudaDeviceCount;
}
EthashCUDAMiner::setNumInstances(m_miningThreads);
#else
cerr << "Selected CUDA mining without having compiled with -DETHASHCUDA=1 or -DBUNDLE=cudaminer" << endl;
exit(1);
@ -486,7 +487,7 @@ private:
sealers["opencl"] = GenericFarm<EthashProofOfWork>::SealerDescriptor{&EthashGPUMiner::instances, [](GenericMiner<EthashProofOfWork>::ConstructionInfo ci){ return new EthashGPUMiner(ci); }};
#endif
#if ETH_ETHASHCUDA
sealers["cuda"] = GenericFarm<EthashProofOfWork>::SealerDescriptor{ &EthashGPUMiner::instances, [](GenericMiner<EthashProofOfWork>::ConstructionInfo ci){ return new EthashCUDAMiner(ci); } };
sealers["cuda"] = GenericFarm<EthashProofOfWork>::SealerDescriptor{ &EthashCUDAMiner::instances, [](GenericMiner<EthashProofOfWork>::ConstructionInfo ci){ return new EthashCUDAMiner(ci); } };
#endif
f.setSealers(sealers);
f.onSolutionFound([&](EthashProofOfWork::Solution) { return false; });

36
libethash-cuda/ethash_cuda_miner.cpp

@ -129,6 +129,7 @@ unsigned ethash_cuda_miner::getNumDevices()
}
bool ethash_cuda_miner::configureGPU(
int * _devices,
unsigned _blockSize,
unsigned _gridSize,
unsigned _numStreams,
@ -148,24 +149,29 @@ bool ethash_cuda_miner::configureGPU(
uint64_t requiredSize = dagSize + _extraGPUMemory;
for (unsigned int i = 0; i < getNumDevices(); i++)
{
cudaDeviceProp props;
CUDA_SAFE_CALL(cudaGetDeviceProperties(&props, i));
if (props.totalGlobalMem >= requiredSize)
if (_devices[i] != -1)
{
ETHCUDA_LOG(
"Found suitable CUDA device [" << string(props.name)
<< "] with " << props.totalGlobalMem << " bytes of GPU memory"
);
return true;
cudaDeviceProp props;
CUDA_SAFE_CALL(cudaGetDeviceProperties(&props, _devices[i]));
if (props.totalGlobalMem >= requiredSize)
{
ETHCUDA_LOG(
"Found suitable CUDA device [" << string(props.name)
<< "] with " << props.totalGlobalMem << " bytes of GPU memory"
);
}
else
{
ETHCUDA_LOG(
"CUDA device " << string(props.name)
<< " has insufficient GPU memory." << to_string(props.totalGlobalMem) <<
" bytes of memory found < " << to_string(requiredSize) << " bytes of memory required"
);
return false;
}
}
ETHCUDA_LOG(
"CUDA device " << string(props.name)
<< " has insufficient GPU memory." << to_string(props.totalGlobalMem) <<
" bytes of memory found < " << to_string(requiredSize) << " bytes of memory required"
);
}
return false;
return true;
}
unsigned ethash_cuda_miner::s_extraRequiredGPUMem;

1
libethash-cuda/ethash_cuda_miner.h

@ -26,6 +26,7 @@ public:
static unsigned getNumDevices();
static void listDevices();
static bool configureGPU(
int * _devices,
unsigned _blockSize,
unsigned _gridSize,
unsigned _numStreams,

5
libethcore/EthashCUDAMiner.cpp

@ -146,7 +146,7 @@ void EthashCUDAMiner::workLoop()
delete m_miner;
m_miner = new ethash_cuda_miner;
unsigned device = instances() > 1 ? (s_devices[index()] > -1 ? s_devices[index()] : index()) : s_deviceId;
unsigned device = s_devices[index()] > -1 ? s_devices[index()] : index();
EthashAux::FullType dag;
while (true)
@ -202,19 +202,18 @@ bool EthashCUDAMiner::configureGPU(
unsigned _blockSize,
unsigned _gridSize,
unsigned _numStreams,
unsigned _deviceId,
unsigned _extraGPUMemory,
bool _highcpu,
uint64_t _currentBlock
)
{
s_deviceId = _deviceId;
if (_blockSize != 32 && _blockSize != 64 && _blockSize != 128)
{
cout << "Given localWorkSize of " << toString(_blockSize) << "is invalid. Must be either 32,64 or 128" << endl;
return false;
}
if (!ethash_cuda_miner::configureGPU(
s_devices,
_blockSize,
_gridSize,
_numStreams,

1
libethcore/EthashCUDAMiner.h

@ -51,7 +51,6 @@ namespace eth
unsigned _blockSize,
unsigned _gridSize,
unsigned _numStreams,
unsigned _deviceId,
unsigned _extraGPUMemory,
bool _highcpu,
uint64_t _currentBlock

Loading…
Cancel
Save