Skip to content

Commit b5a34b9

Browse files
committed
docs: add cpu-instruction-set-check code snippets
1 parent e1734ab commit b5a34b9

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
heading: 'CPU instruction set check'
3+
title: 'CPU instruction set che'
4+
date: '2024-01-10'
5+
icon: 'Bash'
6+
draft: false
7+
summary: 'How to use Linux scripts to detect CPU instruction sets.'
8+
tags: [Linux]
9+
---
10+
11+
```bash
12+
#!/bin/bash
13+
14+
# 2pc指令集
15+
two_pc="sse2 sse4.1 avx avx2"
16+
17+
# 3pc指令集
18+
three_pc="aes sse2 sse mmx"
19+
20+
# psi指令集
21+
psi="aes sse2 sse4.1 pclmul"
22+
23+
check_instruction() {
24+
missing_instr=""
25+
for instr in $1; do
26+
grep -q "^flags.*\b$instr\b" /proc/cpuinfo
27+
if [[ $? -ne 0 ]]; then
28+
# 添加缺少的指令集到列表
29+
missing_instr+="$instr "
30+
fi
31+
done
32+
33+
if [[ -n $missing_instr ]]; then
34+
echo "Missing instructions: $missing_instr"
35+
else
36+
echo "All instructions present."
37+
fi
38+
}
39+
40+
echo "Checking 2pc instructions..."
41+
check_instruction "$two_pc"
42+
43+
echo "Checking 3pc instructions..."
44+
check_instruction "$three_pc"
45+
46+
echo "Checking psi instructions..."
47+
check_instruction "$psi"
48+
```

json/tag-data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"windows":3,"nodejs":2,"gradle":1,"docker":2,"http":2,"vmware":1,"spring-boot":2,"xxl-job":1,"life":1,"java":8,"logback":2,"kubernetes":3,"linux":1,"maven":2,"nexus":1,"mac":1,"openssl":1,"sm2":1,"redis":1,"nginx":1,"jenkins":1,"git":2,"annotation":1,"mysql":1,"vue":1,"filter":1,"websocket":1,"network":1,"github":1,"ssh":1,"security":1,"spotify":1,"nowplaying":1,"spotify-api":1,"nextjs":1}
1+
{"windows":3,"nodejs":2,"gradle":1,"docker":2,"http":2,"vmware":1,"spring-boot":2,"xxl-job":1,"life":1,"java":8,"logback":2,"kubernetes":3,"linux":2,"maven":2,"nexus":1,"mac":1,"openssl":1,"sm2":1,"redis":1,"nginx":1,"jenkins":1,"git":2,"annotation":1,"mysql":1,"vue":1,"filter":1,"websocket":1,"network":1,"github":1,"ssh":1,"security":1,"spotify":1,"nowplaying":1,"spotify-api":1,"nextjs":1}

0 commit comments

Comments
 (0)