Skip to content

Enable building on macOS#18

Open
al42and wants to merge 2 commits intoSaschaWillems:masterfrom
al42and:macosx
Open

Enable building on macOS#18
al42and wants to merge 2 commits intoSaschaWillems:masterfrom
al42and:macosx

Conversation

@al42and
Copy link
Contributor

@al42and al42and commented Aug 9, 2024

Checked on M1 Mac Mini, macOS Sonoma, GUI and CLI

@SaschaWillems
Copy link
Owner

Thank you very much for your PR. Very much appreciated.

Please note that the online database does not support MacOS, so before I merge this I need to add support for it to the database first.

Since I don't own any Apple devices I need the values for the platform identification. Can you export a JSON file from your device and attach it to this PR?

Btw. : Is OpenCL still supported on Apple devices? I was under the impression that Apple abandoned it.

@al42and
Copy link
Contributor Author

al42and commented Aug 9, 2024

Since I don't own any Apple devices I need the values for the platform identification. Can you export a JSON file from your device and attach it to this PR?

m1.json

Btw. : Is OpenCL still supported on Apple devices? I was under the impression that Apple abandoned it.

It is deprecated, but works ok as far as I can tell.

@SaschaWillems
Copy link
Owner

SaschaWillems commented Aug 10, 2024

Thanks for the report. In order to make this work properly (with the database), you need to adjust the getOperatingSystem function in operatingsystem.cpp and set proper values for Mac platforms.

In the Vulkan Caps Viewer I do it like this:

#if defined(VK_USE_PLATFORM_MACOS_MVK)
    osInfo.type = 3;
#endif
#if defined(VK_USE_PLATFORM_IOS_MVK)
    osInfo.type = 4;
#endif

Can you add that to the PR? So that it sets osInfo.type to 3 when running on MacOS?

@al42and
Copy link
Contributor Author

al42and commented Aug 27, 2024

I used slightly different method, but seems to work, at least on macOS; haven't tested with iOS.

Updated JSON: m1.json

@oscarbg
Copy link

oscarbg commented Apr 12, 2025

submitted M4 result using this PR..

https://opencl.gpuinfo.org/displayreport.php?id=4967

but needed 2 minor patches, due to using latest opencl headers version (2024.10.24)..
used:

brew install opencl-headers

installs:

opencl-headers 2024.10.24

so I build with:

export CPATH=$CPATH:/opt/homebrew/opt/opencl-headers/include

1)first patch it's due to removal of external mem dx cl extensions..
other projects are affected like OpenCL-HPP
KhronosGroup/OpenCL-CLHPP#295
(KhronosGroup/OpenCL-CLHPP@9c2dffe)

2)second patch due to:
KhronosGroup/OpenCL-Headers#231

"fixes the extension enums CL_DEPTH_STENCIL and CL_UNORM_INT24, which were never core enums and hence should not be in the core cl.h at all."

these enums are in cl_gl.h now..

if not fails compilation with:

./openclutils.h:355:4: error: use of undeclared identifier 'CL_DEPTH_STENCIL'
  355 |                         STR(DEPTH_STENCIL);
      |                         ^
./openclutils.h:391:4: error: use of undeclared identifier 'CL_UNORM_INT24'
  391 |                         STR(UNORM_INT24);
      |                         ^

patch 1:

diff --git a/displayutils.cpp b/displayutils.cpp
index 5e333ae..cc77282 100644
--- a/displayutils.cpp
+++ b/displayutils.cpp
@@ -321,10 +321,12 @@ namespace utils
             // cl_khr_external_memory_dma_buf
             STR(CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR);
             // cl_khr_external_memory_dx
+            #if 0
             STR(CL_EXTERNAL_MEMORY_HANDLE_D3D11_TEXTURE_KHR);
             STR(CL_EXTERNAL_MEMORY_HANDLE_D3D11_TEXTURE_KMT_KHR);
             STR(CL_EXTERNAL_MEMORY_HANDLE_D3D12_HEAP_KHR);
             STR(CL_EXTERNAL_MEMORY_HANDLE_D3D12_RESOURCE_KHR);
+            #endif
             // cl_khr_external_memory_opaque_fd
             STR(CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR);
             // cl_khr_external_memory_win32
@@ -341,7 +343,9 @@ namespace utils
         {
 #define STR(r) case r: return #r
             // cl_khr_external_semaphore_dx_fence
+            #if 0
             STR(CL_SEMAPHORE_HANDLE_D3D12_FENCE_KHR);
+            #endif
             // cl_khr_external_semaphore_opaque_fd
             STR(CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR);
             // cl_khr_external_semaphore_sync_fd

patch 2:

diff --git a/openclutils.h b/openclutils.h
index a9f6da6..4a308dc 100644
--- a/openclutils.h
+++ b/openclutils.h
@@ -22,6 +22,7 @@
 
 #include "CL/cl.h"
 #include "CL/cl_ext.h"
+#include "CL/cl_gl.h"
 #include <vector>
 #include <sstream>
 #include <QString>

@oscarbg
Copy link

oscarbg commented Apr 12, 2025

update:
ok sorry for last message really didn't clone the repo with -recursive so OpenCLCapsViewer/external/OpenCL-Headers is empty and using my own latest ocl headers encountered this issues..

OCL ICD support:
now also recompiled with ocl-icd support so detects POCL for example, and sent a report of POCL 6.0 CPU on MacOS..

https://opencl.gpuinfo.org/displayreport.php?id=4968

replicate:
brew install pocl
and patch to load ocl-icd: "/opt/homebrew/opt/ocl-icd/lib/libOpenCL.1.dylib"

diff --git a/openclfunctions.cpp b/openclfunctions.cpp
index 741b5fb..8540353 100644
--- a/openclfunctions.cpp
+++ b/openclfunctions.cpp
@@ -114,6 +114,7 @@ bool checkOpenCLAvailability(QString& error)
         "/usr/local/lib/libpocl.so.1",
         "/usr/lib64/libOpenCL.so.1",
         "/usr/lib32/libOpenCL.so.1",
+        "/opt/homebrew/opt/ocl-icd/lib/libOpenCL.1.dylib",
         "/System/Library/Frameworks/OpenCL.framework",
         "/System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL"
     };


@oscarbg
Copy link

oscarbg commented Apr 12, 2025

now last report on osx..
CLVK report:
https://opencl.gpuinfo.org/displayreport.php?id=4969

now pointing to search for:
"/home/blah/Downloads/clvk/OpenCL.framework/Versions/A/OpenCL"

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

Successfully merging this pull request may close these issues.

3 participants