Skip to content

Commit

Permalink
Get rid of qt_threadque_private_t and qt_spawncache since they're emp…
Browse files Browse the repository at this point in the history
…ty now.
  • Loading branch information
insertinterestingnamehere committed Jan 29, 2025
1 parent c2aacc4 commit 47e05f0
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 143 deletions.
1 change: 0 additions & 1 deletion include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ noinst_HEADERS = \
qt_queue.h \
qt_shepherd_innards.h \
qt_spawn_macros.h \
qt_spawncache.h \
qt_subsystems.h \
qt_teams.h \
qt_threadqueues.h \
Expand Down
29 changes: 0 additions & 29 deletions include/qt_spawncache.h

This file was deleted.

2 changes: 0 additions & 2 deletions include/qt_threadqueues.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ typedef struct _qt_threadqueue_pools {
qt_mpool queues;
} qt_threadqueue_pools_t;

#include "qt_spawncache.h"

void INTERNAL qt_threadqueue_subsystem_init(void);

qt_threadqueue_t INTERNAL *qt_threadqueue_new(void);
Expand Down
7 changes: 1 addition & 6 deletions src/qthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
#include "qt_qthread_struct.h"
#include "qt_queue.h"
#include "qt_shepherd_innards.h"
#include "qt_spawncache.h"
#include "qt_subsystems.h"
#include "qt_syncvar.h"
#include "qt_teams.h"
Expand Down Expand Up @@ -320,7 +319,6 @@ static void *qthread_master(void *arg) {
if (my_id == 0 && me_worker->worker_id == 0) { qthread_after_swap_to_main(); }
qt_context_t my_context;
qt_threadqueue_t *threadqueue;
qt_threadqueue_private_t *localqueue = NULL;
qthread_t *t;
qthread_t *_Atomic *current;
int done = 0;
Expand Down Expand Up @@ -359,9 +357,7 @@ static void *qthread_master(void *arg) {
SPINLOCK_BODY();
}
t = qt_scheduler_get_thread(
threadqueue,
localqueue,
atomic_load_explicit(&me->active, memory_order_relaxed));
threadqueue, atomic_load_explicit(&me->active, memory_order_relaxed));
assert(t);

// Process input preconditions if this is a NASCENT thread
Expand Down Expand Up @@ -453,7 +449,6 @@ static void *qthread_master(void *arg) {
{
qthread_t *f = qt_scheduler_get_thread(
threadqueue,
NULL,
atomic_load_explicit(&me->active, memory_order_relaxed));
qt_threadqueue_enqueue(me->ready, t);
qt_threadqueue_enqueue(me->ready, f);
Expand Down
24 changes: 0 additions & 24 deletions src/threadqueues/distrib_threadqueues.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,34 +382,10 @@ qthread_t INTERNAL *qt_threadqueue_dequeue_specific(qt_threadqueue_t *q,
return NULL;
}

qthread_t INTERNAL *
qt_threadqueue_private_dequeue(qt_threadqueue_private_t *c) {
return NULL;
}

void INTERNAL qt_threadqueue_enqueue_cache(qt_threadqueue_t *q,
qt_threadqueue_private_t *cache) {}

void INTERNAL qt_threadqueue_private_filter(
qt_threadqueue_private_t *restrict c, qt_threadqueue_filter_f f) {}

int INTERNAL
qt_threadqueue_private_enqueue(qt_threadqueue_private_t *restrict pq,
qt_threadqueue_t *restrict q,
qthread_t *restrict t) {
return 0;
}

inline int square(int x) { return x * x; }

int INTERNAL qt_threadqueue_private_enqueue_yielded(
qt_threadqueue_private_t *restrict q, qthread_t *restrict t) {
return 0;
}

// We try and dequeue locally, if that fails we should do some stealing
qthread_t INTERNAL *qt_scheduler_get_thread(qt_threadqueue_t *qe,
qt_threadqueue_private_t *qc,
uint_fast8_t active) {
qt_threadqueue_node_t *node = NULL;
qthread_t *t;
Expand Down
6 changes: 2 additions & 4 deletions src/threadqueues/nemesis_threadqueues.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,8 @@ ssize_t INTERNAL qt_threadqueue_advisory_queuelen(qt_threadqueue_t *q) {
return atomic_load_explicit(&q->advisory_queuelen, memory_order_relaxed);
}

qthread_t INTERNAL *
qt_scheduler_get_thread(qt_threadqueue_t *q,
qt_threadqueue_private_t *Q_UNUSED(qc),
uint_fast8_t Q_UNUSED(active)) {
qthread_t INTERNAL *qt_scheduler_get_thread(qt_threadqueue_t *q,
uint_fast8_t Q_UNUSED(active)) {
#ifdef QTHREAD_CONDWAIT_BLOCKING_QUEUE
int i;
#endif /* QTHREAD_CONDWAIT_BLOCKING_QUEUE */
Expand Down
78 changes: 1 addition & 77 deletions src/threadqueues/sherwood_threadqueues.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ void INTERNAL qt_threadqueue_enqueue_yielded(qt_threadqueue_t *restrict q,

/* dequeue at tail */
qthread_t INTERNAL *qt_scheduler_get_thread(qt_threadqueue_t *q,
qt_threadqueue_private_t *qc,
uint_fast8_t active) {
qthread_shepherd_t *my_shepherd = qthread_internal_getshep();
qthread_t *t;
Expand All @@ -223,82 +222,7 @@ qthread_t INTERNAL *qt_scheduler_get_thread(qt_threadqueue_t *q,
while (1) {
qt_threadqueue_node_t *node = NULL;

// printf("Total number of items: %d+%d\n",
// (qc?(qc->on_deck?(1+qc->qlength):0):0), q->qlength);
if (qc && (qc->on_deck != NULL)) {
assert(qc->tail == NULL || qc->tail->next == NULL);
assert(qc->head == NULL || qc->head->prev == NULL);
node = qc->on_deck;
qc->on_deck = NULL;
assert(node->next == NULL);
assert(node->prev == NULL);

if (atomic_load_explicit(&qc->qlength, memory_order_relaxed) > 0) {
qt_threadqueue_node_t *first = qc->head;
qt_threadqueue_node_t *last = qc->tail;
assert(last->next == NULL);
assert(first->prev == NULL);
/* Note: I tried doing the this code with a TRY rather than a
* LOCK and performance of UTS suffered (slightly). */
#if 0
if (QTHREAD_TRYLOCK_TRY(&q->qlock)) {
assert((q->head && q->tail) || (!q->head && !q->tail));
assert(q->head != first);
assert(q->tail != last);
first->prev = q->tail;
q->tail = last;
if (q->head == NULL) {
q->head = first;
} else {
first->prev->next = first;
}
q->qlength += qc->qlength;
q->qlength_stealable += qc->qlength_stealable;
assert(q->tail->next == NULL);
assert(q->head->prev == NULL);
QTHREAD_TRYLOCK_UNLOCK(&q->qlock);
qc->head = qc->tail = NULL;
qc->qlength = qc->qlength_stealable = 0;
} else {
// Refill on-deck
qc->on_deck = qc->head;
qc->head = qc->head->next;
qc->on_deck->next = NULL;
if (qc->head) {
qc->head->prev = NULL;
}
qc->qlength--;
qc->qlength_stealable -= qc->on_deck->stealable;
}
#else /* if 0 */
QTHREAD_TRYLOCK_LOCK(&q->qlock);
assert(q->head != first);
assert(q->tail != last);
first->prev = q->tail;
q->tail = last;
if (q->head == NULL) {
q->head = first;
} else {
first->prev->next = first;
}
atomic_fetch_add_explicit(
&q->qlength,
atomic_load_explicit(&qc->qlength, memory_order_relaxed),
memory_order_relaxed);
atomic_fetch_add_explicit(
&q->qlength_stealable,
atomic_load_explicit(&qc->qlength_stealable, memory_order_relaxed),
memory_order_relaxed);
assert(q->tail->next == NULL);
assert(q->head->prev == NULL);
QTHREAD_TRYLOCK_UNLOCK(&q->qlock);
qc->head = qc->tail = NULL;
// qc->qlength = qc->qlength_stealable = 0;
atomic_store_explicit(&qc->qlength_stealable, 0, memory_order_relaxed);
atomic_store_explicit(&qc->qlength, 0, memory_order_relaxed);
#endif /* if 0 */
}
} else if (q->head) {
if (q->head) {
QTHREAD_TRYLOCK_LOCK(&q->qlock);
node = q->tail;
if (node != NULL) {
Expand Down

0 comments on commit 47e05f0

Please sign in to comment.