Reliably detect number of make build threads to use

Issue #45 resolved
Jack Hale created an issue

At the moment all calls to make are effectively with -j1. Setting make up to use more threads is easy: `export MAKEFLAGS="-j4"'.

However, detecting the number of logical hardware threads available to pass to make doesn't seem so easy. This is because when the container is in a virtualised environment, e.g. Virtualbox, where x cores are assigned from a CPU with y cores, the number of reported cores is still y. Even hwloc reports y.

Comments (6)

  1. Prof Garth Wells

    grep -c '^processor' /proc/cpuinfo does the trick for me (tested natively, from inside VirtualBox and with Docker on OSX).

  2. Jack Hale reporter

    Sounds good.

    Where is the best place to put this? I suggest inside the user fenics .bash_profile so that we don't ramp up build threads on bamboo or the cloud building service, where everything is always run as pseudo-root

  3. Jack Hale reporter

    Ah, I re-read my initial report... If you have 1 CPU assigned in VirtualBox, how many do you get reported in your command? I get 4, regardless of assigned resources.

  4. Jack Hale reporter

    Completely changed my mind on this. Best and safest option is to pass --env rather than trying autodetect...

    @logg: Know you asked for this, update to latest version of fenicsproject script and adjust the DEFAULT_MAKEFLAGS variable near top or uncomment the magic line below to autodetect.

    Fixed commit b4af0005

  5. Log in to comment