summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0824862)
This commit breaks the following tests:
The following tests FAILED:
181 - smpi-msg-masterslave-thread (Failed)
182 - smpi-msg-masterslave-ucontext (Failed)
183 - smpi-msg-masterslave-raw (Failed)
To fix this, many more changes will be required. This will be done in
the next commit. This commit is just there to make sure changes
remain easily understandable (by having small, easy-to-read commits).
I changed the following:
- Remove variable index_to_process_data
- Make process_data a map instead of an array.
- Remove the "index" variable for SMPI instances (no longer needed)
And cleanup the mess that comes with these changes (delete/free, ...)
#endif
extern std::unordered_map<std::string, double> location2speedup;
#endif
extern std::unordered_map<std::string, double> location2speedup;
+// TODO: Move this to the right location (if we keep this...)
+void smpi_add_process(int adjusted_proc_id);
/** @brief Returns the last call location (filename, linenumber). Process-specific. */
extern "C" {
/** @brief Returns the last call location (filename, linenumber). Process-specific. */
extern "C" {
: name(name)
, size(max_no_processes)
, present_processes(0)
: name(name)
, size(max_no_processes)
, present_processes(0)
, comm_world(comm)
, finalization_barrier(finalization_barrier)
{
, comm_world(comm)
, finalization_barrier(finalization_barrier)
{
+ int cur_process_count = smpi_process_count();
+ for (int i = 0; i < max_no_processes; i++) {
+ smpi_add_process(cur_process_count + i);
+ }
}
const char* name;
int size;
int present_processes;
}
const char* name;
int size;
int present_processes;
- int index; // Badly named. This should be "no_processes_when_registering" ;)
MPI_Comm comm_world;
msg_bar_t finalization_barrier;
};
MPI_Comm comm_world;
msg_bar_t finalization_barrier;
};
static std::map<std::string, Instance> smpi_instances;
extern int process_count; // How many processes have been allocated over all instances?
static std::map<std::string, Instance> smpi_instances;
extern int process_count; // How many processes have been allocated over all instances?
-extern int* index_to_process_data;
/** \ingroup smpi_simulation
* \brief Registers a running instance of a MPI program.
/** \ingroup smpi_simulation
* \brief Registers a running instance of a MPI program.
void smpi_deployment_register_process(const char* instance_id, int rank, int index)
{
void smpi_deployment_register_process(const char* instance_id, int rank, int index)
{
- if (smpi_instances.empty()) { // no instance registered, we probably used smpirun.
- index_to_process_data[index]=index;
+ if (smpi_instances.empty()) // no instance registered, we probably used smpirun.
Instance& instance = smpi_instances.at(instance_id);
instance.present_processes++;
Instance& instance = smpi_instances.at(instance_id);
instance.present_processes++;
- index_to_process_data[index] = instance.index + rank;
instance.comm_world->group()->set_mapping(index, rank);
}
instance.comm_world->group()->set_mapping(index, rank);
}
#endif
std::unordered_map<std::string, double> location2speedup;
#endif
std::unordered_map<std::string, double> location2speedup;
-static simgrid::smpi::Process** process_data = nullptr;
+static std::map</*process_id*/ int, simgrid::smpi::Process*> process_data;
int process_count = 0;
int smpi_universe_size = 0;
int process_count = 0;
int smpi_universe_size = 0;
-int* index_to_process_data = nullptr;
extern double smpi_total_benched_time;
xbt_os_timer_t global_timer;
/**
extern double smpi_total_benched_time;
xbt_os_timer_t global_timer;
/**
void (*smpi_comm_copy_data_callback) (smx_activity_t, void*, size_t) = &smpi_comm_copy_buffer_callback;
void (*smpi_comm_copy_data_callback) (smx_activity_t, void*, size_t) = &smpi_comm_copy_buffer_callback;
+void smpi_add_process(int smx_process)
+{
+ process_data.insert(
+ std::pair<int, simgrid::smpi::Process*>(smx_process, new simgrid::smpi::Process(smx_process, nullptr)));
+}
+
int smpi_process_count()
{
return process_count;
int smpi_process_count()
{
return process_count;
simgrid::smpi::Process* smpi_process_remote(int index)
{
simgrid::smpi::Process* smpi_process_remote(int index)
{
- return process_data[index_to_process_data[index]];
+ return process_data.at(index);
}
MPI_Comm smpi_process_comm_self(){
}
MPI_Comm smpi_process_comm_self(){
- return process_data != nullptr;
+ return not process_data.empty();
}
void smpi_global_init()
}
void smpi_global_init()
- if (index_to_process_data == nullptr) {
- index_to_process_data = new int[SIMIX_process_count()];
- }
-
- bool smpirun = 0;
if (process_count == 0) { // The program has been dispatched but no other
// SMPI instances have been registered. We're using smpirun.
if (process_count == 0) { // The program has been dispatched but no other
// SMPI instances have been registered. We're using smpirun.
SMPI_app_instance_register(smpi_default_instance_name, nullptr,
SIMIX_process_count()); // This call has a side effect on process_count...
MPI_COMM_WORLD = *smpi_deployment_comm_world(smpi_default_instance_name);
}
smpi_universe_size = process_count;
SMPI_app_instance_register(smpi_default_instance_name, nullptr,
SIMIX_process_count()); // This call has a side effect on process_count...
MPI_COMM_WORLD = *smpi_deployment_comm_world(smpi_default_instance_name);
}
smpi_universe_size = process_count;
- process_data = new simgrid::smpi::Process*[process_count];
- for (int i = 0; i < process_count; i++) {
- if (smpirun) {
- process_data[i] = new simgrid::smpi::Process(i, smpi_deployment_finalization_barrier(smpi_default_instance_name));
- smpi_deployment_register_process(smpi_default_instance_name, i, i);
- } else {
- // TODO We can pass a nullptr here because Process::set_data() assigns the
- // barrier from the instance anyway. This is ugly and should be changed
- process_data[i] = new simgrid::smpi::Process(i, nullptr);
- }
- }
}
void smpi_global_destroy()
}
void smpi_global_destroy()
smpi_bench_destroy();
smpi_shared_destroy();
smpi_deployment_cleanup_instances();
smpi_bench_destroy();
smpi_shared_destroy();
smpi_deployment_cleanup_instances();
- int count = smpi_process_count();
- for (int i = 0; i < count; i++) {
- if(process_data[i]->comm_self()!=MPI_COMM_NULL){
- simgrid::smpi::Comm::destroy(process_data[i]->comm_self());
+ for (auto& pair : process_data) {
+ auto& process = pair.second;
+ if (process->comm_self() != MPI_COMM_NULL) {
+ simgrid::smpi::Comm::destroy(process->comm_self());
- if(process_data[i]->comm_intra()!=MPI_COMM_NULL){
- simgrid::smpi::Comm::destroy(process_data[i]->comm_intra());
+ if (process->comm_intra() != MPI_COMM_NULL) {
+ simgrid::smpi::Comm::destroy(process->comm_intra());
- xbt_os_timer_free(process_data[i]->timer());
- xbt_mutex_destroy(process_data[i]->mailboxes_mutex());
- delete process_data[i];
+ xbt_os_timer_free(process->timer());
+ xbt_mutex_destroy(process->mailboxes_mutex());
- delete[] process_data;
- process_data = nullptr;
if (simgrid::smpi::Colls::smpi_coll_cleanup_callback != nullptr)
simgrid::smpi::Colls::smpi_coll_cleanup_callback();
if (simgrid::smpi::Colls::smpi_coll_cleanup_callback != nullptr)
simgrid::smpi::Colls::smpi_coll_cleanup_callback();
xbt_os_timer_free(global_timer);
}
xbt_os_timer_free(global_timer);
}
- delete[] index_to_process_data;
if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP)
smpi_destroy_global_memory_segments();
smpi_free_static();
if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP)
smpi_destroy_global_memory_segments();
smpi_free_static();
- int count = smpi_process_count();
- for (int i = 0; i < count; i++) {
- if(process_data[i]->return_value()!=0){
- ret=process_data[i]->return_value();//return first non 0 value
+ for (int i = 0, count = smpi_process_count(); i < count; i++) {
+ if (process_data.at(i)->return_value() != 0) {
+ ret = process_data.at(i)->return_value(); // return first non 0 value
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_process, smpi, "Logging specific to SMPI (kernel)");
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_process, smpi, "Logging specific to SMPI (kernel)");
-extern int* index_to_process_data;
-
#define MAILBOX_NAME_MAXLEN (5 + sizeof(int) * 2 + 1)
static char *get_mailbox_name(char *str, int index)
#define MAILBOX_NAME_MAXLEN (5 + sizeof(int) * 2 + 1)
static char *get_mailbox_name(char *str, int index)
/** @brief Check if a process is initialized */
int Process::initialized()
{
/** @brief Check if a process is initialized */
int Process::initialized()
{
- if (index_to_process_data == nullptr){
- return false;
- } else{
- return ((index_ != MPI_UNDEFINED) && (state_ == SMPI_INITIALIZED));
- }
+ // TODO cheinrich: Check if we still need this. This should be a global condition, not for a
+ // single process ... ?
+ return ((index_ != MPI_UNDEFINED) && (state_ == SMPI_INITIALIZED));
}
/** @brief Mark a process as initialized (=MPI_Init called) */
}
/** @brief Mark a process as initialized (=MPI_Init called) */
int index = proc->pid - 1; // The maestro process has always ID 0 but we don't need that process here
int index = proc->pid - 1; // The maestro process has always ID 0 but we don't need that process here
- if(index_to_process_data == nullptr){
- index_to_process_data=static_cast<int*>(xbt_malloc(SIMIX_process_count()*sizeof(int)));
- }
-
char* instance_id = (*argv)[1];
try {
int rank = std::stoi(std::string((*argv)[2]));
char* instance_id = (*argv)[1];
try {
int rank = std::stoi(std::string((*argv)[2]));