vincefn / pyvkfft

Python interface to VkFFT
MIT License
51 stars 6 forks source link

Metal backend support? #24

Open BlackRockJL opened 1 year ago

BlackRockJL commented 1 year ago

Hey, awesome work! Are there plans to add a Metal backend support for Apple silicon? :) An update for VkFFT was recently released enabling Metal backends from their side.

vincefn commented 1 year ago

In principle it could be done - not sure how much work that would represent.

However the biggest pre-requisite is a python metal library sufficiently established and maintained (like pycuda/cupy for cuda, pyopencl for OpenCL) so that it is worth the effort.

There's https://github.com/baldand/py-metal-compute but no update in 2 years, and https://github.com/metal-stack/metal-python.

tdgrant1 commented 1 year ago

+1 for this feature

isuruf commented 1 year ago

You can use the OpenCL backend to access the GPU on Apple silicon.

Running the example, you get,

Selected device:  Apple M1 Max
( 800  768   16)[2D] dt=  3.79 ms  154.55 Gbytes/s  [norm=0]
BlackRockJL commented 1 year ago

Oh amazing! I did not know that OpenCL is still a thing for mac since apple claimed it’s deprecated. So you just selected the OpenCL backend and it runs natively (without Rosetta)? Thank you! :)

I found a discussion about OpenCL and macOS if someone is interested in some other background.

https://developer.apple.com/forums/thread/694866

isuruf commented 1 year ago

So you just selected the OpenCL backend and it runs natively (without Rosetta)?

Yes. On Apple Silicon, the OpenCL CPU backend is gone and only the OpenCL Metal backend is available.

vincefn commented 1 year ago

And it's well-tested, see on an M1 mac mini: http://ftp.esrf.fr/pub/scisoft/PyNX/pyvkfft-test/pyvkfft-test-2023-07-31-apple-m1/pyvkfft-test.html