Skip to content

Commit e5c2392

Browse files
[CI] Improved How The CI Handles Num Cores Used
Found that the CI was always building and running using only 2 cores on the regular tests. However, the CI has 4 cores that it can use. The number of cores can change based on some factors. Added the ability of the tests to check how many cores they have available, and use all the cores to build and run VTR tests.
1 parent 286105a commit e5c2392

File tree

3 files changed

+92
-17
lines changed

3 files changed

+92
-17
lines changed

.github/scripts/build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ source $(dirname "$0")/common.sh
66

77
$SPACER
88

9+
if [[ -z "${NUM_PROC}" ]]; then
10+
NUM_PROC=1
11+
fi
12+
913
start_section "vtr.build" "${GREEN}Building..${NC}"
1014
export FAILURE=0
11-
make -k BUILD_TYPE=${BUILD_TYPE} CMAKE_PARAMS="-Werror=dev ${CMAKE_PARAMS} ${CMAKE_INSTALL_PREFIX_PARAMS}" -j2 || export FAILURE=1
15+
make -k BUILD_TYPE=${BUILD_TYPE} CMAKE_PARAMS="-Werror=dev ${CMAKE_PARAMS} ${CMAKE_INSTALL_PREFIX_PARAMS}" -j${NUM_PROC} || export FAILURE=1
1216
end_section "vtr.build"
1317

1418
# When the build fails, produce the failure output in a clear way

.github/scripts/unittest.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ $(dirname "$0")/build.sh
99
$SPACER
1010

1111
start_section "vtr.test.0" "${GREEN}Testing..${NC} ${CYAN}C++ unit tests${NC}"
12-
make test
12+
make test -j${NUM_PROC}
1313
end_section "vtr.test.0"
1414

1515
$SPACER

.github/workflows/test.yml

Lines changed: 86 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,20 @@ jobs:
5252
- uses: actions/checkout@v4
5353
with:
5454
submodules: 'true'
55-
- run: ./.github/scripts/install_dependencies.sh
55+
56+
- name: Get number of CPU cores
57+
uses: SimenB/github-actions-cpu-cores@v2
58+
id: cpu-cores
59+
60+
- name: Install dependencies
61+
run: ./.github/scripts/install_dependencies.sh
5662

5763
- uses: hendrikmuhs/[email protected]
5864

5965
- name: Test
6066
env:
6167
BUILD_TYPE: ${{ matrix.build_type }}
68+
NUM_PROC: ${{ steps.cpu-cores.outputs.count }}
6269
run: |
6370
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
6471
./.github/scripts/build.sh VERBOSE=${{ matrix.verbose }}
@@ -80,7 +87,9 @@ jobs:
8087
with:
8188
python-version: 3.10.10
8289
- uses: actions/checkout@v4
83-
- run: ./.github/scripts/install_dependencies.sh
90+
91+
- name: Install dependencies
92+
run: ./.github/scripts/install_dependencies.sh
8493

8594
- name: Test
8695
run: ./dev/${{ matrix.script }}
@@ -97,11 +106,18 @@ jobs:
97106
- uses: actions/checkout@v4
98107
with:
99108
submodules: 'true'
100-
- run: ./.github/scripts/install_dependencies.sh
109+
110+
- name: Get number of CPU cores
111+
uses: SimenB/github-actions-cpu-cores@v2
112+
id: cpu-cores
113+
114+
- name: Install dependencies
115+
run: ./.github/scripts/install_dependencies.sh
101116

102117
- name: Test
103118
env:
104119
CMAKE_PARAMS: "-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on"
120+
NUM_PROC: ${{ steps.cpu-cores.outputs.count }}
105121
run: ./.github/scripts/unittest.sh
106122

107123

@@ -116,7 +132,13 @@ jobs:
116132
- uses: actions/checkout@v4
117133
with:
118134
submodules: 'true'
119-
- run: ./.github/scripts/install_dependencies.sh
135+
136+
- name: Get number of CPU cores
137+
uses: SimenB/github-actions-cpu-cores@v2
138+
id: cpu-cores
139+
140+
- name: Install dependencies
141+
run: ./.github/scripts/install_dependencies.sh
120142

121143
- uses: hendrikmuhs/[email protected]
122144

@@ -125,6 +147,7 @@ jobs:
125147
#In order to get compilation warnings produced per source file, we must do a non-IPO build
126148
#We also turn warnings into errors for this target by doing a strict compile
127149
CMAKE_PARAMS: "-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DVTR_ENABLE_STRICT_COMPILE=on -DVTR_IPO_BUILD=off"
150+
NUM_PROC: ${{ steps.cpu-cores.outputs.count }}
128151
run: |
129152
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
130153
./.github/scripts/build.sh
@@ -201,17 +224,24 @@ jobs:
201224
- uses: actions/checkout@v4
202225
with:
203226
submodules: 'true'
204-
- run: ./.github/scripts/install_dependencies.sh
227+
228+
- name: Get number of CPU cores
229+
uses: SimenB/github-actions-cpu-cores@v2
230+
id: cpu-cores
231+
232+
- name: Install dependencies
233+
run: ./.github/scripts/install_dependencies.sh
205234

206235
- uses: hendrikmuhs/[email protected]
207236

208237
- name: Test
209238
env:
210239
CMAKE_PARAMS: ${{ matrix.params }}
240+
NUM_PROC: ${{ steps.cpu-cores.outputs.count }}
211241
run: |
212242
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
213243
./.github/scripts/build.sh
214-
./run_reg_test.py ${{ matrix.suite }} -show_failures -j2
244+
./run_reg_test.py ${{ matrix.suite }} -show_failures -j${{ steps.cpu-cores.outputs.count}}
215245
216246
- name: Upload regression run files
217247
if: ${{ !cancelled() }}
@@ -259,7 +289,12 @@ jobs:
259289
with:
260290
submodules: 'true'
261291

262-
- run: ./.github/scripts/install_dependencies.sh
292+
- name: Get number of CPU cores
293+
uses: SimenB/github-actions-cpu-cores@v2
294+
id: cpu-cores
295+
296+
- name: Install dependencies
297+
run: ./.github/scripts/install_dependencies.sh
263298

264299
- uses: hendrikmuhs/[email protected]
265300

@@ -273,12 +308,13 @@ jobs:
273308
# depends on LLVM and all CI tests where VTR_ENABLE_SANITIZE is enabled fail. For a temporary
274309
# fix, we manually reduce the entropy. This quick fix should be removed in the future
275310
# when github deploys a more stable Ubuntu image.
311+
NUM_PROC: ${{ steps.cpu-cores.outputs.count }}
276312
run: |
277313
sudo sysctl -w vm.mmap_rnd_bits=28
278314
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
279315
./.github/scripts/build.sh
280316
# We skip QoR since we are only checking for errors in sanitizer runs
281-
./run_reg_test.py ${{ matrix.suite }} -show_failures -j2 -skip_qor
317+
./run_reg_test.py ${{ matrix.suite }} -show_failures -j${{ steps.cpu-cores.outputs.count }} -skip_qor
282318
283319
284320
Parmys:
@@ -292,18 +328,25 @@ jobs:
292328
- uses: actions/checkout@v4
293329
with:
294330
submodules: 'true'
295-
- run: ./.github/scripts/install_dependencies.sh
331+
332+
- name: Get number of CPU cores
333+
uses: SimenB/github-actions-cpu-cores@v2
334+
id: cpu-cores
335+
336+
- name: Install dependencies
337+
run: ./.github/scripts/install_dependencies.sh
296338

297339
- uses: hendrikmuhs/[email protected]
298340

