Пример #1
0
/****f* simple.c/app_init
*
* SUMMARY
*  This function is called at application start-up.
*  It's used to say hello, setup multicast routing table entries,
*  and initialise application variables.
*
* SYNOPSIS
*  void app_init ()
*
* SOURCE
*/
void app_init ()
{
  uint i;

  /* ------------------------------------------------------------------- */
  /* initialise routing entries                                          */
  /* ------------------------------------------------------------------- */
  /* set a MC routing table entry to send my packets back to me */

  spin1_set_mc_table_entry(coreID,                    // entry
                     coreID,                    // key
                     0xffffffff,                // mask
                     (uint) (1 << (coreID+6))   // route
                    );

  /* ------------------------------------------------------------------- */

  /* ------------------------------------------------------------------- */
  /* initialize the application processor resources                      */
  /* ------------------------------------------------------------------- */
  /* say hello */
  io_printf (IO_STD, "[core %d] -----------------------\n", coreID);
  spin1_delay_us (PRINT_DLY);
  io_printf (IO_STD, "[core %d] starting simulation\n", coreID);
  spin1_delay_us (PRINT_DLY);

  /* use a buffer in the middle of system RAM - avoid conflict with RTK */
  sysram_buffer = (uint *) (SPINN_SYSRAM_BASE + SPINN_SYSRAM_SIZE/2
                            + (coreID * BUFFER_SIZE * sizeof(uint)));
  /* use a buffer somewhere in SDRAM */
  sdram_buffer  = (uint *) (SPINN_SDRAM_BASE + SPINN_SDRAM_SIZE/8
                            + (coreID * BUFFER_SIZE * sizeof(uint)));

  /* allocate buffer in DTCM */
  if ((dtcm_buffer = (uint *) spin1_malloc(BUFFER_SIZE*sizeof(uint))) == 0)
  {
    test_DMA = FALSE;
    io_printf (IO_STD, "[core %d] error - cannot allocate dtcm buffer\n", coreID);
    spin1_delay_us (PRINT_DLY);
  }
  else
  {
    test_DMA = TRUE;
    /* initialize sections of DTCM, system RAM and SDRAM */
    for (i=0; i<BUFFER_SIZE; i++)
    {
      dtcm_buffer[i]   = i;
      sysram_buffer[i] = 0xa5a5a5a5;
      sdram_buffer[i]  = 0x5a5a5a5a;
    }
    io_printf (IO_STD, "[core %d] dtcm buffer @ 0x%8z\n", coreID,
               (uint) dtcm_buffer);
    spin1_delay_us (PRINT_DLY);
  }
  /* ------------------------------------------------------------------- */
}
/**
 * Load the routing tables and router parameters as required by the current
 * experiment. The existing router parameters are stored into the
 * rtr_control_orig_state to be restored by cleanup_router at the end of the
 * experiment.
 */
