Any usable SIMD implementation?

Marco Leise via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 13 03:58:34 PDT 2016


Am Wed, 13 Apr 2016 11:21:35 +0200
schrieb Iain Buclaw via Digitalmars-d
<digitalmars-d at puremagic.com>:

> Yes, cpu_supports is a good way to do it as we only need to invoke
> __builtin_cpu_init once and cache all values when running 'shared
> static this()'.

I was under the assumption that GCC already emits an 'early'
static ctor with a call to __builtin_cpu_init(). It is also
likely that we don't need extra code to copy GCC's cache to
core.cpuids cache (unless the cached data is publicly
exposed somehow). What is your stance on the cross module
inlining issue? Stuff like hasPopcnt etc. wont be inlined
unless you turn them into compiler recognised builtins, right?
It's not a blocker, but something to keep in mind when not
accessing global variables directly.

How about this style as an alternative?:

immutable bool mmx;
immutable bool hasPopcnt;

shared static this()
{
    import gcc.builtins;
    mmx       = __builtin_cpu_supports("mmx"   ) > 0;
    hasPopcnt = __builtin_cpu_supports("popcnt") > 0;
}

-- 
Marco



More information about the Digitalmars-d mailing list