Skip to content

Commit ef1990e

Browse files
committed
build(cmake): configure multi-threaded compilation with /MP and parallel jobs
- Add "jobs": 6 to CMakePresets.json for concurrent target builds - Enable MSVC /MP flag to parallelize object file compilation
1 parent 61b4e87 commit ef1990e

2 files changed

Lines changed: 27 additions & 15 deletions

File tree

cpp/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ if (FORCE_AVX2)
4141
if(MSVC)
4242
check_cxx_compiler_flag("/arch:AVX2" COMPILER_SUPPORTS_AVX2)
4343
if(COMPILER_SUPPORTS_AVX2)
44-
target_compile_options(compile-options INTERFACE /O2 /arch:AVX2 /W1 /EHsc /fp:precise)
44+
target_compile_options(compile-options INTERFACE /O2 /arch:AVX2 /W1 /EHsc /fp:precise /MP)
4545
else()
46-
target_compile_options(compile-options INTERFACE /O2 /W1 /EHsc /fp:precise)
46+
target_compile_options(compile-options INTERFACE /O2 /W1 /EHsc /fp:precise /MP)
4747
endif()
4848
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
4949
check_cxx_compiler_flag("-mavx2" COMPILER_SUPPORTS_AVX2)
@@ -79,7 +79,7 @@ else() # Native build
7979
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
8080
target_compile_options(compile-options INTERFACE -O2 -DNDEBUG -march=native -fpic)
8181
elseif(MSVC)
82-
target_compile_options(compile-options INTERFACE /W4 /EHsc /fp:precise $<$<CONFIG:Release>:/O2>)
82+
target_compile_options(compile-options INTERFACE /W4 /EHsc /fp:precise /MP $<$<CONFIG:Release>:/O2>)
8383
if(SUPPORT_AVX512F)
8484
target_compile_options(compile-options INTERFACE /arch:AVX512)
8585
elseif(SUPPORT_AVX2)

cpp/CMakePresets.json

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,73 +89,85 @@
8989
"name": "windows-msvc-debug",
9090
"displayName": "Windows Debug",
9191
"configurePreset": "windows-msvc",
92-
"configuration": "Debug"
92+
"configuration": "Debug",
93+
"jobs": 6
9394
},
9495
{
9596
"name": "windows-msvc-release",
9697
"displayName": "Windows Release",
9798
"configurePreset": "windows-msvc",
98-
"configuration": "Release"
99+
"configuration": "Release",
100+
"jobs": 6
99101
},
100102
{
101103
"name": "windows-msvc-avx2-debug",
102104
"displayName": "Windows AVX2 Debug",
103105
"configurePreset": "windows-msvc-avx2",
104-
"configuration": "Debug"
106+
"configuration": "Debug",
107+
"jobs": 6
105108
},
106109
{
107110
"name": "windows-msvc-avx2-release",
108111
"displayName": "Windows AVX2 Release",
109112
"configurePreset": "windows-msvc-avx2",
110-
"configuration": "Release"
113+
"configuration": "Release",
114+
"jobs": 6
111115
},
112116
{
113117
"name": "linux-gcc-debug",
114118
"displayName": "Linux Debug",
115119
"configurePreset": "linux-gcc",
116-
"configuration": "Debug"
120+
"configuration": "Debug",
121+
"jobs": 6
117122
},
118123
{
119124
"name": "linux-gcc-release",
120125
"displayName": "Linux Release",
121126
"configurePreset": "linux-gcc",
122-
"configuration": "Release"
127+
"configuration": "Release",
128+
"jobs": 6
123129
},
124130
{
125131
"name": "linux-gcc-avx2-debug",
126132
"displayName": "Linux AVX2 Debug",
127133
"configurePreset": "linux-gcc-avx2",
128-
"configuration": "Debug"
134+
"configuration": "Debug",
135+
"jobs": 6
129136
},
130137
{
131138
"name": "linux-gcc-avx2-release",
132139
"displayName": "Linux AVX2 Release",
133140
"configurePreset": "linux-gcc-avx2",
134-
"configuration": "Release"
141+
"configuration": "Release",
142+
"jobs": 6
135143
},
136144
{
137145
"name": "macos-clang-debug",
138146
"displayName": "macOS Debug",
139147
"configurePreset": "macos-clang",
140-
"configuration": "Debug"
148+
"configuration": "Debug",
149+
"jobs": 6
141150
},
142151
{
143152
"name": "macos-clang-release",
144153
"displayName": "macOS Release",
145154
"configurePreset": "macos-clang",
146-
"configuration": "Release"
155+
"configuration": "Release",
156+
"jobs": 6
147157
},
148158
{
149159
"name": "macos-clang-avx2-debug",
150160
"displayName": "macOS AVX2 Debug",
151161
"configurePreset": "macos-clang-avx2",
152-
"configuration": "Debug"
162+
"configuration": "Debug",
163+
"jobs": 6
153164
},
154165
{
155166
"name": "macos-clang-avx2-release",
156167
"displayName": "macOS AVX2 Release",
157168
"configurePreset": "macos-clang-avx2",
158-
"configuration": "Release"
169+
"configuration": "Release",
170+
"jobs": 6
159171
}
160172
],
161173
"testPresets": [

0 commit comments

Comments
 (0)