Scippy

UG

Ubiquity Generator framework

bbParaNodeTh.cpp
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and software framework */
4/* UG --- Ubquity Generator Framework */
5/* */
6/* Copyright Written by Yuji Shinano <shinano@zib.de>, */
7/* Copyright (C) 2021-2024 by Zuse Institute Berlin, */
8/* licensed under LGPL version 3 or later. */
9/* Commercial licenses are available through <licenses@zib.de> */
10/* */
11/* This code is free software; you can redistribute it and/or */
12/* modify it under the terms of the GNU Lesser General Public License */
13/* as published by the Free Software Foundation; either version 3 */
14/* of the License, or (at your option) any later version. */
15/* */
16/* This program is distributed in the hope that it will be useful, */
17/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
18/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
19/* GNU Lesser General Public License for more details. */
20/* */
21/* You should have received a copy of the GNU Lesser General Public License */
22/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
23/* */
24/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
25
26/**@file bbParaNodeTh.cpp
27 * @brief BbParaNode extension for threads communication.
28 * @author Yuji Shinano
29 *
30 *
31 *
32 */
33
34/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35
36#include "bbParaComm.h"
37#include "bbParaNodeTh.h"
38
39using namespace UG;
40
42BbParaNodeTh::createDatatype(
44 )
45{
46 return clone(comm);
47}
48
49int
52 int root
53 )
54{
55 DEF_PARA_COMM( commTh, comm);
56
57 if( commTh->getRank() == root )
58 {
59 for( int i = 0; i < commTh->getSize(); i++ )
60 {
61 if( i != root )
62 {
63 BbParaNodeTh *sent;
64 sent = createDatatype(comm);
65 assert(!(sent->mergeNodeInfo));
66 sent->mergeNodeInfo = 0;
68 commTh->uTypeSend((void *)sent, ParaTaskType, i, TagTask)
69 );
70 }
71 }
72 }
73 else
74 {
75 BbParaNodeTh *received;
77 commTh->uTypeReceive((void **)&received, ParaTaskType, root, TagTask)
78 );
79 taskId = received->taskId;
81 depth = received->depth;
87 {
88 diffSubproblem = received->diffSubproblem->clone(commTh);
89 }
90 basisInfo = received->basisInfo;
91 mergingStatus = received->mergingStatus;
92 delete received;
93 }
94 return 0;
95}
96
97int
100 int destination
101 )
102{
103 DEF_PARA_COMM( commTh, comm);
104
105 BbParaNodeTh *sent;
106 sent = createDatatype(comm);
107 assert(!(sent->mergeNodeInfo));
108 sent->mergeNodeInfo = 0;
110 commTh->uTypeSend((void *)sent, ParaTaskType, destination, TagTask)
111 );
112
113 return 0;
114}
115
116int
118 ParaComm *comm,
119 int destination
120 )
121{
122
123 assert( !this->isRootTask() );
124 DEF_PARA_COMM( commTh, comm);
125
126 BbParaNodeTh *sent;
127 sent = createDatatype(comm);
128 assert(!(sent->mergeNodeInfo));
129 sent->mergeNodeInfo = 0;
131 commTh->uTypeSend((void *)sent, ParaTaskType, destination, TagNewSubtreeRootNode)
132 );
133
134 return 0;
135}
136
137int
139 ParaComm *comm,
140 int destination, ///< destination rank
141 int tag
142 )
143{
144 DEF_PARA_COMM( commTh, comm);
145
146 BbParaNodeTh *sent;
147 sent = createDatatype(comm);
148 assert(!(sent->mergeNodeInfo));
149 sent->mergeNodeInfo = 0;
151 commTh->uTypeSend((void *)sent, ParaTaskType, destination, tag)
152 );
153
154 return 0;
155}
156
157//int
158//BbParaNodeTh::sendReassignSelfSplitSubtreeRoot(
159// ParaComm *comm,
160// int destination ///< destination rank
161// )
162//{
163// DEF_PARA_COMM( commTh, comm);
164//
165// BbParaNodeTh *sent;
166// sent = createDatatype(comm);
167// assert(!(sent->mergeNodeInfo));
168// sent->mergeNodeInfo = 0;
169// PARA_COMM_CALL(
170// commTh->uTypeSend((void *)sent, ParaTaskType, destination, TagReassignSelfSplitSubtreeRootNode)
171// );
172//
173// return 0;
174//}
175
176
177int
179 ParaComm *comm,
180 int source
181 )
182{
183 DEF_PARA_COMM( commTh, comm);
184
185 BbParaNodeTh *received;
187 commTh->uTypeReceive((void **)&received, ParaTaskType, source, TagTask)
188 );
189 taskId = received->taskId;
191 depth = received->depth;
192 dualBoundValue = received->dualBoundValue;
194 estimatedValue = received->estimatedValue;
197 {
198 diffSubproblem = received->diffSubproblem->clone(commTh);
199 }
200 basisInfo = received->basisInfo;
201 mergingStatus = received->mergingStatus;
202 delete received;
203
204 return 0;
205}
206
207int
209 ParaComm *comm,
210 int source
211 )
212{
213 DEF_PARA_COMM( commTh, comm);
214
215 BbParaNodeTh *received;
217 commTh->uTypeReceive((void **)&received, ParaTaskType, source, TagNewSubtreeRootNode)
218 );
219 taskId = received->taskId;
221 depth = received->depth;
222 dualBoundValue = received->dualBoundValue;
224 estimatedValue = received->estimatedValue;
227 {
228 diffSubproblem = received->diffSubproblem->clone(commTh);
229 }
230 basisInfo = received->basisInfo;
231 mergingStatus = received->mergingStatus;
232 delete received;
233
234 return 0;
235}
236
237int
239 ParaComm *comm,
240 int source,
241 int tag
242 )
243{
244 DEF_PARA_COMM( commTh, comm);
245
246 BbParaNodeTh *received;
248 commTh->uTypeReceive((void **)&received, ParaTaskType, source, tag)
249 );
250 taskId = received->taskId;
252 delete received;
253
254 return 0;
255}
256
257//int
258//BbParaNodeTh::receiveReassignSelfSplitSubtreeRoot(
259// ParaComm *comm,
260// int source
261// )
262//{
263// DEF_PARA_COMM( commTh, comm);
264//
265// BbParaNodeTh *received;
266// PARA_COMM_CALL(
267// commTh->uTypeReceive((void **)&received, ParaTaskType, source, TagReassignSelfSplitSubtreeRootNode)
268// );
269// taskId = received->taskId;
270// generatorTaskId = received->generatorTaskId;
271// delete received;
272//
273// return 0;
274//}
Base class of communicator for UG Framework.
BbParaNode extension for threads communication.
class BbParaNodeTh
Definition: bbParaNodeTh.h:52
int sendSubtreeRootNodeId(ParaComm *comm, int destination, int tag)
send subtree root to be removed
BbParaNodeTh * createDatatype(ParaComm *comm)
create BbParaNode datatype
int sendNewSubtreeRoot(ParaComm *comm, int destination)
send new subtree root node
BbParaNodeTh * clone(ParaComm *comm)
clone this BbParaNodeTh
Definition: bbParaNodeTh.h:99
int bcast(ParaComm *comm, int root)
broadcast this object
int receive(ParaComm *comm, int source)
receive this object
int receiveNewSubtreeRoot(ParaComm *comm, int source)
receive this object
int send(ParaComm *comm, int destination)
send this object
int receiveSubtreeRootNodeId(ParaComm *comm, int source, int tag)
receive this object node Id
double dualBoundValue
dual bound value
Definition: bbParaNode.h:67
BbParaMergeNodeInfo * mergeNodeInfo
pointer to mergeNodeInfo. Not zero means merging
Definition: bbParaNode.h:78
int mergingStatus
merging status: -1 - no merging node, 0 - checking, 1 - merged (representative) 2 - merged to the oth...
Definition: bbParaNode.h:71
double initialDualBoundValue
dual bound value when this node is created This value is updated to precise one when there is guarant...
Definition: bbParaNode.h:68
int depth
depth from the root node of original tree
Definition: bbParaNode.h:66
int basisInfo
indicate if basis information is including or not
Definition: bbParaNode.h:70
Base class of communicator object.
Definition: paraComm.h:102
virtual ParaDiffSubproblem * clone(ParaComm *comm)=0
create clone of this object
bool isRootTask()
check if root task or not
Definition: paraTask.h:624
int diffSubproblemInfo
1: with diffSubproblem, 0: no diffSubproblem
Definition: paraTask.h:557
ParaDiffSubproblem * diffSubproblem
difference between solving instance data and subproblem data
Definition: paraTask.h:558
TaskId taskId
solving task information
Definition: paraTask.h:549
double estimatedValue
estimate value
Definition: paraTask.h:556
TaskId generatorTaskId
subtree root task id of generator
Definition: paraTask.h:550
static ScipParaCommTh * comm
Definition: fscip.cpp:73
static const int ParaTaskType
static const int TagTask
Definition: paraTagDef.h:47
static const int TagNewSubtreeRootNode
Definition: bbParaTagDef.h:72
#define DEF_PARA_COMM(para_comm, comm)
#define PARA_COMM_CALL(paracommcall)
Definition: paraComm.h:47