Issue 179 compilation speedup PIMPL#331
Conversation
better comments unsaved comments
|
@mstimberg Hi Marcel,I am wondering If Thrust is indeed the main bottleneck—and given that we only use a limited set of its features (mainly host/device vectors and copy_if)—would it make sense to replace these with lightweight custom implementations? That way, we could avoid adding extra architectural complexity and significantly reduce compilation overhead. What do you think? |
Maybe! Currently, our |
905218e to
4af01d3
Compare
Also wire host dynamic arrays to host_array_* / _num_host_array_* (with shadowing-safe aliases) instead of raw_pointer_cast / .size().
4af01d3 to
369fd48
Compare
Rename leftover objects_thrust.h includes to objects_storage.h, and drop the duplicate _run_random_number_buffer declaration from objects_api.
This PR introduces PIMPL as we talked in meetings, reducing the cost of parsing heavy header files like Thrust during compilation of various codeobjects. Specifically:
objects_storage.hholds the actual Thrust container. The leanobjects.hexposes raw pointers (such asdev_array_*/host_array_*). And the newly generatedobjects_api.hinsidedevice.pyprovides resize/clear/copy, eventspace extensions, and wrappers for some algorithms and cuRAND-related code previously scattered across other TUs. Most.cufiles access data via raw pointers and the API, concentrating Thrust usage primarily inobjects.cu.Pointers:
sync_all_dev_ptrs()is called once at the end of_init_arrays()for a full refresh. If the container is modified via the API (such asresize_*), only the relevant pointers are synchronized. Therefore, as long as mutates use the API, the global PIMPL pointer can remain consistent with the container. The trade-off is the generation of a large number of API symbols in arrays(which is quite ugly right now). A more general template could be considered later to reduce the amount of generated code. And also I haven't apply PIMPL also for host vector, which will be add soon in following commits.Outcome
On MushroomBody (N=1000), cold compilation with
make -j1is reduced to approximately ~100s (compared to approximately ~200s on master under the same environment RTX3080Ti 12GB).