Skip to content
0.2.0-dev Download ZIP
20 lines ·629 B Raw
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2026 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7JPH_NAMESPACE_BEGIN
8
9/// Prefetch the given address to L1 cache. Can be used to avoid cache misses, but should be used with care as it can also cause cache pollution if used incorrectly.
10template <typename T>
11inline void PrefetchL1(const T *inAddress)
12{
13#ifdef JPH_USE_SSE
14 _mm_prefetch(reinterpret_cast<const char *>(inAddress), _MM_HINT_T0);
15#elif defined(JPH_COMPILER_GCC) || defined(JPH_COMPILER_CLANG)
16 __builtin_prefetch(inAddress, 0, 3);
17#endif
18}
19
20JPH_NAMESPACE_END