MulticoreBSP for C  Version 1.1
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();
199 
215 void bsp_init( void (*spmd)(void), int argc, char **argv );
216 
228 void bsp_abort( char *error_message, ... );
229 
242 void bsp_vabort( char *error_message, va_list args );
243 
264 
281 
292 double bsp_time();
293 
315 void bsp_sync();
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 
443 void bsp_get( const MCBSP_PROCESSOR_INDEX_DATATYPE pid, const void * const source,
444  const MCBSP_BYTESIZE_TYPE offset, void * const destination, const MCBSP_BYTESIZE_TYPE size );
445 
490 void bsp_direct_get( const MCBSP_PROCESSOR_INDEX_DATATYPE pid, const void * const source,
491  const MCBSP_BYTESIZE_TYPE offset, void * const destination, const MCBSP_BYTESIZE_TYPE size );
492 
510 void bsp_set_tagsize( MCBSP_BYTESIZE_TYPE * const size );
511 
528 void bsp_send( const MCBSP_PROCESSOR_INDEX_DATATYPE pid, const void * const tag,
529  const void * const payload, const MCBSP_BYTESIZE_TYPE size );
530 
531 #ifdef MCBSP_ENABLE_HP_DIRECTIVES
532 
580 void bsp_hpsend( const MCBSP_PROCESSOR_INDEX_DATATYPE pid, const void * const tag,
581  const void * const payload, const MCBSP_BYTESIZE_TYPE size );
582 #endif
583 
591 void bsp_qsize( MCBSP_NUMMSG_TYPE * const packets,
592  MCBSP_BYTESIZE_TYPE * const accumulated_size );
593 
615 void bsp_get_tag( MCBSP_BYTESIZE_TYPE * const status,
616  void * const tag );
617 
647 void bsp_move( void * const payload, const MCBSP_BYTESIZE_TYPE max_copy_size );
648 
682 MCBSP_BYTESIZE_TYPE bsp_hpmove( void* * const p_tag, void* * const p_payload );
683 
684 #ifdef ENABLE_FAKE_HP_DIRECTIVES
685 
736 void bsp_hpput( const MCBSP_PROCESSOR_INDEX_DATATYPE pid, const void * const source,
737  void * const destination, const MCBSP_BYTESIZE_TYPE offset, const MCBSP_BYTESIZE_TYPE size );
738 
797 void bsp_hpget( const MCBSP_PROCESSOR_INDEX_DATATYPE pid, const void * const source,
798  const MCBSP_BYTESIZE_TYPE offset, void * const destination, const MCBSP_BYTESIZE_TYPE size );
799 #endif
800 
801 #endif
802