Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
LSGRM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cresson Remi
LSGRM
Commits
e26071bd
Commit
e26071bd
authored
Aug 25, 2016
by
remicres
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ADD: add MPI routines. TODO: move them in appropriate class
parent
ea904bc0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
17 deletions
+13
-17
include/lsgrmHeader.h
include/lsgrmHeader.h
+13
-17
No files found.
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 (
myrank
== 0)
if
(
otb
::
MPIConfig
::
Instance
()
->
GetMyRank
()
==
0
)
{
// Master process
// Gather
for (unsigned int p = 1 ; p <
nprocs
; p++)
for
(
unsigned
int
p
=
1
;
p
<
otb
::
MPIConfig
::
Instance
()
->
GetNbProcs
()
;
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 <
nprocs
; p++)
MPI_Send(&x, 1, dataType, p,
TAG_PIECE
, MPI_COMM_WORLD);
for
(
unsigned
int
p
=
1
;
p
<
otb
::
MPIConfig
::
Instance
()
->
GetNbProcs
()
;
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