View Single Post
Old 2022-04-19, 18:58   #124
rogue's Avatar
Apr 2003
Between here and the

3·2,213 Posts

Support of Metal is requiring changes to the framework. The area affected the most are the makefile, the GPU kernel code, how the GPU workers create the kernels, and the GpuWorker classes.

It appears that the Metal kernel and OpenCL kernel have few differences. I should be able to write a single kernel that can be compiled for both Metal and OpenCL. This means that updating kernels to support both should be very easy.

I have modified the makefile so that it can convert the kernel source into a header that can be included by the GpuWorker. This was a manual process previously.

The makefile also has the ability to create a metallib file on OS X. The application does not use that library, but the process to create that library is a quick way for me to identify syntax bugs in the kernel that I otherwise would only discover at runtime.

The KernelArgument class is gone. This is due to how Metal manages them as the M1 shares memory between the GPU and CPU. This means that the Kernel class has new methods to add arguments and is completely responsible for managing CPU and GPU memory needed for the GpuWorkers. The key is that the GpuWorkers are mostly "agnostic" regarding OpenCL or Metal.

In short lots of interesting things, but I haven't tested anything yet. My biggest fear is that I cannot use Metal in the way that I think I can use it. That is for later this week. If I can get mfsiieve to build and run with both OpenCL and Metal (with the correct results) then migrating the other GPU sievers to use support both should be fairly easy. My second biggest fear is getting incorrect results and trying figure out the root cause.
rogue is offline   Reply With Quote