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
33fb8b86
Commit
33fb8b86
authored
Jun 04, 2024
by
Iker Martín Álvarez
Browse files
WIP. Modifying constants so all of them start with MAM
parent
60dedf0d
Changes
11
Hide whitespace changes
Inline
Side-by-side
Codes/IOcodes/read_ini.c
View file @
33fb8b86
...
...
@@ -74,9 +74,9 @@ static int handler(void* user, const char* section, const char* name,
}
else
if
(
MATCH
(
resize_name
,
"FactorS"
)
&&
LAST
(
pconfig
->
actual_group
,
pconfig
->
n_groups
))
{
pconfig
->
groups
[
pconfig
->
actual_group
].
factor
=
(
float
)
atof
(
value
);
}
else
if
(
MATCH
(
resize_name
,
"Dist"
)
&&
LAST
(
pconfig
->
actual_group
,
pconfig
->
n_groups
))
{
int
aux_value
=
MA
LL
_DIST_COMPACT
;
int
aux_value
=
MA
M_PHY
_DIST_COMPACT
;
if
(
strcmp
(
value
,
"spread"
)
==
0
)
{
aux_value
=
MA
LL
_DIST_SPREAD
;
aux_value
=
MA
M_PHY
_DIST_SPREAD
;
}
pconfig
->
groups
[
pconfig
->
actual_group
].
phy_dist
=
aux_value
;
}
else
if
(
MATCH
(
resize_name
,
"Redistribution_Method"
)
&&
LAST
(
pconfig
->
actual_group
,
pconfig
->
n_groups
))
{
...
...
Codes/malleability/MAM_Configuration.c
View file @
33fb8b86
...
...
@@ -25,10 +25,10 @@ int MAM_I_add_strat(unsigned int *comm_strategies, unsigned int strategy);
int
MAM_I_remove_strat
(
unsigned
int
*
comm_strategies
,
unsigned
int
strategy
);
mam_config_setting_t
configSettings
[]
=
{
{
NULL
,
MA
LL
_SPAWN_MERGE
,
MAM_METHODS_SPAWN_LEN
,
{.
set_config_simple
=
MAM_I_set_method
},
MAM_SPAWN_METHOD_ENV
},
{
NULL
,
MA
M
_SPAWN_MERGE
,
MAM_METHODS_SPAWN_LEN
,
{.
set_config_simple
=
MAM_I_set_method
},
MAM_SPAWN_METHOD_ENV
},
{
NULL
,
MAM_STRAT_SPAWN_CLEAR
,
MAM_STRATS_SPAWN_LEN
,
{.
set_config_simple
=
MAM_I_set_spawn_strat
},
MAM_SPAWN_STRATS_ENV
},
{
NULL
,
MA
LL
_DIST_COMPACT
,
MAM_METHODS_PHYSICAL_DISTRIBUTION_LEN
,
{.
set_config_simple
=
MAM_I_set_method
},
MAM_PHYSICAL_DISTRIBUTION_METHOD_ENV
},
{
NULL
,
MA
LL
_RED_BASELINE
,
MAM_METHODS_RED_LEN
,
{.
set_config_simple
=
MAM_I_set_method
},
MAM_RED_METHOD_ENV
},
{
NULL
,
MA
M_PHY
_DIST_COMPACT
,
MAM_METHODS_PHYSICAL_DISTRIBUTION_LEN
,
{.
set_config_simple
=
MAM_I_set_method
},
MAM_PHYSICAL_DISTRIBUTION_METHOD_ENV
},
{
NULL
,
MA
M
_RED_BASELINE
,
MAM_METHODS_RED_LEN
,
{.
set_config_simple
=
MAM_I_set_method
},
MAM_RED_METHOD_ENV
},
{
NULL
,
MAM_STRAT_RED_CLEAR
,
MAM_STRATS_RED_LEN
,
{.
set_config_simple
=
MAM_I_set_red_strat
},
MAM_RED_STRATS_ENV
},
{
NULL
,
1
,
INT_MAX
,
{.
set_config_complex
=
MAM_I_set_target_number
},
MAM_NUM_TARGETS_ENV
}
...
...
@@ -53,7 +53,7 @@ unsigned int masks_red[] = {MAM_STRAT_CLEAR_VALUE, MAM_MASK_PTHREAD, MAM_MASK_RE
void
MAM_Set_configuration
(
int
spawn_method
,
int
spawn_strategies
,
int
spawn_dist
,
int
red_method
,
int
red_strategies
)
{
int
i
,
aux
;
int
aux_array
[]
=
{
spawn_method
,
spawn_strategies
,
spawn_dist
,
red_method
,
red_strategies
};
if
(
state
>
MA
LL
_NOT_STARTED
)
return
;
if
(
state
>
MA
M_I
_NOT_STARTED
)
return
;
mam_config_setting_t
*
config
=
NULL
;
for
(
i
=
0
;
i
<
MAM_KEY_COUNT
-
1
;
i
++
)
{
//FIXME Numero magico para no cambiar num_targets
...
...
@@ -88,8 +88,8 @@ void MAM_Set_key_configuration(int key, int required, int *provided) {
int
i
,
aux
;
if
(
provided
==
NULL
)
provided
=
&
aux
;
*
provided
=
MA
LL
_DENIED
;
if
(
required
<
0
||
state
>
MA
LL
_NOT_STARTED
)
return
;
*
provided
=
MA
M
_DENIED
;
if
(
required
<
0
||
state
>
MA
M_I
_NOT_STARTED
)
return
;
mam_config_setting_t
*
config
=
NULL
;
for
(
i
=
0
;
i
<
MAM_KEY_COUNT
;
i
++
)
{
...
...
@@ -129,7 +129,7 @@ int MAM_Contains_strat(int key, unsigned int strategy, int *result) {
len
=
MAM_STRATS_RED_LEN
;
break
;
default:
aux
=
MA
LL
_DENIED
;
aux
=
MA
M
_DENIED
;
break
;
}
...
...
@@ -196,16 +196,16 @@ void MAM_Set_initial_configuration() {
void
MAM_Check_configuration
()
{
int
global_internodes
;
if
(
mall
->
numC
==
mall
->
numP
)
{
// Migrate
MAM_Set_key_configuration
(
MAM_SPAWN_METHOD
,
MA
LL
_SPAWN_BASELINE
,
NULL
);
MAM_Set_key_configuration
(
MAM_SPAWN_METHOD
,
MA
M
_SPAWN_BASELINE
,
NULL
);
}
MPI_Allreduce
(
&
mall
->
internode_group
,
&
global_internodes
,
1
,
MPI_INT
,
MPI_MAX
,
mall
->
comm
);
if
(
MAM_Contains_strat
(
MAM_SPAWN_STRATEGIES
,
MAM_STRAT_SPAWN_MULTIPLE
,
NULL
)
&&
global_internodes
)
{
// Remove internode MPI_COMM_WORLDs
MAM_Set_key_configuration
(
MAM_SPAWN_METHOD
,
MA
LL
_SPAWN_BASELINE
,
NULL
);
MAM_Set_key_configuration
(
MAM_SPAWN_METHOD
,
MA
M
_SPAWN_BASELINE
,
NULL
);
}
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_MERGE
)
{
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_MERGE
)
{
if
(
MAM_I_contains_strat
(
mall_conf
->
spawn_strategies
,
MAM_MASK_SPAWN_INTERCOMM
))
{
MAM_I_remove_strat
(
&
mall_conf
->
spawn_strategies
,
MAM_MASK_SPAWN_INTERCOMM
);
}
...
...
@@ -213,7 +213,7 @@ void MAM_Check_configuration() {
MAM_I_remove_strat
(
&
mall_conf
->
spawn_strategies
,
MAM_MASK_SPAWN_SINGLE
);
}
}
if
(
mall_conf
->
red_method
==
MA
LL
_RED_RMA_LOCK
||
mall_conf
->
red_method
==
MA
LL
_RED_RMA_LOCKALL
)
{
if
(
mall_conf
->
red_method
==
MA
M
_RED_RMA_LOCK
||
mall_conf
->
red_method
==
MA
M
_RED_RMA_LOCKALL
)
{
if
(
MAM_I_contains_strat
(
mall_conf
->
spawn_strategies
,
MAM_MASK_SPAWN_INTERCOMM
))
{
MAM_I_remove_strat
(
&
mall_conf
->
spawn_strategies
,
MAM_MASK_SPAWN_INTERCOMM
);
}
...
...
@@ -287,7 +287,7 @@ int MAM_I_set_spawn_strat(unsigned int strategy, unsigned int *strategies) {
break
;
default:
//Unkown strategy
result
=
MA
LL
_DENIED
;
result
=
MA
M
_DENIED
;
break
;
}
...
...
@@ -329,7 +329,7 @@ int MAM_I_set_red_strat(unsigned int strategy, unsigned int *strategies) {
break
;
default:
//Unkown strategy
result
=
MA
LL
_DENIED
;
result
=
MA
M
_DENIED
;
break
;
}
...
...
@@ -340,7 +340,7 @@ int MAM_I_set_red_strat(unsigned int strategy, unsigned int *strategies) {
}
int
MAM_I_set_target_number
(
unsigned
int
new_numC
)
{
if
(
state
>
MA
LL
_NOT_STARTED
||
new_numC
==
0
)
return
MA
LL
_DENIED
;
if
(
state
>
MA
M_I
_NOT_STARTED
||
new_numC
==
0
)
return
MA
M
_DENIED
;
mall
->
numC
=
(
int
)
new_numC
;
return
new_numC
;
...
...
Codes/malleability/MAM_Constants.h
View file @
33fb8b86
...
...
@@ -2,19 +2,19 @@
#define MAM_CONSTANTS_H
//States
#define MA
LL
_DENIED -1
#define MA
M
_DENIED -1
#define MAM_OK 0
enum
mam_states
{
MAM_UNRESERVED
,
MAM_NOT_STARTED
,
MAM_PENDING
,
MAM_USER_PENDING
,
MAM_COMPLETED
};
enum
mam_proc_states
{
MAM_PROC_CONTINUE
,
MAM_PROC_NEW_RANK
,
MAM_PROC_ZOMBIE
};
enum
ma
ll
_spawn_methods
{
MA
LL
_SPAWN_BASELINE
,
MA
LL
_SPAWN_MERGE
,
MAM_METHODS_SPAWN_LEN
};
enum
ma
m
_spawn_methods
{
MA
M
_SPAWN_BASELINE
,
MA
M
_SPAWN_MERGE
,
MAM_METHODS_SPAWN_LEN
};
enum
mam_spawn_strategies
{
MAM_STRAT_SPAWN_CLEAR
,
MAM_STRAT_SPAWN_PTHREAD
,
MAM_STRAT_SPAWN_SINGLE
,
MAM_STRAT_SPAWN_INTERCOMM
,
MAM_STRAT_SPAWN_MULTIPLE
,
MAM_STRATS_SPAWN_LEN
};
enum
mam_phy_dist_methods
{
MA
LL
_DIST_SPREAD
=
1
,
MA
LL
_DIST_COMPACT
,
MAM_METHODS_PHYSICAL_DISTRIBUTION_LEN
};
//FIXME Cambiar nombres a PHY_DIST?
enum
mam_phy_info_methods
{
MA
LL_DIST
_STRING
=
1
,
MA
LL_DIST
_HOSTFILE
};
//FIXME Cambiar nombres a PHY_DIST?
enum
mam_phy_dist_methods
{
MA
M_PHY
_DIST_SPREAD
=
1
,
MA
M_PHY
_DIST_COMPACT
,
MAM_METHODS_PHYSICAL_DISTRIBUTION_LEN
};
enum
mam_phy_info_methods
{
MA
M_PHY_TYPE
_STRING
=
1
,
MA
M_PHY_TYPE
_HOSTFILE
};
enum
ma
ll
_redistribution_methods
{
MA
LL
_RED_BASELINE
,
MA
LL
_RED_POINT
,
MA
LL
_RED_RMA_LOCK
,
MA
LL
_RED_RMA_LOCKALL
,
MAM_METHODS_RED_LEN
};
enum
ma
m
_redistribution_methods
{
MA
M
_RED_BASELINE
,
MA
M
_RED_POINT
,
MA
M
_RED_RMA_LOCK
,
MA
M
_RED_RMA_LOCKALL
,
MAM_METHODS_RED_LEN
};
enum
mam_red_strategies
{
MAM_STRAT_RED_CLEAR
,
MAM_STRAT_RED_PTHREAD
,
MAM_STRAT_RED_WAIT_SOURCES
,
MAM_STRAT_RED_WAIT_TARGETS
,
MAM_STRATS_RED_LEN
};
/* KEYS & VALUES for config*/
...
...
@@ -28,9 +28,6 @@ enum mam_key_values{MAM_SPAWN_METHOD=0, MAM_SPAWN_STRATEGIES, MAM_PHYSICAL_DISTR
#define MAM_ROOT 0
#define MAL_APP_EXECUTING 0
#define MAL_APP_ENDED 1
#define MAM_CHECK_COMPLETION 0
#define MAM_WAIT_COMPLETION 1
...
...
Codes/malleability/MAM_DataStructures.c
View file @
33fb8b86
...
...
@@ -2,7 +2,7 @@
malleability_config_t
*
mall_conf
=
NULL
;
malleability_t
*
mall
=
NULL
;
int
state
=
MA
LL
_UNRESERVED
;
int
state
=
MA
M_I
_UNRESERVED
;
/*
* Crea un tipo derivado para mandar las dos estructuras principales
...
...
Codes/malleability/MAM_DataStructures.h
View file @
33fb8b86
...
...
@@ -13,9 +13,9 @@
#define DEBUG_FUNC(debug_string, rank, numP) printf("MaM [P%d/%d]: %s -- %s:%s:%d\n", rank, numP, debug_string, __FILE__, __func__, __LINE__)
/* --- MAM REAL STATES --- */
enum
mam_inner_states
{
MA
LL
_UNRESERVED
,
MA
LL
_NOT_STARTED
,
MA
LL
_RMS_COMPLETED
,
MA
LL
_SPAWN_PENDING
,
MA
LL
_SPAWN_SINGLE_PENDING
,
MA
LL
_SPAWN_SINGLE_COMPLETED
,
MA
LL
_SPAWN_ADAPT_POSTPONE
,
MA
LL
_SPAWN_COMPLETED
,
MA
LL
_DIST_PENDING
,
MA
LL
_DIST_COMPLETED
,
MA
LL
_SPAWN_ADAPT_PENDING
,
MA
LL
_USER_START
,
MA
LL
_USER_PENDING
,
MA
LL
_USER_COMPLETED
,
MA
LL
_SPAWN_ADAPTED
,
MA
LL
_COMPLETED
};
enum
mam_inner_states
{
MA
M_I
_UNRESERVED
,
MA
M_I
_NOT_STARTED
,
MA
M_I
_RMS_COMPLETED
,
MA
M_I
_SPAWN_PENDING
,
MA
M_I
_SPAWN_SINGLE_PENDING
,
MA
M_I
_SPAWN_SINGLE_COMPLETED
,
MA
M_I
_SPAWN_ADAPT_POSTPONE
,
MA
M_I
_SPAWN_COMPLETED
,
MA
M_I
_DIST_PENDING
,
MA
M_I
_DIST_COMPLETED
,
MA
M_I
_SPAWN_ADAPT_PENDING
,
MA
M_I
_USER_START
,
MA
M_I
_USER_PENDING
,
MA
M_I
_USER_COMPLETED
,
MA
M_I
_SPAWN_ADAPTED
,
MA
M_I
_COMPLETED
};
/* --- TIME CAPTURE STRUCTURE --- */
typedef
struct
{
...
...
Codes/malleability/MAM_Manager.c
View file @
33fb8b86
...
...
@@ -109,7 +109,7 @@ int MAM_Init(int root, MPI_Comm *comm, char *name_exec, void (*user_function)(vo
dist_s_data
->
entries
=
0
;
dist_a_data
->
entries
=
0
;
state
=
MA
LL
_NOT_STARTED
;
state
=
MA
M_I
_NOT_STARTED
;
MAM_Init_configuration
();
MAM_Zombies_service_init
();
...
...
@@ -169,7 +169,7 @@ int MAM_Finalize() {
free
(
mall_conf
);
free
(
user_reconf
);
state
=
MA
LL
_UNRESERVED
;
state
=
MA
M_I
_UNRESERVED
;
return
request_abort
;
}
...
...
@@ -189,54 +189,54 @@ int MAM_Checkpoint(int *mam_state, int wait_completed, void (*user_function)(voi
//TODO This could be changed to an array with the functions to call in each case
switch
(
state
)
{
case
MA
LL
_UNRESERVED
:
case
MA
M_I
_UNRESERVED
:
*
mam_state
=
MAM_UNRESERVED
;
break
;
case
MA
LL
_NOT_STARTED
:
case
MA
M_I
_NOT_STARTED
:
call_checkpoint
=
MAM_St_rms
(
mam_state
);
break
;
case
MA
LL
_RMS_COMPLETED
:
case
MA
M_I
_RMS_COMPLETED
:
call_checkpoint
=
MAM_St_spawn_start
();
break
;
case
MA
LL
_SPAWN_PENDING
:
// Comprueba si el spawn ha terminado
case
MA
LL
_SPAWN_SINGLE_PENDING
:
case
MA
M_I
_SPAWN_PENDING
:
// Comprueba si el spawn ha terminado
case
MA
M_I
_SPAWN_SINGLE_PENDING
:
call_checkpoint
=
MAM_St_spawn_pending
(
wait_completed
);
break
;
case
MA
LL
_SPAWN_ADAPT_POSTPONE
:
case
MA
LL
_SPAWN_COMPLETED
:
case
MA
M_I
_SPAWN_ADAPT_POSTPONE
:
case
MA
M_I
_SPAWN_COMPLETED
:
call_checkpoint
=
MAM_St_red_start
();
break
;
case
MA
LL
_DIST_PENDING
:
case
MA
M_I
_DIST_PENDING
:
call_checkpoint
=
MAM_St_red_pending
(
wait_completed
);
break
;
case
MA
LL
_USER_START
:
case
MA
M_I
_USER_START
:
call_checkpoint
=
MAM_St_user_start
(
mam_state
);
break
;
case
MA
LL
_USER_PENDING
:
case
MA
M_I
_USER_PENDING
:
call_checkpoint
=
MAM_St_user_pending
(
mam_state
,
wait_completed
,
user_function
,
user_args
);
break
;
case
MA
LL
_USER_COMPLETED
:
case
MA
M_I
_USER_COMPLETED
:
call_checkpoint
=
MAM_St_user_completed
();
break
;
case
MA
LL
_SPAWN_ADAPT_PENDING
:
case
MA
M_I
_SPAWN_ADAPT_PENDING
:
call_checkpoint
=
MAM_St_spawn_adapt_pending
(
wait_completed
);
break
;
case
MA
LL
_SPAWN_ADAPTED
:
case
MA
LL
_DIST_COMPLETED
:
case
MA
M_I
_SPAWN_ADAPTED
:
case
MA
M_I
_DIST_COMPLETED
:
call_checkpoint
=
MAM_St_completed
(
mam_state
);
break
;
}
if
(
call_checkpoint
)
{
MAM_Checkpoint
(
mam_state
,
wait_completed
,
user_function
,
user_args
);
}
if
(
state
>
MA
LL
_NOT_STARTED
&&
state
<
MA
LL
_COMPLETED
)
*
mam_state
=
MAM_PENDING
;
if
(
state
>
MA
M_I
_NOT_STARTED
&&
state
<
MA
M_I
_COMPLETED
)
*
mam_state
=
MAM_PENDING
;
return
state
;
}
...
...
@@ -244,7 +244,7 @@ int MAM_Checkpoint(int *mam_state, int wait_completed, void (*user_function)(voi
* TODO
*/
void
MAM_Resume_redistribution
(
int
*
mam_state
)
{
state
=
MA
LL
_USER_COMPLETED
;
state
=
MA
M_I
_USER_COMPLETED
;
if
(
mam_state
!=
NULL
)
*
mam_state
=
MAM_PENDING
;
}
...
...
@@ -258,7 +258,7 @@ void MAM_Commit(int *mam_state) {
#endif
// Get times before commiting
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_BASELINE
)
{
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_BASELINE
)
{
// This communication is only needed when the root process will become a zombie
malleability_times_broadcast
(
mall
->
root_collectives
);
}
...
...
@@ -280,20 +280,20 @@ void MAM_Commit(int *mam_state) {
}
// Reset/Free communicators
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_MERGE
)
{
MAM_comms_update
(
mall
->
intercomm
);
}
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_MERGE
)
{
MAM_comms_update
(
mall
->
intercomm
);
}
if
(
mall
->
intercomm
!=
MPI_COMM_NULL
&&
mall
->
intercomm
!=
MPI_COMM_WORLD
)
{
MPI_Comm_disconnect
(
&
(
mall
->
intercomm
));
}
//FIXME Error en OpenMPI + Merge
MPI_Comm_rank
(
mall
->
comm
,
&
mall
->
myId
);
MPI_Comm_size
(
mall
->
comm
,
&
mall
->
numP
);
mall
->
root
=
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_BASELINE
?
mall
->
root
:
mall
->
root_parents
;
mall
->
root
=
mall_conf
->
spawn_method
==
MA
M
_SPAWN_BASELINE
?
mall
->
root
:
mall
->
root_parents
;
mall
->
root_parents
=
mall
->
root
;
state
=
MA
LL
_NOT_STARTED
;
state
=
MA
M_I
_NOT_STARTED
;
if
(
mam_state
!=
NULL
)
*
mam_state
=
MAM_COMPLETED
;
// Set new communicator
MPI_Comm_dup
(
mall
->
comm
,
mall
->
user_comm
);
//if(mall_conf->spawn_method == MA
LL
_SPAWN_BASELINE) { *(mall->user_comm) = MPI_COMM_WORLD; }
//else if(mall_conf->spawn_method == MA
LL
_SPAWN_MERGE) { MPI_Comm_dup(mall->comm, mall->user_comm); }
//if(mall_conf->spawn_method == MA
M
_SPAWN_BASELINE) { *(mall->user_comm) = MPI_COMM_WORLD; }
//else if(mall_conf->spawn_method == MA
M
_SPAWN_MERGE) { MPI_Comm_dup(mall->comm, mall->user_comm); }
#if USE_MAL_DEBUG
if
(
mall
->
myId
==
mall
->
root
)
DEBUG_FUNC
(
"Reconfiguration has been commited"
,
mall
->
myId
,
mall
->
numP
);
fflush
(
stdout
);
#endif
...
...
@@ -324,9 +324,9 @@ void MAM_Data_add(void *data, size_t *index, size_t total_qty, MPI_Datatype type
add_data
(
data
,
total_qty
,
type
,
total_reqs
,
rep_a_data
);
returned_index
=
rep_a_data
->
entries
-
1
;
}
else
{
if
(
mall_conf
->
red_method
==
MA
LL
_RED_BASELINE
)
{
if
(
mall_conf
->
red_method
==
MA
M
_RED_BASELINE
)
{
total_reqs
=
1
;
}
else
if
(
mall_conf
->
red_method
==
MA
LL
_RED_POINT
||
mall_conf
->
red_method
==
MA
LL
_RED_RMA_LOCK
||
mall_conf
->
red_method
==
MA
LL
_RED_RMA_LOCKALL
)
{
}
else
if
(
mall_conf
->
red_method
==
MA
M
_RED_POINT
||
mall_conf
->
red_method
==
MA
M
_RED_RMA_LOCK
||
mall_conf
->
red_method
==
MA
M
_RED_RMA_LOCKALL
)
{
total_reqs
=
mall
->
numC
;
}
...
...
@@ -364,9 +364,9 @@ void MAM_Data_modify(void *data, size_t index, size_t total_qty, MPI_Datatype ty
total_reqs
=
1
;
modify_data
(
data
,
index
,
total_qty
,
type
,
total_reqs
,
rep_a_data
);
//FIXME total_reqs==0 ???
}
else
{
if
(
mall_conf
->
red_method
==
MA
LL
_RED_BASELINE
)
{
if
(
mall_conf
->
red_method
==
MA
M
_RED_BASELINE
)
{
total_reqs
=
1
;
}
else
if
(
mall_conf
->
red_method
==
MA
LL
_RED_POINT
||
mall_conf
->
red_method
==
MA
LL
_RED_RMA_LOCK
||
mall_conf
->
red_method
==
MA
LL
_RED_RMA_LOCKALL
)
{
}
else
if
(
mall_conf
->
red_method
==
MA
M
_RED_POINT
||
mall_conf
->
red_method
==
MA
M
_RED_RMA_LOCK
||
mall_conf
->
red_method
==
MA
M
_RED_RMA_LOCKALL
)
{
total_reqs
=
mall
->
numC
;
}
...
...
@@ -441,7 +441,7 @@ void MAM_Data_get_pointer(void **data, size_t index, size_t *total_qty, MPI_Data
/*
* @brief Returns a structure to perform data redistribution during a reconfiguration.
*
* This function is intended to be called when the state of MaM is MA
LL
_USER_PENDING only.
* This function is intended to be called when the state of MaM is MA
M_I
_USER_PENDING only.
* It is designed to provide the necessary information for the user to perform data redistribution.
*
* Parameters:
...
...
@@ -449,10 +449,10 @@ void MAM_Data_get_pointer(void **data, size_t index, size_t *total_qty, MPI_Data
*
* Return Value:
* - MAM_OK: If the function successfully retrieves the reconfiguration information.
* - MA
LL
_DENIED: If the function is called when the state of the MaM is not MA
LL
_USER_PENDING.
* - MA
M
_DENIED: If the function is called when the state of the MaM is not MA
M_I
_USER_PENDING.
*/
int
MAM_Get_Reconf_Info
(
mam_user_reconf_t
*
reconf_info
)
{
if
(
state
!=
MA
LL
_USER_PENDING
)
return
MA
LL
_DENIED
;
if
(
state
!=
MA
M_I
_USER_PENDING
)
return
MA
M
_DENIED
;
*
reconf_info
=
*
user_reconf
;
return
MAM_OK
;
...
...
@@ -553,10 +553,10 @@ int MAM_St_rms(int *mam_state) {
MAM_Check_configuration
();
*
mam_state
=
MAM_NOT_STARTED
;
state
=
MA
LL
_RMS_COMPLETED
;
state
=
MA
M_I
_RMS_COMPLETED
;
mall
->
wait_targets_posted
=
0
;
//if(CHECK_RMS()) {return MA
LL
_DENIED;}
//if(CHECK_RMS()) {return MA
M
_DENIED;}
return
1
;
}
...
...
@@ -564,10 +564,10 @@ int MAM_St_spawn_start() {
mall
->
num_parents
=
mall
->
numP
;
state
=
spawn_step
();
//FIXME Esto es necesario pero feo
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_MERGE
&&
mall
->
myId
>=
mall
->
numC
){
mall
->
zombie
=
1
;
}
else
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_BASELINE
){
mall
->
zombie
=
1
;
}
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_MERGE
&&
mall
->
myId
>=
mall
->
numC
){
mall
->
zombie
=
1
;
}
else
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_BASELINE
){
mall
->
zombie
=
1
;
}
if
(
state
==
MA
LL
_SPAWN_COMPLETED
||
state
==
MA
LL
_SPAWN_ADAPT_POSTPONE
){
if
(
state
==
MA
M_I
_SPAWN_COMPLETED
||
state
==
MA
M_I
_SPAWN_ADAPT_POSTPONE
){
return
1
;
}
return
0
;
...
...
@@ -575,7 +575,7 @@ int MAM_St_spawn_start() {
int
MAM_St_spawn_pending
(
int
wait_completed
)
{
state
=
check_spawn_state
(
&
(
mall
->
intercomm
),
mall
->
comm
,
wait_completed
);
if
(
state
==
MA
LL
_SPAWN_COMPLETED
||
state
==
MA
LL
_SPAWN_ADAPTED
)
{
if
(
state
==
MA
M_I
_SPAWN_COMPLETED
||
state
==
MA
M_I
_SPAWN_ADAPTED
)
{
#if USE_MAL_BARRIERS
MPI_Barrier
(
mall
->
comm
);
#endif
...
...
@@ -603,8 +603,8 @@ int MAM_St_red_pending(int wait_completed) {
state
=
check_redistribution
(
wait_completed
);
}
if
(
state
!=
MA
LL
_DIST_PENDING
)
{
state
=
MA
LL
_USER_START
;
if
(
state
!=
MA
M_I
_DIST_PENDING
)
{
state
=
MA
M_I
_USER_START
;
return
1
;
}
return
0
;
...
...
@@ -621,7 +621,7 @@ int MAM_St_user_start(int *mam_state) {
MPI_Comm_dup
(
mall
->
intercomm
,
&
mall
->
tmp_comm
);
}
MPI_Comm_set_name
(
mall
->
tmp_comm
,
"MAM_USER_TMP"
);
state
=
MA
LL
_USER_PENDING
;
state
=
MA
M_I
_USER_PENDING
;
*
mam_state
=
MAM_USER_PENDING
;
return
1
;
}
...
...
@@ -634,16 +634,16 @@ int MAM_St_user_pending(int *mam_state, int wait_completed, void (*user_function
MAM_I_create_user_struct
(
MAM_SOURCES
);
do
{
user_function
(
user_args
);
}
while
(
wait_completed
&&
state
==
MA
LL
_USER_PENDING
);
}
while
(
wait_completed
&&
state
==
MA
M_I
_USER_PENDING
);
}
else
{
MAM_Resume_redistribution
(
mam_state
);
}
if
(
state
!=
MA
LL
_USER_PENDING
)
{
if
(
state
!=
MA
M_I
_USER_PENDING
)
{
#if USE_MAL_BARRIERS
MPI_Barrier
(
mall
->
intercomm
);
#endif
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_MERGE
)
mall_conf
->
times
->
user_end
=
MPI_Wtime
();
// Obtener timestamp de cuando termina user redist
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_MERGE
)
mall_conf
->
times
->
user_end
=
MPI_Wtime
();
// Obtener timestamp de cuando termina user redist
#if USE_MAL_DEBUG
if
(
mall
->
myId
==
mall
->
root
)
DEBUG_FUNC
(
"Ended USER redistribution"
,
mall
->
myId
,
mall
->
numP
);
fflush
(
stdout
);
#endif
...
...
@@ -714,7 +714,7 @@ void Children_init(void (*user_function)(void *), void *user_args) {
#endif
malleability_connect_children
(
&
(
mall
->
intercomm
));
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_MERGE
)
{
// For Merge Method, these processes will be added
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_MERGE
)
{
// For Merge Method, these processes will be added
MPI_Comm_rank
(
mall
->
intercomm
,
&
mall
->
myId
);
MPI_Comm_size
(
mall
->
intercomm
,
&
mall
->
numP
);
}
...
...
@@ -796,7 +796,7 @@ void Children_init(void (*user_function)(void *), void *user_args) {
}
MPI_Comm_set_name
(
mall
->
tmp_comm
,
"MAM_USER_TMP"
);
if
(
user_function
!=
NULL
)
{
state
=
MA
LL
_USER_PENDING
;
state
=
MA
M_I
_USER_PENDING
;
MAM_I_create_user_struct
(
MAM_TARGETS
);
user_function
(
user_args
);
}
...
...
@@ -902,10 +902,10 @@ int start_redistribution() {
MPI_Ibarrier
(
mall
->
intercomm
,
&
mall
->
wait_targets
);
mall
->
wait_targets_posted
=
1
;
}
return
MA
LL
_DIST_PENDING
;
return
MA
M_I
_DIST_PENDING
;
}
}
return
MA
LL
_USER_START
;
return
MA
M_I
_USER_START
;
}
...
...
@@ -978,7 +978,7 @@ int check_redistribution(int wait_completed) {
#endif
MPI_Allreduce
(
&
local_completed
,
&
all_completed
,
1
,
MPI_INT
,
MPI_MIN
,
mall
->
comm
);
if
(
!
all_completed
)
return
MA
LL
_DIST_PENDING
;
// Continue only if asynchronous send has ended
if
(
!
all_completed
)
return
MA
M_I
_DIST_PENDING
;
// Continue only if asynchronous send has ended
}
#if USE_MAL_DEBUG >= 2
...
...
@@ -1001,8 +1001,8 @@ int check_redistribution(int wait_completed) {
#if USE_MAL_BARRIERS
MPI_Barrier
(
mall
->
intercomm
);
#endif
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_MERGE
)
mall_conf
->
times
->
async_end
=
MPI_Wtime
();
// Merge method only
return
MA
LL
_USER_START
;
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_MERGE
)
mall_conf
->
times
->
async_end
=
MPI_Wtime
();
// Merge method only
return
MA
M_I
_USER_START
;
}
/*
...
...
@@ -1032,12 +1032,12 @@ int end_redistribution() {
#if USE_MAL_BARRIERS
MPI_Barrier
(
mall
->
intercomm
);
#endif
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_MERGE
)
mall_conf
->
times
->
sync_end
=
MPI_Wtime
();
// Merge method only
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_MERGE
)
mall_conf
->
times
->
sync_end
=
MPI_Wtime
();
// Merge method only
}
local_state
=
MA
LL
_DIST_COMPLETED
;
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_MERGE
&&
mall
->
numP
>
mall
->
numC
)
{
// Merge Shrink
local_state
=
MA
LL
_SPAWN_ADAPT_PENDING
;
local_state
=
MA
M_I
_DIST_COMPLETED
;
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_MERGE
&&
mall
->
numP
>
mall
->
numC
)
{
// Merge Shrink
local_state
=
MA
M_I
_SPAWN_ADAPT_PENDING
;
}
return
local_state
;
...
...
@@ -1056,7 +1056,7 @@ int comm_state; //FIXME Usar un handler
* Crea una hebra para ejecutar una comunicación en segundo plano.
*/
int
thread_creation
()
{
comm_state
=
MA
LL
_DIST_PENDING
;
comm_state
=
MA
M_I
_DIST_PENDING
;
if
(
pthread_create
(
&
(
mall
->
async_thread
),
NULL
,
thread_async_work
,
NULL
))
{
printf
(
"Error al crear el hilo
\n
"
);
MPI_Abort
(
MPI_COMM_WORLD
,
-
1
);
...
...
@@ -1074,7 +1074,7 @@ int thread_creation() {
int
thread_check
(
int
wait_completed
)
{
int
all_completed
=
0
;
if
(
wait_completed
&&
comm_state
==
MA
LL
_DIST_PENDING
)
{
if
(
wait_completed
&&
comm_state
==
MA
M_I
_DIST_PENDING
)
{
if
(
pthread_join
(
mall
->
async_thread
,
NULL
))
{
printf
(
"Error al esperar al hilo
\n
"
);
MPI_Abort
(
MPI_COMM_WORLD
,
-
1
);
...
...
@@ -1084,7 +1084,7 @@ int thread_check(int wait_completed) {
// Comprueba que todos los hilos han terminado la distribucion (Mismo valor en commAsync)
MPI_Allreduce
(
&
comm_state
,
&
all_completed
,
1
,
MPI_INT
,
MPI_MAX
,
mall
->
comm
);
if
(
all_completed
!=
MA
LL
_DIST_COMPLETED
)
return
MA
LL
_DIST_PENDING
;
// Continue only if asynchronous send has ended
if
(
all_completed
!=
MA
M_I
_DIST_COMPLETED
)
return
MA
M_I
_DIST_PENDING
;
// Continue only if asynchronous send has ended
if
(
pthread_join
(
mall
->
async_thread
,
NULL
))
{
printf
(
"Error al esperar al hilo
\n
"
);
...
...
@@ -1095,8 +1095,8 @@ int thread_check(int wait_completed) {
#if USE_MAL_BARRIERS
MPI_Barrier
(
mall
->
intercomm
);
#endif
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_MERGE
)
mall_conf
->
times
->
async_end
=
MPI_Wtime
();
// Merge method only
return
MA
LL
_USER_START
;
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_MERGE
)
mall_conf
->
times
->
async_end
=
MPI_Wtime
();
// Merge method only
return
MA
M_I
_USER_START
;
}
...
...
@@ -1115,7 +1115,7 @@ void* thread_async_work() {
for
(
i
=
0
;
i
<
rep_a_data
->
entries
;
i
++
)
{
MPI_Bcast
(
rep_a_data
->
arrays
[
i
],
rep_a_data
->
qty
[
i
],
rep_a_data
->
types
[
i
],
mall
->
root_collectives
,
mall
->
intercomm
);
}
comm_state
=
MA
LL
_DIST_COMPLETED
;
comm_state
=
MA
M_I
_DIST_COMPLETED
;
pthread_exit
(
NULL
);
}
...
...
Codes/malleability/distribution_methods/Distributed_CommDist.c
View file @
33fb8b86
...
...
@@ -77,8 +77,8 @@ void sync_communication(void *send, void **recv, int qty, MPI_Datatype datatype,
/* PERFORM COMMUNICATION */
switch
(
mall_conf
->
red_method
)
{
case
MA
LL
_RED_RMA_LOCKALL
:
case
MA
LL
_RED_RMA_LOCK
:
case
MA
M
_RED_RMA_LOCKALL
:
case
MA
M
_RED_RMA_LOCK
:
if
(
is_children_group
)
{
dist_data
.
tamBl
=
0
;
}
else
{
...
...
@@ -87,10 +87,10 @@ void sync_communication(void *send, void **recv, int qty, MPI_Datatype datatype,
sync_rma
(
send
,
*
recv
,
datatype
,
r_counts
,
dist_data
.
tamBl
,
comm
);
break
;
case
MA
LL
_RED_POINT
:
case
MA
M
_RED_POINT
:
sync_point2point
(
send
,
*
recv
,
datatype
,
s_counts
,
r_counts
,
comm
);
break
;
case
MA
LL
_RED_BASELINE
:
case
MA
M
_RED_BASELINE
:
default:
MPI_Alltoallv
(
send
,
s_counts
.
counts
,
s_counts
.
displs
,
datatype
,
*
recv
,
r_counts
.
counts
,
r_counts
.
displs
,
datatype
,
comm
);
break
;
...
...
@@ -122,7 +122,7 @@ void sync_point2point(void *send, void *recv, MPI_Datatype datatype, struct Coun
MPI_Type_size
(
datatype
,
&
datasize
);
init
=
s_counts
.
idI
;
end
=
s_counts
.
idE
;
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_MERGE
&&
(
s_counts
.
idI
==
mall
->
myId
||
s_counts
.
idE
==
mall
->
myId
+
1
))
{
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_MERGE
&&
(
s_counts
.
idI
==
mall
->
myId
||
s_counts
.
idE
==
mall
->
myId
+
1
))
{
offset
=
s_counts
.
displs
[
mall
->
myId
]
*
datasize
;
offset2
=
r_counts
.
displs
[
mall
->
myId
]
*
datasize
;
memcpy
(
recv
+
offset2
,
send
+
offset
,
s_counts
.
counts
[
mall
->
myId
]);
...
...
@@ -145,7 +145,7 @@ void sync_point2point(void *send, void *recv, MPI_Datatype datatype, struct Coun
init
=
r_counts
.
idI
;
end
=
r_counts
.
idE
;
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_MERGE
)
{
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_MERGE
)
{
if
(
r_counts
.
idI
==
mall
->
myId
)
init
=
r_counts
.
idI
+
1
;
else
if
(
r_counts
.
idE
==
mall
->
myId
+
1
)
end
=
r_counts
.
idE
-
1
;
}
...
...
@@ -190,10 +190,10 @@ void sync_rma(void *send, void *recv, MPI_Datatype datatype, struct Counts r_cou
DEBUG_FUNC
(
"Created Window for synchronous RMA communication"
,
mall
->
myId
,
mall
->
numP
);
fflush
(
stdout
);
MPI_Barrier
(
comm
);
#endif
switch
(
mall_conf
->
red_method
)
{
case
MA
LL
_RED_RMA_LOCKALL
:
case
MA
M
_RED_RMA_LOCKALL
:
sync_rma_lockall
(
recv
,
datatype
,
r_counts
,
win
);
break
;
case
MA
LL
_RED_RMA_LOCK
:
case
MA
M
_RED_RMA_LOCK
:
sync_rma_lock
(
recv
,
datatype
,
r_counts
,
win
);
break
;
}
...
...
@@ -293,8 +293,8 @@ void async_communication_start(void *send, void **recv, int qty, MPI_Datatype da
/* PERFORM COMMUNICATION */
switch
(
mall_conf
->
red_method
)
{
case
MA
LL
_RED_RMA_LOCKALL
:
case
MA
LL
_RED_RMA_LOCK
:
case
MA
M
_RED_RMA_LOCKALL
:
case
MA
M
_RED_RMA_LOCK
:
if
(
is_children_group
)
{
dist_data
.
tamBl
=
0
;
}
else
{
...
...
@@ -302,10 +302,10 @@ void async_communication_start(void *send, void **recv, int qty, MPI_Datatype da
}
async_rma
(
send
,
*
recv
,
datatype
,
r_counts
,
dist_data
.
tamBl
,
comm
,
*
requests
,
win
);
break
;
case
MA
LL
_RED_POINT
:
case
MA
M
_RED_POINT
:
async_point2point
(
send
,
*
recv
,
datatype
,
s_counts
,
r_counts
,
comm
,
*
requests
);
break
;
case
MA
LL
_RED_BASELINE
:
case
MA
M
_RED_BASELINE
:
default:
MPI_Ialltoallv
(
send
,
s_counts
.
counts
,
s_counts
.
displs
,
datatype
,
*
recv
,
r_counts
.
counts
,
r_counts
.
displs
,
datatype
,
comm
,
&
((
*
requests
)[
0
]));
break
;
...
...
@@ -376,7 +376,7 @@ void async_communication_end(MPI_Request *requests, size_t request_qty, MPI_Win
//ha terminado, aunque solo se pueda llegar a este punto cuando ha terminado
if
(
MAM_Contains_strat
(
MAM_RED_STRATEGIES
,
MAM_STRAT_RED_WAIT_TARGETS
,
NULL
))
{
MPI_Waitall
(
request_qty
,
requests
,
MPI_STATUSES_IGNORE
);
}
if
((
mall_conf
->
red_method
==
MA
LL
_RED_RMA_LOCKALL
||
mall_conf
->
red_method
==
MA
LL
_RED_RMA_LOCK
)
if
((
mall_conf
->
red_method
==
MA
M
_RED_RMA_LOCKALL
||
mall_conf
->
red_method
==
MA
M
_RED_RMA_LOCK
)
&&
*
win
!=
MPI_WIN_NULL
)
{
MPI_Win_free
(
win
);
}
}
...
...
@@ -434,10 +434,10 @@ void async_rma(void *send, void *recv, MPI_Datatype datatype, struct Counts r_co
MPI_Type_size
(
datatype
,
&
datasize
);
MPI_Win_create
(
send
,
(
MPI_Aint
)
tamBl
*
datasize
,
datasize
,
MPI_INFO_NULL
,
comm
,
win
);
switch
(
mall_conf
->
red_method
)
{
case
MA
LL
_RED_RMA_LOCKALL
:
case
MA
M
_RED_RMA_LOCKALL
:
async_rma_lockall
(
recv
,
datatype
,
r_counts
,
*
win
,
requests
);
break
;
case
MA
LL
_RED_RMA_LOCK
:
case
MA
M
_RED_RMA_LOCK
:
async_rma_lock
(
recv
,
datatype
,
r_counts
,
*
win
,
requests
);
break
;
}
...
...
@@ -526,7 +526,7 @@ void prepare_redistribution(int qty, MPI_Datatype datatype, int numP, int numO,
int
datasize
;
struct
Dist_data
dist_data
;
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_BASELINE
)
{
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_BASELINE
)
{
offset_ids
=
MAM_Contains_strat
(
MAM_SPAWN_STRATEGIES
,
MAM_STRAT_SPAWN_INTERCOMM
,
NULL
)
?
0
:
numP
;
}
else
{
...
...
@@ -555,7 +555,7 @@ void prepare_redistribution(int qty, MPI_Datatype datatype, int numP, int numO,
#endif
prepare_comm_alltoall
(
mall
->
myId
,
numP
,
numO
,
qty
,
offset_ids
,
s_counts
);
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_MERGE
&&
mall
->
myId
<
numO
)
{
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_MERGE
&&
mall
->
myId
<
numO
)
{
prepare_comm_alltoall
(
mall
->
myId
,
numO
,
numP
,
qty
,
offset_ids
,
r_counts
);
// Obtener distribución para este hijo y reservar vector de recibo
get_block_dist
(
qty
,
mall
->
myId
,
numO
,
&
dist_data
);
...
...
@@ -587,10 +587,10 @@ void check_requests(struct Counts s_counts, struct Counts r_counts, MPI_Request
MPI_Request
*
aux
;
switch
(
mall_conf
->
red_method
)
{
case
MA
LL
_RED_BASELINE
:
case
MA
M
_RED_BASELINE
:
sum
=
1
;
break
;
case
MA
LL
_RED_POINT
:
case
MA
M
_RED_POINT
:
default:
sum
=
(
size_t
)
s_counts
.
idE
-
s_counts
.
idI
;
sum
+=
(
size_t
)
r_counts
.
idE
-
r_counts
.
idI
;
...
...
Codes/malleability/spawn_methods/Baseline.c
View file @
33fb8b86
...
...
@@ -36,7 +36,7 @@ int baseline(Spawn_data spawn_data, MPI_Comm *child) { //TODO Tratamiento de err
if
(
spawn_data
.
spawn_is_single
)
{
single_strat_children
(
child
);
}
}
return
MA
LL
_SPAWN_COMPLETED
;
return
MA
M_I
_SPAWN_COMPLETED
;
}
//--------------PRIVATE FUNCTIONS---------------//
...
...
@@ -198,7 +198,7 @@ void single_strat_parents(Spawn_data spawn_data, MPI_Comm *child) {
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
(
MA
LL
_SPAWN_SINGLE_COMPLETED
,
spawn_data
.
spawn_is_async
);
// Indicate other processes to join root to end spawn procedure
set_spawn_state
(
MA
M_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
);
...
...
Codes/malleability/spawn_methods/GenericSpawn.c
View file @
33fb8b86
...
...
@@ -50,7 +50,7 @@ void* thread_work(void *args);
* Si se pide en segundo plano, llamar a "check_spawn_state()" comprobara si la configuracion para
* crearlos esta lista, y si es asi, los crea.
*
* Devuelve el estado de el procedimiento. Si no devuelve "MA
LL
_SPAWN_COMPLETED", es necesario llamar a
* Devuelve el estado de el procedimiento. Si no devuelve "MA
M_I
_SPAWN_COMPLETED", es necesario llamar a
* "check_spawn_state()".
*/
int
init_spawn
(
MPI_Comm
comm
,
MPI_Comm
*
child
)
{
...
...
@@ -58,16 +58,16 @@ int init_spawn(MPI_Comm comm, MPI_Comm *child) {
set_spawn_configuration
(
comm
);
if
(
!
spawn_data
->
spawn_is_async
)
{
generic_spawn
(
child
,
MA
LL
_NOT_STARTED
);
generic_spawn
(
child
,
MA
M_I
_NOT_STARTED
);
local_state
=
get_spawn_state
(
spawn_data
->
spawn_is_async
);
if
(
local_state
==
MA
LL
_SPAWN_COMPLETED
)
if
(
local_state
==
MA
M_I
_SPAWN_COMPLETED
)
deallocate_spawn_data
();
}
else
{
local_state
=
spawn_data
->
spawn_is_single
?
MA
LL
_SPAWN_SINGLE_PENDING
:
MA
LL
_SPAWN_PENDING
;
local_state
=
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_MERGE
&&
spawn_data
->
initial_qty
>
spawn_data
->
target_qty
?
MA
LL
_SPAWN_ADAPT_POSTPONE
:
local_state
;
MA
M_I
_SPAWN_SINGLE_PENDING
:
MA
M_I
_SPAWN_PENDING
;
local_state
=
mall_conf
->
spawn_method
==
MA
M
_SPAWN_MERGE
&&
spawn_data
->
initial_qty
>
spawn_data
->
target_qty
?
MA
M_I
_SPAWN_ADAPT_POSTPONE
:
local_state
;
set_spawn_state
(
local_state
,
0
);
if
((
spawn_data
->
spawn_is_single
&&
mall
->
myId
==
mall
->
root
)
||
!
spawn_data
->
spawn_is_single
)
{
allocate_thread_spawn
(
child
);
...
...
@@ -83,18 +83,18 @@ int init_spawn(MPI_Comm comm, MPI_Comm *child) {
*/
int
check_spawn_state
(
MPI_Comm
*
child
,
MPI_Comm
comm
,
int
wait_completed
)
{
int
local_state
;
int
global_state
=
MA
LL
_NOT_STARTED
;
int
global_state
=
MA
M_I
_NOT_STARTED
;
if
(
spawn_data
->
spawn_is_async
)
{
// Async
local_state
=
get_spawn_state
(
spawn_data
->
spawn_is_async
);
if
(
local_state
==
MA
LL
_SPAWN_SINGLE_PENDING
||
local_state
==
MA
LL
_SPAWN_SINGLE_COMPLETED
)
{
// Single
if
(
local_state
==
MA
M_I
_SPAWN_SINGLE_PENDING
||
local_state
==
MA
M_I
_SPAWN_SINGLE_COMPLETED
)
{
// Single
global_state
=
check_single_state
(
comm
,
child
,
local_state
,
wait_completed
);
}
else
if
(
local_state
==
MA
LL
_SPAWN_PENDING
||
local_state
==
MA
LL
_SPAWN_COMPLETED
||
local_state
==
MA
LL
_SPAWN_ADAPTED
)
{
// Generic
}
else
if
(
local_state
==
MA
M_I
_SPAWN_PENDING
||
local_state
==
MA
M_I
_SPAWN_COMPLETED
||
local_state
==
MA
M_I
_SPAWN_ADAPTED
)
{
// Generic
global_state
=
check_generic_state
(
comm
,
local_state
,
wait_completed
);
}
else
if
(
local_state
==
MA
LL
_SPAWN_ADAPT_POSTPONE
)
{
}
else
if
(
local_state
==
MA
M_I
_SPAWN_ADAPT_POSTPONE
)
{
global_state
=
local_state
;
}
else
{
...
...
@@ -102,18 +102,18 @@ int check_spawn_state(MPI_Comm *child, MPI_Comm comm, int wait_completed) {
MPI_Abort
(
MPI_COMM_WORLD
,
-
1
);
return
-
10
;
}
}
else
if
(
mall_conf
->
spawn_method
==
MA
LL
_SPAWN_MERGE
){
// Start Merge shrink Sync
generic_spawn
(
child
,
MA
LL
_DIST_COMPLETED
);
}
else
if
(
mall_conf
->
spawn_method
==
MA
M
_SPAWN_MERGE
){
// Start Merge shrink Sync
generic_spawn
(
child
,
MA
M_I
_DIST_COMPLETED
);
global_state
=
get_spawn_state
(
spawn_data
->
spawn_is_async
);
}
if
(
global_state
==
MA
LL
_SPAWN_COMPLETED
||
global_state
==
MA
LL
_SPAWN_ADAPTED
)
if
(
global_state
==
MA
M_I
_SPAWN_COMPLETED
||
global_state
==
MA
M_I
_SPAWN_ADAPTED
)
deallocate_spawn_data
();
return
global_state
;
}
/*
* Elimina la bandera bloqueante MA
LL
_SPAWN_ADAPT_POSTPONE para los hilos
* Elimina la bandera bloqueante MA
M_I
_SPAWN_ADAPT_POSTPONE para los hilos
* auxiliares. Esta bandera los bloquea para que el metodo Merge shrink no
* avance hasta que se complete la redistribucion de datos. Por tanto,
* al modificar la bandera los hilos pueden continuar.
...
...
@@ -123,8 +123,8 @@ int check_spawn_state(MPI_Comm *child, MPI_Comm comm, int wait_completed) {
*/
void
unset_spawn_postpone_flag
(
int
outside_state
)
{
int
local_state
=
get_spawn_state
(
spawn_data
->
spawn_is_async
);
if
(
local_state
==
MA
LL
_SPAWN_ADAPT_POSTPONE
&&
outside_state
==
MA
LL
_SPAWN_ADAPT_PENDING
&&
spawn_data
->
spawn_is_async
)
{
set_spawn_state
(
MA
LL
_SPAWN_PENDING
,
spawn_data
->
spawn_is_async
);
if
(
local_state
==
MA
M_I
_SPAWN_ADAPT_POSTPONE
&&
outside_state
==
MA
M_I
_SPAWN_ADAPT_PENDING
&&
spawn_data
->
spawn_is_async
)
{
set_spawn_state
(
MA
M_I
_SPAWN_PENDING
,
spawn_data
->
spawn_is_async
);
wakeup_redistribution
();
}
}
...
...
@@ -149,16 +149,16 @@ void malleability_connect_children(MPI_Comm *parents) {
MAM_Contains_strat
(
MAM_SPAWN_STRATEGIES
,
MAM_STRAT_SPAWN_MULTIPLE
,
&
(
spawn_data
->
spawn_is_multiple
));
switch
(
mall_conf
->
spawn_method
)
{
case
MA
LL
_SPAWN_BASELINE
:
case
MA
M
_SPAWN_BASELINE
:
spawn_data
->
spawn_qty
=
spawn_data
->
target_qty
;
baseline
(
*
spawn_data
,
parents
);
if
(
!
spawn_data
->
spawn_is_intercomm
)
{
intracomm_strategy
(
MAM_TARGETS
,
parents
);
}
break
;
case
MA
LL
_SPAWN_MERGE
:
case
MA
M
_SPAWN_MERGE
:
spawn_data
->
spawn_qty
=
spawn_data
->
target_qty
-
spawn_data
->
initial_qty
;
merge
(
*
spawn_data
,
parents
,
MA
LL
_NOT_STARTED
);
merge
(
*
spawn_data
,
parents
,
MA
M_I
_NOT_STARTED
);
break
;
}
free
(
spawn_data
);
...
...
@@ -180,15 +180,15 @@ void set_spawn_configuration(MPI_Comm comm) {
MAM_Contains_strat
(
MAM_SPAWN_STRATEGIES
,
MAM_STRAT_SPAWN_INTERCOMM
,
&
(
spawn_data
->
spawn_is_intercomm
));
MAM_Contains_strat
(
MAM_SPAWN_STRATEGIES
,
MAM_STRAT_SPAWN_MULTIPLE
,
&
(
spawn_data
->
spawn_is_multiple
));
spawn_data
->
comm
=
comm
;
spawn_data
->
mapping_fill_method
=
MA
LL_DIST
_STRING
;
spawn_data
->
mapping_fill_method
=
MA
M_PHY_TYPE
_STRING
;
spawn_data
->
sets
=
NULL
;
switch
(
mall_conf
->
spawn_method
)
{
case
MA
LL
_SPAWN_BASELINE
:
case
MA
M
_SPAWN_BASELINE
:
spawn_data
->
spawn_qty
=
spawn_data
->
target_qty
;
spawn_data
->
already_created
=
0
;
break
;
case
MA
LL
_SPAWN_MERGE
:
case
MA
M
_SPAWN_MERGE
:
spawn_data
->
spawn_qty
=
spawn_data
->
target_qty
-
spawn_data
->
initial_qty
;
spawn_data
->
already_created
=
spawn_data
->
initial_qty
;
break
;
...
...
@@ -245,19 +245,19 @@ void generic_spawn(MPI_Comm *child, int data_stage) {
processes_dist
(
spawn_data
);
}
switch
(
mall_conf
->
spawn_method
)
{
case
MA
LL
_SPAWN_BASELINE
:
case
MA
M
_SPAWN_BASELINE
:
local_state
=
baseline
(
*
spawn_data
,
child
);
if
(
!
spawn_data
->
spawn_is_intercomm
)
{
local_state
=
intracomm_strategy
(
MAM_SOURCES
,
child
);
}
break
;
case
MA
LL
_SPAWN_MERGE
:
case
MA
M
_SPAWN_MERGE
:
local_state
=
merge
(
*
spawn_data
,
child
,
data_stage
);
break
;
}
// END WORK
aux_state
=
get_spawn_state
(
spawn_data
->
spawn_is_async
);
if
(
!
(
aux_state
==
MA
LL
_SPAWN_PENDING
&&
local_state
==
MA
LL
_SPAWN_ADAPT_POSTPONE
))
{
if
(
!
(
aux_state
==
MA
M_I
_SPAWN_PENDING
&&
local_state
==
MA
M_I
_SPAWN_ADAPT_POSTPONE
))
{
set_spawn_state
(
local_state
,
spawn_data
->
spawn_is_async
);
}
}
...
...
@@ -295,14 +295,14 @@ void* thread_work(void *args) {
int
local_state
;
MPI_Comm
*
child
=
(
MPI_Comm
*
)
args
;
generic_spawn
(
child
,
MA
LL
_NOT_STARTED
);
generic_spawn
(
child
,
MA
M_I
_NOT_STARTED
);
local_state
=
get_spawn_state
(
spawn_data
->
spawn_is_async
);
if
(
local_state
==
MA
LL
_SPAWN_ADAPT_POSTPONE
||
local_state
==
MA
LL
_SPAWN_PENDING
)
{
if
(
local_state
==
MA
M_I
_SPAWN_ADAPT_POSTPONE
||
local_state
==
MA
M_I
_SPAWN_PENDING
)
{
// El grupo de procesos se terminara de juntar tras la redistribucion de datos
local_state
=
wait_redistribution
();
generic_spawn
(
child
,
MA
LL
_DIST_COMPLETED
);
generic_spawn
(
child
,
MA
M_I
_DIST_COMPLETED
);
}
wakeup_completion
();
...
...
@@ -313,22 +313,22 @@ void* thread_work(void *args) {
* Comprueba si una creacion de procesos asincrona en el
* paso "single" ha terminado.
* Si no ha terminado se mantiene el estado
* "MA
LL
_SPAWN_SINGLE_PENDING".
* "MA
M_I
_SPAWN_SINGLE_PENDING".
*
* Si ha terminado se crean los hilos auxiliares para
* los procesos no root y se devuelve el estado
* "MA
LL
_SPAWN_PENDING".
* "MA
M_I
_SPAWN_PENDING".
*/
int
check_single_state
(
MPI_Comm
comm
,
MPI_Comm
*
child
,
int
global_state
,
int
wait_completed
)
{
while
(
wait_completed
&&
mall
->
myId
==
mall
->
root
&&
global_state
==
MA
LL
_SPAWN_SINGLE_PENDING
)
{
while
(
wait_completed
&&
mall
->
myId
==
mall
->
root
&&
global_state
==
MA
M_I
_SPAWN_SINGLE_PENDING
)
{
global_state
=
wait_completion
();
}
MPI_Bcast
(
&
global_state
,
1
,
MPI_INT
,
mall
->
root
,
comm
);
// Non-root processes join root to finalize the spawn
// They also must join if the application has ended its work
if
(
global_state
==
MA
LL
_SPAWN_SINGLE_COMPLETED
)
{
global_state
=
MA
LL
_SPAWN_PENDING
;
if
(
global_state
==
MA
M_I
_SPAWN_SINGLE_COMPLETED
)
{
global_state
=
MA
M_I
_SPAWN_PENDING
;
set_spawn_state
(
global_state
,
spawn_data
->
spawn_is_async
);
if
(
mall
->
myId
!=
mall
->
root
)
{
...
...
@@ -342,18 +342,18 @@ int check_single_state(MPI_Comm comm, MPI_Comm *child, int global_state, int wai
* Comprueba si una creación de procesos asincrona en el
* paso "generic" ha terminado.
* Si no ha terminado devuelve el estado
* "MA
LL
_SPAWN_PENDING".
* "MA
M_I
_SPAWN_PENDING".
*
* Si ha terminado libera la memoria asociada a spawn_data
* y devuelve el estado "MA
LL
_SPAWN_COMPLETED".
* y devuelve el estado "MA
M_I
_SPAWN_COMPLETED".
*/
int
check_generic_state
(
MPI_Comm
comm
,
int
local_state
,
int
wait_completed
)
{
int
global_state
;
while
(
wait_completed
&&
local_state
==
MA
LL
_SPAWN_PENDING
)
local_state
=
wait_completion
();
while
(
wait_completed
&&
local_state
==
MA
M_I
_SPAWN_PENDING
)
local_state
=
wait_completion
();
MPI_Allreduce
(
&
local_state
,
&
global_state
,
1
,
MPI_INT
,
MPI_MIN
,
comm
);
if
(
global_state
==
MA
LL
_SPAWN_COMPLETED
||
global_state
==
MA
LL
_SPAWN_ADAPTED
)
{
if
(
global_state
==
MA
M_I
_SPAWN_COMPLETED
||
global_state
==
MA
M_I
_SPAWN_ADAPTED
)
{
set_spawn_state
(
global_state
,
spawn_data
->
spawn_is_async
);
}
return
global_state
;
...
...
Codes/malleability/spawn_methods/Merge.c
View file @
33fb8b86
...
...
@@ -17,11 +17,11 @@ int merge(Spawn_data spawn_data, MPI_Comm *child, int data_state) {
int
is_children_group
=
1
;
if
(
spawn_data
.
initial_qty
>
spawn_data
.
target_qty
)
{
//Shrink
if
(
data_state
==
MA
LL
_DIST_COMPLETED
)
{
if
(
data_state
==
MA
M_I
_DIST_COMPLETED
)
{
merge_adapt_shrink
(
spawn_data
.
target_qty
,
child
,
spawn_data
.
comm
,
mall
->
myId
);
local_state
=
MA
LL
_SPAWN_ADAPTED
;
local_state
=
MA
M_I
_SPAWN_ADAPTED
;
}
else
{
local_state
=
MA
LL
_SPAWN_ADAPT_POSTPONE
;
local_state
=
MA
M_I
_SPAWN_ADAPT_POSTPONE
;
}
}
else
{
//Expand
MPI_Comm_get_parent
(
&
intercomm
);
...
...
@@ -30,7 +30,7 @@ int merge(Spawn_data spawn_data, MPI_Comm *child, int data_state) {
baseline
(
spawn_data
,
child
);
merge_adapt_expand
(
child
,
is_children_group
);
local_state
=
MA
LL
_SPAWN_COMPLETED
;
local_state
=
MA
M_I
_SPAWN_COMPLETED
;
}
return
local_state
;
...
...
@@ -38,7 +38,7 @@ int merge(Spawn_data spawn_data, MPI_Comm *child, int data_state) {
int
intracomm_strategy
(
int
is_children_group
,
MPI_Comm
*
child
)
{
merge_adapt_expand
(
child
,
is_children_group
);
return
MA
LL
_SPAWN_COMPLETED
;
return
MA
M_I
_SPAWN_COMPLETED
;
}
//--------------PRIVATE MERGE TYPE FUNCTIONS---------------//
...
...
Codes/malleability/spawn_methods/ProcessDist.c
View file @
33fb8b86
...
...
@@ -54,7 +54,7 @@ void processes_dist(Spawn_data *spawn_data) {
spawn_data
->
sets
=
(
Spawn_set
*
)
malloc
(
spawn_data
->
total_spawns
*
sizeof
(
Spawn_set
));
#if USE_MAL_SLURM
switch
(
spawn_data
->
mapping_fill_method
)
{
case
MA
LL_DIST
_STRING
:
case
MA
M_PHY_TYPE
_STRING
:
// if(MAM_Contains_strat(MAM_SPAWN_STRATEGIES, MAM_STRAT_SPAWN_MULTIPLE, NULL) ) {
if
(
spawn_data
->
spawn_is_multiple
)
{
generate_multiple_info_string_slurm
(
mall
->
nodelist
,
procs_array
,
used_nodes
,
spawn_data
);
...
...
@@ -62,7 +62,7 @@ void processes_dist(Spawn_data *spawn_data) {
generate_info_string_slurm
(
mall
->
nodelist
,
procs_array
,
used_nodes
,
spawn_data
);
}
break
;
case
MA
LL_DIST
_HOSTFILE
:
// FIXME Does not consider multiple spawn strat
case
MA
M_PHY_TYPE
_HOSTFILE
:
// FIXME Does not consider multiple spawn strat
generate_info_hostfile_slurm
(
mall
->
nodelist
,
procs_array
,
used_nodes
,
spawn_data
);
break
;
}
...
...
@@ -98,10 +98,10 @@ void node_dist(Spawn_data spawn_data, int **qty, int *used_nodes, int *total_spa
/* GET NEW DISTRIBUTION */
switch
(
mall_conf
->
spawn_dist
)
{
case
MA
LL
_DIST_SPREAD
:
// DIST NODES @deprecated
case
MA
M_PHY
_DIST_SPREAD
:
// DIST NODES @deprecated
spread_dist
(
spawn_data
,
used_nodes
,
procs
);
break
;
case
MA
LL
_DIST_COMPACT
:
// DIST CPUs
case
MA
M_PHY
_DIST_COMPACT
:
// DIST CPUs
compact_dist
(
spawn_data
,
used_nodes
,
procs
);
break
;
}
...
...
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