WIP: test on modularity of scheduler

This commit is contained in:
Adrien Bourmault 2024-03-16 22:59:30 +02:00 committed by Adrien Bourmault
parent 5b4d9f0e2e
commit 8b2f383409
Signed by: neox
GPG Key ID: 95F65F55F682A17A
1 changed files with 33 additions and 16 deletions

View File

@ -32,7 +32,10 @@ static int sched_new_id (void)
return id; 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_threads = omp_get_max_threads();
int n_arrows; int n_arrows;
@ -43,14 +46,6 @@ int sched_start (struct scheduler_t *self, struct parameters_t *parameters)
bool pleaseStop; bool pleaseStop;
struct worker_t **workers; 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 //XXX
n_arrows = 10000000000; n_arrows = 10000000000;
max_cycles = 1; max_cycles = 1;
@ -70,15 +65,8 @@ int sched_start (struct scheduler_t *self, struct parameters_t *parameters)
thread_num = omp_get_thread_num(); thread_num = omp_get_thread_num();
while (!pleaseStop) { 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; workers[thread_num]->id = n_workers;
worker_start(workers[thread_num], self); 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; 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]);
}
}