Exemplo n.º 1
0
void main(){

// Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();
	int i = 0;
	// wait for the go (which means actors are connected)
	while(Mailbox.pGo[me.corenum] == 0);

timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);

	while(i < IN_BUFFER_SIZE)
	{
		// action a0
		int D0, D1;

		D0 = port_read(&X);
		D1 = port_read(&X);
		// end of a0

		// action a1
		int d2, d3;

		d2 = port_read(&X);
		d3 = port_read(&X);

#if 1
		port_write(&Y, D0 + d2); i++;
		port_write(&Y, D0 - d2); i++;
		port_write(&Y, D1 + d3); i++;
		port_write(&Y, D1 - d3); i++;
		// end of a1
#endif

#if 0
		Mailbox.pOutputBuffer[i] = D0 + d2; i++;
		Mailbox.pOutputBuffer[i] = D0 - d2; i++;
		Mailbox.pOutputBuffer[i] = D1 + d3; i++;
		Mailbox.pOutputBuffer[i] = D1 - d3; i++;
#endif
	}
#if 0
*Mailbox.pOutputReady = 10;
#endif

// Get timer value, find the elapsed time and stop 
timerValue = e_ctimer_get(E_CTIMER_1);
Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_1);
}
Exemplo n.º 2
0
int main(int argc, char** args) {
	(void) argc; (void) args;

	e_irq_global_mask(E_TRUE);

	const u32 w = *(u32*) 0x40;
	const u32 h = *(u32*) 0x44;

	f32* b_kh = b;
	f32* c_jh;

	// if (a != (const f32*) 0x2000 || b != (const f32*) 0x4000 || c != (const f32*) 0x6000) {
	// 	*(UserInterrupt*) 0x24 = UserInterrupt::Error;
	// 	return 0;
	// }

	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
	e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX);

	e_ctimer_start(E_CTIMER_0, E_CTIMER_FPU_INST);
	e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);

	for (u32 k = 0; k < w; k += 1) {
		c_jh = c;
		for (u32 j = 0; j < h; j += 1) {
			f32 a_jw_k = a[j*w + k];
			for (u32 i = 0; i < h;) {
				if (i + 1 < h) {
					c_jh[i    ] += a_jw_k * b_kh[i    ];
					c_jh[i + 1] += a_jw_k * b_kh[i + 1];
					i += 2;
				} else {
					c_jh[i    ] += a_jw_k * b_kh[i    ];
					i += 1;
				}
			}
			c_jh += h;
		}
		b_kh += h;
	}

// 	for (u32 k = 0; k < w; k += 1) { // this order of loops is faster than the others on epiphany
// 		for (u32 j = 0; j < h; j += 1) {
// 			for (u32 i = 0; i < h; i += 1) {
// 				c[j*h + i] += a[j*w + k] * b[k*h + i];
// 			}
// 		}
// 	}

	u32 cycles = (u32) e_ctimer_get(E_CTIMER_1);
	u32 fpops  = (u32) e_ctimer_get(E_CTIMER_0);

	*(u32*) 0x48 = E_CTIMER_MAX - cycles;
	*(u32*) 0x4c = E_CTIMER_MAX - fpops;

	*(UserInterrupt*) 0x24 = UserInterrupt::Done;

	return 0;
}
Exemplo n.º 3
0
void main(){

  // Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_CLK, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();
	int i = 0;

	// wait for the go (which means actors are connected)
	while(Mailbox.pGo[me.corenum] == 0);

timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_CLK, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);

	while(i < IN_BUFFER_SIZE)
	{
		// action a0
		int a, b, c, d;
	
		a = port_read(&X);
		b = port_read(&X);
		c = port_read(&X);
		d = port_read(&X);

#if 1
		port_write(&Y, (a + c) >> 8); i++;
		port_write(&Y, (a - c) >> 8); i++;
		port_write(&Y, (b + d) >> 8); i++;
		port_write(&Y, (b - d) >> 8); i++;
		// end of action a0
#endif

#if 0
		Mailbox.pOutputBuffer[i] = (a + c) >> 8; i++;
		Mailbox.pOutputBuffer[i] = (a - c) >> 8; i++;
		Mailbox.pOutputBuffer[i] = (b + d) >> 8; i++;
		Mailbox.pOutputBuffer[i] = (b - d) >> 8; i++;
#endif

	}

#if 0
*Mailbox.pOutputReady = 12;
#endif

// Get timer value, find the elapsed time and stop 
timerValue = e_ctimer_get(E_CTIMER_1);
Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_1);
}
Exemplo n.º 4
0
void main()
{
  // Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();
	int i = 0;
	int a, b;
	int w0, w1;

	// Wait until we get the go message from the host
	while(Mailbox.pGo[me.corenum] == 0); 

timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);
	// Run continuously
	while(i < (IN_BUFFER_SIZE * 2))//temporary value 128
	{
	  w0 = ww0;
	  w1 = ww1;
		index0 = (index0 + 1) & 3;

		ww0 = W0[index0];
		ww1 = W1[index0];

		a = port_read(&X);
		b = port_read(&X);

// For full version we need to change the following line to #ifdef FULL
#if 1
		port_write(&Y, a * w0); i++;
		port_write(&Y, a * w1); i++;
		port_write(&Y, b * w0); i++;
		port_write(&Y, b * w1); i++;
#endif

#if 0
		// Send the outputs to the host
		Mailbox.pOutputBuffer[i] = a * w0; i++;
		Mailbox.pOutputBuffer[i] = a * w1; i++;
		Mailbox.pOutputBuffer[i] = b * w0; i++;
		Mailbox.pOutputBuffer[i] = b * w1; i++;
#endif
	}
	
// Get timer value, find the elapsed time and stop 
timerValue = e_ctimer_get(E_CTIMER_1);
Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_1);
}
Exemplo n.º 5
0
/**
 * Timer1 ISR
 * This routine is installed with the interrupt Attach function
 * There will be no signal number attached when invoked
 * @param signum: not used
 */
void __attribute__((interrupt)) timer1_trace_isr(int signum)
{
   (void)signum;

	e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX);
	e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);
	return;
}
Exemplo n.º 6
0
/**
 * Start trace, but wait until all processors on this chip are ready and waiting to start
 */
