AVX: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
Created page with "{{stub}} '''Advanced Vector Extensions''' is a '''SIMD''' (Single Instruction, Multiple Data) instruction set introduced by Intel in 2011. == OS Support == AVX need to be e..." |
No edit summary |
||
Line 14: | Line 14: | ||
<source lang="asm"> |
<source lang="asm"> |
||
enable_avx: |
enable_avx: |
||
push rax |
push rax |
||
push rbx |
push rbx |
||
push rcx |
push rcx |
||
push rdx |
push rdx |
||
mov rax, cr0 |
mov rax, cr0 |
||
and ax, 0xFFFB |
and ax, 0xFFFB |
||
or ax, 0x2 |
or ax, 0x2 |
||
mov cr0, rax |
mov cr0, rax |
||
mov rax, cr4 |
mov rax, cr4 |
||
or ax, 3 << 9 |
or ax, 3 << 9 |
||
or eax, 1 << 18 |
or eax, 1 << 18 |
Revision as of 16:23, 6 January 2017
This page is a stub.
You can help the wiki by accurately adding more contents to it.
Advanced Vector Extensions is a SIMD (Single Instruction, Multiple Data) instruction set introduced by Intel in 2011.
OS Support
AVX need to be enabled by the kernel before being used. Forgetting to do this will raise an #UD on the first AVX call. Both SSE and OSXSAVE must be enabled before allowing. Failing to do so will also produce an #UD.
AVX is enabled by setting bit 2 of the XCR0 register. Bit 1 of XCR0 must also be set (indicating SSE support).
Here is an example of assembly code enabling SSE and AVX :
enable_avx:
push rax
push rbx
push rcx
push rdx
mov rax, cr0
and ax, 0xFFFB
or ax, 0x2
mov cr0, rax
mov rax, cr4
or ax, 3 << 9
or eax, 1 << 18
mov cr4, rax
xor rcx, rcx
xgetbv
or eax, 7
xsetbv
pop rdx
pop rcx
pop rbx
pop rax
ret