Hitmap 1.3
 All Data Structures Namespaces Files Functions Variables Typedefs Friends Macros Groups Pages
hit_blockTile.h
Go to the documentation of this file.
1 
14 /*
15  * <license>
16  *
17  * Hitmap v1.2
18  *
19  * This software is provided to enhance knowledge and encourage progress in the scientific
20  * community. It should be used only for research and educational purposes. Any reproduction
21  * or use for commercial purpose, public redistribution, in source or binary forms, with or
22  * without modifications, is NOT ALLOWED without the previous authorization of the copyright
23  * holder. The origin of this software must not be misrepresented; you must not claim that you
24  * wrote the original software. If you use this software for any purpose (e.g. publication),
25  * a reference to the software package and the authors must be included.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND ANY
28  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
29  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
30  * THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
34  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  * Copyright (c) 2007-2015, Trasgo Group, Universidad de Valladolid.
38  * All rights reserved.
39  *
40  * More information on http://trasgo.infor.uva.es/
41  *
42  * </license>
43 */
44 
45 #ifndef _HitBlockTile_
46 #define _HitBlockTile_
47 
48 #include "hit_sshape.h"
49 #include "hit_tile.h"
50 #include "hit_dump.h"
51 
77 typedef HitTile_HitTile HitBlockTile;
78 
94 void hit_blockTileNew( HitBlockTile *container, void *originalVar, int blockSizes[ HIT_MAXDIMS ] );
95 
109 #define hit_blockTileAlloc( varP, baseType ) hit_blockTileAllocInternal( varP, sizeof(baseType), NULL )
110 
127 #define hit_blockTileAllocFill( varP, baseType, fillValue ) hit_blockTileAllocInternal( varP, sizeof(baseType), fillValue )
128 
129 // @cond INTERNAL
133 void hit_blockTileAllocInternal( HitBlockTile *container, size_t baseSizeExtent, void *fillValue );
134 // @endcond
135 
146 void hit_blockTileFree( HitBlockTile container );
147 
160 #define hit_blockTileSelect( ... ) hit_tileSelect( __VA_ARGS__ );
161 
175 #define hit_blockTileSelectNoBoundary( ... ) hit_tileSelectNoBoundary( __VA_ARGS__ );
176 
192 #define hit_blockTileSelectArrayCoords( ... ) hit_tileSelectArrayCoords( __VA_ARGS__ );
193 
211 #define hit_blockTileSelectArrayCoordsNoBoundary( ... ) hit_tileSelectArrayCoordsNoBoundary( __VA_ARGS__ );
212 
213 // @cond INTERNAL
232 #define hit_blockTileUnpadElem( elem, baseType ) (((elem).unpadded != NULL) ? *(HitTile_##baseType *)((elem).unpadded) : *(HitTile_##baseType *)&(elem))
233 // @endcond
234 
258 #define hit_blockTileElemAt( tile, baseType, ndims, ... ) hit_blockTileUnpadElem( hit_tileElemAt(tile, ndims, __VA_ARGS__ ), baseType )
259 
285 #define hit_blockTileElemAtNS( tile, baseType, ndims, ... ) hit_blockTileUnpadElem( hit_tileElemAtNoStride(tile, ndims, __VA_ARGS__ ), baseType )
286 
305 #define hit_blockTileElemAtArrayCoords( tile, baseType, ndims, ... ) hit_blockTileUnpadElem( hit_tileElemAtArrayCoords(tile, ndims, __VA_ARGS__ ), baseType )
306 
327 #define hit_blockTileBufferAt( tile, baseType, ndims, ... ) ( *(HitTile_##baseType *) & hit_tileElemAt(tile, ndims, __VA_ARGS__ ) )
328 
347 #define hit_blockTileBufferAtNS( tile, baseType, ndims, ... ) ( *(HitTile_##baseType *) & hit_tileElemAtNoStride(tile, ndims, __VA_ARGS__ ) )
348 
368 #define hit_blockTileBufferAtArrayCoords( tile, baseType, ndims, ... ) ( *(HitTile_##baseType *) & hit_tileElemAtArrayCoords(tile, ndims, __VA_ARGS__ ) )
369 
370 /* UTILITIES */
371 
387 #define hit_blockTileDimBlockSize( tile, dim ) ( tile.childSize[ dim ] )
388 
400 static inline HitBlockTile * hit_blockTileRoot( HitBlockTile * tile ) {
401  while ( tile->ref != NULL && tile->ref->hierDepth > 0 ) tile = tile->ref;
402  return tile;
403 }
404 
405 // @cond INTERNAL
409 static inline void hit_blockTileDumpTiles( HitBlockTile container, const char *fileName ) {
410  hit_dumpTileFile( container, fileName, "--- Level 1 ---" );
411 
412  int k,l;
413  hit_tileForDimDomain( container, 0, k ) {
414  hit_tileForDimDomain( container, 1, l ) {
415  HitTile third;
416  third = hit_tileElemAt( container, 2, k, l );
417  hit_dumpTileFile( third, fileName, "--- Level 2 ---" );
418  if ( third.unpadded != NULL ) {
419  hit_dumpTileFile( *(third.unpadded), fileName, "--- Unpadded selection: " );
420  }
421  }
422  }
423 }
424 // @endcond
425 
426 
427 /* END OF HEADER FILE _HitBlockTile_ */
428 #endif
void hit_blockTileAllocInternal(HitBlockTile *container, size_t baseSizeExtent, void *fillValue)
Definition: hit_blockTile.c:75
#define hit_tileElemAt(var, ndims,...)
Definition: hit_tile.h:519
#define hit_dumpTileFile(var, prefix, comment)
Definition: hit_dump.h:63
#define HIT_MAXDIMS
Definition: hit_shape.h:72
HitTile_HitTile HitBlockTile
Definition: hit_blockTile.h:77
void hit_blockTileFree(HitBlockTile container)
#define hit_tileForDimDomain(tile, dim, index)
Definition: hit_tile.h:587
void hit_blockTileNew(HitBlockTile *container, void *originalVar, int blockSizes[HIT_MAXDIMS])
Definition: hit_blockTile.c:47