Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Make state/snapshot comparison work with SMPI variable privatisation
[simgrid.git] / src / smpi / smpi_global.c
1 /* Copyright (c) 2007-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "private.h"
8 #include "smpi_mpi_dt_private.h"
9 #include "mc/mc.h"
10 #include "xbt/replay.h"
11 #include "surf/surf.h"
12 #include "simix/smx_private.h"
13 #include "simgrid/sg_config.h"
14
15 #include <float.h>              /* DBL_MAX */
16 #include <stdint.h>
17 #include <stdio.h>
18 #include <stdlib.h>
19
20 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_kernel, smpi,
21                                 "Logging specific to SMPI (kernel)");
22
23 typedef struct s_smpi_process_data {
24   double simulated;
25   int *argc;
26   char ***argv;
27   smx_rdv_t mailbox;
28   smx_rdv_t mailbox_small;
29   xbt_os_timer_t timer;
30   MPI_Comm comm_self;
31   MPI_Comm* comm_world;
32   void *data;                   /* user data */
33   int index;
34   char state;
35   int sampling;                 /* inside an SMPI_SAMPLE_ block? */
36   char* instance_id;
37   xbt_bar_t finalization_barrier;
38 } s_smpi_process_data_t;
39
40 static smpi_process_data_t *process_data = NULL;
41 int process_count = 0;
42 int* index_to_process_data = NULL;
43
44
45 MPI_Comm MPI_COMM_WORLD = MPI_COMM_UNINITIALIZED;
46 int MPI_UNIVERSE_SIZE;
47
48 MPI_Errhandler *MPI_ERRORS_RETURN = NULL;
49 MPI_Errhandler *MPI_ERRORS_ARE_FATAL = NULL;
50 MPI_Errhandler *MPI_ERRHANDLER_NULL = NULL;
51
52 #define MAILBOX_NAME_MAXLEN (5 + sizeof(int) * 2 + 1)
53
54 static char *get_mailbox_name(char *str, int index)
55 {
56   snprintf(str, MAILBOX_NAME_MAXLEN, "SMPI-%0*x", (int) (sizeof(int) * 2),
57            index);
58   return str;
59 }
60
61 static char *get_mailbox_name_small(char *str, int index)
62 {
63   snprintf(str, MAILBOX_NAME_MAXLEN, "small%0*x", (int) (sizeof(int) * 2),
64            index);
65   return str;
66 }
67
68 void smpi_process_init(int *argc, char ***argv)
69 {
70   int index=-1;
71   smpi_process_data_t data;
72   smx_process_t proc;
73
74   if (argc && argv) {
75     proc = SIMIX_process_self();
76     //FIXME: dirty cleanup method to avoid using msg cleanup functions on these processes when using MSG+SMPI
77     proc->context->cleanup_func=SIMIX_process_cleanup;
78     char* instance_id = (*argv)[1];
79     int rank = atoi((*argv)[2]);
80     index =  SIMIX_process_get_PID(proc) -1;
81
82     if(!index_to_process_data){
83         index_to_process_data=(int*)xbt_malloc(SIMIX_process_count()*sizeof(int));
84     }
85     MPI_Comm* temp_comm_world;
86     xbt_bar_t temp_bar;
87     smpi_deployment_register_process(instance_id, rank, index, &temp_comm_world ,&temp_bar);
88     data = smpi_process_remote_data(index);
89     data->comm_world = temp_comm_world;
90     if(temp_bar != NULL) data->finalization_barrier = temp_bar;
91     data->index = index;
92     data->instance_id = instance_id;
93     xbt_free(simcall_process_get_data(proc));
94     simcall_process_set_data(proc, data);
95     if (*argc > 3) {
96       free((*argv)[1]);
97       free((*argv)[2]);
98       memmove(&(*argv)[1], &(*argv)[3], sizeof(char *) * (*argc - 3));
99       (*argv)[(*argc) - 1] = NULL;
100       (*argv)[(*argc) - 2] = NULL;
101     }
102     (*argc)-=2;
103     data->argc = argc;
104     data->argv = argv;
105     // set the process attached to the mailbox
106     simcall_rdv_set_receiver(data->mailbox_small, proc);
107     XBT_DEBUG("<%d> New process in the game: %p", index, proc);
108
109     if(smpi_privatize_global_variables){
110       switch_data_segment(index);
111     }
112
113   }
114   if (smpi_process_data() == NULL)
115     xbt_die("smpi_process_data() returned NULL. You probably gave a NULL parameter to MPI_Init. Although it's required by MPI-2, this is currently not supported by SMPI.");
116 }
117
118 void smpi_process_destroy(void)
119 {
120   int index = smpi_process_index();
121   if(smpi_privatize_global_variables){
122     switch_data_segment(index);
123   }
124   process_data[index_to_process_data[index]]->state = SMPI_FINALIZED;
125   XBT_DEBUG("<%d> Process left the game", index);
126 }
127
128 /**
129  * @brief Prepares the current process for termination.
130  */
131 void smpi_process_finalize(void)
132 {
133     // This leads to an explosion of the search graph
134     // which cannot be reduced:
135     if(MC_is_active())
136       return;
137
138     int index = smpi_process_index();
139     // wait for all pending asynchronous comms to finish
140     xbt_barrier_wait(process_data[index_to_process_data[index]]->finalization_barrier);
141 }
142
143 /**
144  * @brief Check if a process is finalized
145  */
146 int smpi_process_finalized()
147 {
148   int index = smpi_process_index();
149     if (index != MPI_UNDEFINED)
150       return (process_data[index_to_process_data[index]]->state == SMPI_FINALIZED);
151     else
152       return 0;
153 }
154
155 /**
156  * @brief Check if a process is initialized
157  */
158 int smpi_process_initialized(void)
159 {
160   int index = smpi_process_index();
161   return ( (index != MPI_UNDEFINED)
162           && (process_data[index_to_process_data[index]]->state == SMPI_INITIALIZED));
163 }
164
165 /**
166  * @brief Mark a process as initialized (=MPI_Init called)
167  */
168 void smpi_process_mark_as_initialized(void)
169 {
170   int index = smpi_process_index();
171   if ((index != MPI_UNDEFINED) && (!process_data[index_to_process_data[index]]->state != SMPI_FINALIZED))
172     process_data[index_to_process_data[index]]->state = SMPI_INITIALIZED;
173 }
174
175
176 int smpi_global_size(void)
177 {
178   char *value = getenv("SMPI_GLOBAL_SIZE");
179
180   if (!value) {
181     fprintf(stderr,
182             "Please set env var SMPI_GLOBAL_SIZE to expected number of processes.\n");
183     xbt_abort();
184   }
185   return atoi(value);
186 }
187
188 smpi_process_data_t smpi_process_data(void)
189 {
190   return SIMIX_process_self_get_data(SIMIX_process_self());
191 }
192
193 smpi_process_data_t smpi_process_remote_data(int index)
194 {
195   return process_data[index_to_process_data[index]];
196 }
197
198 void smpi_process_set_user_data(void *data)
199 {
200   smpi_process_data_t process_data = smpi_process_data();
201   process_data->data = data;
202 }
203
204 void *smpi_process_get_user_data()
205 {
206   smpi_process_data_t process_data = smpi_process_data();
207   return process_data->data;
208 }
209
210 int smpi_process_count(void)
211 {
212   return process_count;
213 }
214
215 int smpi_process_index(void)
216 {
217   smpi_process_data_t data = smpi_process_data();
218   //return -1 if not initialized
219   return data ? data->index : MPI_UNDEFINED;
220 }
221
222 int smpi_process_index_of_smx_process(smx_process_t process) {
223   smpi_process_data_t data = SIMIX_process_get_data(process);
224   return data ? data->index : MPI_UNDEFINED;
225 }
226
227 MPI_Comm smpi_process_comm_world(void)
228 {
229   smpi_process_data_t data = smpi_process_data();
230   //return MPI_COMM_NULL if not initialized
231   return data ? *data->comm_world : MPI_COMM_NULL;
232 }
233
234 smx_rdv_t smpi_process_mailbox(void)
235 {
236   smpi_process_data_t data = smpi_process_data();
237   return data->mailbox;
238 }
239
240 smx_rdv_t smpi_process_mailbox_small(void)
241 {
242   smpi_process_data_t data = smpi_process_data();
243   return data->mailbox_small;
244 }
245
246 smx_rdv_t smpi_process_remote_mailbox(int index)
247 {
248   smpi_process_data_t data = smpi_process_remote_data(index);
249   return data->mailbox;
250 }
251
252
253 smx_rdv_t smpi_process_remote_mailbox_small(int index)
254 {
255   smpi_process_data_t data = smpi_process_remote_data(index);
256   return data->mailbox_small;
257 }
258
259 xbt_os_timer_t smpi_process_timer(void)
260 {
261   smpi_process_data_t data = smpi_process_data();
262   return data->timer;
263 }
264
265 void smpi_process_simulated_start(void)
266 {
267   smpi_process_data_t data = smpi_process_data();
268   data->simulated = SIMIX_get_clock();
269 }
270
271 double smpi_process_simulated_elapsed(void)
272 {
273   smpi_process_data_t data = smpi_process_data();
274   return SIMIX_get_clock() - data->simulated;
275 }
276
277 MPI_Comm smpi_process_comm_self(void)
278 {
279   smpi_process_data_t data = smpi_process_data();
280   if(data->comm_self==MPI_COMM_NULL){
281     MPI_Group group = smpi_group_new(1);
282     data->comm_self = smpi_comm_new(group, NULL);
283     smpi_group_set_mapping(group, smpi_process_index(), 0);
284   }
285
286   return data->comm_self;
287 }
288
289 void smpi_process_set_sampling(int s)
290 {
291   smpi_process_data_t data = smpi_process_data();
292   data->sampling = s;
293 }
294
295 int smpi_process_get_sampling(void)
296 {
297   smpi_process_data_t data = smpi_process_data();
298   return data->sampling;
299 }
300
301 void print_request(const char *message, MPI_Request request)
302 {
303   XBT_DEBUG
304       ("%s  request %p  [buf = %p, size = %zu, src = %d, dst = %d, tag = %d, flags = %x]",
305        message, request, request->buf, request->size, request->src,
306        request->dst, request->tag, request->flags);
307 }
308
309 void smpi_comm_copy_buffer_callback(smx_action_t comm,
310                                            void *buff, size_t buff_size)
311 {
312   XBT_DEBUG("Copy the data over");
313   if(_xbt_replay_is_active()) return;
314   void* tmpbuff=buff;
315
316   if((smpi_privatize_global_variables)
317       && ((char*)buff >= start_data_exe)
318       && ((char*)buff < start_data_exe + size_data_exe )
319     ){
320        XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !");
321        switch_data_segment(((smpi_process_data_t)SIMIX_process_get_data(comm->comm.src_proc))->index);
322        tmpbuff = (void*)xbt_malloc(buff_size);
323        memcpy(tmpbuff, buff, buff_size);
324   }
325
326
327   if((smpi_privatize_global_variables)
328       && ((char*)comm->comm.dst_buff >= start_data_exe)
329       && ((char*)comm->comm.dst_buff < start_data_exe + size_data_exe )
330     ){
331        XBT_DEBUG("Privatization : We are copying to a zone inside global memory - Switch data segment");
332        switch_data_segment(((smpi_process_data_t)SIMIX_process_get_data(comm->comm.dst_proc))->index);
333   }
334
335
336   memcpy(comm->comm.dst_buff, tmpbuff, buff_size);
337   if (comm->comm.detached) {
338     // if this is a detached send, the source buffer was duplicated by SMPI
339     // sender to make the original buffer available to the application ASAP
340     xbt_free(buff);
341     //It seems that the request is used after the call there this should
342     //be free somewhereelse  but where???
343     //xbt_free(comm->comm.src_data);// inside SMPI the request is keep
344     //inside the user data and should be free
345     comm->comm.src_buff = NULL;
346   }
347
348   if(tmpbuff!=buff)xbt_free(tmpbuff);
349
350 }
351
352 static void smpi_check_options(){
353   //check correctness of MPI parameters
354
355    xbt_assert(sg_cfg_get_int("smpi/async_small_thres") <=
356               sg_cfg_get_int("smpi/send_is_detached_thres"));
357
358    if (sg_cfg_is_default_value("smpi/running_power")) {
359      XBT_INFO("You did not set the power of the host running the simulation.  "
360               "The timings will certainly not be accurate.  "
361               "Use the option \"--cfg=smpi/running_power:<flops>\" to set its value."
362               "Check http://simgrid.org/simgrid/latest/doc/options.html#options_smpi_bench for more information.");
363    }
364 }
365
366 int smpi_enabled(void) {
367   return process_data != NULL;
368 }
369
370 void smpi_global_init(void)
371 {
372   int i;
373   MPI_Group group;
374   char name[MAILBOX_NAME_MAXLEN];
375   int smpirun=0;
376
377
378   if (process_count == 0){
379     process_count = SIMIX_process_count();
380     smpirun=1;
381   }
382   process_data = xbt_new0(smpi_process_data_t, process_count);
383   for (i = 0; i < process_count; i++) {
384     process_data[i] = xbt_new(s_smpi_process_data_t, 1);
385     //process_data[i]->index = i;
386     process_data[i]->argc = NULL;
387     process_data[i]->argv = NULL;
388     process_data[i]->mailbox = simcall_rdv_create(get_mailbox_name(name, i));
389     process_data[i]->mailbox_small =
390         simcall_rdv_create(get_mailbox_name_small(name, i));
391     process_data[i]->timer = xbt_os_timer_new();
392     if (MC_is_active())
393       MC_ignore_heap(process_data[i]->timer, xbt_os_timer_size());
394     process_data[i]->comm_self = MPI_COMM_NULL;
395     process_data[i]->comm_world = NULL;
396     process_data[i]->state = SMPI_UNINITIALIZED;
397     process_data[i]->sampling = 0;
398     process_data[i]->finalization_barrier = NULL;
399   }
400   //if the process was launched through smpirun script
401   //we generate a global mpi_comm_world
402   //if not, we let MPI_COMM_NULL, and the comm world
403   //will be private to each mpi instance
404   if(smpirun){
405     group = smpi_group_new(process_count);
406     MPI_COMM_WORLD = smpi_comm_new(group, NULL);
407     xbt_bar_t bar=xbt_barrier_init(process_count);
408
409     MPI_UNIVERSE_SIZE = smpi_comm_size(MPI_COMM_WORLD);
410     for (i = 0; i < process_count; i++) {
411       smpi_group_set_mapping(group, i, i);
412       process_data[i]->finalization_barrier = bar;
413     }
414   }
415 }
416
417 void smpi_global_destroy(void)
418 {
419   int count = smpi_process_count();
420   int i;
421
422   smpi_bench_destroy();
423   if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED){
424       while (smpi_group_unuse(smpi_comm_group(MPI_COMM_WORLD)) > 0);
425       xbt_free(MPI_COMM_WORLD);
426       xbt_barrier_destroy(process_data[0]->finalization_barrier);
427   }else{
428       smpi_deployment_cleanup_instances();
429   }
430   MPI_COMM_WORLD = MPI_COMM_NULL;
431   for (i = 0; i < count; i++) {
432     if(process_data[i]->comm_self!=MPI_COMM_NULL){
433       smpi_group_unuse(smpi_comm_group(process_data[i]->comm_self));
434       smpi_comm_destroy(process_data[i]->comm_self);
435     }
436     xbt_os_timer_free(process_data[i]->timer);
437     simcall_rdv_destroy(process_data[i]->mailbox);
438     simcall_rdv_destroy(process_data[i]->mailbox_small);
439     xbt_free(process_data[i]);
440   }
441   xbt_free(process_data);
442   process_data = NULL;
443
444   xbt_free(index_to_process_data);
445   if(smpi_privatize_global_variables)
446     smpi_destroy_global_memory_segments();
447   smpi_free_static();
448 }
449
450 #ifndef WIN32
451 void __attribute__ ((weak)) user_main_()
452 {
453   xbt_die("Should not be in this smpi_simulated_main");
454   return;
455 }
456
457 int __attribute__ ((weak)) smpi_simulated_main_(int argc, char **argv)
458 {
459   smpi_process_init(&argc, &argv);
460   user_main_();
461   return 0;
462 }
463
464 int __attribute__ ((weak)) main(int argc, char **argv)
465 {
466   return smpi_main(smpi_simulated_main_, argc, argv);
467 }
468
469 #endif
470
471 static void smpi_init_logs(){
472
473   /* Connect log categories.  See xbt/log.c */
474   XBT_LOG_CONNECT(smpi);        /* Keep this line as soon as possible in this
475                                    function: xbt_log_appender_file.c depends on it
476                                    DO NOT connect this in XBT or so, or it will be
477                                    useless to xbt_log_appender_file.c */
478 #ifdef HAVE_TRACING
479   XBT_LOG_CONNECT(instr_smpi);
480 #endif
481   XBT_LOG_CONNECT(smpi_base);
482   XBT_LOG_CONNECT(smpi_bench);
483   XBT_LOG_CONNECT(smpi_coll);
484   XBT_LOG_CONNECT(smpi_colls);
485   XBT_LOG_CONNECT(smpi_comm);
486   XBT_LOG_CONNECT(smpi_dvfs);
487   XBT_LOG_CONNECT(smpi_group);
488   XBT_LOG_CONNECT(smpi_kernel);
489   XBT_LOG_CONNECT(smpi_mpi);
490   XBT_LOG_CONNECT(smpi_mpi_dt);
491   XBT_LOG_CONNECT(smpi_pmpi);
492   XBT_LOG_CONNECT(smpi_replay);
493   XBT_LOG_CONNECT(smpi_rma);
494
495 }
496
497
498 static void smpi_init_options(){
499   int gather_id = find_coll_description(mpi_coll_gather_description,
500                                           sg_cfg_get_string("smpi/gather"));
501     mpi_coll_gather_fun = (int (*)(void *, int, MPI_Datatype,
502                                    void *, int, MPI_Datatype, int, MPI_Comm))
503         mpi_coll_gather_description[gather_id].coll;
504
505     int allgather_id = find_coll_description(mpi_coll_allgather_description,
506                                              sg_cfg_get_string("smpi/allgather"));
507     mpi_coll_allgather_fun = (int (*)(void *, int, MPI_Datatype,
508                                       void *, int, MPI_Datatype, MPI_Comm))
509         mpi_coll_allgather_description[allgather_id].coll;
510
511     int allgatherv_id = find_coll_description(mpi_coll_allgatherv_description,
512                                               sg_cfg_get_string("smpi/allgatherv"));
513     mpi_coll_allgatherv_fun = (int (*)(void *, int, MPI_Datatype, void *, int *,
514                                        int *, MPI_Datatype, MPI_Comm))
515         mpi_coll_allgatherv_description[allgatherv_id].coll;
516
517     int allreduce_id = find_coll_description(mpi_coll_allreduce_description,
518                                              sg_cfg_get_string("smpi/allreduce"));
519     mpi_coll_allreduce_fun = (int (*)(void *sbuf, void *rbuf, int rcount,
520                                       MPI_Datatype dtype, MPI_Op op,
521                                       MPI_Comm comm))
522         mpi_coll_allreduce_description[allreduce_id].coll;
523
524     int alltoall_id = find_coll_description(mpi_coll_alltoall_description,
525                                             sg_cfg_get_string("smpi/alltoall"));
526     mpi_coll_alltoall_fun = (int (*)(void *, int, MPI_Datatype,
527                                      void *, int, MPI_Datatype, MPI_Comm))
528         mpi_coll_alltoall_description[alltoall_id].coll;
529
530     int alltoallv_id = find_coll_description(mpi_coll_alltoallv_description,
531                                              sg_cfg_get_string("smpi/alltoallv"));
532     mpi_coll_alltoallv_fun = (int (*)(void *, int *, int *, MPI_Datatype,
533                                       void *, int *, int *, MPI_Datatype,
534                                       MPI_Comm))
535         mpi_coll_alltoallv_description[alltoallv_id].coll;
536
537     int bcast_id = find_coll_description(mpi_coll_bcast_description,
538                                          sg_cfg_get_string("smpi/bcast"));
539     mpi_coll_bcast_fun = (int (*)(void *buf, int count, MPI_Datatype datatype,
540                                   int root, MPI_Comm com))
541         mpi_coll_bcast_description[bcast_id].coll;
542
543     int reduce_id = find_coll_description(mpi_coll_reduce_description,
544                                           sg_cfg_get_string("smpi/reduce"));
545     mpi_coll_reduce_fun = (int (*)(void *buf, void *rbuf, int count,
546                                    MPI_Datatype datatype, MPI_Op op,
547                                    int root, MPI_Comm comm))
548         mpi_coll_reduce_description[reduce_id].coll;
549
550     int reduce_scatter_id =
551         find_coll_description(mpi_coll_reduce_scatter_description,
552                               sg_cfg_get_string("smpi/reduce_scatter"));
553     mpi_coll_reduce_scatter_fun = (int (*)(void *sbuf, void *rbuf, int *rcounts,
554                                            MPI_Datatype dtype, MPI_Op op,
555                                            MPI_Comm comm))
556         mpi_coll_reduce_scatter_description[reduce_scatter_id].coll;
557
558     int scatter_id = find_coll_description(mpi_coll_scatter_description,
559                                            sg_cfg_get_string("smpi/scatter"));
560     mpi_coll_scatter_fun = (int (*)(void *sendbuf, int sendcount,
561                                     MPI_Datatype sendtype, void *recvbuf,
562                                     int recvcount, MPI_Datatype recvtype,
563                                     int root, MPI_Comm comm))
564         mpi_coll_scatter_description[scatter_id].coll;
565
566     int barrier_id = find_coll_description(mpi_coll_barrier_description,
567                                            sg_cfg_get_string("smpi/barrier"));
568     mpi_coll_barrier_fun = (int (*)(MPI_Comm comm))
569         mpi_coll_barrier_description[barrier_id].coll;
570
571     smpi_cpu_threshold = sg_cfg_get_double("smpi/cpu_threshold");
572     smpi_running_power = sg_cfg_get_double("smpi/running_power");
573     smpi_privatize_global_variables = sg_cfg_get_boolean("smpi/privatize_global_variables");
574     if (smpi_cpu_threshold < 0)
575       smpi_cpu_threshold = DBL_MAX;
576
577 }
578
579 int smpi_main(int (*realmain) (int argc, char *argv[]), int argc, char *argv[])
580 {
581   srand(SMPI_RAND_SEED);
582
583   if (getenv("SMPI_PRETEND_CC") != NULL) {
584     /* Hack to ensure that smpicc can pretend to be a simple
585      * compiler. Particularly handy to pass it to the configuration tools */
586     return 0;
587   }
588
589   smpi_init_logs();
590
591 #ifdef HAVE_TRACING
592   TRACE_global_init(&argc, argv);
593
594   TRACE_add_start_function(TRACE_smpi_alloc);
595   TRACE_add_end_function(TRACE_smpi_release);
596 #endif
597
598   SIMIX_global_init(&argc, argv);
599
600   // parse the platform file: get the host list
601   SIMIX_create_environment(argv[1]);
602   SIMIX_comm_set_copy_data_callback(&smpi_comm_copy_buffer_callback);
603   SIMIX_function_register_default(realmain);
604   SIMIX_launch_application(argv[2]);
605
606   smpi_init_options();
607
608   smpi_global_init();
609
610   smpi_check_options();
611
612   if(smpi_privatize_global_variables)
613     smpi_initialize_global_memory_segments();
614
615   /* Clean IO before the run */
616   fflush(stdout);
617   fflush(stderr);
618
619   if (MC_is_active())
620     MC_do_the_modelcheck_for_real();
621   else
622     SIMIX_run();
623
624   if (sg_cfg_get_boolean("smpi/display_timing"))
625     XBT_INFO("Simulation time: %g seconds.", SIMIX_get_clock());
626
627   smpi_global_destroy();
628
629 #ifdef HAVE_TRACING
630   TRACE_end();
631 #endif
632
633   return 0;
634 }
635
636 // This function can be called from extern file, to initialize logs, options, and processes of smpi
637 // without the need of smpirun
638 void SMPI_init(){
639   smpi_init_logs();
640   smpi_init_options();
641   smpi_global_init();
642   smpi_check_options();
643 #ifdef HAVE_TRACING
644   if (TRACE_is_enabled() && TRACE_is_configured()) {
645     TRACE_smpi_alloc();
646   }
647 #endif
648   if(smpi_privatize_global_variables)
649     smpi_initialize_global_memory_segments();
650 }
651
652 void SMPI_finalize(){
653   smpi_global_destroy();
654 }