From 8b2f383409e0c1e54e346318f221c96a09655b29 Mon Sep 17 00:00:00 2001 From: "Adrien Bourmault (neox)" Date: Sat, 16 Mar 2024 22:59:30 +0200 Subject: [PATCH] WIP: test on modularity of scheduler --- src/scheduler.c | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/src/scheduler.c b/src/scheduler.c index 43ac7df..d2a82f0 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -32,7 +32,10 @@ static int sched_new_id (void) return id; } -int sched_start (struct scheduler_t *self, struct parameters_t *parameters) + +static int sched_run(struct scheduler_t *self, + struct parameters_t *parameters, + struct model_t *model) { int n_threads = omp_get_max_threads(); int n_arrows; @@ -43,14 +46,6 @@ int sched_start (struct scheduler_t *self, struct parameters_t *parameters) bool pleaseStop; struct worker_t **workers; - self->id = sched_new_id(); - - printlog("Hey, I'm the scheduler %d and I can work with %d threads !\n", - self->id, - n_threads); - - workers = calloc(n_threads, sizeof(struct worker_t*)); - //XXX n_arrows = 10000000000; max_cycles = 1; @@ -70,15 +65,8 @@ int sched_start (struct scheduler_t *self, struct parameters_t *parameters) thread_num = omp_get_thread_num(); while (!pleaseStop) { - /* n_workers++; */ - /* if (n_workers > max_workers) { */ - /* pleaseStop = true; */ - /* } */ - - workers[thread_num] = calloc(1, sizeof(struct worker_t)); workers[thread_num]->id = n_workers; worker_start(workers[thread_num], self); - free(workers[thread_num]); } } @@ -88,3 +76,32 @@ int sched_start (struct scheduler_t *self, struct parameters_t *parameters) return SCHED_NORMAL_EXIT; } + +int sched_start (struct scheduler_t *self, struct parameters_t *parameters) +{ + int n_threads = omp_get_max_threads(); + int n_arrows; + int n_workers; + int workers_per_cycle; + int max_cycles; + int max_workers; + bool pleaseStop; + struct worker_t **workers; + + self->id = sched_new_id(); + + printlog("Hey, I'm the scheduler %d and I can work with %d threads !\n", + self->id, + n_threads); + + workers = calloc(n_threads, sizeof(struct worker_t*)); + for (int i = 0; i < n_threads; i++) { + workers[thread_num] = calloc(1, sizeof(struct worker_t)); + } + + sched_run(self, parameters, NULL); + + for (int i = 0; i < n_threads; i++) { + free(workers[thread_num]); + } +}