Hitmap 1.3
 All Data Structures Namespaces Files Functions Variables Typedefs Friends Macros Groups Pages
matrix_sig_vs_bit.c
Go to the documentation of this file.
1 
8 /*
9  * <license>
10  *
11  * Hitmap v1.2
12  *
13  * This software is provided to enhance knowledge and encourage progress in the scientific
14  * community. It should be used only for research and educational purposes. Any reproduction
15  * or use for commercial purpose, public redistribution, in source or binary forms, with or
16  * without modifications, is NOT ALLOWED without the previous authorization of the copyright
17  * holder. The origin of this software must not be misrepresented; you must not claim that you
18  * wrote the original software. If you use this software for any purpose (e.g. publication),
19  * a reference to the software package and the authors must be included.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND ANY
22  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
24  * THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * Copyright (c) 2007-2015, Trasgo Group, Universidad de Valladolid.
32  * All rights reserved.
33  *
34  * More information on http://trasgo.infor.uva.es/
35  *
36  * </license>
37 */
38 
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <hitmap.h>
42 #include <hit_com.h>
43 #include <unistd.h>
44 #include <time.h>
45 #include <string.h>
46 
47 
48 // Define the Tile_int
49 hit_tileNewType(int);
50 
51 // Layout
53 
54 
55 #define printfR(...) { if( hit_Rank == 0 ) { printf(__VA_ARGS__); fflush(stdout); }}
56 
57 
58 
59 int main(int argc, char ** vargs){
60 
61  int nodes;
62 
63  if(argc != 2){
64  printf("Usage: %s NUMBER_OF_NODES\n",vargs[0]);
65  exit(0);
66  }
67  sscanf(vargs[1],"%d",&nodes);
68 
69  hit_comInit(&argc,&vargs);
70 
71  printfR("nodes: %d\n",nodes);
72 
73  printfR("Sig Shape\tSig Tile\tSTile NStride\tBitmap Shape\tGBTile iterator\tGBTile direct\n");
74 
75  int i,j;
76  HitClock t;
77 
78  // A.1 Create Sig Shape
79  hit_clockStart(t);
80  HitSig sig = hit_sig(0,nodes-1,1);
81  HitShape shape = hit_shape(2,sig,sig);
82  hit_clockStop(t);
83  printfR("%f\t",hit_clockGetSeconds(t));
84 
85  // A.2 Allocate and set zeros
86  HitTile_int tile;
87  hit_tileDomainShapeAlloc(&tile,int,shape);
88 
89  hit_clockStart(t);
90  for(i=0;i<nodes;i++)
91  for(j=0;j<nodes;j++){
92  hit_tileElemAt(tile,2,i,j) = 0;
93  }
94  hit_clockStop(t);
95  printfR("%f\t",hit_clockGetSeconds(t));
96 
97  // A.3 set zeros no stride
98  hit_clockStart(t);
99  for(i=0;i<nodes;i++)
100  for(j=0;j<nodes;j++){
101  hit_tileElemAtNoStride(tile,2,i,j) = 0;
102  }
103  hit_clockStop(t);
104  printfR("%f\t",hit_clockGetSeconds(t));
105 
106  // A.3 Free
107  hit_tileFree(tile);
108 
109 
110 
111  // B.1 Create Bit shape
112  hit_clockStart(t);
113  HitShape bshape = hit_bitmapShape(nodes);
114  for(i=0;i<nodes;i++)
115  for(j=0;j<nodes;j++){
116  //hit_bShapeAddEdge(&bshape,i,j);
117  hit_bShapeSet(bshape,i,j);
118  }
119  hit_clockStop(t);
120  printfR("%f\t",hit_clockGetSeconds(t));
121 
122  // B.2 Allocate and set zeros
123  HitTile_int btile;
124  hit_gbTileDomainShapeAlloc(&btile, int, bshape, HIT_EDGES);
125 
126  hit_clockStart(t);
127  int vertex, edge;
128  hit_bShapeVertexIterator(vertex,bshape){
129  hit_bShapeEdgeIterator(edge,bshape,vertex){
130 
131  hit_gbTileEdgeIteratorAt(btile,vertex,edge) = 0;
132 
133  }
134  }
135  hit_clockStop(t);
136  printfR("%f\t",hit_clockGetSeconds(t));
137 
138 
139  // B.3 set zeros without iterator
140  hit_clockStart(t);
141  for(i=0;i<nodes;i++)
142  for(j=0;j<nodes;j++){
143  hit_gbTileEdgeAt(btile,i,j) = 0;
144  }
145  hit_clockStop(t);
146  printfR("%f\t",hit_clockGetSeconds(t));
147 
148 
149  // B.4 Free
150  hit_tileFree(btile);
151 
152  printfR("\n");
153 
154  hit_comFinalize();
155 
156  return 0;
157 }
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
#define hit_bShapeSet(bitshape, i, j)
#define hit_shape(nd,...)
Definition: hit_sshape.h:175
#define hit_tileNewType(baseType)
Definition: hit_tile.h:163
#define hit_tileElemAt(var, ndims,...)
Definition: hit_tile.h:519
#define hit_bShapeEdgeIterator(var, shape, vertex)
Definition: hit_bshape.h:494
#define HIT_LAYOUT_NULL_STATIC
Definition: hit_layout.h:300
HitShape hit_bitmapShape(int nvertices)
Definition: hit_bshape.c:46
Definition: hit_sig.h:79
#define HIT_EDGES
Definition: hit_tile.h:214
#define hit_bShapeVertexIterator(var, shape)
Definition: hit_bshape.h:455
#define hit_tileDomainShapeAlloc(newVarP, baseType, shape)
Definition: hit_tile.h:354
#define printfR(...)
void hit_comInit(int *pargc, char **pargv[])
Definition: hit_com.c:111
HitShape shape
#define hit_gbTileEdgeAt(var, pos1, pos2)
Definition: hit_gbtile.h:164
#define hit_tileElemAtNoStride(var, ndims,...)
Definition: hit_tile.h:558
#define hit_clockStop(c)
Definition: hit_utils.h:109
int main(int argc, char *argv[])
Definition: cannonAsync.c:62
HitLayout lay
Definition: heat.c:107
#define hit_tileFree(var)
Definition: hit_tile.h:369
void hit_comFinalize()
Definition: hit_com.c:159
#define hit_clockGetSeconds(c)
Definition: hit_utils.h:190
#define hit_gbTileDomainShapeAlloc(var, baseType, shape, allocOpts)
Definition: hit_gbtile.h:99
#define hit_gbTileEdgeIteratorAt(var, vertex, edge_index)
#define hit_clockStart(c)
Definition: hit_utils.h:87