A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[SMPI] Use variable instead of 3 calls to the same function
[simgrid.git]
/
src
/
smpi
/
internals
/
smpi_process.cpp
diff --git
a/src/smpi/internals/smpi_process.cpp
b/src/smpi/internals/smpi_process.cpp
index
742af85
..
d341b28
100644
(file)
--- a/
src/smpi/internals/smpi_process.cpp
+++ b/
src/smpi/internals/smpi_process.cpp
@@
-3,21
+3,17
@@
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+#include "smpi_process.hpp"
#include "mc/mc.h"
#include "mc/mc.h"
-#include "src/mc/mc_replay.h"
-#include "src/msg/msg_private.h"
-#include "src/simix/smx_private.h"
-#include "private.h"
#include "private.hpp"
#include "private.hpp"
-#include "smpi_process.hpp"
-#include "smpi_group.hpp"
#include "smpi_comm.hpp"
#include "smpi_comm.hpp"
-
+#include "smpi_group.hpp"
+#include "src/mc/mc_replay.hpp"
+#include "src/msg/msg_private.hpp"
+#include "src/simix/smx_private.hpp"
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)");
-//TODO : replace
-extern simgrid::smpi::Process **process_data;
extern int* index_to_process_data;
#define MAILBOX_NAME_MAXLEN (5 + sizeof(int) * 2 + 1)
extern int* index_to_process_data;
#define MAILBOX_NAME_MAXLEN (5 + sizeof(int) * 2 + 1)
@@
-70,14
+66,15
@@
Process::Process(int index, msg_bar_t finalization_barrier)
void Process::set_data(int index, int* argc, char*** argv)
{
char* instance_id = (*argv)[1];
void Process::set_data(int index, int* argc, char*** argv)
{
char* instance_id = (*argv)[1];
- comm_world_
= smpi_deployment_comm_world(instance_id);
- msg_bar_t bar = smpi_deployment_finalization_barrier(instance_id);
- if (bar
!=nullptr) // don't overwrite the default
one
+ comm_world_ = smpi_deployment_comm_world(instance_id);
+ msg_bar_t bar
= smpi_deployment_finalization_barrier(instance_id);
+ if (bar
!= nullptr) // don't overwrite the current one if the instance has n
one
finalization_barrier_ = bar;
instance_id_ = instance_id;
finalization_barrier_ = bar;
instance_id_ = instance_id;
- index_ = index;
+ index_
= index;
- static_cast<simgrid::msg::ActorExt*>(SIMIX_process_self()->userdata)->data = this;
+ process_ = SIMIX_process_self();
+ static_cast<simgrid::msg::ActorExt*>(process_->userdata)->data = this;
if (*argc > 3) {
memmove(&(*argv)[0], &(*argv)[2], sizeof(char *) * (*argc - 2));
if (*argc > 3) {
memmove(&(*argv)[0], &(*argv)[2], sizeof(char *) * (*argc - 2));
@@
-89,8
+86,7
@@
void Process::set_data(int index, int* argc, char*** argv)
argv_ = argv;
// set the process attached to the mailbox
mailbox_small_->setReceiver(simgrid::s4u::Actor::self());
argv_ = argv;
// set the process attached to the mailbox
mailbox_small_->setReceiver(simgrid::s4u::Actor::self());
- process_ = SIMIX_process_self();
- XBT_DEBUG("<%d> New process in the game: %p", index_, SIMIX_process_self());
+ XBT_DEBUG("<%d> New process in the game: %p", index_, process_);
}
/** @brief Prepares the current process for termination. */
}
/** @brief Prepares the current process for termination. */
@@
-168,6
+164,16
@@
smpi_trace_call_location_t* Process::call_location()
return &trace_call_loc_;
}
return &trace_call_loc_;
}
+void Process::set_privatized_region(smpi_privatization_region_t region)
+{
+ privatized_region_ = region;
+}
+
+smpi_privatization_region_t Process::privatized_region()
+{
+ return privatized_region_;
+}
+
int Process::index()
{
return index_;
int Process::index()
{
return index_;
@@
-264,15
+270,14
@@
void Process::set_return_value(int val){
void Process::init(int *argc, char ***argv){
void Process::init(int *argc, char ***argv){
- if (process_data == nullptr){
- printf("SimGrid was not initialized properly before entering MPI_Init. Aborting, please check compilation process and use smpirun\n");
- exit(1);
+ if (smpi_process_count() == 0) {
+ xbt_die("SimGrid was not initialized properly before entering MPI_Init. Aborting, please check compilation process and use smpirun\n");
}
if (argc != nullptr && argv != nullptr) {
smx_actor_t proc = SIMIX_process_self();
proc->context->set_cleanup(&MSG_process_cleanup_from_SIMIX);
}
if (argc != nullptr && argv != nullptr) {
smx_actor_t proc = SIMIX_process_self();
proc->context->set_cleanup(&MSG_process_cleanup_from_SIMIX);
- int index = proc->pid - 1;
+ 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)));
if(index_to_process_data == nullptr){
index_to_process_data=static_cast<int*>(xbt_malloc(SIMIX_process_count()*sizeof(int)));
@@
-286,14
+291,17
@@
void Process::init(int *argc, char ***argv){
throw std::invalid_argument(std::string("Invalid rank: ") + (*argv)[2]);
}
throw std::invalid_argument(std::string("Invalid rank: ") + (*argv)[2]);
}
+ // cheinrich: I'm not sure what the impact of the SMPI_switch_data_segment on this call is. I moved
+ // this up here so that I can set the privatized region before the switch.
+ Process* process = smpi_process_remote(index);
if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP){
if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP){
- /* Now using
segment index of the
process */
+ /* Now using
the segment index of this
process */
index = proc->segment_index;
index = proc->segment_index;
+ process->set_privatized_region(smpi_init_global_memory_segment_process());
/* Done at the process's creation */
SMPI_switch_data_segment(index);
}
/* Done at the process's creation */
SMPI_switch_data_segment(index);
}
- Process* process = smpi_process_remote(index);
process->set_data(index, argc, argv);
}
xbt_assert(smpi_process(),
process->set_data(index, argc, argv);
}
xbt_assert(smpi_process(),