コード例 #1
0
// Implémentation
int main()
{
    fini = (int *) ( ((e_get_coreid()) << 20) + FLAG_FINI );
    message = (int *) ( ((e_get_coreid()) << 20) + MESSAGE );
    panel = (PanelDessin *) ( ((e_get_coreid()) << 20) + ADRESSE_PANEL );
    
    // Notre structure est ici
    Calcul * monCalcul = (Calcul *) ( ((e_get_coreid()) << 20) + ADRESSE_CALCUL );
    
    // On rajoute les liens vers nos fonctions locales
    monCalcul->differentEpsilonPres = Calcul_differentEpsilonPres;
    monCalcul->egalEpsilonPres = Calcul_egalEpsilonPres;
    monCalcul->calcul = Calcul_calcul;
    monCalcul->calculM = Calcul_calculM;
    (monCalcul->lcPrec).ajouterCouleur = ListeCouleurs_ajouterCouleur;
    (monCalcul->lcPrec).equals = ListeCouleurs_equals;
    //*message = (int)(monCalcul);
    *fini = 0;
    monCalcul->calcul(monCalcul);

    //*message = monCalcul->valInit[10];// (int) (monCalcul->tabPtsY[1]);
// Fonction(s) à rentrer dans la structure
    *fini = 1;
    return EXIT_SUCCESS;
}
コード例 #2
0
int main(void) {
	const char		  ShmName[] = "hello_shm"; 
	const char        Msg[] = "Hello World from core 0x%03x!";
	char              buf[256] = { 0 };
	e_coreid_t		  coreid;
	e_memseg_t   	  emem;
	unsigned          my_row;
	unsigned          my_col;
	
	/////////////////////////////
	trace_start_wait_all();
	/////////////////////////////

	// Who am I? Query the CoreID from hardware.
	coreid = e_get_coreid();
	e_coords_from_coreid(coreid, &my_row, &my_col);

	if ( E_OK != e_shm_attach(&emem, ShmName) ) {
		return EXIT_FAILURE;
	}

	// Attach to the shm segment
	snprintf(buf, sizeof(buf), Msg, coreid);

	if ( emem.size >= strlen(buf) + 1 ) {
		// Write the message (including the null terminating
		// character) to shared memory
		e_write((void*)&emem, buf, my_row, my_col, NULL, strlen(buf) + 1);
	} else {
		// Shared memory region is too small for the message
		return EXIT_FAILURE;
	}

	return EXIT_SUCCESS;
}
コード例 #3
0
void init(){

	// Init core enumerations
	me.coreID  = e_get_coreid();
	e_coords_from_coreid(me.coreID, &me.row, &me.col);
	me.row     = me.row - E_FIRST_CORE_ROW;
	me.col     = me.col - E_FIRST_CORE_COL;
	me.corenum = me.row * E_COLS_IN_CHIP + me.col;

	// Initialize the mailbox shared buffer pointers
	Mailbox.pBase = (void *)  MAILBOX_ADDRESS;
	Mailbox.pGo = Mailbox.pBase + offsetof(mbox_t, go[0]);
	Mailbox.pReady = Mailbox.pBase + offsetof(mbox_t, ready[0]);
	Mailbox.pClocks = Mailbox.pBase + offsetof(mbox_t, clocks);

#if 0	
	// ## For debugging ##
Mailbox.pOutputBuffer = Mailbox.pBase + offsetof(mbox_t, output_buffer[0]);
Mailbox.pOutputReady = Mailbox.pBase + offsetof(mbox_t, output_ready);
#endif
	Mailbox.pTimer0 = Mailbox.pBase + offsetof(mbox_t, timer0);
	Mailbox.pTimer1 = Mailbox.pBase + offsetof(mbox_t, timer1);

	me.count = 0;
	
	// Init the ports
	init_input_port(&X);
	init_output_port(&Y);


// Set the port pointers of the actor struct
	final.X = (me.coreID << 20) | (int) &X;
コード例 #4
0
ファイル: scale.c プロジェクト: njpacoma/parallella-examples
void init()
{
	// Init core enumerations
	me.coreID  = e_get_coreid();
	e_coords_from_coreid(me.coreID, &me.row, &me.col);
	//me.row     = me.row - E_FIRST_CORE_ROW;
	//me.col     = me.col - E_FIRST_CORE_COL;
    me.corenum = me.row * e_group_config.group_cols + me.col;
	//me.corenum = me.row * E_COLS_IN_CHIP + me.col;
	//me.coreIDn = me.coreID;
	//e_neighbor_id((e_coreid_t *) &me.coreIDn, E_NEXT_CORE, E_CHIP_WRAP);

	// Initialize the mailbox shared buffer pointers
	Mailbox.pBase = (void *)  MAILBOX_ADDRESS;
	Mailbox.pGo = Mailbox.pBase + offsetof(mbox_t, go[0]);
	Mailbox.pReady = Mailbox.pBase + offsetof(mbox_t, ready[0]);
	Mailbox.pClocks = Mailbox.pBase + offsetof(mbox_t, clocks);

#if 0
	Mailbox.pOutputBuffer = Mailbox.pBase + offsetof(mbox_t, output_buffer[0]);
	Mailbox.pOutputReady = Mailbox.pBase + offsetof(mbox_t, output_ready);
#endif

	Mailbox.pTimer0 = Mailbox.pBase + offsetof(mbox_t, timer0);
	Mailbox.pTimer1 = Mailbox.pBase + offsetof(mbox_t, timer1);

	// Init the ports
	init_input_port(&X);

	// Set the port pointer, the address must be global
	scale.X = (me.coreID << 20) | (int) &X;

#ifdef FULL
	init_output_port(&Y);
	scale.Y = (me.coreID << 20) | (int) &Y;
#endif

	scale.coreID = me.coreID;

	// Set the global actor pointer(don't forget to use global address)
	actors.scale = (me.coreID << 20) | (int) &scale;
	

	me.count = 0;

	// Coefficients
	W0[0] = 2048;	W0[1] = 2676;	W0[2] = 2841;	W0[3] = 1609;
	
	W1[0] = 2048;	W1[1] = 1108;	W1[2] = 565;	W1[3] = 2408;

	ww0 = W0[0];
	ww1 = 2048;

	index0 = 0;

	// Init the host-accelerator sync signals
	Mailbox.pReady[me.corenum] = &me.mystate;
	
	return;
}
コード例 #5
0
ファイル: matmul_unit.c プロジェクト: bouhouch6/epiphany-sdk
void init()
{
	// Init core enumerations
	me.coreID  = e_get_coreid();
	e_coords_from_coreid(me.coreID, &me.row, &me.col);
	me.row     = me.row - E_FIRST_CORE_ROW;
	me.col     = me.col - E_FIRST_CORE_COL;
	me.corenum = me.row * E_COLS_IN_CHIP + me.col;
	me.coreIDh = me.coreID;
	e_neighbor_id((e_coreid_t *) &me.coreIDh, E_PREV_CORE, E_ROW_WRAP);
	me.coreIDv = me.coreID;
	e_neighbor_id((e_coreid_t *) &me.coreIDv, E_PREV_CORE, E_COL_WRAP);
	me.coreIDn = me.coreID;
	e_neighbor_id((e_coreid_t *) &me.coreIDn, E_NEXT_CORE, E_CHIP_WRAP);

	// Initialize the mailbox shared buffer pointers
	Mailbox.pBase = (void *) SHARED_DRAM;
	Mailbox.pA    = Mailbox.pBase + offsetof(shared_buf_t, A[0]);
	Mailbox.pB    = Mailbox.pBase + offsetof(shared_buf_t, B[0]);
	Mailbox.pC    = Mailbox.pBase + offsetof(shared_buf_t, C[0]);
	Mailbox.pCore = Mailbox.pBase + offsetof(shared_buf_t, core);

	// Initialize per-core parameters - core data structure
	
	// Initialize pointers to the operand matrices ping-pong arrays
	me.bank[_BankA][_PING] = (void *) &(AA[0][0][0]);
	me.bank[_BankA][_PONG] = (void *) &(AA[1][0][0]);
	me.bank[_BankB][_PING] = (void *) &(BB[0][0][0]);
	me.bank[_BankB][_PONG] = (void *) &(BB[1][0][0]);
	me.bank[_BankC][_PING] = (void *) &(CC   [0][0]);

	// Initialize the pointer addresses of the arrays in the horizontal and vertical target
	// cores, where the submatrices data will be swapped, and the inter-core sync signals.
	me.tgt_bk[_BankA][_PING] = _gptr(me.coreIDh, me.bank[_BankA][_PONG]);
	me.tgt_bk[_BankA][_PONG] = _gptr(me.coreIDh, me.bank[_BankA][_PING]);
	me.tgt_synch             = _gptr(me.coreIDh, (&(me.synch)));
	
	me.tgt_bk[_BankB][_PING] = _gptr(me.coreIDv, me.bank[_BankB][_PONG]);
	me.tgt_bk[_BankB][_PONG] = _gptr(me.coreIDv, me.bank[_BankB][_PING]);
	me.tgt_syncv             = _gptr(me.coreIDv, (&(me.syncv)));

	me.tgt_go_sync  = _gptr(me.coreIDn, (&(me.go_sync)));
	me.tgt_dma_sync = _gptr(me.coreIDn, (&(me.dma_sync)));

	me.pingpong = _PING;

	// Clear the inter-core sync signals
	me.synch = 0;
	me.syncv = 0;
	me.go_sync = 0;
	me.dma_sync = (me.corenum == 0) ? 1 : 0;
	// Init the host-accelerator sync signals
	Mailbox.pCore->go[me.corenum] = 0;
	if (me.corenum == 0)
		Mailbox.pCore->ready = 1;
	
	me.count = 0;

	return;
}
コード例 #6
0
void init()
{
	// Init core enumerations
	me.coreID  = e_get_coreid();
	e_coords_from_coreid(me.coreID, &me.row, &me.col);
	//me.row     = me.row - E_FIRST_CORE_ROW;
	//me.col     = me.col - E_FIRST_CORE_COL;
	//me.corenum = me.row * E_COLS_IN_CHIP + me.col;
    me.corenum = me.row * e_group_config.group_cols + me.col;

	// Initialize the mailbox shared buffer pointers
	Mailbox.pBase = (void *)  MAILBOX_ADDRESS;
	Mailbox.pGo = Mailbox.pBase + offsetof(mbox_t, go[0]);
	Mailbox.pReady = Mailbox.pBase + offsetof(mbox_t, ready[0]);
	Mailbox.pClocks = Mailbox.pBase + offsetof(mbox_t, clocks);

#if 0
	// ## For debugging ##
Mailbox.pOutputBuffer = Mailbox.pBase + offsetof(mbox_t, output_buffer[0]);
Mailbox.pOutputReady = Mailbox.pBase + offsetof(mbox_t, output_ready);
#endif

	Mailbox.pTimer0 = Mailbox.pBase + offsetof(mbox_t, timer0);
	Mailbox.pTimer1 = Mailbox.pBase + offsetof(mbox_t, timer1);

	// Init the ports
	init_input_port(&X);
	init_input_port(&Y);

	// Set the port pointer
	scale.X = (me.coreID << 20) | (int) &X;
	scale.Y = (me.coreID << 20) | (int) &Y;
	
	scale.coreID = me.coreID;

	// Set the global actor pointer
	actors.scaleCol = (me.coreID << 20) | (int) &scale;
	

	me.count = 0;

	// Coefficients
	W0[0] = 2048;	W0[1] = 2676;	W0[2] = 2841;	W0[3] = 1609;
	
	W1[0] = 2048;	W1[1] = 1108;	W1[2] = 565;	W1[3] = 2408;

	ww0 = W0[0];
	ww1 = 2048;

	index0 = 0;

	// Init the host-accelerator sync signals

	Mailbox.pReady[me.corenum] = 1;

	return;


}
コード例 #7
0
ファイル: e-hello.c プロジェクト: caidongyun/parallella
int main(int argc, char *argv[]) {
  e_coreid_t core_id = e_get_coreid();

  int row, col;
  e_coords_from_coreid(core_id, &row, &col);
  e_write(&e_group_config, &core_id, row, col, (int*) 0x2000, sizeof(int));

  return 0;
}
コード例 #8
0
int main(void) {
  unsigned row, col, delay, num, core_id;

  row = e_group_config.core_row;
  col = e_group_config.core_col;
  core_id = e_get_coreid();
  num = row * e_group_config.group_cols + col;
  result  = (volatile unsigned *) (0x8f000000 + 0x4*num); // writing to external memory, writing 4bytes
  *result = num;
}
コード例 #9
0
ファイル: e_trace_dma.c プロジェクト: 3upperm2n/pal
/**
 * Initialize data structures, call this first before using trace functions
 */
int trace_init()
{
	// If I am the master
	if(e_get_coreid() == TRACE_MASTER_ID) {
		// setup my DMA engine
		setupDMA2(); // REMEMBER TO CHANGE
	}

	//register timer ISR
	e_irq_global_mask(0);
	e_irq_attach(E_TIMER1_INT, timer1_trace_isr);
	e_irq_mask(E_TIMER1_INT, 0);

	// setup timer 1 for work
	e_ctimer_stop(E_CTIMER_1);
	e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX);
	logCoreid = (e_get_coreid()& 0xFFF) << 8; // make it easy to use core-id
	return 0;
}
コード例 #10
0
int main(void) {
    e_coreid_t coreid;
    unsigned row, col, i;

    coreid = e_get_coreid();
    e_coords_from_coreid(coreid, &row, &col);
    printf("Core id: %x row=%u col=%u\n", (unsigned)coreid, row, col);

    return 0;
}
コード例 #11
0
ファイル: e_main.cpp プロジェクト: paperManu/epiphany
int main(void)
{
    e_coreid_t coreid = e_get_coreid();
    unsigned int row, col;
    e_coords_from_coreid(coreid, &row, &col);

    //volatile Mailbox* mailbox = (Mailbox*)e_emem_config.base;
    mailbox->sync[row][col] = 1; //(int)(row * 10 + col);

    return 0;
}
コード例 #12
0
ファイル: clip.c プロジェクト: 9578577/parallella-examples
void init(){

	// Init core enumerations
	me.coreID  = e_get_coreid();
	e_coords_from_coreid(me.coreID, &me.row, &me.col);
	me.row     = me.row - E_FIRST_CORE_ROW;
	me.col     = me.col - E_FIRST_CORE_COL;
	me.corenum = me.row * E_COLS_IN_CHIP + me.col;
	// corenum 12 is empty because of our structure
// hence this core gets num 13 but it should be 12
	me.corenum--;

	// Initialize the mailbox shared buffer pointers
	Mailbox.pBase = (void *) MAILBOX_ADDRESS;
	Mailbox.pGo = Mailbox.pBase + offsetof(mbox_t, go[0]);
	Mailbox.pReady = Mailbox.pBase + offsetof(mbox_t, ready[0]);
	Mailbox.pClocks = Mailbox.pBase + offsetof(mbox_t, clocks);

	Mailbox.pSignedBuffer = Mailbox.pBase + offsetof(mbox_t, signed_buffer[0]);
	Mailbox.pSignedBufferSize = Mailbox.pBase + offsetof(mbox_t, signed_buffer_size);


	Mailbox.pOutputReady = Mailbox.pBase + offsetof(mbox_t, output_ready);	
	Mailbox.pOutputBuffer = Mailbox.pBase + offsetof(mbox_t, output_buffer[0]);

	Mailbox.pTimer0 = Mailbox.pBase + offsetof(mbox_t, timer0);
	Mailbox.pTimer1 = Mailbox.pBase + offsetof(mbox_t, timer1);

	me.count = 0;

	// Init the global variables
	clip.count = -1;
	clip.coreID = me.coreID;

	// Init the ports
	//init_input_port(&SIGNED);
	init_input_port(&I);
	//init_output_port(&O);

	// Set the port pointers of the actor struct
	//clip.SIGNED = &SIGNED;
	clip.I = (me.coreID << 20) | (int) &I;
	//clip.O = &O;

	// Set the global actor pointer
	actors.clip = (me.coreID << 20) | (int) &clip;

	// Init the host-accelerator sync signals
	// Let the host know that we are ready (for sync)	
	Mailbox.pReady[me.corenum] = 3;

}
コード例 #13
0
//void check(unsigned int *argu, unsigned int time, unsigned int mask0, unsigned int mask1){
void check(e_core_reg_id_t argu, unsigned int time, unsigned int mask0, unsigned int mask1){
	
	unsigned output = 0x0;
	unsigned set0 = 0;
	unsigned set1 = 0;
	unsigned int m0, m1, current, t;
	//unsigned int  _RegAdd;
	e_core_reg_id_t _RegAdd;
	t = time;
	_RegAdd = argu;
	m0 = mask0;
	m1 = mask1;

	//get core id
	e_coreid_t coreid;
	coreid = e_get_coreid();

	//save the current data
	current = e_reg_read(_RegAdd);

	//clear to 0
	e_reg_write(_RegAdd, current & m0);
	output = e_reg_read(_RegAdd);
	if(output != (current & m0)){
		set0 = 1;
		sprintf(outbuf + strlen(outbuf), "Core 0x%03x set Reg %-20s TO 0 FAILED! The current value is 0x%08x! Expecting 0x%08x!\n", 			coreid, reg[t], output, current & m0);
	}

	//set to 1
	e_reg_write(_RegAdd, current | m1);
	output = e_reg_read(_RegAdd);
	if(output != (current | m1)){
		set1 = 1;
		sprintf(outbuf + strlen(outbuf), "Core 0x%03x set Reg %-20s TO 1 FAILED! The current value is 0x%08x! Expecting 0x%08x!\n", 			coreid, reg[t], output, current | m1);
	}

	//clear to 0
	e_reg_write(_RegAdd, current & m0);
	output = e_reg_read(_RegAdd);
	if(output != (current & m0)){
		set0 = 1;
		sprintf(outbuf + strlen(outbuf), "Core 0x%03x set Reg %-20s TO 0 FAILED! The current value is 0x%08x! Expecting 0x%08x!\n", 			coreid, reg[t], output, current & m0);
	}

	if(set1 == 0 & set0 == 0)
		sprintf(outbuf + strlen(outbuf), "Core 0x%03x set Reg %-20s HAS  PASSED!\n", coreid, reg[t]);

	//store the old data
	e_reg_write(_RegAdd, current);

}
コード例 #14
0
int main(void) {
	e_coreid_t coreid;
	//point to area of memory with to store the string 
	

	// Query the CoreID from hardware.
	coreid = e_get_coreid();

	outbuf = (unsigned int *) ptr_address;
        msg = (unsigned int *) int_address;
	*outbuf = coreid; 
	*msg = 1;

	return EXIT_SUCCESS;
}
コード例 #15
0
int main(void) {
  unsigned row, col, delay, num, core_id;

  row = e_group_config.core_row;
  col = e_group_config.core_col;
  core_id = e_get_coreid();
  num = row * e_group_config.group_cols + col;
  result  = (volatile int *) (0x8f000000 + 0x4*num); // writing to external memory, writing 4bytes

  //instructions[0] = UNLOCKED;
  *result = 0;

  while(1) {
    while(instructions[0] != UNLOCKED);
    *result = num;
  }
}
コード例 #16
0
void check_ILAT(unsigned int num){
	unsigned output, current, t;
	unsigned set0 = 0;
	unsigned set1 = 0;
	e_core_reg_id_t _RegAdd;
	t = num;
	_RegAdd = E_REG_ILAT;

	//get core id
	e_coreid_t coreid;
	coreid = e_get_coreid();

	//save the current data
	current = e_reg_read(_RegAdd);

	//clear to 0
	e_reg_write(E_REG_ILATCL, 0xffffffff);
	output = e_reg_read(_RegAdd);
	if(output != 0x0){
		set0 = 1;
		sprintf(outbuf + strlen(outbuf), "Core 0x%03x set Reg %-20s TO 0 FAILED! The current value is 0x%08x! Expecting 0x%08x!\n", 			coreid, reg[t], output, 0x0);
	}

	//set to 1
	e_reg_write(E_REG_ILATST, 0xffffffff);
	output = e_reg_read(_RegAdd);
	if(output != 0xffffffff){
		set1 = 1;
		sprintf(outbuf + strlen(outbuf), "Core 0x%03x set Reg %-20s TO 1 FAILED! The current value is 0x%08x! Expecting 0x%08x!\n", 			coreid, reg[t], output, 0xffffffff);
	}

	//clear to 0
	e_reg_write(E_REG_ILATCL, 0xffffffff);
	output = e_reg_read(_RegAdd);
	if(output != 0x0){
		set0 = 1;
		sprintf(outbuf + strlen(outbuf), "Core 0x%03x set Reg %-20s TO 0 FAILED! The current value is 0x%08x! Expecting 0x%08x!\n", 			coreid, reg[t], output, 0x0);
	}

	if(set1 == 0 & set0 == 0)
		sprintf(outbuf + strlen(outbuf), "Core 0x%03x set Reg %-20s HAS  PASSED!\n", coreid, reg[t]);

	//store the old data
	e_reg_write(_RegAdd, current);
}
コード例 #17
0
void init(){

	// Init core enumerations
	me.coreID  = e_get_coreid();
	e_coords_from_coreid(me.coreID, &me.row, &me.col);
	me.row     = me.row - E_FIRST_CORE_ROW;
	me.col     = me.col - E_FIRST_CORE_COL;
	me.corenum = me.row * E_COLS_IN_CHIP + me.col;

	// Initialize the mailbox shared buffer pointers
	Mailbox.pBase = (void *)  MAILBOX_ADDRESS;
	Mailbox.pGo = Mailbox.pBase + offsetof(mbox_t, go[0]);
	Mailbox.pReady = Mailbox.pBase + offsetof(mbox_t, ready[0]);
	Mailbox.pClocks = Mailbox.pBase + offsetof(mbox_t, clocks);

#if 0
	// ## For debugging ##
	Mailbox.pOutputBuffer = Mailbox.pBase + offsetof(mbox_t, output_buffer[0]);
	Mailbox.pOutputReady = Mailbox.pBase + offsetof(mbox_t, output_ready);
#endif

	Mailbox.pTimer0 = Mailbox.pBase + offsetof(mbox_t, timer0);
	Mailbox.pTimer1 = Mailbox.pBase + offsetof(mbox_t, timer1);

	me.count = 0;
	
	// Init the ports
	init_input_port(&X);
	init_output_port(&Y);

	// Set the port pointers of the actor struct
	shuffle.X = (me.coreID << 20) | (int) &X;
	shuffle.Y = (me.coreID << 20) | (int) &Y;

	shuffle.coreID = me.coreID;

	// Set the global actor pointer
	actors.shuffleRow = (me.coreID << 20) | (int) &shuffle;

	// Init the host-accelerator sync signals
	// Let the host know that we are ready (for sync)
	Mailbox.pGo[me.corenum] = 0;	
	Mailbox.pReady[me.corenum] = me.corenum;
}
コード例 #18
0
void init()
{
    unsigned next_row, next_col;
	// Init core enumerations
	me.coreID  = e_get_coreid();
	e_coords_from_coreid(me.coreID, &me.row, &me.col);
    me.corenum = me.row * e_group_config.group_cols + me.col;
	//e_neighbor_id(E_NEXT_CORE, E_GROUP_WRAP, &next_row, &next_col);
	//me.coreIDn = next_row * e_group_config.group_cols + next_col;
	////e_neighbor_id(E_NEXT_CORE, E_GROUP_WRAP, (e_coreid_t *) &me.coreIDn);

	// Initialize the mailbox shared buffer pointers
	Mailbox.pBase = (void *) MAILBOX_ADDRESS;//(void*) SHARED_DRAM;
	Mailbox.pGo = Mailbox.pBase + offsetof(mbox_t, go[0]);
	Mailbox.pReady = Mailbox.pBase + offsetof(mbox_t, ready[0]);
	Mailbox.pClocks = Mailbox.pBase + offsetof(mbox_t, clocks);
	Mailbox.pInBuffer = Mailbox.pBase + offsetof(mbox_t, in_buffer[0]);
	Mailbox.pInBufferSize = Mailbox.pBase + offsetof(mbox_t, in_buffer_size);
	Mailbox.pConnectActors = Mailbox.pBase + offsetof(mbox_t, connectActors);
#if 0
	// Debug 
Mailbox.pOutputReady = Mailbox.pBase + offsetof(mbox_t, output_ready);
Mailbox.pOutputBuffer = Mailbox.pBase + offsetof(mbox_t, output_buffer);
#endif

	Mailbox.pTimer0 = Mailbox.pBase + offsetof(mbox_t, timer0);
	Mailbox.pTimer1 = Mailbox.pBase + offsetof(mbox_t, timer1);

	// initialize the port
	init_output_port(&Y);

	// Set the port pointer
	rowSort.Y = (me.coreID << 20) | (int) &Y;

	rowSort.coreID = me.coreID;

	// Set the global actor pointer
	actors.rowSort = (me.coreID << 20) | (int) &rowSort;

        // Init the host-accelerator sync signals
        Mailbox.pReady[me.corenum] = &me.mystate;

	return;
}
コード例 #19
0
ファイル: emain.c プロジェクト: nkcr/parallella-computing
int main(void) {
    unsigned row, col, delay, num, core_id;

    row = e_group_config.core_row;
    col = e_group_config.core_col;
    core_id = e_get_coreid();
    num = row * e_group_config.group_cols + col;
    result  = (volatile float *) (0x8f000000 + 0x4*num); // writing to external memory, writing 4bytes
    sharedx = (volatile float *) (0x8f000000 + 16*sizeof(float));
    sharedy = (volatile float *) (0x8f000000 + 16*sizeof(float) + 200*sizeof(float));
    sharedm = (volatile float *) (0x8f000000 + 16*sizeof(float) + 200*sizeof(float) + 200*sizeof(float));
    shared_status = (volatile int *) (0x8f000000 + 16*sizeof(float) + 200*sizeof(float) + 200*sizeof(float) + 200*201*sizeof(float) + 0x4*num);
    *shared_status = LOCKED;
    while(1) {
        // Read current status, locked?
        while(*shared_status == LOCKED);
        // Compute given instructions
        int i = instructions.i;
        int j = instructions.j;
        int ldm = instructions.ldm;
        sharedy[i] = ((((((((((((((( (sharedy[i])
                                     + sharedx[j-15]*sharedm[ldm*(j-15)+i])
                                   + sharedx[j-14]*sharedm[ldm*(j-14)+i])
                                  + sharedx[j-13]*sharedm[ldm*(j-13)+i])
                                 + sharedx[j-12]*sharedm[ldm*(j-12)+i])
                                + sharedx[j-11]*sharedm[ldm*(j-11)+i])
                               + sharedx[j-10]*sharedm[ldm*(j-10)+i])
                              + sharedx[j- 9]*sharedm[ldm*(j- 9)+i])
                             + sharedx[j- 8]*sharedm[ldm*(j- 8)+i])
                            + sharedx[j- 7]*sharedm[ldm*(j- 7)+i])
                           + sharedx[j- 6]*sharedm[ldm*(j- 6)+i])
                          + sharedx[j- 5]*sharedm[ldm*(j- 5)+i])
                         + sharedx[j- 4]*sharedm[ldm*(j- 4)+i])
                        + sharedx[j- 3]*sharedm[ldm*(j- 3)+i])
                       + sharedx[j- 2]*sharedm[ldm*(j- 2)+i])
                      + sharedx[j- 1]*sharedm[ldm*(j- 1)+i])
                     + sharedx[j]   *sharedm[ldm*j+i];

        // *result = sharedy[i];
        // Set status to locked
        *shared_status = LOCKED;
    }
}
コード例 #20
0
ファイル: e_prime.c プロジェクト: 9578577/parallella-examples
int main(void)
{
	e_coreid_t id = e_get_coreid();
	unsigned row, col;
	
	unsigned long number;

	// Get the row, column coordinates of this core
	e_coords_from_coreid(id, &row, &col);

	// Assign the starting value for each core (3,5,7,..33)
	// Each core starts with a unique odd number (2 is the only even prime number)
	number = 2 + ((2*row*4) + (2*col+1));

	// Initialize this core number starting with
	(*num) = number;

	// Initialize this core iteration count for stats
	(*count) = 0;

	// Initialize the number of found primes counter
	(*primes) = 0;

	// while(*count < *max_tests)
	while(number < *max_tests)
	{
		if(is_prime(number))
			(*primes)++;

		// Skip to the next odd number for this core to test, assuming total of 16 cores
		// Core (0,0) started with 3 on the first iteration, and next test 35
		// Core (0,1) started with 5 on the first iteration, and next test 37
		// etc
		number += (2*16);

		*num = number;

		(*count)++;
	}

	return EXIT_SUCCESS;
} 
コード例 #21
0
void *e_get_global_address(unsigned row, unsigned col, const void *ptr)
{
	unsigned   uptr;
	e_coreid_t coreid;

	/* If the address is global, return the pointer unchanged */
	if (((unsigned) ptr) & 0xfff00000)
		return ptr;
	else if ((row == E_SELF) || (col == E_SELF))
		coreid = e_get_coreid();
	else
		coreid = (row * 0x40 + col) + e_group_config.group_id;

	/* Get the 20 ls bits of the pointer and add coreid. */
//	uptr = ((unsigned) ptr) & 0x000fffff; // not needed because of the 1st condition above
	uptr = (unsigned) ptr;
	uptr = (coreid << 20) | uptr;

	return (void *) uptr;
}
コード例 #22
0
ファイル: e_demo.c プロジェクト: AlbertoGP/epiphany-examples
int main(void)
{
	unsigned *a, *b, *c, *size;
	unsigned i, j;
	int      coreid;
	unsigned *src, *dest;
	unsigned row, col;
	
	coreid = e_get_coreid() ^ 0x0c3; // Copy to the opposite core in chip
	src    = (unsigned *) 0x6000;
	dest   = (void *) ((coreid<<20) | 0x6000);
	
	size = (unsigned *) 0x1e00;
	a    = (unsigned *) 0x2000;
	b    = (unsigned *) 0x4000;
	c    = (unsigned *) 0x6000;
	
	// Doing convolution to generate busy level
	for (i=0; i<(*size); i++)
	{
		for (j=0; j<=i; j++)
		{
			c[i] += a[i-j] * b[j];
		}
	}
	
	for(i=0; i<100000; i++)
	{
		e_dma_copy(dest, src, *size);
	}
	
	// clear the IMASK
	e_irq_mask(E_SYNC, E_FALSE);
	
	// enable the global interrupt
	e_irq_global_mask(E_FALSE);

	__asm__ __volatile__("idle");

	return EXIT_SUCCESS;
}
コード例 #23
0
ファイル: epiphany.c プロジェクト: lvuotto/epiphany-test
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;
  
}
コード例 #24
0
int task_main(int argc, const char *argv[]) 
{
        e_coreid_t coreid;
        unsigned row, col;
        int wg_rows, wg_cols, my_row, my_col;
        coreid = e_get_coreid();
        e_coords_from_coreid (coreid, &row, &col);
        x_get_task_environment (&wg_rows, &wg_cols, &my_row, &my_col);
        x_set_task_status ("Hello from core 0x%03x (%d,%d) taskpos %d %d in %d %d", 
                           coreid, col, row, my_col, my_row, wg_cols, wg_rows);
        if (row == 1 && col == 1) {
          sync_send_test(X_TO_LEFT);
        }
        else if (row == 1 && col == 0) {
          sync_receive_test(X_FROM_RIGHT);      
        }
        else {
          x_sleep(30);
          x_set_task_status ("Goodbye from core 0x%03x (%d,%d) pid %d", 
                             coreid, col, row, my_col, my_row);
        }
        return X_SUCCESSFUL_TASK;
}
コード例 #25
0
/* Is address on this core? */
int e_is_oncore(const void *ptr)
{
	return (e_coreid_from_address(ptr) == e_get_coreid()) ? 1 : 0;
}
コード例 #26
0
ファイル: e-main.c プロジェクト: SkinnerSweet/barelog
int main(int argc, char **argv) {

	size_t shm_size = 1024;
	(void) shm_size;
	char tmp[17];

	unsigned my_row;
	unsigned my_col;
	e_coreid_t coreid;

	coreid = e_get_coreid();
	e_coords_from_coreid(coreid, &my_row, &my_col);

	/* <BARELOG_OVERLOAD> */
	barelog_mem_space_t mem_space =
		{ .phy_base = (void *) 0x8f000000, .length = 0x01000000,
			.alignment = 1, .word_size = 4, .data = 0 };

	barelog_platform_t platform = { .name = "PARALLELLA", .mem_space =
		mem_space, };

	barelog_policy_t policy = REPLACE;

	barelog_init_logger(my_row * 4 + my_col, platform, policy, policy, my_read,
		my_write, get_clock, init_clock, start_clock);
	/* </BARELOG_OVERLOAD> */

	sync();
	barelog_start();

	uint32_t clock00 = get_clock();
	barelog_log(BARELOG_CRITICAL_LVL, "Program starts at %u.", clock00);

	uint32_t clock01 = get_clock();
	(void) clock01;

	char buff[50] = {0};
	barelog_log(BARELOG_INFO_LVL, "e_read begins.");
	barelog_flush(2);
	barelog_clean(2);
	e_read(&e_emem_config, tmp, 0, 0, (void *)(0x8f000000+BARELOG_SHARED_MEM_MAX), 17);
	barelog_log(BARELOG_INFO_LVL, "e_read ends.%u", get_clock());

	uint32_t clock1 = get_clock();
	(void) clock1;

	// Uncomment to test the fulfillment of the events buffer.
	/*for (uint8_t k = 0; k < 1; ++k) {
		for (uint8_t i = 0; i < 200;  ++i) {
			barelog_log("Test %u %u %u", get_clock(), k, i);
			barelog_flush_buffer();
			barelog_clean_buffer();
			__asm__ __volatile__ ("nop");
		}
		__asm__ __volatile__ ("nop");
	}*/

	uint32_t clock2 = get_clock();
	(void) clock2;

	// Uncomment to access various clocks data.
	/*
	barelog_log("Results %u %u %u %u", clock00, clock01, clock1, clock2);
	if (barelog_flush_buffer() != BARELOG_SUCCESS) {
		exit(EXIT_FAILURE);
	}
	barelog_clean_buffer();
	 */

	snprintf(buff, 50, "%s from core %u", tmp, (my_row*4 + my_col));

	barelog_log(BARELOG_DEBUG_LVL, "e_write begins.");
	barelog_flush(1);
	barelog_clean(1);
	e_write((void*) &e_emem_config, buff, 0, 0, (void *)(0x8f000000+BARELOG_SHARED_MEM_MAX + (my_row*4+my_col)*50), 50);

	barelog_immediate_log(BARELOG_DEBUG_LVL, "e_write ends.");
	barelog_log(BARELOG_CRITICAL_LVL, "Program ends at %u", get_clock());
	barelog_flush(6); // Voluntary flushing too many events to check everything went well.


	exit(EXIT_SUCCESS);
}
コード例 #27
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;

}
コード例 #28
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;

}
コード例 #29
0
ファイル: emain.c プロジェクト: bergeraaron/parallella-rc4
int main(void) {

  unsigned core_row, core_col,
           group_rows, group_cols,
           core_num;

  core_row = e_group_config.core_row;
  core_col = e_group_config.core_col;
  group_rows = e_group_config.group_rows;
  group_cols = e_group_config.group_cols;

  core_num = core_row * group_cols + core_col;
/**
  // starts at the beginning of sdram
  resultflags  = (volatile uint16_t *) (0x8f000000 + 0x2);
  iv = (volatile unsigned char*) (0x8f0000002 + 0x3);
  data = (volatile unsigned char*) (0x8f000005 + 0x2);
  key = (volatile unsigned char *) (0x8f000007 + 0x5*core_num);
/**/
  // starts at the beginning of sdram
  resultflags  = (volatile uint16_t *) (0x8f000000);
  iv = (volatile unsigned char*) (0x8f000002);
  data = (volatile unsigned char*) (0x8f000005);
  key = (volatile unsigned char *) (0x8f000008 + 0x5*core_num);

        e_coreid_t id = e_get_coreid();

        //run through a keyspace
        //we got something that we should try to crack
        unsigned char * icvp;
        unsigned int crc;
        unsigned char testkey[8];
	unsigned char localdata[3];
	int a,b,c,d,e;
	//unsigned int compcrc;

	localdata[0] = data[0];
	localdata[1] = data[1];
	localdata[2] = data[2];

        //data[0]=0x22;
        //data[1]=0xAA;

        testkey[0] = iv[0];//iv1
        testkey[1] = iv[1];//iv2
        testkey[2] = iv[2];//iv3
        //sections to try for our loop

	//*result = 0;
  while(1) {

        //for(int a = 0x00; a <= 0xFF;a++)
	for(a = core_start[core_num]; a <= core_start[core_num+1];a++)
        {
                for(b = 0x00;b <= 0xFF;b++)
                {
                        for(c = 0x00;c <= 0xFF;c++)
                        {
                                for(d = 0x00;d <= 0xFF;d++)
                                {
                                        for(e = 0x00;e <= 0xFF;e++)
                                        {

                                                testkey[3] = a;//a
                                                testkey[4] = b;//b
                                                testkey[5] = c;//c
                                                testkey[6] = d;//d
                                                testkey[7] = e;//e
/**
RC4_KEY rc4_key;
RC4_set_key(&rc4_key, sizeof(key), key);
RC4(&rc4_key, data_size, data, un_data_section);
/**/
/**/
                                                rc4_init(testkey, 8);
                                                returnedbyte = RC4(data_size, localdata, un_data_section);
/**/
key[0] = testkey[3];
key[1] = testkey[4];
key[2] = testkey[5];
key[3] = testkey[6];
key[4] = testkey[7];
/**/

if(un_data_section[0] == 0xAA && un_data_section[1] == 0xAA && un_data_section[2] == 0x03)// && un_data_section[2] == 0x03)
{
	key[0] = testkey[3];
	key[1] = testkey[4];
	key[2] = testkey[5];
	key[3] = testkey[6];
	key[4] = testkey[7];

        //possible snap header
	if(CHECK_BIT(*resultflags,core_num) == 0)
        	*resultflags += flags[core_num];
}

                                        }//e for loop
                                }//d for loop
                        }//c for loop
                }//b for loop
        }//a for loop
  }
}