From patchwork Tue Jan 29 08:31:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Hoffmann X-Patchwork-Id: 216458 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id 815242C007B for ; Tue, 29 Jan 2013 19:32:12 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id DC9D2101C5F; Tue, 29 Jan 2013 08:31:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uTtINBwMv0vL; Tue, 29 Jan 2013 08:31:49 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7AAFC1019CC; Tue, 29 Jan 2013 08:31:49 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 7DB208F7A2 for ; Tue, 29 Jan 2013 08:32:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 6A165311BA for ; Tue, 29 Jan 2013 08:32:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sb2nOzg8AyGJ for ; Tue, 29 Jan 2013 08:31:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.9]) by silver.osuosl.org (Postfix) with ESMTPS id A4FC5311AA for ; Tue, 29 Jan 2013 08:31:58 +0000 (UTC) Received: from stephan-desktop (p5492DFDB.dip.t-dialin.net [84.146.223.219]) by mrelayeu.kundenserver.de (node=mrbap3) with ESMTP (Nemesis) id 0MOiCE-1U2sYf3SFS-0063xv; Tue, 29 Jan 2013 09:31:55 +0100 Received: by stephan-desktop (Postfix, from userid 1000) id 3FEDF5010C2; Tue, 29 Jan 2013 09:31:54 +0100 (CET) From: Stephan Hoffmann To: buildroot@uclibc.org Date: Tue, 29 Jan 2013 09:31:55 +0100 Message-Id: <1359448315-22100-1-git-send-email-sho@relinux.de> X-Mailer: git-send-email 1.7.0.4 X-Provags-ID: V02:K0:a6UYLAU2uv7bm/RKU6QFCCjALLe2pCbofwrVyfvt/Gg YS8MGTrENfvfMWfV2yG325+0BEr1fZEig2+gFB2josRR+4FTUi LOGjmaUeKuj7WDNi0GB2ddCPmHfBlgCdID03Fz3xEe42sPFGgN AizbkaE/jIPf1Yxch6M/wehomSs5I5w5A0o5eElsoRCOowdvu9 mRf6iB0GB3KFEBQCMqte27xYVxVfuQju5W2Qo2dc2zm1jxMU2p lbfUtsRNrr2q8gfUvVW6cokVE663UXuQIKlrjjp8efUvg2jxFC +zGAOO3gzEIttKwhLIfRANEcYIWzhATtLNNz1N8qp10RUXAcb7 foTSUkdAKGDg3y+KrRe1+JmirnVxbOGG3RKR7+/e+oG5eMy5Jk zqK6UbrVVtEWg== Subject: [Buildroot] [PATCH] New package: cache-calibrator X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net The Calibrator is a small C program that is supposed to analyze a computers (cache-) memory system and extract the following parameters: number of cache levels for each cache level: its size its linesize its access/miss latency main memory access latency number of TLB levels for each TLB level: its capacity (i.e. number of entries) the pagesize used the TLB miss latency http://homepages.cwi.nl/~manegold/Calibrator/ It is also recommended as a load generator for realtime testing in: https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO#Benchmarking Signed-off-by: Stephan Hoffmann --- package/Config.in | 1 + package/cache-calibrator/Config.in | 13 +++ ...calibrator-Fix-conflicting-round-function.patch | 108 ++++++++++++++++++++ package/cache-calibrator/cache-calibrator.mk | 21 ++++ 4 files changed, 143 insertions(+), 0 deletions(-) create mode 100644 package/cache-calibrator/Config.in create mode 100644 package/cache-calibrator/cache-calibrator-Fix-conflicting-round-function.patch create mode 100644 package/cache-calibrator/cache-calibrator.mk diff --git a/package/Config.in b/package/Config.in index ebd9817..e6682fc 100644 --- a/package/Config.in +++ b/package/Config.in @@ -19,6 +19,7 @@ endmenu menu "Debugging, profiling and benchmark" source "package/bonnie/Config.in" +source "package/cache-calibrator/Config.in" source "package/dhrystone/Config.in" source "package/dstat/Config.in" source "package/dmalloc/Config.in" diff --git a/package/cache-calibrator/Config.in b/package/cache-calibrator/Config.in new file mode 100644 index 0000000..6425cd0 --- /dev/null +++ b/package/cache-calibrator/Config.in @@ -0,0 +1,13 @@ +config BR2_PACKAGE_CACHE_CALIBRATOR + bool "cache-calibrator" + help + Cache calibrator is a small C program that is + supposed to analyze a computers (cache-) memory + system and extract useful information + + http://homepages.cwi.nl/~manegold/Calibrator/ + + It is also recommended as a load generator for + realtime testing in: + + https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO diff --git a/package/cache-calibrator/cache-calibrator-Fix-conflicting-round-function.patch b/package/cache-calibrator/cache-calibrator-Fix-conflicting-round-function.patch new file mode 100644 index 0000000..71181a6 --- /dev/null +++ b/package/cache-calibrator/cache-calibrator-Fix-conflicting-round-function.patch @@ -0,0 +1,108 @@ +From 39ac7268c4350040976005da98daf10edf676d3e Mon Sep 17 00:00:00 2001 +From: Stephan Hoffmann +Date: Mon, 28 Jan 2013 17:32:10 +0100 +Subject: [PATCH] Fix conflicting round() function + +calibrator.c defines a local round() function that conflicts +with the one from the standard library. + +This is fixed by renaming the local function. + +Signed-off-by: Stephan Hoffmann +--- + calibrator.c | 30 +++++++++++++++--------------- + 1 files changed, 15 insertions(+), 15 deletions(-) + +diff --git a/calibrator.c b/calibrator.c +index e045dfd..8471c04 100644 +--- a/calibrator.c ++++ b/calibrator.c +@@ -128,7 +128,7 @@ void ErrXit(char *format, ...) { + exit(1); + } + +-lng round(dbl x) ++lng lng_round(dbl x) + { + return (lng)(x + 0.5); + } +@@ -890,16 +890,16 @@ void plotCache(cacheInfo *cache, lng **result, lng MHz, char *fn, FILE *fp, lng + fprintf(fp, ")\n"); + fprintf(fp, "set y2tics"); + for (l = 0, s = " ("; l <= cache->levels; l++, s = ", ") { +- if (!delay) fprintf(fp, "%s'(%ld)' %f", s, round(CYperIt(cache->latency1[l] - delay)), NSperIt(cache->latency1[l] - delay)); +- else fprintf(fp, "%s'(%ld)' %f", s, round(CYperIt(cache->latency2[l] - delay)), NSperIt(cache->latency2[l] - delay)); ++ if (!delay) fprintf(fp, "%s'(%ld)' %f", s, lng_round(CYperIt(cache->latency1[l] - delay)), NSperIt(cache->latency1[l] - delay)); ++ else fprintf(fp, "%s'(%ld)' %f", s, lng_round(CYperIt(cache->latency2[l] - delay)), NSperIt(cache->latency2[l] - delay)); + } + for (y = 1; y <= yh; y *= 10) { + fprintf(fp, "%s'%1.3g' %ld", s, (dbl)(y * MHz) / 1000.0, y); + } + fprintf(fp, ")\n"); + for (l = 0; l <= cache->levels; l++) { +- if (!delay) z = (dbl)round(CYperIt(cache->latency1[l] - delay)) * 1000.0 / (dbl)MHz; +- else z = (dbl)round(CYperIt(cache->latency2[l] - delay)) * 1000.0 / (dbl)MHz; ++ if (!delay) z = (dbl)lng_round(CYperIt(cache->latency1[l] - delay)) * 1000.0 / (dbl)MHz; ++ else z = (dbl)lng_round(CYperIt(cache->latency2[l] - delay)) * 1000.0 / (dbl)MHz; + fprintf(fp, "set label %ld '(%1.3g) ' at %f,%f right\n", l + 1, z, xl, z); + fprintf(fp, "set arrow %ld from %f,%f to %f,%f nohead lt 0\n", l + 1, xl, z, xh, z); + } +@@ -986,16 +986,16 @@ void plotTLB(TLBinfo *TLB, lng **result, lng MHz, char *fn, FILE *fp, lng delay) + fprintf(fp, "%s'' %ld)\n", s, TLB->mincachelines); + fprintf(fp, "set y2tics"); + for (l = 0, s = " ("; l <= TLB->levels; l++, s = ", ") { +- if (!delay) fprintf(fp, "%s'(%ld)' %f", s, round(CYperIt(TLB->latency1[l] - delay)), NSperIt(TLB->latency1[l] - delay)); +- else fprintf(fp, "%s'(%ld)' %f", s, round(CYperIt(TLB->latency2[l] - delay)), NSperIt(TLB->latency2[l] - delay)); ++ if (!delay) fprintf(fp, "%s'(%ld)' %f", s, lng_round(CYperIt(TLB->latency1[l] - delay)), NSperIt(TLB->latency1[l] - delay)); ++ else fprintf(fp, "%s'(%ld)' %f", s, lng_round(CYperIt(TLB->latency2[l] - delay)), NSperIt(TLB->latency2[l] - delay)); + } + for (y = 1; y <= yh; y *= 10) { + fprintf(fp, "%s'%1.3g' %ld", s, (dbl)(y * MHz) / 1000.0, y); + } + fprintf(fp, ")\n"); + for (l = 0; l <= TLB->levels; l++) { +- if (!delay) z = (dbl)round(CYperIt(TLB->latency1[l] - delay)) * 1000.0 / (dbl)MHz; +- else z = (dbl)round(CYperIt(TLB->latency2[l] - delay)) * 1000.0 / (dbl)MHz; ++ if (!delay) z = (dbl)lng_round(CYperIt(TLB->latency1[l] - delay)) * 1000.0 / (dbl)MHz; ++ else z = (dbl)lng_round(CYperIt(TLB->latency2[l] - delay)) * 1000.0 / (dbl)MHz; + fprintf(fp, "set label %ld '(%1.3g) ' at %f,%f right\n", l + 1, z, xl, z); + fprintf(fp, "set arrow %ld from %f,%f to %f,%f nohead lt 0\n", l + 1, xl, z, xh, z); + } +@@ -1023,9 +1023,9 @@ void printCPU(cacheInfo *cache, lng MHz, lng delay) + FILE *fp = stdout; + + fprintf(fp, "CPU loop + L1 access: "); +- fprintf(fp, " %6.2f ns = %3ld cy\n", NSperIt(cache->latency1[0]), round(CYperIt(cache->latency1[0]))); ++ fprintf(fp, " %6.2f ns = %3ld cy\n", NSperIt(cache->latency1[0]), lng_round(CYperIt(cache->latency1[0]))); + fprintf(fp, " ( delay: "); +- fprintf(fp, " %6.2f ns = %3ld cy )\n", NSperIt(delay), round(CYperIt(delay))); ++ fprintf(fp, " %6.2f ns = %3ld cy )\n", NSperIt(delay), lng_round(CYperIt(delay))); + fprintf(fp, "\n"); + fflush(fp); + } +@@ -1047,8 +1047,8 @@ void printCache(cacheInfo *cache, lng MHz) + fprintf(fp, " %3ld KB ", cache->size[l] / 1024); + } + fprintf(fp, " %3ld bytes ", cache->linesize[l + 1]); +- fprintf(fp, " %6.2f ns = %3ld cy " , NSperIt(cache->latency2[l + 1] - cache->latency2[l]), round(CYperIt(cache->latency2[l + 1] - cache->latency2[l]))); +- fprintf(fp, " %6.2f ns = %3ld cy\n", NSperIt(cache->latency1[l + 1] - cache->latency1[l]), round(CYperIt(cache->latency1[l + 1] - cache->latency1[l]))); ++ fprintf(fp, " %6.2f ns = %3ld cy " , NSperIt(cache->latency2[l + 1] - cache->latency2[l]), lng_round(CYperIt(cache->latency2[l + 1] - cache->latency2[l]))); ++ fprintf(fp, " %6.2f ns = %3ld cy\n", NSperIt(cache->latency1[l + 1] - cache->latency1[l]), lng_round(CYperIt(cache->latency1[l + 1] - cache->latency1[l]))); + } + fprintf(fp, "\n"); + fflush(fp); +@@ -1075,9 +1075,9 @@ void printTLB(TLBinfo *TLB, lng MHz) + } else { + fprintf(fp, " %3ld KB ", TLB->pagesize[l + 1] / 1024); + } +- fprintf(fp, " %6.2f ns = %3ld cy ", NSperIt(TLB->latency2[l + 1] - TLB->latency2[l]), round(CYperIt(TLB->latency2[l + 1] - TLB->latency2[l]))); ++ fprintf(fp, " %6.2f ns = %3ld cy ", NSperIt(TLB->latency2[l + 1] - TLB->latency2[l]), lng_round(CYperIt(TLB->latency2[l + 1] - TLB->latency2[l]))); + /* +- fprintf(fp, " %6.2f ns = %3ld cy" , NSperIt(TLB->latency1[l + 1] - TLB->latency1[l]), round(CYperIt(TLB->latency1[l + 1] - TLB->latency1[l]))); ++ fprintf(fp, " %6.2f ns = %3ld cy" , NSperIt(TLB->latency1[l + 1] - TLB->latency1[l]), lng_round(CYperIt(TLB->latency1[l + 1] - TLB->latency1[l]))); + */ + fprintf(fp, "\n"); + } +-- +1.7.0.4 + diff --git a/package/cache-calibrator/cache-calibrator.mk b/package/cache-calibrator/cache-calibrator.mk new file mode 100644 index 0000000..8abc647 --- /dev/null +++ b/package/cache-calibrator/cache-calibrator.mk @@ -0,0 +1,21 @@ +############################################################# +# +# cache-calibrator +# +############################################################# + +CACHE_CALIBRATOR_SOURCE = calibrator.c +CACHE_CALIBRATOR_SITE = http://homepages.cwi.nl/~manegold/Calibrator/src +CACHE_CALIBRATOR_EXTRACT_CMDS = cp $(DL_DIR)/$(CACHE_CALIBRATOR_SOURCE) $(D) +CACHE_CALIBRATOR_LICENSE = Cache calibrator license +CACHE_CALIBRATOR_LICENSE_FILES = calibrator.c + +define CACHE_CALIBRATOR_BUILD_CMDS + $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) $(@D)/calibrator.c -o $(@D)/cache_calibrator -lm +endef + +define CACHE_CALIBRATOR_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 0755 $(@D)/cache_calibrator $(TARGET_DIR)/usr/bin/cache_calibrator +endef + +$(eval $(generic-package))