143 lines
4.9 KiB
C
143 lines
4.9 KiB
C
//***************************************************************************************
|
|
// Administrative routines.
|
|
//***************************************************************************************
|
|
//
|
|
// Author: Rob F. Van der Wijngaart
|
|
// Intel Corporation
|
|
// Date: 008/30/2010
|
|
//
|
|
//***************************************************************************************
|
|
//
|
|
//
|
|
// Copyright 2010 Intel Corporation
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
//
|
|
// [2010-10-25] added support for non-blocking send/recv operations
|
|
// - iRCCE_isend(), ..._test(), ..._wait(), ..._push()
|
|
// - iRCCE_irecv(), ..._test(), ..._wait(), ..._push()
|
|
// by Carsten Clauss, Chair for Operating Systems,
|
|
// RWTH Aachen University
|
|
//
|
|
// [2010-11-12] extracted non-blocking code into separate library
|
|
// by Carsten Scholtes
|
|
//
|
|
// [2011-02-21] added support for multiple incoming queues
|
|
// (one recv queue per remote rank)
|
|
//
|
|
|
|
#include <metalsvm/stddef.h>
|
|
|
|
#ifdef CONFIG_ROCKCREEK
|
|
|
|
#include <asm/iRCCE_lib.h>
|
|
|
|
// send request queue
|
|
iRCCE_SEND_REQUEST* iRCCE_isend_queue;
|
|
// recv request queue
|
|
iRCCE_RECV_REQUEST* iRCCE_irecv_queue[RCCE_MAXNP];
|
|
|
|
// recv request queue for those with source = iRCCE_ANY_SOURCE:
|
|
iRCCE_RECV_REQUEST* iRCCE_irecv_any_source_queue;
|
|
|
|
// mailbox in MPB
|
|
volatile iRCCE_MAIL_HEADER* iRCCE_mailbox_recv[RCCE_MAXNP]; // store addresses for receiving headers
|
|
volatile iRCCE_MAIL_HEADER* iRCCE_mailbox_send[RCCE_MAXNP]; // store addresses for sending headeres
|
|
|
|
// mailbox recv queue
|
|
iRCCE_MAIL_HEADER_LIST iRCCE_mailbox_recv_queue[iRCCE_PRIOS];
|
|
|
|
// mail garbage queue
|
|
iRCCE_MAIL_HEADER_LIST iRCCE_mail_garbage;
|
|
|
|
// flag indicating if last header was received
|
|
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
|
|
//--------------------------------------------------------------------------------------
|
|
/**
|
|
* @brief initialize the library
|
|
*
|
|
* To initialize the mailbox system the function calles RCCE_malloc() as often
|
|
* as there are UEs participating. As a result the respective mailboxes are
|
|
* located at the begin of the local MPB directly behind the space reserved for
|
|
* flags by RCCE_init(). In iRCCE_mailbox_recv[i] a pointer to the mailbox is
|
|
* saved respectively. To access the send mailboxes at the receiving UEs the
|
|
* coresponding pointers are saved in iRCCE_mailbox_send[i] resprectively.
|
|
*/
|
|
//--------------------------------------------------------------------------------------
|
|
int iRCCE_init(void) {
|
|
int i;
|
|
|
|
for(i=0; i<RCCE_MAXNP; i++) {
|
|
iRCCE_irecv_queue[i] = NULL;
|
|
iRCCE_mailbox_recv[i] = NULL;
|
|
iRCCE_mailbox_send[i] = NULL;
|
|
iRCCE_last_mail[i] = 0;
|
|
iRCCE_mailbox_status[i] = iRCCE_MAILBOX_OPEN;
|
|
}
|
|
|
|
iRCCE_isend_queue = NULL;
|
|
iRCCE_irecv_any_source_queue = NULL;
|
|
|
|
// init trash bin for mailbox
|
|
iRCCE_mail_garbage.first = NULL;
|
|
iRCCE_mail_garbage.last = NULL;
|
|
|
|
// init mail-priority lists
|
|
for( i=0; i<iRCCE_PRIOS; ++i ) {
|
|
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; i<RCCE_NP; i++ ) {
|
|
iRCCE_mailbox_recv[i] = (iRCCE_MAIL_HEADER*)RCCE_malloc(RCCE_LINE_SIZE);
|
|
|
|
}
|
|
|
|
|
|
for( i=0; i<RCCE_NP; i++ ) {
|
|
iRCCE_mailbox_send[i] = (iRCCE_MAIL_HEADER*)(RCCE_comm_buffer[i] + ((RCCE_buff_ptr - RCCE_comm_buffer[RCCE_IAM]) - (RCCE_NP-RCCE_IAM)*RCCE_LINE_SIZE ));
|
|
}
|
|
|
|
return (iRCCE_SUCCESS);
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------
|
|
// FUNCTION: iRCCE_finalize
|
|
//--------------------------------------------------------------------------------------
|
|
// finalize the library
|
|
//--------------------------------------------------------------------------------------
|
|
int iRCCE_finalize(void) {
|
|
// empty iRCCE_mail_garbage
|
|
iRCCE_MAIL_HEADER* run;
|
|
iRCCE_MAIL_HEADER* erase_header;
|
|
|
|
iRCCE_mailbox_flush();
|
|
|
|
for( run = iRCCE_mail_garbage.first; run != NULL; ) {
|
|
erase_header = run;
|
|
run = run->next;
|
|
kfree( erase_header, sizeof(iRCCE_MAIL_HEADER) );
|
|
}
|
|
|
|
iRCCE_mail_garbage.first = iRCCE_mail_garbage.last = NULL;
|
|
|
|
return iRCCE_SUCCESS;
|
|
}
|
|
#endif
|