Hello,
the libgomp configuration for RTEMS uses currently the POSIX
implementation. Unfortunately the performance is unacceptable bad, so I
work currently on a specialized RTEMS configuration. I would like to
reuse the code of the Linux futex barrier. On RTEMS there is no
kernel/user space separation. In order to make the futex management
simpler, I would like to optionally embed a futex object in the barrier.
Would a change like this be acceptable?
diff --git a/libgomp/config/linux/bar.h b/libgomp/config/linux/bar.h
index 3236436..b47b9f6 100644
--- a/libgomp/config/linux/bar.h
+++ b/libgomp/config/linux/bar.h
@@ -40,6 +40,9 @@ typedef struct
unsigned generation;
unsigned awaited __attribute__((aligned (64)));
unsigned awaited_final;
+#ifdef HAVE_BARRIER_FUTEX
+ gomp_barrier_futex_t futex;
+#endif
} gomp_barrier_t;
typedef unsigned int gomp_barrier_state_t;
diff --git a/libgomp/config/linux/futex.h b/libgomp/config/linux/futex.h
index c99ea37..7aab595 100644
--- a/libgomp/config/linux/futex.h
+++ b/libgomp/config/linux/futex.h
@@ -68,3 +68,7 @@ cpu_relax (void)
{
__asm volatile ("" : : : "memory");
}
+
+#define barrier_futex_wait(addr, val, futex) futex_wait (addr, val)
+
+#define barrier_futex_wake(addr, count, futex) futex_wake (addr, count)
diff --git a/libgomp/config/linux/bar.c b/libgomp/config/linux/bar.c
index 51fbd99..d776796 100644
--- a/libgomp/config/linux/bar.c
+++ b/libgomp/config/linux/bar.c
@@ -40,7 +40,7 @@ gomp_barrier_wait_end (gomp_barrier_t *bar,
gomp_barrier_state_t state)
bar->awaited = bar->total;
__atomic_store_n (&bar->generation, bar->generation + BAR_INCR,
MEMMODEL_RELEASE);
- futex_wake ((int *) &bar->generation, INT_MAX);
+ barrier_futex_wake ((int *) &bar->generation, INT_MAX, &bar->futex);
}
else
{
@@ -74,7 +74,8 @@ gomp_barrier_wait_last (gomp_barrier_t *bar)
void
gomp_team_barrier_wake (gomp_barrier_t *bar, int count)
{
- futex_wake ((int *) &bar->generation, count == 0 ? INT_MAX : count);
+ barrier_futex_wake ((int *) &bar->generation, count == 0 ? INT_MAX :
count,
+ &bar->futex);
}
void
@@ -100,7 +101,7 @@ gomp_team_barrier_wait_end (gomp_barrier_t *bar,
gomp_barrier_state_t state)
state &= ~BAR_CANCELLED;
state += BAR_INCR - BAR_WAS_LAST;
__atomic_store_n (&bar->generation, state, MEMMODEL_RELEASE);
- futex_wake ((int *) &bar->generation, INT_MAX);
+ barrier_futex_wake ((int *) &bar->generation, INT_MAX, &bar->futex);
return;
}
}
@@ -163,7 +164,7 @@ gomp_team_barrier_wait_cancel_end (gomp_barrier_t *bar,
{
state += BAR_INCR - BAR_WAS_LAST;
__atomic_store_n (&bar->generation, state, MEMMODEL_RELEASE);
- futex_wake ((int *) &bar->generation, INT_MAX);
+ barrier_futex_wake ((int *) &bar->generation, INT_MAX, &bar->futex);
return false;
}
}
@@ -199,13 +200,14 @@ gomp_team_barrier_wait_cancel (gomp_barrier_t *bar)
void
gomp_team_barrier_cancel (struct gomp_team *team)
{
+ gomp_barrier_t *bar = &team->barrier;
gomp_mutex_lock (&team->task_lock);
- if (team->barrier.generation & BAR_CANCELLED)
+ if (bar->generation & BAR_CANCELLED)
{
gomp_mutex_unlock (&team->task_lock);
return;
}
- team->barrier.generation |= BAR_CANCELLED;
+ bar->generation |= BAR_CANCELLED;
gomp_mutex_unlock (&team->task_lock);
- futex_wake ((int *) &team->barrier.generation, INT_MAX);
+ barrier_futex_wake ((int *) &bar->generation, INT_MAX, &bar->futex);
}
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.