Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel LCD computation fails on macOS #91

Open
dgazzoni opened this issue Feb 19, 2023 · 1 comment
Open

Parallel LCD computation fails on macOS #91

dgazzoni opened this issue Feb 19, 2023 · 1 comment
Assignees
Labels

Comments

@dgazzoni
Copy link
Contributor

Configuration: OSACA 0.4.13 running on macOS Ventura 13.2 using the system Python 3.9.6. Also happens on the Homebrew-installed Python 3.10.9 and 3.11.1.

Just create any large (> 50 instructions) kernel and try to run OSACA. The following error is output:

Traceback (most recent call last):
  File "/usr/local/bin/osaca", line 8, in <module>
    sys.exit(main())
  File "/Library/Python/3.9/site-packages/osaca/osaca.py", line 431, in main
    run(args, output_file=args.out)
  File "/Library/Python/3.9/site-packages/osaca/osaca.py", line 380, in run
    inspect(args, output_file=output_file)
  File "/Library/Python/3.9/site-packages/osaca/osaca.py", line 336, in inspect
    kernel_graph = KernelDG(kernel, parser, machine_model, semantics, args.lcd_timeout)
  File "/Library/Python/3.9/site-packages/osaca/semantics/kernel_dg.py", line 32, in __init__
    self.loopcarried_deps = self.check_for_loopcarried_dep(self.kernel, timeout)
  File "/Library/Python/3.9/site-packages/osaca/semantics/kernel_dg.py", line 133, in check_for_loopcarried_dep
    p.start()
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 47, in _launch
    reduction.dump(process_obj, fp)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object '_trim_arity.<locals>.wrapper'

On the other hand, the issue does not happen with OSACA 0.4.13 on a Raspberry Pi 4 running Ubuntu Linux 22.04, with Python 3.10.6.

My understanding is that it is related to the parallel LCD computation feature. Some research appears to indicate that _trim_arity comes from the pyparsing package.

@dgazzoni
Copy link
Contributor Author

Upon further research, this appears to be an issue involving macOS, the multiprocessing package, and supposedly the pyparsing package. My understanding is that the default mode for multiprocessing was changed from fork to something else (possibly spawn), due to a macOS bug. This change probably ended up requiring that a certain variable from pyparsing be picklable, which it isn't.

I see three possibilities to make OSACA work on macOS:

  1. Fully disable parallelization on macOS;
  2. Add this code somewhere before running parallel code, although it may trigger other macOS bugs:

multiprocessing.set_start_method("fork")

  1. Restrict the use of pyparsing to serial code, so it doesn't have to be pickled.

@JanLJL JanLJL self-assigned this Jul 18, 2023
@JanLJL JanLJL added the bug label Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants