stan-dev / cmdstan

CmdStan, the command line interface to Stan
https://mc-stan.org/users/interfaces/cmdstan
BSD 3-Clause "New" or "Revised" License
212 stars 93 forks source link

Parallelize gcc lto #1224

Open jsks opened 11 months ago

jsks commented 11 months ago

gcc allows passing the number of threads for parallelization to use at link time with LTO. Since gcc 10.x this can be set automatically with -flto=auto which will use either GNU Make's job server or fallback to detecting the number of available CPU threads (see the gcc documentation)

An additional ifeq check can be added to makefile around line 74. This will silence the lto-wrapper warning that currently pops up about serial compilation of LTRANS jobs when compiling with gcc and STAN_CPP_OPTIMS enabled and hopefully decrease the linking time.

bob-carpenter commented 11 months ago

Thanks, @jsks. I'm not an expert in make, but this looks like a good idea.