From 57ca6620a629043ff441f0caf359d46f9a5b7a0d Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Tue, 22 Sep 2026 13:04:16 +0200 Subject: [PATCH 1/2] MathUtils: make SMatrixGPU compile as MSL Three separate issues: * Metal has no static storage duration inside a function, so MatRepSymGPU::off() drops the static on its offset table. Nothing is lost by dropping it everywhere rather than forking: arrays, unlike scalars, are emitted into read-only data either way. On the host it is marginally better, since the static form reached the table through the GOT. * operator=(Expr) now takes the expression by value. MSL folds the address space into a deduced parameter, so the generic operator=(const M&) deduced M = thread Expr<...>, matched exactly, beat the Expr overload and then tried mRep = rhs.mRep on an expression. A by-value parameter has no address space to deduce, so the Expr overload wins on Metal as it already did elsewhere. Expr is two references, so there is no copy cost. * Metal supports up to C++17, so it needs the same treatment as OpenCL for a requires-clause. --- Common/MathUtils/include/MathUtils/SMatrixGPU.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Common/MathUtils/include/MathUtils/SMatrixGPU.h b/Common/MathUtils/include/MathUtils/SMatrixGPU.h index 8158a93666a92..d3f5919fbd3b8 100644 --- a/Common/MathUtils/include/MathUtils/SMatrixGPU.h +++ b/Common/MathUtils/include/MathUtils/SMatrixGPU.h @@ -340,7 +340,7 @@ class MatRepSymGPU static GPUdi() int off(int i) { - static constexpr auto v = row_offsets_utils::make(off1); + constexpr auto v = row_offsets_utils::make(off1); return v[i]; } @@ -453,7 +453,7 @@ class SMatrixGPU GPUd() SMatrixGPU(const SMatrixGPU& rhs); template GPUd() SMatrixGPU(const Expr& rhs); - template + template GPUd() SMatrixGPU& operator=(const M& rhs); template GPUd() SMatrixGPU& operator=(const Expr& rhs); @@ -518,7 +518,7 @@ class SMatrixGPU R mRep; }; -#ifndef __OPENCL__ // TODO: current C++ for OpenCL 2021 is at C++17, so no concepts. But we don't need this trick for OpenCL anyway, so we can just hide it. +#if !defined(__OPENCL__) && !defined(__METAL__) // TODO: current C++ for OpenCL 2021 and MSL 4.1 are both at C++17, so no concepts. But we don't need this trick there anyway, so we can just hide it. template requires(sizeof(typename X::traits_type::pos_type) != 0) // do not provide a template to fair::Logger, etc... (pos_type is a member type of all std::ostream classes) GPUd() X& operator<<(Y& y, const SMatrixGPU&) @@ -684,7 +684,7 @@ GPUdi() SMatrixGPU& SMatrixGPU::operator=(const Expr } template -template +template GPUdi() SMatrixGPU& SMatrixGPU::operator=(const M & rhs) { mRep = rhs.mRep; From 5d3bcd37a60ae9e0f7ed6ab9f6e284961b53cab8 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Tue, 22 Sep 2026 11:07:48 +0000 Subject: [PATCH 2/2] Please consider the following formatting changes --- Common/MathUtils/include/MathUtils/SMatrixGPU.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/MathUtils/include/MathUtils/SMatrixGPU.h b/Common/MathUtils/include/MathUtils/SMatrixGPU.h index d3f5919fbd3b8..2e551aac98d24 100644 --- a/Common/MathUtils/include/MathUtils/SMatrixGPU.h +++ b/Common/MathUtils/include/MathUtils/SMatrixGPU.h @@ -685,7 +685,7 @@ GPUdi() SMatrixGPU& SMatrixGPU::operator=(const Expr template template -GPUdi() SMatrixGPU& SMatrixGPU::operator=(const M & rhs) +GPUdi() SMatrixGPU& SMatrixGPU::operator=(const M& rhs) { mRep = rhs.mRep; return *this;