Skip to content
Snippets Groups Projects
Commit d3c5911f authored by fireice-uk's avatar fireice-uk
Browse files

move nicehash check into nonce calc

parent 27b839b8
No related branches found
No related tags found
No related merge requests found
...@@ -844,7 +844,8 @@ size_t XMRRunJob(GpuContext* ctx, cl_uint* HashOutput) ...@@ -844,7 +844,8 @@ size_t XMRRunJob(GpuContext* ctx, cl_uint* HashOutput)
} }
}*/ }*/
if((ret = clEnqueueNDRangeKernel(ctx->CommandQueues, ctx->Kernels[1], 1, &ctx->Nonce, &g_thd, &w_size, 0, NULL, NULL)) != CL_SUCCESS) size_t tmpNonce = ctx->Nonce;
if((ret = clEnqueueNDRangeKernel(ctx->CommandQueues, ctx->Kernels[1], 1, &tmpNonce, &g_thd, &w_size, 0, NULL, NULL)) != CL_SUCCESS)
{ {
printer::inst()->print_msg(L1,"Error %s when calling clEnqueueNDRangeKernel for kernel %d.", err_to_str(ret), 1); printer::inst()->print_msg(L1,"Error %s when calling clEnqueueNDRangeKernel for kernel %d.", err_to_str(ret), 1);
return ERR_OCL_API; return ERR_OCL_API;
...@@ -897,7 +898,8 @@ size_t XMRRunJob(GpuContext* ctx, cl_uint* HashOutput) ...@@ -897,7 +898,8 @@ size_t XMRRunJob(GpuContext* ctx, cl_uint* HashOutput)
BranchNonces[i] = ((BranchNonces[i] + w_size - 1u) / w_size) * w_size; BranchNonces[i] = ((BranchNonces[i] + w_size - 1u) / w_size) * w_size;
// number of global threads must be a multiple of the work group size (w_size) // number of global threads must be a multiple of the work group size (w_size)
assert(BranchNonces[i]%w_size == 0); assert(BranchNonces[i]%w_size == 0);
if((ret = clEnqueueNDRangeKernel(ctx->CommandQueues, ctx->Kernels[i + 3], 1, &ctx->Nonce, BranchNonces + i, &w_size, 0, NULL, NULL)) != CL_SUCCESS) size_t tmpNonce = ctx->Nonce;
if((ret = clEnqueueNDRangeKernel(ctx->CommandQueues, ctx->Kernels[i + 3], 1, &tmpNonce, BranchNonces + i, &w_size, 0, NULL, NULL)) != CL_SUCCESS)
{ {
printer::inst()->print_msg(L1,"Error %s when calling clEnqueueNDRangeKernel for kernel %d.", err_to_str(ret), i + 3); printer::inst()->print_msg(L1,"Error %s when calling clEnqueueNDRangeKernel for kernel %d.", err_to_str(ret), i + 3);
return ERR_OCL_API; return ERR_OCL_API;
......
...@@ -36,7 +36,7 @@ struct GpuContext ...@@ -36,7 +36,7 @@ struct GpuContext
int computeUnits; int computeUnits;
std::string name; std::string name;
size_t Nonce; uint32_t Nonce;
}; };
......
...@@ -200,10 +200,7 @@ void minethd::work_main() ...@@ -200,10 +200,7 @@ void minethd::work_main()
//Allocate a new nonce every 16 rounds //Allocate a new nonce every 16 rounds
if((round_ctr++ & 0xF) == 0) if((round_ctr++ & 0xF) == 0)
{ {
if(oWork.bNiceHash) globalStates::inst().calc_start_nonce(pGpuCtx->Nonce, oWork.bNiceHash, h_per_round * 16);
pGpuCtx->Nonce = globalStates::inst().calc_start_nonce(pGpuCtx->Nonce & 0xFF000000u, h_per_round * 16);
else
pGpuCtx->Nonce = globalStates::inst().calc_start_nonce(0, h_per_round * 16);
} }
cl_uint results[0x100]; cl_uint results[0x100];
......
...@@ -348,6 +348,9 @@ void minethd::work_main() ...@@ -348,6 +348,9 @@ void minethd::work_main()
assert(sizeof(job_result::sJobID) == sizeof(pool_job::sJobID)); assert(sizeof(job_result::sJobID) == sizeof(pool_job::sJobID));
memcpy(result.sJobID, oWork.sJobID, sizeof(job_result::sJobID)); memcpy(result.sJobID, oWork.sJobID, sizeof(job_result::sJobID));
if(oWork.bNiceHash)
result.iNonce = *piNonce;
while(globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) == iJobNo) while(globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) == iJobNo)
{ {
if ((iCount++ & 0xF) == 0) //Store stats every 16 hashes if ((iCount++ & 0xF) == 0) //Store stats every 16 hashes
...@@ -360,10 +363,7 @@ void minethd::work_main() ...@@ -360,10 +363,7 @@ void minethd::work_main()
if((nonce_ctr++ & (nonce_chunk-1)) == 0) if((nonce_ctr++ & (nonce_chunk-1)) == 0)
{ {
if(oWork.bNiceHash) globalStates::inst().calc_start_nonce(result.iNonce, oWork.bNiceHash, nonce_chunk);
result.iNonce = globalStates::inst().calc_start_nonce(*piNonce & 0xFF000000, nonce_chunk);
else
result.iNonce = globalStates::inst().calc_start_nonce(0, nonce_chunk);
} }
*piNonce = ++result.iNonce; *piNonce = ++result.iNonce;
...@@ -466,6 +466,9 @@ void minethd::double_work_main() ...@@ -466,6 +466,9 @@ void minethd::double_work_main()
assert(sizeof(job_result::sJobID) == sizeof(pool_job::sJobID)); assert(sizeof(job_result::sJobID) == sizeof(pool_job::sJobID));
if(oWork.bNiceHash)
iNonce = *piNonce0;
while (globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) == iJobNo) while (globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) == iJobNo)
{ {
if ((iCount & 0x7) == 0) //Store stats every 16 hashes if ((iCount & 0x7) == 0) //Store stats every 16 hashes
...@@ -480,10 +483,7 @@ void minethd::double_work_main() ...@@ -480,10 +483,7 @@ void minethd::double_work_main()
if((nonce_ctr++ & (nonce_chunk/2 - 1)) == 0) if((nonce_ctr++ & (nonce_chunk/2 - 1)) == 0)
{ {
if(oWork.bNiceHash) globalStates::inst().calc_start_nonce(iNonce, oWork.bNiceHash, nonce_chunk);
iNonce = globalStates::inst().calc_start_nonce(*piNonce0 & 0xFF000000, nonce_chunk);
else
iNonce = globalStates::inst().calc_start_nonce(0, nonce_chunk);
} }
......
...@@ -33,11 +33,14 @@ struct globalStates ...@@ -33,11 +33,14 @@ struct globalStates
//pool_data is in-out winapi style //pool_data is in-out winapi style
void switch_work(miner_work& pWork, pool_data& dat); void switch_work(miner_work& pWork, pool_data& dat);
inline uint32_t calc_start_nonce(uint32_t nicehash_nonce, uint32_t reserve_count) inline void calc_start_nonce(uint32_t& nonce, bool use_nicehash, uint32_t reserve_count)
{ {
uint32_t debug_nonce = nicehash_nonce | iGlobalNonce.fetch_add(reserve_count); if(use_nicehash)
printer::inst()->print_msg(L1, "DEBUG: start_nonce assigned nh: %.8x rc: %.8x nonce: %.8x", nicehash_nonce, reserve_count, debug_nonce); nonce = (nonce & 0xFF000000) | iGlobalNonce.fetch_add(reserve_count);
return debug_nonce; else
nonce = iGlobalNonce.fetch_add(reserve_count);
printer::inst()->print_msg(L1, "DEBUG: start_nonce assigned rc: %.8x nonce: %.8x", reserve_count, nonce);
} }
miner_work oGlobalWork; miner_work oGlobalWork;
......
...@@ -232,10 +232,7 @@ void minethd::work_main() ...@@ -232,10 +232,7 @@ void minethd::work_main()
//Allocate a new nonce every 16 rounds //Allocate a new nonce every 16 rounds
if((round_ctr++ & 0xF) == 0) if((round_ctr++ & 0xF) == 0)
{ {
if(oWork.bNiceHash) iNonce = globalStates::inst().calc_start_nonce(iNonce, oWork.bNiceHash, h_per_round * 16);
iNonce = globalStates::inst().calc_start_nonce(iNonce & 0xFF000000u, h_per_round * 16);
else
iNonce = globalStates::inst().calc_start_nonce(0, h_per_round * 16);
} }
uint32_t foundNonce[10]; uint32_t foundNonce[10];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment