pcg-c-basic icon indicating copy to clipboard operation
pcg-c-basic copied to clipboard

Can't inline

Open travisdowns opened this issue 7 years ago • 2 comments

Since PCG is oriented towards speed, I thought I'd mention that as far as performance goes, not being able to inline the core functions like pcg32_random_r has a significant impact on speed. I'm getting around this by simply doing #include "pcg-basic.c" - yes, including the implementation file!

A usual solution is to declare the key functions static inline in the header file, then you don't have to mess around with "out of line" versions.

The more fully featured C library is able to be inlined.

travisdowns avatar Mar 04 '19 03:03 travisdowns

Can't LTO solve this? -flto? Gold linker, etc.

lemire avatar Mar 04 '19 13:03 lemire

I don't think gold linker has anything to do with it (?), but yes LTO solves it.

LTO is still a bit like PGO - some people know about it, few people use it. If you are writing a high performance library you don't want to rely on people using it.

In a way LTO is harder to turn on than PGO even, because the old TU-at-a-time model hides certain types of bugs that are revealed when you enable LTO, because the compiler can now see that what you've been doing is UB after all, etc. On Mon, Mar 4, 2019, 10:10 AM Daniel Lemire [email protected] wrote:

Can't LTO solve this? -flto? Gold linker, etc.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/imneme/pcg-c-basic/issues/14#issuecomment-469247404, or mute the thread https://github.com/notifications/unsubscribe-auth/ACSswffZpNsyL45gj_hu3X3G5UMQkrH9ks5vTRs7gaJpZM4bbfKc .

travisdowns avatar Mar 04 '19 14:03 travisdowns