root/ompi/mca/osc/monitoring/osc_monitoring_module.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2016-2017 Inria.  All rights reserved.
   3  * Copyright (c) 2017      Research Organization for Information Science
   4  *                         and Technology (RIST). All rights reserved.
   5  * Copyright (c) 2017      Amazon.com, Inc. or its affiliates.  All Rights
   6  *                         reserved.
   7  * $COPYRIGHT$
   8  *
   9  * Additional copyrights may follow
  10  *
  11  * $HEADER$
  12  */
  13 
  14 #ifndef MCA_OSC_MONITORING_MODULE_H
  15 #define MCA_OSC_MONITORING_MODULE_H
  16 
  17 #include <ompi/info/info.h>
  18 #include <ompi/win/win.h>
  19 #include <ompi/mca/osc/osc.h>
  20 
  21 /* Define once and for all the module_template variable name */
  22 #define OMPI_OSC_MONITORING_MODULE_VARIABLE(template)   \
  23     ompi_osc_monitoring_module_## template ##_template
  24 
  25 /* Define once and for all the
  26  * ompi_osc_monitoring_## template ##_set_template function name
  27  */
  28 #define OSC_MONITORING_SET_TEMPLATE_FCT_NAME(template)  \
  29     ompi_osc_monitoring_## template ##_set_template
  30 
  31 /* Define the ompi_osc_monitoring_module_## template ##_template
  32  * variable
  33  */
  34 #define OMPI_OSC_MONITORING_MODULE_GENERATE(template)                   \
  35     /* Define the ompi_osc_monitoring_module_## template ##_template */ \
  36     static ompi_osc_base_module_t OMPI_OSC_MONITORING_MODULE_VARIABLE(template);
  37 
  38 #define OSC_MONITORING_GENERATE_TEMPLATE_MODULE(template)               \
  39                                                                         \
  40     static int ompi_osc_monitoring_## template ##_free(ompi_win_t *win) \
  41     {                                                                   \
  42         return OMPI_OSC_MONITORING_MODULE_VARIABLE(template).osc_free(win); \
  43     }
  44 
  45 #define MCA_OSC_MONITORING_MODULE_TEMPLATE_GENERATE(template)           \
  46     /* Generate template specific module initialization function:       \
  47      * ompi_osc_monitoring_## template ##_set_template(ompi_osc_base_module_t*module) \
  48      */                                                                 \
  49     static inline ompi_osc_base_module_t *                              \
  50     OSC_MONITORING_SET_TEMPLATE_FCT_NAME(template) (ompi_osc_base_module_t*module) \
  51     {                                                                   \
  52         /* Define the ompi_osc_monitoring_module_## template ##_init_done variable */ \
  53         opal_atomic_int32_t init_done = 0;                              \
  54         /* Define and set the ompi_osc_monitoring_## template           \
  55          * ##_template variable. The functions recorded here are        \
  56          * linked to the original functions of the original             \
  57          * {template} module that was replaced.                         \
  58          */                                                             \
  59         static const ompi_osc_base_module_t module_specific_interception_layer = { \
  60             .osc_win_attach = ompi_osc_monitoring_## template ##_attach, \
  61             .osc_win_detach = ompi_osc_monitoring_## template ##_detach, \
  62             .osc_free = ompi_osc_monitoring_## template ##_free,        \
  63                                                                         \
  64             .osc_put = ompi_osc_monitoring_## template ##_put,          \
  65             .osc_get = ompi_osc_monitoring_## template ##_get,          \
  66             .osc_accumulate = ompi_osc_monitoring_## template ##_accumulate, \
  67             .osc_compare_and_swap = ompi_osc_monitoring_## template ##_compare_and_swap, \
  68             .osc_fetch_and_op = ompi_osc_monitoring_## template ##_fetch_and_op, \
  69             .osc_get_accumulate = ompi_osc_monitoring_## template ##_get_accumulate, \
  70                                                                         \
  71             .osc_rput = ompi_osc_monitoring_## template ##_rput,        \
  72             .osc_rget = ompi_osc_monitoring_## template ##_rget,        \
  73             .osc_raccumulate = ompi_osc_monitoring_## template ##_raccumulate, \
  74             .osc_rget_accumulate = ompi_osc_monitoring_## template ##_rget_accumulate, \
  75                                                                         \
  76             .osc_fence = ompi_osc_monitoring_## template ##_fence,      \
  77                                                                         \
  78             .osc_start = ompi_osc_monitoring_## template ##_start,      \
  79             .osc_complete = ompi_osc_monitoring_## template ##_complete, \
  80             .osc_post = ompi_osc_monitoring_## template ##_post,        \
  81             .osc_wait = ompi_osc_monitoring_## template ##_wait,        \
  82             .osc_test = ompi_osc_monitoring_## template ##_test,        \
  83                                                                         \
  84             .osc_lock = ompi_osc_monitoring_## template ##_lock,        \
  85             .osc_unlock = ompi_osc_monitoring_## template ##_unlock,    \
  86             .osc_lock_all = ompi_osc_monitoring_## template ##_lock_all, \
  87             .osc_unlock_all = ompi_osc_monitoring_## template ##_unlock_all, \
  88                                                                         \
  89             .osc_sync = ompi_osc_monitoring_## template ##_sync,        \
  90             .osc_flush = ompi_osc_monitoring_## template ##_flush,      \
  91             .osc_flush_all = ompi_osc_monitoring_## template ##_flush_all, \
  92             .osc_flush_local = ompi_osc_monitoring_## template ##_flush_local, \
  93             .osc_flush_local_all = ompi_osc_monitoring_## template ##_flush_local_all, \
  94         };                                                              \
  95         if ( 1 == opal_atomic_add_fetch_32(&init_done, 1) ) {           \
  96             /* Saves the original module functions in                   \
  97              * ompi_osc_monitoring_module_## template ##_template       \
  98              */                                                         \
  99             memcpy(&OMPI_OSC_MONITORING_MODULE_VARIABLE(template),      \
 100                    module, sizeof(ompi_osc_base_module_t));             \
 101         }                                                               \
 102         /* Replace the original functions with our generated ones */    \
 103         memcpy(module, &module_specific_interception_layer,             \
 104                sizeof(ompi_osc_base_module_t));                         \
 105         return module;                                                  \
 106     }
 107 
 108 #endif /* MCA_OSC_MONITORING_MODULE_H */
 109 

/* [<][>][^][v][top][bottom][index][help] */