diff mbox

[API-NEXT,PATCHv3,07/18] drv: adding sync.h

Message ID 1469102786-65530-8-git-send-email-christophe.milard@linaro.org
State New
Headers show

Commit Message

Christophe Milard July 21, 2016, 12:06 p.m. UTC
Based on API interface file.

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

---
 include/odp/drv/spec/sync.h | 91 +++++++++++++++++++++++++++++++++++++++++++++
 platform/Makefile.inc       |  3 +-
 2 files changed, 93 insertions(+), 1 deletion(-)
 create mode 100644 include/odp/drv/spec/sync.h

-- 
2.7.4
diff mbox

Patch

diff --git a/include/odp/drv/spec/sync.h b/include/odp/drv/spec/sync.h
new file mode 100644
index 0000000..ea60685
--- /dev/null
+++ b/include/odp/drv/spec/sync.h
@@ -0,0 +1,91 @@ 
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODPDRV memory barriers
+ */
+
+#ifndef ODPDRV_API_SYNC_H_
+#define ODPDRV_API_SYNC_H_
+#include <odp/visibility_begin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup odpdrv_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 ODPDRV
+ * synchronization mechanisms (e.g. execution barriers, locks, queues, etc )
+ * include all necessary memory barriers, so these calls are not needed when
+ * using those. Also ODPDRV atomic operations have memory ordered versions.
+ * These explicit barriers may be needed when thread synchronization is based on
+ * a non-ODPDRV 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 odpdrv_mb_acquire() before it reads the
+ * memory written by the releasing thread.
+ *
+ * This call is not needed when using ODPDRV defined synchronization mechanisms.
+ *
+ * @see odpdrv_mb_acquire()
+ */
+void odpdrv_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
+ * odpdrv_mb_release() before signaling the acquiring thread. After the
+ * acquiring thread receives the signal, it must call this barrier before it
+ * read the memory written by the releasing thread.
+ *
+ * This call is not needed when using ODPDRV defined synchronization mechanisms.
+ *
+ * @see odpdrv_mb_release()
+ */
+void odpdrv_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 ODPDRV defined synchronization mechanisms.
+ */
+void odpdrv_mb_full(void);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <odp/visibility_end.h>
+#endif
diff --git a/platform/Makefile.inc b/platform/Makefile.inc
index 9fea4a7..21f2922 100644
--- a/platform/Makefile.inc
+++ b/platform/Makefile.inc
@@ -63,4 +63,5 @@  odpapispecinclude_HEADERS = \
 
 odpdrvspecincludedir= $(includedir)/odp/drv/spec
 odpdrvspecinclude_HEADERS = \
-		  $(top_srcdir)/include/odp/drv/spec/byteorder.h
+		  $(top_srcdir)/include/odp/drv/spec/byteorder.h \
+		  $(top_srcdir)/include/odp/drv/spec/sync.h