Re: Add `--parallel` option to automatically use all CPU threads
Mats Wichmann <[email protected]>
| Newsgroups | gmane.comp.programming.tools.scons.user |
|---|---|
| Message-ID | <[email protected]> |
On April 6, 2022 5:04:06 PM MDT, Bill Deegan <[email protected]> wrote: >Greetings, > >There's no need to add an additional option for this. >If you can programmatically detect the # of cores (in python), you can do >this in your own code via SetOption('num_jobs', NUMBER HERE) and even >check if num_jobs is set to 1 which is the current default value and if so >then set it to the actual number of cores. > >What might work as a SCons default behavior change though, is to have -j's >default value be 0 and if 0, use some logic to set based on # of available >cores. > > >-Bill Yup, we have talked about this. -j0 already went into the test runner, fwiw. > >On Wed, Apr 6, 2022 at 3:29 PM Hugo Locurcio <[email protected]> wrote: > >> Hello, >> >> This is a feature request for SCons to add a `--parallel` option, which >> would be equivalent to `-j` with the number of logical CPU cores present >> on the system. CMake provides a similar option, which is convenient to >> avoid juggling with non-portable lines that rely on shell extensions >> (and therefore don't always play well with IDE configuration). >> >> We recently encountered this issue while adding a CLion + SCons guide to >> the Godot documentation: >> https://github.com/godotengine/godot-docs/pull/5743 >> Since CLion doesn't seem to expand command executions in its command >> lines, the current build commands given in the various Compiling pages >> don't work when used under CLion. >> >> Instead of using: >> >> scons -j$(nproc) # Linux >> >> scons -j%NUMBER_OF_PROCESSORS% # Windows (cmd) >> >> scons -j$env:NUMBER_OF_PROCESSORS # Windows (PowerShell) >> >> scons -j$(sysctl -n hw.logicalcpu) # macOS >> >> >> You could just use: >> >> scons --parallel # All platforms :) >> >> >> This new option would cover the 90% use case (that is, using all CPU >> threads to build a program) with an easy-to-remember command. This also >> happens to be the same switch as used by CMake. >> >> _______________________________________________ >> Scons-users mailing list >> [email protected] >> https://pairlist4.pair.net/mailman/listinfo/scons-users >> -- Sent from my Android device with K-9 Mail. Please excuse my brevity.