Hitmap 1.3
 All Data Structures Namespaces Files Functions Variables Typedefs Friends Macros Groups Pages
hit_save.c
Go to the documentation of this file.
1 
7 /*
8  * <license>
9  *
10  * Hitmap v1.2
11  *
12  * This software is provided to enhance knowledge and encourage progress in the scientific
13  * community. It should be used only for research and educational purposes. Any reproduction
14  * or use for commercial purpose, public redistribution, in source or binary forms, with or
15  * without modifications, is NOT ALLOWED without the previous authorization of the copyright
16  * holder. The origin of this software must not be misrepresented; you must not claim that you
17  * wrote the original software. If you use this software for any purpose (e.g. publication),
18  * a reference to the software package and the authors must be included.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND ANY
21  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23  * THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * Copyright (c) 2007-2015, Trasgo Group, Universidad de Valladolid.
31  * All rights reserved.
32  *
33  * More information on http://trasgo.infor.uva.es/
34  *
35  * </license>
36 */
37 
38 #include <hit_save.h>
39 #include <hit_com.h>
40 #include <hit_topology.h>
41 
42 #ifdef notcompilethisfile
43 
44 /* Hit TOPOLOGY: COMMIT */
45 void hit_topCommitInternal(HitTopology *topo, MPI_Comm oldComm) {
46  MPI_Comm *newCom = (MPI_Comm *)malloc( sizeof( MPI_Comm ) );
47 
48  int ok = MPI_Comm_split( oldComm, topo->active, topo->linearRank, newCom );
49  hit_mpiTestError(ok,"Failed split communicator for topology commit");
50 
51  topo->pTopology.lowLevel = (void *)newCom;
52 }
53 
54 /* Hit TOPOLOGY: FREE */
55 void hit_topFreeInternal(HitTopology *topo, MPI_Comm *oldComm) {
56  int ok = MPI_Comm_free( (MPI_Comm *)topo->pTopology.lowLevel );
57  hit_mpiTestError(ok,"Failed to free communicator for topology");
58 
59  topo->pTopology.lowLevel = (void *)MPI_COMM_NULL;
60 }
61 
62 
63 
64 /* HitCom: CREATE STRUCT MPI TYPE */
65 void hit_comTypeStructInternal(HitType * newType, int count, ...){
66 
67  int * lengths;
68  HitType * types;
69 
70  // @arturo Ago 2015: New allocP interface
71  /*
72  hit_malloc(lengths,sizeof(int) * (size_t) count);
73  hit_malloc(types,sizeof(HitType) * (size_t) count);
74  */
75  hit_malloc(lengths, int, count);
76  hit_malloc(types, HitType, count);
77 
78 
79  va_list ap;
80  va_start(ap, count);
81 
82  int i;
83  for(i=0;i<count;i++){
84 
85  lengths[i] = va_arg(ap,int);
86  types[i] = va_arg(ap,HitType);
87  }
88  va_end(ap);
89 
90 
91  HitAint * displacements;
92  // @arturo Ago 2015: New allocP interface
93  // hit_malloc(displacements,sizeof(HitAint) * (size_t) count);
94  hit_malloc(displacements, HitAint, count);
95 
96  displacements[0] = (HitAint) 0;
97 
98  for(i=1; i<count; i++){
99  int size;
100  MPI_Type_size(types[i-1],&size);
101  displacements[i] = displacements[i-1] + (HitAint) lengths[i-1] * size ;
102  }
103 
104  MPI_Type_create_struct(count, lengths, displacements, types, newType);
105  MPI_Type_commit(newType);
106 
107  hit_free(displacements);
108  hit_free(lengths);
109  hit_free(types);
110 
111 }
112 
113 #endif
#define hit_free(ptr)
Definition: hit_allocP.h:152
HitPTopology * pTopology
Definition: hit_topology.h:253
MPI_Datatype * types
Definition: refMPIluBack.c:109
#define hit_mpiTestError(ok, cad)
Definition: hit_com.h:62
int size[2]
Definition: SWcommon.c:57
MPI_Datatype HitType
Definition: hit_com.h:70
MPI_Aint HitAint
Definition: hit_com.h:82
#define hit_malloc(ptr, type, nmemb)
Definition: hit_allocP.h:93