alpaka-group / alpaka

Abstraction Library for Parallel Kernel Acceleration :llama:
https://alpaka.readthedocs.io
Mozilla Public License 2.0
354 stars 73 forks source link

Precompiled Header Support #858

Open SimeonEhrig opened 5 years ago

SimeonEhrig commented 5 years ago

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

sbastrakov commented 5 years ago

An earlier investigation of precompiled headers for alpaka: #383

ax3l commented 5 years ago

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.

SimeonEhrig commented 5 years ago

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 :-)

ax3l commented 5 years ago

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

j-stephan commented 4 years ago

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.

BenjaminW3 commented 4 years ago

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.

bernhardmgruber commented 2 years ago

I think precompiled headers will become obsolete in C++20, because we can just import <alpaka>.

SimeonEhrig commented 2 years ago

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.