Skip to content

Commit

Permalink
Merge pull request dlang#3808 from WalterBright/simdExample
Browse files Browse the repository at this point in the history
add clarifying examples of SIMD usage
  • Loading branch information
WalterBright committed Apr 24, 2022
2 parents d20bb68 + b567075 commit 27b9a9d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/core/simd.d
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,28 @@ version (D_SIMD)
* op2 = second operand
* Returns:
* result of opcode
* Example:
---
import core.simd;
import core.stdc.stdio;
void main()
{
float4 A = [2.34f, -70000.0f, 0.00001f, 345.5f];
float4 R = A;
R = cast(float4) __simd(XMM.RCPSS, R, A);
printf("%g %g %g %g\n", R.array[0], R.array[1], R.array[2], R.array[3]);
}
---
* Prints `0.427368 -70000 1e-05 345.5`.
* The use of the two operand form for `XMM.RCPSS` is necessary because the result of the instruction
* contains elements of both operands.
* Example:
---
double[2] A = [56.0, -75.0];
double2 R = cast(double2) __simd(XMM.LODUPD, *cast(double2*)A.ptr);
---
* The cast to `double2*` is necessary because the type of `*A.ptr` is `double`.
*/
pure @safe void16 __simd(XMM opcode, void16 op1, void16 op2);

Expand Down

0 comments on commit 27b9a9d

Please sign in to comment.