-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Milestone
Description
The new Intel Intrinsic APIs (dotnet/corefx#23489) follow the convention of using the suffix Aligned for methods that require alignment. E.g.:
public static unsafe Vector256<byte> Load(byte* address)
public static unsafe Vector256<byte> LoadAligned(byte* address)The System.Runtime.CompilerServices.Unsafe class currently does the opposite. E.g.:
public unsafe static T Read<T>(void* source)
public unsafe static T ReadUnaligned<T>(void* source)Should the Unsafe class switch?
Benefit: ease of use. Methods without a suffix feel like the "default"; methods with a suffix feel like special cases that can be ignored most of the time. Unaligned access is a much better default than aligned access.
public static partial class Unsafe
{
public static ref T AddByteOffset<T>(ref T source, System.IntPtr byteOffset)
public static ref T Add<T>(ref T source, int elementOffset)
public static void* Add<T>(void* source, int elementOffset)
public static ref T Add<T>(ref T source, System.IntPtr elementOffset)
public static bool AreSame<T>(ref T left, ref T right)
public static void* AsPointer<T>(ref T value)
public static ref T AsRef<T>(void* source)
public static T As<T>(object o) where T : class
public static ref TTo As<TFrom, TTo>(ref TFrom source)
public static System.IntPtr ByteOffset<T>(ref T origin, ref T target)
- public static void CopyBlock(ref byte destination, ref byte source, uint byteCount)
- public static void CopyBlock(void* destination, void* source, uint byteCount)
+ public static void CopyBlockAligned(ref byte destination, ref byte source, uint byteCount)
+ public static void CopyBlockAligned(void* destination, void* source, uint byteCount)
- public static void CopyBlockUnaligned(ref byte destination, ref byte source, uint byteCount)
- public static void CopyBlockUnaligned(void* destination, void* source, uint byteCount)
+ public static void CopyBlock(ref byte destination, ref byte source, uint byteCount)
+ public static void CopyBlock(void* destination, void* source, uint byteCount)
public static void Copy<T>(void* destination, ref T source)
public static void Copy<T>(ref T destination, void* source)
- public static void InitBlock(ref byte startAddress, byte value, uint byteCount)
- public static void InitBlock(void* startAddress, byte value, uint byteCount)
+ public static void InitBlockAligned(ref byte startAddress, byte value, uint byteCount)
+ public static void InitBlockAligned(void* startAddress, byte value, uint byteCount)
- public static void InitBlockUnaligned(ref byte startAddress, byte value, uint byteCount)
- public static void InitBlockUnaligned(void* startAddress, byte value, uint byteCount)
+ public static void InitBlock(ref byte startAddress, byte value, uint byteCount)
+ public static void InitBlock(void* startAddress, byte value, uint byteCount)
- public static T Read<T>(void* source)
+ public static T ReadAligned<T>(void* source)
- public static T ReadUnaligned<T>(void* source)
- public static T ReadUnaligned<T>(ref byte source)
+ public static T Read<T>(void* source)
+ public static T Read<T>(ref byte source)
public static int SizeOf<T>()
public static ref T SubtractByteOffset<T>(ref T source, System.IntPtr byteOffset)
public static ref T Subtract<T>(ref T source, int elementOffset)
public static void* Subtract<T>(void* source, int elementOffset)
public static ref T Subtract<T>(ref T source, System.IntPtr elementOffset)
- public static void Write<T>(void* destination, T value)
+ public static void WriteAligned<T>(void* destination, T value)
- public static void WriteUnaligned<T>(void* destination, T value)
- public static void WriteUnaligned<T>(ref byte destination, T value)
+ public static void Write<T>(void* destination, T value)
+ public static void Write<T>(ref byte destination, T value)
}Reactions are currently unavailable