@@ -201,8 +201,8 @@ bool ethash_cl_miner::configureGPU(
201201 uint64_t _currentBlock
202202)
203203{
204- s_workgroupSize = _localWorkSize[ 0 ] ;
205- s_initialGlobalWorkSize = _globalWorkSize[ 0 ] ;
204+ s_workgroupSize = _localWorkSize;
205+ s_initialGlobalWorkSize = _globalWorkSize;
206206 s_allowCPU = _allowCPU;
207207 s_extraRequiredGPUMem = _extraGPUMemory;
208208
@@ -234,8 +234,10 @@ bool ethash_cl_miner::configureGPU(
234234
235235bool ethash_cl_miner::s_allowCPU = false ;
236236unsigned ethash_cl_miner::s_extraRequiredGPUMem;
237- unsigned ethash_cl_miner::s_workgroupSize = ethash_cl_miner::c_defaultLocalWorkSize;
238- unsigned ethash_cl_miner::s_initialGlobalWorkSize = ethash_cl_miner::c_defaultGlobalWorkSizeMultiplier * ethash_cl_miner::c_defaultLocalWorkSize;
237+ // unsigned ethash_cl_miner::s_workgroupSize = ethash_cl_miner::c_defaultLocalWorkSize;
238+ // unsigned ethash_cl_miner::s_initialGlobalWorkSize = ethash_cl_miner::c_defaultGlobalWorkSizeMultiplier * ethash_cl_miner::c_defaultLocalWorkSize;
239+ unsigned *ethash_cl_miner::s_workgroupSize = nullptr ;
240+ unsigned *ethash_cl_miner::s_initialGlobalWorkSize = nullptr ;
239241
240242bool ethash_cl_miner::searchForAllDevices (function<bool (cl::Device const &)> _callback)
241243{
@@ -335,6 +337,7 @@ bool ethash_cl_miner::init(
335337 void ** hostDAG
336338)
337339{
340+ m_device_id = _deviceId;
338341 // get all platforms
339342 try
340343 {
@@ -399,9 +402,9 @@ bool ethash_cl_miner::init(
399402 m_queue = cl::CommandQueue (m_context, device);
400403
401404 // make sure that global work size is evenly divisible by the local workgroup size
402- m_globalWorkSize = s_initialGlobalWorkSize;
403- if (m_globalWorkSize % s_workgroupSize != 0 )
404- m_globalWorkSize = ((m_globalWorkSize / s_workgroupSize) + 1 ) * s_workgroupSize;
405+ m_globalWorkSize = s_initialGlobalWorkSize[_deviceId] ;
406+ if (m_globalWorkSize % s_workgroupSize[_deviceId] != 0 )
407+ m_globalWorkSize = ((m_globalWorkSize / s_workgroupSize[_deviceId] ) + 1 ) * s_workgroupSize[_deviceId] ;
405408
406409 uint64_t dagSize = ethash_get_datasize (_light->block_number );
407410 uint32_t dagSize128 = (unsigned )(dagSize / ETHASH_MIX_BYTES );
@@ -411,7 +414,7 @@ bool ethash_cl_miner::init(
411414 // note: ETHASH_CL_MINER_KERNEL is simply ethash_cl_miner_kernel.cl compiled
412415 // into a byte array by bin2h.cmake. There is no need to load the file by hand in runtime
413416 string code (ETHASH_CL_MINER_KERNEL , ETHASH_CL_MINER_KERNEL + ETHASH_CL_MINER_KERNEL_SIZE );
414- addDefinition (code, " GROUP_SIZE" , s_workgroupSize);
417+ addDefinition (code, " GROUP_SIZE" , s_workgroupSize[_deviceId] );
415418 addDefinition (code, " DAG_SIZE" , dagSize128);
416419 addDefinition (code, " LIGHT_SIZE" , lightSize64);
417420 addDefinition (code, " ACCESSES" , ETHASH_ACCESSES );
@@ -495,7 +498,7 @@ bool ethash_cl_miner::init(
495498 for (uint32_t i = 0 ; i < fullRuns; i++)
496499 {
497500 m_dagKernel.setArg (0 , i * m_globalWorkSize);
498- m_queue.enqueueNDRangeKernel (m_dagKernel, cl::NullRange, m_globalWorkSize, s_workgroupSize);
501+ m_queue.enqueueNDRangeKernel (m_dagKernel, cl::NullRange, m_globalWorkSize, s_workgroupSize[_deviceId] );
499502 m_queue.finish ();
500503 printf (" Generate DAG device OPENCL#%d: %.0f%%\n " , _deviceId, 100 .0f * (float )i / (float )fullRuns);
501504 }
@@ -573,7 +576,7 @@ void ethash_cl_miner::search(uint8_t const* header, uint64_t target, search_hook
573576 m_searchKernel.setArg (3 , start_nonce);
574577
575578 // execute it!
576- m_queue.enqueueNDRangeKernel (m_searchKernel, cl::NullRange, m_globalWorkSize, s_workgroupSize);
579+ m_queue.enqueueNDRangeKernel (m_searchKernel, cl::NullRange, m_globalWorkSize, s_workgroupSize[m_device_id] );
577580
578581 pending.push ({ start_nonce, buf });
579582 buf = (buf + 1 ) % c_bufferCount;
0 commit comments