This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gomp] GOMP_CPU_AFFINITY support
On Thu, Apr 05, 2007 at 11:04:52PM +0200, Daniel Franke wrote:
> I played with it and while preparing the docs, some questions arose:
>
> a) is there any way to query the affinity settings from within the app?
You can getenv ("GOMP_CPU_AFFINITY"), or non-portably query affinity.
> b) is there any way to disable the affinity settings after startup?
> c) is there any way to disable this feature completely?
No+No.
> d) if GOMP_CPU_AFFINITY="0 1 4" is used on a 4 CPU machine, an error is
> printed. How do you handle it internally? Does the implementation discard the
> settings completely, or does it ignore the erroneous part only? From tests, I
> would assume the former?!
No error is printed for GOMP_CPU_AFFINITY="0 1 4", all it does is discard
non-existent CPUs (or CPUs disallowed by previous affinity setting, e.g.
through taskset(1)) from the list, so if you have CPUs 0-3,
GOMP_CPU_AFFINITY="0 1 4" is the same as GOMP_CPU_AFFINITY=0,1 , i.e.
threads are assigned to CPUs 0 (initial thread), 1, 0, 1, 0, 1 ...
A warning is only printed if no CPUs are left, say if
you try say GOMP_CPU_AFFINITY=4-7:2 and only have CPUs 0-3.
> e) will it be ported to 4.2 prior to release?
No. It can't be considered a bugfix.
> Questions (a)-(c) relate to inventative people who set GOMP_CPU_AFFINITY=0 (or
> similar) for their collegues and those wonder what happend to their nice and
> shiny parallelized application that only runs on a single CPU ...
How is that different from inventive people that start other people's shells with
taskset -c 0 /bin/sh?
Jakub