ChairImpSec / PROLEAD

PROLEAD - A Probing-Based Leakage Detection Tool for Hardware and Software
BSD 3-Clause "New" or "Revised" License
32 stars 28 forks source link

Introducing cpu core selector #11

Closed gmottajr closed 10 months ago

gmottajr commented 10 months ago

Introducing the CpuCoreSelector, a class designed to manage and optimize thread allocation, especially useful when running the same application on different systems with varying numbers of CPU cores . It provides a flexible way to determine the best number of threads to use based on the system's hardware and user-defined preferences.

Files

Public Static Method: getOptimalThreadCount

This method calculates the optimal number of threads based on the selected ThreadOption. It takes two parameters:

Parameters

Return Value

Returns the calculated optimal number of threads as an unsigned integer.

Behavior

All: Returns the total number of logical cores available on the system. Half/Third/Quarter: Calculates the respective fraction of the total number of cores. Specific: Returns the lesser of specificCount or the total number of cores, ensuring that the thread count does not exceed the number of available cores. Default Case: In an undefined scenario, it safely returns 1 as a fallback.

Usage Example

unsigned int threads = ThreadManager::getOptimalThreadCount(ThreadOption::Half);
// This will set 'threads' to half the number of cores available on the system.
nicolaimueller commented 10 months ago

Hey @gmottajr,

Thanks a ton for your efforts. Everything seems solid at first glance. I'll be merging your pull request shortly and getting the CpuCoreSelector integrated into PROLEAD.

Cheers, Nico

gmottajr commented 10 months ago

Hi Nico (@nicolaimueller),

That sounds like music to my ears! :musical_note: :musical_note: :headphones:

That was fun! :tada:

You are very welcome, man!

Thank you very much as well for your positive feedback and for considering the integration of the CpuCoreSelector into PROLEAD. I can\t be happier to hear that everything looks good to you. :joy:

I'm very appreciative about the opportunity to contribute to your project, looking forward to seeing the CpuCoreSelector become a valuable addition to PROLEAD.

I do love coding in C++ and eagerly looking forward to more opportunities to collaborate with you and the team in the future. :eyes:

Thank you once again, and I'm here to contribute and learn together. :smile:

Cheers,

Gerson Motta Junior.