Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Iker Martín Álvarez
Proteo
Commits
6a2cd38f
Commit
6a2cd38f
authored
Oct 07, 2024
by
iker_martin
Browse files
Single Strategy moved to different file
parent
335fdd65
Changes
5
Show whitespace changes
Inline
Side-by-side
Codes/MaM/MAM_Constants.h
View file @
6a2cd38f
...
...
@@ -37,4 +37,8 @@ enum mam_key_values{MAM_SPAWN_METHOD=0, MAM_SPAWN_STRATEGIES, MAM_PHYSICAL_DISTR
#define MAM_DATA_VARIABLE 0
#define MAM_DATA_CONSTANT 1
// Tags for messages in spawn strategies
#define MAM_MPITAG_STRAT_SINGLE 130
#define MAM_MPITAG_STRAT_MULTIPLE 131
#endif
Codes/MaM/spawn_methods/Baseline.c
View file @
6a2cd38f
...
...
@@ -4,14 +4,9 @@
#include "../MAM_Constants.h"
#include "../MAM_DataStructures.h"
#include "Baseline.h"
#include "S
pawn_stat
e.h"
#include "S
trategy_Singl
e.h"
#include "PortService.h"
#define MAM_TAG_STRAT_SINGLE 130
#define MAM_TAG_STRAT_MULTIPLE 131
#define MAM_TAG_STRAT_MULTIPLE_FIRST 131
#define MAM_TAG_STRAT_MULTIPLE_OTHER 132
//--------------PRIVATE DECLARATIONS---------------//
int
baseline_spawn
(
Spawn_set
spawn_set
,
MPI_Comm
comm
,
MPI_Comm
*
child
);
void
baseline_parents
(
Spawn_data
spawn_data
,
Spawn_ports
*
spawn_port
,
MPI_Comm
*
child
);
...
...
@@ -20,8 +15,8 @@ void multiple_strat_parents(Spawn_data spawn_data, MPI_Comm comm, MPI_Comm *inte
void
multiple_strat_parents2
(
Spawn_data
spawn_data
,
Spawn_ports
*
spawn_port
,
MPI_Comm
comm
,
MPI_Comm
*
intercomms
,
MPI_Comm
*
child
);
void
multiple_strat_children
(
MPI_Comm
*
parents
);
void
multiple_strat_children2
(
MPI_Comm
*
parents
,
Spawn_ports
*
spawn_port
);
void
single_strat_parents
(
Spawn_data
spawn_data
,
MPI_Comm
*
child
);
void
single_strat_children
(
MPI_Comm
*
parents
,
Spawn_ports
*
spawn_port
);
//
void single_strat_parents(Spawn_data spawn_data, MPI_Comm *child);
//
void single_strat_children(MPI_Comm *parents, Spawn_ports *spawn_port);
//--------------PUBLIC FUNCTIONS---------------//
...
...
@@ -116,12 +111,12 @@ void multiple_strat_parents(Spawn_data spawn_data, MPI_Comm comm, MPI_Comm *inte
if
(
mall
->
myId
==
mall
->
root
)
{
port_name
=
(
char
*
)
malloc
(
MPI_MAX_PORT_NAME
*
sizeof
(
char
));
tag
=
MAM_TAG_STRAT_MULTIPLE
_FIRST
;
tag
=
MAM_
MPI
TAG_STRAT_MULTIPLE
;
MPI_Send
(
&
spawn_data
.
total_spawns
,
1
,
MPI_INT
,
MAM_ROOT
,
tag
,
intercomms
[
0
]);
MPI_Recv
(
port_name
,
MPI_MAX_PORT_NAME
,
MPI_CHAR
,
MPI_ANY_SOURCE
,
tag
,
intercomms
[
0
],
MPI_STATUS_IGNORE
);
for
(
i
=
1
;
i
<
spawn_data
.
total_spawns
;
i
++
)
{
MPI_Send
(
port_name
,
MPI_MAX_PORT_NAME
,
MPI_CHAR
,
MAM_ROOT
,
tag
+
i
,
intercomms
[
i
]);
MPI_Recv
(
&
aux
,
1
,
MPI_CHAR
,
MPI_ANY_SOURCE
,
MAM_TAG_STRAT_MULTIPLE
_FIRST
,
intercomms
[
0
],
MPI_STATUS_IGNORE
);
MPI_Recv
(
&
aux
,
1
,
MPI_CHAR
,
MPI_ANY_SOURCE
,
MAM_
MPI
TAG_STRAT_MULTIPLE
,
intercomms
[
0
],
MPI_STATUS_IGNORE
);
}
}
else
{
port_name
=
malloc
(
1
);
}
...
...
@@ -144,14 +139,14 @@ void multiple_strat_parents2(Spawn_data spawn_data, Spawn_ports *spawn_port, MPI
buffer
[
1
]
=
spawn_data
.
total_spawns
;
MPI_Bcast
(
buffer
,
2
,
MPI_INT
,
rootBcast
,
intercomms
[
i
]);
if
(
mall
->
myId
==
mall
->
root
)
{
MPI_Recv
(
&
aux
,
1
,
MPI_CHAR
,
MPI_ANY_SOURCE
,
MAM_TAG_STRAT_MULTIPLE
,
intercomms
[
0
],
MPI_STATUS_IGNORE
);
MPI_Recv
(
&
aux
,
1
,
MPI_CHAR
,
MPI_ANY_SOURCE
,
MAM_
MPI
TAG_STRAT_MULTIPLE
,
intercomms
[
0
],
MPI_STATUS_IGNORE
);
}
for
(
i
=
1
;
i
<
spawn_data
.
total_spawns
;
i
++
)
{
buffer
[
0
]
=
i
;
MPI_Bcast
(
buffer
,
2
,
MPI_INT
,
rootBcast
,
intercomms
[
i
]);
if
(
mall
->
myId
==
mall
->
root
)
{
MPI_Recv
(
&
aux
,
1
,
MPI_CHAR
,
MPI_ANY_SOURCE
,
MAM_TAG_STRAT_MULTIPLE
,
intercomms
[
0
],
MPI_STATUS_IGNORE
);
MPI_Recv
(
&
aux
,
1
,
MPI_CHAR
,
MPI_ANY_SOURCE
,
MAM_
MPI
TAG_STRAT_MULTIPLE
,
intercomms
[
0
],
MPI_STATUS_IGNORE
);
}
}
...
...
@@ -181,7 +176,7 @@ void multiple_strat_children(MPI_Comm *parents) {
if
(
mall
->
myId
==
mall
->
root
)
{
port_name
=
(
char
*
)
malloc
(
MPI_MAX_PORT_NAME
*
sizeof
(
char
));
MPI_Probe
(
MPI_ANY_SOURCE
,
MPI_ANY_TAG
,
parents_comm
,
&
stat
);
if
(
stat
.
MPI_TAG
==
MAM_TAG_STRAT_MULTIPLE
_FIRST
)
{
if
(
stat
.
MPI_TAG
==
MAM_
MPI
TAG_STRAT_MULTIPLE
)
{
MPI_Recv
(
&
total_spawns
,
1
,
MPI_INT
,
stat
.
MPI_SOURCE
,
stat
.
MPI_TAG
,
parents_comm
,
MPI_STATUS_IGNORE
);
MPI_Open_port
(
MPI_INFO_NULL
,
port_name
);
MPI_Send
(
port_name
,
MPI_MAX_PORT_NAME
,
MPI_CHAR
,
stat
.
MPI_SOURCE
,
stat
.
MPI_TAG
,
parents_comm
);
...
...
@@ -191,7 +186,7 @@ void multiple_strat_children(MPI_Comm *parents) {
}
else
{
MPI_Recv
(
port_name
,
MPI_MAX_PORT_NAME
,
MPI_CHAR
,
stat
.
MPI_SOURCE
,
stat
.
MPI_TAG
,
parents_comm
,
&
stat
);
// The "+1" is because the first iteration is done before the loop
start
=
stat
.
MPI_TAG
-
MAM_TAG_STRAT_MULTIPLE
_FIRST
+
1
;
start
=
stat
.
MPI_TAG
-
MAM_
MPI
TAG_STRAT_MULTIPLE
+
1
;
}
}
else
{
port_name
=
malloc
(
1
);
}
...
...
@@ -264,7 +259,7 @@ void multiple_strat_children2(MPI_Comm *parents, Spawn_ports *spawn_port) {
MPI_Comm_dup
(
mall
->
comm
,
&
newintracomm
);
if
(
new_root
)
{
MPI_Send
(
&
aux
,
1
,
MPI_CHAR
,
mall
->
root_parents
,
MAM_TAG_STRAT_MULTIPLE
,
parents_comm
);
// Ensures order in the created intracommunicator
MPI_Send
(
&
aux
,
1
,
MPI_CHAR
,
mall
->
root_parents
,
MAM_
MPI
TAG_STRAT_MULTIPLE
,
parents_comm
);
// Ensures order in the created intracommunicator
}
}
...
...
@@ -275,7 +270,7 @@ void multiple_strat_children2(MPI_Comm *parents, Spawn_ports *spawn_port) {
MPI_Comm_disconnect
(
&
intercomm
);
if
(
new_root
)
{
MPI_Send
(
&
aux
,
1
,
MPI_CHAR
,
mall
->
root_parents
,
MAM_TAG_STRAT_MULTIPLE
,
parents_comm
);
// Ensures order in the created intracommunicator
MPI_Send
(
&
aux
,
1
,
MPI_CHAR
,
mall
->
root_parents
,
MAM_
MPI
TAG_STRAT_MULTIPLE
,
parents_comm
);
// Ensures order in the created intracommunicator
}
}
...
...
@@ -294,54 +289,3 @@ void multiple_strat_children2(MPI_Comm *parents, Spawn_ports *spawn_port) {
DEBUG_FUNC
(
"Additional spawn action - Multiple CH completed"
,
mall
->
myId
,
mall
->
numP
);
fflush
(
stdout
);
#endif
}
\ No newline at end of file
/*
* Si la variable "type" es 1, la creación es con la participación de todo el grupo de padres
* Si el valor es diferente, la creación es solo con la participación del proceso root
*/
void
single_strat_parents
(
Spawn_data
spawn_data
,
MPI_Comm
*
child
)
{
char
*
port_name
;
MPI_Comm
newintercomm
;
if
(
mall
->
myId
==
mall
->
root
)
{
port_name
=
(
char
*
)
malloc
(
MPI_MAX_PORT_NAME
*
sizeof
(
char
));
MPI_Recv
(
port_name
,
MPI_MAX_PORT_NAME
,
MPI_CHAR
,
MPI_ANY_SOURCE
,
MAM_TAG_STRAT_SINGLE
,
*
child
,
MPI_STATUS_IGNORE
);
set_spawn_state
(
MAM_I_SPAWN_SINGLE_COMPLETED
,
spawn_data
.
spawn_is_async
);
// Indicate other processes to join root to end spawn procedure
wakeup_completion
();
}
else
{
port_name
=
malloc
(
1
);
}
MPI_Comm_connect
(
port_name
,
MPI_INFO_NULL
,
mall
->
root
,
spawn_data
.
comm
,
&
newintercomm
);
if
(
mall
->
myId
==
mall
->
root
)
MPI_Comm_disconnect
(
child
);
free
(
port_name
);
*
child
=
newintercomm
;
#if MAM_DEBUG >= 4
DEBUG_FUNC
(
"Additional spawn action - Single PA completed"
,
mall
->
myId
,
mall
->
numP
);
fflush
(
stdout
);
#endif
}
/*
* Conectar grupo de hijos con grupo de padres
* Devuelve un intercomunicador para hablar con los padres
*
* Solo se utiliza cuando la creación de los procesos ha sido
* realizada por un solo proceso padre
*/
void
single_strat_children
(
MPI_Comm
*
parents
,
Spawn_ports
*
spawn_port
)
{
MPI_Comm
newintercomm
;
int
is_root
=
mall
->
myId
==
mall
->
root
?
1
:
0
;
open_port
(
spawn_port
,
is_root
,
MAM_SERVICE_UNNEEDED
);
if
(
mall
->
myId
==
mall
->
root
)
{
MPI_Send
(
spawn_port
->
port_name
,
MPI_MAX_PORT_NAME
,
MPI_CHAR
,
mall
->
root_parents
,
MAM_TAG_STRAT_SINGLE
,
*
parents
);
}
MPI_Comm_accept
(
spawn_port
->
port_name
,
MPI_INFO_NULL
,
mall
->
root
,
mall
->
comm
,
&
newintercomm
);
MPI_Comm_disconnect
(
parents
);
*
parents
=
newintercomm
;
}
Codes/MaM/spawn_methods/Strategy_Single.c
0 → 100644
View file @
6a2cd38f
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "../MAM_Constants.h"
#include "../MAM_DataStructures.h"
#include "PortService.h"
#include "Spawn_state.h"
#include "Strategy_Single.h"
/*
* Si la variable "type" es 1, la creación es con la participación de todo el grupo de padres
* Si el valor es diferente, la creación es solo con la participación del proceso root
*/
void
single_strat_parents
(
Spawn_data
spawn_data
,
MPI_Comm
*
child
)
{
char
*
port_name
;
MPI_Comm
newintercomm
;
#if MAM_DEBUG >= 4
DEBUG_FUNC
(
"Additional spawn action - Single PA started"
,
mall
->
myId
,
mall
->
numP
);
fflush
(
stdout
);
#endif
if
(
mall
->
myId
==
mall
->
root
)
{
port_name
=
(
char
*
)
malloc
(
MPI_MAX_PORT_NAME
*
sizeof
(
char
));
MPI_Recv
(
port_name
,
MPI_MAX_PORT_NAME
,
MPI_CHAR
,
MPI_ANY_SOURCE
,
MAM_MPITAG_STRAT_SINGLE
,
*
child
,
MPI_STATUS_IGNORE
);
set_spawn_state
(
MAM_I_SPAWN_SINGLE_COMPLETED
,
spawn_data
.
spawn_is_async
);
// Indicate other processes to join root to end spawn procedure
wakeup_completion
();
}
else
{
port_name
=
malloc
(
1
);
}
MPI_Comm_connect
(
port_name
,
MPI_INFO_NULL
,
mall
->
root
,
spawn_data
.
comm
,
&
newintercomm
);
if
(
mall
->
myId
==
mall
->
root
)
MPI_Comm_disconnect
(
child
);
free
(
port_name
);
*
child
=
newintercomm
;
#if MAM_DEBUG >= 4
DEBUG_FUNC
(
"Additional spawn action - Single PA completed"
,
mall
->
myId
,
mall
->
numP
);
fflush
(
stdout
);
#endif
}
/*
* Conectar grupo de hijos con grupo de padres
* Devuelve un intercomunicador para hablar con los padres
*
* Solo se utiliza cuando la creación de los procesos ha sido
* realizada por un solo proceso padre
*/
void
single_strat_children
(
MPI_Comm
*
parents
,
Spawn_ports
*
spawn_port
)
{
MPI_Comm
newintercomm
;
int
is_root
=
mall
->
myId
==
mall
->
root
?
1
:
0
;
#if MAM_DEBUG >= 4
DEBUG_FUNC
(
"Additional spawn action - Single CH started"
,
mall
->
myId
,
mall
->
numP
);
fflush
(
stdout
);
#endif
open_port
(
spawn_port
,
is_root
,
MAM_SERVICE_UNNEEDED
);
if
(
mall
->
myId
==
mall
->
root
)
{
MPI_Send
(
spawn_port
->
port_name
,
MPI_MAX_PORT_NAME
,
MPI_CHAR
,
mall
->
root_parents
,
MAM_MPITAG_STRAT_SINGLE
,
*
parents
);
}
MPI_Comm_accept
(
spawn_port
->
port_name
,
MPI_INFO_NULL
,
mall
->
root
,
mall
->
comm
,
&
newintercomm
);
MPI_Comm_disconnect
(
parents
);
*
parents
=
newintercomm
;
#if MAM_DEBUG >= 4
DEBUG_FUNC
(
"Additional spawn action - Single CH completed"
,
mall
->
myId
,
mall
->
numP
);
fflush
(
stdout
);
#endif
}
Codes/MaM/spawn_methods/Strategy_Single.h
0 → 100644
View file @
6a2cd38f
#ifndef MAM_SPAWN_SINGLE_H
#define MAM_SPAWN_SINGLE_H
#include <mpi.h>
#include "Spawn_DataStructure.h"
void
single_strat_parents
(
Spawn_data
spawn_data
,
MPI_Comm
*
child
);
void
single_strat_children
(
MPI_Comm
*
parents
,
Spawn_ports
*
spawn_port
);
#endif
Exec/configuration.ini
View file @
6a2cd38f
...
...
@@ -5,7 +5,7 @@ Granularity=100000
SDR
=
1000.0
ADR
=
0.0
Rigid
=
1
;
end [general]
;end [general]
[stage0]
Stage_Type
=
0
Stage_Bytes
=
0
...
...
Write
Preview
Supports
Markdown
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