Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to Disable CPU Affinity Mask #11

Open
SigmaX opened this issue Nov 3, 2020 · 2 comments
Open

Option to Disable CPU Affinity Mask #11

SigmaX opened this issue Nov 3, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@SigmaX
Copy link
Contributor

SigmaX commented Nov 3, 2020

As per the docs here, by default CARLsim configures all neuron groups with a CPU affinity mask, such that they always execute on CPU 0 (at least on Linux).

In many applications, we wish to run multiple CARLsim instances on the same machine (ex. to achieve statistically significant runs, or to evaluate different subpopulations in an evolutionary algorithm). The affinity mask interferes with this by placing all CARLsim instances on CPU 0.

Manually specifying the CPU affinity for simulations is tedious, so it would be preferable to have the option to remove the mask (or even to leave it disabled by default).

I have confirmed that simply commenting out the call to pthread_attr_setaffinity_np() here in the SNN::doCurrentUpdate() method (which does most of the work in a CARLsim simulation) is sufficient---without that line, separate CARLsim instances are automatically spread across all the cores on my machine.

Before and after photos, running 12 CARLsim instances concurrently (the red line is CPU 0):

0de8a0b94c1dfb3f2177a38784f59fae
ba211827bf4a7ac99860b7969bfe254e

CPU 0 still does more than its share of work (probably because I only removed the affinity mask from one function---many others are still using it in this example).

I'd propose adding a runtime flag to disable this and all other calls to pthread_attr_setaffinity_np().

Note: This problems does not affect macOS, because macOS traditionally ignores pthreads affinity masks.

@SigmaX SigmaX added the enhancement New feature or request label Nov 3, 2020
@SigmaX
Copy link
Contributor Author

SigmaX commented Nov 3, 2020

Does this also affect mutlithreaded parallelism within a single CARLsim instance? If so, that's a good argument for disabling the affinity mask entirely by default.

@SigmaX
Copy link
Contributor Author

SigmaX commented Dec 13, 2020

Commenting out all 15 affinity masks in snn_manager.cpp gives me full utilization on all threads.

For my use case (multiple CARLsim instances being run on CPU by ECJ) it makes sense to remove all of these from the codebase. I'd like someone else's input, though, to ensure that this doesn't break multi-CPU simulations or something.

image

SigmaX added a commit that referenced this issue Dec 15, 2020
…tr_t. This allows multi-CPU support to automatically distribute across cores on Linux machines. Fixes #11.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant