Browse Source

Merge branch 'cudaminer-frontier' into lop3

cl-refactor
Jan Willem Penterman 10 years ago
parent
commit
5ca5b9a01b
  1. 19
      ethminer/MinerAux.h
  2. 29
      libethash-cuda/CMakeLists.txt
  3. 14
      libethash-cuda/ethash_cuda_miner.cpp
  4. 1
      libethash-cuda/ethash_cuda_miner.h
  5. 5
      libethcore/EthashCUDAMiner.cpp
  6. 1
      libethcore/EthashCUDAMiner.h

19
ethminer/MinerAux.h

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

29
libethash-cuda/CMakeLists.txt

@ -0,0 +1,29 @@
set(EXECUTABLE ethash-cuda)
FIND_PACKAGE(CUDA REQUIRED)
file(GLOB SRC_LIST "*.cpp" "*.cu")
file(GLOB HEADERS "*.h" "*.cuh")
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};--std=c++11;--disable-warnings;--ptxas-options=-v;-use_fast_math;-lineinfo)
LIST(APPEND CUDA_NVCC_FLAGS_RELEASE -O3)
LIST(APPEND CUDA_NVCC_FLAGS_DEBUG -G)
if(COMPUTE)
LIST(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_${COMPUTE},code=sm_${COMPUTE})
else(COMPUTE)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode arch=compute_20,code=sm_20;-gencode arch=compute_30,code=sm_30;-gencode arch=compute_32,code=sm_32;-gencode arch=compute_35,code=sm_35;-gencode arch=compute_50,code=sm_50;-gencode arch=compute_52,code=sm_52)
endif(COMPUTE)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CUDA_INCLUDE_DIRS})
include_directories(..)
CUDA_ADD_LIBRARY(${EXECUTABLE} STATIC ${SRC_LIST} ${HEADERS})
TARGET_LINK_LIBRARIES(${EXECUTABLE} ${CUDA_LIBRARIES} ethash)
install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} )

14
libethash-cuda/ethash_cuda_miner.cpp

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

1
libethash-cuda/ethash_cuda_miner.h

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

5
libethcore/EthashCUDAMiner.cpp

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

1
libethcore/EthashCUDAMiner.h

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

Loading…
Cancel
Save