48 return(
new ScipParaSolutionMpi(objectiveFunctionValue, nVars, indicesAmongSolvers, values));
53 ScipParaSolutionMpi::createPreDatatype(
56 const int nBlocks = 2;
57 MPI_Datatype preDatatype;
59 MPI_Aint startAddress = 0;
62 int blockLengths[nBlocks];
63 MPI_Aint displacements[nBlocks];
64 MPI_Datatype types[nBlocks];
66 for(
int i = 0; i < nBlocks; i++ ){
71 MPI_Get_address( &objectiveFunctionValue, &startAddress )
74 types[0] = MPI_DOUBLE;
77 MPI_Get_address( &nVars, &address )
79 displacements[1] = address - startAddress;
83 MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &preDatatype)
91 ScipParaSolutionMpi::createDatatype(
92 bool memAllocNecessary
95 const int nBlocks = 2;
97 MPI_Datatype datatype = MPI_DATATYPE_NULL;
99 MPI_Aint startAddress = 0;
100 MPI_Aint address = 0;
102 int blockLengths[nBlocks];
103 MPI_Aint displacements[nBlocks];
104 MPI_Datatype types[nBlocks];
108 if( memAllocNecessary )
110 indicesAmongSolvers =
new int[nVars];
111 values =
new SCIP_Real[nVars];
115 MPI_Get_address( indicesAmongSolvers, &startAddress )
117 displacements[0] = 0;
118 blockLengths[0] = nVars;
122 MPI_Get_address( values, &address )
124 displacements[1] = address - startAddress;
125 blockLengths[1] = nVars;
126 types[1] = MPI_DOUBLE;
129 MPI_Type_create_struct(nBlocks, blockLengths, displacements, types, &datatype)
140 MPI_Datatype preDatatype;
141 preDatatype = createPreDatatype();
143 MPI_Type_commit( &preDatatype )
146 commMpi->ubcast(&objectiveFunctionValue, 1, preDatatype, root)
149 MPI_Type_free( &preDatatype )
153 MPI_Datatype datatype;
156 datatype = createDatatype(
false);
160 datatype = createDatatype(
true);
163 MPI_Type_commit( &datatype )
166 commMpi->ubcast(indicesAmongSolvers, 1, datatype, root)
169 MPI_Type_free( &datatype )
180 MPI_Datatype preDatatype;
181 preDatatype = createPreDatatype();
183 MPI_Type_commit( &preDatatype )
186 commMpi->usend(&objectiveFunctionValue, 1, preDatatype, destination,
TagSolution)
189 MPI_Type_free( &preDatatype )
193 MPI_Datatype datatype;
194 datatype = createDatatype(
false);
196 MPI_Type_commit( &datatype )
199 commMpi->usend(indicesAmongSolvers, 1, datatype, destination, TagSolution1)
202 MPI_Type_free( &datatype )
212 MPI_Datatype preDatatype;
213 preDatatype = createPreDatatype();
215 MPI_Type_commit( &preDatatype )
218 commMpi->ureceive(&objectiveFunctionValue, 1, preDatatype, source,
TagSolution)
221 MPI_Type_free( &preDatatype )
225 MPI_Datatype datatype;
226 datatype = createDatatype(
true);
228 MPI_Type_commit( &datatype )
231 MPI_Type_commit( &datatype )
234 commMpi->ureceive(indicesAmongSolvers, 1, datatype, source, TagSolution1)
237 MPI_Type_free( &datatype )
static ScipParaCommTh * comm
SCIP ParaComm extension for MPI communication.
ScipParaSolution extension for MPI communication.
#define PARA_COMM_CALL(paracommcall)
virtual int getRank()=0
get rank of this process or this thread depending on run-time environment
static const int TagSolution
#define DEF_PARA_COMM(para_comm, comm)
#define MPI_CALL(mpicall)
Base class of communicator object.