This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ping x 7: [PATCH] [libgomp] make it possible to use OMP on both sides of a fork


Hi all,

Got total silence the last 4 times I posted this, and users have been
bugging me about it offline, so trying again.

This patch fixes a showstopper problem preventing the transparent use
of OpenMP in scientific libraries, esp. with Python. Specifically, it
is currently not possible to use GNU OpenMP -- even in a limited,
temporary manner -- in any program that uses (or might use) fork() for
parallelism, even if the fork() and the use of OpenMP occur at totally
different times. This limitation is unique to GNU OpenMP -- every
competing OpenMP implementation already contains something like this
patch. While technically not fully POSIX-compliant (because POSIX
gives much much weaker guarantees around fork() than any real Unix),
the approach used in this patch (a) performs only POSIX-compliant
operations when the host program is itself fully POSIX-compliant, and
(b) actually works perfectly reliably in practice on all commonly used
platforms I'm aware of.

Tested on linux x86-64. I do not have write access to the SVN repo, so
looking for someone to do the commit.

Previous discussion/review:
  http://gcc.gnu.org/ml/gcc-patches/2014-02/msg00813.html
Bugzilla entry:
  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60035

2014-02-12  Nathaniel J. Smith  <njs@pobox.com>

    * team.c (gomp_free_pool_helper): Move per-thread cleanup to main
    thread.
    (gomp_free_thread): Delegate implementation to...
    (gomp_free_thread_pool): ...this new function. Like old
    gomp_free_thread, but does per-thread cleanup, and has option to
    skip everything that involves interacting with actual threads,
    which is useful when called after fork.
    (gomp_after_fork_callback): New function.
    (gomp_team_start): Register atfork handler, and check for fork on
    entry.
    * testsuite/libgomp.c/fork-1.c: New test.

Thanks,
-n

-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org

Attachment: gomp-safe-fork-patch.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]