Skip to content

Commit 636b95d

Browse files
author
Vasileios Karakasis
authored
Merge pull request #810 from teojgo/feat/limit_concerrency_make
[feat] Limit concurrent build jobs to `1` by default in build systems
2 parents f3bc335 + 6141ebe commit 636b95d

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

docs/advanced.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ReFrame will invoke ``make`` as follows:
5252

5353
.. code::
5454
55-
make -j CC='cc' CXX='CC' FC='ftn' NVCC='nvcc' CPPFLAGS='-DMESSAGE'
55+
make -j 1 CC='cc' CXX='CC' FC='ftn' NVCC='nvcc' CPPFLAGS='-DMESSAGE'
5656
5757
The compiler variables (``CC``, ``CXX`` etc.) are set based on the corresponding values specified in the `coniguration of the current environment <configure.html#environments-configuration>`__.
5858
You may instruct the build system to ignore the default values from the environment by setting the following:
@@ -65,15 +65,17 @@ In this case, ``make`` will be invoked as follows:
6565

6666
.. code::
6767
68-
make -j CPPFLAGS='-DMESSAGE'
68+
make -j 1 CPPFLAGS='-DMESSAGE'
6969
70-
Notice that the ``-j`` option is always generated.
71-
If you want to limit build concurrency, you can do it as follows:
70+
Notice that the ``-j 1`` option is always generated.
71+
You may change the maximum build concurrency as follows:
7272

7373
.. code-block:: python
7474
7575
self.build_system.max_concurrency = 4
7676
77+
By setting :attr:`max_concurrency <reframe.core.buildsystems.Make.max_concurrency>` to :class:`None`, no limit for concurrent parallel jobs will be placed.
78+
This means that ``make -j`` will be used for building.
7779

7880
Finally, you may also customize the name of the ``Makefile``.
7981
You can achieve that by setting the corresponding variable of the :class:`Make <reframe.core.buildsystems.Make>` build system:
@@ -140,7 +142,7 @@ The generated build script then will have the following lines:
140142
.. code-block:: bash
141143
142144
./custom_configure -with-mylib
143-
make -j CPPFLAGS='-DHAVE_FOO'
145+
make -j 1 CPPFLAGS='-DHAVE_FOO'
144146
145147
146148
Implementing a Run-Only Regression Test

reframe/core/buildsystems.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,19 @@ class Make(BuildSystem):
214214
#: Otherwise, it will invoked as ``make -j``.
215215
#:
216216
#: :type: integer
217-
#: :default: :class:`None`
217+
#: :default: ``1``
218+
#:
219+
#: .. note::
220+
#: .. versionchanged:: 2.19
221+
#: The default value is now ``1``
218222
max_concurrency = fields.TypedField('max_concurrency', int, type(None))
219223

220224
def __init__(self):
221225
super().__init__()
222226
self.options = []
223227
self.makefile = None
224228
self.srcdir = None
225-
self.max_concurrency = None
229+
self.max_concurrency = 1
226230

227231
def emit_build_commands(self, environ):
228232
cmd_parts = ['make']
@@ -467,7 +471,7 @@ class ConfigureBasedBuildSystem(BuildSystem):
467471
#: Same as for the :attr:`Make` build system.
468472
#:
469473
#: :type: integer
470-
#: :default: :class:`None`
474+
#: :default: ``1``
471475
max_concurrency = fields.TypedField('max_concurrency', int, type(None))
472476

473477
def __init__(self):
@@ -476,7 +480,7 @@ def __init__(self):
476480
self.builddir = None
477481
self.config_opts = []
478482
self.make_opts = []
479-
self.max_concurrency = None
483+
self.max_concurrency = 1
480484

481485

482486
class CMake(ConfigureBasedBuildSystem):

unittests/test_buildsystems.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_emit_from_buildsystem(self):
7070

7171
def test_emit_no_env_defaults(self):
7272
self.build_system.flags_from_environ = False
73-
self.assertEqual(['make -j'],
73+
self.assertEqual(['make -j 1'],
7474
self.build_system.emit_build_commands(self.environ))
7575

7676

@@ -124,7 +124,7 @@ def test_emit_from_buildsystem(self):
124124

125125
def test_emit_no_env_defaults(self):
126126
self.build_system.flags_from_environ = False
127-
self.assertEqual(['cmake .', 'make -j'],
127+
self.assertEqual(['cmake .', 'make -j 1'],
128128
self.build_system.emit_build_commands(self.environ))
129129

130130

@@ -173,7 +173,7 @@ def test_emit_from_buildsystem(self):
173173

174174
def test_emit_no_env_defaults(self):
175175
self.build_system.flags_from_environ = False
176-
self.assertEqual(['./configure', 'make -j'],
176+
self.assertEqual(['./configure', 'make -j 1'],
177177
self.build_system.emit_build_commands(self.environ))
178178

179179

0 commit comments

Comments
 (0)