Much simplify cores2instances() function by using a LUT.
This commit is contained in:
parent
d81f65e7e7
commit
431bf4b9ff
@ -30,7 +30,7 @@
|
||||
#define VER_LAMEXP_MINOR_LO 4
|
||||
#define VER_LAMEXP_TYPE Alpha
|
||||
#define VER_LAMEXP_PATCH 3
|
||||
#define VER_LAMEXP_BUILD 790
|
||||
#define VER_LAMEXP_BUILD 791
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Tool versions (minimum expected versions!)
|
||||
|
@ -64,6 +64,7 @@
|
||||
|
||||
#include <MMSystem.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
@ -987,39 +988,27 @@ bool ProcessingDialog::shutdownComputer(void)
|
||||
static int cores2instances(int cores)
|
||||
{
|
||||
//This function was approximated as a "cubic spline" with sampling points at:
|
||||
//(1,1);(2,2);(4,4);(8,6);(16,8);(32,10);(64,12)
|
||||
|
||||
double x = static_cast<double>(cores), y = 1.0;
|
||||
|
||||
if(x >= 1.0)
|
||||
//(1,1); (2,2); (4,4); (8,6); (16,8); (32,10); (64,12)
|
||||
static const double LUT[8][5] =
|
||||
{
|
||||
if(x < 2.0)
|
||||
{ 1.0, 0.01440972, -0.04322917, 1.02881944, 0.00000000},
|
||||
{ 2.0, -0.02881944, 0.21614583, 0.51006944, 0.34583333},
|
||||
{ 4.0, 0.01017795, -0.25182292, 2.38194444, -2.15000000},
|
||||
{ 8.0, 0.00005425, -0.00885417, 0.43819444, 3.03333333},
|
||||
{16.0, 0.00011122, -0.01158854, 0.48194444, 2.80000000},
|
||||
{32.0, 0.00000949, -0.00182292, 0.16944444, 6.13333333},
|
||||
{64.0, 0.00000000, 0.00000000, 0.00000000, 12.00000000},
|
||||
{DBL_MAX}
|
||||
};
|
||||
|
||||
double x = abs(static_cast<double>(cores)), y = 1.0;
|
||||
|
||||
for(size_t i = 0; i < 7; i++)
|
||||
{
|
||||
if((x >= LUT[i][0]) && (x < LUT[i+1][0]))
|
||||
{
|
||||
y = ((83.0/5760.0) * pow(x,3.0)) - ((83.0/1920.0) * pow(x,2.0)) + ((2963.0/2880.0) * x);
|
||||
}
|
||||
else if((x >= 2.0) && (x < 4.0))
|
||||
{
|
||||
y = - ((83.0/2880.0) * pow(x,3.0)) + ((83.0/384.0) * pow(x,2.0)) + ((1469.0/2880.0) * x) + (83.0/240.0);
|
||||
}
|
||||
else if((x >= 4.0) && (x < 8.0))
|
||||
{
|
||||
y = ((469.0/46080.0) * pow(x,3.0)) - ((967.0/3840.0) * pow(x,2.0)) + ((343.0/144.0) * x) - (43.0/20.0);
|
||||
}
|
||||
else if((x >= 8.0) && (x < 16.0))
|
||||
{
|
||||
y = ((1.0/18432.0) * pow(x,3.0)) - ((17.0/1920.0) * pow(x,2.0)) + ((631.0/1440.0) * x) + (91.0/30.0);
|
||||
}
|
||||
else if((x >= 16.0) && (x < 32.0))
|
||||
{
|
||||
y = ((41.0/368640.0) * pow(x,3.0)) - ((89.0/7680.0) * pow(x,2.0)) + ((347.0/720.0) * x) + (14.0/5.0);
|
||||
}
|
||||
else if((x >= 32.0) && (x < 64.0))
|
||||
{
|
||||
y = ((7.0/737280.0) * pow(x,3.0)) - ((7.0/3840.0) * pow(x,2.0)) + ((61.0/360.0) * x) + (92.0/15.0);
|
||||
}
|
||||
else //if(x >= 64.0)
|
||||
{
|
||||
y = 12.0;
|
||||
y = (LUT[i][1] * pow(x, 3.0)) + (LUT[i][2] * pow(x, 2.0)) + (LUT[i][3] * x) + LUT[i][4];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <tchar.h>
|
||||
|
||||
//Windows includes
|
||||
#define NOMINMAX
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user