Click or drag to resize
Ab4d.SharpEngine logo

MemoryUtils Class

MemoryUtils is a static class that contains methods and property that can be used to perform advanced memory copy operations by using AVX2 NonTemporal instructions. Do disable AVX2 NonTemporal, set the static UseAdvancedMemoryCopyInstructions to false.
Inheritance Hierarchy
SystemObject
  Ab4d.SharpEngine.UtilitiesMemoryUtils

Namespace: Ab4d.SharpEngine.Utilities
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 1.0.8740+deb2991acfe86a95cca780cd4f82bcae2805c1a5
Syntax
C#
public static class MemoryUtils

The MemoryUtils type exposes the following members.

Properties
 NameDescription
Public propertyStatic memberIsCopyMemoryNonTemporalSupported 
Public propertyStatic memberUseAdvancedMemoryCopyInstructions Static nullable Boolean field that specifies if advanced NonTemporal AVX copy is used to copy textures from the GPU memory to the main CPU memory. This can be very beneficial when Intel GPU is used. If this value is not set by the user and if AVX2 instructions are supported by the CPU, then on first copy a benchmark is used to determine if NonTemporal AVX copy is significantly faster than normal memory copy. This benchmark also sets a value to this property.
Top
Methods
 NameDescription
Public methodStatic memberAlignPtrTo32 Aligns the specified pointer to 32 bytes (if not already aligned then the ptr address is increased to the next aligned address). The method returns the addressOffset (if more than 0 then the ptr address is increased that offset).
Public methodStatic memberAlignValueTo32 Aligns the specified value to 32 bytes (if not already aligned then the value is increased to the next aligned value). The method returns the valueOffset (if more than 0 then the value was increased by that offset).
Public methodStatic memberCopy(IntPtr, IntPtr, Int32) Copy memory size bytes from source to destination. This method can also set the if it was not set before.
Public methodStatic memberCopy(IntPtr, IntPtr, Int32, Byte) Copy memory size bytes from source to destination. In case the destination is not aligned to 32, the tempByteArray may be used / created as a temporary storage. This method can also set the if it was not set before.
Public methodStatic memberCopyMemoryNonTemporalAvx When source and destination are aligned to 32, then non-temporal avx copy was performed.
Public methodStatic memberCopyToArray Copies the size bytes from the source to the destinationArray. When source is aligned to 32, then non-temporal avx copy was performed. When destination array is not aligned to 32, then it can be resized and destinationArrayOffset is set to the offset when the data start.
Public methodStatic memberIsAlignedTo32 Returns true when the specified memory address is aligned to 32.
Top
See Also