From 2531db992a2fe4d0915eb7f957528972ef1622f3 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Wed, 16 Jun 2021 12:42:19 +0200 Subject: [PATCH] space is now Space_t --- include/base.h | 22 +++++++++++++++++++--- src/main.c | 12 ++++++------ src/scheduler.c | 8 ++++---- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/include/base.h b/include/base.h index 50d4c29..0f17103 100644 --- a/include/base.h +++ b/include/base.h @@ -36,13 +36,29 @@ struct { int z; } typedef Arrow_t; +struct { + size_t size; + Arrow_t *array; +} typedef ArrowArray_t; + +struct { + char *label; + int narrow; +} typedef Site_t; + +struct { + int nsite; + char *label; + Site_t *sites; +} typedef SpaceUnit_t; + struct { int xmax; int ymax; int zmax; size_t size; - Arrow_t *space; -} typedef ArrowArray_t; //XXX + SpaceUnit_t *space; +} typedef Space_t; struct { size_t size; @@ -59,7 +75,7 @@ struct { // struct { - ArrowArray_t *globalDrawingSpace; + Space_t *globalDrawingSpace; IntArray_t *transitionsTree; ArrowArray_t *arrowList; int nmaxThread; diff --git a/src/main.c b/src/main.c index 136e37b..eac0a86 100644 --- a/src/main.c +++ b/src/main.c @@ -49,23 +49,23 @@ int main(int argc, char **argv) scheduler0 = (Scheduler_t*) calloc(1, sizeof(Scheduler_t)); scheduler0->globalDrawingSpace = - (ArrowArray_t*) calloc(1, sizeof(ArrowArray_t)); + (Space_t*) calloc(1, sizeof(Space_t)); scheduler0->globalDrawingSpace->space = - (Arrow_t*) calloc(SPACE_SIZE, sizeof(Arrow_t)); + (SpaceUnit_t*) calloc(SPACE_SIZE, sizeof(SpaceUnit_t)); scheduler0->globalDrawingSpace->size = SPACE_SIZE; scheduler0->arrowList = (ArrowArray_t*) calloc(1, sizeof(ArrowArray_t)); - scheduler0->arrowList->space = + scheduler0->arrowList->array = (Arrow_t*) calloc(ARROW_NUMBER, sizeof(Arrow_t)); scheduler0->arrowList->size = ARROW_NUMBER; printLog("Populating a random arrow list...\n"); for (int i = 0; i < ARROW_NUMBER; i++) { - scheduler0->arrowList->space[i].x = + scheduler0->arrowList->array[i].x = rand() % scheduler0->globalDrawingSpace->xmax; - scheduler0->arrowList->space[i].y = + scheduler0->arrowList->array[i].y = rand() % scheduler0->globalDrawingSpace->ymax; - scheduler0->arrowList->space[i].z = + scheduler0->arrowList->array[i].z = rand() % scheduler0->globalDrawingSpace->zmax; } diff --git a/src/scheduler.c b/src/scheduler.c index 437bcfa..281bdef 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -116,14 +116,14 @@ static void *schedulerMain(void *scheduler) if (nworker < ncpu) { // Random choice of an arrow electedArrow = - &args->arrowList->space[rand() % args->arrowList->size]; + &args->arrowList->array[rand() % args->arrowList->size]; // Find a local area workArea = findWorkArea(centersList, electedArrow, args->ruleRadius, args->globalDrawingSpace->size, - args->arrowList->xmax, - args->arrowList->ymax, - args->arrowList->zmax + args->globalDrawingSpace->xmax, + args->globalDrawingSpace->ymax, + args->globalDrawingSpace->zmax ); // If a free area exists,