summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog8
-rw-r--r--libgfortran/caf/libcaf.h7
-rw-r--r--libgfortran/caf/single.c45
3 files changed, 57 insertions, 3 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 48db71b8df7..4843fd50464 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,11 @@
+2015-11-26 Tobias Burnus <burnus@net-b.de>
+ Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>
+
+ * caf/libcaf.h (_gfortran_caf_event_post,
+ _gfortran_caf_event_wait,_gfortran_caf_event_query): New prototypes.
+ * caf/single.c (_gfortran_caf_event_post,
+ _gfortran_caf_event_wait,_gfortran_caf_event_query): Implement.
+
2015-11-22 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/52251
diff --git a/libgfortran/caf/libcaf.h b/libgfortran/caf/libcaf.h
index 660bd7c0945..ebda579d06c 100644
--- a/libgfortran/caf/libcaf.h
+++ b/libgfortran/caf/libcaf.h
@@ -57,7 +57,9 @@ typedef enum caf_register_t {
CAF_REGTYPE_COARRAY_ALLOC,
CAF_REGTYPE_LOCK_STATIC,
CAF_REGTYPE_LOCK_ALLOC,
- CAF_REGTYPE_CRITICAL
+ CAF_REGTYPE_CRITICAL,
+ CAF_REGTYPE_EVENT_STATIC,
+ CAF_REGTYPE_EVENT_ALLOC
}
caf_register_t;
@@ -133,5 +135,8 @@ void _gfortran_caf_atomic_op (int, caf_token_t, size_t, int, void *, void *,
void _gfortran_caf_lock (caf_token_t, size_t, int, int *, int *, char *, int);
void _gfortran_caf_unlock (caf_token_t, size_t, int, int *, char *, int);
+void _gfortran_caf_event_post (caf_token_t, size_t, int, int *, char *, int);
+void _gfortran_caf_event_wait (caf_token_t, size_t, int, int *, char *, int);
+void _gfortran_caf_event_query (caf_token_t, size_t, int, int *, int *);
#endif /* LIBCAF_H */
diff --git a/libgfortran/caf/single.c b/libgfortran/caf/single.c
index 6c582860ebf..9c4b3434f5c 100644
--- a/libgfortran/caf/single.c
+++ b/libgfortran/caf/single.c
@@ -101,7 +101,8 @@ _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
void *local;
if (type == CAF_REGTYPE_LOCK_STATIC || type == CAF_REGTYPE_LOCK_ALLOC
- || type == CAF_REGTYPE_CRITICAL)
+ || type == CAF_REGTYPE_CRITICAL || type == CAF_REGTYPE_EVENT_STATIC
+ || type == CAF_REGTYPE_EVENT_ALLOC)
local = calloc (size, sizeof (bool));
else
local = malloc (size);
@@ -133,7 +134,8 @@ _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
*stat = 0;
if (type == CAF_REGTYPE_COARRAY_STATIC || type == CAF_REGTYPE_LOCK_STATIC
- || type == CAF_REGTYPE_CRITICAL)
+ || type == CAF_REGTYPE_CRITICAL || type == CAF_REGTYPE_EVENT_STATIC
+ || type == CAF_REGTYPE_EVENT_ALLOC)
{
caf_static_t *tmp = malloc (sizeof (caf_static_t));
tmp->prev = caf_static_list;
@@ -1071,6 +1073,45 @@ _gfortran_caf_atomic_op (int op, caf_token_t token, size_t offset,
*stat = 0;
}
+void
+_gfortran_caf_event_post (caf_token_t token, size_t index,
+ int image_index __attribute__ ((unused)),
+ int *stat, char *errmsg __attribute__ ((unused)),
+ int errmsg_len __attribute__ ((unused)))
+{
+ uint32_t value = 1;
+ uint32_t *event = (uint32_t *) ((char *) TOKEN (token) + index*sizeof(uint32_t));
+ __atomic_fetch_add (event, (uint32_t) value, __ATOMIC_RELAXED);
+
+ if(stat)
+ *stat = 0;
+}
+
+void
+_gfortran_caf_event_wait (caf_token_t token, size_t index,
+ int until_count, int *stat,
+ char *errmsg __attribute__ ((unused)),
+ int errmsg_len __attribute__ ((unused)))
+{
+ uint32_t *event = (uint32_t *) ((char *) TOKEN (token) + index*sizeof(uint32_t));
+ uint32_t value = (uint32_t)-until_count;
+ __atomic_fetch_add (event, (uint32_t) value, __ATOMIC_RELAXED);
+
+ if(stat)
+ *stat = 0;
+}
+
+void
+_gfortran_caf_event_query (caf_token_t token, size_t index,
+ int image_index __attribute__ ((unused)),
+ int *count, int *stat)
+{
+ uint32_t *event = (uint32_t *) ((char *) TOKEN (token) + index*sizeof(uint32_t));
+ __atomic_load (event, (uint32_t *) count, __ATOMIC_RELAXED);
+
+ if(stat)
+ *stat = 0;
+}
void
_gfortran_caf_lock (caf_token_t token, size_t index,