Skip to content

crc: avoid VPTERNLOGQ on Hygon in crc32_iscsi_by16_10#403

Open
MaodiMa wants to merge 1 commit intointel:masterfrom
MaodiMa:crc32c_avx512_vpternlogq
Open

crc: avoid VPTERNLOGQ on Hygon in crc32_iscsi_by16_10#403
MaodiMa wants to merge 1 commit intointel:masterfrom
MaodiMa:crc32c_avx512_vpternlogq

Conversation

@MaodiMa
Copy link
Copy Markdown
Contributor

@MaodiMa MaodiMa commented Mar 26, 2026

Disable VPTERNLOGQ instruction in crc32_iscsi_by16_10 on Hygon CPU.

Using VPTERNLOGQ in this case leads to an uarch bottleneck on current Hygon CPU and does not perform ideally. So we would like to use VPXORQ instead. This will leads to ~53.5% speedup according to make perf :

original bandwidth (MB/s) opt speedup
Hygon 49643.52 76193.92 53.5%

Modification only takes effect on Hygon CPU, based on the result of cpuinfo check.

Disable VPTERNLOGQ based on platform check, as it reduces IPC on
Hygon CPUs.

Signed-off-by: Maodi Ma <mamaodi@hygon.cn>
vpclmulqdq zmm1, zmm0, zmm16, 0x10
vpclmulqdq zmm0, zmm0, zmm16, 0x01
vpternlogq zmm0, zmm1, [arg2+16*0], 0x96
TERNARY_XOR zmm0, zmm1, [arg2+16*0]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works but it is code intrusive and I think it would be better to do it through macro only

vpternlogq %1, %2, %3, 0x96
%endif
%endmacro

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about having a macro like this? this should not need more code changes

%ifdef NO_VPTERNLOGQ
%macro vpternlogq 4
%if %4 == 0x96
vpxorq %1, %1, %2
vpxorq %1, %1, %3
%endif
%endmacro
%endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants