| 14 | } |
| 15 | |
| 16 | CudaKeySearchDevice::CudaKeySearchDevice(int device, int threads, int pointsPerThread, int blocks) |
| 17 | { |
| 18 | cuda::CudaDeviceInfo info; |
| 19 | try { |
| 20 | info = cuda::getDeviceInfo(device); |
| 21 | _deviceName = info.name; |
| 22 | } catch(cuda::CudaException ex) { |
| 23 | throw KeySearchException(ex.msg); |
| 24 | } |
| 25 | |
| 26 | if(threads <= 0 || threads % 32 != 0) { |
| 27 | throw KeySearchException("The number of threads must be a multiple of 32"); |
| 28 | } |
| 29 | |
| 30 | if(pointsPerThread <= 0) { |
| 31 | throw KeySearchException("At least 1 point per thread required"); |
| 32 | } |
| 33 | |
| 34 | // Specifying blocks on the commandline is depcreated but still supported. If there is no value for |
| 35 | // blocks, devide the threads evenly among the multi-processors |
| 36 | if(blocks == 0) { |
| 37 | if(threads % info.mpCount != 0) { |
| 38 | throw KeySearchException("The number of threads must be a multiple of " + util::format("%d", info.mpCount)); |
| 39 | } |
| 40 | |
| 41 | _threads = threads / info.mpCount; |
| 42 | |
| 43 | _blocks = info.mpCount; |
| 44 | |
| 45 | while(_threads > 512) { |
| 46 | _threads /= 2; |
| 47 | _blocks *= 2; |
| 48 | } |
| 49 | } else { |
| 50 | _threads = threads; |
| 51 | _blocks = blocks; |
| 52 | } |
| 53 | |
| 54 | _iterations = 0; |
| 55 | |
| 56 | _device = device; |
| 57 | |
| 58 | _pointsPerThread = pointsPerThread; |
| 59 | } |
| 60 | |
| 61 | void CudaKeySearchDevice::init(const secp256k1::uint256 &start, int compression, const secp256k1::uint256 &stride) |
| 62 | { |
nothing calls this directly
no test coverage detected