Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove a global variable, and use a static to remember if smpi_main is running.
[simgrid.git] / src / smpi / include / private.hpp
index fb1f518..e663ba5 100644 (file)
@@ -29,6 +29,7 @@ constexpr unsigned MPI_REQ_COMPLETE       = 0x1000;
 constexpr unsigned MPI_REQ_BSEND          = 0x2000;
 constexpr unsigned MPI_REQ_MATCHED        = 0x4000;
 constexpr unsigned MPI_REQ_CANCELLED      = 0x8000;
+constexpr unsigned MPI_REQ_NBC            = 0x10000;
 
 enum class SmpiProcessState { UNINITIALIZED, INITIALIZING, INITIALIZED /*(=MPI_Init called)*/, FINALIZED };
 
@@ -83,6 +84,8 @@ XBT_PRIVATE void smpi_deployment_unregister_process(const std::string& instance_
 
 XBT_PRIVATE MPI_Comm* smpi_deployment_comm_world(const std::string& instance_id);
 XBT_PRIVATE void smpi_deployment_cleanup_instances();
+XBT_PRIVATE int smpi_deployment_smpirun(simgrid::s4u::Engine* e, const std::string& hostfile, int np,
+                                        const std::string& replayfile, int map, int argc, char* argv[]);
 
 XBT_PRIVATE void smpi_comm_copy_buffer_callback(simgrid::kernel::activity::CommImpl* comm, void* buff,
                                                 size_t buff_size);
@@ -114,10 +117,12 @@ XBT_PRIVATE double smpi_cfg_auto_shared_malloc_thresh();
 XBT_PRIVATE bool smpi_cfg_display_alloc();
 
 // utilities
+XBT_PRIVATE void smpi_init_options_internal(bool called_by_smpi_main);
+
 extern XBT_PRIVATE char* smpi_data_exe_start; // start of the data+bss segment of the executable
-extern XBT_PRIVATE int smpi_data_exe_size;    // size of the data+bss segment of the executable
+extern XBT_PRIVATE size_t smpi_data_exe_size; // size of the data+bss segment of the executable
 
-XBT_PRIVATE void smpi_switch_data_segment(simgrid::s4u::ActorPtr actor);
+XBT_PRIVATE bool smpi_switch_data_segment(simgrid::s4u::ActorPtr actor, const void* addr = nullptr);
 
 XBT_PRIVATE void smpi_prepare_global_memory_segment();
 XBT_PRIVATE void smpi_backup_global_memory_segment();
@@ -128,6 +133,16 @@ XBT_PRIVATE void smpi_bench_end();
 XBT_PRIVATE void smpi_shared_destroy();
 XBT_PRIVATE double smpi_adjust_comp_speed();
 
+// This helper class uses RAII to call smpi_bench_end() when an object is built, and have smpi_bench_begin() be called
+// automatically when going out of scope.
+class XBT_PRIVATE SmpiBenchGuard {
+public:
+  SmpiBenchGuard() { smpi_bench_end(); }
+  SmpiBenchGuard(const SmpiBenchGuard&) = delete;
+  SmpiBenchGuard& operator=(const SmpiBenchGuard&) = delete;
+  ~SmpiBenchGuard() { smpi_bench_begin(); }
+};
+
 XBT_PRIVATE unsigned char* smpi_get_tmp_sendbuffer(size_t size);
 XBT_PRIVATE unsigned char* smpi_get_tmp_recvbuffer(size_t size);
 XBT_PRIVATE void smpi_free_tmp_buffer(const unsigned char* buf);
@@ -494,7 +509,6 @@ struct s_smpi_privatization_region_t {
 };
 using smpi_privatization_region_t = s_smpi_privatization_region_t*;
 
-extern XBT_PRIVATE int smpi_loaded_page;
 XBT_PRIVATE smpi_privatization_region_t smpi_init_global_memory_segment_process();
 
 /**
@@ -531,13 +545,13 @@ XBT_PRIVATE void private_execute_flops(double flops);
     }\
   }
 
-#define CHECK_INIT\
-  {\
-    int init_flag=0;\
-    PMPI_Initialized(&init_flag);\
-    CHECK_ARGS((!init_flag), MPI_ERR_OTHER, "%s: MPI_Init was not called !", __func__)\
-    PMPI_Finalized(&init_flag);\
-    CHECK_ARGS((init_flag), MPI_ERR_OTHER, "%s: MPI_Finalize was already called !", __func__)\
+#define CHECK_INIT                                                                                                     \
+  {                                                                                                                    \
+    int init_flag = 0;                                                                                                 \
+    PMPI_Initialized(&init_flag);                                                                                      \
+    CHECK_ARGS(not init_flag, MPI_ERR_OTHER, "%s: MPI_Init was not called !", __func__)                                \
+    PMPI_Finalized(&init_flag);                                                                                        \
+    CHECK_ARGS(init_flag, MPI_ERR_OTHER, "%s: MPI_Finalize was already called !", __func__)                            \
   }
 
 #define CHECK_MPI_NULL(num, val, err, ptr)\