Skip to content

Commit

Permalink
Merge pull request #50 from Qiskit-Partners/opmp_flag_version
Browse files Browse the repository at this point in the history
Check if compiled with omp from about function
  • Loading branch information
nonhermitian authored Sep 5, 2021
2 parents cb2bc2d + 3783e00 commit 81561f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion mthree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@

try:
from .version import version as __version__
from .version import openmp
except ImportError:
__version__ = '0.0.0'
openmp = False

from .mitigation import M3Mitigation

Expand All @@ -35,5 +37,7 @@ def about():
print('='*80)
print('# Matrix-free Measurement Mitigation (M3) version {}'.format(__version__))
print('# (C) Copyright IBM 2021.')
print('# Paul D. Nation, Hwajung Kang, Neereja Sundaresan, and Jay Gambetta')
print('# Paul Nation, Hwajung Kang, Neereja Sundaresan')
print('# Jay Gambetta, and Matthew Treinish.')
print('# Compiled with OpenMP: {}'.format(openmp))
print('='*80)
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@
# Add openmp flags
OPTIONAL_FLAGS = []
OPTIONAL_ARGS = []
WITH_OMP = False
for _arg in sys.argv:
if _arg.startswith("--with-"):
_options = _arg.split("--with-")[1].split(",")
sys.argv.remove(_arg)
if "openmp" in _options or os.getenv("MTHREE_OPENMP", False):
WITH_OMP = True
if sys.platform == 'win32':
OPTIONAL_FLAGS = ['/openmp']
else:
Expand Down Expand Up @@ -120,12 +122,12 @@ def write_version_py(filename='mthree/version.py'):
# pylint: disable=missing-module-docstring
short_version = '%(version)s'
version = '%(fullversion)s'
release = %(isrelease)s
openmp = %(with_omp)s
"""
a = open(filename, 'w')
try:
a.write(cnt % {'version': VERSION, 'fullversion':
FULLVERSION, 'isrelease': str(ISRELEASED)})
a.write(cnt % {'version': VERSION, 'fullversion':FULLVERSION,
'with_omp': str(WITH_OMP)})
finally:
a.close()

Expand Down

0 comments on commit 81561f2

Please sign in to comment.