Added autoconfig for cn/gpu.

This commit is contained in:
XMRig 2019-09-08 16:28:51 +07:00
parent 859626cbe3
commit 29790da63d
10 changed files with 157 additions and 33 deletions

View file

@ -50,7 +50,7 @@ static inline uint32_t getPossibleIntensity(const OclDevice &device, const Algor
{
const uint32_t maxThreads = getMaxThreads(device, algorithm);
const size_t minFreeMem = (maxThreads == 40000u ? 512u : 128u) * oneMiB;
const size_t availableMem = device.freeMem() - minFreeMem;
const size_t availableMem = device.freeMemSize() - minFreeMem;
const size_t perThread = algorithm.l3() + 224u;
const auto maxIntensity = static_cast<uint32_t>(availableMem / perThread);
@ -104,9 +104,9 @@ bool ocl_generic_cn_generator(const OclDevice &device, const Algorithm &algorith
return false;
}
const uint32_t threadCount = ((device.globalMem() - intensity * 2 * algorithm.l3()) > 128 * oneMiB) ? 2 : 1;
const uint32_t threadCount = ((device.globalMemSize() - intensity * 2 * algorithm.l3()) > 128 * oneMiB) ? 2 : 1;
threads.add(OclThread(device.index(), intensity, 8, getStridedIndex(device, algorithm), 2, threadCount, 8, algorithm));
threads.add(OclThread(device.index(), intensity, 8, getStridedIndex(device, algorithm), 2, threadCount, 8));
return true;
}

View file

@ -0,0 +1,84 @@
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "backend/opencl/OclThreads.h"
#include "backend/opencl/wrappers/OclDevice.h"
#include "crypto/common/Algorithm.h"
namespace xmrig {
constexpr const size_t oneMiB = 1024u * 1024u;
bool ocl_generic_cn_gpu_generator(const OclDevice &device, const Algorithm &algorithm, OclThreads &threads)
{
if (algorithm != Algorithm::CN_GPU) {
return false;
}
uint32_t worksize = 8;
uint32_t numThreads = 1u;
size_t minFreeMem = 128u * oneMiB;
if (device.type() == OclDevice::Vega_10 || device.type() == OclDevice::Vega_20) {
minFreeMem = oneMiB;
worksize = 16;
}
else if (device.type() == OclDevice::Navi_10) {
numThreads = 2u;
}
else if (device.name() == "Fiji") {
worksize = 16;
}
size_t maxThreads = device.computeUnits() * 6 * 8;
const size_t maxAvailableFreeMem = device.freeMemSize() - minFreeMem;
const size_t memPerThread = std::min(device.maxMemAllocSize(), maxAvailableFreeMem);
size_t memPerHash = algorithm.l3() + 240u;
size_t maxIntensity = memPerThread / memPerHash;
size_t possibleIntensity = std::min(maxThreads, maxIntensity);
size_t intensity = 0;
size_t cuUtilization = ((possibleIntensity * 100) / (worksize * device.computeUnits())) % 100;
if (cuUtilization >= 75) {
intensity = (possibleIntensity / worksize) * worksize;
}
else {
intensity = (possibleIntensity / (worksize * device.computeUnits())) * device.computeUnits() * worksize;
}
threads.add(OclThread(device.index(), intensity, worksize, numThreads, 1));
return true;
}
} // namespace xmrig

View file

@ -61,7 +61,7 @@ static inline uint32_t getMaxThreads(const OclDevice &device, const Algorithm &a
static inline uint32_t getPossibleIntensity(const OclDevice &device, const Algorithm &algorithm)
{
const uint32_t maxThreads = getMaxThreads(device, algorithm);
const size_t availableMem = device.freeMem() - (128u * oneMiB);
const size_t availableMem = device.freeMemSize() - (128u * oneMiB);
const size_t perThread = algorithm.l3() + 224u;
const auto maxIntensity = static_cast<uint32_t>(availableMem / perThread);
@ -123,7 +123,7 @@ bool ocl_vega_cn_generator(const OclDevice &device, const Algorithm &algorithm,
const uint32_t worksize = getWorksize(algorithm);
const uint32_t memChunk = getMemChunk(algorithm);
threads.add(OclThread(device.index(), intensity, worksize, getStridedIndex(algorithm), memChunk, 2, 8, algorithm));
threads.add(OclThread(device.index(), intensity, worksize, getStridedIndex(algorithm), memChunk, 2, 8));
return true;
}