OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

prefetch.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2004-2006 The Regents of the University of California.
3 * All rights reserved.
4 * $COPYRIGHT$
5 *
6 * Additional copyrights may follow
7 *
8 * $HEADER$
9 */
10
11 /** @file
12 *
13 * Compiler-specific prefetch functions
14 *
15 * A small set of prefetch / prediction interfaces for using compiler
16 * directives to improve memory prefetching and branch prediction
17 */
18
19 #ifndef OPAL_PREFETCH_H
20 #define OPAL_PREFETCH_H
21
22 #if defined(c_plusplus) || defined(__cplusplus)
23 /* C++ code */
24
25 #if OMPI_CXX_HAVE_BUILTIN_EXPECT
26 #define OPAL_LIKELY(expression) __builtin_expect(!!(expression), 1)
27 #define OPAL_UNLIKELY(expression) __builtin_expect(!!(expression), 0)
28 #else
29 #define OPAL_LIKELY(expression) (expression)
30 #define OPAL_UNLIKELY(expression) (expression)
31 #endif
32
33 #if OMPI_CXX_HAVE_BUILTIN_PREFETCH
34 #define OPAL_PREFETCH(address,rw,locality) __builtin_prefetch(address,rw,locality)
35 #else
36 #define OPAL_PREFETCH(address,rw,locality)
37 #endif
38
39 #else
40 /* C code */
41
42 #if OPAL_C_HAVE_BUILTIN_EXPECT
43 #define OPAL_LIKELY(expression) __builtin_expect(!!(expression), 1)
44 #define OPAL_UNLIKELY(expression) __builtin_expect(!!(expression), 0)
45 #else
46 #define OPAL_LIKELY(expression) (expression)
47 #define OPAL_UNLIKELY(expression) (expression)
48 #endif
49
50 #if OPAL_C_HAVE_BUILTIN_PREFETCH
51 #define OPAL_PREFETCH(address,rw,locality) __builtin_prefetch(address,rw,locality)
52 #else
53 #define OPAL_PREFETCH(address,rw,locality)
54 #endif
55
56 #endif
57
58 #endif