Skip to content

Commit

Permalink
Try some more things
Browse files Browse the repository at this point in the history
  • Loading branch information
skottmckay committed Feb 24, 2024
1 parent dc95481 commit c006eec
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
5 changes: 5 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,11 @@ endif(MSVC_Z7_OVERRIDE)
# set default MSVC warning level to 3 for external dependencies
set_msvc_c_cpp_compiler_warning_level(3)

# configure build to be parallel.
if (MSVC)
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
endif()

# Fuzz test has only been tested with BUILD_SHARED_LIB option,
# using the MSVC compiler and on windows OS.
if (MSVC AND WIN32 AND onnxruntime_FUZZ_TEST AND onnxruntime_BUILD_SHARED_LIB AND onnxruntime_USE_FULL_PROTOBUF)
Expand Down
9 changes: 7 additions & 2 deletions tools/ci_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1662,11 +1662,16 @@ def build_targets(args, cmake_path, build_dir, configs, num_parallel_jobs, targe
build_tool_args = []
if num_parallel_jobs != 1:
if is_windows() and args.cmake_generator != "Ninja" and not args.build_wasm:
# https://devblogs.microsoft.com/cppblog/improved-parallelism-in-msbuild/
cmd_args += ["-DCMAKE_VS_GLOBALS=UseMultiToolTask=true;EnforceProcessCountAcrossBuilds=true"]

num_physical_cores = len(os.sched_getaffinity(0))
build_tool_args += [
f"/maxcpucount:{num_parallel_jobs}",
# https://github.com/Microsoft/checkedc-clang/wiki/Parallel-builds-of-clang-on-Windows
f"/p:CL_MPCount={max(num_physical_cores - 1, 1)}",
"/m",
# if nodeReuse is true, msbuild processes will stay around for a bit after the build completes
"/nodeReuse:False",
f"/p:CL_MPCount={num_parallel_jobs}",
]
elif args.cmake_generator == "Xcode":
build_tool_args += [
Expand Down
30 changes: 22 additions & 8 deletions tools/ci_build/github/azure-pipelines/templates/win-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,30 @@ stages:
arguments: '--config RelWithDebInfo --use_binskim_compliant_compile_flags --enable_lto --disable_rtti --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --update --cmake_generator "$(VSGenerator)" --enable_onnx_tests $(TelemetryOption) ${{ parameters.buildparameter }} '
workingDirectory: '$(Build.BinariesDirectory)'

# building with build.py so the parallelization parameters are added to the msbuild command
- task: PythonScript@0
- task: VSBuild@1
displayName: 'Build'
inputs:
scriptPath: '$(Build.SourcesDirectory)\tools\ci_build\build.py'
arguments: >
--config RelWithDebInfo
--build_dir $(Build.BinariesDirectory)
--parallel --build
workingDirectory: '$(Build.BinariesDirectory)'
solution: '$(Build.BinariesDirectory)\RelWithDebInfo\onnxruntime.sln'
platform: ${{ parameters.msbuildPlatform }}
configuration: RelWithDebInfo
msbuildArchitecture: ${{ parameters.buildArch }}
maximumCpuCount: true
logProjectEvents: true
workingFolder: '$(Build.BinariesDirectory)\RelWithDebInfo'
createLogFile: true
msbuildArgs: "/p:CL_MPCount=2" # not too many here as there are multiple levels of parallelism. TODO: maybe set based on num physical cores

# building with build.py so the parallelization parameters are added to the msbuild command.
# Could try this out of interest to see what CL_MPCount gets set to in a build machine
# - task: PythonScript@0
# displayName: 'Build'
# inputs:
# scriptPath: '$(Build.SourcesDirectory)\tools\ci_build\build.py'
# arguments: >
# --config RelWithDebInfo
# --build_dir $(Build.BinariesDirectory)
# --parallel --build
# workingDirectory: '$(Build.BinariesDirectory)'

- task: PythonScript@0
displayName: 'test'
Expand Down

0 comments on commit c006eec

Please sign in to comment.