Commit 8f3d76a0 authored by Jacob Emil Baungard Hansen's avatar Jacob Emil Baungard Hansen
Browse files

Changed all of the pointers in the beehive to use SCC specific pointer offsets

parent cdb71760
......@@ -88,6 +88,8 @@ SAC_MT_Helper_AllocHiveCommons (unsigned num_bees, unsigned num_schedulers,
unsigned sizeof_hive, unsigned sizeof_bee)
{
/* allocate the Hive struct */
printf ("%s", "AllocHiveCommons -2 \n");
fflush (NULL);
struct sac_hive_common_t *hive
= (struct sac_hive_common_t *)SAC_CALLOC (1, sizeof_hive);
if (!hive) {
......@@ -100,8 +102,10 @@ SAC_MT_Helper_AllocHiveCommons (unsigned num_bees, unsigned num_schedulers,
if (!hive->bees) {
SAC_RuntimeError ("Could not allocate memory for an array of ptrs to bees.");
}
printf ("%s", "AllocHiveCommons -1 \n");
fflush (NULL);
// SAC_TR_PRINT( ("Initializing Tasklocks."));
SAC_TR_PRINT (("Initializing Tasklocks."));
if (num_schedulers > 0) {
/* allocate scheduler's data structures in the hive */
hive->SAC_MT_Tasklock = (pthread_mutex_t *)SAC_MALLOC (
......@@ -116,6 +120,9 @@ SAC_MT_Helper_AllocHiveCommons (unsigned num_bees, unsigned num_schedulers,
= (pthread_mutex_t *)SAC_MALLOC (num_schedulers * sizeof (pthread_mutex_t));
hive->SAC_MT_Taskcount = (int *)SAC_CALLOC (num_schedulers, sizeof (int));
printf ("%s", "AllocHiveCommons -0 \n");
fflush (NULL);
/* check success */
if (!hive->SAC_MT_Tasklock || !hive->SAC_MT_Task || !hive->SAC_MT_LAST_Task
|| !hive->SAC_MT_rest_iterations || !hive->SAC_MT_act_tasksize
......@@ -124,6 +131,42 @@ SAC_MT_Helper_AllocHiveCommons (unsigned num_bees, unsigned num_schedulers,
SAC_RuntimeError (
"Could not allocate memory for scheduling data in the hive!");
}
printf ("%s", "AllocHiveCommons 1 \n");
fflush (NULL);
printf ("tasklock pointer (before) %p \n ", hive->SAC_MT_Tasklock);
// change the SAC_MT elements to offsets in the SCC case.
#if defined(SAC_MT_LIB_scc)
printf ("%s \n", "AllocHiveCommons 1.5");
fflush (NULL);
hive->SAC_MT_Tasklock = scc_subtract_pointer (hive->SAC_MT_Tasklock);
printf ("%s %d\n", "offset: ", hive->SAC_MT_Tasklock);
fflush (NULL);
hive->SAC_MT_Task = scc_subtract_pointer (hive->SAC_MT_Task);
hive->SAC_MT_LAST_Task = scc_subtract_pointer (hive->SAC_MT_LAST_Task);
hive->SAC_MT_rest_iterations
= scc_subtract_pointer (hive->SAC_MT_rest_iterations);
hive->SAC_MT_act_tasksize = scc_subtract_pointer (hive->SAC_MT_act_tasksize);
hive->SAC_MT_last_taskend = scc_subtract_pointer (hive->SAC_MT_last_taskend);
hive->SAC_MT_TS_Tasklock = scc_subtract_pointer (hive->SAC_MT_TS_Tasklock);
hive->SAC_MT_Taskcount = scc_subtract_pointer (hive->SAC_MT_Taskcount);
#endif
printf ("%s", "AllocHiveCommons 2 \n");
fflush (NULL);
pthread_mutex_t *tasklock_two
= (pthread_mutex_t *)scc_plus_pointer ((int)hive->SAC_MT_Tasklock);
printf ("tasklock pointer (after plus) %p idx 0 %p inline %p \n ", tasklock_two,
&tasklock_two[0],
&((pthread_mutex_t *)scc_plus_pointer (hive->SAC_MT_Tasklock))[0]);
fflush (NULL);
pthread_mutex_init (&tasklock_two[0], NULL);
// printf("tasklock pointer macro %p \n", &(SAC_MT_TASKLOCK_INIT( hive, 0, 0,
// 1))); fflush(NULL);
// pthread_mutex_init( &(SAC_MT_TASKLOCK_INIT( hive, 0, 0, 1)), NULL);
/* initialize the mutexes in the scheduler's data */
for (unsigned n = 0; n < num_schedulers; ++n) {
......@@ -135,9 +178,10 @@ SAC_MT_Helper_AllocHiveCommons (unsigned num_bees, unsigned num_schedulers,
// pthread_mutex_init( &(hive->SAC_MT_Tasklock[n + num_schedulers * i]),
// NULL);
}
pthread_mutex_t *tasklock
= (pthread_mutex_t *)scc_plus_pointer ((int)hive->SAC_MT_TS_Tasklock);
/* init pthread_mutex_t SAC_MT_TS_Tasklock[SAC_SET_NUM_SCHEDULERS]; */
pthread_mutex_init (&(hive->SAC_MT_TS_Tasklock[n]), NULL);
pthread_mutex_init (&(tasklock[n]), NULL);
}
}
......@@ -157,6 +201,15 @@ SAC_MT_Helper_AllocHiveCommons (unsigned num_bees, unsigned num_schedulers,
* bees, not the queen bee itself */
struct sac_bee_common_t *b
= (struct sac_bee_common_t *)(other_bees + sizeof_bee * (i - 1));
#if defined(SAC_MT_LIB_scc)
/* put a bee into hive */
hive->bees[i] = scc_subtract_pointer (b);
/* set bee's data */
b->local_id = i;
b->thread_id
= SAC_HM_THREADID_INVALID; /* must be assigned within the thread! */
b->hive = scc_subtract_pointer (hive);
#else
/* put a bee into hive */
hive->bees[i] = b;
/* set bee's data */
......@@ -164,6 +217,7 @@ SAC_MT_Helper_AllocHiveCommons (unsigned num_bees, unsigned num_schedulers,
b->thread_id
= SAC_HM_THREADID_INVALID; /* must be assigned within the thread! */
b->hive = hive;
#endif
}
}
......@@ -174,8 +228,11 @@ SAC_MT_Helper_AllocHiveCommons (unsigned num_bees, unsigned num_schedulers,
hive->queen_class >>= 1;
/* increment the number of hives in the system */
// change the SAC_MT elements to offsets in the SCC case.
#if defined(SAC_MT_LIB_scc)
printf ("Bees pointer before offset %p \n ", hive->bees);
hive->bees = scc_subtract_pointer (hive->bees);
SAC_MT_cnt_hives += 1;
SAC_MT_cnt_worker_bees += num_bees - 1;
#else
......@@ -200,12 +257,51 @@ SAC_MT_Helper_FreeHiveCommons (struct sac_hive_common_t *hive)
{
/* decrement the number of hives in the environment */
#if defined(SAC_MT_LIB_scc)
printf ("%s other bee:", "RelaseHive Commons 1 \n");
fflush (NULL);
if (hive->num_bees > 1) {
/* the other_bees ptr below is equal to the identically-named variable in
* SAC_MT_Helper_AllocHiveCommons() */
struct sac_bee_common_t **bees
= (struct sac_bee_common_t **)scc_plus_pointer (hive->bees);
printf ("%s bees: %p \n", "RelaseHive Commons 1 \n", bees);
fflush (NULL);
printf ("bee[1] %p \n", bees[1]);
fflush (NULL);
struct sac_bee_common_t *other_bees
= (struct sac_bee_common_t *)scc_plus_pointer (bees[1]);
printf ("%s \n", "free other bee", bees[1]);
fflush (NULL);
SAC_FREE (other_bees);
}
printf ("%s", "RelaseHive Commons 2 \n");
fflush (NULL);
/* free the array of pointers */
SAC_FREE (scc_plus_pointer (hive->bees));
hive->bees = NULL;
printf ("%s", "RelaseHive Commons 3 \n");
fflush (NULL);
/* free the scheduler's data; typecast due to volatile */
SAC_FREE ((void *)scc_plus_pointer (hive->SAC_MT_Tasklock));
SAC_FREE ((void *)scc_plus_pointer (hive->SAC_MT_Task));
SAC_FREE ((void *)scc_plus_pointer (hive->SAC_MT_LAST_Task));
SAC_FREE ((void *)scc_plus_pointer (hive->SAC_MT_rest_iterations));
SAC_FREE ((void *)scc_plus_pointer (hive->SAC_MT_act_tasksize));
SAC_FREE ((void *)scc_plus_pointer (hive->SAC_MT_last_taskend));
SAC_FREE ((void *)scc_plus_pointer (hive->SAC_MT_TS_Tasklock));
SAC_FREE ((void *)scc_plus_pointer (hive->SAC_MT_Taskcount));
printf ("%s", "RelaseHive Commons 4 \n");
fflush (NULL);
SAC_MT_cnt_hives -= 1;
SAC_MT_cnt_worker_bees -= hive->num_bees - 1;
printf ("%s", "RelaseHive Commons 5 \n");
fflush (NULL);
#else
__sync_sub_and_fetch (&SAC_MT_cnt_hives, 1);
__sync_sub_and_fetch (&SAC_MT_cnt_worker_bees, hive->num_bees - 1);
#endif
if (hive->num_bees > 1) {
/* the other_bees ptr below is equal to the identically-named variable in
......@@ -228,8 +324,14 @@ SAC_MT_Helper_FreeHiveCommons (struct sac_hive_common_t *hive)
SAC_FREE ((void *)hive->SAC_MT_TS_Tasklock);
SAC_FREE ((void *)hive->SAC_MT_Taskcount);
__sync_sub_and_fetch (&SAC_MT_cnt_hives, 1);
__sync_sub_and_fetch (&SAC_MT_cnt_worker_bees, hive->num_bees - 1);
#endif
/* free the hive itself */
SAC_FREE (hive);
printf ("%s \n", "End of FreeHiveCommons");
fflush (NULL);
}
/****************************************************************************
......@@ -250,12 +352,28 @@ void
SAC_MT_Generic_AttachHive (struct sac_hive_common_t *hive, struct sac_bee_common_t *queen)
#endif
{
printf ("genericattachhive hive: %p, queen %p \n", hive, queen);
fflush (NULL);
/* check: the hive must not be already attached */
if (hive->bees[0]) {
struct sac_bee_common_t **bees;
#if defined(SAC_MT_LIB_scc)
printf ("%s %p \n", "generic attach SCC SPECIFIC! ", hive->bees);
fflush (NULL);
bees = (struct sac_bee_common_t **)scc_plus_pointer (hive->bees);
printf ("%s %p \n", "generic attach SCC SPECIFIC! ", bees);
fflush (NULL);
#else
bees = hive->bees;
#endif
printf ("%s %p bees \n", "generic attach hive -1 bees: ", bees);
fflush (NULL);
if (bees[0]) {
SAC_RuntimeError ("AttachHive: Cannot attach a hive which is already attached!"
" Call DetachHive() first.");
return;
}
printf ("%s %p \n", "generic attach hive 0 quenn->hive: ", queen->hive);
fflush (NULL);
if (queen->hive) {
/* destroy the current hive */
......@@ -264,11 +382,18 @@ SAC_MT_Generic_AttachHive (struct sac_hive_common_t *hive, struct sac_bee_common
/* now we're a queen without any hive */
assert (!queen->hive);
printf ("%s \n", "generic attach hive 1");
fflush (NULL);
/* put the queen in the hive */
hive->bees[0] = queen;
bees[0] = queen;
printf ("%s \n", "generic attach hive 2");
fflush (NULL);
queen->hive = hive;
printf ("%s \n", "generic attach hive 3");
fflush (NULL);
queen->b_class = hive->queen_class;
printf ("%s \n", "generic attach hive 4");
fflush (NULL);
}
/**************************************************************************
......@@ -298,11 +423,19 @@ SAC_MT_Generic_DetachHive (struct sac_bee_common_t *queen)
}
struct sac_hive_common_t *hive = queen->hive;
printf ("hive: %p \n", hive);
fflush (NULL);
struct sac_bee_common_t **bees;
#if defined(SAC_MT_LIB_scc)
bees = (struct sac_bee_common_t **)scc_plus_pointer (hive->bees);
#else
bees = hive->bees;
#endif
/* check that we're the queen */
assert (hive->bees[0] == queen);
assert (bees[0] == queen);
/* remove the queen from the hive */
hive->bees[0] = NULL;
bees[0] = NULL;
queen->hive = NULL;
queen->b_class = 0;
......
......@@ -204,10 +204,12 @@ tls_destroy_self_bee_key (void *data)
static void
ThreadServeLoop (struct sac_bee_pth_t *SAC_MT_self)
{
struct sac_hive_common_t *common_hive
= (struct sac_hive_common_t *)scc_plus_pointer (SAC_MT_self->c.hive);
printf ("%s %p \n", "SCC CODE ThreadServceLoop", SAC_MT_self);
fflush (NULL);
printf ("Worker thread H:%p, L:%d ready. \n", SAC_MT_self->c.hive,
SAC_MT_self->c.local_id);
printf ("Worker thread H:%p, L:%d ready. \n", common_hive, SAC_MT_self->c.local_id);
fflush (NULL);
for (;;) {
/*SAC_TR_PRINT(("Worker thread H:%p, L:%d ready.",
......@@ -215,22 +217,26 @@ ThreadServeLoop (struct sac_bee_pth_t *SAC_MT_self)
/* wait on start lock: the queen will release it when all is ready
* for an SPMD execution */
printf ("%s 1: %p 2: %p \n", "wait_on_barrier", &SAC_MT_self->start_barr_locfl,
SAC_MT_self->start_barr_locfl);
printf ("%s addr_locl: %p val_locl: %u addr_shared %p val_shared %u \n",
"wait_on_barrier", &SAC_MT_self->start_barr_locfl,
SAC_MT_self->start_barr_locfl,
&CAST_HIVE_COMMON_TO_PTH (common_hive)->start_barr_sharedfl,
CAST_HIVE_COMMON_TO_PTH (common_hive)->start_barr_sharedfl);
fflush (NULL);
SAC_MT_PTH_wait_on_barrier (&SAC_MT_self->start_barr_locfl,
&CAST_HIVE_COMMON_TO_PTH (SAC_MT_self->c.hive)
&CAST_HIVE_COMMON_TO_PTH (common_hive)
->start_barr_sharedfl);
printf ("%s num_bees: %u \n", "check hive", SAC_MT_self->c.hive->num_bees);
printf ("%s num_bees: %u \n", "check hive", common_hive->num_bees);
fflush (NULL);
/* check there is a hive */
assert (SAC_MT_self->c.hive);
assert (common_hive);
// printf("%s %s %d \n", "run function",
// SAC_MT_self->c.hive->spmd_fun,SAC_MT_self->c.hive->spmd_fun); fflush(NULL);
/* run SPMD; the barrier is in the function */
printf ("%s \n", "run function");
printf ("%s \n", "run function ");
fflush (NULL);
CAST_HIVE_COMMON_TO_PTH (SAC_MT_self->c.hive)->spmd_fun (SAC_MT_self);
CAST_HIVE_COMMON_TO_PTH (common_hive)->spmd_fun (SAC_MT_self);
}
}
......@@ -256,27 +262,30 @@ ThreadControl (void *arg)
fflush (NULL);
/* This is executed in the bee >1 of a new hive */
struct sac_bee_pth_t *const SAC_MT_self = (struct sac_bee_pth_t *)arg;
assert (SAC_MT_self && SAC_MT_self->c.hive);
struct sac_hive_common_t *common_hive
= (struct sac_hive_common_t *)scc_plus_pointer (SAC_MT_self->c.hive);
assert (SAC_MT_self && common_hive);
assert (SAC_MT_self->c.local_id >= 1);
printf ("%s \n", "test 1");
printf ("%s localid %u %p\n", "test 1", SAC_MT_self->c.local_id,
&SAC_MT_self->c.local_id);
fflush (NULL);
pthread_setspecific (SAC_MT_self_bee_key, SAC_MT_self);
SAC_MT_self->c.thread_id = (SAC_HM_DiscoversThreads ()) ? SAC_HM_CurrentThreadId ()
: SAC_MT_self->c.local_id;
printf ("%s \n", "test 2");
printf ("%s hive: %p \n", "test 2", common_hive);
fflush (NULL);
/* correct worker class */
while ((SAC_MT_self->c.local_id + SAC_MT_self->c.b_class)
>= SAC_MT_self->c.hive->num_bees) {
while ((SAC_MT_self->c.local_id + SAC_MT_self->c.b_class) >= common_hive->num_bees) {
SAC_MT_self->c.b_class >>= 1;
}
printf ("%s \n", "test 3");
fflush (NULL);
printf ("ThreadControl num_bees: %u", common_hive->num_bees);
printf (("This is worker thread H:%p, L:%u, T:%u with class %u.", SAC_MT_self->c.hive,
SAC_MT_self->c.local_id, SAC_MT_self->c.thread_id, SAC_MT_self->c.b_class));
printf ("%s \n", "test 4");
fflush (NULL);
struct sac_hive_pth_t *const hive = CAST_HIVE_COMMON_TO_PTH (SAC_MT_self->c.hive);
struct sac_hive_pth_t *const hive = CAST_HIVE_COMMON_TO_PTH (common_hive);
printf ("%s \n", "test 5");
fflush (NULL);
/* create other */
......@@ -528,15 +537,21 @@ EnsureThreadHasBee (void)
if (self) {
/* ok, there's a bee already */
printf ("%s %p \n", "Ensure thread has bee - there's already one: ", self);
fflush (NULL);
return self;
}
/* allocate the bee structure */
self = (struct sac_bee_pth_t *)SAC_CALLOC (1, sizeof (struct sac_bee_pth_t));
if (!self) {
SAC_RuntimeError ("Could not allocate memory for the first bee.");
}
// printf( "%s queen %p common & %p common %p \n", "Allocating a new bee", self,
// &(self->c), self->c);fflush(NULL);
printf ("%s \n ", "EnsureThreadHasBee");
fflush (NULL);
/* set bee's data */
self->c.local_id = 0;
self->c.thread_id
......@@ -583,7 +598,10 @@ SAC_MT_ReleaseHive (struct sac_hive_common_t *h)
/* no hive, no work */
return;
}
if (h->bees[0]) {
struct sac_bee_common_t **bees
= (struct sac_bee_common_t **)scc_plus_pointer (h->bees);
if (bees[0]) {
/* there is a queen! */
SAC_RuntimeError ("SAC_MT_*_ReleaseHive: Cannot release a hive with a queen."
" Call DetachHive() first.");
......@@ -598,15 +616,27 @@ SAC_MT_ReleaseHive (struct sac_hive_common_t *h)
SAC_MT_PTH_signal_barrier (NULL, &hive->start_barr_sharedfl);
/* wait on bees until done */
printf ("RelaseHive numbees: %p \n", hive->c.num_bees);
fflush (NULL);
bees = (struct sac_bee_common_t **)scc_plus_pointer (hive->c.bees);
/*for (unsigned i = 1; i < hive->c.num_bees; ++i) {
pthread_join(CAST_BEE_COMMON_TO_PTH(bees[i])->pth, NULL);
}*/
for (unsigned i = 1; i < hive->c.num_bees; ++i) {
pthread_join (CAST_BEE_COMMON_TO_PTH (hive->c.bees[i])->pth, NULL);
// pthread_join(CAST_BEE_COMMON_TO_PTH(bees[i])->pth, NULL);
}
printf ("RelaseHive numbees 2: %d \n", hive->c.num_bees);
fflush (NULL);
/* now, all slave bees should be dead; release data */
for (unsigned i = 1; i < hive->c.num_bees; ++i) {
SAC_MT_PTH_destroy_lck (&CAST_BEE_COMMON_TO_PTH (hive->c.bees[i])->stop_lck);
SAC_MT_PTH_destroy_lck (&CAST_BEE_COMMON_TO_PTH (bees[i])->stop_lck);
}
printf ("RelaseHive numbees 3: %p \n", hive->c.num_bees);
fflush (NULL);
/* release the memory */
SAC_MT_Helper_FreeHiveCommons (&hive->c);
}
......@@ -649,18 +679,28 @@ SAC_MT_AllocHive (unsigned int num_bees, int num_schedulers, const int *places,
sizeof (struct sac_hive_pth_t),
sizeof (struct sac_bee_pth_t)));
struct sac_bee_common_t **bees
= (struct sac_bee_common_t **)scc_plus_pointer ((int)hive->c.bees);
/* setup extended info in bees */
for (unsigned i = 1; i < hive->c.num_bees; ++i) {
struct sac_bee_pth_t *b = CAST_BEE_COMMON_TO_PTH (hive->c.bees[i]);
// struct sac_bee_pth_t *b = CAST_BEE_COMMON_TO_PTH(hive->c.bees[i]);
struct sac_bee_pth_t *b = CAST_BEE_COMMON_TO_PTH (
(struct sac_bee_common_t *)scc_plus_pointer ((int)bees[i]));
/* init locks */
SAC_MT_INIT_BARRIER (b);
}
// pthread_setspecific(SAC_MT_self_bee_key, CAST_BEE_COMMON_TO_PTH( (struct
// sac_bee_common_t *) scc_plus_pointer((int) bees[0])) ) ;
SAC_TR_PRINT (("Thread class of master thread is %d.", (int)hive->c.queen_class));
SAC_TR_PRINT (("AllocHive - 0 num bees %d", hive->c.num_bees));
if (hive->c.num_bees > 1) {
SAC_TR_PRINT (("Creating worker thread #1 of class 0"));
SAC_TR_PRINT (("AllocHive - 1"));
/* if (0 != pthread_create( &CAST_BEE_COMMON_TO_PTH(hive->c.bees[1])->pth,
&SAC_MT_thread_attribs,
......@@ -669,18 +709,18 @@ SAC_MT_AllocHive (unsigned int num_bees, int num_schedulers, const int *places,
SAC_RuntimeError( "Unable to create (initial) worker thread #1");
}*/
int i;
printf ("NUM BEES: %u \n", hive->c.num_bees);
printf ("HIVE: %p, again %p \n", hive, hive->c.bees[i - 1]->hive);
SAC_TR_PRINT (("AllocHive - 2 "));
// printf("HIVE: %p, again2 %p num_bees: %u \n", hive, hive->c.bees[1]->hive,
// hive->c.bees[1]->hive->num_bees);
for (i = 2; i <= hive->c.num_bees; i++) {
int offset = scc_subtract_pointer (hive->c.bees[i - 1]);
printf (
"hive int: %d hive addr: %p, hive addr2: %p offset: %d num_bees: %u \n",
hive->c.bees[i - 1], hive->c.bees[i - 1], &hive->c.bees[i - 1],
hive->c.num_bees);
int offset = bees[i - 1];
// printf("hive int: %d hive addr: %p, hive addr2: %p offset: %d num_bees: %u
// \n",hive->c.bees[i-1], hive->c.bees[i-1],
// &hive->c.bees[i-1],hive->c.num_bees );
char command[256];
strcpy (command, "ssh 192.168.0.");
char end[2];
sprintf (end, "%d", i);
sprintf (end, "%d", (i));
strcat (command, end);
strcat (command, " -f \"/shared/jacob/launch_workers -worker ");
char offset_char[128];
......@@ -780,17 +820,17 @@ void
SAC_MT_AttachHive (struct sac_hive_common_t *h)
#endif
{
SAC_TR_PRINT (("Attaching hive to a queen."));
if (!h) {
SAC_RuntimeError ("__AttachHive called with a NULL hive!");
return;
}
/* allocate a bee for the current thread, if needed */
struct sac_bee_pth_t *queen = EnsureThreadHasBee ();
/* generic attach func */
SAC_MT_Generic_AttachHive (h, &queen->c);
printf ("%s \n", "Done Generic Attach Hive");
fflush (NULL);
}
/******************************************************************************
......@@ -848,7 +888,9 @@ SAC_MT_PTH_SetupStandalone (int num_schedulers)
__AttachHive (hive);
/* In standalone programs there is only a single global queen-bee. Place her in the
* global variable. All the ST functions will take it from there. */
SAC_MT_singleton_queen = hive->bees[0];
struct sac_bee_common_t **bees
= (struct sac_bee_common_t **)scc_plus_pointer (hive->bees);
SAC_MT_singleton_queen = bees[0];
}
#if !TRACE
......@@ -895,10 +937,9 @@ void *
SAC_MT_LaunchWorker (void *arg)
#endif
{
printf ("%s pointer: %p \n", "HELLO??", arg);
fflush (NULL);
struct sac_bee_pth_t *self = (struct sac_bee_pth_t *)arg;
printf ("localid: %d \n", self->c.local_id);
struct sac_hive_common_t *hive
= (struct sac_hive_common_t *)scc_plus_pointer ((int)self->c.hive);
// int num_bees = ((struct sac_hive_common_t *)((struct sac_bee_pth_t *)
//arg)->c.hive)->num_bees; printf("%s beeid %d pointer: %p num_bees: %u \n",
// "SAC_MT_LaunchWorker", ((struct sac_bee_pth_t *) arg)->c.local_id,arg,num_bees);
......
......@@ -268,9 +268,13 @@ struct sac_hive_common_t {
/* no descriptor */
#define SAC_MT_RECEIVE_PARAM_in__NODESC(spmdfun, num, basetype, var_NT) \
printf ("%s \n", "SAC_MT_RECEIVE_PARAM_in__NODESC"); \
fflush (NULL); \
SAC_ND_TYPE (var_NT, basetype) \
SAC_ND_A_FIELD (var_NT) = SAC_MT_SELF_FRAME (spmdfun)->in_##num; \
printf ("Where is this ?? %p \n", &SAC_MT_SELF_FRAME (spmdfun)->in_##num);
printf ("Where is this ?? with & %p without %p \n", \
&SAC_MT_SELF_FRAME (spmdfun)->in_##num, \
&SAC_MT_SELF_FRAME (spmdfun)->in_##num); \
fflush (NULL);
#if 0
/* (not used) create a new but fake descriptor */
#define SAC_MT_RECEIVE_PARAM_in__NODESC__FAKERC(spmdfun, num, basetype, var_NT) \
......@@ -349,14 +353,21 @@ struct sac_hive_common_t {
printf ("%s \n", "SAC_MT_RECEIVE_PARAM_inout__DESC SCC IMP"); \
fflush (NULL); \
basetype *stack_element = SAC_MT_SELF_FRAME_SCC (spmdfun, in_##num); \
printf ("%s \n", "SAC_MT_RECEIVE_PARAM_inout__DESC SCC IMP 1"); \
fflush (NULL); \
SAC_ND_TYPE (var_NT, basetype) * SAC_NAMEP (SAC_ND_A_FIELD (var_NT)) \
= &stack_element; \
printf ("%s \n", "SAC_MT_RECEIVE_PARAM_inout__DESC SCC IMP 2"); \
fflush (NULL); \
SAC_ND_DESC_TYPE (var_NT) \
CAT0 (SAC_ND_A_DESC (var_NT), __s) \
= (SAC_ND_DESC_TYPE (var_NT) *)SAC_MT_SELF_FRAME_SCC (spmdfun, in_##num##_desc); \
printf ("%s \n", "SAC_MT_RECEIVE_PARAM_inout__DESC SCC IMP 3"); \
fflush (NULL); \
SAC_ND_DESC_TYPE (var_NT) * SAC_NAMEP (SAC_ND_A_DESC (var_NT)) \
= &CAT0 (SAC_ND_A_DESC (var_NT), __s); \
printf ("VAL: %p, VAL*: , VAL** \n", CAT0 (SAC_ND_A_DESC (var_NT), __s));
printf ("VAL: %p, VAL*: , VAL** \n", CAT0 (SAC_ND_A_DESC (var_NT), __s)); \
fflush (NULL);
#else /* SAC_DO_MT_SCC */
#define SAC_MT_RECEIVE_PARAM_inout__DESC(spmdfun, num, basetype, var_NT) \
printf ("%s \n", "SAC_MT_RECEIVE_PARAM_inout__DESC - SAC_HAS_RC_NORC = FALSE"); \
......@@ -504,27 +515,55 @@ struct sac_hive_common_t {
/*
* Macros for implementing the barrier synchronisation
*/
// void * ptr = (void *) CAST_BEE_COMMON_TO_PTH( ((struct sac_bee_common_t *) )scc_plus_pointer( ( (struct sac_bee_common_t **) scc_plus_pointer(SAC_MT_self->c.hive->bees))[SAC_MT_son_id]) ); \
#define SAC_MT_SYNC_BEGIN(spmdfun) \
{ \
printf ("%s \n", "SAC_MT_SYNC_BEGIN 0"); \
fflush (NULL); \
unsigned int SAC_MT_ready_count = SAC_MT_MYWORKERCLASS (); \
unsigned int SAC_MT_son_id; \
unsigned int SAC_MT_i; \
struct spmdfun##_RT *rdata; \
rdata = (struct spmdfun##_RT *)SAC_MT_self->c.hive->retdata; \
\
while (SAC_MT_ready_count > 0) { \
printf ("%s rdata %p added %p SAC_MT_READY_COUNT %u \n", "SAC_MT_SYNC_BEGIN 1", \
rdata, scc_plus_pointer (rdata), SAC_MT_ready_count); \
fflush (NULL); \
\
while (SAC_MT_ready_count > 0) \
{ \
printf ("%s \n", "while (SAC_MT_ready_count > 0)"); \
fflush (NULL); \
SAC_MT_i = SAC_MT_MYWORKERCLASS (); \
\
do { \
printf ("%s \n", "while (SAC_MT_ready_count > 0) bees: "); \
fflush (NULL); \
printf ("%s %p\n", \
"while (SAC_MT_ready_count > 0) hive: ", SAC_MT_self->c.hive); \
fflush (NULL); \
SAC_MT_son_id = SAC_MT_SELF_LOCAL_ID () + SAC_MT_i; \
\
printf ("SAC_MT_CHECK_BARRIER SAC_MT_self->c.hive->bees: %p localid %d " \
"%p again \n", \
SAC_MT_self->c.hive->bees, SAC_MT_self->c.local_id, \
((struct sac_bee_common_t **)scc_plus_pointer ( \
SAC_MT_self->c.hive->bees))[SAC_MT_son_id]); \
fflush (NULL); \
printf ("result %d", SAC_MT_CHECK_BARRIER (spmdfun, SAC_MT_son_id)); \
fflush (NULL); \
if (SAC_MT_CHECK_BARRIER (spmdfun, SAC_MT_son_id)) {
#define SAC_MT_SYNC_CONT(spmdfun) \
printf ("%s \n", "SAC_MT_SYNC_BEGIN 1.1"); \
fflush (NULL); \
SAC_MT_CLEAR_BARRIER (spmdfun, SAC_MT_son_id) \
SAC_MT_ready_count >>= 1; \
printf ("%s \n", "SAC_MT_SYNC_BEGIN 1.2"); \
fflush (NULL); \
if (SAC_MT_ready_count == 0) { \
printf ("%s \n", "SAC_MT_SYNC_BEGIN 1.3"); \
fflush (NULL); \
break; \
} \
} \
......@@ -532,11 +571,45 @@ struct sac_hive_common_t {
while (SAC_MT_i >>= 1) \
; \
SAC_MT_SYNC_RELAX (); \
printf ("%s \n", "SAC_MT_SYNC_BEGIN 2"); \
fflush (NULL); \
\
\
}