Scippy

UG

Ubiquity Generator framework

scipParaInterruptMsgMonitor.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 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 scipParaInterruptMsgMonitor.cpp
27  * @brief Interrupt message monitor thread class.
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 "cassert"
37 #if defined(_MSC_VER)
38 #include "windows.h"
39 #else
40 #include "unistd.h"
41 #endif
42 #include "scipParaComm.h"
43 #include "scipParaSolver.h"
45 
46 using namespace ParaSCIP;
47 
50  ScipParaSolver *inScipParaSolver
51  ) : terminateRequested(false), paraComm(comm), scipParaSolver(inScipParaSolver)
52 {
53  rank = paraComm->getRank();
54  // std::cout << typeid(*paraComm).name() << std::endl;
55 }
56 
57 void
59 {
61  // DEF_SCIP_PARA_COMM( scipParaComm, paraComm);
62  for(;;)
63  {
64 #ifdef _MSC_VER
65  _sleep(static_cast<unsigned int>(1));
66 #else
67  sleep(static_cast<unsigned int>(1));
68 #endif
69  if( terminateRequested ) return; // the flag update can be delayed
70  DEF_SCIP_PARA_COMM( scipParaComm, paraComm); // should be writen in here. I do not know the reason
71  // std::cout << typeid(*paraComm).name() << std::endl;
72  // std::cout << typeid(*scipParaComm).name() << std::endl;
73  if( !scipParaSolver->getScip() ) return; // solver is in destructor
74  if( !scipParaComm ) return;
75  scipParaComm->lockInterruptMsg();
76  int source;
77  int tag = UG::TagInterruptRequest;
78  if( !scipParaSolver->getScip() ) // check gain. solver is in destructor
79  {
80  scipParaComm->unlockInterruptMsg();
81  return;
82  }
83  /************************************
84  * check if there are some messages *
85  ************************************/
86  if ( scipParaComm->iProbe(&source, &tag) )
87  {
88  assert( tag == UG::TagInterruptRequest );
89  assert( !scipParaSolver->isInterrupting() );
90  if( !scipParaSolver->getScip() ) // check gain. solver is in destructor
91  {
92  scipParaComm->unlockInterruptMsg();
93  return;
94  }
96  // scipParaSolver->issueInterruptSolve(); // this is performed above function
97  }
98  scipParaComm->unlockInterruptMsg();
99  if( terminateRequested ) break;
100  }
101 }
static ScipParaCommTh * comm
Definition: fscip.cpp:73
int processTagInterruptRequest(int source, int tag)
Interrupt message monitor thread class.
virtual void setLocalRank(int inRank)
Definition: paraComm.h:166
virtual int getRank()=0
get rank of this process or this thread depending on run-time environment
ParaSolver extension for SCIP: Parallelized solver implementation for SCIP.
ParaComm extension for SCIP solver.
ScipParaSolver * scipParaSolver
pointer to ScipParaSolver object
static const int TagInterruptRequest
Definition: paraTagDef.h:57
UG::ParaComm * paraComm
ParaCommunicator object.
Base class of communicator object.
Definition: paraComm.h:101
#define DEF_SCIP_PARA_COMM(scip_para_comm, comm)