forked from tensorflow/tensorflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprefetch.h
More file actions
57 lines (47 loc) · 1.91 KB
/
Copy pathprefetch.h
File metadata and controls
57 lines (47 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_PLATFORM_PREFETCH_H_
#define TENSORFLOW_PLATFORM_PREFETCH_H_
#include "tensorflow/core/platform/platform.h"
namespace tensorflow {
namespace port {
// Prefetching support
//
// Defined behavior on some of the uarchs:
// PREFETCH_HINT_T0:
// prefetch to all levels of the hierarchy (except on p4: prefetch to L2)
// PREFETCH_HINT_NTA:
// p4: fetch to L2, but limit to 1 way (out of the 8 ways)
// core: skip L2, go directly to L1
// k8 rev E and later: skip L2, can go to either of the 2-ways in L1
enum PrefetchHint {
PREFETCH_HINT_T0 = 3, // More temporal locality
PREFETCH_HINT_T1 = 2,
PREFETCH_HINT_T2 = 1, // Less temporal locality
PREFETCH_HINT_NTA = 0 // No temporal locality
};
template <PrefetchHint hint>
void prefetch(const void* x);
// ---------------------------------------------------------------------------
// Inline implementation
// ---------------------------------------------------------------------------
template <PrefetchHint hint>
inline void prefetch(const void* x) {
#if defined(__llvm__) || defined(COMPILER_GCC)
__builtin_prefetch(x, 0, hint);
#else
// You get no effect. Feel free to add more sections above.
#endif
}
} // namespace port
} // namespace tensorflow
#endif // TENSORFLOW_PLATFORM_PREFETCH_H_