Skip to content

Commit 5b05b2a

Browse files
authored
limit n_compiler_processes (#1177)
1 parent e4cb5d6 commit 5b05b2a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pynestml/codegeneration/nest_builder.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,15 @@ def add_libraries_to_sli(paths: Union[str, Sequence[str]]):
7171

7272

7373
class NESTBuilder(Builder):
74-
r"""Compile, build and install the NEST C++ code and NEST extension module."""
74+
r"""Compile, build and install the NEST C++ code and NEST extension module.
75+
76+
Options:
77+
``max_n_compiler_processes``: limit the maximum number of processes used for compilation. Used for ``-j`` compiler parameter.
78+
"""
7579

7680
_default_options = {
77-
"nest_path": None
81+
"nest_path": None,
82+
"max_n_compiler_processes": 4
7883
}
7984

8085
def __init__(self, options: Optional[Mapping[str, Any]] = None):
@@ -130,9 +135,11 @@ def build(self) -> None:
130135
except AttributeError:
131136
n_cpu = os.cpu_count()
132137

138+
n_compiler_processes = min(n_cpu, self.get_option("max_n_compiler_processes"))
139+
133140
nest_config_path = f"-Dwith-nest={os.path.join(nest_path, 'bin', 'nest-config')}"
134141
cmake_cmd = ['cmake', nest_config_path, install_prefix, '.']
135-
make_all_cmd = ['make', f'-j{n_cpu}', 'all']
142+
make_all_cmd = ['make', f'-j{n_compiler_processes}', 'all']
136143
make_install_cmd = ['make', 'install']
137144

138145
# remove CMakeCache.txt if exists

0 commit comments

Comments
 (0)