New formula to selected the number of instances based on CPU count.

This commit is contained in:
LoRd_MuldeR 2011-11-26 02:47:48 +01:00
parent 2243c77f4b
commit 284e796e72
2 changed files with 14 additions and 6 deletions

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 4
#define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 3
#define VER_LAMEXP_BUILD 787
#define VER_LAMEXP_BUILD 789
///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!)

View File

@ -63,12 +63,19 @@
#include <QProgressDialog>
#include <MMSystem.h>
#include <math.h>
////////////////////////////////////////////////////////////
//Maximum number of parallel instances
#define MAX_INSTANCES 16U
//Helper function
static inline double log5(double X)
{
return log(X) / log(5.0);
}
////////////////////////////////////////////////////////////
#define CHANGE_BACKGROUND_COLOR(WIDGET, COLOR) \
@ -361,16 +368,17 @@ void ProcessingDialog::initEncoding(void)
if(maximumInstances < 1)
{
lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features();
maximumInstances = (cpuFeatures.count > 4) ? ((cpuFeatures.count / 2) + 2) : cpuFeatures.count;
double cpu_count = static_cast<double>(qBound(1, cpuFeatures.count, 64));
maximumInstances = qRound(cpu_count / qMax(log5(cpu_count), 1.0));
}
unsigned int parallelThreadCount = qBound(1U, maximumInstances, static_cast<unsigned int>(m_pendingJobs.count()));
if(parallelThreadCount > 1)
maximumInstances = qBound(1U, maximumInstances, static_cast<unsigned int>(m_pendingJobs.count()));
if(maximumInstances > 1)
{
m_progressModel->addSystemMessage(tr("Multi-threading enabled: Running %1 instances in parallel!").arg(QString::number(parallelThreadCount)));
m_progressModel->addSystemMessage(tr("Multi-threading enabled: Running %1 instances in parallel!").arg(QString::number(maximumInstances)));
}
for(unsigned int i = 0; i < parallelThreadCount; i++)
for(unsigned int i = 0; i < maximumInstances; i++)
{
startNextJob();
}