299341
- name: Test
300342
env:
301343
CMAKE_PARAMS: '-DVTR_IPO_BUILD=off'
302344
BUILD_TYPE: debug
345+
NUM_PROC: ${{ steps.cpu-cores.outputs.count }}
303346
run: |
304347
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
305348
./.github/scripts/build.sh
306-
./run_reg_test.py parmys_reg_basic -show_failures -j2
349+
./run_reg_test.py parmys_reg_basic -show_failures -j${{ steps.cpu-cores.outputs.count }}
307350
308351
309352
ODINII:
@@ -317,19 +360,26 @@ jobs:
317360
- uses: actions/checkout@v4
318361
with:
319362
submodules: 'true'
320-
- run: ./.github/scripts/install_dependencies.sh
363+
364+
- name: Get number of CPU cores
365+
uses: SimenB/github-actions-cpu-cores@v2
366+
id: cpu-cores
367+
368+
- name: Install dependencies
369+
run: ./.github/scripts/install_dependencies.sh
321370

322371
- uses: hendrikmuhs/[email protected]
323372

324373
- name: Test
325374
env:
326375
CMAKE_PARAMS: '-DVTR_ASSERT_LEVEL=3 -DVTR_ENABLE_SANITIZE=on -DVTR_IPO_BUILD=off -DWITH_BLIFEXPLORER=on -DWITH_PARMYS=OFF -DWITH_ODIN=on'
327376
BUILD_TYPE: debug
377+
NUM_PROC: ${{ steps.cpu-cores.outputs.count }}
328378
run: |
329379
sudo sysctl -w vm.mmap_rnd_bits=28
330380
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
331381
./.github/scripts/build.sh
332-
./run_reg_test.py odin_reg_basic -show_failures -j2
382+
./run_reg_test.py odin_reg_basic -show_failures -j${{ steps.cpu-cores.outputs.count }}
333383
334384
335385
VQM2BLIF:
@@ -343,13 +393,20 @@ jobs:
343393
- uses: actions/checkout@v4
344394
with:
345395
submodules: 'true'
346-
- run: ./.github/scripts/install_dependencies.sh
396+
397+
- name: Get number of CPU cores
398+
uses: SimenB/github-actions-cpu-cores@v2
399+
id: cpu-cores
400+
401+
- name: Install dependencies
402+
run: ./.github/scripts/install_dependencies.sh
347403

348404
- uses: hendrikmuhs/[email protected]
349405

350406
- name: Test
351407
env:
352408
BUILD_TYPE: release
409+
NUM_PROC: ${{ steps.cpu-cores.outputs.count }}
353410
run: |
354411
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
355412
./.github/scripts/build.sh
@@ -378,7 +435,13 @@ jobs:
378435
- uses: actions/checkout@v4
379436
with:
380437
submodules: 'true'
381-
- run: ./.github/scripts/install_dependencies.sh
438+
439+
- name: Get number of CPU cores
440+
uses: SimenB/github-actions-cpu-cores@v2
441+
id: cpu-cores
442+
443+
- name: Install dependencies
444+
run: ./.github/scripts/install_dependencies.sh
382445

383446
- uses: hendrikmuhs/[email protected]
384447

@@ -387,6 +450,7 @@ jobs:
387450
CMAKE_PARAMS: "-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DWITH_ODIN=on"
388451
MATRIX_EVAL: ${{ matrix.eval }}
389452
BUILD_TYPE: release
453+
NUM_PROC: ${{ steps.cpu-cores.outputs.count }}
390454
run: |
391455
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
392456
./.github/scripts/build.sh
@@ -413,13 +477,20 @@ jobs:
413477
- uses: actions/checkout@v4
414478
with:
415479
submodules: 'true'
416-
- run: ./.github/scripts/install_dependencies.sh
480+
481+
- name: Get number of CPU cores
482+
uses: SimenB/github-actions-cpu-cores@v2
483+
id: cpu-cores
484+
485+
- name: Install dependencies
486+
run: ./.github/scripts/install_dependencies.sh
417487

418488
- uses: hendrikmuhs/[email protected]
419489

420490
- name: Test
421491
env:
422492
CMAKE_PARAMS: '-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on'
493+
NUM_PROC: ${{ steps.cpu-cores.outputs.count }}
423494
_COVERITY_URL: 'https://scan.coverity.com/download/linux64'
424495
_COVERITY_MD5: 'd0d7d7df9d6609e578f85096a755fb8f'
425496
run: |

0 commit comments

Comments
 (0)