preda / gpuowl

GPU Mersenne primality test.
GNU General Public License v3.0
176 stars 39 forks source link

Add support for MacOS #294

Closed proski closed 2 months ago

proski commented 2 months ago

This is for x86_64 only. No attempt was made to support Apple Silicon. However, this PR could be used as a spepping stone in that direction.

The remaining problem is an error when running prpll:

Exception gpu_error: INVALID_WORK_GROUP_SIZE (-54) transpIn at /Users/plroskin/src/gpuowl/src/clwrap.cpp:312 run

That would need to be addressed by an OpenCL expert. It's possible that the issue is specific to my hardware or software.

However, many other issues have been addressed is a clean way.

Basically, the C++ code compiles, the OpenCL code compiles and loads, but fails to run on the GPU.

tdulcet commented 2 months ago

@proski - If you want future commits to be automatically checked that they successfully build on x86 macOS, you could add something like this to the existing GitHub actions workflow file:

  macOS:
    name: macOS

    runs-on: macos-13
    steps:
    - uses: actions/checkout@v4
    - name: Install
      run: |
        brew install opencl-headers
        g++ --version
    - name: Script
      run: |
        make prpll -j "$(sysctl -n hw.ncpu)"
        cd build-release
        rm -f -- *.o
        ./prpll -h
    - uses: actions/upload-artifact@v4
      if: always()
      with:
        name: macos_prpll
        path: ${{ github.workspace }}

I am guessing that the opencl-headers package would need to be installed. The opencl-icd-loader package might need to be installed as well.

proski commented 2 months ago

@proski - If you want future commits to be automatically checked that they successfully build on x86 macOS, you could add something like this to the existing GitHub actions workflow file:

I've added it, thank you!

I am guessing that the opencl-headers package would need to be installed. The opencl-icd-loader package might need to be installed as well.

None of them is needed. Even gcc@14 is installed already, but I'm installing it anyway to be explicit about the dependency.

We should run a real test like prpll -iters 10000 -ll 82589933 but other OSes don't do it, so let's keep it consistent. Also, there is no test for the cmake build, I should have added it in #293. It could be added in a separate PR.

proski commented 2 months ago

INVALID_WORK_GROUP_SIZE is reproducible in the CI:

https://github.com/preda/gpuowl/actions/runs/10842867463/job/30089143591?pr=295#step:4:71

proski commented 2 months ago

Added fallback for the case when cmake cannot find OpenCL but linking with -lOpenCL works. Observed on Windows in the CI.