diff --git a/arch/x86/include/asm/iRCCE.h b/arch/x86/include/asm/iRCCE.h index 60250eab..ed762ba2 100644 --- a/arch/x86/include/asm/iRCCE.h +++ b/arch/x86/include/asm/iRCCE.h @@ -45,6 +45,7 @@ #define iRCCE_MAILBOX_ALL -4 #define iRCCE_MAILBOX_OPEN 0 #define iRCCE_MAILBOX_CLOSED 1 +#define iRCCE_MAILBOX_INVALID -1 // iRCCE-mailbox-system tags #define iRCCE_LAST_MAIL -1 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index 413c2932..7132026b 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c @@ -233,11 +233,9 @@ void irq_handler(struct state *s) { /* This is a blank function pointer */ void (*handler) (struct state * s); - + // at first, we check our work queues -// if( s->int_no == 124 ) { - check_workqueues(); -// } + check_workqueues(); /* * Find out if we have a custom handler to run for this diff --git a/arch/x86/scc/iRCCE_mailbox.c b/arch/x86/scc/iRCCE_mailbox.c index 045a731d..b01907d0 100644 --- a/arch/x86/scc/iRCCE_mailbox.c +++ b/arch/x86/scc/iRCCE_mailbox.c @@ -24,10 +24,6 @@ // limitations under the License. // // -#include "iRCCE_lib.h" -#include -#include -#include /** * @@ -60,7 +56,7 @@ static int iRCCE_mailbox_close_one(int rank, int check); void iRCCE_mailbox_print_header(iRCCE_MAIL_HEADER* header) { - printf( "\n" + kprintf( "\n" "-------------------------\n" "| RCK%d\n" "-------------------------\n" @@ -185,6 +181,7 @@ static int iRCCE_mailbox_check() { } } + return iRCCE_SUCCESS; } @@ -210,7 +207,7 @@ int iRCCE_mail_recv( int i; iRCCE_MAIL_HEADER* help_header; - + // if there is no mail, check for incoming if ( !iRCCE_mailbox_recv_queue[0].first ) { iRCCE_mailbox_check(); @@ -237,6 +234,7 @@ int iRCCE_mail_recv( // no mail queued *header = NULL; + return iRCCE_MAILBOX_EMPTY; } @@ -312,6 +310,11 @@ int iRCCE_mail_send( int dest // UE that will receive the header ) { + // check for an attempt to send in own mailbox + if( dest == RCCE_IAM ) { + return iRCCE_MAILBOX_INVALID; + } + // if dest mailbox is full, check for incoming mail RC_cache_invalidate(); while( iRCCE_mailbox_send[dest]->sent ) { diff --git a/arch/x86/scc/icc.c b/arch/x86/scc/icc.c index d3cd427d..f0c8b957 100644 --- a/arch/x86/scc/icc.c +++ b/arch/x86/scc/icc.c @@ -192,25 +192,40 @@ int icc_halt(void) uint32_t flags; uint32_t do_send = 1; - do { - // iRCCE is not thread save => disable interrupts - flags = irq_nested_disable(); + // iRCCE is not thread save => disable interrupts + flags = irq_nested_disable(); - if (do_send) { - do_send = (iRCCE_isend_push() == iRCCE_PENDING); - iRCCE_irecv_push(); - } - icc_mail_check(); + icc_mail_check(); - irq_nested_enable(flags); - } while(do_send); + irq_nested_enable(flags); HALT; return 0; } -#define ROUNDS 100000 +#define ROUNDS 10000 + +static inline void icc_mail_check_tag(iRCCE_MAIL_HEADER* mail) { + char* recv_buffer; + + switch( mail->tag ) { + case iRCCE_ANYLENGTH: + recv_buffer = (char*)kmalloc( mail->size ); + iRCCE_irecv(recv_buffer, mail->size, + mail->source, NULL ); + break; + + case PING_REQ: + iRCCE_mail_send(0, PING_RESP, 0, NULL, mail->source); + break; + + default: + break; + } + +} + int icc_mail_ping( void ) { @@ -271,11 +286,9 @@ int icc_mail_ping( void ) return 0; } + #define CORE_A 0 // sender -#define CORE_B RCCE_num_ues()-1 // receiver -#define NOISE_ROUNDS 1000000 - - +#define CORE_B 1 // receiver int icc_mail_ping_irq( void ) { /* return if not core 0 */ @@ -285,34 +298,36 @@ int icc_mail_ping_irq( void ) uint64_t timer = 0; int rem_rank = CORE_B; int i; + int res; iRCCE_MAIL_HEADER* recv_header = NULL; kprintf( "Hello from mail_ping_irq ... \n" ); + kprintf( "my_rank = %d\n", my_ue ); kprintf( "rem_rank = %d\n", rem_rank ); // disable interrupts flags = irq_nested_disable(); for( i=0; itag == PING_RESP ) + /* send interrupt */ + icc_send_irq(rem_rank); + + /* wait for response */ + do { + res = iRCCE_mail_recv(&recv_header); + if( res == iRCCE_SUCCESS ) { + if( (recv_header->source == rem_rank) + && (recv_header->tag == PING_RESP) ) break; - } while( 1 ); + iRCCE_mail_release(&recv_header); + } + } while( 1 ); + + /* release mail */ + iRCCE_mail_release(&recv_header); - /* release mail */ - iRCCE_mail_release(&recv_header); - } - /* start timer in first round */ if( i == 0 ) timer = rdtsc(); @@ -321,40 +336,52 @@ int icc_mail_ping_irq( void ) /* stop timer */ timer = rdtsc() - timer; + kprintf( "timer = %ld\n", timer ); + kprintf( "mail_pingpong needs in average %d µsec (%d ticks)!\n", + timer/(2*ROUNDS*533), timer/(2*ROUNDS) ); - kprintf( "timer = %d\n", timer ); - if( my_ue == 0 ) { - kprintf( "mail_pingpong needs in average %f µsec (%d ticks)!\n", - timer/(2.0*ROUNDS*533), timer/(2*ROUNDS) ); + + /* recv noise mails */ + while(1) { + iRCCE_mail_recv(&recv_header); + if(recv_header) iRCCE_mail_release(&recv_header); } irq_nested_enable(flags); - return 0; } int icc_mail_noise() { - int i, j; + int j, res; int num_ranks = RCCE_num_ues(); iRCCE_MAIL_HEADER* recv_mail = NULL; - + + kprintf( "Hello from icc_mail_noise: my_ue = %d\n", my_ue ); + // leave function if not participating - if( (my_ue == CORE_A) || (my_ue == CORE_B) ) { + if( (my_ue == CORE_A) /*|| (my_ue == CORE_B)*/) { return -1; - } + } - for( i=0; itag ) { - case 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); - break; - - case iRCCE_ANYLENGTH_PIGGYBACK: - iRCCE_mail_send(0, 2, 0, NULL, header->source); - break; - - case PING_REQ: - iRCCE_mail_send(0, PING_RESP, 0, NULL, header->source); - break; - } - - + while( (res = iRCCE_mail_recv(&header)) == iRCCE_SUCCESS ) { + icc_mail_check_tag(header); iRCCE_mail_release( &header ); } } diff --git a/kernel/tests.c b/kernel/tests.c index fc4f4d39..67b3904d 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -90,11 +90,16 @@ static int STDCALL foo(void* arg) int STDCALL mail_ping(void* arg) { //icc_mail_ping(); icc_mail_ping_irq(); - //icc_mail_noise(); // generate noise in the mesh icc_halt(); return 0; } + +int STDCALL mail_noise(void*arg) { + icc_mail_noise(); // generate noise in the mesh + + return 0; +} #endif static int STDCALL join_test(void* arg) @@ -133,6 +138,7 @@ int test_init(void) //create_kernel_task(NULL, producer, NULL); //create_kernel_task(NULL, consumer, NULL); create_kernel_task(NULL, mail_ping, NULL); + create_kernel_task(NULL, mail_noise, NULL); //create_user_task(NULL, "/bin/hello", argv); //create_user_task(NULL, "/bin/tests", argv); //create_user_task(NULL, "/bin/jacobi", argv);