diff --git a/src/mca/ptl/prof/ptl_prof.c b/src/mca/ptl/prof/ptl_prof.c new file mode 100644 index 0000000000..7b2e704f99 --- /dev/null +++ b/src/mca/ptl/prof/ptl_prof.c @@ -0,0 +1,147 @@ +#include "ptl_prof.h" + +static int ptl_prof_add_procs_fn( struct mca_ptl_base_module_t* ptl, + size_t nprocs, + struct ompi_proc_t** procs, + struct mca_ptl_base_peer_t** peer, + ompi_bitmap_t* reachable ) +{ + return 0; +} + +static int ptl_prof_del_procs_fn( struct mca_ptl_base_module_t* ptl, + size_t nprocs, + struct ompi_proc_t** procs, + struct mca_ptl_base_peer_t** peer ) +{ + return 0; +} + +static int ptl_prof_finalize_fn( struct mca_ptl_base_module_t* ptl ) +{ + return 0; +} + +static int ptl_prof_send_fn( struct mca_ptl_base_module_t* ptl, + struct mca_ptl_base_peer_t* ptl_base_peer, + struct mca_pml_base_send_request_t* request, + size_t offset, + size_t size, + int flags ) +{ + return 0; +} + +static int ptl_prof_put_fn( struct mca_ptl_base_module_t* ptl, + struct mca_ptl_base_peer_t* ptl_base_peer, + struct mca_pml_base_send_request_t* request, + size_t offset, + size_t size, + int flags ) +{ + return 0; +} + +static int ptl_prof_get_fn( struct mca_ptl_base_module_t* ptl, + struct mca_ptl_base_peer_t* ptl_base_peer, + struct mca_pml_base_recv_request_t* request, + size_t offset, + size_t size, + int flags ) +{ + return 0; +} + +static void ptl_prof_matched_fn( struct mca_ptl_base_module_t* ptl, + struct mca_ptl_base_recv_frag_t* request ) +{ +} + +static int ptl_prof_request_init_fn( struct mca_ptl_base_module_t* ptl, + struct mca_pml_base_send_request_t* request ) +{ + return 0; +} + +static void ptl_prof_request_fini_fn( struct mca_ptl_base_module_t* ptl, struct mca_pml_base_send_request_t* request ) +{ +} + +static bool ptl_prof_match_fn( struct mca_ptl_base_module_t* ptl, + struct mca_ptl_base_recv_frag_t* recv_frag, + struct mca_ptl_base_match_header_t* header ) +{ + return true; +} + +static void ptl_prof_send_progress_fn( struct mca_ptl_base_module_t* ptl, + struct mca_pml_base_send_request_t* send_request, + size_t bytes_sent ) +{ +} + +static void ptl_prof_recv_progress_fn( struct mca_ptl_base_module_t* ptl, + struct mca_pml_base_recv_request_t* recv_request, + size_t bytes_received, + size_t bytes_delivered ) +{ +} + +/* The default profiling PTL. We will canibalize all others PTL + * except this one. It's just a simple way to have the control function + * called. + */ +mca_ptl_prof_t mca_ptl_prof = { + { NULL, + 0, /* maximum size of request cache for this PTL */ + 0, /* number of bytes required by PTL for request cache */ + 0, /* ptl_frag_first_size */ + 0, /* ptl_frag_min_size */ + 0, /* ptl_frag_max_size */ + 0, /* ptl_exclusivity */ + 0, /* ptl_latency */ + 0, /* ptl_bandwidth */ + MCA_PTL_PUT | MCA_PTL_GET, /* ptl flags */ + ptl_prof_add_procs_fn, + ptl_prof_del_procs_fn, + ptl_prof_finalize_fn, + ptl_prof_send_fn, + ptl_prof_put_fn, + ptl_prof_get_fn, + ptl_prof_matched_fn, + ptl_prof_request_init_fn, + ptl_prof_request_fini_fn, + ptl_prof_match_fn, + ptl_prof_send_progress_fn, + ptl_prof_recv_progress_fn, + NULL, /* the stack :) */ + NULL, + } +}; + +static void ptl_prof_construct(mca_ptl_prof_t* ptl) +{ + ptl->super.ptl_add_procs = ptl_prof_add_procs_fn; + ptl->super.ptl_del_procs = ptl_prof_del_procs_fn; + ptl->super.ptl_finalize = ptl_prof_finalize_fn; + ptl->super.ptl_send = ptl_prof_send_fn; + ptl->super.ptl_put = ptl_prof_put_fn; + ptl->super.ptl_get = ptl_prof_get_fn; + ptl->super.ptl_matched = ptl_prof_matched_fn; + ptl->super.ptl_request_init = ptl_prof_request_init_fn; + ptl->super.ptl_request_fini = ptl_prof_request_fini_fn; + ptl->super.ptl_match = ptl_prof_match_fn; + ptl->super.ptl_send_progress = ptl_prof_send_progress_fn; + ptl->super.ptl_recv_progress = ptl_prof_recv_progress_fn; + ptl->super.ptl_stack = NULL; +} + +static void ptl_prof_destruct(mca_ptl_prof_t* ptl) +{ + /* deregistering the profiling ids from the profiling layer */ +} + +OBJ_CLASS_INSTANCE( mca_ptl_prof_t, ompi_object_t, + ptl_prof_construct, + ptl_prof_destruct ); + diff --git a/src/mca/ptl/prof/ptl_prof.h b/src/mca/ptl/prof/ptl_prof.h new file mode 100644 index 0000000000..1db2d8db11 --- /dev/null +++ b/src/mca/ptl/prof/ptl_prof.h @@ -0,0 +1,41 @@ +/* + * *$HEADER$ + * */ +/** + * * @file + * */ + +#ifndef PTL_PROF_H_HAS_BEEN_INCLUDED +#define PTL_PROF_H_HAS_BEEN_INCLUDED + +#include "event/event.h" +#include "mca/pml/pml.h" +#include "mca/ptl/ptl.h" +#include "mca/pml/base/pml_base_recvreq.h" +#include "mca/ptl/base/ptl_base_recvfrag.h" + +/** + * PROF PTL module. + */ +struct mca_ptl_prof_module_1_0_0 { + mca_ptl_base_component_t super; /**< base PTL module */ + struct mca_ptl_t** prof_ptls; /**< array of available PTLs */ + u_int32_t prof_num_ptls; /**< number of ptls actually used */ + u_int32_t prof_max_ptls; /**< maximum number of ptls - available kernel ifs */ + u_int32_t prof_buf_size; /**< the size of the internal buffer used to profile each PTL */ +}; +typedef struct mca_ptl_prof_module_1_0_0 mca_ptl_prof_module_1_0_0_t; +/** + * Profiling module. + */ +struct mca_ptl_prof { + mca_ptl_base_module_t super; + u_int32_t prof_create_id; + u_int32_t prof_start_send_id; + u_int32_t prof_start_recv_id; + u_int32_t prof_complete_id; +}; +typedef struct mca_ptl_prof mca_ptl_prof_t; +OBJ_CLASS_DECLARATION(mca_ptl_prof_t); + +#endif /* PTL_PROF_H_HAS_BEEN_INCLUDED */ diff --git a/src/mca/ptl/prof/ptl_prof_component.c b/src/mca/ptl/prof/ptl_prof_component.c new file mode 100644 index 0000000000..69c794e7c9 --- /dev/null +++ b/src/mca/ptl/prof/ptl_prof_component.c @@ -0,0 +1,93 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * $HEADER$ + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "constants.h" +#include "event/event.h" +#include "util/if.h" +#include "util/argv.h" +#include "util/output.h" +#include "mca/pml/pml.h" +#include "mca/ptl/ptl.h" +#include "mca/pml/base/pml_base_sendreq.h" +#include "mca/ptl/base/ptl_base_recvfrag.h" +#include "mca/base/mca_base_param.h" +#include "mca/base/mca_base_module_exchange.h" +#include "ptl_prof.h" + +/** + * This is the moment to grab all existing modules, and then replace their + * functions with my own. In same time the ptl_stack will be initialized + * with the pointer to a ptl automatically generate, which will contain + * the correct pointers. + */ +static int ptl_prof_module_control_fn( int param, void* value, size_t size ) +{ + /* check in mca_ptl_base_modules_initialized */ + return 0; +} + +/* We have to create at least one PTL, just to allow the PML to call the control + * function associated with this PTL. + */ +extern mca_ptl_prof_t mca_ptl_prof; +static struct mca_ptl_t** ptl_prof_module_init_fn( int *num_ptls, + bool *allow_multi_user_threads, + bool *have_hidden_threads ) +{ + *num_ptls = 1; + *allow_multi_user_threads = true; + *have_hidden_threads = false; + return (struct mca_ptl_t**)&mca_ptl_prof; +} + +static int mca_ptl_prof_module_open_fn( void ) +{ + return OMPI_SUCCESS; +} + +static int mca_ptl_prof_module_close_fn( void ) +{ + return OMPI_SUCCESS; +} + +mca_ptl_prof_module_1_0_0_t mca_ptl_prof_module = { + { + /* First, the mca_base_module_t struct containing meta information + about the module itself */ + + { + /* Indicate that we are a pml v1.0.0 module (which also implies a + specific MCA version) */ + + MCA_PTL_BASE_VERSION_1_0_0, + + "prof", /* MCA module name */ + 1, /* MCA module major version */ + 0, /* MCA module minor version */ + 0, /* MCA module release version */ + mca_ptl_prof_module_open_fn, /* module open */ + mca_ptl_prof_module_close_fn /* module close */ + }, + + /* Next the MCA v1.0.0 module meta data */ + + { + /* Whether the module is checkpointable or not */ + true + }, + + ptl_prof_module_init_fn, + ptl_prof_module_control_fn, + NULL, + } +};