Fix problem with mixed affinity mask on different nodes.

If task distribution (with slurm for instance) causes both fully
allocated and not-fully allocated nodes to be assigned to the job then
there may be tasks with a all-cores affinity mask and tasks with a
not-all-cores affinity masks.

Fixes #1613

Change-Id: I71c0daa43a5dd42da57bfd09037806ce1d9334b5