As indicated, SQL Server 2016 added the use of SSE and AVX instructions in various code paths to improve performance. The inquiries have centered around the support boundaries of the SSE and AVX instructions. This post will outline SQL Server’s decisions around SSE/AVX or software algorithm use.

SSE/AVX

SQL Server asks the CPU if it supports SSE or AVX in order to determine the level of hardware support present on the system. The SOS layer added helper functions which invoke the CPUID instruction to determine the level of support. The CPU support intrinsic __cpuidex is called to retrieve instruction set support information. Based on the returned information the type of support is determined.

For AVX/AVX2 the CPU must also indicate that bit 6 is enabled from the _xgetbv call, _XCR_XFEATURE_ENABLED_MASK lookup.

For Row Bucketing in Column Store

If AVX2 or AVX use AVX

Else If SSE42 or below use SSE

Else use Software algorithms

Bulk Import

SSE4 and Below – Use SSE for seeking delimiters and string to integer conversions

Numeric from String

Any string to numeric conversion.

SSE4 and Below – Use SSE for converting strings to numeric values

Encryption

The use of on-board encryption and possible SSE/AVX usage is all determined by Windows. Windows 2012 R2 and newer releases have been enlightened the Crypto* APIs. Version of SQL Server 2012, 2014, and 2016 using the Crypto* APIs take advantage of the hardware implementations through the API support. Reference APIs such as: CryptDecrypt