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

Will the Metal framework be wrapped? #264

Closed
ronaldoussoren opened this issue Mar 25, 2019 · 11 comments
Closed

Will the Metal framework be wrapped? #264

ronaldoussoren opened this issue Mar 25, 2019 · 11 comments

Comments

@ronaldoussoren
Copy link
Owner

Original report by Aaron Elkins (Bitbucket: [Aaron Elkins](https://bitbucket.org/Aaron Elkins), ).


Hey, do you have any plan to wrap the Metal framework into PyObjc?

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


Maybe, but that will be a lot of work and requires some serious design work to get a usable API. It doesn't help that I have no use case for using these APIs myself.

To be honest I'm still hoping that someone else builds something like PyOpenGL but for Metal instead of OpenGL.

@ronaldoussoren
Copy link
Owner Author

Original comment by Aaron Elkins (Bitbucket: [Aaron Elkins](https://bitbucket.org/Aaron Elkins), ).


Yep, I was thinking using PyOpenGL for my project, but since OpenGL is deprecated in the new macOS Mojave, so I think I should use Metal instead, but no Metal binding for Python.

Hope there will be a good solution for Python in the near future.

@ronaldoussoren
Copy link
Owner Author

Original comment by Yuan Chuan Kee (Bitbucket: yuanchuankee, GitHub: yuanchuankee).


I have been looking at this too.

My use case is to use the MPS for machine learning as currently most popular ML framework such as Tensorflow and PyTorch only supports CUDA.

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


I agree that having bindings to the Metal framework would be useful, but creating these would likely require more time than I have available.

That said, I just took a quick look at the headers and the main API appears to be a regular Objective-C class-based API and that should be fairly easy to wrap (although still quite some work due to the size of the API). A complicating factor is passing memory to/from Metal in a sane way, and possibly dealing with SIMD types (such as vector_float3).

I'll definitely add looking into this to my list for the summer, but might get around to this earlier.

Do you know if there are interesting, but simple, Objective-C examples for using Metal that could be used to functionally test a Python binding?

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


FWIW I plan to wrap the Metal frameworks for PyObjC 6.0 (later this year).

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


I’ve started work on these bindings, but it is going slower than expected. One reason for that is that my tooling for creating bindings breaks on the Metal headers.

I expect similar problems with the MetalPerformanceShader framework (which is a pretty large framework).

I still expect to ship PyObjC 6.0 with support for these frameworks though.

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


Given the current rumours about a macOS 10.15 release later this week I’ll probably not ship Metal bindings with 6.0.

A ran into a problem with generating metadata for this framework, these headers contain constructs that are not understood by the Python bindings to libclang that I’m using. I’m hoping that I can “just” move to the Python bindings in the clang repository, but that will take some time. Creating metadata manually is not really an option due to the sheer size of these frameworks.

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


I’ve made some progress on this, I’ve tweaked the metadata generator to not crash on the metal headers, and that should make it a lot easier to make progress.

My current plan is to have a release with Metal support before the holidays (both Metal itself and MetalPerformanceShaders).

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


Initial bindings are in changeset 4264900dfc8b. The bindings are far from finished though, tests don’t pass yet and are not complete.

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


I’ve done some updates over the last couple of days and the bindings are nearing completion. With some luck I’ll release a version of PyObjC with these binding before the end of the year.

@ronaldoussoren
Copy link
Owner Author

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


Changeset bc938aaa4c76 finishes work on pyobjc-framework-Metal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant