-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport_supported_x86_64_micro_arch.yaml
62 lines (54 loc) · 2.41 KB
/
report_supported_x86_64_micro_arch.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
- name: Determine which x86-64 micro-architecture level is supported on each host
hosts:
- all
gather_facts: true
gather_subset:
- platform
vars:
micro_arch_requirements:
# https://gitlab.com/x86-psABIs/x86-64-ABI/-/blob/d725a37222da8468dd37564f40005138449621d8/x86-64-ABI/low-level-sys-info.tex#L14-57
# as well as the unofficial `x86-64-v2-aes` ("v2.5") which is `x86-64-v2` plus `aes`
x86-64: ['cmov', 'cx8', 'fpu', 'fxsr', 'mmx', 'sse', 'sse2', 'syscall']
x86-64-v2: ['cx16', 'lahf_lm', 'popcnt', 'sse4_1', 'sse4_2', 'ssse3']
x86-64-v2-aes: ['aes', 'cx16', 'lahf_lm', 'popcnt', 'sse4_1', 'sse4_2', 'ssse3']
x86-64-v3: ['abm', 'avx', 'avx2', 'bmi1', 'bmi2', 'f16c', 'fma', 'movbe', 'xsave']
x86-64-v4: ['avx512bw', 'avx512cd', 'avx512dq', 'avx512f', 'avx512vl']
pre_tasks:
- name: Proceed on Linux systems with x86_64 machine architecture only
ansible.builtin.meta: end_host
when:
- ansible_facts['system'] not in ['Linux'] or
ansible_facts['machine'] not in ['x86_64']
tasks:
- name: Load all CPU flags from /proc/cpuinfo
ansible.builtin.command:
cmd: >-
env LC_ALL=C grep -Po '^flags\s*:\s\K.*' /proc/cpuinfo
register: all_cpu_flags
changed_when: false
check_mode: false
- name: Generate distinct list of supported CPU flags
ansible.builtin.set_fact:
supported_cpu_flags: "{{ all_cpu_flags['stdout_lines'] | join | split(' ') | sort | unique }}"
- name: Check for required CPU flags of each micro architecture
ansible.builtin.set_fact:
supported_micro_archs: "{{ supported_micro_archs | d({}) | combine({inventory_hostname: {_micro_arch: _is_supported}}, recursive=true) }}"
vars:
_micro_arch: "{{ item[0] }}"
_required_flags: "{{ item[1] }}"
_is_supported: "{{ _required_flags | difference(supported_cpu_flags) | length == 0 | bool }}"
loop: "{{ micro_arch_requirements | dictsort }}"
loop_control:
label: "{{ _micro_arch }}"
- name: Report results
ansible.builtin.debug:
msg: |-
{{ supported_micro_archs }}
- name: Prepare Ansible statistics reporting if enabled
ansible.builtin.set_stats:
data:
supported_micro_archs: "{{ supported_micro_archs }}"
aggregate: true
when:
- lookup('ansible.builtin.config', 'SHOW_CUSTOM_STATS') | bool