//*************************************************************************************** // // 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-11-26] added xxx // by Carsten Clauss, Chair for Operating Systems, // RWTH Aachen University // #include "iRCCE_lib.h" #include #include #ifdef __hermit__ #include "rte_memcpy.h" #define memcpy_scc rte_memcpy #elif defined COPPERRIDGE || defined SCC #include "scc_memcpy.h" #else #define memcpy_scc memcpy #endif static int iRCCE_msend_general( char *privbuf, // source buffer in local private memory (send buffer) t_vcharp combuf, // intermediate buffer in MPB size_t chunk, // size of MPB available for this message (bytes) RCCE_FLAG *sent, // flag indicating whether message has been sent by source ssize_t size // size of message (bytes) ) { char padline[RCCE_LINE_SIZE]; // copy buffer, used if message not multiple of line size size_t wsize, // offset within send buffer when putting in "chunk" bytes remainder, // bytes remaining to be sent nbytes; // number of bytes to be sent in single iRCCE_put call char *bufptr; // running pointer inside privbuf for current location size_t subchunk1, subchunk2; // sub-chunks for the pipelined message transfer int ue; #ifndef _iRCCE_ANY_LENGTH_ #define FLAG_SET_VALUE RCCE_FLAG_SET #else RCCE_FLAG_STATUS FLAG_SET_VALUE = (RCCE_FLAG_STATUS)size; #endif // send data in units of available chunk size of comm buffer for (wsize=0; wsize< (size/chunk)*chunk; wsize+=chunk) { bufptr = privbuf + wsize; nbytes = chunk; // copy private data to own comm buffer RCCE_put(combuf, (t_vcharp) bufptr, nbytes, RCCE_IAM); for(ue=0; ue= RCCE_NP) return(RCCE_error_return(RCCE_debug_comm,RCCE_ERROR_ID)); else { return(iRCCE_mrecv_general(privbuf, RCCE_buff_ptr, RCCE_chunk, &RCCE_sent_flag[source], size, source)); } } //-------------------------------------------------------------------------------------- // FUNCTION: iRCCE_mcast //-------------------------------------------------------------------------------------- // multicast based on msend() and mrecv() //-------------------------------------------------------------------------------------- int iRCCE_mcast(char *buf, size_t size, int root) { if(RCCE_IAM != root) { return iRCCE_mrecv(buf, size, root); } else { return iRCCE_msend(buf, size); } } //-------------------------------------------------------------------------------------- // FUNCTION: iRCCE_bcast //-------------------------------------------------------------------------------------- // wrapper function for using iRCCE's multicast feature //-------------------------------------------------------------------------------------- int iRCCE_bcast(char *buf, size_t size, int root, RCCE_COMM comm) { if(memcmp(&comm, &RCCE_COMM_WORLD, sizeof(RCCE_COMM)) == 0) { return RCCE_bcast(buf, size, root, comm); } else { return iRCCE_mcast(buf, size, root); } }