FoldingAtHome / fah-client-bastet

Folding@home client, code named Bastet
GNU General Public License v3.0
74 stars 13 forks source link

Support for Apple GPU Acceleration in Folding Client #303

Open mreid-tt opened 2 weeks ago

mreid-tt commented 2 weeks ago

I'm enthusiastic about contributing my machine's spare processing power to this project. Currently, I'm using Apple Silicon devices, and while the client works well for CPU-based folding, I wondered if there are any plans to leverage Apple GPUs. Adding support for Apple GPU acceleration could significantly boost folding performance and expand the power available to the community.

muziqaz commented 2 weeks ago

There are no plans to support Apple GPUs. This is because OpenMM, which FAH uses for GPU workloads, does not support Apple GPUs. They might be able to shed more light why that is, but rumour has it, that Apple is not forthcoming with providing support for OpenMM.

mreid-tt commented 2 weeks ago

Thank you for the feedback and for highlighting OpenMM. I came across some discussions about drivers for Apple's Metal as well as support for OpenCL. Notably, OpenMM 8.0.0's release notes mention an improvement:

The OpenCL platform now has improved support for low end GPUs that don't support 64 bit atomic operations. That includes, for example, the embedded GPUs found in Intel and Apple processors. Previusly there were certain Forces that couldn't be used on those GPUs, such as CustomManyParticleForce and AmoebaMultipoleForce. All Forces are now fully supported on those processors. In addition, performance on them will often be better than before.

Unfortunately, this doesn’t resolve issues for current macOS users, as Apple’s Transition to Metal deprecates OpenCL for GPU computations as of macOS 10.14.

To ensure long-term compatibility, an Apple Metal implementation of OpenMM would be ideal. I noticed some discussions in Future of OSX GPU support, but much of it is complex, and any specific timeline remains unclear. It’s disappointing, especially since macOS has many CPU cores (twice as many as Windows) that underperform in contributions, as shown in OS statistics.

mreid-tt commented 2 weeks ago

hey @muziqaz, I hope you don't mind but I asked the OpenMM folks about GPU support and based on their response in https://github.com/openmm/openmm/issues/2489#issuecomment-2458237923, it should be possible. Perhaps this could be something for the team to revisit?

kbernhagen commented 2 weeks ago

I believe the main impediment right now is a failure of the client to get AMD PCI info for GPUs. You can see this in the debug build client log.

And Apple silicon GPUs are not PCI devices, so the current method of detecting and whitelisting those will not work. But for Apple silicon, it seems like it could be safe to always enable for OpenCL the GPU found using the OpenCL api. A core does its own thing to detect a GPU, I think.

muziqaz commented 2 weeks ago

I think due to lack of developer available time, relatively small and edge markets tend to go into back of the queue. The main priority right now in regards to the GPU folding is to sort out few issues with PC side and get AMD HIP out. After that it is possible we can ask to look into Apple GPU stuff