From 5cd3d7557aa7a83eab83ed450dbfbd5f92d2a66e Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sat, 2 Jul 2011 03:13:24 -0700 Subject: [PATCH] fine tuning to increase the performance of the mailbox example --- arch/x86/include/asm/icc.h | 10 +++--- arch/x86/kernel/processor.c | 3 ++ arch/x86/scc/icc.c | 61 +++++++++++++++++++------------------ 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/arch/x86/include/asm/icc.h b/arch/x86/include/asm/icc.h index cb806761..9cca3390 100644 --- a/arch/x86/include/asm/icc.h +++ b/arch/x86/include/asm/icc.h @@ -39,12 +39,10 @@ typedef struct { extern bootinfo_t* bootinfo; -/* -#define ICC_TYPE_IP (1 << 0) -#define ICC_TYPE_SVM (1 << 1) -#define ICC_TYPE_PINGREQUEST (1 << 2) -#define ICC_TYPE_PINGRESPONSE (1 << 3) -*/ +#define ICC_TAG_IP 0 +#define ICC_TAG_SVM 1 +#define ICC_TAG_PINGREQUEST 2 +#define ICC_TAG_PINGRESPONSE 3 int icc_init(void); int icc_halt(void); diff --git a/arch/x86/kernel/processor.c b/arch/x86/kernel/processor.c index 4210c38f..93e5f540 100644 --- a/arch/x86/kernel/processor.c +++ b/arch/x86/kernel/processor.c @@ -21,6 +21,7 @@ #include #include #include +#include #ifdef CONFIG_ROCKCREEK #include #endif @@ -104,6 +105,8 @@ void udelay(uint32_t usecs) mb(); end = rdtsc(); diff = end > start ? end - start : start - end; + if ((diff < deadline) && (deadline - diff > 50000)) + check_workqueues(); } while(diff < deadline); } diff --git a/arch/x86/scc/icc.c b/arch/x86/scc/icc.c index b2a517b9..963eabc3 100644 --- a/arch/x86/scc/icc.c +++ b/arch/x86/scc/icc.c @@ -203,27 +203,25 @@ int icc_halt(void) icc_mail_check(); irq_nested_enable(flags); + + NOP1; } while(do_send); - HALT; + //HALT; return 0; } #define MAIL_MSG_SIZE 20 +uint64_t timer; int icc_mail_ping( void ) { uint32_t flags; - uint64_t timer; int remote_rank = (my_ue+1)%2; - char send_buffer[MAIL_MSG_SIZE]; - int length = MAIL_MSG_SIZE; - - if( my_ue ) { - return 0; - } + if (my_ue) + return -1; kprintf( "Hello from mail_ping ... \n" ); @@ -233,25 +231,16 @@ int icc_mail_ping( void ) // start timer timer = rdtsc(); - // start anylength send - iRCCE_isend( send_buffer, -length, remote_rank, NULL ); + /* send ping request */ + iRCCE_mail_send(0, ICC_TAG_PINGREQUEST, 0, NULL, remote_rank); - // wait for response - iRCCE_MAIL_HEADER* mail; - do { - iRCCE_mail_recv( &mail ); - } while( !mail ); - - // stop timer - timer = rdtsc() - timer; + NOP8; + icc_send_irq(remote_rank); - if( mail->tag == 2 ) { - kprintf( "Response received in %d ticks!\n", timer ); - } - else { - kprintf( "Response didn't arrive!\n" ); - } + /* check for incoming messages */ + icc_mail_check(); + // enable interrupts irq_nested_enable(flags); return 0; @@ -261,21 +250,33 @@ void icc_mail_check(void) { iRCCE_MAIL_HEADER* header = NULL; int res; - char* recv_buffer; + //char* recv_buffer; // empty mailbox and interpret headers while( (res = iRCCE_mail_recv( &header )) == iRCCE_SUCCESS ) { - if( header->tag == 1 ) { - iRCCE_mail_send( 0, 2, 0, NULL, header->source ); - } - else if( header->tag == iRCCE_ANYLENGTH ) { + switch(header->tag) + { + case ICC_TAG_PINGREQUEST: + iRCCE_mail_send( 0, ICC_TAG_PINGRESPONSE, 0, NULL, header->source ); + NOP8; + icc_send_irq( header->source ); + break; + case ICC_TAG_PINGRESPONSE: + timer = rdtsc() - timer; + kprintf( "Response received in %d ticks!\n", timer ); + break; + default: + kprintf("Invalid mail: tag = %d\n", header->tag); + break; + } + /*else if( header->tag == iRCCE_ANYLENGTH ) { recv_buffer = (char*)kmalloc( header->size ); iRCCE_irecv( recv_buffer, header->size, header->source, NULL ); iRCCE_mail_send( 0, 2, 0, NULL, header->source ); } else if( header->tag == iRCCE_ANYLENGTH_PIGGYBACK ) { iRCCE_mail_send( 0, 2, 0, NULL, header->source ); - } + }*/ iRCCE_mail_release( &header ); }