int trace_start_wait_all()
{
	e_irq_attach(E_WAND_INT, wand_trace_isr);
	e_irq_mask(E_WAND_INT, 0);
	__asm__ __volatile__("wand"); // Set our WAND bit
	__asm__ __volatile__("idle"); // Idle and wait for an interrupt
	e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK); // Start counting
	return 0;
}
int main(void){
  test_t *me = (void *) 0x7000;
  void   *pmem, *src, *dst;
  
  pmem = (void *) (e_emem_config.base + 0x01000000);
  me->eot = 0;
  
  me->sram_clocks_read = me->sram_clocks_write = 11223344;
  me->eram_clocks_read = me->eram_clocks_write = 55667788;
  
  me->eot = 1;
  
  // Initialize timer
  e_irq_mask(E_TIMER0_INT, E_TRUE);
  e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
  
  // Measure time for local -> SRAM
  src = (void *) (Abuf);
  dst = (void *) e_get_global_address(0, 1, (void *) 0x2000);
  me->sram_clocks_write = e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
  e_memcopy(dst, src, _BUF_SZ);
  me->sram_clocks_write -= e_ctimer_get(E_CTIMER_0);
  
  me->eot = 2;
  
  // Measure time for SRAM -> local
  src = (void *) e_get_global_address(0, 1, (void *) 0x4000);
  dst = (void *) (Bbuf);
  me->sram_clocks_read = e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
  e_memcopy(dst, src, _BUF_SZ);
  me->sram_clocks_read -= e_ctimer_get(E_CTIMER_0);
  
  me->eot = 3;
  
  // Measure time for local -> ERAM
  src = (void *) (Abuf);
  dst = (void *) (pmem+0x0000);
  me->eram_clocks_write = e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
  e_memcopy(dst, src, _BUF_SZ);
  me->eram_clocks_write -= e_ctimer_get(E_CTIMER_0);
  
  me->eot = 4;
  
  // Measure time for ERAM -> local
  src = (void *) (pmem+0x0000);
  dst = (void *) (Bbuf);
  me->eram_clocks_read = e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
  e_memcopy(dst, src, _BUF_SZ);
  me->eram_clocks_read -= e_ctimer_get(E_CTIMER_0);
  
  me->eot = 5;
  
  return EXIT_SUCCESS;
}
Exemplo n.º 8
0
int main(void)
{
	e_mutex_t *mutex;
	volatile unsigned *po;
	unsigned time_p;
	unsigned time_c;
	int i;
	unsigned *box;
	unsigned *box1;
	
	// Define the address of mutex
	mutex = (int *)0x00004000;
	
	// Define the address of counter
	po = (int *)0x00006000;
	
	// Define the mailbox
	box = (int *)0x00006200;
	box1 = (int *)0x00006300;
	
	// Initialize the counter to 0
	*po = 0;
			
	// Initialize the mutex in core (0,0)
	e_mutex_init(0, 0, mutex, MUTEXATTR_NULL);
	
	// Start counting 
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	time_p = e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	// Wait to get the key
	e_mutex_lock(0, 0, mutex);
		
	// Add 1 to counter
	po[0] = po[0] + 1;
	
	// Release the key
	e_mutex_unlock(0, 0, mutex);

	while(po[0] != 16) {};
	
	// Return the value of counter
	time_c = e_ctimer_get(E_CTIMER_0);

	*box = time_p - time_c;
	*box1 = po[0];
	
return 0;
}
Exemplo n.º 9
0
int main(void)
{
	e_mutex_t *mutex;
	volatile unsigned *po;
	unsigned time_p;
	unsigned time_c;
	unsigned clk_hardcode;
	int i;
	unsigned *box;
	unsigned *box1;
	clk_hardcode = 19118172;
	mutex = (int *)0x00004000;
	po = (int *)0x00006000;
	box = (int *)0x00006200;
	box1 = (int *)0x00006300;
	*po = 0;
			
	//for (i=0; i<16; i++)
	//	((unsigned *) 0x6200)[i] = 0xdeadbeef;
	// Initialize the mutex in core (0,0)
	e_mutex_init(0, 0, mutex, MUTEXATTR_NULL);
	
	// Start counting 
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);

	// Wait to get the key
	e_mutex_lock(0, 0, mutex);
		
	// Add 1 to counter
	po[0] = po[0] + 1;
	
	// Release the key
	e_mutex_unlock(0, 0, mutex);

	while(po[0] != 16) {};
	
	// Return the value of counter
	time_c = e_ctimer_get(E_CTIMER_0);

	*box = time_p - time_c;
	*box1 = po[0];
	
