Coverage Report

Created: 2025-12-01 15:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/contrib/faiss/faiss/utils/prefetch.h
Line
Count
Source
1
/*
2
 * Copyright (c) Meta Platforms, Inc. and affiliates.
3
 *
4
 * This source code is licensed under the MIT license found in the
5
 * LICENSE file in the root directory of this source tree.
6
 */
7
8
#pragma once
9
10
// prefetches
11
12
#ifdef __AVX__
13
14
// AVX
15
16
#include <xmmintrin.h>
17
18
0
inline void prefetch_L1(const void* address) {
19
0
    _mm_prefetch((const char*)address, _MM_HINT_T0);
20
0
}
21
130k
inline void prefetch_L2(const void* address) {
22
130k
    _mm_prefetch((const char*)address, _MM_HINT_T1);
23
130k
}
24
0
inline void prefetch_L3(const void* address) {
25
0
    _mm_prefetch((const char*)address, _MM_HINT_T2);
26
0
}
27
28
#elif defined(__aarch64__)
29
30
// ARM64
31
32
#ifdef _MSC_VER
33
34
// todo: arm on MSVC
35
inline void prefetch_L1(const void* address) {}
36
inline void prefetch_L2(const void* address) {}
37
inline void prefetch_L3(const void* address) {}
38
39
#else
40
// arm on non-MSVC
41
42
inline void prefetch_L1(const void* address) {
43
    __builtin_prefetch(address, 0, 3);
44
}
45
inline void prefetch_L2(const void* address) {
46
    __builtin_prefetch(address, 0, 2);
47
}
48
inline void prefetch_L3(const void* address) {
49
    __builtin_prefetch(address, 0, 1);
50
}
51
#endif
52
53
#else
54
55
// a generic platform
56
57
#ifdef _MSC_VER
58
59
inline void prefetch_L1(const void* address) {}
60
inline void prefetch_L2(const void* address) {}
61
inline void prefetch_L3(const void* address) {}
62
63
#else
64
65
inline void prefetch_L1(const void* address) {
66
    __builtin_prefetch(address, 0, 3);
67
}
68
inline void prefetch_L2(const void* address) {
69
    __builtin_prefetch(address, 0, 2);
70
}
71
inline void prefetch_L3(const void* address) {
72
    __builtin_prefetch(address, 0, 1);
73
}
74
75
#endif
76
77
#endif