Skip to content

Commit

Permalink
Merge pull request #24 from SpiNNakerManchester/basic_rogers
Browse files Browse the repository at this point in the history
Basic rogers
  • Loading branch information
Luis A. Plana authored May 22, 2020
2 parents 67c1969 + 7209981 commit 5ff3a36
Show file tree
Hide file tree
Showing 28 changed files with 1,298 additions and 1,051 deletions.
22 changes: 11 additions & 11 deletions c_code/comms_i.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
// ------------------------------------------------------------------------
void i_receivePacket (uint key, uint payload)
{
#ifdef DEBUG
pkt_recv++;
#endif

// check if stop packet
if ((key & SPINN_TYPE_MASK) == SPINN_STOP_KEY)
{
// sync packet received
// stop packet received
#ifdef DEBUG
stp_recv++;
#endif
Expand All @@ -31,24 +35,25 @@ void i_receivePacket (uint key, uint payload)
io_printf (IO_BUF, "sc:%x\n", tick_stop);
#endif

// check if all threads done
if (if_thrds_done == 0)
// check if all other threads done
if (if_thrds_pend == 0)
{
// if done initialize semaphore,
if_thrds_done = 1;
if_thrds_pend = 1;

// and advance tick
spin1_schedule_callback (if_advance_tick, NULL, NULL, SPINN_I_TICK_P);
}
else
{
// if not done report processing thread done
if_thrds_done -= 1;
if_thrds_pend -= 1;
}

return;
}

// check if network stop packet
if ((key & SPINN_TYPE_MASK) == SPINN_STPN_KEY)
{
// network stop packet received
Expand All @@ -61,13 +66,8 @@ void i_receivePacket (uint key, uint payload)
return;
}

#ifdef DEBUG
pkt_recv++;
#endif

// check if space in packet queue,
// queue packet - if space available
uint new_tail = (i_pkt_queue.tail + 1) % SPINN_INPUT_PQ_LEN;

if (new_tail == i_pkt_queue.head)
{
// if queue full exit and report failure
Expand Down
56 changes: 28 additions & 28 deletions c_code/comms_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
// ------------------------------------------------------------------------
void s_receivePacket (uint key, uint payload)
{
#ifdef DEBUG
pkt_recv++;
#endif

// check if stop packet
if ((key & SPINN_TYPE_MASK) == SPINN_STOP_KEY)
{
Expand All @@ -31,23 +35,26 @@ void s_receivePacket (uint key, uint payload)
io_printf (IO_BUF, "sc:%x\n", tick_stop);
#endif

// check if all threads done
if (sf_thrds_done == 0)
// check if all other threads done
if (sf_thrds_pend == 0)
{
// if done initialise semaphore
sf_thrds_done = 1;
sf_thrds_pend = 1;

// and advance tick
spin1_schedule_callback (sf_advance_tick, NULL, NULL, SPINN_S_TICK_P);
}
else
{
// if not done report processing thread done
sf_thrds_done -= 1;
sf_thrds_pend -= 1;
}

return;
}

// check if network stop packet
else if ((key & SPINN_TYPE_MASK) == SPINN_STPN_KEY)
if ((key & SPINN_TYPE_MASK) == SPINN_STPN_KEY)
{
// network stop packet received
#ifdef DEBUG
Expand All @@ -58,33 +65,26 @@ void s_receivePacket (uint key, uint payload)
spin1_exit (SPINN_NO_ERROR);
return;
}

// queue packet - if space available
uint new_tail = (s_pkt_queue.tail + 1) % SPINN_SUM_PQ_LEN;
if (new_tail == s_pkt_queue.head)
{
// if queue full exit and report failure
spin1_exit (SPINN_QUEUE_FULL);
}
else
{
#ifdef DEBUG
pkt_recv++;
#endif
// if not full queue packet,
s_pkt_queue.queue[s_pkt_queue.tail].key = key;
s_pkt_queue.queue[s_pkt_queue.tail].payload = payload;
s_pkt_queue.tail = new_tail;

// check if space in packet queue,
uint new_tail = (s_pkt_queue.tail + 1) % SPINN_SUM_PQ_LEN;

if (new_tail == s_pkt_queue.head)
// and schedule processing thread -- if not active already
if (!s_active)
{
// if queue full exit and report failure
spin1_exit (SPINN_QUEUE_FULL);
}
else
{
// if not full queue packet,
s_pkt_queue.queue[s_pkt_queue.tail].key = key;
s_pkt_queue.queue[s_pkt_queue.tail].payload = payload;
s_pkt_queue.tail = new_tail;

// and schedule processing thread -- if not active already
if (!s_active)
{
s_active = TRUE;
spin1_schedule_callback (s_process, NULL, NULL, SPINN_S_PROCESS_P);
}
s_active = TRUE;
spin1_schedule_callback (s_process, NULL, NULL, SPINN_S_PROCESS_P);
}
}
}
Expand Down
Loading

0 comments on commit 5ff3a36

Please sign in to comment.