Skip to content

Commit 8a3903e

Browse files
committed
add flag to invoke create callback on all ranks
1 parent 8421258 commit 8a3903e

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

libcircle.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#ifndef LIBCIRCLE_H
22
#define LIBCIRCLE_H
33

4+
#include <stdint.h>
5+
46
/* define a C interface */
57
#ifdef __cplusplus
68
extern "C" {
79
#endif
810

9-
#include <stdint.h>
10-
1111
/**
1212
* The maximum length of a string value which is allowed to be placed on the
1313
* queue structure.
@@ -22,8 +22,9 @@ extern "C" {
2222
* Run time flags for the behavior of splitting work.
2323
*/
2424
#define CIRCLE_SPLIT_RANDOM (1 << 0) /* Split work randomly. */
25-
#define CIRCLE_SPLIT_EQUAL ~CIRCLE_SPLIT_RANDOM /* Split work evenly */
26-
#define CIRCLE_DEFAULT_FLAGS CIRCLE_SPLIT_RANDOM /* Default behavior is random work stealing */
25+
#define CIRCLE_SPLIT_EQUAL (1 << 1) /* Split work evenly */
26+
#define CIRCLE_CREATE_GLOBAL (1 << 2) /* Call create callback on all procs */
27+
#define CIRCLE_DEFAULT_FLAGS CIRCLE_SPLIT_EQUAL /* Default behavior is random work stealing */
2728

2829
/**
2930
* The various logging levels that libcircle will output.

libcircle/worker.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,17 @@ int8_t CIRCLE_worker()
347347
LOG(CIRCLE_LOG_DBG, "Using randomized load splitting.");
348348
}
349349

350+
/* start the termination token on rank 0 */
350351
if(rank == 0) {
351-
(*(CIRCLE_INPUT_ST.create_cb))(&queue_handle);
352352
local_state.have_token = 1;
353353
}
354354

355+
/* start by adding work to queue by calling create_cb,
356+
* only invoke on master unless CREATE_GLOBAL is set */
357+
if(rank == 0 || CIRCLE_INPUT_ST.options & CIRCLE_CREATE_GLOBAL) {
358+
(*(CIRCLE_INPUT_ST.create_cb))(&queue_handle);
359+
}
360+
355361
CIRCLE_work_loop(sptr, &queue_handle);
356362
CIRCLE_cleanup_mpi_messages(sptr);
357363

0 commit comments

Comments
 (0)