return 0;
}
Exemplo n.º 10
0
int main () {
  
  e_coreid_t coreid;
  unsigned int row, col, core, trow, tcol, *ec;
  volatile msg_block_t *msg = (msg_block_t *) BUF_ADDRESS;
  
  e_ctimer_set(E_CTIMER_0, 0xffffffff);
  e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
 
  ec = (unsigned int *) 0x4000;
  *ec = 0;
  
  coreid = e_get_coreid();
  e_coords_from_coreid(coreid, &row, &col);
   
  core = row*e_group_config.group_cols + col;
  
  srand(msg->shared_msg[core].seed);
  msg->shared_msg[core].seed = msg->shared_msg[core].seed + 10;
  
  trow = ((core + 1) % E_GROUP_CORES) / e_group_config.group_rows;
  tcol =  (core + 1) % e_group_config.group_cols;
  
  ec = e_get_global_address(trow, tcol, ec);
  e_write(&e_group_config, &coreid, 0, 0, ec, sizeof(e_coreid_t));
  /**ec = coreid;*/
  msg->shared_msg[core].msg = e_coreid_from_coords(trow, tcol);
  msg->shared_msg[core].external = *(unsigned int *) 0x4000;
    
  /* Sync */
  e_wait(E_CTIMER_1, 2000); 
  msg->shared_msg[core].timer = 0xffffffff - e_ctimer_get(E_CTIMER_0);
  msg->shared_msg[core].coreid = coreid;

  e_ctimer_stop(E_CTIMER_0);
  
  return 0;
  
}
Exemplo n.º 11
0
int main(void)
{
	unsigned mesh_reg;
	unsigned mesh_reg_modify;
	unsigned time_c, time_p;
	unsigned time;
	unsigned tran,k,i,j,h,m,n,q;
	unsigned *mailbox, *mode;
	unsigned *commander;
	unsigned *counter;
	unsigned *master, *slave, *p;
	unsigned *row, *col;
	unsigned *n_row, *n_col;
	unsigned *neighbour0, *neighbour1, *neighbour2, *neighbour3;
	
	row = (unsigned *)0x5000;
	col = (unsigned *)0x5004;
	n_row = (unsigned *)0x5008;
	n_col = (unsigned *)0x500c;
	master = (unsigned *)0x2000;
	p =(unsigned *) 0x2000;
	slave = (unsigned *) e_get_global_address(*row, *col, p);
	commander = (unsigned *)0x5100;
	p = (unsigned *) 0x5300;
	counter = (unsigned *) e_get_global_address(*row, *col, p);
	mailbox = (unsigned *)0x6000;
	mode = (unsigned *)0x5400;
	tran = 2048;
	
	// Core number 
	k = (e_group_config.core_row)*e_group_config.group_cols + (e_group_config.core_col);
	
	// Broadcast to all the other neighbours
	p = (unsigned *)0x5100;
	e_neighbor_id(E_PREV_CORE, E_ROW_WRAP, n_row, n_col);
	neighbour0 = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;
	
	e_neighbor_id(E_NEXT_CORE, E_ROW_WRAP, n_row, n_col);
	neighbour1 = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;
	
	e_neighbor_id(E_PREV_CORE, E_COL_WRAP, n_row, n_col);
	neighbour2 = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;
	
	e_neighbor_id(E_NEXT_CORE, E_COL_WRAP, n_row, n_col);
	neighbour3 = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;
	
	// Initialize master and slave
	for(i=0; i<tran; i++)
	{
		master[i] = 0xdeadbee9;
		slave[i] = 0x00000000;
	}
	
	while(1)
	{
		//Clear the mode box
		mode[0] = 0xdeadbeef;	

		// Clear the start commander 
		commander[0] = 0x00000000;
		
		// Wait for the mesh event
		while(mode[0] == 0xdeadbeef)
		{};
		
		q = mode[0];
		mesh_reg = e_reg_read(E_REG_MESH_CONFIG);
		mesh_reg_modify = mesh_reg & 0xffffff0f;
		mesh_reg_modify = mesh_reg_modify |mesh_type[1][q]; 
		e_reg_write(E_REG_MESH_CONFIG, mesh_reg_modify);
		
		// Set the ctimer
		e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;		
		
		// Waiting for the signal to start transfering
		while(commander[0] != 0xdeadbeef)
		{};
		
		// Start the ctimer and select the time type
		time_p = e_ctimer_start(E_CTIMER_0, E_CTIMER_MESH_0);
	
		// Broadcast to all the other neighbours
		neighbour0[0] = 0xdeadbeef;
		neighbour1[0] = 0xdeadbeef;
		neighbour2[0] = 0xdeadbeef;
		neighbour3[0] = 0xdeadbeef;
		
		e_dma_copy(slave, master, 0x2000);	
		
		// Wait for transfer finishing
		while(slave[2047] != 0xdeadbee9 )
		{};
		counter[k] = 1;
	
		// Get the time now
		time_c = e_ctimer_get(E_CTIMER_0);
	
		time = time_p - time_c;		
		
		// Output the result
		mailbox[q] = time;
		
		// Load the original value of E_REG_MESH_CONFIG
		e_reg_write(E_REG_MESH_CONFIG, mesh_reg);
	
		// Check if all the mesh events have been through
		if(q == 12)
		{
			break;
		}
	}
	return 0;
}
Exemplo n.º 12
0
int main(void)
{
	unsigned time_c, time_p;
	unsigned time;
	unsigned i,j,q,h,m,n,k;
	unsigned *commander;
	unsigned *counter;
	unsigned *mailbox;
	unsigned *n_row, *n_col;
	unsigned *neighbour0, *neighbour1, *neighbour2, *neighbour3, *p;
	
	commander = (unsigned *)0x6100;
	counter = (unsigned *)0x6300;
	mailbox = (unsigned *)0x5000;
	n_row = (unsigned *)0x5100;
	n_col = (unsigned *)0x5200;
	p = (unsigned *)0x6100;
	
	// Broadcast to all neighbours
	e_neighbor_id(E_PREV_CORE, E_ROW_WRAP, n_row, n_col);
	neighbour0 = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;
	
	e_neighbor_id(E_NEXT_CORE, E_ROW_WRAP, n_row, n_col);
	neighbour1 = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;
	
	e_neighbor_id(E_PREV_CORE, E_COL_WRAP, n_row, n_col);
	neighbour2 = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;
	
	e_neighbor_id(E_NEXT_CORE, E_COL_WRAP, n_row, n_col);
	neighbour3 = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;
	
	// Get core information
	k = e_group_config.core_row * e_group_config.group_cols + e_group_config.core_col;
	
	// Clear the counter of finishing transfering
	for(i=0; i<(e_group_config.group_rows*e_group_config.group_cols); i++)
	{
		counter[i] = 0;
	}
	
	// Initialize the commander and counter for the specific core
	counter[k] = 1;
	commander[0] = 0x00000000;
	
	
	// Set the ctimer
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
			
	// Waiting for the signal of starting transfering
	while(commander[0] != (unsigned)0xdeadbeef)
	{};
	
	// Broadcast the signal to neighbours
	neighbour0[0] = 0xdeadbeef;
	neighbour1[0] = 0xdeadbeef;
	neighbour2[0] = 0xdeadbeef;
	neighbour3[0] = 0xdeadbeef;
	
	// Start the ctimer and select the time type
	time_p = e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	
	while(1)
	{
		if((counter[0]&counter[1]&counter[2]&counter[3]&counter[4]&counter[5]
		   &counter[6]&counter[7]&counter[8]&counter[9]&counter[10]&counter[11]
		   &counter[12]&counter[13]&counter[14]&counter[15]) != 0)
		{
			time_c = e_ctimer_get(E_CTIMER_0);
			break;
		}	
	}
	
	time = time_p - time_c;	
	mailbox[0] = time;
	
	return 0;
}
Exemplo n.º 13
0
void main()
{
  // Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	int x0, x1, x2, x3, x5;
	int i = 0;
#if 0
int j = 0;
#endif
	// Initialize data structures - mainly target pointers
	init();

	// Wait for the connect actors signal
	while(*Mailbox.pConnectActors == 0);
	connect_actors();

	// Reset the connect actors signal to inform the host that actors are connected
	*Mailbox.pConnectActors = 0;

	// Wait for the trigger from the host
	while(Mailbox.pGo[me.corenum] == 0);

timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);
	while(i < IN_BUFFER_SIZE)
	{

		// Read x0, x1, x2, x3
		x0 = Mailbox.pInBuffer[i]; i++;
		x1 = Mailbox.pInBuffer[i]; i++;
		x2 = Mailbox.pInBuffer[i]; i++;
		x3 = Mailbox.pInBuffer[i]; i++;

		// Write x0 and read an input and write it directly to the output

		port_write(&Y, x0);
		port_write(&Y, Mailbox.pInBuffer[i]); i++;

#if 0
Mailbox.pOutputBuffer[j] = x0; j++;
Mailbox.pOutputBuffer[j] = Mailbox.pInBuffer[i - 1]; j++;
#endif

		// Read x5
		x5 = Mailbox.pInBuffer[i]; i++;

		// Write x2 and read an input and write it directly to the output
		port_write(&Y, x2);
		port_write(&Y, Mailbox.pInBuffer[i]); i++;

#if 0
Mailbox.pOutputBuffer[j] = x2; j++;
Mailbox.pOutputBuffer[j] = Mailbox.pInBuffer[i - 1]; j++;
#endif
		// write x1 and read an input and write it directly to the output
		port_write(&Y, x1);
		port_write(&Y, Mailbox.pInBuffer[i]); i++;
#if 0
Mailbox.pOutputBuffer[j] = x1; j++;
Mailbox.pOutputBuffer[j] = Mailbox.pInBuffer[i - 1]; j++;
#endif

		// Write x5 and x3
		port_write(&Y, x5);
		port_write(&Y, x3);

#if 0
Mailbox.pOutputBuffer[j] = x5; j++;
Mailbox.pOutputBuffer[j] = x3; j++;
#endif
	}

