Difference in encoding CELT media between AMD and Intel CPUs in floating-point mode
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 3.3k
- Forks
- 808
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
We recently made note of an issue where encoding CELT media in floating-point mode was giving slightly different results on AMD and Intel CPUs. The difference arose due to the use of _mm_rcp_ps and _mm_rsqrt_ps in op_pvq_search_sse2, see:
https://github.com/xiph/opus/blob/master/celt/x86/vq_sse2.c#L108
https://github.com/xiph/opus/blob/master/celt/x86/vq_sse2.c#L173
These intrinsics/instructions are defined to be approximations, and permitted to have slightly different implementations across CPUs. In order to better produce similar results for offline-generated media across different CPU architectures, it would be good to replace these with _mm_div_ps and _mm_sqrt_ps which have stricter definitions on their behaviour.
The following should be logically similar to the lines above, and harmonize the results across architectures:
For vq_sse2.c#L108:
rcp4 = _mm_mul_ps(_mm_set_ps1((float)(K+.8)), _mm_div_ps(_mm_set_ps1(1.f), sums));
And for vq_sse2.c#L173:
y4 = _mm_div_ps(_mm_set_ps1(1.f), _mm_sqrt_ps(y4));
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in celt/x86/vq_sse2.c at the two op_pvq_search_sse2 locations linked in the issue, and review how the reciprocal and reciprocal-square-root intrinsics are used. Replace the approximate operations as described, then verify that floating-point CELT encoding produces matching results on AMD and Intel CPUs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100