private static void StoreRemainingElements <T>(ref T *origin, ref T *target, uint count, uint remainder) where T : unmanaged { if ((count & remainder) > 0) { if (sizeof(T) == sizeof(byte)) { StoreRemainingByte((byte *)origin, (byte *)target, remainder); } if (sizeof(T) == sizeof(short)) { StoreRemainingInt16((short *)origin, (short *)target, remainder); } if (sizeof(T) == sizeof(int)) { StoreRemainingInt32((int *)origin, (int *)target, remainder); } if (sizeof(T) == sizeof(long)) { StoreRemainingInt64((long *)origin, (long *)target, remainder); } PointerArithmetic.Increment(ref origin, ref target, remainder); } }
public static void StoreLastElementsVector128 <T>(T *origin, double *target, uint index, uint length) where T : unmanaged { PointerArithmetic.Increment(ref origin, ref target, index); uint count = length - index; StoreRemainingElements(1, ref origin, ref target, length);
static void StoreRemainingElements(uint remainder, ref T *origin, ref short *target, uint count) { if ((count & remainder) > 0) { if (typeof(T) == typeof(byte)) { StoreRemainingByte(remainder, origin, target); } PointerArithmetic.Increment(ref origin, ref target, remainder); } }
public static void StoreLastElementsVector128Downcast <T>(T *origin, byte *target, uint index, uint length) where T : unmanaged { if (!Ssse3.IsSupported) { return; } PointerArithmetic.Increment(ref origin, ref target, index); uint count = length - index; StoreRemainingElements(4, ref origin, ref target, count); StoreRemainingElements(2, ref origin, ref target, count); StoreRemainingElements(1, ref origin, ref target, count);
public static void StoreLastElementsVector256 <T>(T *origin, short *target, uint index, uint length) where T : unmanaged { if (typeof(T) == typeof(short)) { SSE2Helper.StoreLastElementsVector256((short *)origin, target, index, length); return; } if (!Sse41.IsSupported) { return; } PointerArithmetic.Increment(ref origin, ref target, index); uint count = length - index; StoreRemainingElements(8, ref origin, ref target, count); StoreLastElementsVector128(origin, target, 0, count);
static void StoreRemainingElements(uint remainder, ref T *origin, ref byte *target, uint count) { if ((count & remainder) > 0) { if (remainder == 1) { *target = *(byte *)origin; } else { if (typeof(T) == typeof(short)) { StoreRemainingInt16(remainder, origin, target); } if (typeof(T) == typeof(int)) { StoreRemainingInt32(remainder, origin, target); } } PointerArithmetic.Increment(ref origin, ref target, remainder); } }
public static void StoreLastElementsVector128 <T>(T *origin, T *target, uint index, uint length) where T : unmanaged { PointerArithmetic.Increment(ref origin, ref target, index); uint count = length - index; if (sizeof(T) <= sizeof(byte)) { StoreRemainingElements(ref origin, ref target, count, 8); } if (sizeof(T) <= sizeof(short)) { StoreRemainingElements(ref origin, ref target, count, 4); } if (sizeof(T) <= sizeof(int)) { StoreRemainingElements(ref origin, ref target, count, 2); } if (sizeof(T) <= sizeof(long)) { StoreRemainingElements(ref origin, ref target, count, 1); } }
static void StoreRemainingElements(uint remainder, ref T *origin, ref double *target, uint count) { if ((count & remainder) > 0) { if (typeof(T) == typeof(byte)) { *target = *(byte *)origin; } else if (typeof(T) == typeof(short)) { *target = *(short *)origin; } else if (typeof(T) == typeof(int)) { *target = *(int *)origin; } else if (typeof(T) == typeof(float)) { *target = *(float *)origin; } PointerArithmetic.Increment(ref origin, ref target, remainder); } }
public void IncrementUInt32() { ResetPointersForIncrementation(); PointerArithmetic.Increment(ref p1, ref p2, 2U); AssertPointerAdjustment(p1, 2); AssertPointerAdjustment(p2, 2); ResetPointersForIncrementation(); PointerArithmetic.Increment(ref p3, ref p4, 3U); AssertPointerAdjustment(p3, 3); AssertPointerAdjustment(p4, 3); ResetPointersForIncrementation(); PointerArithmetic.Increment(ref p5, ref p6, ref p7, 4U); AssertPointerAdjustment(p5, 4); AssertPointerAdjustment(p6, 4); AssertPointerAdjustment(p7, 4); ResetPointersForIncrementation(); PointerArithmetic.Increment(ref p1, ref p2, ref p3, ref p8, 1U); AssertPointerAdjustment(p1, 1); AssertPointerAdjustment(p2, 1); AssertPointerAdjustment(p3, 1); AssertPointerAdjustment(p8, 1); ResetPointersForIncrementation(); PointerArithmetic.Increment(ref p1, ref p2, ref p4, ref p5, ref p8, 1U); AssertPointerAdjustment(p1, 1); AssertPointerAdjustment(p2, 1); AssertPointerAdjustment(p4, 1); AssertPointerAdjustment(p5, 1); AssertPointerAdjustment(p8, 1); ResetPointersForIncrementation(); PointerArithmetic.Increment(ref p1, ref p2, ref p4, ref p6, ref p7, ref p8, 4U); AssertPointerAdjustment(p1, 4); AssertPointerAdjustment(p2, 4); AssertPointerAdjustment(p4, 4); AssertPointerAdjustment(p6, 4); AssertPointerAdjustment(p7, 4); AssertPointerAdjustment(p8, 4); ResetPointersForIncrementation(); PointerArithmetic.Increment(ref p1, ref p2, ref p3, ref p4, ref p5, ref p6, ref p7, 2U); AssertPointerAdjustment(p1, 2); AssertPointerAdjustment(p2, 2); AssertPointerAdjustment(p3, 2); AssertPointerAdjustment(p4, 2); AssertPointerAdjustment(p5, 2); AssertPointerAdjustment(p6, 2); AssertPointerAdjustment(p7, 2); ResetPointersForIncrementation(); PointerArithmetic.Increment(ref p1, ref p2, ref p3, ref p4, ref p5, ref p6, ref p7, ref p8, 3U); AssertPointerAdjustment(p1, 3); AssertPointerAdjustment(p2, 3); AssertPointerAdjustment(p3, 3); AssertPointerAdjustment(p4, 3); AssertPointerAdjustment(p5, 3); AssertPointerAdjustment(p6, 3); AssertPointerAdjustment(p7, 3); AssertPointerAdjustment(p8, 3); }
public void DecrementUInt64() { ResetPointersForDecrementation(); PointerArithmetic.Decrement(ref p1, ref p2, 2UL); AssertPointerAdjustment(p1, 8); AssertPointerAdjustment(p2, 8); ResetPointersForDecrementation(); PointerArithmetic.Decrement(ref p3, ref p4, 3UL); AssertPointerAdjustment(p3, 7); AssertPointerAdjustment(p4, 7); ResetPointersForDecrementation(); PointerArithmetic.Decrement(ref p5, ref p6, ref p7, 4UL); AssertPointerAdjustment(p5, 6); AssertPointerAdjustment(p6, 6); AssertPointerAdjustment(p7, 6); ResetPointersForDecrementation(); PointerArithmetic.Decrement(ref p1, ref p2, ref p3, ref p8, 1UL); AssertPointerAdjustment(p1, 9); AssertPointerAdjustment(p2, 9); AssertPointerAdjustment(p3, 9); AssertPointerAdjustment(p8, 9); ResetPointersForDecrementation(); PointerArithmetic.Decrement(ref p1, ref p2, ref p4, ref p5, ref p8, 1UL); AssertPointerAdjustment(p1, 9); AssertPointerAdjustment(p2, 9); AssertPointerAdjustment(p4, 9); AssertPointerAdjustment(p5, 9); AssertPointerAdjustment(p8, 9); ResetPointersForDecrementation(); PointerArithmetic.Decrement(ref p1, ref p2, ref p4, ref p6, ref p7, ref p8, 4UL); AssertPointerAdjustment(p1, 6); AssertPointerAdjustment(p2, 6); AssertPointerAdjustment(p4, 6); AssertPointerAdjustment(p6, 6); AssertPointerAdjustment(p7, 6); AssertPointerAdjustment(p8, 6); ResetPointersForDecrementation(); PointerArithmetic.Decrement(ref p1, ref p2, ref p3, ref p4, ref p5, ref p6, ref p7, 2UL); AssertPointerAdjustment(p1, 8); AssertPointerAdjustment(p2, 8); AssertPointerAdjustment(p3, 8); AssertPointerAdjustment(p4, 8); AssertPointerAdjustment(p5, 8); AssertPointerAdjustment(p6, 8); AssertPointerAdjustment(p7, 8); ResetPointersForDecrementation(); PointerArithmetic.Decrement(ref p1, ref p2, ref p3, ref p4, ref p5, ref p6, ref p7, ref p8, 3UL); AssertPointerAdjustment(p1, 7); AssertPointerAdjustment(p2, 7); AssertPointerAdjustment(p3, 7); AssertPointerAdjustment(p4, 7); AssertPointerAdjustment(p5, 7); AssertPointerAdjustment(p6, 7); AssertPointerAdjustment(p7, 7); AssertPointerAdjustment(p8, 7); }