From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAPsm-0003Qz-CD for qemu-devel@nongnu.org; Tue, 07 Jun 2016 18:54:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAPsd-00055p-SR for qemu-devel@nongnu.org; Tue, 07 Jun 2016 18:53:58 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:33020) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAPs9-00053v-4c for qemu-devel@nongnu.org; Tue, 07 Jun 2016 18:53:51 -0400 Date: Tue, 7 Jun 2016 18:53:00 -0400 From: "Emilio G. Cota" Message-ID: <20160607225300.GA16255@flamenco> References: <1464138802-23503-1-git-send-email-cota@braap.org> <1464138802-23503-9-git-send-email-cota@braap.org> <5749E02A.3080909@gmail.com> <20160603172245.GA8361@flamenco> <5751BE73.2090402@gmail.com> <5751C25F.6080801@gmail.com> <20160606234014.GA4418@flamenco> <5756D4D8.7060202@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5756D4D8.7060202@gmail.com> Subject: Re: [Qemu-devel] [PATCH v6 08/15] qdist: add module to represent frequency distributions of data List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Fedorov Cc: QEMU Developers , MTTCG Devel , Alex =?iso-8859-1?Q?Benn=E9e?= , Paolo Bonzini , Richard Henderson On Tue, Jun 07, 2016 at 17:06:16 +0300, Sergey Fedorov wrote: > On 07/06/16 02:40, Emilio G. Cota wrote: > > On Fri, Jun 03, 2016 at 20:46:07 +0300, Sergey Fedorov wrote: > >> Maybe something like > >> https://en.wikipedia.org/wiki/Kahan_summation_algorithm could help? > > That algorithm is overkill for what we're doing. Pairwise summation > > should suffice: > > > > diff --git a/util/qdist.c b/util/qdist.c > > index 3343640..909bd2b 100644 > > --- a/util/qdist.c > > +++ b/util/qdist.c > > @@ -367,20 +367,34 @@ unsigned long qdist_sample_count(const struct qdist *dist) > > return count; > > } > > > > +static double qdist_pairwise_avg(const struct qdist *dist, size_t index, > > + size_t n, unsigned long count) > > +{ > > + if (n <= 2) { > > We would like to amortize the overhead of the recursion by making the > cut-off sufficiently large. Yes, this was just for showing what it looked like. We can use 128 here like JuliaLang does: https://github.com/JuliaLang/julia/blob/d98f2c0dcd/base/arraymath.jl#L366 (snip) > Otherwise looks good. Thanks! Emilio