// Get timer value, find the elapsed time and stop 
timerValue = e_ctimer_get(E_CTIMER_1);
Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_1);

}
Exemplo n.º 14
0
int main(void) {
	//initialize
	unsigned time_s, time_e, time;
	unsigned expect;
	int *p0, *p1;
	unsigned ctimer;
	int i, j;
	int a;	
	int fault;
	int row, col;

	sprintf(outbuf,"\t");

	row = e_group_config.core_row;
	col = e_group_config.core_col;
	ctimer = (unsigned)e_get_global_address(row,col,(void *)0xf0438);
	fault = 0x0;
	//ctimer = 0x849f0438;
	p0 = (int *)0x5200;
	*p0 = 0x0;
	//*p0 = 0x10;
	//p1 = (int *)0x80a05200;

	for(i=0;i<4;i++)
	{	
		for(j=0;j<4;j++)
		{	

			p1 = e_get_global_address(i,j,(void *)0x5100);
			//p1 = e_get_global_address(0,0,(void *)0x5200);
			*p1 = 0x210;
			a = 0x0;
	
	
			e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
			e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
			//record the ctimer
			__asm__ __volatile__("ldr %0, [%1]":"=r"(time_s):"r"(ctimer):);
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
				
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	
			__asm__ __volatile__("ldr %0, [%1]":"=r"(a):"r"(p1):);	

			__asm__ __volatile__("ldr %0, [%1]":"=r"(time_e):"r"(ctimer):);


			

			//time_e = e_ctimer_get(E_CTIMER_0);
			e_ctimer_stop(E_CTIMER_0);
			time = time_s - time_e;
			//if(time = (i+j)*)
			expect = ((abs(row - i) + abs(col - j)) * 3 + 17)*10 + 17;
			if(time != expect)
				*p0++;
			
			
			//sprintf(outbuf,"time = %d cycles!", fault);
		}
	}

/*
	if(fault == 0)
		sprintf(outbuf+strlen(outbuf),"test20 emesh_read_latency Passed!");
	else
		sprintf(outbuf+strlen(outbuf),"test20 emesh_read_latency failed!\t\t\tWarnning, failed!");
*/
	
	return EXIT_SUCCESS;
}
Exemplo n.º 15
0
void main(){

 e_ctimer_set(E_CTIMER_0, E_CTIMER_CLK, E_CTIMER_MAX); 
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();

	// wait for the go (which means actors are connected)
	while(Mailbox.pGo[me.corenum] == 0);


timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

  // Timer functions 1
  e_ctimer_set(E_CTIMER_1, E_CTIMER_CLK, E_CTIMER_MAX);
  e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);

	int j = 0;	
	int signed_counter = 0;

	// Run until there is no input left
	while(j < IN_BUFFER_SIZE)
	{
		//action read_signed
		if(clip.count < 0){

			//clip.sflag = port_read(&SIGNED);
			clip.sflag = Mailbox.pSignedBuffer[signed_counter++];
			clip.count = 63;
		} // end of action read_signed
		else { // action limit


			int i = port_read(&I);	


			if(i > 255){
#if 0
			  port_write(&O, 255); j++;
#endif

#if 1
Mailbox.pOutputBuffer[j] = 255; j++;
#endif
// j++;
			}
			else if(clip.sflag == 0 && i < 0){
#if 0
			  port_write(&O, 0); j++;
#endif

#if 1
Mailbox.pOutputBuffer[j] = 0; j++;
#endif
//j++;
			}
			else if(i < -255){
#if 0
			  port_write(&O, -255); j++;
#endif

#if 1
Mailbox.pOutputBuffer[j] = -255; j++;
#endif
//j++;
			}
			else{
#if 0
			  port_write(&O, i); j++;
#endif

#if 1
Mailbox.pOutputBuffer[j] = i; j++;
#endif
//j++;
			}

			clip.count = clip.count - 1;	
		}
		
	}

	timerValue = e_ctimer_get(E_CTIMER_1);
	Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
#if 1
	*Mailbox.pOutputReady = 1;
