From patchwork Thu Jan 18 14:01:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 124966 Delivered-To: patch@linaro.org Received: by 10.46.64.27 with SMTP id n27csp140373lja; Thu, 18 Jan 2018 06:06:53 -0800 (PST) X-Google-Smtp-Source: ACJfBos4ZV3MM92qxqrdM0XWn21evmPNY+POD1YE0S5kid4yT8SeKwOfoEIYyGK2BmP8V9IUUgH/ X-Received: by 10.55.53.205 with SMTP id c196mr52375828qka.311.1516284413697; Thu, 18 Jan 2018 06:06:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516284413; cv=none; d=google.com; s=arc-20160816; b=Aqyy0E3QD/pNAB/kBrQCvIki/hRrVln0VRmnzLIlTlj4vwniuNPPb36JfDtbBiRuG0 tWFpaOVbORYG6M44KxAZb5RmiPGtsEKJvvdmdoejiUNf/BcbngpZUscKcQ6DEKvsm6nu j02FC62jPdnRe312i1sGRWdUkMxmhDiLOLLEscDvK+5QDMuJLx2U2iG8iPe6eCCAu3cI Plzukiihsaqsel7rv3JMRg6VUQ6QdjYJesEGd9RZzhg186PpxbpVQUDJjCBwG8Kshc6A madU4NX6icHnYbO+g2Lfxbs4vFD0wDET8shr/1tZJ6AtPgomjKNjHHzoAK1GaZK2hr/B i1VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=TbFxh7K6qRqg5c6uE0kjTWrUt4JzzpsWzxJccv+nqrs=; b=C74dXT/Vf4LFsNfI3BeQNYVlCU2mta6HkDwYMn6wPXCF3mx1OxFiywQvSx9Lz3Bk8T tNG8COk8+U8BM0NP6Y3Ifc3GIGI/eN9Vkr2ZmgtTKt3jz1QPjwazX8+YUNzbz/8L8xHb dRTZLA3RypqCIQoxM9sctfoDQ81XUcx7+GpEzrs/KEiaduXYJkjL1z/OEi++T0Z8gH0E BD1JHl7oxp7ZYAfDgehrBu6gwmqVWM3UFq+B0MTqXxy9t1trIFJ3PIggOKbLpu7eLd7t EDUoVsKmX5Wu64i/b5QtPekS/43Q+cHnyMyjX1FeAeO1GJxIo7YefmU0KK/usM1kWOw3 3R9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id a85si1198861qkb.116.2018.01.18.06.06.53; Thu, 18 Jan 2018 06:06:53 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 2C5F0627F8; Thu, 18 Jan 2018 14:06:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 94CAC6280D; Thu, 18 Jan 2018 14:03:22 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id C8628627F1; Thu, 18 Jan 2018 14:03:09 +0000 (UTC) Received: from forward103p.mail.yandex.net (forward103p.mail.yandex.net [77.88.28.106]) by lists.linaro.org (Postfix) with ESMTPS id D879762802 for ; Thu, 18 Jan 2018 14:01:19 +0000 (UTC) Received: from mxback17j.mail.yandex.net (mxback17j.mail.yandex.net [IPv6:2a02:6b8:0:1619::93]) by forward103p.mail.yandex.net (Yandex) with ESMTP id 46CD82183CB8 for ; Thu, 18 Jan 2018 17:01:18 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback17j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id KmATEpSnMz-1IeSXOH1; Thu, 18 Jan 2018 17:01:18 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id sNY3tHYRi1-1HhesD3c; Thu, 18 Jan 2018 17:01:17 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 18 Jan 2018 17:01:12 +0300 Message-Id: <1516284076-2857-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516284076-2857-1-git-send-email-odpbot@yandex.ru> References: <1516284076-2857-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 381 Subject: [lng-odp] [PATCH CATERPILLAR v4 1/5] example: add papi path configuration option X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 381 (bogdanPricope:cat_benchmark_poc) ** https://github.com/Linaro/odp/pull/381 ** Patch: https://github.com/Linaro/odp/pull/381.patch ** Base sha: 4d17f8ae64aba0e6f24877be30f86ae5880cef7e ** Merge commit sha: c651bdf2f6e197eb49c2aecff6f64a247db2b982 **/ example/m4/configure.m4 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/example/m4/configure.m4 b/example/m4/configure.m4 index 208c5d6d7..034415903 100644 --- a/example/m4/configure.m4 +++ b/example/m4/configure.m4 @@ -7,6 +7,16 @@ AC_ARG_ENABLE([test-example], [test_example=yes]) AM_CONDITIONAL([test_example], [test x$test_example = xyes ]) +PAPI_PATH="" +code_instrumentation=no +AC_ARG_WITH([papi-path], +AS_HELP_STRING([--with-papi-path=DIR path to papi install directory]), + [PAPI_PATH="$withval" + code_instrumentation=yes],[]) + +AC_SUBST([PAPI_PATH]) +AM_CONDITIONAL([CODE_INSTRUM], [test x$code_instrumentation = xyes ]) + AC_CONFIG_FILES([example/classifier/Makefile example/generator/Makefile example/hello/Makefile From patchwork Thu Jan 18 14:01:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 124972 Delivered-To: patch@linaro.org Received: by 10.46.64.27 with SMTP id n27csp143857lja; Thu, 18 Jan 2018 06:15:32 -0800 (PST) X-Google-Smtp-Source: ACJfBosk18Cbqx3w2LPiFa6FRSkazG9t6K08s9ckOdF+zXaikVRqp03BfS2G6xpVmoGhGjgsZRrM X-Received: by 10.55.214.75 with SMTP id t72mr66484968qki.12.1516284929070; Thu, 18 Jan 2018 06:15:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516284929; cv=none; d=google.com; s=arc-20160816; b=TvOoQHz+/RF5fZChxxHT5OdL/OgQHPG+6F8C5Zw256OhdUXb2jXY4c9r3KdO+lMx0l naDfsYj0GxBXb2yAkEllUaQ+kmXJNtnWvWRYE7TnDN/atNCVzGEEDalFIdcIPqyHMFxi FpxX4AtXuJjmHJT06m3FT0dPAYTBcbGw9UAzGGHSyYrNvB/h3OKNVPc60PlWSsB9BuoO pKCQ4mKBysZFNwP4laiXAHZP1pe0cBYXnC2LvGYbzuTBLUAvnnpuBaVxDxFMh6hTANwD P+I2+JwmnwjFKehXBW9LhL+OC9KDudJsAJE0LjOBSoA/7Uboqejpp1jrk4ej9JnqDgNA jUsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=6EWcNAUJaLUiAMzDJVSrNOjubanfdyyH9+vAhekk3bI=; b=yaLsHUHd+yRf9fnHKqosz5DiOj+wnsbXMLn/C1v0INpVlr/qzWPiRQuHzoaKR7Lt/Y h2gE6GYp9L/UgzDFMa8X8Tv7y2fwp1j4gHPdAf8dzzOvlm77OvBY71kKGafqh79semax 8MXOfoq9f+Y3w7ZYhyDeCp9Ycgb5uVWNqi8+TgVCgKQ/UBoxd6Es/BFV3DXsG899so4F 8h/jQIYjS22PFMBpSatOs6AFkvwZn4zdlgJmuYaU4CrdlDdaN/Yve2HSgRbCJ2GW1c++ wgYrJp4y3ZZCxFzbt5Ale+smRpDhJ6lF78RI19LaceM6I4YB4XkmkwA98WMEixJOpPpm 7G9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id p62si3014313qkb.184.2018.01.18.06.15.28; Thu, 18 Jan 2018 06:15:29 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 7510362815; Thu, 18 Jan 2018 14:15:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 18621627CD; Thu, 18 Jan 2018 14:06:41 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 39FD06280B; Thu, 18 Jan 2018 14:06:32 +0000 (UTC) Received: from forward106j.mail.yandex.net (forward106j.mail.yandex.net [5.45.198.249]) by lists.linaro.org (Postfix) with ESMTPS id 707E86282D for ; Thu, 18 Jan 2018 14:04:26 +0000 (UTC) Received: from mxback20j.mail.yandex.net (mxback20j.mail.yandex.net [IPv6:2a02:6b8:0:1619::114]) by forward106j.mail.yandex.net (Yandex) with ESMTP id F3D9B1803053 for ; Thu, 18 Jan 2018 17:01:18 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback20j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id u2flrjWi70-1IfK7IwQ; Thu, 18 Jan 2018 17:01:18 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id sNY3tHYRi1-1IhGEfZG; Thu, 18 Jan 2018 17:01:18 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 18 Jan 2018 17:01:13 +0300 Message-Id: <1516284076-2857-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516284076-2857-1-git-send-email-odpbot@yandex.ru> References: <1516284076-2857-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 381 Subject: [lng-odp] [PATCH CATERPILLAR v4 2/5] example: instrum: add skeleton X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 381 (bogdanPricope:cat_benchmark_poc) ** https://github.com/Linaro/odp/pull/381 ** Patch: https://github.com/Linaro/odp/pull/381.patch ** Base sha: 4d17f8ae64aba0e6f24877be30f86ae5880cef7e ** Merge commit sha: c651bdf2f6e197eb49c2aecff6f64a247db2b982 **/ example/Makefile.am | 4 ++++ example/Makefile.inc | 4 ++++ example/instrum/Makefile.am | 20 ++++++++++++++++++++ example/instrum/instrum.c | 18 ++++++++++++++++++ example/m4/configure.m4 | 1 + 5 files changed, 47 insertions(+) create mode 100644 example/instrum/Makefile.am create mode 100644 example/instrum/instrum.c diff --git a/example/Makefile.am b/example/Makefile.am index b6e8d81fe..99c5726f7 100644 --- a/example/Makefile.am +++ b/example/Makefile.am @@ -13,4 +13,8 @@ SUBDIRS = classifier \ ddf_ifs \ ddf_app +if CODE_INSTRUM +SUBDIRS += instrum +endif + noinst_HEADERS = example_debug.h diff --git a/example/Makefile.inc b/example/Makefile.inc index 31bf7c435..78b750cda 100644 --- a/example/Makefile.inc +++ b/example/Makefile.inc @@ -13,4 +13,8 @@ AM_CFLAGS = \ -I$(top_srcdir)/platform/@with_platform@/arch/@ARCH_DIR@ \ -I$(top_builddir)/include +if CODE_INSTRUM +AM_LDFLAGS = -L$(LIB) -lssl -lcrypto -latomic +else AM_LDFLAGS = -L$(LIB) -static +endif diff --git a/example/instrum/Makefile.am b/example/instrum/Makefile.am new file mode 100644 index 000000000..bf2a19c0d --- /dev/null +++ b/example/instrum/Makefile.am @@ -0,0 +1,20 @@ +LIB = $(top_builddir)/lib + +AM_CFLAGS = \ + -I$(srcdir) \ + -I$(top_srcdir)/example \ + -I$(top_srcdir)/platform/@with_platform@/include \ + -I$(top_srcdir)/include/ \ + -I$(top_srcdir)/include/odp/arch/@ARCH_ABI@ \ + -I$(top_srcdir)/helper/include \ + -I$(top_builddir)/platform/@with_platform@/include \ + -I$(top_srcdir)/platform/@with_platform@/arch/@ARCH_DIR@ \ + -I$(top_builddir)/include \ + -I$(PAPI_PATH)/include + +AM_LDFLAGS = -L$(PAPI_PATH)/lib -lpapi + +lib_LTLIBRARIES = $(LIB)/libinstrum.la + +__LIB__libinstrum_la_SOURCES = \ + instrum.c diff --git a/example/instrum/instrum.c b/example/instrum/instrum.c new file mode 100644 index 000000000..88580c58f --- /dev/null +++ b/example/instrum/instrum.c @@ -0,0 +1,18 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include + +static __attribute__((constructor)) void setup_wrappers(void) +{ + printf("Setup Wrappers\n"); +} + +static __attribute__((destructor)) void teardown_wrappers(void) +{ + printf("Teardown Wrappers\n"); +} diff --git a/example/m4/configure.m4 b/example/m4/configure.m4 index 034415903..d2258bf27 100644 --- a/example/m4/configure.m4 +++ b/example/m4/configure.m4 @@ -31,4 +31,5 @@ AC_CONFIG_FILES([example/classifier/Makefile example/traffic_mgmt/Makefile example/ddf_ifs/Makefile example/ddf_app/Makefile + example/instrum/Makefile example/Makefile]) From patchwork Thu Jan 18 14:01:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 124970 Delivered-To: patch@linaro.org Received: by 10.46.64.27 with SMTP id n27csp141897lja; Thu, 18 Jan 2018 06:10:18 -0800 (PST) X-Google-Smtp-Source: ACJfBovnwpvQ+iPxIiTItG/Ljchc7RX0pB3arFmUMyD8u6jBBE5XtaVe3lu0zmZXbuAjaSYWJJso X-Received: by 10.55.168.137 with SMTP id r131mr53864317qke.27.1516284618191; Thu, 18 Jan 2018 06:10:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516284618; cv=none; d=google.com; s=arc-20160816; b=ctaI5OFwGzOD7+OBI7A2rlyN+mIMjNcNFbHhd4WbJkeL4cZ/NwQWwVJEWBJH2zABUw Gvw9MnFMEKm8Tj7bdq10FU6KyUnwb+ffP4jIZsVQ+bdGB90zsPS2SKKWwIni1l7iCpJc 9GJpRzH8CueFNNzII5dhpYWlyvGLwX0Bokk9+EUwlCWuAmNI07cQoendUG9dinsXhcaV XXL7CIUhzow2kAKJ5cuRqiA/EsfPlmHcvrGYv6Qg98/DjBdYZ5GfCPplvK2M6xw8qbQQ MYtkwXbFTq04C/IsGe22LrANLgMTWurJgKyAYl2rgb9n+IroUA5ObuEQQEnBLdfoDjtx DeGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=v1uRstrSOV5RHrrdeSy9vCfbdrvw5ab1/7u+uXciSEU=; b=JOJmr6belZKlY1lma9Qz6og82hnMgQdw1AxCiqc7U1GpLFBxUFvDAsSNtNURaNKZJ9 JSOo8sKoHN5KlEgPtFTTExEzEsV1fETzv5lV+94PsKjHju2Zv62dIY78PDQThTf48Lss mjTkrXGC8GGngZOawYHkQSO6v0dggI/dEMunBnDMT9Ev9ehFed15ArOF9F348NoqGwJe P+XgMt+hfJfYs2aOXRHS1HstjwRGcwmapbmjvwSm/uGtP8L/S+niezklvLF/UQQKG1f7 OV9sWNPlHt7s/fNd7RtYk0FUXhBaFMu4OXGe6w0ZsB7qfgib+7JQUuOH6SrAAwAIKXHg d6KA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id h197si2868869qke.105.2018.01.18.06.10.17; Thu, 18 Jan 2018 06:10:18 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id CCFED62793; Thu, 18 Jan 2018 14:10:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 172AA627DD; Thu, 18 Jan 2018 14:03:50 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 97C38627F0; Thu, 18 Jan 2018 14:03:13 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id 7A712627FA for ; Thu, 18 Jan 2018 14:01:21 +0000 (UTC) Received: from mxback15j.mail.yandex.net (mxback15j.mail.yandex.net [IPv6:2a02:6b8:0:1619::91]) by forward103j.mail.yandex.net (Yandex) with ESMTP id 3F5DA34C2902 for ; Thu, 18 Jan 2018 17:01:20 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback15j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id jVTDxoF4IO-1KYS0QHd; Thu, 18 Jan 2018 17:01:20 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id sNY3tHYRi1-1JhqexAt; Thu, 18 Jan 2018 17:01:19 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 18 Jan 2018 17:01:14 +0300 Message-Id: <1516284076-2857-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516284076-2857-1-git-send-email-odpbot@yandex.ru> References: <1516284076-2857-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 381 Subject: [lng-odp] [PATCH CATERPILLAR v4 3/5] example: instrum: use low level API to retrieve performance counters X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 381 (bogdanPricope:cat_benchmark_poc) ** https://github.com/Linaro/odp/pull/381 ** Patch: https://github.com/Linaro/odp/pull/381.patch ** Base sha: 4d17f8ae64aba0e6f24877be30f86ae5880cef7e ** Merge commit sha: c651bdf2f6e197eb49c2aecff6f64a247db2b982 **/ example/instrum/Makefile.am | 16 ++++- example/instrum/drv.c | 39 +++++++++++ example/instrum/drv.h | 19 ++++++ example/instrum/init.c | 54 +++++++++++++++ example/instrum/init.h | 19 ++++++ example/instrum/instrum.c | 19 +++++- example/instrum/instrum_common.h | 34 ++++++++++ example/instrum/papi_cnt.c | 143 +++++++++++++++++++++++++++++++++++++++ example/instrum/papi_cnt.h | 28 ++++++++ example/instrum/sample.h | 29 ++++++++ example/instrum/sched.c | 43 ++++++++++++ example/instrum/sched.h | 19 ++++++ example/instrum/store.c | 126 ++++++++++++++++++++++++++++++++++ example/instrum/store.h | 36 ++++++++++ 14 files changed, 622 insertions(+), 2 deletions(-) create mode 100644 example/instrum/drv.c create mode 100644 example/instrum/drv.h create mode 100644 example/instrum/init.c create mode 100644 example/instrum/init.h create mode 100644 example/instrum/instrum_common.h create mode 100644 example/instrum/papi_cnt.c create mode 100644 example/instrum/papi_cnt.h create mode 100644 example/instrum/sample.h create mode 100644 example/instrum/sched.c create mode 100644 example/instrum/sched.h create mode 100644 example/instrum/store.c create mode 100644 example/instrum/store.h diff --git a/example/instrum/Makefile.am b/example/instrum/Makefile.am index bf2a19c0d..452b36c46 100644 --- a/example/instrum/Makefile.am +++ b/example/instrum/Makefile.am @@ -16,5 +16,19 @@ AM_LDFLAGS = -L$(PAPI_PATH)/lib -lpapi lib_LTLIBRARIES = $(LIB)/libinstrum.la +noinst_HEADERS = \ + $(srcdir)/instrum_common.h \ + $(srcdir)/sample.h \ + $(srcdir)/store.h \ + $(srcdir)/papi_cnt.h \ + $(srcdir)/init.h \ + $(srcdir)/drv.h \ + $(srcdir)/sched.h + __LIB__libinstrum_la_SOURCES = \ - instrum.c + instrum.c \ + store.c \ + papi_cnt.c \ + init.c \ + drv.c \ + sched.c diff --git a/example/instrum/drv.c b/example/instrum/drv.c new file mode 100644 index 000000000..d82018ecc --- /dev/null +++ b/example/instrum/drv.c @@ -0,0 +1,39 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include +#include +#include + +static int (*instr_odpdrv_print_all)(void); + +int instr_odpdrv_init(void) +{ + INSTR_FUNCTION(odpdrv_print_all); + + if (!instr_odpdrv_print_all) { + printf("odpdrv_print_all: Not Found\n"); + return -1; + } + + return 0; +} + +int odpdrv_print_all(void) +{ + int ret; + + STORE_SAMPLE_INIT; + + STORE_SAMPLE_START; + ret = (*instr_odpdrv_print_all)(); + STORE_SAMPLE_END; + + return ret; +} diff --git a/example/instrum/drv.h b/example/instrum/drv.h new file mode 100644 index 000000000..12441a7e4 --- /dev/null +++ b/example/instrum/drv.h @@ -0,0 +1,19 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef __INSTRUM_DRV_H__ +#define __INSTRUM_DRV_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +int instr_odpdrv_init(void); + +#ifdef __cplusplus +} +#endif +#endif /* __INSTRUM_DRV_H__ */ diff --git a/example/instrum/init.c b/example/instrum/init.c new file mode 100644 index 000000000..8691ff978 --- /dev/null +++ b/example/instrum/init.c @@ -0,0 +1,54 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include +#include +#include + +static int (*instr_odp_init_local)(odp_instance_t instance, + odp_thread_type_t thr_type); + +static int (*instr_odp_term_local)(void); + +int instr_odpinit_init(void) +{ + INSTR_FUNCTION(odp_init_local); + + if (!instr_odp_init_local) { + printf("odp_init_local: Not Found\n"); + return -1; + } + + INSTR_FUNCTION(odp_term_local); + + if (!instr_odp_term_local) { + printf("odp_term_local: Not Found\n"); + return -1; + } + + return 0; +} + +int odp_init_local(odp_instance_t instance, odp_thread_type_t thr_type) +{ + int ret; + + ret = (*instr_odp_init_local)(instance, thr_type); + + instr_store_init_local(); + + return ret; +} + +int odp_term_local(void) +{ + instr_store_term_local(); + + return (*instr_odp_term_local)(); +} diff --git a/example/instrum/init.h b/example/instrum/init.h new file mode 100644 index 000000000..b92e9d4a3 --- /dev/null +++ b/example/instrum/init.h @@ -0,0 +1,19 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef __INSTRUM_INIT_H__ +#define __INSTRUM_INIT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +int instr_odpinit_init(void); + +#ifdef __cplusplus +} +#endif +#endif /*__INSTRUM_INIT_H__*/ diff --git a/example/instrum/instrum.c b/example/instrum/instrum.c index 88580c58f..05b38da68 100644 --- a/example/instrum/instrum.c +++ b/example/instrum/instrum.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2017, Linaro Limited +/* Copyright (c) 2018, Linaro Limited * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -6,13 +6,30 @@ #include #include +#include +#include +#include +#include static __attribute__((constructor)) void setup_wrappers(void) { printf("Setup Wrappers\n"); + + if (instr_store_init()) + return; + + if (instr_odpinit_init()) + return; + + if (instr_odpdrv_init()) + return; + + if (instr_odpsched_init()) + return; } static __attribute__((destructor)) void teardown_wrappers(void) { printf("Teardown Wrappers\n"); + instr_store_term(); } diff --git a/example/instrum/instrum_common.h b/example/instrum/instrum_common.h new file mode 100644 index 000000000..594423e1f --- /dev/null +++ b/example/instrum/instrum_common.h @@ -0,0 +1,34 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef __INSTRUM_COMMON_H__ +#define __INSTRUM_COMMON_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef RTLD_NEXT +/*#define __GNU_SOURCE*/ +#define __USE_GNU +#endif + +#include +#include + +#define INSTR_FUNCTION(func) do { \ + instr_##func = dlsym(RTLD_NEXT, #func); \ + if (dlerror()) { \ + errno = EACCES; \ + instr_##func = NULL; \ + } \ + } while (0) + +#ifdef __cplusplus +} +#endif + +#endif /* __INSTRUM_COMMON_H__ */ diff --git a/example/instrum/papi_cnt.c b/example/instrum/papi_cnt.c new file mode 100644 index 000000000..c38c856a0 --- /dev/null +++ b/example/instrum/papi_cnt.c @@ -0,0 +1,143 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include +#include + +static int papi_event_tab[SAMPLE_COUNTER_TAB_SIZE] = {PAPI_BR_CN, PAPI_L2_DCM}; + +static __thread int event_set = PAPI_NULL; + +int papi_init(void) +{ + int retval, i; + + retval = PAPI_library_init(PAPI_VER_CURRENT); + if (retval != PAPI_VER_CURRENT) { + printf("PAPI Library initialization error!\n"); + return -1; + } + + retval = PAPI_thread_init((unsigned long(*)(void))(pthread_self)); + if (retval != PAPI_OK) { + printf("PAPI_thread_init error!\n"); + goto err_shutdown; + } + + if (PAPI_set_granularity(PAPI_GRN_THR) != PAPI_OK) { + printf("PAPI_set_granularity error!\n"); + goto err_shutdown; + } + + for (i = 0; i < SAMPLE_COUNTER_TAB_SIZE; i++) { + retval = PAPI_query_event(papi_event_tab[i]); + if (retval != PAPI_OK) { + printf("PAPI_query_event %d - error\n", i); + goto err_shutdown; + } + } + + return 0; + +err_shutdown: + PAPI_shutdown(); + + return -1; +} + +void papi_term(void) +{ + PAPI_shutdown(); +} + +int papi_init_local(void) +{ + int retval; + + retval = PAPI_register_thread(); + if (retval != PAPI_OK) { + printf("PAPI_register_thread failed - %d\n", retval); + return -1; + } + + /* Create LL event set */ + event_set = PAPI_NULL; + retval = PAPI_create_eventset(&event_set); + if (retval != PAPI_OK) { + printf("PAPI_create_eventset error: %d\n", retval); + return -1; + } + + retval = PAPI_add_events(event_set, papi_event_tab, + SAMPLE_COUNTER_TAB_SIZE); + if (retval != PAPI_OK) { + printf("PAPI_add_events error: %d\n", retval); + goto err_clean_evset; + } + + retval = PAPI_start(event_set); + if (retval != PAPI_OK) { + printf("PAPI_start error: %d\n", retval); + goto err_clean_evset; + } + + return 0; + +err_clean_evset: + PAPI_cleanup_eventset(event_set); + PAPI_destroy_eventset(&event_set); + + return -1; +} + +int papi_term_local(void) +{ + long long last_counters[SAMPLE_COUNTER_TAB_SIZE]; + + if (PAPI_stop(event_set, last_counters) == PAPI_OK) { + int i; + + for (i = 0; i < SAMPLE_COUNTER_TAB_SIZE; i++) + printf("Counter[%d] = %lld\n", i, last_counters[i]); + } + + PAPI_cleanup_eventset(event_set); + PAPI_destroy_eventset(&event_set); + + return 0; +} + +int papi_sample_start(profiling_sample_t *spl) +{ + spl->timestamp_ns = PAPI_get_real_nsec(); + if (PAPI_read_ts(event_set, spl->counters, &spl->diff_cyc) != PAPI_OK) { + fprintf(stderr, "PAPI_read_counters - FAILED\n"); + return -1; + } + + return 0; +} + +int papi_sample_end(profiling_sample_t *spl) +{ + long long end_counters[SAMPLE_COUNTER_TAB_SIZE], end_cyc; + int i; + + if (PAPI_read_ts(event_set, end_counters, &end_cyc) != PAPI_OK) { + fprintf(stderr, "PAPI_read_counters - FAILED\n"); + return -1; + } + + for (i = 0; i < SAMPLE_COUNTER_TAB_SIZE; i++) + spl->counters[i] = end_counters[i] - spl->counters[i]; + + spl->diff_cyc = end_cyc - spl->diff_cyc; + + return 0; +} diff --git a/example/instrum/papi_cnt.h b/example/instrum/papi_cnt.h new file mode 100644 index 000000000..72e49c72c --- /dev/null +++ b/example/instrum/papi_cnt.h @@ -0,0 +1,28 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef __INSTRUM_PAPI_COUNTERS_H__ +#define __INSTRUM_PAPI_COUNTERS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +int papi_init(void); +void papi_term(void); +int papi_init_local(void); +int papi_term_local(void); + +int papi_sample_start(profiling_sample_t *spl); +int papi_sample_end(profiling_sample_t *spl); + +#ifdef __cplusplus +} +#endif +#endif /* __INSTRUM_PAPI_COUNTERS_H__ */ + diff --git a/example/instrum/sample.h b/example/instrum/sample.h new file mode 100644 index 000000000..ca5f183a1 --- /dev/null +++ b/example/instrum/sample.h @@ -0,0 +1,29 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef __INSTRUM_SAMPLE_H__ +#define __INSTRUM_SAMPLE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define SAMPLE_NAME_SIZE_MAX 20 +#define SAMPLE_COUNTER_TAB_SIZE 2 + +typedef struct { + char name[SAMPLE_NAME_SIZE_MAX]; + long long timestamp_ns; + long long diff_cyc; + + long long counters[SAMPLE_COUNTER_TAB_SIZE]; +} profiling_sample_t; + +#ifdef __cplusplus +} +#endif +#endif /* __INSTRUM_SAMPLE_H__ */ + diff --git a/example/instrum/sched.c b/example/instrum/sched.c new file mode 100644 index 000000000..3e4a03bf1 --- /dev/null +++ b/example/instrum/sched.c @@ -0,0 +1,43 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include +#include +#include + +static int (*instr_odp_schedule_multi)(odp_queue_t *from, + uint64_t wait, + odp_event_t events[], + int num); + +int instr_odpsched_init(void) +{ + INSTR_FUNCTION(odp_schedule_multi); + + if (!instr_odp_schedule_multi) { + printf("odp_schedule_multi: Not Found\n"); + return -1; + } + + return 0; +} + +int odp_schedule_multi(odp_queue_t *from, uint64_t wait, odp_event_t events[], + int num) +{ + int ret; + + STORE_SAMPLE_INIT; + + STORE_SAMPLE_START; + ret = (*instr_odp_schedule_multi)(from, wait, events, num); + STORE_SAMPLE_END; + + return ret; +} diff --git a/example/instrum/sched.h b/example/instrum/sched.h new file mode 100644 index 000000000..2a092b0ed --- /dev/null +++ b/example/instrum/sched.h @@ -0,0 +1,19 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef __INSTRUM_SCHED_H__ +#define __INSTRUM_SCHED_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +int instr_odpsched_init(void); + +#ifdef __cplusplus +} +#endif +#endif /* __INSTRUM_SCHED_H__ */ diff --git a/example/instrum/store.c b/example/instrum/store.c new file mode 100644 index 000000000..aa338aa6c --- /dev/null +++ b/example/instrum/store.c @@ -0,0 +1,126 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include +#include +#include + +#define SAMPLE_TAB_SIZE 50000 + +static __thread profiling_sample_t profile_sample_tab[SAMPLE_TAB_SIZE]; +static __thread uint64_t profile_sample_idx; +static __thread uint64_t profile_sample_ovf; + +#define STORE_DIR_ENV "ODP_INSTRUM_STORE_DIR" +#define STORE_DIR_NAME_DFLT "/tmp" +#define STORE_DIR_NAME_SIZE_MAX 250 +#define STORE_FILE_NAME_SIZE_MAX 250 + +static char store_dir[STORE_DIR_NAME_SIZE_MAX]; + +int instr_store_init(void) +{ + const char *store_dir_env = NULL; + + store_dir_env = getenv(STORE_DIR_ENV); + if (!store_dir_env) + store_dir_env = STORE_DIR_NAME_DFLT; + + strncpy(store_dir, store_dir_env, STORE_DIR_NAME_SIZE_MAX); + store_dir[STORE_DIR_NAME_SIZE_MAX - 1] = '\0'; + + if (papi_init()) + return -1; + + return 0; +} + +void instr_store_term(void) +{ + papi_term(); +} + +int instr_store_init_local(void) +{ + return papi_init_local(); +} + +int instr_store_term_local(void) +{ + return papi_term_local(); +} + +static void store_dump(void) +{ + FILE *f = NULL; + char file_name[STORE_DIR_NAME_SIZE_MAX + STORE_FILE_NAME_SIZE_MAX]; + char smpl[250], smpl_tmp[250]; + int i, j; + + sprintf(file_name, "%s/profile_%d_%ju.csv", + store_dir, odp_thread_id(), + profile_sample_ovf); + + f = fopen(file_name, "w"); + if (f == NULL) { + printf("Failed to create profiling file %s\n", file_name); + return; + } + + for (i = 0; i < SAMPLE_TAB_SIZE; i++) { + sprintf(smpl, "%lld,%lld,%s", + profile_sample_tab[i].timestamp_ns, + profile_sample_tab[i].diff_cyc, + profile_sample_tab[i].name); + for (j = 0; j < SAMPLE_COUNTER_TAB_SIZE; j++) { + sprintf(smpl_tmp, ",%lld", + profile_sample_tab[i].counters[j]); + strcat(smpl, smpl_tmp); + } + fprintf(f, "%s\n", smpl); + } + + fclose(f); +} + +instr_profiling_sample_t store_sample_start(const char *func) +{ + profiling_sample_t *spl = NULL; + + if (profile_sample_idx == SAMPLE_TAB_SIZE) + return NULL; + + spl = &profile_sample_tab[profile_sample_idx]; + + strncpy(spl->name, func, SAMPLE_NAME_SIZE_MAX); + spl->name[SAMPLE_NAME_SIZE_MAX - 1] = '\0'; + + if (papi_sample_start(spl)) + return NULL; + + profile_sample_idx++; + return spl; +} + +void store_sample_end(instr_profiling_sample_t _spl) +{ + profiling_sample_t *spl = _spl; + + if (!spl) /* failed sample - on start */ + return; + + if (papi_sample_end(spl)) + spl->name[0] = 0; /* failed sample - on end*/ + + if (profile_sample_idx == SAMPLE_TAB_SIZE) { + store_dump(); + profile_sample_idx = 0; + profile_sample_ovf++; + } +} diff --git a/example/instrum/store.h b/example/instrum/store.h new file mode 100644 index 000000000..1d671fbfd --- /dev/null +++ b/example/instrum/store.h @@ -0,0 +1,36 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef __INSTRUM_STORE_H__ +#define __INSTRUM_STORE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *instr_profiling_sample_t; + +#define STORE_SAMPLE_INIT \ + instr_profiling_sample_t _spl + +#define STORE_SAMPLE_START \ + (_spl = store_sample_start(__func__)) + +#define STORE_SAMPLE_END \ + store_sample_end(_spl) + +int instr_store_init(void); +void instr_store_term(void); +int instr_store_init_local(void); +int instr_store_term_local(void); + +instr_profiling_sample_t store_sample_start(const char *); +void store_sample_end(instr_profiling_sample_t); + +#ifdef __cplusplus +} +#endif +#endif /* __INSTRUM_STORE_H__ */ From patchwork Thu Jan 18 14:01:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 124967 Delivered-To: patch@linaro.org Received: by 10.46.64.27 with SMTP id n27csp140675lja; Thu, 18 Jan 2018 06:07:40 -0800 (PST) X-Google-Smtp-Source: ACJfBos/F+/ZXQR1AJ3p6qX+fsbt3XMXhS8ZW2H2MVcys34jS4kW/vXFZMQrv+kM4JMMk/AvL6R3 X-Received: by 10.55.12.4 with SMTP id 4mr44867095qkm.158.1516284460711; Thu, 18 Jan 2018 06:07:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516284460; cv=none; d=google.com; s=arc-20160816; b=EgUMW7hfE6Xwjsz4xRT6MiwvzdKqGJnZpeqTaNJ7B9P8RhVtmOzulQophud1q7/ig7 vHNPdqaaPwFICilebZn7MNK0nnNI/bGWaIfRw6hL7eM7VVLY2gU7Eme6Yg7Xz2faDkTt 7mRKyGTLid5lRxFBPhTGm17MWKemO4RorXRy5mGOrtf+agQqbnNzKPJU5B0r7EhMtEez 0Nu+9yasMsWkzBwFcjApmByUMIHHlC+GMxsCieXlfFNG3+juHJcFxmEigOtq+oqrF3VJ XPWh6YFLl1ZNfDzc0ndBnVNoVvH00sLJaLCidiOsPmpXMwaVV6iW3cLabGDfOXssLprf R2rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=W9VL/pGMe0aDfj/UrZGGhLbbyNx76NC9Q6W3mF9iD5k=; b=KLG3twfukkMY8brNik5dKAwrNJqXnuVNij0eDFgUweeo4snapamnyDwS0cKzilUaVz Xr/SAr/UoBYaQm0sR6zms9N+SlBjgmWO/f54Z6io3IUg+AHa6ncbjoJ/DaiRIBB9n+5N IsuBTciv4IM4LmD9YVc8M8AO9hvO8Na8mfinuBkVlMN5iLsjcbCf01jtPEZmVGiQIESE av360Ukrj6xw56N5dK9S0yMB2kJ80LcsL7xzEqHBi2Ckf7BAXoS5WpaFoemzVBQpBU95 wxFl2BgDj8xC2IFRdcDFzT+Ujf91SDYiK88tOuJi+p8bmfGVv7Sbfyde8QX3QjfHPX8t HKIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id k53si888907qtc.244.2018.01.18.06.07.40; Thu, 18 Jan 2018 06:07:40 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 55EB462787; Thu, 18 Jan 2018 14:07:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id E01F162807; Thu, 18 Jan 2018 14:03:26 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 5E63E627F1; Thu, 18 Jan 2018 14:03:10 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id 1535962800 for ; Thu, 18 Jan 2018 14:01:22 +0000 (UTC) Received: from mxback10o.mail.yandex.net (mxback10o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::24]) by forward103j.mail.yandex.net (Yandex) with ESMTP id 04CED34C531E for ; Thu, 18 Jan 2018 17:01:21 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback10o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 6NX7SSei2n-1KjS1njQ; Thu, 18 Jan 2018 17:01:20 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id sNY3tHYRi1-1Khq0bsL; Thu, 18 Jan 2018 17:01:20 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 18 Jan 2018 17:01:15 +0300 Message-Id: <1516284076-2857-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516284076-2857-1-git-send-email-odpbot@yandex.ru> References: <1516284076-2857-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 381 Subject: [lng-odp] [PATCH CATERPILLAR v4 4/5] example: instrum: configure papi event set X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Bogdan Pricope Configure the set of papi counters to be acquired via an environment variable. Signed-off-by: Bogdan Pricope --- /** Email created from pull request 381 (bogdanPricope:cat_benchmark_poc) ** https://github.com/Linaro/odp/pull/381 ** Patch: https://github.com/Linaro/odp/pull/381.patch ** Base sha: 4d17f8ae64aba0e6f24877be30f86ae5880cef7e ** Merge commit sha: c651bdf2f6e197eb49c2aecff6f64a247db2b982 **/ example/instrum/papi_cnt.c | 44 +++++++++++++++++++++++++++++++++++++++----- example/instrum/papi_cnt.h | 2 ++ example/instrum/sample.h | 2 +- example/instrum/store.c | 4 +++- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/example/instrum/papi_cnt.c b/example/instrum/papi_cnt.c index c38c856a0..da8267834 100644 --- a/example/instrum/papi_cnt.c +++ b/example/instrum/papi_cnt.c @@ -6,17 +6,25 @@ #include #include +#include #include #include #include -static int papi_event_tab[SAMPLE_COUNTER_TAB_SIZE] = {PAPI_BR_CN, PAPI_L2_DCM}; +#define PAPI_EVENTS_ENV "ODP_INSTRUM_PAPI_EVENTS" + +#define PAPI_EVENT_TAB_SIZE_DFLT 2 +int papi_event_tab_dflt[PAPI_EVENT_TAB_SIZE_DFLT] = {PAPI_BR_CN, PAPI_L2_DCM}; + +static int papi_event_tab[SAMPLE_COUNTER_TAB_SIZE]; +static int papi_event_tab_size; static __thread int event_set = PAPI_NULL; int papi_init(void) { int retval, i; + char *papi_events_env = NULL; retval = PAPI_library_init(PAPI_VER_CURRENT); if (retval != PAPI_VER_CURRENT) { @@ -35,7 +43,28 @@ int papi_init(void) goto err_shutdown; } - for (i = 0; i < SAMPLE_COUNTER_TAB_SIZE; i++) { + papi_events_env = getenv(PAPI_EVENTS_ENV); + if (papi_events_env) { + char *tk = strtok(papi_events_env, ","); + int papi_event; + + while (tk != NULL && + papi_event_tab_size < SAMPLE_COUNTER_TAB_SIZE) { + if (PAPI_event_name_to_code(tk, &papi_event) == PAPI_OK) + papi_event_tab[papi_event_tab_size++] = + papi_event; + + tk = strtok(NULL, ","); + } + } + + if (!papi_event_tab_size) { + for (i = 0; i < PAPI_EVENT_TAB_SIZE_DFLT; i++) + papi_event_tab[i] = papi_event_tab_dflt[i]; + papi_event_tab_size = PAPI_EVENT_TAB_SIZE_DFLT; + } + + for (i = 0; i < papi_event_tab_size; i++) { retval = PAPI_query_event(papi_event_tab[i]); if (retval != PAPI_OK) { printf("PAPI_query_event %d - error\n", i); @@ -75,7 +104,7 @@ int papi_init_local(void) } retval = PAPI_add_events(event_set, papi_event_tab, - SAMPLE_COUNTER_TAB_SIZE); + papi_event_tab_size); if (retval != PAPI_OK) { printf("PAPI_add_events error: %d\n", retval); goto err_clean_evset; @@ -103,7 +132,7 @@ int papi_term_local(void) if (PAPI_stop(event_set, last_counters) == PAPI_OK) { int i; - for (i = 0; i < SAMPLE_COUNTER_TAB_SIZE; i++) + for (i = 0; i < papi_event_tab_size; i++) printf("Counter[%d] = %lld\n", i, last_counters[i]); } @@ -113,6 +142,11 @@ int papi_term_local(void) return 0; } +int papi_counters_cnt(void) +{ + return papi_event_tab_size; +} + int papi_sample_start(profiling_sample_t *spl) { spl->timestamp_ns = PAPI_get_real_nsec(); @@ -134,7 +168,7 @@ int papi_sample_end(profiling_sample_t *spl) return -1; } - for (i = 0; i < SAMPLE_COUNTER_TAB_SIZE; i++) + for (i = 0; i < papi_event_tab_size; i++) spl->counters[i] = end_counters[i] - spl->counters[i]; spl->diff_cyc = end_cyc - spl->diff_cyc; diff --git a/example/instrum/papi_cnt.h b/example/instrum/papi_cnt.h index 72e49c72c..db55e75e0 100644 --- a/example/instrum/papi_cnt.h +++ b/example/instrum/papi_cnt.h @@ -18,6 +18,8 @@ void papi_term(void); int papi_init_local(void); int papi_term_local(void); +int papi_counters_cnt(void); + int papi_sample_start(profiling_sample_t *spl); int papi_sample_end(profiling_sample_t *spl); diff --git a/example/instrum/sample.h b/example/instrum/sample.h index ca5f183a1..e88ef4f96 100644 --- a/example/instrum/sample.h +++ b/example/instrum/sample.h @@ -12,7 +12,7 @@ extern "C" { #endif #define SAMPLE_NAME_SIZE_MAX 20 -#define SAMPLE_COUNTER_TAB_SIZE 2 +#define SAMPLE_COUNTER_TAB_SIZE 10 typedef struct { char name[SAMPLE_NAME_SIZE_MAX]; diff --git a/example/instrum/store.c b/example/instrum/store.c index aa338aa6c..ccc6f05ae 100644 --- a/example/instrum/store.c +++ b/example/instrum/store.c @@ -23,6 +23,7 @@ static __thread uint64_t profile_sample_ovf; #define STORE_FILE_NAME_SIZE_MAX 250 static char store_dir[STORE_DIR_NAME_SIZE_MAX]; +static int counters_cnt; int instr_store_init(void) { @@ -38,6 +39,7 @@ int instr_store_init(void) if (papi_init()) return -1; + counters_cnt = papi_counters_cnt(); return 0; } @@ -78,7 +80,7 @@ static void store_dump(void) profile_sample_tab[i].timestamp_ns, profile_sample_tab[i].diff_cyc, profile_sample_tab[i].name); - for (j = 0; j < SAMPLE_COUNTER_TAB_SIZE; j++) { + for (j = 0; j < counters_cnt; j++) { sprintf(smpl_tmp, ",%lld", profile_sample_tab[i].counters[j]); strcat(smpl, smpl_tmp); From patchwork Thu Jan 18 14:01:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 124969 Delivered-To: patch@linaro.org Received: by 10.46.64.27 with SMTP id n27csp141326lja; Thu, 18 Jan 2018 06:09:11 -0800 (PST) X-Google-Smtp-Source: ACJfBovvGh9eHNk8jLeiD1tdikN2mfCf4LkSGszHUsYqa1xOh34ExwJFpBgH9wJl5F88IYX9jZtP X-Received: by 10.55.195.219 with SMTP id r88mr61596217qkl.219.1516284551380; Thu, 18 Jan 2018 06:09:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516284551; cv=none; d=google.com; s=arc-20160816; b=idXvSJp+7F+L8J0gwn/gpoDERKpPrJ8hneSDnVAvkmUyy/cbRsCotaC5INN7UzA+Ms 0W8EG9dKJKEllhQfH7RVJkqSQdL/vsXEdG3+dJOqZv+/UlCgWYX5Ltxt8E1cAdVkTtLc LbdQ6z5259zH2rUDm61RA5qcnV1Uk9YBRanrOryMan8hy+f4F52CuKnNzQZfY4NKVgPx tvpF3yGaFpk3yY4/A97F1BCJ+FTctE5KYUv71KxDQY7otW+kHN7F12llWENLW4wOPtMD it7ZvudpYele2HjILi4fVbixKfem8aX/w/+XOVjyRALWMTABI/Ma/sXSNzYj+r2dyPqN Plow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=XnHdbQvbyb8e862lqfeNCHUXyErlnVo/WC1gdFS5T7s=; b=CP2i64UJ6m8OvB69sOvBHi/OFhyi6BCamAYIM3R5o0WgB+KbgOSmD4MsH2Jb8CzZxi fk+fwx1nPYWcPZuUsUYzuWNk7A3ArPcSQYqVSR4sEfuqhIKjYKc+ohNZSCTZaf+ra8We RwkjnuJ5kPPcWHcH5wxgphQHUOvNztGlq4784O+2jd90cAHW9WCU1m1TeKdIxRtB0fsn WjmLdDQ0eFGICGYlWTMLqTUkX/ThFqEULmeiBx4N3CWD+gMBQ4XCDpCiwKY/Y9rSihnY spfw0TZzwg7le0mx9tEj8aljyipVrWnPoNuQ/In4unpAZYv+vALYTkhTGBuIIs8rtPnT urMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id d58si642731qte.288.2018.01.18.06.09.11; Thu, 18 Jan 2018 06:09:11 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 11E9E6282D; Thu, 18 Jan 2018 14:09:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 3499D62815; Thu, 18 Jan 2018 14:03:34 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 1C1B9627F1; Thu, 18 Jan 2018 14:03:12 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 14833627F8 for ; Thu, 18 Jan 2018 14:01:23 +0000 (UTC) Received: from mxback6g.mail.yandex.net (mxback6g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:167]) by forward100p.mail.yandex.net (Yandex) with ESMTP id D114D5103629 for ; Thu, 18 Jan 2018 17:01:21 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback6g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 0pCPGZE9dX-1L4monrV; Thu, 18 Jan 2018 17:01:21 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id sNY3tHYRi1-1Lh494JR; Thu, 18 Jan 2018 17:01:21 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 18 Jan 2018 17:01:16 +0300 Message-Id: <1516284076-2857-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516284076-2857-1-git-send-email-odpbot@yandex.ru> References: <1516284076-2857-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 381 Subject: [lng-odp] [PATCH CATERPILLAR v4 5/5] example: instrum: configure instrumented API set X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Bogdan Pricope Add configure time option to trim API set to be instrumented. Signed-off-by: Bogdan Pricope --- /** Email created from pull request 381 (bogdanPricope:cat_benchmark_poc) ** https://github.com/Linaro/odp/pull/381 ** Patch: https://github.com/Linaro/odp/pull/381.patch ** Base sha: 4d17f8ae64aba0e6f24877be30f86ae5880cef7e ** Merge commit sha: c651bdf2f6e197eb49c2aecff6f64a247db2b982 **/ example/instrum/Makefile.am | 18 ++++++++++++++---- example/instrum/drv.h | 3 +++ example/instrum/instrum.c | 4 ++++ example/instrum/sched.h | 3 +++ example/m4/configure.m4 | 17 ++++++++++++----- 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/example/instrum/Makefile.am b/example/instrum/Makefile.am index 452b36c46..30c26046f 100644 --- a/example/instrum/Makefile.am +++ b/example/instrum/Makefile.am @@ -25,10 +25,20 @@ noinst_HEADERS = \ $(srcdir)/drv.h \ $(srcdir)/sched.h -__LIB__libinstrum_la_SOURCES = \ +INSTRUM_SRC = \ instrum.c \ store.c \ papi_cnt.c \ - init.c \ - drv.c \ - sched.c + init.c + +if CODE_INSTRUM_SCHED +AM_CFLAGS += -DCODE_INSTRUM_SCHED +INSTRUM_SRC += sched.c +endif + +if CODE_INSTRUM_DDF +AM_CFLAGS += -DCODE_INSTRUM_DDF +INSTRUM_SRC += drv.c +endif + +__LIB__libinstrum_la_SOURCES = $(INSTRUM_SRC) diff --git a/example/instrum/drv.h b/example/instrum/drv.h index 12441a7e4..ed3dd7a08 100644 --- a/example/instrum/drv.h +++ b/example/instrum/drv.h @@ -7,6 +7,8 @@ #ifndef __INSTRUM_DRV_H__ #define __INSTRUM_DRV_H__ +#ifdef CODE_INSTRUM_DDF + #ifdef __cplusplus extern "C" { #endif @@ -16,4 +18,5 @@ int instr_odpdrv_init(void); #ifdef __cplusplus } #endif +#endif /* CODE_INSTRUM_DDF */ #endif /* __INSTRUM_DRV_H__ */ diff --git a/example/instrum/instrum.c b/example/instrum/instrum.c index 05b38da68..93b6cc78f 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_DDF if (instr_odpdrv_init()) return; +#endif /* CODE_INSTRUM_DDF */ +#ifdef CODE_INSTRUM_SCHED if (instr_odpsched_init()) return; +#endif /* CODE_INSTRUM_SCHED */ } static __attribute__((destructor)) void teardown_wrappers(void) 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 d2258bf27..970dfd927 100644 --- a/example/m4/configure.m4 +++ b/example/m4/configure.m4 @@ -7,15 +7,22 @@ AC_ARG_ENABLE([test-example], [test_example=yes]) AM_CONDITIONAL([test_example], [test x$test_example = xyes ]) -PAPI_PATH="" -code_instrumentation=no AC_ARG_WITH([papi-path], AS_HELP_STRING([--with-papi-path=DIR path to papi install directory]), [PAPI_PATH="$withval" - code_instrumentation=yes],[]) - + code_instrumentation=yes], + [PAPI_PATH="" + code_instrumentation=no]) AC_SUBST([PAPI_PATH]) -AM_CONDITIONAL([CODE_INSTRUM], [test x$code_instrumentation = xyes ]) +AM_CONDITIONAL([CODE_INSTRUM], [test x$code_instrumentation = xyes]) + +AC_ARG_WITH([code-instrum-profile], +AS_HELP_STRING([--with-code-instrum-profile=all|scheduler|ddf 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_DDF],[test $code_instrum_profile = "all" || test $code_instrum_profile = "ddf"]) AC_CONFIG_FILES([example/classifier/Makefile example/generator/Makefile