Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tau memory_instrumentation (master) #5

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/opal_configure_options.m4
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ else
fi
AC_DEFINE_UNQUOTED(OPAL_ENABLE_MEM_PROFILE, $WANT_MEM_PROFILE,
[Whether we want the memory profiling or not])
AM_CONDITIONAL([OPAL_ENABLE_MEM_PROFILE], [test "$WANT_MEM_PROFILE" = "1"])

#
# Developer picky compiler options
Expand Down
3 changes: 3 additions & 0 deletions ompi/communicator/comm_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "opal/util/bit_ops.h"
#include "opal/util/info_subscriber.h"
#include "opal/util/string_copy.h"
#include "opal/util/memprof.h"
#include "opal/mca/pmix/pmix.h"
#include "ompi/constants.h"
#include "ompi/mca/pml/pml.h"
Expand Down Expand Up @@ -242,6 +243,7 @@ ompi_communicator_t *ompi_comm_allocate ( int local_size, int remote_size )

/* create new communicator element */
new_comm = OBJ_NEW(ompi_communicator_t);
OPAL_MEMPROF_START_ALLOC(new_comm->super.s_base.obj_class->cls_name, 0, 0);
new_comm->super.s_info = NULL;
new_comm->c_local_group = ompi_group_allocate ( local_size );
if ( 0 < remote_size ) {
Expand All @@ -258,6 +260,7 @@ ompi_communicator_t *ompi_comm_allocate ( int local_size, int remote_size )

/* fill in the inscribing hyper-cube dimensions */
new_comm->c_cube_dim = opal_cube_dim(local_size);
OPAL_MEMPROF_STOP_ALLOC(new_comm->super.s_base.obj_class->cls_name, 0);

return new_comm;
}
Expand Down
19 changes: 18 additions & 1 deletion ompi/group/group_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "ompi/constants.h"
#include "mpi.h"

#include "opal/util/memprof.h"

/* define class information */
static void ompi_group_construct(ompi_group_t *);
static void ompi_group_destruct(ompi_group_t *);
Expand Down Expand Up @@ -57,7 +59,11 @@ ompi_predefined_group_t *ompi_mpi_group_null_addr = &ompi_mpi_group_null;
ompi_group_t *ompi_group_allocate(int group_size)
{
/* local variables */
OPAL_MEMPROF_START_ALLOC("ompi_group_t", 0, 0);
ompi_proc_t **procs = calloc (group_size, sizeof (ompi_proc_t *));
OPAL_MEMPROF_START_ALLOC("ompi_proc_t **", group_size * sizeof(ompi_proc_t *), 0);
OPAL_MEMPROF_STOP_ALLOC("ompi_proc_t **", 1);
OPAL_MEMPROF_STOP_ALLOC("ompi_group_t", 0);
ompi_group_t *new_group;

if (NULL == procs) {
Expand All @@ -81,6 +87,7 @@ ompi_group_t *ompi_group_allocate_plist_w_procs (ompi_proc_t **procs, int group_

/* create new group group element */
new_group = OBJ_NEW(ompi_group_t);
OPAL_MEMPROF_START_ALLOC(new_group->super.obj_class->cls_name, 0, 0);

if (NULL == new_group) {
return NULL;
Expand All @@ -105,7 +112,7 @@ ompi_group_t *ompi_group_allocate_plist_w_procs (ompi_proc_t **procs, int group_
OMPI_GROUP_SET_DENSE(new_group);

ompi_group_increment_proc_count (new_group);

OPAL_MEMPROF_STOP_ALLOC(new_group->super.obj_class->cls_name, 0);
return new_group;
}

Expand All @@ -126,11 +133,14 @@ ompi_group_t *ompi_group_allocate_sporadic(int group_size)
new_group = NULL;
goto error_exit;
}
OPAL_MEMPROF_START_ALLOC(new_group->super.obj_class->cls_name, 0, 0);
/* allocate array of (grp_sporadic_list )'s */
if (0 < group_size) {
new_group->sparse_data.grp_sporadic.grp_sporadic_list =
(struct ompi_group_sporadic_list_t *)malloc
(sizeof(struct ompi_group_sporadic_list_t ) * group_size);
OPAL_MEMPROF_START_ALLOC("ompi_group_sporadic_list_t *", sizeof(struct ompi_group_sporadic_list_t ) * group_size, 0);
OPAL_MEMPROF_STOP_ALLOC("ompi_group_sporadic_list_t *", 1);

/* non-empty group */
if ( NULL == new_group->sparse_data.grp_sporadic.grp_sporadic_list) {
Expand All @@ -151,6 +161,7 @@ ompi_group_t *ompi_group_allocate_sporadic(int group_size)
OMPI_GROUP_SET_SPORADIC(new_group);

error_exit:
OPAL_MEMPROF_STOP_ALLOC(new_group->super.obj_class->cls_name, 0);
return new_group;
}

Expand All @@ -168,6 +179,7 @@ ompi_group_t *ompi_group_allocate_strided(void)
new_group = NULL;
goto error_exit;
}
OPAL_MEMPROF_START_ALLOC(new_group->super.obj_class->cls_name, 0, 0);
/* initialize our rank to MPI_UNDEFINED */
new_group->grp_my_rank = MPI_UNDEFINED;
new_group->grp_proc_pointers = NULL;
Expand All @@ -177,6 +189,7 @@ ompi_group_t *ompi_group_allocate_strided(void)
new_group->sparse_data.grp_strided.grp_strided_last_element = -1;
error_exit:
/* return */
OPAL_MEMPROF_STOP_ALLOC(new_group->super.obj_class->cls_name, 0);
return new_group;
}
ompi_group_t *ompi_group_allocate_bmap(int orig_group_size , int group_size)
Expand All @@ -196,8 +209,11 @@ ompi_group_t *ompi_group_allocate_bmap(int orig_group_size , int group_size)
goto error_exit;
}
/* allocate the unsigned char list */
OPAL_MEMPROF_START_ALLOC(new_group->super.obj_class->cls_name, 0, 0);
new_group->sparse_data.grp_bitmap.grp_bitmap_array = (unsigned char *)malloc
(sizeof(unsigned char) * ompi_group_div_ceil(orig_group_size,BSIZE));
OPAL_MEMPROF_START_ALLOC("unsigned char *", sizeof(struct ompi_group_sporadic_list_t ) * group_size, 0);
OPAL_MEMPROF_STOP_ALLOC("unsigned char *", 1);

new_group->sparse_data.grp_bitmap.grp_bitmap_array_len =
ompi_group_div_ceil(orig_group_size,BSIZE);
Expand All @@ -211,6 +227,7 @@ ompi_group_t *ompi_group_allocate_bmap(int orig_group_size , int group_size)

error_exit:
/* return */
OPAL_MEMPROF_STOP_ALLOC(new_group->super.obj_class->cls_name, 0);
return new_group;
}

Expand Down
5 changes: 5 additions & 0 deletions ompi/mca/pml/ob1/pml_ob1_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

#include "ompi_config.h"
#include "opal/util/memprof.h"
#include <string.h>

#include "pml_ob1.h"
Expand Down Expand Up @@ -108,7 +109,11 @@ OBJ_CLASS_INSTANCE(
int mca_pml_ob1_comm_init_size (mca_pml_ob1_comm_t* comm, size_t size)
{
/* send message sequence-number support - sender side */
OPAL_MEMPROF_START_ALLOC(comm->super.obj_class->cls_name, 0, 0);
comm->procs = (mca_pml_ob1_comm_proc_t **) calloc(size, sizeof (mca_pml_ob1_comm_proc_t *));
OPAL_MEMPROF_START_ALLOC("mca_pml_ob1_comm_proc_t", size * sizeof(mca_pml_ob1_comm_proc_t *), 0);
OPAL_MEMPROF_STOP_ALLOC("mca_pml_ob1_comm_proc_t", 1);
OPAL_MEMPROF_STOP_ALLOC(comm->super.obj_class->cls_name, 0);
if(NULL == comm->procs) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
Expand Down
5 changes: 5 additions & 0 deletions ompi/mca/pml/yalla/pml_yalla.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "opal/runtime/opal.h"
#include "opal/memoryhooks/memory.h"
#include "opal/util/memprof.h"
#include "opal/mca/memory/base/base.h"
#include "opal/mca/pmix/pmix.h"
#include "ompi/mca/pml/base/pml_base_bsend.h"
Expand Down Expand Up @@ -256,7 +257,11 @@ int mca_pml_yalla_add_procs(struct ompi_proc_t **procs, size_t nprocs)
return OMPI_ERROR;
}

OPAL_MEMPROF_START_ALLOC(procs[i]->super.super.super.obj_class->cls_name, 0, 0);
OPAL_MEMPROF_START_ALLOC("mxm_conn_h", sizeof(mxm_conn_h), 0);
procs[i]->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_PML] = conn;
OPAL_MEMPROF_STOP_ALLOC("mxm_conn_h", 1);
OPAL_MEMPROF_STOP_ALLOC(procs[i]->super.super.super.obj_class->cls_name, 0);
}

