Page MenuHome

macOS/bpy: add support for OpenMP
ClosedPublic

Authored by Ankit Meel (ankitm) on Mar 9 2021, 10:50 AM.

Details

Summary

Changed made:
Add linker options.
Copy the libomp.dylib to 2.93/lib/libomp.dylib.
Change the LC_LOAD_DYLIB item such that
the lib is found at bpy.so/../../Resources/2.93/lib/libomp.dylib.
Installation is done in D10664.
Ref T86579


Any way to avoid the dylib stuff ?

Diff Detail

Event Timeline

Ankit Meel (ankitm) requested review of this revision.Mar 9 2021, 10:50 AM
Ankit Meel (ankitm) created this revision.
Ankit Meel (ankitm) added a comment.EditedMar 9 2021, 10:58 AM

This will link, but bpy will not launch import because it needs OpenMP at an appropriate place.
Will follow up with another patch for that.

Ankit Meel (ankitm) retitled this revision from macOS/bpy: fix linker error with OpenMP to macOS/bpy: fix link and launch error with OpenMP.

Actually, fixed the launch issue here itself. Too many diffs..

Ankit Meel (ankitm) retitled this revision from macOS/bpy: fix link and launch error with OpenMP to macOS/bpy: fix link and import error with OpenMP.Mar 9 2021, 1:44 PM

Was this working before? When did it break?

Ok, so from what I understand it never worked and everyone has been building the bpy module without OpenMP on macOS. And so this is effectively adding OpenMP support for bpy.

Ankit Meel (ankitm) retitled this revision from macOS/bpy: fix link and import error with OpenMP to macOS/bpy: add support for OpenMP.Mar 10 2021, 2:18 PM
Ankit Meel (ankitm) edited the summary of this revision. (Show Details)
Ankit Meel (ankitm) planned changes to this revision.Mar 10 2021, 2:21 PM

To be able to import bpy without installing it in the python installation, will add a LC_LOAD_DYLIB entry containing @rpath and multiple LC_RPATH entries guessing where the lib might be.

source/creator/CMakeLists.txt
1009–1010 ↗(On Diff #35057)

What do you mean by multiple installations, like multiple bpy installations in a single site-packages? How would Python known which one to use on import bpy?

I do think it would be good to put everything in a bpy/ folder if possible, but not sure how multiple versions can work.

source/creator/CMakeLists.txt
1009–1010 ↗(On Diff #35057)

I didn't think this through. I want to keep Blender version in sync with the OpenMP version suitable for that version. Will replace the multiple installation comment.

it would be good to put everything in a bpy/ folder

Do you want to change ../Resources to ./bpy ? That will need changes in the part that looks for fonts and scripts, not just a rename here and in D10664: macOS/bpy: install to site-packages I guess.

source/creator/CMakeLists.txt
1009–1010 ↗(On Diff #35057)

It doesn't have to be part of this patch, since ideally we do this for all platforms and it may not be so simple.

But I imagine you'd modify appdir.c to disable the Resources exception when building as a Python module, and then have a layout like this:

site-packages/bpy
site-packages/bpy/__init__.so
site-packages/bpy/2.92
site-packages/bpy/lib
This revision is now accepted and ready to land.Mar 22 2021, 3:47 PM
This revision was automatically updated to reflect the committed changes.