From a4f9d1c0c3ce808ac62484a10285b5520ee607e0 Mon Sep 17 00:00:00 2001 From: Thomas Naughton Date: Tue, 15 Jan 2019 13:55:42 -0500 Subject: [PATCH] move profile funcs/stubs out to memprof file Guard these using existing OPAL_ENABLE_MEM_PROFILE option that is enabled via '--enable-mem-profile' configury. --- config/opal_configure_options.m4 | 1 + opal/class/opal_object.c | 24 +---------------- opal/class/opal_object.h | 7 +---- opal/util/Makefile.am | 7 +++++ opal/util/memprof.c | 45 ++++++++++++++++++++++++++++++++ opal/util/memprof.h | 39 +++++++++++++++++++++++++++ 6 files changed, 94 insertions(+), 29 deletions(-) create mode 100644 opal/util/memprof.c create mode 100644 opal/util/memprof.h diff --git a/config/opal_configure_options.m4 b/config/opal_configure_options.m4 index 43fcaf3469d..f02a6d0eb4f 100644 --- a/config/opal_configure_options.m4 +++ b/config/opal_configure_options.m4 @@ -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 diff --git a/opal/class/opal_object.c b/opal/class/opal_object.c index 108b310716a..37c03884ccf 100644 --- a/opal/class/opal_object.c +++ b/opal/class/opal_object.c @@ -32,30 +32,8 @@ #include "opal/sys/atomic.h" #include "opal/class/opal_object.h" #include "opal/constants.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) { - -} /* * Instantiation of class descriptor for the base class. This is diff --git a/opal/class/opal_object.h b/opal/class/opal_object.h index 789f7c2e568..79c8c6b5db6 100644 --- a/opal/class/opal_object.h +++ b/opal/class/opal_object.h @@ -124,6 +124,7 @@ #include #include "opal/threads/thread_usage.h" +#include "opal/util/memprof.h" BEGIN_C_DECLS @@ -132,12 +133,6 @@ BEGIN_C_DECLS #define OPAL_OBJ_MAGIC_ID ((0xdeafbeedULL << 32) + 0xdeafbeedULL) #endif -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); /* typedefs ***********************************************************/ diff --git a/opal/util/Makefile.am b/opal/util/Makefile.am index 521acc8bf9f..9e8ec4f402c 100644 --- a/opal/util/Makefile.am +++ b/opal/util/Makefile.am @@ -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 @@ -55,6 +57,7 @@ headers = \ if.h \ keyval_parse.h \ malloc.h \ + memprof.h \ net.h \ numtostr.h \ opal_environ.h \ @@ -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 = \ diff --git a/opal/util/memprof.c b/opal/util/memprof.c new file mode 100644 index 00000000000..8afbff0f574 --- /dev/null +++ b/opal/util/memprof.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018 Cisco Systems, Inc. All rights reserved. + * 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) { + +} diff --git a/opal/util/memprof.h b/opal/util/memprof.h new file mode 100644 index 00000000000..ddc8fafa46e --- /dev/null +++ b/opal/util/memprof.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2018 UT-Battelle, LLC. All rights reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#ifndef OPAL_MEMPROF_H +#define OPAL_MEMPROF_H + +BEGIN_C_DECLS + +#if OPAL_ENABLE_MEM_PROFILE + + 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); + +#endif /* OPAL_ENABLE_MEM_PROFILE */ + +END_C_DECLS + +#endif /* OPAL_MEMPROF_H */