Skip to content

Commit

Permalink
Start on a check for the OpenMP issue, but need to learn what the err…
Browse files Browse the repository at this point in the history
…or message looks like and can't reproduce locally, so pushing this to find out from the GHA wheel
  • Loading branch information
jobovy committed Jul 4, 2024
1 parent c808134 commit 3ab630a
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion galpy/util/_load_extension_libs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# _load_extension_libs.py: centralized place to load the C extensions
import ctypes
import subprocess
import sys
import sysconfig
import warnings
Expand All @@ -19,8 +20,38 @@
_libgalpy_actionAngleTorus = None
_libgalpy_actionAngleTorus_loaded = None

_checked_openmp_issue = False

def load_libgalpy():

def _check_openmp_issue():
# Check whether we get an error of the type "OMP: Error #15: Initializing libomp.dylib, but found libomp.dylib already initialized.", which occurs, e.g., when using pip-installed galpy with conda-installed numpy and causes segmentation faults and general issues
# This is a known issue with OpenMP and is not galpy's fault (GitHub Copilot suggested this comment!)

# Check this by running a subprocess that imports galpy.orbit
proc = subprocess.run(
[
sys.executable,
"-c",
"from galpy.util._load_extension_libs import load_libgalpy; load_libgalpy(check_openmp_issue=False)",
],
check=True,
capture_output=True,
)
print(proc.stdout)
print(proc.stderr)
print(proc.returncode)
global _checked_openmp_issue
_checked_openmp_issue = True
return False


def load_libgalpy(check_openmp_issue=True):
if check_openmp_issue and not _checked_openmp_issue:
_check_openmp_issue()
else:
print(
f"Not checking for OpenMP issue and _checked_openmp_issue={_checked_openmp_issue}"
)
global _libgalpy
global _libgalpy_loaded
if _libgalpy_loaded is False or not _libgalpy is None:
Expand Down

0 comments on commit 3ab630a

Please sign in to comment.