void
setup_router(void)
{
	// Install the router entries
	for (int i = 0; i < config_root.num_router_entries; i++) {
		if (!spin1_set_mc_table_entry( i
		                             , config_router_entries[i].key
		                             , config_router_entries[i].mask
		                             , config_router_entries[i].route
		                             )) {
			io_printf( IO_BUF, "Could not load routing table entry %d with key 0x%08x"
			         , i
			         , config_router_entries[i].key
			         );
			config_root.completion_state = COMPLETION_STATE_FAILIURE;
		}
	}
	
	// Only one core should configure the router
	if (leadAp) {
		// Store the current router configuration
		rtr_control_orig_state = rtr_unbuf[RTR_CONTROL];
		
		// Set up the packet drop timeout
		rtr_unbuf[RTR_CONTROL] = (rtr_unbuf[RTR_CONTROL] & ~0x00FF8000u)
		                       | (config_root.rtr_drop_e<<4 | config_root.rtr_drop_m) << 16
		                       | 1<<15 // Re-initialise counters
		                       ;
		
		// Configure forwarded packets counter
		rtr_unbuf[FWD_CNTR_CFG] = (0x1<< 0) // Type = nn
		                        | (0x1<< 4) // ER = 0 (non-emergency-routed packets)
		                        | (  0<< 8) // M = 0 (match emergency flag on incoming packets)
		                        | (0x3<<10) // Def = Match default and non-default routed packets
		                        | (0x3<<12) // PL = Match packets with and without payloads
		                        | (0x3<<14) // Loc = Match local and external packets
		                        | ( (0x1F<<19) // Match all external links
		                          | (   0<<18) // Don't match monitor packets
		                          | (   1<<17) // Match packets to local non-monitor cores
		                          | (   0<<16) // Don't match dropped packets
		                          ) // Dest = Which destinations should be matched
		                        | (  0<<30) // E = Don't enable interrupt on event
		                        ;
		
		// Configure dropped packets counter
		rtr_unbuf[DRP_CNTR_CFG] = (0x1<< 0) // Type = nn
		                        | (0x1<< 4) // ER = 0 (non-emergency-routed packets)
		                        | (  0<< 8) // M = 0 (match emergency flag on incoming packets)
		                        | (0x3<<10) // Def = Match default and non-default routed packets
		                        | (0x3<<12) // PL = Match packets with and without payloads
		                        | (0x3<<14) // Loc = Match local and external packets
		                        | ( (0x00<<19) // Don't match external links
		                          | (   0<<18) // Don't match monitor packets
		                          | (   0<<17) // Don't match packets to local non-monitor cores
		                          | (   1<<16) // Match dropped packets
		                          ) // Dest = Which destinations should be matched
		                        | (  0<<30) // E = Don't enable interrupt on event
		                        ;
	}
	
	// Allow change to make it into the router
	spin1_delay_us(10000);
}
Пример #3
0
void c_main (void)
{
    // simulation initialization
    coreID = spin1_get_core_id();
    chipID = spin1_get_chip_id();

    spin1_set_timer_tick(TICK_TIME);

    // the intrachip communication is totally independent from a
    // chip to another. chips do not interfere with each other (good point)


    if(chipID == 0) { // 0, 0
        // in this chip, we test master to nodes, then nodes to master
        // results: performance is good


        // from master to nodes
        spin1_set_mc_table_entry(0x6, 	ERROR_MSG,	 0xFFFFFFFF, ALL_NODES_MASTER_CHIP);
        // froms nodes to master
        spin1_set_mc_table_entry(0x7, 	UPD_MSG,	 0xFFFFFFFF, MASTER_CORE);

        if(coreID == 1) { // master core
            // events setting
            spin1_callback_on(MC_PACKET_RECEIVED,eventMaster_chip0,0);
            spin1_callback_on(TIMER_TICK, update_chip0, 0);

        }
        else { // nodes
            // events setting
            spin1_callback_on(MC_PACKET_RECEIVED,eventNode_chip0,0);
        }


    }
    else if(chipID == 1) { // 0, 1
        // in this chip, we test parallel message sending (core 1 to 2, core 3 to 4 and core 5 to 6, independently)
        // results: performance good


        spin1_set_mc_table_entry(0x2, 	0x2,	 0xFFFFFFFF, CORE(2));
        spin1_set_mc_table_entry(0x4, 	0x4,	 0xFFFFFFFF, CORE(4));
        spin1_set_mc_table_entry(0x6, 	0x6,	 0xFFFFFFFF, CORE(6));


        if(coreID == 3 | coreID == 1 | coreID == 5) { // sending cores
            spin1_callback_on(TIMER_TICK, update_chip1, -2);

        }
        else { // receiving cores
            spin1_callback_on(MC_PACKET_RECEIVED,eventRec_chip1,-1);
        }

    }
    else if(chipID == 256) { // 1, 0
        // ...
    }
    else if(chipID == 257) { // 1, 1
        // ...
    }

    // Note that calling io_printf in the functions slows down a lot the system.
    // Therefore tests should be performed without calling this function
    // (or calling it not so often)


    spin1_start();
}
Пример #4
0
void routing_table_init () {
  my_key = ROUTING_KEY(chipID, coreID);
  init_arrived = NONE_ARRIVED;

  if (IS_NORTHERNMOST_CORE(coreID)) {
    if (IS_NORTHERNMOST_CHIP(my_x, my_y)) {
      // don't send packets north
      // don't expect packets from north
      north_key = DONT_ROUTE_KEY;
      init_arrived |= NORTH_ARRIVED;
    } else {
      // send packets to chip to the north
      my_route |= ROUTE_TO_LINK(NORTH_LINK);
      // expect packets from chip to the north (southernmost core)
      route_from_north = TRUE;
      north_key = ROUTING_KEY(CHIP_TO_NORTH(chipID), SOUTHERNMOST_CORE(coreID));
    }
  } else {
    // expect packets from north
    north_key = ROUTING_KEY(chipID, CORE_TO_NORTH(coreID));
    // send to north core
    my_route |= ROUTE_TO_CORE(CORE_TO_NORTH(coreID));
  }

  if (IS_SOUTHERNMOST_CORE(coreID)) {
    if (IS_SOUTHERNMOST_CHIP(my_x, my_y)) {
      // don't send packets south
      // don't expect packets from south
      south_key = DONT_ROUTE_KEY;
      init_arrived |= SOUTH_ARRIVED;
    } else {
      // send packets to chip to the south
      my_route |= ROUTE_TO_LINK(SOUTH_LINK);
      // expect packets from chip to the south (northernmost core)
      route_from_south = TRUE;
      south_key = ROUTING_KEY(CHIP_TO_SOUTH(chipID), NORTHERNMOST_CORE(coreID));
    }
  } else {
    // expect packets from south
    south_key = ROUTING_KEY(chipID, CORE_TO_SOUTH(coreID));
    // send to south core
    my_route |= ROUTE_TO_CORE(CORE_TO_SOUTH(coreID));
  }


  spin1_set_mc_table_entry((6 * coreID), // entry
                     my_key,             // key
                     0xffffffff,         // mask
                     my_route            // route
                    );

  /* set MC routing table entries to get packets from neighbour chips */
  /* north */
  if (route_from_north)
  {
    spin1_set_mc_table_entry((6 * coreID) + 1,     // entry
                             north_key,            // key
                             0xffffffff,           // mask
                             ROUTE_TO_CORE(coreID) // route
                            );
  }

  /* south */
  if (route_from_south)
  {
    spin1_set_mc_table_entry((6 * coreID) + 2,     // entry
                             south_key,            // key
                             0xffffffff,           // mask
                             ROUTE_TO_CORE(coreID) // route
                            );
  }


}