From patchwork Thu Jan 25 14:00:19 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: 125856 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1135795ljf; Thu, 25 Jan 2018 06:06:54 -0800 (PST) X-Google-Smtp-Source: AH8x224DWL6C1ssWQ+c43GvQjezy5GjnX1mV/2aw7pYahU6D4he3w10+6boWMkbR33+fNRFCfFOs X-Received: by 10.237.33.164 with SMTP id l33mr17339138qtc.100.1516889214360; Thu, 25 Jan 2018 06:06:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516889214; cv=none; d=google.com; s=arc-20160816; b=t8NGRxlZ7i0uD/ZNY8ZMM3hVPbXk3jRH5z3DDdrwPbq7bMfiH2D4dmnuLQOxDIVlyA i4ymrVfEb86MtxveIBwuV5J7YB+6u+DXatVc0xYhqNv8yqyeEibILYfDa9PRJJCstD+9 ZhVXL2jtLndvQBKrDjjudg4pj8WKHwoUyGXas74p1BVVJ43XxI4kC56hSiUG6bIxtYxN 1vDnb6qWyTUkLHy3FzpcQrcdV3/oaVA7YuV8LOC5vDHxUddfOFajo77OZdoUIlbfyGYs M16OjzVLEqm26B6lsIgP082qfZz5173qXV0i2EI9KVtLGLYi2fdqTfvGO+EIO+yxTfWn q+6w== 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=6SseaGG7hL92CLrqEzfU7VpawlxRtFTlcqrsmNuI4D4=; b=qcszYh/N5BmFDieKGrN4BzbMdUzTLHN858RnA9Bph/+RKuao5EB1p3V5CkMiY0Nvi4 npBHr+Uns0dFsxwsZFGI23O9lKsNi68tKSb6eMYAW7b0P62lc0EzFY7yk5dTMBeI0Ybc DYJat+ICckwKrWfVW1HfXXyv+IW75V58sLXlSX6uIQ8riNGQjwkDYIZegLn5pbM15eDc XP17+ExIKBSY0hJAVbykbBOp6Td9DHoWSytz3c9l3gg9arXDlCEU49OaIUUTZGPbwjt8 87zk/B2XUP7kteQoNjed6o+iN7vEvfxVC7vj4Pefwo8SYrq9tw2lcPXkpk4TpWTIojtE 1CgA== 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 u7si414145qkd.181.2018.01.25.06.06.54; Thu, 25 Jan 2018 06:06:54 -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 0830C6176B; Thu, 25 Jan 2018 14:06:54 +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 E650E61794; Thu, 25 Jan 2018 14:04:33 +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 D957A61792; Thu, 25 Jan 2018 14:04:28 +0000 (UTC) Received: from forward103p.mail.yandex.net (forward103p.mail.yandex.net [77.88.28.106]) by lists.linaro.org (Postfix) with ESMTPS id C99176179A for ; Thu, 25 Jan 2018 14:01:41 +0000 (UTC) Received: from mxback12j.mail.yandex.net (mxback12j.mail.yandex.net [IPv6:2a02:6b8:0:1619::87]) by forward103p.mail.yandex.net (Yandex) with ESMTP id 490372183C8C for ; Thu, 25 Jan 2018 17:00:26 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback12j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id g0W0CEcH3E-0Q40xK7B; Thu, 25 Jan 2018 17:00:26 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id MmDmS2v3bj-0PUOdGiS; Thu, 25 Jan 2018 17:00:25 +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, 25 Jan 2018 17:00:19 +0300 Message-Id: <1516888824-25562-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516888824-25562-1-git-send-email-odpbot@yandex.ru> References: <1516888824-25562-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 406 Subject: [lng-odp] [PATCH CATERPILLAR v2 1/6] 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 406 (bogdanPricope:cat_benchmark_pr) ** https://github.com/Linaro/odp/pull/406 ** Patch: https://github.com/Linaro/odp/pull/406.patch ** Base sha: f87bb5146fb25f7cd62246500cb4f7e625375654 ** Merge commit sha: 577e1fa00c9cfe0840f5b0f5d5d826f414ac03c6 **/ 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 25 14:00:20 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: 125848 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1130625ljf; Thu, 25 Jan 2018 06:00:47 -0800 (PST) X-Google-Smtp-Source: AH8x227uCNzacefrFC37RaapK91uptT8by/5JaRZmD6h7Y05oIuJZEHJcGgdk+IPvZPFk48S1leO X-Received: by 10.37.124.134 with SMTP id x128mr8416172ybc.94.1516888846992; Thu, 25 Jan 2018 06:00:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516888846; cv=none; d=google.com; s=arc-20160816; b=dmSHTOkYv+zYBLFgiAOGmLSVEZ8F9dpblMfylVD6G0oCQ58ToFoPig7HURhSeHf/4m KyCuvy1UK6X5BPqjgfC2dl0TzUnM3Mwn2LlNZU7N/Ac3F5vuwF5/znf5zx8/69ordtn3 Mf5iLXM0UUmA6gGvgDoLzU4iTgI5exdhwrs4rsD8H6w3iX2UL2GN18L57JL7lHzn0q6h X4CXWZTyu8Ck0HRPzH3U2WLDQTM+CE1rv7fQj+Z3UWDMHWKYT3yXD+eFCS7bPhr9KO5k ZCuI0/KrB65eL86JWbKsTrFBGbZ0phc572Br92f5yMwYNezp6GsHJGneCSyrsFq/aVCh Ea5Q== 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=ECcyfSY92cM/L/Qfal+d0uOzrbdaGS8owIMGLbQnBtE=; b=eCteKPsRBelE4izYjhmyzQu9C9OMvqzfRiDEc+C0jmo/SsWOxx2SrE3oaKFuu3hpd+ spKVq3GFynK5xEXsY0Jbe4OCzEnQGsF/wydiZW+xIfDoU/mBalHwsDGOs0msm5r18ncT k1EeiLEsROad2IrF98t+QOTjN5kE2JkVDIZop2i0CiYUsp6lTy105PBcB/c/mG9h0qzU A7tRTOV3UYUsfn9+o4ngL/eL8ZG5kW9TO4v3Opc2GN/M3h45EFZGQZ3HjyixV1RUvu/T WOMVC5BXx5IlgSt3SNADtsIWK2GOjm+Yd7HhLiznlIUxXo4KlOauMby+DoY3JdECa+bU Nw2g== 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 n184si2647983qkd.18.2018.01.25.06.00.46; Thu, 25 Jan 2018 06:00:46 -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 AB1EE6172A; Thu, 25 Jan 2018 14:00:45 +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 15BD0616F4; Thu, 25 Jan 2018 14:00:38 +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 7FA1A6172A; Thu, 25 Jan 2018 14:00:33 +0000 (UTC) Received: from forward101j.mail.yandex.net (forward101j.mail.yandex.net [5.45.198.241]) by lists.linaro.org (Postfix) with ESMTPS id 5921160669 for ; Thu, 25 Jan 2018 14:00:28 +0000 (UTC) Received: from mxback10g.mail.yandex.net (mxback10g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:171]) by forward101j.mail.yandex.net (Yandex) with ESMTP id D0A451240932 for ; Thu, 25 Jan 2018 17:00:26 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback10g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 3zWRv3hszY-0QxSb6uu; Thu, 25 Jan 2018 17:00:26 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id MmDmS2v3bj-0QU43tkL; Thu, 25 Jan 2018 17:00:26 +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, 25 Jan 2018 17:00:20 +0300 Message-Id: <1516888824-25562-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516888824-25562-1-git-send-email-odpbot@yandex.ru> References: <1516888824-25562-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 406 Subject: [lng-odp] [PATCH CATERPILLAR v2 2/6] 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 406 (bogdanPricope:cat_benchmark_pr) ** https://github.com/Linaro/odp/pull/406 ** Patch: https://github.com/Linaro/odp/pull/406.patch ** Base sha: f87bb5146fb25f7cd62246500cb4f7e625375654 ** Merge commit sha: 577e1fa00c9cfe0840f5b0f5d5d826f414ac03c6 **/ 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 25 14:00:21 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: 125853 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1133185ljf; Thu, 25 Jan 2018 06:03:39 -0800 (PST) X-Google-Smtp-Source: AH8x2251qoSeIflB2DtBq4H3E9zWGVC1lenlkq7nK3EhktJbcHnh8zdgDZwgMXKWIEy7RQVK3ZrZ X-Received: by 10.200.7.74 with SMTP id k10mr17833081qth.333.1516889018840; Thu, 25 Jan 2018 06:03:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516889018; cv=none; d=google.com; s=arc-20160816; b=YNPkjuIWAVn/QHWUTBZ1/ejRwIpKUP0nuGxIo8IfXLx3NBRzpAvM4eMv8nx690bPFU 2HB9zGfUNw0KoUmPMZxkk6QNYPDaJ+QPpePzmI+XApQ35uS/r7JgiuMdfKI7rZvfIK61 RU3o9hjFsdZHlE45KBEwU5lzp2DF7n6P/UyZX1SXB1m6bfa3de64yIjtM1O9fVU7+TPO DrNSfwhX5yNNarxox/oiW8Go/Iccd4sqZ+t6f1jgKzyoHYw9yIzDLwgpZKi1IS+LvUDi bsEU9ZH0A0okI2lUMSlfxbkYdm2sBaQA5CufmbqXSAcuh43Tgeh+aIhSiVmlFxG1Q5L+ T+Ng== 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=6XhIXMo5pKHQNIHz9m7OdVp7cK2bHpqQHPLkydIAkH8=; b=i3Fb1WGGGp16g49p+CJJ0CMDrb3KnQzvHLaTfFnK7ku7RI1h/pFNEb/gCamFfGK8O2 n5RAG3gHW4wrFIZ5hbIN6s7UrIat7QTG2NYgpbfvlZd7j7+IVsrsPNdvCpEFB89YsqeV 6WfPG4VQH0PSwJGEXMuy6FXl2uPv7IoHMyeDKeCDKTHEUGHwRxKL3X0TH1N5YwxxR/q/ IWUTe8yPkbcNsOqrJ6hTY+7qh/UTdnBjPR8VkNcK9L3PcQZcyWD+zlIpAoCoOG9NO3uB jCFd1HwO25BWdKyV6jbgSnoaBwb2V4e7DIATo03CJGBWTp9IwNVi/wlYKSwSbKI8p1PH jvew== 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 j68si1154075qka.214.2018.01.25.06.03.38; Thu, 25 Jan 2018 06:03:38 -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 60B07617A6; Thu, 25 Jan 2018 14:03:38 +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 391A4616F4; Thu, 25 Jan 2018 14:01:08 +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 3FD9861759; Thu, 25 Jan 2018 14:00:39 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 013516096B for ; Thu, 25 Jan 2018 14:00:30 +0000 (UTC) Received: from mxback3g.mail.yandex.net (mxback3g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:164]) by forward100p.mail.yandex.net (Yandex) with ESMTP id B0CB15102D77 for ; Thu, 25 Jan 2018 17:00:27 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback3g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id KPfu0armro-0Rbq7jot; Thu, 25 Jan 2018 17:00:27 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id MmDmS2v3bj-0QUeURK4; Thu, 25 Jan 2018 17:00:26 +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, 25 Jan 2018 17:00:21 +0300 Message-Id: <1516888824-25562-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516888824-25562-1-git-send-email-odpbot@yandex.ru> References: <1516888824-25562-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 406 Subject: [lng-odp] [PATCH CATERPILLAR v2 3/6] 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 406 (bogdanPricope:cat_benchmark_pr) ** https://github.com/Linaro/odp/pull/406 ** Patch: https://github.com/Linaro/odp/pull/406.patch ** Base sha: f87bb5146fb25f7cd62246500cb4f7e625375654 ** Merge commit sha: 577e1fa00c9cfe0840f5b0f5d5d826f414ac03c6 **/ 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 25 14:00:23 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: 125851 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1132402ljf; Thu, 25 Jan 2018 06:02:45 -0800 (PST) X-Google-Smtp-Source: AH8x226KWK3h5XILt2Omrl4LuPU/xHUGirEe4rWzb2cryeqzWjRn4F7Tw5C2yU1/B+BWkboBsdSV X-Received: by 10.55.27.91 with SMTP id b88mr14017626qkb.280.1516888964939; Thu, 25 Jan 2018 06:02:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516888964; cv=none; d=google.com; s=arc-20160816; b=0wZ4MKm8lDIJS+Rl7i3TguQ9KoRef44PBOLitkrFoW0dh/uzEfjuYG6/mV1gFGZi6k NWU4mNFplUELc4LvwrlXuvEX88BxyDiitv9CSf8alqiCQFVV+M7Qcndhmw47yxbgzu3H 1E2UsHUNaVtfJvMErMTsn3XxWkQ0FvuZzsBZk33h5Gffum2GC/79lyle1Aklap5eFpJX 0kGp6MEFOrvhOlDJ/ymW6HqBUPhMDODJ9KZ1eGY0yblvR9nW2bdU6QH1YnqnnlePDZaE mv0mcFiCNV2CFCFE8JF1BXLRmBPP1VyKvks8gPuur02arb4RyjxMaO1ovrOZaElEVF0Q 17xQ== 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=q93rwuyveLGeJNGZaACq3fqeqcptwLawRGrAzHYamOQ=; b=hL10x8P7Jv6TTQ+OYV5eQMGCGZBjz7GPzfO1eTnF+PTxG9Vn4UHo9quhTE7gVLnGFM 0zU6E5YY9KdF63kRgUhQGQMMSriNBVgcveGOO4z4bMZ7Z+wRVX60/Qww76fBH2eENjWA 3dixm+LvG56x9XQ6NAB35cjUZAqtFJZt1u05K+o2ctJ0xCrykEKZQVQQvq/eoTFxj2vH XWcPQPxduWZjzOMPhiDW+UwlhRo28VA7k3ZFpiwMGclfv3SR2uG2+jyClrcxqzl+vGGW gUDcN5ZUNlYQ3z6QEBloFv9UJ2ggkeR36T9nCgzf2dCmYhYdpltQQWVItPsXwS2kr+da P/Qw== 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 a1si3694961qtc.390.2018.01.25.06.02.44; Thu, 25 Jan 2018 06:02:44 -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 90707617AF; Thu, 25 Jan 2018 14:02:44 +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 E3BDD6176F; Thu, 25 Jan 2018 14:00:55 +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 90CA7616F4; Thu, 25 Jan 2018 14:00:36 +0000 (UTC) Received: from forward102p.mail.yandex.net (forward102p.mail.yandex.net [77.88.28.102]) by lists.linaro.org (Postfix) with ESMTPS id 8EF3F616F4 for ; Thu, 25 Jan 2018 14:00:30 +0000 (UTC) Received: from mxback5o.mail.yandex.net (mxback5o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1f]) by forward102p.mail.yandex.net (Yandex) with ESMTP id 1FB324305065 for ; Thu, 25 Jan 2018 17:00:29 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback5o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Iny7TAcfsT-0SNasBrG; Thu, 25 Jan 2018 17:00:29 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id MmDmS2v3bj-0SUmnvsv; Thu, 25 Jan 2018 17:00:28 +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, 25 Jan 2018 17:00:23 +0300 Message-Id: <1516888824-25562-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516888824-25562-1-git-send-email-odpbot@yandex.ru> References: <1516888824-25562-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 406 Subject: [lng-odp] [PATCH CATERPILLAR v2 5/6] 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 406 (bogdanPricope:cat_benchmark_pr) ** https://github.com/Linaro/odp/pull/406 ** Patch: https://github.com/Linaro/odp/pull/406.patch ** Base sha: f87bb5146fb25f7cd62246500cb4f7e625375654 ** Merge commit sha: 577e1fa00c9cfe0840f5b0f5d5d826f414ac03c6 **/ 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 From patchwork Thu Jan 25 14:00:24 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: 125849 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1131636ljf; Thu, 25 Jan 2018 06:01:51 -0800 (PST) X-Google-Smtp-Source: AH8x226xQqdgiVRWHwuHHZmljhDX9QXRhRSAmXBxUUYJmEWGzFp+fyWNMJLuB/gmBmn8gZNgAj2f X-Received: by 10.37.239.8 with SMTP id g8mr8272299ybd.500.1516888911660; Thu, 25 Jan 2018 06:01:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516888911; cv=none; d=google.com; s=arc-20160816; b=cu4GmNRdQyXe3IYxRBJl7MG5sQbClGOMsb7km8MG8NjGL0GpGbxoFTRroUR70b2Sdp YOA2RX1rlxqQhxK8u6z8mSEahq/TKWKmfJKxQbwExm3k46/3JYU7ZIlzYr0PbVHyPEOe NO2K3qQnjOiZnmSjILici9S9TUrCmeTuKAKoT/G26g4wXnIlQMd5qi2TRx2HEYBeYWPc 5bEVfuHJKxO/WX+5sRguIQVjhWxqaMmAOSOgTRBKE/ZIFEiquxf0lTjzcp5XVAdHfwbB HWMjlogqJAjymiT1sCw/KCgEOjT/90aPUQ0mrNFSFiY5vncWqlrqpJV9CP7DCI4VGzxi OtTg== 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=oUFP3kjuGDKBtiQFe5B6UYVPlt1zM6Jk6FxOyahlfLo=; b=ItGP0dO5Zivo3KVCaR41zZzsez/l0Twdtfq7FgkI2iqjbQIx+vegyr5SGXKtjE+MLa Z1Jr2jwlDoRh0MWr9PAlEoleZEh7BAhInetM3ATJiwnJPFyGn0JzIZBWunbliY3brC6A 7QAQkGDB6PAw7Xu1t6UvhTugjtChMOtrMw4KllnVQAZuCCiEzDZjrHhIEw+7kS9QLfrG qZzfqepjJXmf+KNMaENbLnKfenmQ5elI8SNopzB/68gnXsDal781/3be2bE4Sr8W8AwR bHW7povHo7O3x6r4ZLplwAZpqRFdDBID9pVEDu75ld2l9ieI4Ksx2l8zgVJ9hmg2ryKk zPdQ== 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 k3si2566172qkb.279.2018.01.25.06.01.51; Thu, 25 Jan 2018 06:01:51 -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 22A6261798; Thu, 25 Jan 2018 14:01:51 +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 7C3A46172A; Thu, 25 Jan 2018 14:00:48 +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 61369616F8; Thu, 25 Jan 2018 14:00:36 +0000 (UTC) Received: from forward102p.mail.yandex.net (forward102p.mail.yandex.net [77.88.28.102]) by lists.linaro.org (Postfix) with ESMTPS id 38443616F8 for ; Thu, 25 Jan 2018 14:00:31 +0000 (UTC) Received: from mxback6j.mail.yandex.net (mxback6j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10f]) by forward102p.mail.yandex.net (Yandex) with ESMTP id 110FC430507B for ; Thu, 25 Jan 2018 17:00:30 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback6j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id kr3eFY5KjN-0Th8j3mc; Thu, 25 Jan 2018 17:00:30 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id MmDmS2v3bj-0TUSbSe3; Thu, 25 Jan 2018 17:00:29 +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, 25 Jan 2018 17:00:24 +0300 Message-Id: <1516888824-25562-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516888824-25562-1-git-send-email-odpbot@yandex.ru> References: <1516888824-25562-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 406 Subject: [lng-odp] [PATCH CATERPILLAR v2 6/6] example: instrum: update DEPENDENCIES 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 Describe configuration and requirements of code instrumentation library. Signed-off-by: Bogdan Pricope --- /** Email created from pull request 406 (bogdanPricope:cat_benchmark_pr) ** https://github.com/Linaro/odp/pull/406 ** Patch: https://github.com/Linaro/odp/pull/406.patch ** Base sha: f87bb5146fb25f7cd62246500cb4f7e625375654 ** Merge commit sha: 577e1fa00c9cfe0840f5b0f5d5d826f414ac03c6 **/ DEPENDENCIES | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/DEPENDENCIES b/DEPENDENCIES index 008c4df4d..8b465992f 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -202,6 +202,83 @@ Prerequisites for building the OpenDataPlane (ODP) API 1024MB of memory: $ sudo ODP_PKTIO_DPDK_PARAMS="-m 1024" ./test/performance/odp_l2fwd -i 0 -c 1 +3.5 Code instrumentation with PAPI library (optional) + + PAPI library is used to instrument ODP API. + +3.5.1 Building PAPI library + + ODP example library 'instrum' is using PAPI library to retrieve performance + counters associated with execution of ODP API. PAPI library is currently at 5.6.0. + However, if possible one should try to use the latest PAPI master branch commit for + the best performance and the latest bug fixes. + + # Checkout PAPI code + $ git clone https://bitbucket.org/icl/papi.git + $ cd papi + $ git checkout papi-5-6-0-t (optional) + + # Build PAPI + $ cd ./src/ + $ ./configure --prefix= + $ make clean + $ make + $ make install + +3.5.2 Building ODP with PAPI support + + $ cd + $ ./bootstrap + $ ./configure --with-papi-path= + $ make clean + $ make + + Note: Building ODP with PAPI support forces dynamic linkage of ODP example applications with + ODP library. + +3.5.3 Configuration of instrumented API set + + Instrumentation profile option can be applied at configure time to select API set to + be instrumented. By default, all ODP APIs stated in 'instrum' example are instrumented. + + $ ./configure --with-papi-path= --with-code-instrum-profile= + +3.5.4 Running ODP application with code instrumentation + + ODP example library 'instrum' is preloaded before execution of ODP application. ODP application + must link dynamically with ODP library. + + # LD_PRELOAD=libinstrum.so.0.0.0 ./odp_application + + Note: ODP and PAPI shared libraries must be accessible at runtime. Use LD_LIBRARY_PATH for + non-standard locations. + + # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/lib + +3.5.5 Retrieving performance counters + + Performance counters are acquired per ODP worker and dumped in fix size sample chunks to CSV files. + + CSV file name is composed as follows: profile__.csv + + Default CSV files storage folder is '/tmp'. Use ODP_INSTRUM_STORE_DIR environment variable to + select a different folder. + + # export ODP_INSTRUM_STORE_DIR= + + CSV row contains the counters for execution of one API call: timestamp (ns) for the start of API call, + duration (cycles), API name and the differences between end and start for the list of PAPI counters. + +3.5.6 Selecting performance counters + + By default, PAPI_BR_CN and PAPI_L2_DCM are acquired. Use ODP_INSTRUM_PAPI_EVENTS environment variable + to configure the list of PAPI counters (events). + + # export ODP_INSTRUM_PAPI_EVENTS=PAPI_BR_CN,PAPI_L2_DCM,PAPI_BR_UCN + + Note: Some PAPI counters may not be available for some architectures. Use papi tools 'papi_avail' and + 'papi_native_avail' to retrieve the list of available counters. + 4.0 Packages needed to build API tests CUnit test framework version 2.1-3 is required