Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable IPO by default on debug builds in CMake #219

Merged

Conversation

sleweke-bayer
Copy link
Contributor

Debug builds produce slow binaries. We do not gain anything by using IPO here. On the contrary, IPO increases build times considerably. So we disable IPO by default on debug builds to save some developer time.

Debug builds produce slow binaries. We do not gain anything by using IPO
here. On the contrary, IPO increases build times considerably. So we
disable IPO by default on debug builds to save some developer time.
@schmoelder
Copy link
Contributor

Hey everyone,

could someone please explain what IPO means? I guess it's not initial public offering, right? 🤑

@ronald-jaepel
Copy link
Collaborator

Googling "IPO c compilation" gives https://en.wikipedia.org/wiki/Interprocedural_optimization . Is that correct?

@sleweke-bayer
Copy link
Contributor Author

What @ronald-jaepel says: IPO = Interprocedural optimization (mostly link time optimization = LTO). Originally, every compilation unit (roughly a .cpp file) is compiled and optimized individually. The resulting object files are then linked together to form the final binary.
With IPO or LTO, the compilation pass is rather thin since only local optimizations are performed. Most of the heavy-lifting and optimization is postponed to link time, where information from all compilation units (say, .cpp files) is available. This enables optimizations across compilation units.
Therefore, IPO results in faster binaries but has high costs in compile time and memory usage during compile time.

@ronald-jaepel ronald-jaepel self-requested a review July 8, 2024 14:24
@ronald-jaepel
Copy link
Collaborator

ronald-jaepel commented Jul 9, 2024

When building this PR on Windows 11 with Visual Studio 17.8.5 and MSBuild I get the error:

C1128 number of sections exceeded object file format limit: compile with /bigobj ...\CADET\src\libcadet\model\GeneralRateModelDG.cpp

I therefore replaced

target_compile_options(CADET::CompileOptions INTERFACE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
		-Wall -pedantic-errors -Wextra -Wno-unused-parameter -Wno-unused-function> #-Wconversion -Wsign-conversion
	$<$<CXX_COMPILER_ID:MSVC>:
		/W4 /wd4100>
)

in the CMakeLists.txt

with a check if "Debug" and then an added /bigobj and no change if CMAKE_BUILD_TYPE is not "Debug":

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
	target_compile_options(CADET::CompileOptions INTERFACE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
		-Wall -pedantic-errors -Wextra -Wno-unused-parameter -Wno-unused-function> #-Wconversion -Wsign-conversion
	$<$<CXX_COMPILER_ID:MSVC>:
		/W4 /wd4100 /bigobj>
)
else()
	target_compile_options(CADET::CompileOptions INTERFACE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
		-Wall -pedantic-errors -Wextra -Wno-unused-parameter -Wno-unused-function> #-Wconversion -Wsign-conversion
	$<$<CXX_COMPILER_ID:MSVC>:
		/W4 /wd4100>
)
endif()

After that it builds. I rebased onto master and compared the two and with IPO it takes 2:39.6 (minutes:seconds.milliseconds) and without IPO it takes 2:39.1 . Is the difference larger on your machine Sam?

@ronald-jaepel ronald-jaepel removed their request for review July 9, 2024 13:01
@sleweke-bayer
Copy link
Contributor Author

It doesn't make a noticeable difference on my current machine. It makes a difference on my old one, though.

Copy link

github-actions bot commented Jul 10, 2024

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@sleweke-bayer
Copy link
Contributor Author

  • The CADET maintainers know my real name.

At least one of the following two applies:

  • The CADET maintainers know my current employer.

  • I am not making this contribution on behalf of my current employer.

@sleweke-bayer
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA.

@ronald-jaepel ronald-jaepel merged commit bc36a1a into cadet:master Jul 10, 2024
4 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants