From 3b8d3e1de39e3272a1ecdcb64df022e5b89b2c2b Mon Sep 17 00:00:00 2001 From: Antoniu Pop Date: Fri, 25 Sep 2009 12:53:53 +0000 Subject: 2009-09-25 Antoniu Pop Adding stream window operations to libGOMP. libgomp/ * stream.c (GOMP_stream_head_window, GOMP_stream_tail_window, GOMP_stream_pop_window, GOMP_stream_push_window): New. * libgomp_g.h (GOMP_stream_head_window, GOMP_stream_tail_window, GOMP_stream_pop_window, GOMP_stream_push_window): Declared. * libgomp.map (GOMP_stream_head_window, GOMP_stream_tail_window, GOMP_stream_pop_window, GOMP_stream_push_window): Declared. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/streamization@152169 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgomp/ChangeLog.streamization | 12 ++++++++++++ libgomp/libgomp.map | 4 ++++ libgomp/libgomp_g.h | 4 ++++ libgomp/stream.c | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+) diff --git a/libgomp/ChangeLog.streamization b/libgomp/ChangeLog.streamization index a4d2aac7b54..bce7a9a4eae 100644 --- a/libgomp/ChangeLog.streamization +++ b/libgomp/ChangeLog.streamization @@ -1,3 +1,15 @@ +2009-09-25 Antoniu Pop + +Adding stream window operations to libGOMP. + + * stream.c (GOMP_stream_head_window, GOMP_stream_tail_window, + GOMP_stream_pop_window, GOMP_stream_push_window): New. + + * libgomp_g.h (GOMP_stream_head_window, GOMP_stream_tail_window, + GOMP_stream_pop_window, GOMP_stream_push_window): Declared. + * libgomp.map (GOMP_stream_head_window, GOMP_stream_tail_window, + GOMP_stream_pop_window, GOMP_stream_push_window): Declared. + 2009-09-22 Antoniu Pop Adding multi-reader support in libGOMP streams. diff --git a/libgomp/libgomp.map b/libgomp/libgomp.map index 98863cbffd5..a9f9d496c4c 100644 --- a/libgomp/libgomp.map +++ b/libgomp/libgomp.map @@ -170,10 +170,14 @@ GOMP_2.0 { GOMP_stream_create; GOMP_stream_register_reader; GOMP_stream_push; + GOMP_stream_push_window; GOMP_stream_commit; GOMP_stream_tail; + GOMP_stream_tail_window; GOMP_stream_head; + GOMP_stream_head_window; GOMP_stream_pop; + GOMP_stream_pop_window; GOMP_stream_eos_p; GOMP_stream_set_eos; GOMP_stream_destroy; diff --git a/libgomp/libgomp_g.h b/libgomp/libgomp_g.h index 6fd4814a1eb..7ff68e8be1b 100644 --- a/libgomp/libgomp_g.h +++ b/libgomp/libgomp_g.h @@ -183,10 +183,14 @@ extern void GOMP_single_copy_end (void *); extern void *GOMP_stream_create (size_t, size_t, size_t, size_t); extern size_t GOMP_stream_register_reader (void *); extern void GOMP_stream_push (void *, void *); +extern void GOMP_stream_push_window (void *); extern void GOMP_stream_commit (void *); extern void *GOMP_stream_tail (void *); +extern void *GOMP_stream_tail_window (void *); extern void *GOMP_stream_head (void *, size_t); +extern void *GOMP_stream_head_window (void *, size_t); extern void GOMP_stream_pop (void *, size_t); +extern void GOMP_stream_pop_window (void *, size_t); extern bool GOMP_stream_eos_p (void *, size_t); extern void GOMP_stream_set_eos (void *); extern void GOMP_stream_destroy (void *); diff --git a/libgomp/stream.c b/libgomp/stream.c index e835e48132a..2d1e087734c 100644 --- a/libgomp/stream.c +++ b/libgomp/stream.c @@ -221,6 +221,26 @@ GOMP_stream_head (void *s, size_t id) return ((gomp_stream) s)->buffer + ((gomp_stream) s)->read_index[id]; } +/* Return a pointer to the next windowfull of elements in stream S or + NULL if only the last window is left and is not full. FIXME: use a + futex for the eos ? */ + +void * +GOMP_stream_head_window (void *vs, size_t id) +{ + gomp_stream s = (gomp_stream) vs; + + /* If we're in the last and only partially filled window of the + stream. */ + if ((((gomp_stream) s)->eos_p + && (((gomp_stream) s)->read_index[id] + == ((gomp_stream) s)->write_index)) + || s->read_buffer_index[id] == s->write_buffer_index) + return NULL; + + return (void *) s->buffer + s->read_buffer_index[id]; +} + /* Returns a pointer to the next available location in stream S that can hold an element. Don't commit the element: for that, a call to gomp_stream_push is needed. */ @@ -231,6 +251,15 @@ GOMP_stream_tail (void *s) return ((gomp_stream) s)->buffer + ((gomp_stream) s)->write_index; } +/* Return a pointer on the next empty window to write to. */ + +void * +GOMP_stream_tail_window (void *s) +{ + gomp_stream stream = (gomp_stream) s; + return (void *) stream->buffer + stream->write_buffer_index; +} + /* Returns true when there are no more elements to be read from the stream S. Returning false guarantees that at least one element will be available for reading. Unless this function is called @@ -298,8 +327,20 @@ GOMP_stream_push (void *s, void *elt) gomp_stream_push ((gomp_stream) s, (char *) elt); } +void +GOMP_stream_push_window (void *s) +{ + slide_write_window ((gomp_stream) s); +} + void GOMP_stream_pop (void *s, size_t id) { gomp_stream_pop ((gomp_stream) s, id); } + +void +GOMP_stream_pop_window (void *s, size_t id) +{ + slide_read_window ((gomp_stream) s, id); +} -- cgit v1.2.3