blob: 0b75ffaee2129dca0999c7d5448d2ef3c05c402d (
plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/* Copyright (c) 2013-2018, Linaro Limited
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* @file
*
* ODP memory barriers
*/
#ifndef ODP_API_SPEC_SYNC_H_
#define ODP_API_SPEC_SYNC_H_
#include <odp/visibility_begin.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @addtogroup odp_barrier
* @details
* <b> Memory barriers </b>
*
* Memory barriers enforce ordering of memory load and store operations
* specified before and after the barrier. These barriers may affect both
* compiler optimizations and CPU out-of-order execution. All ODP
* synchronization mechanisms (e.g. execution barriers, locks, queues, etc )
* include all necessary memory barriers, so these calls are not needed when
* using those. Also ODP atomic operations have memory ordered versions. These
* explicit barriers may be needed when thread synchronization is based on
* a non-ODP defined mechanism. Depending on the HW platform, heavy usage of
* memory barriers may cause significant performance degradation.
*
* @{
*/
/**
* Memory barrier for release operations
*
* This memory barrier has release semantics. It synchronizes with a pairing
* barrier for acquire operations. The releasing and acquiring threads
* synchronize through shared memory. The releasing thread must call this
* barrier before signaling the acquiring thread. After the acquiring thread
* receives the signal, it must call odp_mb_acquire() before it reads the
* memory written by the releasing thread.
*
* This call is not needed when using ODP defined synchronization mechanisms.
*
* @see odp_mb_acquire()
*/
void odp_mb_release(void);
/**
* Memory barrier for acquire operations
*
* This memory barrier has acquire semantics. It synchronizes with a pairing
* barrier for release operations. The releasing and acquiring threads
* synchronize through shared memory. The releasing thread must call
* odp_mb_release() before signaling the acquiring thread. After the acquiring
* thread receives the signal, it must call this barrier before it reads the
* memory written by the releasing thread.
*
* This call is not needed when using ODP defined synchronization mechanisms.
*
* @see odp_mb_release()
*/
void odp_mb_acquire(void);
/**
* Full memory barrier
*
* This is a full memory barrier. It guarantees that all load and store
* operations specified before it are visible to other threads before
* all load and store operations specified after it.
*
* This call is not needed when using ODP defined synchronization mechanisms.
*/
void odp_mb_full(void);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#include <odp/visibility_end.h>
#endif
|