Skip to content

Commit

Permalink
Merge pull request nginnever#69 from lhl/master
Browse files Browse the repository at this point in the history
Added -P flag to specify which OpenCL Platform to look at
  • Loading branch information
omaralvarez authored Nov 5, 2016
2 parents 5991779 + 83ce0ba commit f6987d5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/libzogminer/gpuconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class GPUConfig {
//~GPUConfig();

bool useGPU;
unsigned platformId;
int64_t selGPU;
unsigned globalWorkSize;
unsigned workgroupSize;
Expand Down
12 changes: 6 additions & 6 deletions src/libzogminer/gpusolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ char *s_hexdump(const void *_a, uint32_t a_len)
return buf;
}

GPUSolver::GPUSolver() {
GPUSolver::GPUSolver(unsigned platformId) {

/* Notes
I've added some extra parameters in this interface to assist with dev, such as
Expand Down Expand Up @@ -72,7 +72,7 @@ GPUSolver::GPUSolver() {
@params: unsigned localWorkSizes
@params: unsigned globalWorkSizes
*/
GPU = miner->configureGPU(0, local_work_size, global_work_size);
GPU = miner->configureGPU(platformId, local_work_size, global_work_size);
if(!GPU)
std::cout << "ERROR: No suitable GPU found! No work will be performed!" << std::endl;

Expand All @@ -86,11 +86,11 @@ GPUSolver::GPUSolver() {
std::vector<std::string> kernels {"kernel_init_ht", "kernel_round0", "kernel_round1", "kernel_round2","kernel_round3", "kernel_round4", "kernel_round5", "kernel_round6", "kernel_round7", "kernel_round8", "kernel_sols"};

if(GPU)
initOK = miner->init(0, 0, kernels);
initOK = miner->init(platformId, 0, kernels);

}

GPUSolver::GPUSolver(int64_t selGPU) {
GPUSolver::GPUSolver(unsigned platformId, int64_t selGPU) {

/* Notes
I've added some extra parameters in this interface to assist with dev, such as
Expand Down Expand Up @@ -121,7 +121,7 @@ GPUSolver::GPUSolver(int64_t selGPU) {
@params: unsigned localWorkSizes
@params: unsigned globalWorkSizes
*/
GPU = miner->configureGPU(0, local_work_size, global_work_size);
GPU = miner->configureGPU(platformId, local_work_size, global_work_size);
if(!GPU)
std::cout << "ERROR: No suitable GPU found! No work will be performed!" << std::endl;

Expand All @@ -134,7 +134,7 @@ GPUSolver::GPUSolver(int64_t selGPU) {
*/
std::vector<std::string> kernels {"kernel_init_ht", "kernel_round0", "kernel_round1", "kernel_round2","kernel_round3", "kernel_round4", "kernel_round5", "kernel_round6", "kernel_round7", "kernel_round8", "kernel_sols"};
if(GPU)
initOK = miner->init(0, selGPU, kernels);
initOK = miner->init(platformId, selGPU, kernels);

}

Expand Down
4 changes: 2 additions & 2 deletions src/libzogminer/gpusolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ enum GPUSolverCancelCheck
class GPUSolver {

public:
GPUSolver();
GPUSolver(int64_t selGPU);
GPUSolver(unsigned platformId);
GPUSolver(unsigned platformId, int64_t selGPU);
~GPUSolver();
bool run(unsigned int n, unsigned int k, uint8_t *header, size_t header_len, uint64_t nonce,
const std::function<bool(std::vector<unsigned char>)> validBlock,
Expand Down
3 changes: 2 additions & 1 deletion src/standaloneminer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void test_mine(int n, int k, uint32_t d, GPUConfig conf)
arith_uint256 hashTarget = arith_uint256().SetCompact(d);
GPUSolver * solver;
if(conf.useGPU)
solver = new GPUSolver(conf.selGPU);
solver = new GPUSolver(conf.platformId, conf.selGPU);

uint64_t nn= 0;
//TODO Free
Expand Down Expand Up @@ -246,6 +246,7 @@ int main(int argc, char* argv[])

conf.useGPU = GetBoolArg("-G", false);
conf.selGPU = GetArg("-S", 0);
conf.platformId = GetArg("-P", 0);
//std::cout << GPU << " " << selGPU << std::endl;

// Zcash debugging
Expand Down

0 comments on commit f6987d5

Please sign in to comment.