Date: Mon, 01 Sep 2025 09:19:57 -0700
On Sunday, 31 August 2025 22:33:22 Pacific Daylight Time Tiago Freire wrote:
> > You want to have your cake and eat it too: have fast and cross-platform
> > basic algorithms. You usually can't have both.
>
> But that's precisely what I want to solve.
> I can provide multiple implementations.
> If I can test what is the target platform, I can pick the best
> implementation. If you don't have the hardware you get the "generic but at
> least it works" implementation, but if you do you can get the better
> version for your hardware.
And while I agree you should do that and that all of this should be
standardised somewhere, I don't agree any of this needs to be in the C++
Standard. It's not standard in the first place. It's usually not standard
across vendors and often will not be even across generations from a single
vendor.
> You would still end up with a cross-platform library, from a user's
> perspective it still works everywhere, but it is internally built with
> non-portable components. And that is fine because you can just swap those
> components.
> But if I have to go to every single compiler vendor to figure out how to do
> this test, it becomes much harder.
You still need to test the hardware and you often need to test the output of
the compiler too. So, as Jason said, that's rather minor.
But as I said, the listing should be standard. There should be no issue having
to guess wither the macro is called __AVX_VER__ (MSVC) or __AVX10_1__
(everyone else). I'll bring this up with a colleague who knows people in the
x86 Council.
> > You want to have your cake and eat it too: have fast and cross-platform
> > basic algorithms. You usually can't have both.
>
> But that's precisely what I want to solve.
> I can provide multiple implementations.
> If I can test what is the target platform, I can pick the best
> implementation. If you don't have the hardware you get the "generic but at
> least it works" implementation, but if you do you can get the better
> version for your hardware.
And while I agree you should do that and that all of this should be
standardised somewhere, I don't agree any of this needs to be in the C++
Standard. It's not standard in the first place. It's usually not standard
across vendors and often will not be even across generations from a single
vendor.
> You would still end up with a cross-platform library, from a user's
> perspective it still works everywhere, but it is internally built with
> non-portable components. And that is fine because you can just swap those
> components.
> But if I have to go to every single compiler vendor to figure out how to do
> this test, it becomes much harder.
You still need to test the hardware and you often need to test the output of
the compiler too. So, as Jason said, that's rather minor.
But as I said, the listing should be standard. There should be no issue having
to guess wither the macro is called __AVX_VER__ (MSVC) or __AVX10_1__
(everyone else). I'll bring this up with a colleague who knows people in the
x86 Council.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Platform & System Engineering
Received on 2025-09-01 16:20:07