是否可以在 Fortran 中找到向量处理器的最大向量长度?

Is it possible to find the max vector length of the vector processor in Fortran?

是否可以在 Fortran 中测试处理器是否是矢量处理器并找出矢量的最大长度?

我检查了下面列出的 cpuinfo

processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 63
model name  : Intel(R) Xeon(R) CPU E5-2697 v3 @ 2.60GHz
stepping    : 2
microcode   : 0x27
cpu MHz     : 1201.078
cache size  : 17920 KB
physical id : 0
siblings    : 7
core id     : 0
cpu cores   : 7
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 15
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid
bogomips    : 5200.36
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

不,答案是指令集标志,在你的情况下 avx2, sse4_1, sse4_2,你真的应该研究它们的意思 https://en.wikipedia.org/wiki/SSE4 https://en.wikipedia.org/wiki/Advanced_Vector_Extensions

相同的 CPU 具有不同的矢量指令,具有不同的功能。没有定义长度的单个向量单元。每个可能的指令集和每个数据类型(概念上)都有一个。例如,从 Wikipedia:

SSE used only a single data type for XMM registers:

four 32-bit single-precision floating point numbers

SSE2 would later expand the usage of the XMM registers to include:

two 64-bit double-precision floating point numbers or
two 64-bit integers or
four 32-bit integers or
eight 16-bit short integers or
sixteen 8-bit bytes or characters.

AVX 和 AVX2 添加了 256 位操作,但这取决于您需要的特定操作是否在支持的操作中,或者您需要使用 SSE(2)。