minor optimizations, use RC_RCCEID to determine the core id

This commit is contained in:
Stefan Lankes 2011-10-10 22:03:12 +02:00
parent 52ad55730e
commit 244aa1a4c0

View file

@ -37,7 +37,6 @@
bootinfo_t* bootinfo = (bootinfo_t*) SCC_BOOTINFO;
static int num_ues, my_ue;
/* PSE bit for Pentium+ equals MPE (message buffer enable) flag in RCK! So, use it to create _PAGE_MPB symbol... */
#define _CR4_MPE 0x00000800
@ -115,15 +114,14 @@ static void icc_handler(struct state *s)
iRCCE_MAIL_HEADER* header = NULL;
int tmp, source;
uint32_t status_low, status_high, status;
static int z, core_id = -1;
static int z = -1;
volatile static uint32_t* status_addr;
volatile static uint32_t* reset_addr;
if (core_id < 0) {
core_id = RC_COREID[my_ue];
z = Z_PID(core_id);
status_addr = (volatile uint32_t*) (FPGA_BASE + IRQ_STATUS + core_id * 8);
reset_addr = (volatile uint32_t*) (FPGA_BASE + IRQ_RESET + core_id * 8);
if (z < 0) {
z = Z_PID(RC_MY_COREID);
status_addr = (volatile uint32_t*) (FPGA_BASE + IRQ_STATUS + RC_MY_COREID * 8);
reset_addr = (volatile uint32_t*) (FPGA_BASE + IRQ_RESET + RC_MY_COREID * 8);
}
status_low = status_addr[0];
@ -140,15 +138,13 @@ static void icc_handler(struct state *s)
status >>= 6; // shift emac bits
for (source=0; status!=0; status >>= 1, ++source) {
if ( (status & 0x1) != 0 ) {
iRCCE_mail_check(source);
}
if (((status & 0x1) != 0) && (RC_RCCEID[source] >= 0))
iRCCE_mail_check(RC_RCCEID[source]);
}
for (source=26, status=status_high; status!=0; status >>= 1, ++source) {
if ( (status & 0x1) != 0 ) {
iRCCE_mail_check(source);
}
if (((status & 0x1) != 0) && (RC_RCCEID[source] >= 0))
iRCCE_mail_check(RC_RCCEID[source]);
}
} else iRCCE_mail_check(iRCCE_MAILBOX_ALL);
@ -213,9 +209,7 @@ int icc_init(void)
// enable additional outputs
//RCCE_debug_set(RCCE_DEBUG_ALL);
my_ue = RCCE_ue();
num_ues = RCCE_num_ues();
kprintf("Got rank %d of %d ranks\n", my_ue, num_ues);
kprintf("Got rank %d of %d ranks\n", RCCE_IAM, RCCE_NP);
RCCE_barrier(&RCCE_COMM_WORLD);
@ -241,7 +235,7 @@ int icc_init(void)
#endif
// reset INTR/LINT0 flag
z = Z_PID(RC_COREID[my_ue]);
z = Z_PID(RC_MY_COREID);
tmp=ReadConfigReg(CRB_OWN + (z==0 ? GLCFG0 : GLCFG1));
tmp &= ~(1 << GLCFG_XINTR_BIT);
SetConfigReg(CRB_OWN + (z==0 ? GLCFG0 : GLCFG1), tmp);
@ -274,16 +268,16 @@ int icc_init(void)
else
kputs("disabled!\n");
// set interrupt handler (INTR/LINT0)
// set interrupt handler (LINT0)
irq_install_handler(124, icc_handler);
// unmask interrupts
volatile uint32_t* irq_mask = (volatile uint32_t*)(FPGA_BASE + IRQ_MASK + RC_COREID[my_ue]*8);
volatile uint32_t* irq_mask = (volatile uint32_t*)(FPGA_BASE + IRQ_MASK + RC_COREID[RCCE_IAM]*8);
irq_mask[0] = 0x00; //0x3F;
irq_mask[1] = 0x00;
// set remote interrupts to LINT 0
volatile uint32_t* irq_config = (volatile uint32_t*)(FPGA_BASE + IRQ_CONFIG + RC_COREID[my_ue]*4);
volatile uint32_t* irq_config = (volatile uint32_t*)(FPGA_BASE + IRQ_CONFIG + RC_COREID[RCCE_IAM]*4);
irq_config[0] = 0x00;
kprintf( "irq_mask = 0x%x, 0x%x\n", irq_mask[0], irq_mask[1]);
@ -308,7 +302,7 @@ int icc_halt(void)
#define CORE_B 1 // receiver
int icc_send_gic_irq(int core_num) {
volatile uint32_t* irq_request = (volatile uint32_t*)(FPGA_BASE+IRQ_REQUEST+RC_COREID[my_ue]*8);
volatile uint32_t* irq_request = (volatile uint32_t*)(FPGA_BASE+IRQ_REQUEST+RC_MY_COREID*8);
uint32_t bit_pos;
if (BUILTIN_EXPECT((core_num < 0) || (core_num > 48), 0))
@ -335,9 +329,9 @@ int icc_mail_ping(void)
iRCCE_MAIL_HEADER* recv_header = NULL;
/* leave function if not participating in pingpong */
if( (my_ue != CORE_A) && (my_ue != CORE_B) ) return -1;
if( (RCCE_IAM != CORE_A) && (RCCE_IAM != CORE_B) ) return -1;
kprintf( "my_ue = %d\n", my_ue );
kprintf( "my_ue = %d\n", RCCE_IAM);
kprintf( "Hello from mail_ping ... \n" );
kprintf( "rounds = %d\n", ROUNDS );
@ -347,7 +341,7 @@ int icc_mail_ping(void)
for( i=0; i<ROUNDS+1; ++i ) {
/* senders part */
if( my_ue == CORE_A ) {
if( RCCE_IAM == CORE_A ) {
/* send ping request */
iRCCE_mail_send(0, PING_REQ, 0, NULL, CORE_B);
@ -384,7 +378,7 @@ int icc_mail_ping(void)
timer = rdtsc() - timer;
if( my_ue == CORE_A ) {
if( RCCE_IAM == CORE_A ) {
kprintf( "timer = %ld\n", timer );
kprintf( "mail_pingpong needs in average %d ns (%d ticks)!\n",
timer*1000/(2*ROUNDS*get_cpu_frequency()), timer/(2*ROUNDS) );
@ -399,7 +393,7 @@ int icc_mail_ping_irq(void)
{
kprintf( "Hello from mail_ping_irq ... \n" );
/* return if not core A */
if( my_ue != CORE_A ) return 0;
if( RCCE_IAM != CORE_A ) return 0;
uint32_t flags;
uint64_t timer = 0;
@ -407,7 +401,7 @@ int icc_mail_ping_irq(void)
int res;
iRCCE_MAIL_HEADER* recv_header = NULL;
kprintf( "my_rank = %d\n", my_ue );
kprintf( "my_rank = %d\n", RCCE_IAM );
kprintf( "rem_rank = %d\n", CORE_B );
kprintf( "rounds = %d\n", ROUNDS );
@ -454,13 +448,13 @@ int icc_mail_noise(void) {
iRCCE_MAIL_HEADER* recv_mail = NULL;
// leave function if not participating
if( !((my_ue == 4) || (my_ue == 2) || (my_ue == CORE_B)) ) {
if( !((RCCE_IAM == 4) || (RCCE_IAM == 2) || (RCCE_IAM == CORE_B)) ) {
kprintf( "mail_noise: leaving" );
return -1;
}
kprintf( "Hello from icc_mail_noise: my_ue = %d\n", my_ue );
kprintf( "Hello from icc_mail_noise: my_ue = %d\n", RCCE_IAM );
kprintf( "num_ues = %d\n", num_ranks );
for( i=0; i<10000; ++i ) {