[Issue 15873] In order to implement std.simd, compile time info about CPU specifics is needed

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Apr 4 11:34:26 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=15873

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com

--- Comment #1 from Walter Bright <bugzilla at digitalmars.com> ---
For DMD, the minimum SIMD level can be ascertained by:

1. the operating system - for example, OSX is only sold on certain CPUs and
above. Also, Linux assumes SIMD in the default behavior of gcc.
2. 32 or 64 bit code being generated

The DMD compiler assumes the existence of that minimum SIMD level, and
generates SIMD code accordingly.


The SIMD capabilities can be tested at runtime:

  http://dlang.org/phobos/core_cpuid.html

This is used, for example, here:

 
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/arraydouble.d#L33

The idea is to use a template to statically generated code for each supported
SIMD level. Then, test the capabilities at a high level, and select the right
branch at the high level. Then each level's implementation runs at full speed
with custom code for that level.

--


More information about the Digitalmars-d-bugs mailing list