Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Cresson Remi
LSGRM
Commits
e26071bd
Commit
e26071bd
authored
Aug 25, 2016
by
remicres
Browse files
ADD: add MPI routines. TODO: move them in appropriate class
parent
ea904bc0
Changes
1
Hide whitespace changes
Inline
Side-by-side
include/lsgrmHeader.h
View file @
e26071bd
...
...
@@ -15,6 +15,7 @@
#ifdef OTB_USE_MPI
#include "otbMPIConfig.h"
#include "mpi.h" // TODO: implement needed methods inside otbMPIConfig.h
#endif
/*
...
...
@@ -25,7 +26,7 @@ bool MyTurn(int div = 0)
{
#ifdef OTB_USE_MPI
otb
::
MPIConfig
::
Pointer
mpiConfig
=
otb
::
MPIConfig
::
Instance
();
int
proc
=
0
;
unsigned
int
proc
=
0
;
if
(
mpiConfig
->
GetNbProcs
()
!=
0
)
proc
=
div
%
mpiConfig
->
GetNbProcs
();
return
(
proc
==
mpiConfig
->
GetMyRank
());
...
...
@@ -37,33 +38,32 @@ bool MyTurn(int div = 0)
* This function gather the given value in other process, and update it
* TODO: MPI implementation using OTB MPI Wrapper
*/
/*
template
<
typename
T
>
void
GatherMe
(
T
&
x
,
MPI_Datatype
dataType
)
{
if (
myr
ank == 0)
if
(
otb
::
MPIConfig
::
Instance
()
->
GetMyR
ank
()
==
0
)
{
// Master process
// Gather
for (unsigned int p = 1 ; p <
np
rocs ; p++)
for
(
unsigned
int
p
=
1
;
p
<
otb
::
MPIConfig
::
Instance
()
->
GetNbP
rocs
()
;
p
++
)
{
T
partial_sum
;
MPI_Recv( &partial_sum, 1, dataType, p,
TAG_PIECE
, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
MPI_Recv
(
&
partial_sum
,
1
,
dataType
,
p
,
MPI_ANY_TAG
,
MPI_COMM_WORLD
,
MPI_STATUS_IGNORE
);
x
+=
partial_sum
;
}
// Dispatch
for (unsigned int p = 1 ; p <
np
rocs ; p++)
MPI_Send(&x, 1, dataType, p,
TAG_PIECE
, MPI_COMM_WORLD);
for
(
unsigned
int
p
=
1
;
p
<
otb
::
MPIConfig
::
Instance
()
->
GetNbP
rocs
()
;
p
++
)
MPI_Send
(
&
x
,
1
,
dataType
,
p
,
MPI_ANY_TAG
,
MPI_COMM_WORLD
);
}
else
{
// Slave process
MPI_Send(&x, 1, dataType, 0,
TAG_PIECE
, MPI_COMM_WORLD);
MPI_Recv(&x, 1, dataType, 0,
TAG_PIECE
, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
MPI_Send
(
&
x
,
1
,
dataType
,
0
,
MPI_ANY_TAG
,
MPI_COMM_WORLD
);
MPI_Recv
(
&
x
,
1
,
dataType
,
0
,
MPI_ANY_TAG
,
MPI_COMM_WORLD
,
MPI_STATUS_IGNORE
);
}
}
*/
/*
* Gather accumulatedMemory and isFusion variables
...
...
@@ -71,20 +71,16 @@ void GatherMe(T& x, MPI_Datatype dataType)
*/
void
GatherUsefulVariables
(
unsigned
long
long
int
&
accumulatedMemory
,
bool
&
isFusion
)
{
/*
MPI_Barrier(MPI_COMM_WORLD);
otb
::
MPIConfig
::
Instance
()
->
barrier
();
int
isFusionInteger
=
0
;
long
long
int
accumulatedMemoryLLI
=
static_cast
<
long
long
int
>
(
accumulatedMemory
);
if
(
isFusion
)
isFusionInteger
=
1
;
GatherMe<int>(isFusionInteger, MPI_INT
, myrank, nprocs
);
GatherMe<long long int>(accumulatedMemoryLLI, MPI_LONG_LONG_INT
, myrank, nprocs
);
GatherMe
<
int
>
(
isFusionInteger
,
MPI_INT
);
GatherMe
<
long
long
int
>
(
accumulatedMemoryLLI
,
MPI_LONG_LONG_INT
);
accumulatedMemory
=
static_cast
<
long
long
unsigned
int
>
(
accumulatedMemoryLLI
);
if
(
isFusionInteger
>
0
)
isFusion
=
true
;
if (myrank == 0)
std::cout << "Accumulated memory " << accumulatedMemory << " bytes, there is fusion "<< isFusion << std::endl;
*/
}
/*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment