Skip to content

Commit

Permalink
Move processor count global into __cilkrts namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
VoxSciurorum authored and neboat committed Sep 16, 2024
1 parent f58b713 commit f461280
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions runtime/cilk2c_inlined.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ _Alignas(__cilkrts_stack_frame)
size_t __cilkrts_stack_frame_align = __alignof__(__cilkrts_stack_frame);

__attribute__((always_inline)) unsigned __cilkrts_get_nworkers(void) {
return cilkg_nproc;
return __cilkrts_nproc;
}

// Internal method to get the Cilk worker ID. Intended for debugging purposes.
Expand Down Expand Up @@ -376,7 +376,7 @@ __cilk_helper_epilogue_exn(__cilkrts_stack_frame *sf,
/// grainsize = min(2048, ceil(n / (8 * nworkers)))
#define __cilkrts_grainsize_fn_impl(NAME, INT_T) \
__attribute__((always_inline)) INT_T NAME(INT_T n) { \
INT_T small_loop_grainsize = n / (8 * cilkg_nproc); \
INT_T small_loop_grainsize = n / (8 * __cilkrts_nproc); \
if (small_loop_grainsize <= 1) \
return 1; \
INT_T large_loop_grainsize = 2048; \
Expand All @@ -389,7 +389,7 @@ __cilk_helper_epilogue_exn(__cilkrts_stack_frame *sf,

__attribute__((always_inline)) uint8_t
__cilkrts_cilk_for_grainsize_8(uint8_t n) {
uint8_t small_loop_grainsize = n / (8 * cilkg_nproc);
uint8_t small_loop_grainsize = n / (8 * __cilkrts_nproc);
if (small_loop_grainsize <= 1)
return 1;
return small_loop_grainsize;
Expand Down
5 changes: 3 additions & 2 deletions runtime/global.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ __cilkrts_worker default_worker = {.self = 0,
CHEETAH_INTERNAL
local_state default_worker_local_state;

unsigned cilkg_nproc = 0;
// A global used to calculate grain size.
unsigned __cilkrts_nproc = 0;

static void set_alert_debug_level() {
/* Only the bits also set in ALERT_LVL are used. */
Expand Down Expand Up @@ -163,7 +164,7 @@ global_state *global_state_init(int argc, char *argv[]) {
unsigned active_size = g->options.nproc;
CILK_ASSERT(active_size > 0);
g->nworkers = active_size;
cilkg_nproc = active_size;
__cilkrts_nproc = active_size;

g->workers_started = false;
g->root_closure_initialized = false;
Expand Down
2 changes: 1 addition & 1 deletion runtime/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "types.h"
#include "worker.h"

extern unsigned cilkg_nproc;
extern unsigned __cilkrts_nproc;

struct __cilkrts_worker;
struct Closure;
Expand Down

0 comments on commit f461280

Please sign in to comment.