Can you as a human implement Xorshiro256ss using SIMD #94646
-
Here's source : https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/Random.Xoshiro256StarStarImpl.cs,bb77e610694e64ca Here's ChatGPT using System;
using System.Numerics;
public class Xorshiro256ss
{
private Vector<ulong> state;
public Xorshiro256ss(ulong seed)
{
state = new Vector<ulong>(seed);
}
public ulong Next()
{
Vector<ulong> result = state ^ (state << 17);
result = result ^ (result >> 31);
result = result ^ (result << 8);
state = result;
return result[0];
}
// You can add more methods if needed, like generating random doubles or floats.
} |
Beta Was this translation helpful? Give feedback.
Answered by
huoyaoyuan
Nov 13, 2023
Replies: 1 comment 8 replies
-
I don't trust ChatGPT at all on (non-well known) algorithm. Only this part is transformable into SIMD: s2 ^= s0;
s3 ^= s1;
s1 ^= s2;
s0 ^= s3; into Vector128<ulong> lower = Create(s0, s1);
Vector128<ulong> upper = Create(s2, s3);
upper ^= lower;
lower ^= upper.Shuffle([1, 0]); Every other steps heavily depends on the results of last step, and are asymmetric on 4 state values. It's not candidate for SIMD at all. |
Beta Was this translation helpful? Give feedback.
8 replies
Answer selected by
Xyncgas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't trust ChatGPT at all on (non-well known) algorithm.
Only this part is transformable into SIMD:
into
Every other steps heavily depends on the results of last step, and are asymmetric on 4 state values. It's not candidate for SIMD at all.