From e813c37d9fcac2720b46bf864ef558921b2feb07 Mon Sep 17 00:00:00 2001 From: Simon Pickartz Date: Mon, 1 Aug 2011 13:55:29 +0200 Subject: [PATCH] update mailbox_system to newest version --- arch/x86/include/asm/iRCCE.h | 18 ++++++---- arch/x86/include/asm/iRCCE_lib.h | 1 + arch/x86/scc/iRCCE_admin.c | 6 ++-- arch/x86/scc/iRCCE_mailbox.c | 60 +++++++++++++++++++++++++------- 4 files changed, 64 insertions(+), 21 deletions(-) diff --git a/arch/x86/include/asm/iRCCE.h b/arch/x86/include/asm/iRCCE.h index ed762ba2..7300065c 100644 --- a/arch/x86/include/asm/iRCCE.h +++ b/arch/x86/include/asm/iRCCE.h @@ -40,19 +40,22 @@ #define iRCCE_ANY_SOURCE -1 #define iRCCE_PRIOS 5 -#define iRCCE_MAILBOX_EMPTY -2 -#define iRCCE_LAST_MAILS_NOT_RECV -3 #define iRCCE_MAILBOX_ALL -4 -#define iRCCE_MAILBOX_OPEN 0 -#define iRCCE_MAILBOX_CLOSED 1 -#define iRCCE_MAILBOX_INVALID -1 + +// status codes +#define iRCCE_ERROR_ID RCCE_ERROR_ID +#define iRCCE_MAILBOX_OPEN -1 +#define iRCCE_MAILBOX_CLOSED -2 +#define iRCCE_MAILBOX_INVALID -3 +#define iRCCE_MAILBOX_EMPTY -4 +#define iRCCE_LAST_MAILS_NOT_RECV -5 // iRCCE-mailbox-system tags #define iRCCE_LAST_MAIL -1 +#define iRCCE_LAST_MAIL -1 #define iRCCE_ANYLENGTH -2 #define iRCCE_ANYLENGTH_PIGGYBACK -3 - typedef volatile char iRCCE_SHORT_FLAG; typedef struct _iRCCE_SEND_REQUEST { @@ -182,7 +185,8 @@ int iRCCE_irecv_cancel(iRCCE_RECV_REQUEST *, int *); int iRCCE_mail_send(size_t, int, char, char*, int); int iRCCE_mail_recv(iRCCE_MAIL_HEADER**); // -// functions to empty mailbox-queue and to check for last mails: +// functions to empty mailbox-queue and to check for mails: +int iRCCE_mail_check(int); int iRCCE_mail_release(iRCCE_MAIL_HEADER**); int iRCCE_last_mail_recv(void); int iRCCE_mailbox_wait(void); diff --git a/arch/x86/include/asm/iRCCE_lib.h b/arch/x86/include/asm/iRCCE_lib.h index 70df2596..ff020884 100644 --- a/arch/x86/include/asm/iRCCE_lib.h +++ b/arch/x86/include/asm/iRCCE_lib.h @@ -46,6 +46,7 @@ extern iRCCE_SHORT_FLAG iRCCE_mailbox_status[RCCE_MAXNP]; // garbage collection for mailbox extern iRCCE_MAIL_HEADER_LIST iRCCE_mail_garbage; + #ifdef _OPENMP #pragma omp threadprivate (iRCCE_isend_queue, iRCCE_irecv_queue) #endif diff --git a/arch/x86/scc/iRCCE_admin.c b/arch/x86/scc/iRCCE_admin.c index cd119167..9e59d2fb 100644 --- a/arch/x86/scc/iRCCE_admin.c +++ b/arch/x86/scc/iRCCE_admin.c @@ -66,8 +66,6 @@ iRCCE_SHORT_FLAG iRCCE_last_mail[RCCE_MAXNP]; // field to store open/closed status of mailboxes iRCCE_SHORT_FLAG iRCCE_mailbox_status[RCCE_MAXNP]; - - //-------------------------------------------------------------------------------------- // FUNCTION: iRCCE_init //-------------------------------------------------------------------------------------- @@ -105,6 +103,7 @@ int iRCCE_init(void) { iRCCE_mailbox_recv_queue[i].first = NULL; iRCCE_mailbox_recv_queue[i].last = NULL; } + // allocate space in MPB for mailbox and set senders mailbox-pointer for( i=0; inext; @@ -136,6 +137,7 @@ int iRCCE_finalize(void) { } iRCCE_mail_garbage.first = iRCCE_mail_garbage.last = NULL; + return iRCCE_SUCCESS; } #endif diff --git a/arch/x86/scc/iRCCE_mailbox.c b/arch/x86/scc/iRCCE_mailbox.c index b01907d0..3803238b 100644 --- a/arch/x86/scc/iRCCE_mailbox.c +++ b/arch/x86/scc/iRCCE_mailbox.c @@ -41,8 +41,7 @@ #include // forward declaration -static int iRCCE_mailbox_close_one(int rank, int check); - +int iRCCE_mailbox_close_one(int rank, int check); //------------------------------------------------------------------------------ // FUNCTION: iRCCE_mailbox_print_header @@ -110,7 +109,7 @@ static int iRCCE_mail_fetch( // copy header to allocated memory - RC_cache_invalidate(); + //RC_cache_invalidate(); iRCCE_memcpy_get( (void*)header, (void*)iRCCE_mailbox_recv[rank], RCCE_LINE_SIZE ); @@ -158,14 +157,15 @@ static int iRCCE_mail_fetch( * write out the data. */ //------------------------------------------------------------------------------ +iRCCE_MAIL_HEADER dummy_header = {0, 0, 0, NULL, 0, 0, 0, {[0 ... iRCCE_MAIL_HEADER_PAYLOAD-1] = 0} }; + + static int iRCCE_mailbox_check() { int i,j; for( j=1; jsent = RCCE_FLAG_UNSET; - *(int *)RCCE_fool_write_combine_buffer = 1; + *(iRCCE_mailbox_recv[i]) = dummy_header; } } } - return iRCCE_SUCCESS; } +//------------------------------------------------------------------------------ +// FUNCTION: iRCCE_mail_check +//------------------------------------------------------------------------------ +/** + * @brief routine to check one specific mailbox + * @param sender is the core ID from which the mailbox is checked + * + * This function may be called by the user application to check one specific + * mailbox. It is recommended to use it in combination with an inter core + * interrupt. + * + */ +//------------------------------------------------------------------------------ +int iRCCE_mail_check(int sender) { + // verify sender's ID + if( (sender < 0) || (sender > RCCE_NP) || (sender == RCCE_IAM) ) { + return iRCCE_ERROR_ID; + } + + // check if mailbox is open + if( iRCCE_mailbox_status[sender] == iRCCE_MAILBOX_CLOSED ) { + return iRCCE_MAILBOX_CLOSED; + } + + RC_cache_invalidate(); + if( iRCCE_mailbox_recv[sender]->sent ) { + iRCCE_mail_fetch(sender); + + // reset senders flag + RC_cache_invalidate(); + *(iRCCE_mailbox_recv[sender]) = dummy_header; + + return iRCCE_SUCCESS; + } + else { + return iRCCE_MAILBOX_EMPTY; + } +} + //------------------------------------------------------------------------------ // FUNCTION: iRCCE_mail_recv //------------------------------------------------------------------------------ @@ -309,8 +346,7 @@ int iRCCE_mail_send( char* payload, // pointer to buffer for header payload int dest // UE that will receive the header ) { - - // check for an attempt to send in own mailbox + // check for an attempt to send to own mailbox if( dest == RCCE_IAM ) { return iRCCE_MAILBOX_INVALID; } @@ -444,8 +480,8 @@ int iRCCE_mailbox_flush(void) { * last-mail. * * This function closes a mailbox of the given rank. If the check flag is set - * an iRCCE_mail_check()-call is performed. The close procedure has to be locked - * to be sure that no UE sends any mail while closing the mailbox. + * an iRCCE_mailbox_check()-call is performed. The close procedure has to be + * locked to be sure that no UE sends any mail while closing the mailbox. */ //------------------------------------------------------------------------------ static int iRCCE_mailbox_close_one(int rank, int check) {