News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

custom makefile support mutliple cpus

Started by mattn2, October 14, 2012, 08:57:06 PM

Previous topic - Next topic

mattn2

Hi,

we are looking for a way to get the amount of cpus in a codeblocks variable that can be used in the custom makefile parameters

something like:

$make -r -R -j $cpus -f $makefile $target

is something like this available?

thanks a lot
martin

dmoore

Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

Jenna

Quote from: mattn2 on October 14, 2012, 08:57:06 PM
Hi,

we are looking for a way to get the amount of cpus in a codeblocks variable that can be used in the custom makefile parameters

something like:

$make -r -R -j $cpus -f $makefile $target

is something like this available?

thanks a lot
martin

On linux you should be able to use something like (note the backticks):
Quote$make -r -R -j `getconf _NPROCESSORS_ONLN` -f $makefile $target

dmoore

Isn't it a bit odd that a compiler that supports multiple CPUs doesn't have a switch to detect the number of CPUs?
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

mattn2

it's not the compiler, but make

on windows i could also use the env var %NUMBER_OF_PROCESSORS% - but i'm looking for a portable way to handle this.

Jenna

You could try something like:
Quote$make -r -R -j $if(PLATFORM == PLATFORM_MSW){%NUMBER_OF_PROCESSORS%}{`getconf _NPROCESSORS_ONLN`} -f $makefile $target
the linux part should work, but I'm not sure about the windows part, you might need someting similar to linux' "echo".

mattn2

thanks - but there is also mac - which does this again a little bit different. and c::b must already know the amount of cpus, no?

Jenna

wxWidgets has a static function to determine the umber of cpu's, but I don't know how good it works.
But it could surely be used to add a cpu_count macro, that can be used wherever macro-/variable-expansion is done.

oBFusCATed

Quote from: jens on October 25, 2012, 10:29:42 PM
wxWidgets has a static function to determine the umber of cpu's, but I don't know how good it works.
But it could surely be used to add a cpu_count macro, that can be used wherever macro-/variable-expansion is done.
We have also a setting for the number of cpus used for building, this could be provided here.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Jenna

Quote from: oBFusCATed on October 25, 2012, 10:34:10 PM
Quote from: jens on October 25, 2012, 10:29:42 PM
wxWidgets has a static function to determine the umber of cpu's, but I don't know how good it works.
But it could surely be used to add a cpu_count macro, that can be used wherever macro-/variable-expansion is done.
We have also a setting for the number of cpus used for building, this could be provided here.
Both could be provided:
the number of CPU's determined by wxw and the number of parallel processes for building set by the user in the compiler options dialog.

MortenMacFly

Quote from: jens on October 25, 2012, 10:29:42 PM
wxWidgets has a static function to determine the umber of cpu's, but I don't know how good it works.
It works pretty well - I am using it in another of my projects (You meant the static wxThread based method, right?)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Jenna

Quote from: MortenMacFly on October 26, 2012, 06:17:54 AM
Quote from: jens on October 25, 2012, 10:29:42 PM
wxWidgets has a static function to determine the umber of cpu's, but I don't know how good it works.
It works pretty well - I am using it in another of my projects (You meant the static wxThread based method, right?)
Yes

MortenMacFly

Quote from: jens on October 26, 2012, 09:36:22 AM
Yes
Reminds me: Recently had the chance to work on a 16 core "enterprise PC". What a mind-blowing fast compilation of everything you do there with C::B, having setup 16 parallel build processes. Also, the wxThread methods worked fine there, too. Now all I need is somebody giving me enough money because I want to have such a beast, too. :-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Jenna

Quote from: MortenMacFly on October 27, 2012, 06:16:39 PM
Quote from: jens on October 26, 2012, 09:36:22 AM
Yes
Reminds me: Recently had the chance to work on a 16 core "enterprise PC". What a mind-blowing fast compilation of everything you do there with C::B, having setup 16 parallel build processes. Also, the wxThread methods worked fine there, too. Now all I need is somebody giving me enough money because I want to have such a beast, too. :-)
That's more or least what I need too, with at least 32 GB of Ram.

An alternative would be a quadcore laptop with 32 GB installable Ram.

oBFusCATed

Moar cores, moar...

Jen: why would you need so much ram? ;D
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]