#endif
	
	e_ctimer_stop(E_CTIMER_1);
}
int main(void)
{
	unsigned time_c, time_p;
	unsigned time;
	unsigned tran,k,i,j,q,h,m,n;
	unsigned *box;
	unsigned *n_row, *n_col, *p;
	unsigned *neighbour_n;
	unsigned *neighbour_s;
	unsigned *neighbour_w;
	unsigned *neighbour_e;
	unsigned *master;
	
	// Define the mailbox
	master = (unsigned *)0x2000;
	box = (unsigned *) 0x5000;
	n_row = (unsigned *)0x6000;
	n_col = (unsigned *)0x6004;
	tran = 2048;
	p =(unsigned *) 0x2000;

	// Get the neighbour global address
	e_neighbor_id(E_NEXT_CORE, E_ROW_WRAP, n_row, n_col);
	neighbour_e = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;
	
	e_neighbor_id(E_PREV_CORE, E_ROW_WRAP, n_row, n_col);
	neighbour_w = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;
	
	e_neighbor_id(E_NEXT_CORE, E_COL_WRAP, n_row, n_col);
	neighbour_s = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;
	
	e_neighbor_id(E_PREV_CORE, E_COL_WRAP, n_row, n_col);
	neighbour_n = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;	
	
	// Test the writing bandwidth	
	// Initialize master and slave
	for(i=0; i<tran; i++)
	{
		master[i] = 0xdeadbeef;
		neighbour_e[i] = 0x00000000;
		neighbour_w[i] = 0x00000000;
		neighbour_s[i] = 0x00000000;
		neighbour_n[i] = 0x00000000;
	}
			
	
	// Set the ctimer
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	
	// Start the ctimer and select the time type
	time_p = e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	
	// Write to all neighbour cores
	e_dma_copy(neighbour_e, master, 0x2000);	
	e_dma_copy(neighbour_w, master, 0x2000);
	e_dma_copy(neighbour_s, master, 0x2000);
	e_dma_copy(neighbour_n, master, 0x2000);
		
	// Get the time now
	time_c = e_ctimer_get(E_CTIMER_0);	
		
	time = time_p - time_c;
		
	// Output the result
	box[0] = time;	

	// Test the reading bandwidth
	// Initialize master and slave
	for(i=0; i<tran; i++)
	{
		master[i] = 0x00000000;
		neighbour_e[i] = 0xdeadbee1;
		neighbour_w[i] = 0xdeadbee2;
		neighbour_s[i] = 0xdeadbee3;
		neighbour_n[i] = 0xdeadbee4;
	}
			
	
	// Set the ctimer
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	
	// Start the ctimer and select the time type
	time_p = e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	
	// Read from all neighbour cores
	e_dma_copy(master, neighbour_e, 0x2000);	
	e_dma_copy(master, neighbour_w, 0x2000);
	e_dma_copy(master, neighbour_s, 0x2000);
	e_dma_copy(master, neighbour_n, 0x2000);
		
	// Get the time now
	time_c = e_ctimer_get(E_CTIMER_0);	
		
	time = time_p - time_c;
		
	// Output the result
	box[1] = time;	
	return 0;
}
Exemplo n.º 17
0
int main(void)
{
    unsigned mesh_reg;
    unsigned mesh_reg_modify;
    unsigned time_c, time_p;
    unsigned time;
    unsigned time_c1, time_p1;
    unsigned time1;
    unsigned i,j,q,m,n,k;
    unsigned *commander;
    unsigned *counter;
    unsigned *mailbox,*mode;
    unsigned *n_row, *n_col;
    unsigned *neighbour0, *neighbour1, *neighbour2, *neighbour3, *p;

    commander = (unsigned *)0x5100;
    counter = (unsigned *)0x5300;
    mailbox = (unsigned *)0x6000;
    mode = (unsigned *)0x5400;
    n_row = (unsigned *)0x5008;
    n_col = (unsigned *)0x500c;
    p = (unsigned *)0x5100;

    // Broadcast to neighbours
    e_neighbor_id(E_PREV_CORE, E_ROW_WRAP, n_row, n_col);
    neighbour0 = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;

    e_neighbor_id(E_NEXT_CORE, E_ROW_WRAP, n_row, n_col);
    neighbour1 = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;

    e_neighbor_id(E_PREV_CORE, E_COL_WRAP, n_row, n_col);
    neighbour2 = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;

    e_neighbor_id(E_NEXT_CORE, E_COL_WRAP, n_row, n_col);
    neighbour3 = (unsigned *) e_get_global_address(*n_row, *n_col, p) ;

    // Get core information
    k = e_group_config.core_row * e_group_config.group_cols + e_group_config.core_col;

    while(1)
    {
        // Clear the counter of finishing transfering
        for(m=0; m<(e_group_config.group_rows*e_group_config.group_cols); m++)
        {
            counter[m] = 0;
        }

        // Initialize the commander and counter
        counter[k] = 1;

        //Clear the mode box
        mode[0] = 0xdeadbeef;

        // Clear the start commander
        commander[0] = 0x00000000;

        // Wait for the mesh event
        while(mode[0] == 0xdeadbeef)
        {};

        q = mode[0];

        mesh_reg = e_reg_read(E_REG_MESH_CONFIG);
        mesh_reg_modify = mesh_reg & 0xffffff0f;
        mesh_reg_modify = mesh_reg_modify |mesh_type[1][q];
        e_reg_write(E_REG_MESH_CONFIG, mesh_reg_modify);

        // Set the ctimer
        e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;

        // Waiting for the signal to start transfering
        while(commander[0] != 0xdeadbeef)
        {};

        // Start the ctimer and select the time type
        time_p = e_ctimer_start(E_CTIMER_0, E_CTIMER_MESH_0);

        // Broadcast to all the other neighbours
        neighbour0[0] = 0xdeadbeef;
        neighbour1[0] = 0xdeadbeef;
        neighbour2[0] = 0xdeadbeef;
        neighbour3[0] = 0xdeadbeef;


        while((counter[0]&counter[1]&counter[2]&counter[3]&counter[4]&counter[5]&counter[6]
                &counter[7]&counter[8]&counter[9]&counter[10]&counter[11]&counter[12]&counter[13]
                &counter[14]&counter[15]) == 0) {};

        time_c = e_ctimer_get(E_CTIMER_0);

        time = time_p - time_c;
        mailbox[(*mode)] = time;

        // Load the original value to E_REG_MESH_CONFIG system register
        e_reg_write(E_REG_MESH_CONFIG, mesh_reg);

        if(mode[0] == 12)
        {
            break;
        }
    }
    return 0;
}
Exemplo n.º 18
0
void main(){

// Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_CLK, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();
	
	int j = 0;
	int consumed_elements = 0;

	// wait for the go (which means actors are connected)
	while(Mailbox.pGo[me.corenum] == 0);

timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_CLK, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);

	while(j < IN_BUFFER_SIZE)
	{
		
		// action #1
		if(transpose.rcount < 64){

			int row = (transpose.rcount >> 3);
			int quad = (transpose.rcount >> 2) & 1;
			int i;
	
			if(quad == 0){

				for(i = 0; i < 4; i++){

					if(input_available(&X)){

						switch(consumed_elements){
						case 0:
							transpose.mem[transpose.select][row][0] = port_read(&X);
							break;
						case 1:
							transpose.mem[transpose.select][row][7] = port_read(&X);
							break;
						case 2:
							transpose.mem[transpose.select][row][3] = port_read(&X);
							break;
						case 3:
							transpose.mem[transpose.select][row][4] = port_read(&X);
							transpose.rcount = transpose.rcount + 4;
							break;
						default:
							break;
						}
					
						// if we consumed 4 elements, get out of for loop
						if(consumed_elements == 3)
						  i = 4;

						consumed_elements = (consumed_elements + 1) % 4;
					}
				}
			}
			else{
				 for(i = 0; i < 4; i++){
                                        if(input_available(&X)){
                                                switch(consumed_elements){
                                                case 0:
                                                        transpose.mem[transpose.select][row][1] = port_read(&X);
                                                        break;
                                                case 1:
                                                        transpose.mem[transpose.select][row][6] = port_read(&X);
                                                        break;
                                                case 2:
                                                        transpose.mem[transpose.select][row][2] = port_read(&X);
                                                        break;
                                                case 3:
                                                        transpose.mem[transpose.select][row][5] = port_read(&X);
                                                        transpose.rcount = transpose.rcount + 4;
                                                        break;
                                                default:
							break;
                                                }

						// if we consumed 4 elements, get out of for loop
						if(consumed_elements == 3)
						  i = 4;

                                                consumed_elements = (consumed_elements + 1) % 4;
                                        }
                                }
			}
	
		}
		// end of action #1

		// action #2
		if(transpose.ccount > 0){


			int a, b;
			int col = (64 - transpose.ccount) >> 3;
			int pair = ((64 - transpose.ccount) >> 1) & 3;
			int k = transpose.select ^ 1;

			if(pair == 0){
				a = 0;
				b = 4;
			}
			else if(pair == 1){
				a = 2;
				b = 6;
			}
			else if(pair == 2){
				a = 1;
				b = 7;
			}
			else{
				a = 5;
				b = 3;
			}

#if 1
			port_write(&Y, transpose.mem[k][a][col]); j++;
			port_write(&Y, transpose.mem[k][b][col]); j++;
#endif



#if 0
			// DEBUG
			Mailbox.pOutputBuffer[j] = transpose.mem[k][a][col]; j++;
			Mailbox.pOutputBuffer[j] = transpose.mem[k][b][col]; j++;
#endif

			transpose.ccount = transpose.ccount - 2;


		}
Exemplo n.º 19
0
int main(void)
{
    e_coreid_t coreid;
    unsigned int i;
    unsigned int num;
    unsigned int time_p;
    unsigned int time_c;
    unsigned int time_compare;
    unsigned int list[14] = {4, 3, 3, 144953, 68892, 24971, 52908, 96970, 19531, 17676, 10459, 10458, 357432, 36235};
    unsigned int index = 0;
    unsigned *mailbox;
    float volatile af;
    float volatile bf;
    float volatile cf;
    float volatile df;
    float volatile ref;
    unsigned int temp;

    float volatile in_sin;
    float volatile in_cos;
    float volatile in_sqt;
    float volatile in_ceil;
    float volatile in_log;
    float re_f0, re_f1, re_f2, re_f3, re_f4, re_f5;

    af = 3.5f;
    bf = 2.8f;
    cf = 8.0f;
    df = 3.0f;
    in_sin = (float) pi;
    in_sin = in_sin / 6 ;
    in_cos = (float) pi;
    in_cos = in_cos / 3 ;
    in_sqt = 0.25f;
    in_ceil = 2.5f;
    in_log = 100.0f;
    mailbox = (unsigned *)0x6000;
    mailbox[0] = 0;

    // Who am I? Query the CoreID from hardware.
    coreid = e_get_coreid();
    sprintf(outbuf, "");

    // Get time waste on functions
    e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
    time_p = e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);
    time_compare = time_p - time_c ;

    // Addition
    // E_CTIMER0
    e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    ref = bf + af ;


    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if (!((ref > 6.299f)&&(ref < 6.301f)) )
    {
        sprintf(outbuf, "\n Addition is wrong!\n");
    } else
    {
        if ( (temp >=(list[0] - 2)) && (temp <=(list[0] + 2)) )
        {
            index++;//sprintf(outbuf , "\nPASS for addition!\n");
        } else
        {
            sprintf(outbuf , "\nThe clock cycle for addition is %d instead of %d.\n", temp, list[0]);
        }
    }

    // Subtraction
    // E_CTIMER0
    e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    ref =  af - bf;


    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if ( !((ref > 0.699f)&&(ref < 0.701f)))
    {
        sprintf(outbuf+strlen(outbuf), "\n Subtraction is wrong!\n");
    } else
    {
        if ((temp >= (list[1] - 2)) && (temp <= (list[1] + 2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf) , "\nPASS for substraction!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for subtraction is %d instead of %d.\n", temp, list[1]);
        }
    }

    // Mul
    //E_CTIMER0
    e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    ref = af * bf;

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if (!((ref > 9.799f)&&(ref < 9.801f)))
    {
        sprintf(outbuf+strlen(outbuf), "\n Multiplication is wrong!\n");
    } else
    {
        if ((temp >=(unsigned) (list[2] -2)) && (temp <=(unsigned) (list[2]+2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for multiplication!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for multiplication is %d instead of %d.\n", temp, list[2]);
        }
    }

    // Div
    //E_CTIMER0
    e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    ref = ( af / bf);

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if (!((ref > 1.2499f)&&(ref < 1.2501f)))
    {
        sprintf(outbuf+strlen(outbuf), "\n Division is wrong!\n");
    } else
    {
        if ( (temp > (unsigned) (list[3] * 0.8)) && (temp < (unsigned) (list[3] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for division!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for division is %d instead of %d.\n", temp, list[3]);
        }
    }

    // Mod
    // E_CTIMER0
    e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    ref = fmodf(cf,df);


    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if (!((ref > 1.99f)&&(ref < 2.01f)))
    {
        sprintf(outbuf+strlen(outbuf), "\n Mod is wrong!\n");
    } else
    {
        if ( (temp > (unsigned)(list[4] * 0.8)) && (temp < (unsigned)(list[4] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for mod!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for mod is %d instead of %d.\n", temp, list[4]);
        }
    }

    // Sin
    // E_CTIMER0
    e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    re_f0 = sinf(in_sin);

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if ( !((re_f0 > 0.499) && (re_f0 < 0.501)) )
    {
        sprintf(outbuf+strlen(outbuf), "\n Sin is wrong!\n");
    } else
    {
        if ( (temp > (unsigned)(list[5] * 0.8)) && (temp < (unsigned)(list[5] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for sin!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for sin is %d instead of %d.\n", temp, list[5]);
        }
    }

    // Cos
    // E_CTIMER0
    e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    re_f1 = cosf(in_cos);

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if (  !((re_f1 > 0.499) && (re_f1 < 0.501)))
    {
        sprintf(outbuf+strlen(outbuf), "\n Cos is wrong!\n");
    } else
    {
        if ( (temp > (unsigned)(list[6] * 0.8)) && (temp < (unsigned)(list[6] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for cos!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for cos is %d instead of %d.\n", temp, list[6]);
        }
    }


    // Sqrt
    e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    re_f2 = sqrtf(in_sqt);

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if ( !((re_f2 > 0.499) && (re_f2 < 0.501)) )
    {
        sprintf(outbuf+strlen(outbuf), "\n Sqrt is wrong!\n");
    } else
    {
        if ( (temp > (list[7] * 0.8)) && (temp < (list[7] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for square root!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for sqrt is %d instead of %d.\n", temp, list[7]);
        }
    }

    // Ceil
    e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    re_f3 = ceilf(in_ceil);

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if ( !((re_f3 > 2.99) && (re_f3 < 3.01)) )
    {
        sprintf(outbuf+strlen(outbuf), "\n Ceil is wrong!\n");
    } else
    {
        if ( (temp > (list[8] * 0.8)) && (temp < (list[8] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for ceil!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for ceil is %d instead of %d.\n", temp, list[8]);
        }
    }

    // Floor
    e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    re_f5 = floorf(in_ceil);

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if ( !((re_f5 > 1.99f) && (re_f5 < 2.01f))  )
    {
        sprintf(outbuf+strlen(outbuf), "\n Floor is wrong!\n");
    } else
    {
        if ( (temp > (list[9] * 0.8)) && (temp < (list[9] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for floor!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for floor is %d instead of %d.\n", temp, list[9]);
        }
    }


    // Log10
    e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_1);

    re_f4 = log10f(df);

    time_c = e_ctimer_get(E_CTIMER_1);
    e_ctimer_stop(E_CTIMER_1);

    temp = time_p - time_c - time_compare;

    if ( !((re_f4 > 0.477f) && (re_f4 < 0.478f)) )
    {
        sprintf(outbuf+strlen(outbuf), "\n Log10 is wrong!\n");
    } else
    {
        if ( (temp > (list[11] * 0.8)) && (temp < (list[11] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for log10!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for log10 is %d instead of %d.\n", temp, list[10]);
        }
    }


    // Ln
    e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_0);

    re_f4 = logf(in_log);

    time_c = e_ctimer_get(E_CTIMER_0);
    e_ctimer_stop(E_CTIMER_0);

    temp = time_p - time_c - time_compare;

    if (!((re_f4 > 4.6f) && (re_f4 < 4.61f)) )
    {
        sprintf(outbuf+strlen(outbuf), "\n Ln is wrong!\n");
    } else
    {
        if ( (temp > (list[11] * 0.8)) && (temp < (list[11] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for ln!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for ln is %d instead of %d.\n", temp, list[11]);
        }
    }

    // Power
    e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_1);

    re_f4 = powf(cf,df);

    time_c = e_ctimer_get(E_CTIMER_1);
    e_ctimer_stop(E_CTIMER_1);

    temp = time_p - time_c - time_compare;

    if (!( (re_f4 > 511.99f) && (re_f4 < 512.01f) ))
    {
        sprintf(outbuf+strlen(outbuf), "\n Power is wrong!\n");
    } else
    {
        if ( (temp > (list[12] * 0.8)) && (temp < (list[12] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for power!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for power is %d instead of %d.\n", temp, list[12]);
        }
    }

    // Ldexp
    e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX) ;
    e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);
    time_p = e_ctimer_get(E_CTIMER_1);

    re_f4 = ldexpf(cf,df);

    time_c = e_ctimer_get(E_CTIMER_1);
    e_ctimer_stop(E_CTIMER_1);

    temp = time_p - time_c - time_compare;

    if ( !((re_f4 > 63.99f) && (re_f4 < 64.01f)) )
    {
        sprintf(outbuf+strlen(outbuf), "\n Ldexp is wrong!\n");
    } else
    {
        if ( (temp > (list[13] * 0.8)) && (temp < (list[13] * 1.2)) )
        {
            index++;//sprintf(outbuf +strlen(outbuf), "\nPASS for ldexp!\n");
        } else
        {
            sprintf(outbuf +strlen(outbuf), "\nThe clock cycle for ldexp is %d instead of %d.\n", temp, list[13]);
        }
    }

    mailbox[0] = index;

    return EXIT_SUCCESS;

}
Exemplo n.º 20
0
static uint64_t platform_clock(void)
{
    static mach_timebase_info_data_t tb_info = {
        .numer = 0,
        .denom = 0,
    };
    uint64_t abs_time, nanosec;

    abs_time = mach_absolute_time();
    if (tb_info.denom == 0) {
        (void) mach_timebase_info(&tb_info);
    }
    nanosec = abs_time;
    nanosec /= tb_info.denom;
    nanosec *= tb_info.numer;

    return nanosec;
}
#elif defined(HAVE_E_LIB_H)
static uint64_t platform_clock(void)
{
    // Assuming 600MHz clock 10^9 / (600 * 10^6)
    const float factor = 1.6666666666666666666f;

    static uint64_t clock = 0;
    uint64_t diff, nanosec;

    static bool initialized = false;

    if (!initialized) {
        e_ctimer_stop(E_CTIMER_0);
        e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
        e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
        initialized = true;
        return 0;
    }

    /* Clock will drift here */
    diff = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);

    e_ctimer_stop(E_CTIMER_0);
    e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
    e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

    clock += diff;

    nanosec = (uint64_t) ((float) clock * factor);

    return nanosec;
}
#else
#error "No timing function"
#endif

static void platform_print_duration(uint64_t start,
                                    uint64_t end)
{
    if (end < start)
        bench_printf("%" PRIu64, 0xffffffffffffffffUL);
    else
        bench_printf("%" PRIu64, end - start);
}

/* end of platform specific section */

struct item_data
{
    uint64_t start;
    uint64_t end;
};
Exemplo n.º 21
0
/**
 * Starts the clock.
 */
static int8_t start_clock(void) {
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	return 0;
}
Exemplo n.º 22
0
void main()
{

// Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();
	int i = 0;
	int a, b;
	int w0, w1;

	// Wait until we get the go message from the host
	while(Mailbox.pGo[me.corenum] == 0); 

timerValue = e_ctimer_get(E_CTIMER_0);
 Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);

	while(i < (IN_BUFFER_SIZE * 2))
	{
		w0 = ww0;
		w1 = ww1;

		index0 = (index0 + 1) & 3;

		ww0 = W0[index0];
		ww1 = W1[index0];

		a = port_read(&X);
		b = port_read(&X);

#if 1
		port_write(&Y, a * w0); i++;
		port_write(&Y, a * w1); i++;
		port_write(&Y, b * w0); i++;
		port_write(&Y, b * w1); i++;
#endif

#if 0
		Mailbox.pOutputBuffer[i] = a * w0; i++;
		Mailbox.pOutputBuffer[i] = a * w1; i++;
		Mailbox.pOutputBuffer[i] = b * w0; i++;
		Mailbox.pOutputBuffer[i] = b * w1; i++;
#endif

	}

#if 0
*Mailbox.pOutputReady = 8;
#endif

// Get timer value, find the elapsed time and stop 
timerValue = e_ctimer_get(E_CTIMER_1);
Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_1);
}
Exemplo n.º 23
0
/**
 * This function starts the clock counter, tracing can be used after this call
 */
int trace_start()
{
	e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);
	return 0;
}
Exemplo n.º 24
0
int main()
{
  msg_t *m = (msg_t *) 0x4000;
  uint64_t d64;
  uint32_t d32;
  uint16_t d16;
  uint8_t  d8;
  unsigned int dt;
  void *da, *dua, *dc;
  for (unsigned int row = 0; row < E_ROWS; row++) {
    for (unsigned int col = 0; col < E_COLS; col++) {
      if (row == 0 && col == 0) continue;
      unsigned int tcore = row * E_COLS + col;

      da = e_get_global_address(row, col, (void *) MEM_ALINEADA);
      dua = e_get_global_address(row, col, (void *) MEM_NO_ALINEADA);
      dc = e_get_global_address(row, col, (void *) MEM_A_CABALLO);

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d64, da, sizeof(d64));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].t64 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d32, da, sizeof(d32));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].t32 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d16, da, sizeof(d16));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].t16 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d8, da, sizeof(d8));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].t8 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d64, dua, sizeof(d64));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].ua64 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d32, dua, sizeof(d32));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].ua32 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d16, dua, sizeof(d16));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].ua16 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d8, dua, sizeof(d8));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].ua8 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d64, dua, sizeof(d64));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].c64 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d32, dc, sizeof(d32));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].c32 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d16, dc, sizeof(d16));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].c16 = (dt - DUMMY_WAIT) / (double) VECES;

      e_dma_wait(E_DMA_1);
      e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX);
      e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
      for (int i = 0; i < VECES; i++)
        e_dma_copy(&d8, dc, sizeof(d8));
      e_dma_wait(E_DMA_1);
      e_wait(E_CTIMER_1, DUMMY_WAIT);
      e_ctimer_stop(E_CTIMER_0);
      dt = E_CTIMER_MAX - e_ctimer_get(E_CTIMER_0);
      m->ticks[tcore].c8 = (dt - DUMMY_WAIT) / (double) VECES;
    }
  }
  m->finalizado = E_TRUE;

  return 0;
}
Exemplo n.º 25
0
int main(void)
{
	e_coreid_t coreid;
	unsigned int i;
	unsigned int num;
	unsigned int time_p;
	unsigned int time_c;
	unsigned int time_compare;
	float volatile af;
	float volatile bf;
	float volatile cf;
	float volatile df;
	float ref;	
	unsigned int temp;

	float volatile in_sin;
	float volatile in_cos;
	float volatile in_sqt;
	float volatile in_ceil;
	float volatile in_log;
	float re_f0, re_f1, re_f2, re_f3, re_f4, re_f5;

	af = 3.5f;
	bf = 2.8f;	
	cf = 8.0f;
	df = 3.0f;
	in_sin = (float) pi;
	in_sin = in_sin / 6 ;
	in_cos = (float) pi;
	in_cos = in_cos / 3 ;
	in_sqt = 0.25f;
	in_ceil = 2.5f;
	in_log = 100.0f;

	// Who am I? Query the CoreID from hardware.
	coreid = e_get_coreid();
	sprintf(outbuf, "");

	// Get time waste on functions
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);
	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
	time_compare = time_p - time_c ;

	// Addition
	// E_CTIMER0
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);
		
		ref = bf + af ;

	
	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if (!((ref > 6.299f)&&(ref < 6.301f)))
	{
		sprintf(outbuf, "\n Addition is wrong!\n");
	}else
	{
		sprintf(outbuf , "\nE_CTIMER0: The clock cycle of addition is %d.\n", temp);
	}
	
	// Subtraction
	// E_CTIMER0
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);
		
		ref =  af - bf;

	
	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( !((ref > 0.699f)&&(ref < 0.701f)))
	{
		sprintf(outbuf+strlen(outbuf), "\n Subtraction is wrong!\n");
	}else
	{
		sprintf(outbuf+strlen(outbuf) , "\n E_CTIMER0: The clock cycle of subtraction is %d.\n", temp);
	}

	// Mul
	//E_CTIMER0
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);
		
		ref = af * bf;
	
	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;


	if (!((ref > 9.799f)&&(ref < 9.801f)))
	{
		sprintf(outbuf+strlen(outbuf), "\n Multiplication is wrong!\n");
	}else
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of multiplication is %d.\n", temp);
	}

	// Div
	//E_CTIMER0
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);
	
		ref = ( af / bf);
	
	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if (!((ref > 1.2499f)&&(ref < 1.2501f)))
	{
		sprintf(outbuf+strlen(outbuf), "\n Division is wrong!\n");
	}else
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of division is %d.\n", temp);
	}

	// Mod
	// E_CTIMER0
	e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);
	
		ref = fmodf(cf,df);

	
	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if (!((ref > 1.99f)&&(ref < 2.01f)))
	{
		sprintf(outbuf+strlen(outbuf), "\n Mod is wrong!\n");
	}else
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of mod is %d.\n", temp);
	}
	
	// Sin
	// E_CTIMER0
	e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f0 = sinf(in_sin);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f0 > 0.499) && (re_f0 < 0.501) )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of sin is %d.\n", temp);		
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Sin is wrong!\n");
	}
	
	// Cos
	// E_CTIMER0
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f1 = cosf(in_cos);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;
	
	if (  (re_f1 > 0.499) && (re_f1 < 0.501))
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of cos is %d.\n", temp);
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Cos is wrong!\n");
	}
	

	// Sqrt
	e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f2 = sqrtf(in_sqt);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f2 > 0.499) && (re_f2 < 0.501) )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of sqrt is %d.\n", temp);		
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Sqrt is wrong!\n");
	}
	
	// Ceil
	e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f3 = ceilf(in_ceil);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f3 > 2.99) && (re_f3 < 3.01) )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of ceil is %d.\n", temp);		
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Ceil is wrong!\n");
	}

	// Floor
	e_ctimer_set(E_CTIMER_0,  E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f5 = floorf(in_ceil);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f5 > 1.99f) && (re_f5 < 2.01f)  )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of floor is %d.\n", temp);
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Floor is wrong!\n");
	}
	

	// Log10
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f4 = log10f(df);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f4 > 0.477f) && (re_f4 < 0.478f) )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of log10 is %d.\n", temp);
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Log10 is wrong!\n");
	}

	// Ln
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f4 = logf(in_log);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f4 > 4.6f) && (re_f4 < 4.61f) )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of ln is %d.\n", temp);
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Ln is wrong!\n");
	}
	
	// Power
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f4 = powf(cf,df);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f4 > 511.99f) && (re_f4 < 512.01f) )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of power is %d.\n", temp);
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Power is wrong!\n");
	}
	
	// Ldexp
	e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX) ;
	e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);
	time_p = e_ctimer_get(E_CTIMER_0);	
		 
	re_f4 = ldexpf(cf,df);

	time_c = e_ctimer_get(E_CTIMER_0);
	e_ctimer_stop(E_CTIMER_0);
			
	temp = time_p - time_c - time_compare;

	if ( (re_f4 > 63.99f) && (re_f4 < 64.01f) )
	{
		sprintf(outbuf+strlen(outbuf) , "\nE_CTIMER0: The clock cycle of ldexp is %d.\n", temp);
	}else
	{
		sprintf(outbuf+strlen(outbuf), "\n Ldexp is wrong!\n");
	}
	return EXIT_SUCCESS;

}
Exemplo n.º 26
0
void main(){

// Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_CLK, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();

	int i = 0;

	// wait for the go (which means actors are connected)
	while(Mailbox.pGo[me.corenum] == 0);

timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_CLK, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);

	while(i < IN_BUFFER_SIZE)
	{
		int a, b, c, d, x2, x3, x4, x5, x6h, x6l, x7h, x7l;

		// action a0
		a = port_read(&X);
		b = port_read(&X);
		c = port_read(&X);
		d = port_read(&X);

		x4 = c;
		x5 = d;
#if 1
		port_write(&Y, a); i++;
		port_write(&Y, b); i++;
		// end of action a0
#endif

#if 0
		//DEBUG
		Mailbox.pOutputBuffer[i] = a; i++;
		Mailbox.pOutputBuffer[i] = b; i++;

#endif
		// action a1
		x2 = port_read(&X);
		a = port_read(&X);
		x3 = port_read(&X);
		b = port_read(&X);
	
		int ah = a >> 8;
		int bh = b >> 8;
		int al = a & 255;
		int bl = b & 255;

		x6h = 181 * (ah + bh);
		x7h = 181 * (ah - bh);
		x6l = 181 * (al + bl) + 128;
		x7l = 181 * (al - bl) + 128;

#if 1
		port_write(&Y, x2); i++;	
		port_write(&Y, x3); i++;
		// end of action a1
#endif

#if 0
		//DEBUG
		Mailbox.pOutputBuffer[i] = x2; i++;
		Mailbox.pOutputBuffer[i] = x3; i++;

#endif

#if 1
		// action a2
		port_write(&Y, x4); i++;
		port_write(&Y, x5); i++;
		port_write(&Y, x6h + (x6l >> 8)); i++;
		port_write(&Y, x7h + (x7l >> 8)); i++;

		// end of action a2
#endif

#if 0
		//DEBUG
		Mailbox.pOutputBuffer[i] = x4; i++;
		Mailbox.pOutputBuffer[i] = x5; i++;
		Mailbox.pOutputBuffer[i] = x6h + (x6l >> 8); i++;
		Mailbox.pOutputBuffer[i] = x7h + (x7l >> 8); i++;

#endif
	}

// Get timer value, find the elapsed time and stop 
timerValue = e_ctimer_get(E_CTIMER_1);
Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_1);
}