MulticoreBSP for C  Version 1.2
mcbsp.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 by Albert-Jan N. Yzelman
3  *
4  * This file is part of MulticoreBSP in C --
5  * a port of the original Java-based MulticoreBSP.
6  *
7  * MulticoreBSP for C is distributed as part of the original
8  * MulticoreBSP and is free software: you can redistribute
9  * it and/or modify it under the terms of the GNU Lesser
10  * General Public License as published by the Free Software
11  * Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  * MulticoreBSP is distributed in the hope that it will be
14  * useful, but WITHOUT ANY WARRANTY; without even the
15  * implied warranty of MERCHANTABILITY or FITNESS FOR A
16  * PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General
20  * Public License along with MulticoreBSP. If not, see
21  * <http://www.gnu.org/licenses/>.
22  */
23 
81 #ifndef _H_MCBSP
82 #define _H_MCBSP
83 
88 //#define MCBSP_USE_SPINLOCK
89 
107 #define MCBSP_ALLOW_MULTIPLE_REGS
108 
114 #define MCBSP_ENABLE_HP_DIRECTIVES
115 
129 #define ENABLE_FAKE_HP_DIRECTIVES
130 
131 //define MCBSP_NO_CHECKS to disable all run-time sanity
132 //checks, except those regarding memory allocation.
133 
134 #ifdef MCBSP_COMPATIBILITY_MODE
135 
136  #define MCBSP_PROCESSOR_INDEX_DATATYPE int
137 
138  #define MCBSP_NUMMSG_TYPE int
139 
140  #define MCBSP_BYTESIZE_TYPE int
141 #else
142 
143  #define MCBSP_PROCESSOR_INDEX_DATATYPE unsigned int
144 
145  #define MCBSP_NUMMSG_TYPE unsigned int
146 
147  #define MCBSP_BYTESIZE_TYPE size_t
148 #endif
149 
150 //set forced defines
151 #ifdef MCBSP_COMPATIBILITY_MODE
152  //The BSPlib standard requires multiple registrations.
153  #define MCBSP_ALLOW_MULTIPLE_REGS
154  //The BSPlib standard prescribes the existance of
155  //bsp_hpput and bsp_hpget, so they should be defined
156  //even if no actual high-performant implementation is
157  //actually available.
158  #define MCBSP_ENABLE_HP_DIRECTIVES
159  #define ENABLE_FAKE_HP_DIRECTIVES
160 #endif
161 #ifdef ENABLE_FAKE_HP_DIRECTIVES
162  //if fake HP directives are defined,
163  //HP directives are enabled.
164  #define MCBSP_ENABLE_HP_DIRECTIVES
165 #endif
166 
167 
168 #include <stdarg.h>
169 #include <stddef.h>
170 
188 
198 void bsp_end( void );
199 
215 void bsp_init( void (*spmd)(void), int argc, char **argv );
216 
228 void bsp_abort( const char * const error_message, ... );
229 
242 void bsp_vabort( const char * const error_message, va_list args );
243 
264 
281 
292 double bsp_time( void );
293 
315 void bsp_sync( void );
316 
339 void bsp_push_reg( void * const address, const MCBSP_BYTESIZE_TYPE size );
340 
359 void bsp_pop_reg( void * const address );
360 
398 void bsp_put( const MCBSP_PROCESSOR_INDEX_DATATYPE pid, const void * const source,
399  void * const destination, const MCBSP_BYTESIZE_TYPE offset, const MCBSP_BYTESIZE_TYPE size );
400 
442 void bsp_get( const MCBSP_PROCESSOR_INDEX_DATATYPE pid, const void * const source,
443  const MCBSP_BYTESIZE_TYPE offset, void * const destination, const MCBSP_BYTESIZE_TYPE size );
444 
489 void bsp_direct_get( const MCBSP_PROCESSOR_INDEX_DATATYPE pid, const void * const source,
490  const MCBSP_BYTESIZE_TYPE offset, void * const destination, const MCBSP_BYTESIZE_TYPE size );
491 
517 void bsp_set_tagsize( MCBSP_BYTESIZE_TYPE * const size );
518 
535 void bsp_send( const MCBSP_PROCESSOR_INDEX_DATATYPE pid, const void * const tag,
536  const void * const payload, const MCBSP_BYTESIZE_TYPE size );
537 
538 #ifdef MCBSP_ENABLE_HP_DIRECTIVES
539 
587 void bsp_hpsend( const MCBSP_PROCESSOR_INDEX_DATATYPE pid, const void * const tag,
588  const void * const payload, const MCBSP_BYTESIZE_TYPE size );
589 #endif
590 
598 void bsp_qsize( MCBSP_NUMMSG_TYPE * const packets,
599  MCBSP_BYTESIZE_TYPE * const accumulated_size );
600 
622 void bsp_get_tag( MCBSP_BYTESIZE_TYPE * const status,
623  void * const tag );
624 
654 void bsp_move( void * const payload, const MCBSP_BYTESIZE_TYPE max_copy_size );
655 
689 MCBSP_BYTESIZE_TYPE bsp_hpmove( void* * const p_tag, void* * const p_payload );
690 
691 #ifdef ENABLE_FAKE_HP_DIRECTIVES
692 
743 void bsp_hpput( const MCBSP_PROCESSOR_INDEX_DATATYPE pid, const void * const source,
744  void * const destination, const MCBSP_BYTESIZE_TYPE offset, const MCBSP_BYTESIZE_TYPE size );
745 
804 void bsp_hpget( const MCBSP_PROCESSOR_INDEX_DATATYPE pid, const void * const source,
805  const MCBSP_BYTESIZE_TYPE offset, void * const destination, const MCBSP_BYTESIZE_TYPE size );
806 #endif
807 
808 #endif
809