Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asm.hpp: fix usage of _mm_prefetch #14884

Merged
merged 1 commit into from Dec 11, 2023
Merged

Conversation

oltolm
Copy link
Contributor

@oltolm oltolm commented Dec 10, 2023

I'd like to try again to fix usage of _mm_prefetch.

prefetch_exec has the following comment.

	// Try to prefetch to Level 2 cache since it's not split to data/code on most processors
	template <typename T>
	constexpr void prefetch_exec(T func)

I changed the argument from 2 to _MM_HINT_T1.

// MSVC
#define _MM_HINT_T1     2
// GCC/Clang
  _MM_HINT_T1 = 2,

As you can see there was no change. T1 is also correct:

T1 (temporal data with respect to first level cache misses)—prefetch data into level 2 cache and higher.

prefetch_read has the following comment

	// Try to prefetch to Level 1 cache
	constexpr void prefetch_read(const void* ptr)

I changed 3 to _MM_HINT_T0.

// MSVC
#define _MM_HINT_T0     1
// GCC/Clang
  _MM_HINT_T0 = 3,

As you can see there is no change on Clang/GCC, but there is a change on MSVC. I think that this is correct:

T0 (temporal data)—prefetch data into all levels of the cache hierarchy.

The way it is now it is prefetched into level 3 and higher on MSVC:

#define _MM_HINT_T2     3

T2 (temporal data with respect to second level cache misses)—prefetch data into level 3 cache and higher, or an implementation-specific choice.

@elad335 elad335 merged commit cb4a688 into RPCS3:master Dec 11, 2023
4 of 6 checks passed
@oltolm oltolm deleted the mm_prefetch_fix branch December 11, 2023 16:16
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.

None yet

2 participants