Skip to content

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

Open

Description

@yaoyuannnn

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.

Activity

  1. tbenthompson commented on Dec 18, 2020

    @tbenthompson
    Owner

    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!

  2. changed the title [-]Is there any option to limit the threads cppimport uses for compilation[/-] [+]Add configuration for setting the degree of compilation parallelism.[/+] on Jan 7, 2021
  3. tbenthompson commented on Jan 7, 2021

    @tbenthompson
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions