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

Add configuration for setting the degree of compilation parallelism. #51

Open
yaoyuannnn opened this issue Dec 17, 2020 · 2 comments
Open

Comments

@yaoyuannnn
Copy link

Maybe the first question is how many cppimport will use by default. Since I'm running it on a machine with a small memory, sometimes I can see the compilation goes out of memory.

@tbenthompson
Copy link
Owner

tbenthompson commented Dec 18, 2020

Currently, parallelism is off by default. If you turn parallelism on, the number of cores is equal to multiprocessing.cpu_count().

This would be quite easy to modify. I have two proposals for how we could do this:

  • Change the parallelism flag to instead take a parameter indicating the number of threads to use. Ideally, this would be done in a way that maintains backward compatibility with the current True/False behavior. So, perhaps, True == multiprocessing.cpu_count, False = 1, and then any integer uses that number of threads.
  • A slightly different, but similar proposal would be to just add another configuration field that contains the number of threads to use.

Some locations in the code that would be useful for this:

parallel = False,

def parallel_compile(self, sources, output_dir = None, macros = None,

parallelize = cfg.get('parallel') and py33orgreater

I would be excited to accept a pull request if you have the time to implement this!

@tbenthompson tbenthompson reopened this Jan 7, 2021
@tbenthompson tbenthompson changed the title Is there any option to limit the threads cppimport uses for compilation Add configuration for setting the degree of compilation parallelism. Jan 7, 2021
@tbenthompson
Copy link
Owner

Reopened because this is something I want to do eventually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants