[v4,5/7] example: instrum: configure instrumented API set

Message ID 1517911222-3896-6-git-send-email-odpbot@yandex.ru
State New
Headers show
Series
  • Code instrumentation with PAPI library
Related show

Commit Message

Github ODP bot Feb. 6, 2018, 10 a.m.
From: Bogdan Pricope <bogdan.pricope@linaro.org>


Add configure time option to trim API set to be instrumented.

Signed-off-by: Bogdan Pricope <bogdan.pricope@linaro.org>

---
/** Email created from pull request 443 (bogdanPricope:master_benchmark_pr)
 ** https://github.com/Linaro/odp/pull/443
 ** Patch: https://github.com/Linaro/odp/pull/443.patch
 ** Base sha: 27a7923236030fed0272cc9072f0cde62496e91d
 ** Merge commit sha: 34bd4730244cef8aa4ef2778135e469012c66768
 **/
 example/instrum/Makefile.am    | 16 +++++++++++++---
 example/instrum/instrum.c      |  4 ++++
 example/instrum/pktio_direct.h |  3 +++
 example/instrum/sched.h        |  3 +++
 example/m4/configure.m4        |  8 ++++++++
 5 files changed, 31 insertions(+), 3 deletions(-)

Patch

diff --git a/example/instrum/Makefile.am b/example/instrum/Makefile.am
index 852bdc77f..368f24c7d 100644
--- a/example/instrum/Makefile.am
+++ b/example/instrum/Makefile.am
@@ -11,13 +11,11 @@  AM_LDFLAGS = $(PAPI_LIBS)
 
 lib_LTLIBRARIES = $(LIB)/libinstrum.la
 
-__LIB__libinstrum_la_SOURCES = \
+INSTRUM_SRC = \
 		instrum.c \
 		store.c \
 		papi_cnt.c \
 		init.c \
-		pktio_direct.c\
-		sched.c \
 		instrum_common.h \
 		sample.h \
 		store.h \
@@ -25,3 +23,15 @@  __LIB__libinstrum_la_SOURCES = \
 		init.h \
 		pktio_direct.h \
 		sched.h
+
+if CODE_INSTRUM_SCHED
+AM_CFLAGS += -DCODE_INSTRUM_SCHED
+INSTRUM_SRC += sched.c
+endif
+
+if CODE_INSTRUM_PKTIO_DIRECT
+AM_CFLAGS += -DCODE_INSTRUM_PKTIO_DIRECT
+INSTRUM_SRC += pktio_direct.c
+endif
+
+__LIB__libinstrum_la_SOURCES = $(INSTRUM_SRC)
diff --git a/example/instrum/instrum.c b/example/instrum/instrum.c
index 605675154..aba07e0c2 100644
--- a/example/instrum/instrum.c
+++ b/example/instrum/instrum.c
@@ -21,11 +21,15 @@  static __attribute__((constructor)) void setup_wrappers(void)
 	if (instr_odpinit_init())
 		return;
 
+#ifdef CODE_INSTRUM_SCHED
 	if (instr_odpsched_init())
 		return;
+#endif /* CODE_INSTRUM_SCHED */
 
+#ifdef CODE_INSTRUM_PKTIO_DIRECT
 	if (instr_odppktio_direct_init())
 		return;
+#endif /* CODE_INSTRUM_PKTIO_DIRECT */
 }
 
 static __attribute__((destructor)) void teardown_wrappers(void)
diff --git a/example/instrum/pktio_direct.h b/example/instrum/pktio_direct.h
index 1bc544dd2..6f2fc6ce7 100644
--- a/example/instrum/pktio_direct.h
+++ b/example/instrum/pktio_direct.h
@@ -7,6 +7,8 @@ 
 #ifndef __INSTRUM_PKTIO_DIRECT_H__
 #define __INSTRUM_PKTIO_DIRECT_H__
 
+#ifdef CODE_INSTRUM_PKTIO_DIRECT
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -16,4 +18,5 @@  int instr_odppktio_direct_init(void);
 #ifdef __cplusplus
 }
 #endif
+#endif /* CODE_INSTRUM_PKTIO_DIRECT */
 #endif /* __INSTRUM_PKTIO_DIRECT_H__ */
diff --git a/example/instrum/sched.h b/example/instrum/sched.h
index 2a092b0ed..6cfc40bdc 100644
--- a/example/instrum/sched.h
+++ b/example/instrum/sched.h
@@ -7,6 +7,8 @@ 
 #ifndef __INSTRUM_SCHED_H__
 #define __INSTRUM_SCHED_H__
 
+#ifdef CODE_INSTRUM_SCHED
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -16,4 +18,5 @@  int instr_odpsched_init(void);
 #ifdef __cplusplus
 }
 #endif
+#endif /* CODE_INSTRUM_SCHED */
 #endif /* __INSTRUM_SCHED_H__ */
diff --git a/example/m4/configure.m4 b/example/m4/configure.m4
index d925bbe78..f2ed909e1 100644
--- a/example/m4/configure.m4
+++ b/example/m4/configure.m4
@@ -17,6 +17,14 @@  AC_ARG_ENABLE([code-instrum],
 
 AM_CONDITIONAL([CODE_INSTRUM], [test x$code_instrumentation = xyes ])
 
+AC_ARG_WITH([code-instrum-profile],
+AS_HELP_STRING([--with-code-instrum-profile=all|scheduler|pktio_direct   set code instrumentation profile]),
+    [code_instrum_profile="$withval"],
+    [code_instrum_profile="all"])
+
+AM_CONDITIONAL([CODE_INSTRUM_SCHED],[test $code_instrum_profile = "all" || test $code_instrum_profile = "scheduler"])
+AM_CONDITIONAL([CODE_INSTRUM_PKTIO_DIRECT],[test $code_instrum_profile = "all" || test $code_instrum_profile = "pktio_direct"])
+
 AC_CONFIG_FILES([example/classifier/Makefile
 		 example/generator/Makefile
 		 example/hello/Makefile