Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
-d, --device option was not being passed to the KeyFinder class, so CUDA device 0 was always being used.
  • Loading branch information
brichard19 committed Feb 28, 2018
1 parent f3eeb10 commit 75715cf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
13 changes: 10 additions & 3 deletions KeyFinder/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int main(int argc, char **argv)

std::vector<std::string> targetList;
secp256k1::uint256 start(1);
unsigned long long range = 0;// (unsigned long long)2 << 32;
unsigned long long range = 0;

if(cuda::getDeviceCount == 0) {
printf("No CUDA devices available\n");
Expand Down Expand Up @@ -181,7 +181,14 @@ int main(int argc, char **argv)

targetList.push_back(ops[0]);

cuda::CudaDeviceInfo devInfo = cuda::getDeviceInfo(device);
cuda::CudaDeviceInfo devInfo;

try {
devInfo = cuda::getDeviceInfo(device);
} catch(cuda::CudaException &Ex) {
printf("Error initializing device: %s\n", Ex.msg.c_str());
return 1;
}

printf("Device: %s\n", devInfo.name.c_str());
printf("Target: %s\n", targetList[0].c_str());
Expand All @@ -202,7 +209,7 @@ int main(int argc, char **argv)

printf("Starting at: %s\n", start.toString().c_str());

KeyFinder f(start, range, targetList, compression, blocks, threads, pointsPerThread);
KeyFinder f(device, start, range, targetList, compression, blocks, threads, pointsPerThread);

f.setResultCallback(resultCallback);
f.setStatusInterval(1800);
Expand Down
4 changes: 2 additions & 2 deletions KeyFinderLib/KeyFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ void KeyFinder::defaultStatusCallback(KeyFinderStatusInfo status)
}


KeyFinder::KeyFinder(const secp256k1::uint256 &start, unsigned long long range, std::vector<std::string> &targetHashes, int compression, int blocks, int threads, int pointsPerThread)
KeyFinder::KeyFinder(int device, const secp256k1::uint256 &start, unsigned long long range, std::vector<std::string> &targetHashes, int compression, int blocks, int threads, int pointsPerThread)
{
_devCtx = NULL;
_total = 0;
_statusInterval = 1000;
_device = 0;
_device = device;
_pointsPerThread = DEFAULT_POINTS_PER_THREAD;
_numThreads = DEFAULT_NUM_THREADS;
_numBlocks = DEFAULT_NUM_BLOCKS;
Expand Down
2 changes: 1 addition & 1 deletion KeyFinderLib/KeyFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class KeyFinder {
};
};

KeyFinder(const secp256k1::uint256 &start, unsigned long long range, std::vector<std::string> &targetHashes, int compression, int blocks = 0, int threads = 0, int pointsPerThread = 0);
KeyFinder(int device, const secp256k1::uint256 &start, unsigned long long range, std::vector<std::string> &targetHashes, int compression, int blocks = 0, int threads = 0, int pointsPerThread = 0);
~KeyFinder();

void init();
Expand Down

0 comments on commit 75715cf

Please sign in to comment.