Skip to content

Commit

Permalink
pool: add ABT_POOL_RANDWS
Browse files Browse the repository at this point in the history
Now all the builtin pools are FIFO, which is known to be inefficient for
divide-and-conquer task paralleism.  This PR implements ABT_POOL_RANDWS
to provide a good pool implementation for this type of parallelism.
  • Loading branch information
shintaro-iwasaki committed Aug 5, 2021
1 parent b415983 commit 915ff28
Show file tree
Hide file tree
Showing 6 changed files with 499 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/include/abt.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,31 @@ enum ABT_pool_kind {
*
* If the user does not know how \c ABT_POOL_FIFO_WAIT works,
* \c ABT_POOL_FIFO is recommended. */
ABT_POOL_FIFO_WAIT
ABT_POOL_FIFO_WAIT,
/**
* Random work-stealing pool which is often adopted by fine-grained task
* parallel runtime systems such as Cilk.
*
* Create push Non-create push (e.g., yield/resume)
* \ /
* (head) <- <- <- (tail)
* / \
* Local pop Remote pop
*
* Specifically, if one of the following flags is set to ABT_pool_context, a
* work unit is pushed to the head.
* - ABT_POOL_CONTEXT_OP_THREAD_CREATE
* - ABT_POOL_CONTEXT_OP_THREAD_CREATE_TO
* - ABT_POOL_CONTEXT_OP_THREAD_REVIVE
* - ABT_POOL_CONTEXT_OP_THREAD_REVIVE_TO
* Otherwise, a work unit is pushed to the tail.
*
* If ABT_POOL_CONTEXT_OWNER_SECONDARY is set to ABT_pool_context, a work
* unit is popped from the tail. Otherwise, a work unit is popped from the
* head.
*
* The user is recommended to use this pool with ABT_SCHED_RANDWS. */
ABT_POOL_RANDWS
};

/**
Expand Down
5 changes: 5 additions & 0 deletions src/include/abti.h
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,11 @@ ABTI_pool_get_fifo_wait_def(ABT_pool_access access,
ABTI_pool_required_def *p_required_def,
ABTI_pool_optional_def *p_optional_def,
ABTI_pool_deprecated_def *p_deprecated_def);
ABTU_ret_err int
ABTI_pool_get_randws_def(ABT_pool_access access,
ABTI_pool_required_def *p_required_def,
ABTI_pool_optional_def *p_optional_def,
ABTI_pool_deprecated_def *p_deprecated_def);
void ABTI_pool_print(ABTI_pool *p_pool, FILE *p_os, int indent);
void ABTI_pool_reset_id(void);

Expand Down
1 change: 1 addition & 0 deletions src/pool/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ abt_sources += \
pool/pool.c \
pool/pool_config.c \
pool/pool_user_def.c \
pool/randws.c \
pool/thread_queue.h
5 changes: 5 additions & 0 deletions src/pool/pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,11 @@ ABTU_ret_err int ABTI_pool_create_basic(ABT_pool_kind kind,
ABTI_pool_get_fifo_wait_def(access, &required_def,
&optional_def, &deprecated_def);
break;
case ABT_POOL_RANDWS:
abt_errno =
ABTI_pool_get_randws_def(access, &required_def, &optional_def,
&deprecated_def);
break;
default:
abt_errno = ABT_ERR_INV_POOL_KIND;
break;
Expand Down
Loading

0 comments on commit 915ff28

Please sign in to comment.