Prepare arrows module

This commit is contained in:
Adrien Bourmault 2021-06-15 23:46:18 +02:00
parent f98e51bf4a
commit 5862b207ce
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
6 changed files with 52 additions and 6 deletions

24
src/arrows.c Normal file
View File

@ -0,0 +1,24 @@
//=-------------------------------------------------------------------------=//
// Arrows management module //
// //
// Copyright © 2021 The Gem-graph Project //
// //
// This file is part of gem-graph. //
// //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU Affero General Public License as //
// published by the Free Software Foundation, either version 3 of the //
// License, or (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU Affero General Public License for more details. //
// //
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//=-------------------------------------------------------------------------=//
#include "../include/base.h"
/* -------------------------------------------------------------------------- */

View File

@ -41,7 +41,7 @@ void CenterRemove(Center_t *oldCenter)
register Center_t *prev; register Center_t *prev;
register Center_t *next; register Center_t *next;
printLog("Removing center %p\n", oldCenter); //printLog("Removing center %p\n", oldCenter);
if (!oldCenter) return; if (!oldCenter) return;
prev = oldCenter->prev; prev = oldCenter->prev;

View File

@ -43,7 +43,7 @@ pthread_t *WorkerInit(Worker_t *worker)
static void *LittleWorker(void *worker) static void *LittleWorker(void *worker)
{ {
Worker_t *args; Worker_t *args;
int a; int a = rand()%__INT_MAX__;
args = (Worker_t*) worker; args = (Worker_t*) worker;
printLog("Worker #%lu online\n", *args->id); printLog("Worker #%lu online\n", *args->id);

View File

@ -25,7 +25,7 @@
#define ARROW_NUMBER 150 #define ARROW_NUMBER 150
#define MAX_CYCLES 40000 #define MAX_CYCLES 400000
#define SPACE_SIZE 10000 #define SPACE_SIZE 10000
#define MAX_THREAD 0 #define MAX_THREAD 0

View File

@ -88,7 +88,7 @@ static void *GreatScheduler(void *scheduler)
args = (Scheduler_t*) scheduler; args = (Scheduler_t*) scheduler;
printLog("Scheduler #%lu online\n", *args->id); printLog("Scheduler #%lu online\n", *args->id);
ncpu = get_nprocs(); ncpu = get_nprocs() * 3;
printLog("%d CPUs available.\n", ncpu); printLog("%d CPUs available.\n", ncpu);
// Data structures // Data structures
@ -119,13 +119,13 @@ static void *GreatScheduler(void *scheduler)
// If a free area exists, // If a free area exists,
if (workArea) { if (workArea) {
printLog("A free workArea exists at %p\n", workArea); //printLog("A free workArea exists at %p\n", workArea);
// preempt it, // preempt it,
CenterAdd(centersList, workArea); CenterAdd(centersList, workArea);
// find a worker socket, // find a worker socket,
for (int i = 0; i < ncpu; i++) { for (int i = 0; i < ncpu; i++) {
if (!workerArray[i].id) { if (!workerArray[i].id) {
printLog("Adding worker at rank %d\n", i); //printLog("Adding worker at rank %d\n", i);
// prepare the worker for the area, // prepare the worker for the area,
workerArray[i].localWorkAreaCenter = workArea; workerArray[i].localWorkAreaCenter = workArea;
// create the worker, // create the worker,

22
src/tests/arrows.c Normal file
View File

@ -0,0 +1,22 @@
//=-------------------------------------------------------------------------=//
// Arrows tests //
// //
// Copyright © 2021 The Gem-graph Project //
// //
// This file is part of gem-graph. //
// //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU Affero General Public License as //
// published by the Free Software Foundation, either version 3 of the //
// License, or (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU Affero General Public License for more details. //
// //
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//=-------------------------------------------------------------------------=//
#include "../centers.c"