Open SimeonEhrig opened 5 years ago
An earlier investigation of precompiled headers for alpaka: #383
Yes, but CMake's 3.16 support for PCH is very different from cotire, according to one CMake maintainers. Definitely worth trying again, especially since we already do unity builds anyway.
Sounds good to me. Unfortunately, I'm not really familiar with CMake. I presented the idea of PCH in a meeting a few weeks earlier and checked if an implementation with CMake 3.16 could be useful. But if you say it could work, it's fine with me :-)
I think we just need to add selected headers to our CMake target(s), as described here: https://cmake.org/cmake/help/v3.16/command/target_precompile_headers.html#command:target_precompile_headers
Since this will likely be the next step of the efforts in #919: Which headers would we want to precompile? All of them? A subset? User's choice (= precompile individual concepts)?
Since Alpaka is installable: Should there also be an option to install PCHs? As far as I understand they would be limited to a specific compiler. It might be more sensible to generate PCHs on the fly for the user's target.
I do not think that installing precompiled headers is useful.
We are not even sure that PCH will be useful for alpaka at all but we can only find out once we added support for it. I think we should be able to have all headers (so alpaka.hpp
) as PCH.
I think precompiled headers will become obsolete in C++20, because we can just import <alpaka>
.
I think precompiled headers will become obsolete in C++20, because we can just
import <alpaka>
.
That's correct, but I think it will take some time, until we can move to c++ modules. Therefore, I think it is still useful to test PCH.
Precompiled headers can reduce compilation time. It works like object files for cpp files. In special cases, templates should be accelerated because a compiled version of the generic template is stored in the precompiled header. Theoretically, it should reduce compilation time. Practically, I'm not sure, so someone has to test it.
CMake 3.16 supports PCH, so testing and integration should not be too difficult.
Implementation details: https://clang.llvm.org/docs/PCHInternals.html https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html https://docs.microsoft.com/en-us/cpp/build/creating-precompiled-header-files?view=vs-2019 https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-pch