Skip to content

GPU CMake: enable the Metal backend by default where the toolchain supports it - #15982

Open
ktf wants to merge 3 commits into
AliceO2Group:devfrom
ktf:pr15982
Open

ktf wants to merge 3 commits into
AliceO2Group:devfrom
ktf:pr15982

Conversation

@ktf

@ktf ktf commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

ENABLE_METAL defaults to AUTO like the other backends: it is used when the
Metal toolchain compiles MSL 4.1 (macOS 27) and silently skipped otherwise.

Notice that in any case by default we use the CPU, even when Metal is available.

@ktf
ktf requested review from a team and davidrohr as code owners October 17, 2026 14:02
@ktf

ktf commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

In case someone wants to experiment with it while I am away...

@alibuild

alibuild commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Error while checking build/O2/fullCI_slc9 for e139bea at 2026-11-10 03:51:

-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindHepMC.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindFlukaVMC.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindTBB.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/Findpythia.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindVMC.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindGeant4VMC.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindRapidJSON.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/O2Dependencies.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindO2GPU.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindFastJet.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/O2CompileFlags.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindVGM.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindO2GPUWayland.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindLibUV.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindVtune.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindGeant4.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindMCStepLogger.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/O2SimulationDependencies.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindOpenMPMacOS.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindlibjalienO2.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/Findpythia6.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindGLFW.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindXRootD.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindHepMC3.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindAliRoot.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindGeant3.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/CMakeLists.txt
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/O2TestsAdapter.cmake
-- Installing: /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/lib/cmake/O2/FindAliceGridUtils.cmake
+ mkdir -p /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/etc/modulefiles
+ rsync -a --delete etc/modulefiles/ /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15/etc/modulefiles
+ cp /sw/BUILD/4088699252dd5e472752d9611987d69a5fe93e8b/O2/compile_commands.json /sw/slc9_x86-64/O2/slc9_x86-64-slc9_x86-64-local15
++ readlink /sw/SOURCES/O2/slc9_x86-64-slc9_x86-64/0
+ DEVEL_SOURCES=/O2
+ '[' /O2 '!=' /sw/SOURCES/O2/slc9_x86-64-slc9_x86-64/0 ']'
+ perl -p -i -e 's|/sw/SOURCES/O2/slc9_x86-64-slc9_x86-64/0|/O2|' compile_commands.json
+ ln -sf /sw/BUILD/4088699252dd5e472752d9611987d69a5fe93e8b/O2/compile_commands.json /O2/compile_commands.json
+ [[ -n '' ]]
+ checkFindO2GPU
+ [[ -n /alidist ]]
+ [[ -f /alidist/resources/FindO2GPU.cmake ]]
+ cmp -s /alidist/resources/FindO2GPU.cmake /sw/SOURCES/O2/slc9_x86-64-slc9_x86-64/0/dependencies/FindO2GPU.cmake
++ grep '# FindO2GPU.cmake Version ' /alidist/resources/FindO2GPU.cmake
++ awk '{print $4}'
++ grep '# FindO2GPU.cmake Version ' /sw/SOURCES/O2/slc9_x86-64-slc9_x86-64/0/dependencies/FindO2GPU.cmake
++ awk '{print $4}'
+ [[ ! 23 -gt 24 ]]
+ echo 'FindO2GPU.cmake differs in O2 compared to alidist, please sync O2/dependencies/FindO2GPU.cmake to alidist/resources and make sure to update the version number'
FindO2GPU.cmake differs in O2 compared to alidist, please sync O2/dependencies/FindO2GPU.cmake to alidist/resources and make sure to update the version number
+ exit 1

Full log here.

@ktf ktf changed the title Enable Metal if available GPU CMake: enable the Metal backend by default where the toolchain supports it Nov 12, 2026
@alibuild

alibuild commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Error while checking build/O2/fullCI_slc9 for 720ab81 at 2026-11-15 09:59:

## sw/BUILD/o2codechecker-latest/log
100% tests passed, 0 tests failed out of 1

Full log here.

Comment thread GPU/documentation/build-standalone.md Resolved
Comment thread GPU/documentation/build-standalone.md Resolved
Comment thread dependencies/FindO2GPU.cmake Resolved
Comment thread GPU/documentation/build-standalone.md Resolved
Comment thread GPU/documentation/build-standalone.md Resolved
@davidrohr

Copy link
Copy Markdown
Collaborator

ok, I should have said, in general I am fine with this change (as discussed in person). I also appreciate if people improve the documentation :). So please go ahead like this :).

@ktf

ktf commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

I am not sure if "people" is the right collective noun, but ok... ;-)

@ktf
ktf force-pushed the pr15982 branch 2 times, most recently from 3e4ca31 to 19719ae Compare November 15, 2026 08:36
The stage run with ENABLE_GPU_TEST=1 was hardcoded to CUDA. FST_GPUTYPE
selects it, e.g. FST_GPUTYPE=METAL on macOS; the default stays CUDA.
@ktf

ktf commented Nov 15, 2026

Copy link
Copy Markdown
Member Author

@davidrohr I dropped all the things in the documentation you had comments on from the PR and I will open a separate one with just those.

This one works for me to enable the metal backend. All that is left is the optimisations which I left for after your tracking changes.

@davidrohr davidrohr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, except for I'd try to get rid of the cast for printf

}
if (nEventsProcessed > 1) {
printf("Total: %ld clusters, %ld tracks\n", nClustersTotal, nTracksTotal);
printf("Total: %lld clusters, %lld tracks\n", (long long)nClustersTotal, (long long)nTracksTotal);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get rid of the cast? Perhaps we can use size_t and %z?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be done. I also changed nBunch to int32 for the other cast.

ktf added 2 commits November 15, 2026 23:33
…pports it

ENABLE_METAL defaults to AUTO like the other backends: it is used when the
Metal toolchain compiles MSL 4.1 (macOS 27) and silently skipped otherwise.

Notice that in any case by default we use the CPU, even when Metal is available.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants