Skip to content

Commit cc5d11e

Browse files
Merge pull request #5121 from MicrosoftDocs/main638669467113340238sync_temp
For protected branch, push strategy should use PR and merge to target branch method to work around git push error
2 parents 9ea45bc + e79160b commit cc5d11e

File tree

7 files changed

+154
-3
lines changed

7 files changed

+154
-3
lines changed

docs/build/reference/arch-x64.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Enables Intel Advanced Vector Extensions 10 version 1.
3535

3636
## Remarks
3737

38-
The **`/arch`** option enables the use of certain instruction set extensions, particularly for vector calculation, available in processors from Intel and AMD. In general, more recently introduced processors may support extensions beyond the ones supported by older processors, although you should consult the documentation for a particular processor or test for instruction set extension support using [`__cpuid`](../../intrinsics/cpuid-cpuidex.md) before executing code using an instruction set extension.
38+
The **`/arch`** option enables the use of certain instruction set extensions, particularly for vector calculation, available in processors from Intel and AMD. In general, more recently introduced processors may support extensions beyond the ones supported by older processors, although you should consult the documentation for a particular processor or test for instruction set extension support using [`__cpuid`](../../intrinsics/cpuid-cpuidex.md) before executing code using an instruction set extension. You can also use the [`__check_isa_support`](../../intrinsics/check-isa-arch-support.md) intrinsic to check for more frequently used CPU features.
3939

4040
**`/arch`** only affects code generation for native functions. When you use [`/clr`](clr-common-language-runtime-compilation.md) to compile, **`/arch`** has no effect on code generation for managed functions.
4141

docs/build/reference/arch-x86.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Enables Intel Advanced Vector Extensions 10 version 1.
3838

3939
## Remarks
4040

41-
The **`/arch`** option enables or disables the use of certain instruction set extensions, particularly for vector calculation, available in processors from Intel and AMD. In general, more recently introduced processors may support extensions beyond the ones supported by older processors. You should consult the documentation for a particular processor or test for instruction set extension support using [`__cpuid`](../../intrinsics/cpuid-cpuidex.md) before executing code using an instruction set extension.
41+
The **`/arch`** option enables or disables the use of certain instruction set extensions, particularly for vector calculation, available in processors from Intel and AMD. In general, more recently introduced processors may support extensions beyond the ones supported by older processors. You should consult the documentation for a particular processor or test for instruction set extension support using [`__cpuid`](../../intrinsics/cpuid-cpuidex.md) before executing code using an instruction set extension. You can also use the [`__check_isa_support`](../../intrinsics/check-isa-arch-support.md) intrinsic to check for more frequently used CPU features.
4242

4343
**`/arch`** only affects code generation for native functions. When you use [`/clr`](clr-common-language-runtime-compilation.md) to compile, **`/arch`** has no effect on code generation for managed functions.
4444

docs/intrinsics/alphabetical-listing-of-intrinsic-functions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.assetid: 178f88a2-7e8e-43ac-b55e-ef3298bef895
77
---
88
# Alphabetical listing of intrinsic functions
99

10-
The following sections describe the Microsoft-specific intrinsic functions available on some or all architectures. Other supported intrinsics are documented by processor manufacturers, either in the header files or on their websites. For more information, and links to manufacturer documentation, see these articles: [ARM intrinsics](../intrinsics/arm-intrinsics.md), [ARM64 intrinsics](../intrinsics/arm64-intrinsics.md), [x86 intrinsics](../intrinsics/x86-intrinsics-list.md), and [x64 intrinsics](../intrinsics/x64-amd64-intrinsics-list.md). C Runtime Library (CRT) functions implemented as intrinsics aren't documented here. CRT intrinsic functions are documented in the [C Runtime Library Reference](../c-runtime-library/c-run-time-library-reference.md).
10+
The following sections describe the Microsoft-specific intrinsic functions available on some or all architectures. Processor manufacturers document other supported intrinsics, either in the header files or on their websites. For more information, and links to manufacturer documentation, see these articles: [ARM intrinsics](../intrinsics/arm-intrinsics.md), [ARM64 intrinsics](../intrinsics/arm64-intrinsics.md), [x86 intrinsics](../intrinsics/x86-intrinsics-list.md), and [x64 intrinsics](../intrinsics/x64-amd64-intrinsics-list.md). C Runtime Library (CRT) functions implemented as intrinsics aren't documented here. CRT intrinsic functions are documented in the [C Runtime Library Reference](../c-runtime-library/c-run-time-library-reference.md).
1111

1212
[`__addfsbyte`, `__addfsword`, `__addfsdword`](../intrinsics/addfsbyte-addfsword-addfsdword.md)
1313

@@ -29,6 +29,8 @@ The following sections describe the Microsoft-specific intrinsic functions avail
2929

3030
[`_bittestandset`, `_bittestandset64`](../intrinsics/bittestandset-bittestandset64.md)
3131

32+
[`__check_isa_support`, `__check_arch_support`](../intrinsics/check-isa-arch-support.md)
33+
3234
[`__cpuid`, `__cpuidex`](../intrinsics/cpuid-cpuidex.md)
3335

3436
[`_cvt_ftoi_fast`, `_cvt_ftoll_fast`, `_cvt_ftoui_fast`, `_cvt_ftoull_fast`, `_cvt_dtoi_fast`, `_cvt_dtoll_fast`, `_cvt_dtoui_fast`, `_cvt_dtoull_fast`](../intrinsics/fast-conversion-functions.md)
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
description: "Learn more about: __check_isa_support, __check_arch_support"
3+
title: "__check_isa_support, __check_arch_support"
4+
ms.date: "11/07/2024"
5+
f1_keywords: ["__check_isa_support", "__check_arch_support"]
6+
helpviewer_keywords: ["__check_isa_support intrinsic", "__check_arch_support intrinsic"]
7+
---
8+
# __check_isa_support, __check_arch_support
9+
10+
**Microsoft Specific**
11+
12+
`__check_isa_support` - detects if the processor supports the specified ISA feature and AVX10 version at run time.
13+
`__check_arch_support` - detects if the arch flag (see [`/arch` (x86)](..\build\reference\arch-x86.md), [`/arch` (x64)](..\build\reference\arch-x64.md)) supports the specified ISA feature and AVX10 version at compile time.
14+
15+
## Syntax
16+
17+
```C
18+
_Bool __check_isa_support(
19+
unsigned feature,
20+
unsigned avx10_version
21+
);
22+
23+
_Bool __check_arch_support(
24+
unsigned feature,
25+
unsigned avx10_version
26+
);
27+
```
28+
29+
```cpp
30+
bool __check_isa_support(
31+
unsigned feature,
32+
unsigned avx10_version
33+
);
34+
35+
bool __check_arch_support(
36+
unsigned feature,
37+
unsigned avx10_version
38+
);
39+
```
40+
41+
### Parameters
42+
43+
*feature*\
44+
[in] ISA feature to check.
45+
46+
*avx10_version*\
47+
[in] AVX10 version to check. 0 if AVX10 version check isn't required.
48+
49+
## Return value
50+
51+
`__check_isa_support` returns `true` if the processor supports `feature` and `avx10_version` at run time, `false` otherwise.
52+
`__check_arch_support` returns `true` if the `/arch` flag supports `feature` and `avx10_version` at compile time, `false` otherwise.
53+
54+
## Requirements
55+
56+
|Intrinsic|Architecture|
57+
|---------------|------------------|
58+
|`__check_isa_support`|x86, x64|
59+
|`__check_arch_support`|x86, x64|
60+
61+
**Header file** `<immintrin.h>`
62+
63+
## Remarks
64+
65+
The `__check_isa_support` intrinsic provides a faster alternative to the [`__cpuid`](cpuid-cpuidex.md) intrinsic to dynamically check for most frequently used CPU features. The `__check_arch_support` intrinsic provides an alternative to the [`predefined macros`](..\preprocessor\predefined-macros.md) for compile time code selection based on ISA extensions.
66+
67+
The following feature values can be used in these intrinsics. These values are defined in `isa_availability.h`.
68+
69+
|Feature Value Name|Description|
70+
|---------------|------------------|
71+
|`__IA_SUPPORT_VECTOR128`|Vector instructions with lengths up to 128 bits. This feature is enabled for SSE2 or later extensions|
72+
|`__IA_SUPPORT_VECTOR256`|Vector instructions with lengths up to 256 bits. This feature is enabled for AVX2 or later extensions|
73+
|`__IA_SUPPORT_VECTOR512`|Vector instructions with lengths up to 512 bits. This feature is enabled for AVX-512 or later extensions|
74+
|`__IA_SUPPORT_AVX10`|AVX10 support. This feature is enabled for AVX10.1 or later extensions|
75+
|`__IA_SUPPORT_SSE42`|SSE4.2 support|
76+
|`__IA_SUPPORT_SV128X`|AVX-512 instructions for scalar of 128 bits. Can be used to signal that certain useful AVX-512 instruction like conversions can be used in scalar code|
77+
|`__IA_SUPPORT_AVX10_2`|AVX10.2 support|
78+
|`__IA_SUPPORT_APX`|APX support|
79+
|`__IA_SUPPORT_FP16`|Half-precision floating-point instruction support|
80+
81+
Multiple feature values can be combined using the OR(|) operator.
82+
83+
The `__check_arch_support` intrinsic can always be evaluated at compile time, so using it in optimized code adds no extra instructions to execute.
84+
Support for these intrinsics was added in Visual Studio 2022 version 17.10.
85+
86+
## Example
87+
88+
This example uses 256-bit AVX-512 instructions to vectorize conversion of double-precision values to 64-bit signed integer values. The tail loop for converting any source values not handled by the vector code is also used in case the vector code can't be executed. The compile-time support is checked before runtime support so that a runtime check can be avoided if possible.
89+
90+
```cpp
91+
// Compile this test with: /EHsc /O2
92+
#include <iostream>
93+
#include <vector>
94+
#include <immintrin.h>
95+
#include <isa_availability.h>
96+
using namespace std;
97+
98+
#define CHECK_INSTRUCTION_SUPPORT(a,v) \
99+
(__check_arch_support((a),(v)) || __check_isa_support((a),(v)))
100+
101+
int main()
102+
{
103+
vector<double> input = {0.3, 1.4, 2.5, 3.6, 4.7, 5.8, 6.9, 8.0, 9.1, 11.14};
104+
vector<__int64> output(10, 0);
105+
int i = 0;
106+
107+
if (CHECK_INSTRUCTION_SUPPORT(__IA_SUPPORT_SV128X | __IA_SUPPORT_VECTOR256, 0))
108+
{
109+
for (; i < input.size() - 4; i += 4)
110+
{
111+
__m256i values = _mm256_cvttpd_epi64(_mm256_load_pd(&input[i]));
112+
_mm256_storeu_epi64((void*)&output[i], values);
113+
}
114+
}
115+
for (; i < input.size(); i++)
116+
{
117+
output[i] = input[i];
118+
}
119+
120+
for (i = 0; i < output.size(); i++) {
121+
cout << "output[" << i << "] = " << output[i] << endl;
122+
}
123+
}
124+
```
125+
126+
```Output
127+
output[0] = 0
128+
output[1] = 1
129+
output[2] = 2
130+
output[3] = 3
131+
output[4] = 4
132+
output[5] = 5
133+
output[6] = 6
134+
output[7] = 8
135+
output[8] = 9
136+
output[9] = 11
137+
```
138+
139+
**END Microsoft Specific**
140+
141+
## See also
142+
143+
[Compiler intrinsics](../intrinsics/compiler-intrinsics.md)

docs/intrinsics/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ items:
3939
href: ../intrinsics/bittestandreset-bittestandreset64.md
4040
- name: _bittestandset, _bittestandset64
4141
href: ../intrinsics/bittestandset-bittestandset64.md
42+
- name: __check_isa_support, __check_arch_support
43+
href: ../intrinsics/check-isa-arch-support.md
4244
- name: __cpuid, __cpuidex
4345
href: ../intrinsics/cpuid-cpuidex.md
4446
- name: __debugbreak

docs/intrinsics/x64-amd64-intrinsics-list.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ The following table lists the intrinsics available on x64 processors. The Techno
8484
| [`_castf64_u64`](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_castf64_u64) | | immintrin.h | `unsigned __int64 _castf64_u64 (double);` |
8585
| [`_castu32_f32`](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_castu32_f32) | | immintrin.h | `float _castu32_f32 (unsigned __int32);` |
8686
| [`_castu64_f64`](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_castu64_f64) | | immintrin.h | `double _castu64_f64 (unsigned __int64 a);` |
87+
| [`__check_isa_support`](check-isa-arch-support.md) | | immintrin.h | `bool __check_isa_support(unsigned int, unsigned int);` |
88+
| [`__check_arch_support`](check-isa-arch-support.md) | | immintrin.h | `bool __check_arch_support(unsigned int, unsigned int);` |
8789
| `_clac` | SMAP | intrin.h | `void _clac(void);` |
8890
| [`__cpuid`](cpuid-cpuidex.md) | | intrin.h | `void __cpuid(int *, int);` |
8991
| [`__cpuidex`](cpuid-cpuidex.md) | | intrin.h | `void __cpuidex(int *, int, int);` |

docs/intrinsics/x86-intrinsics-list.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ The following table lists the intrinsics available on x86 processors. The Techno
6161
| [`_castf64_u64`](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_castf64_u64) | | immintrin.h | `unsigned __int64 _castf64_u64 (double);` |
6262
| [`_castu32_f32`](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_castu32_f32) | | immintrin.h | `float _castu32_f32 (unsigned __int32);` |
6363
| [`_castu64_f64`](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_castu64_f64) | | immintrin.h | `double _castu64_f64 (unsigned __int64 a);` |
64+
| [`__check_isa_support`](check-isa-arch-support.md) | | immintrin.h | `bool __check_isa_support(unsigned int, unsigned int);` |
65+
| [`__check_arch_support`](check-isa-arch-support.md) | | immintrin.h | `bool __check_arch_support(unsigned int, unsigned int);` |
6466
| `_clac` | SMAP | intrin.h | `void _clac(void);` |
6567
| [`__cpuid`](cpuid-cpuidex.md) | | intrin.h | `void __cpuid(int *, int);` |
6668
| [`__cpuidex`](cpuid-cpuidex.md) | | intrin.h | `void __cpuidex(int *, int, int);` |

0 commit comments

Comments
 (0)