The following program void main(string[] args) { import core.simd; float4 a = 1, b = 2; float4 c = __simd(XMM.ADDSS, a, b); } fails to compile with gdc. The compiler aborts with test.d:5: error: undefined identifier __simd test.d:5: error: undefined identifier XMM My running gdc on Linux. gdc (crosstool-NG hg+unknown-20131212.080758) 4.8.2 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. How do I generate SSE instructions with gdc?
__simd requires the compiler to expose D_SIMD. Which is not implemented in GDC. And given the nature of the intrinsic, I can't see it ever being introduced. To access SIMD instructions, instead use the gcc.builtins module. --- import gcc.builtins; float4 a = 1, b = 2; float4 c = __builtin_ia32_addps(a, b); --- You can get a list of all builtins gdc exposes using: echo "module gcc.builtins;" > builtins.d && gdc -fsyntax-only -fintfc builtins.d Then open the file 'builtins.di' for viewing. There is currently no maintained list of this because what is generated for gcc.builtins may change depending on target or optimisation flags passed to gdc.
There is no __builtin_ia32_loadaps with my gdc. I'm using the latest binaries. Is this to be expected? Probably I'm doing something wrong. I cannot find it in the generated builtins.di and gdc says error: undefined identifier __builtin_ia32_loadaps, did you mean function __builtin_ia32_loadhps.
There is no __builtin_ia32_loadaps in GCC either.
Quote from (Updated code example for D) https://gcc.gnu.org/ml/gcc-help/2011-06/msg00237.html """ The __builtin_ia32_loadaps builtin function was removed and the documentation is out of date. The movaps instruction from memory is easily generated using code like import core.simd; float4 loadaps(float4 *p) { return *p; } """
Might I suggest that std.simd exists to wrangle the difference between compilers (and arch/platforms). It's on dub, or my github. I'll finish it up when I have all the tools required and ideally include in phobos, but what's there is usable now.
(In reply to Manu from comment #5) > Might I suggest that std.simd exists to wrangle the difference between > compilers (and arch/platforms). > It's on dub, or my github. I'll finish it up when I have all the tools > required and ideally include in phobos, but what's there is usable now. Nice to see that it's well tested too. :) https://github.com/TurkeyMan/simd/blob/master/std/simd.d#L4224
Thanks for the reply. Sorry I'm fairly new to this low-level programming. I'm looking forward to std.simd. Currently I familiarize myself with this kind of programming. I believe std.simd will be a huge relief. But first I have to feel the "real" pain. Makes me appreciate your work even more and gives me some numbers regarding possible overheads.
Fair enough. Although it's a direct abstraction for most operations, so no overheads. Some algorithms which aren't supported by certain architectures need to be emulated however.
Do you have some timeline? I'd like to see it reviewed.