Ejemplo n.º 1
0
LinearPass::LinearPass(duint VirtualStart, duint VirtualEnd, BBlockArray & MainBlocks)
    : AnalysisPass(VirtualStart, VirtualEnd, MainBlocks)
{
    // This is a fix for when the total data analysis size is less
    // than what parallelization can support. The minimum size requirement
    // is ((# THREADS) * (512)) bytes. If the requirement isn't met,
    // scale to use a single thread.
    if((512 * IdealThreadCount()) >= m_DataSize)
        SetIdealThreadCount(1);
}
Ejemplo n.º 2
0
uint AnalysisPass::IdealThreadCount()
{
    if(m_InternalMaxThreads == 0)
    {
        // Determine the maximum hardware thread count at once
        uint maximumThreads = max(std::thread::hardware_concurrency(), 1);

        // Don't consume 100% of the CPU, adjust accordingly
        if(maximumThreads > 1)
            maximumThreads -= 1;

        SetIdealThreadCount(maximumThreads);
    }

    return m_InternalMaxThreads;
}