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

Update setup.py to build object files in parallel if requested #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import sys
import platform
import numpy
from multiprocessing.pool import ThreadPool


PLATFORM_TO_ARCH = {
Expand Down Expand Up @@ -218,6 +219,7 @@ def get_compiler_name(self):

def compile_objects(self, platform, py_arch, obj_dir):
objects = []
specs = []
platform_arch = platform + "-" + py_arch
compiler = self.get_compiler_name()
with open(os.path.join(BLIS_DIR, "make", "%s.jsonl" % platform_arch)) as file_:
Expand Down Expand Up @@ -257,7 +259,11 @@ def compile_objects(self, platform, py_arch, obj_dir):
for f in spec["flags"]
if "visibility=hidden" not in f
]
objects.append(self.build_object(env=env, **spec))
specs.append(spec)
jobs = int(os.getenv("MAX_JOBS", "1")) if self.parallel is None else self.parallel
pool = ThreadPool(jobs or None)
with pool:
objects = pool.map(lambda spec: self.build_object(env=env, **spec), specs)
return objects

def build_object(self, compiler, source, target, flags, macros, include, env=None):
Expand Down