On Wed, May 06, 2015 at 04:29:02PM -0700, Adrian Chadd wrote: > This patch implements basic top level thread affinity support for > freebsd. It doesn't yet implement thread affinity support for > core/socket grouping yet; I'm working on a library to extract that out > to userland and plan on teaching libgomp about it at a later stage. > > https://people.freebsd.org/~adrian/gcc/20150506-gcc-trunk-libgomp-1.diff > > I'd appreciate feedback/review.
In affinity.c, that sounds like way too much code duplication, besides slightly different includes (but, seems it is only added ones, not removed), the only differences I see are: 1) you are assuming HAVE_PTHREAD_AFFINITY_NP is defined, is that really needed? The configure test should pass and define this macro if you have it 2) cpu_set_t vs. cpuset_t 3) assuming CPU_ALLOC_SIZE is not defined and so aren't CPU_*_S 4) gomp_cpuset_popcount vs. CPU_COUNT 5) gomp_affinity_init_level is different 1) and 3) can be IMHO kept as is, for 2)/4) you could just add a short config/freebsd/affinity.c wrapper that includes right headers, defines a few macros and finally #include "../linux/affinity.c" For 5), guess that function could be moved into some header (affinity-init.h) and you could have a different version in config/linux and config/freebsd. As you add your own proc.c, I guess for 4) also just defining your own gomp_cpuset_popcount in there would work too. Jakub