return OMPI_SUCCESS;
Expand Down
3 changes: 3 additions & 0 deletions ompi/win/win.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "opal/util/info_subscriber.h"
#include "opal/util/string_copy.h"
#include "opal/util/memprof.h"

#include "mpi.h"
#include "ompi/win/win.h"
Expand Down Expand Up @@ -148,6 +149,7 @@ static int alloc_window(struct ompi_communicator_t *comm, opal_info_t *info, int

/* create the object */
win = OBJ_NEW(ompi_win_t);
OPAL_MEMPROF_START_ALLOC(win->super.s_base.obj_class->cls_name, 0, 0);
if (NULL == win) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
Expand Down Expand Up @@ -187,6 +189,7 @@ static int alloc_window(struct ompi_communicator_t *comm, opal_info_t *info, int
}

*win_out = win;
OPAL_MEMPROF_STOP_ALLOC(win->super.s_base.obj_class->cls_name, 0);

return OMPI_SUCCESS;
}
Expand Down
2 changes: 2 additions & 0 deletions opal/class/opal_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "opal/sys/atomic.h"
#include "opal/class/opal_object.h"
#include "opal/constants.h"
#include "opal/util/memprof.h"


/*
* Instantiation of class descriptor for the base class. This is
Expand Down
6 changes: 6 additions & 0 deletions opal/class/opal_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
#include <stdlib.h>

#include "opal/threads/thread_usage.h"
#include "opal/util/memprof.h"

BEGIN_C_DECLS

Expand All @@ -132,6 +133,7 @@ BEGIN_C_DECLS
#define OPAL_OBJ_MAGIC_ID ((0xdeafbeedULL << 32) + 0xdeafbeedULL)
#endif


/* typedefs ***********************************************************/

typedef struct opal_object_t opal_object_t;
Expand Down Expand Up @@ -457,6 +459,7 @@ static inline void opal_obj_run_destructors(opal_object_t * object)

assert(NULL != object->obj_class);

OPAL_MEMPROF_TRACK_DEALLOC(object->obj_class->cls_name, object->obj_class->cls_sizeof);
cls_destruct = object->obj_class->cls_destruct_array;
while( NULL != *cls_destruct ) {
(*cls_destruct)(object);
Expand All @@ -480,6 +483,8 @@ static inline opal_object_t *opal_obj_new(opal_class_t * cls)
opal_object_t *object;
assert(cls->cls_sizeof >= sizeof(opal_object_t));

OPAL_MEMPROF_START_ALLOC(cls->cls_name, cls->cls_sizeof, 0);

#if OPAL_WANT_MEMCHECKER
object = (opal_object_t *) calloc(1, cls->cls_sizeof);
#else
Expand All @@ -493,6 +498,7 @@ static inline opal_object_t *opal_obj_new(opal_class_t * cls)
object->obj_reference_count = 1;
opal_obj_run_constructors(object);
}
OPAL_MEMPROF_STOP_ALLOC(cls->cls_name, 1);
return object;
}

Expand Down
7 changes: 7 additions & 0 deletions opal/util/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# Copyright (c) 2016 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
# Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
# Copyright (c) 2019 UT-Battelle, LLC. All rights reserved.
#
# $COPYRIGHT$
#
# Additional copyrights may follow
Expand Down Expand Up @@ -55,6 +57,7 @@ headers = \
if.h \
keyval_parse.h \
malloc.h \
memprof.h \
net.h \
numtostr.h \
opal_environ.h \
Expand Down Expand Up @@ -119,6 +122,10 @@ if OPAL_COMPILE_TIMING
libopalutil_la_SOURCES += timings.c
endif

if OPAL_ENABLE_MEM_PROFILE
libopalutil_la_SOURCES += memprof.c
endif

libopalutil_la_LIBADD = \
keyval/libopalutilkeyval.la
libopalutil_la_DEPENDENCIES = \
Expand Down
45 changes: 45 additions & 0 deletions opal/util/memprof.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2019 UT-Battelle, LLC. All rights reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/

#include "opal_config.h"
#include "opal/util/memprof.h"


void __attribute__((weak)) Tau_track_class_allocation(const char * name,
size_t size) {

}

void __attribute__((weak)) Tau_track_class_deallocation(const char * name,
size_t size) {

}

void __attribute__((weak)) Tau_start_class_allocation(const char * name,
size_t size,
int include_in_parent) {

}

void __attribute__((weak)) Tau_stop_class_allocation(const char * name,
int record) {

}

void __attribute__((weak)) Tau_start_class_deallocation(const char * name,
size_t size,
int include_in_parent) {

}

void __attribute__((weak)) Tau_stop_class_deallocation(const char * name,
int record) {

}
Loading