From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alex Gramiak Newsgroups: gmane.emacs.devel Subject: Re: Removing assumption of unsigned long pixel values for colours Date: Mon, 06 May 2019 10:11:27 -0600 Message-ID: <878svjk1g0.fsf@gmail.com> References: <87v9yqjdnh.fsf@gmail.com> <83a7g2kqsi.fsf@gnu.org> <87lfzlkeic.fsf@gmail.com> <83zho0khdu.fsf@gnu.org> <87h8a8k84a.fsf@gmail.com> <83pnowjo63.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="192084"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: Eli Zaretskii , emacs-devel To: Daniel Pittman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 06 18:11:32 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hNgDE-000nro-4S for ged-emacs-devel@m.gmane.org; Mon, 06 May 2019 18:11:32 +0200 Original-Received: from localhost ([127.0.0.1]:58980 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNgDC-0006eO-U0 for ged-emacs-devel@m.gmane.org; Mon, 06 May 2019 12:11:30 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:46091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNgD6-0006eC-Ht for emacs-devel@gnu.org; Mon, 06 May 2019 12:11:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hNgD5-000660-FN for emacs-devel@gnu.org; Mon, 06 May 2019 12:11:24 -0400 Original-Received: from mail-it1-x12f.google.com ([2607:f8b0:4864:20::12f]:35935) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hNgD5-00065P-5s; Mon, 06 May 2019 12:11:23 -0400 Original-Received: by mail-it1-x12f.google.com with SMTP id o190so3640922itc.1; Mon, 06 May 2019 09:11:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=PXwqfMPn2FmGSYmTi6voMY8fEzpbgHaioOEfnQhmxwI=; b=el+c5Dd644SwcRgoTrmu54akrpQPfEbZtqs6IWoGZSqN8g4evFF+PEkmcFVqcvqa1q kwXNPI58hps/0+UsAJKe8Xl4noD8rfupaqroCZUSuQ8V0n8LmUdhY5WC5Blw2LVYDR/6 DTGBayePb7mtpC8VfwVH9/FVJDVa2F53Pau0gvxAhdqhhFNONjGEoDiUjXjeu1rtiuZK P+rqd31y4oKvH/nbhX8cgmDTP9rjvy8TE0U+eMg0odpbTIfRVwDXi6NydJbqE6t3JX/9 kwpCQr5+mLw5a6P5ZeWj6kcVIaRYuh8NR7GRxfZEPQEt3D7UfR8v6uK0mXZFPM5HZNYC xd5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=PXwqfMPn2FmGSYmTi6voMY8fEzpbgHaioOEfnQhmxwI=; b=s/Ku8hvOapCwDaiUxaYIpzfXOkOAqFxJkihRJ+wsnW2Kw/smr5EhApLFhu4S2uo4KE /Re09drFujJxMNayRwSIIe6z0ddegbU3o38/ukr1NI1VbQ/aVLIhwEh6tfTPgapXZZ/0 3DVAhfSHTrpD3VjI/5mvy0eRWRqM5cyEcoO4Lyn+qp1TyB8Bz0hf1KIwdVN9VAvfylKJ +ZW2pmJWAwvMCJ81P6C3It/nXl1SlRQAWJVtMlJrljw22u/l0RaGJdVUYyEgb+NzXQbJ ZGBC9rPYYaNwNy4ahTAwRs+izszUujIS5oj/Wmq8P+1V+viJRUpwvsT4Fw2TUNxxdF2+ Mv4g== X-Gm-Message-State: APjAAAVn/6vof2jLlyVflDPhfKSDt3sILsJKzzDoVunOQv9eTQbmXbBW +dUm+ErZ2Ko31U0ROw65ezfeOlh6 X-Google-Smtp-Source: APXvYqz4cs+xhrUFullUhN0xNDrUcF7owD//Zt6okIEnm/h9A2cLzkHFa37yhIwEbqiPNE8RAUXUJQ== X-Received: by 2002:a24:de41:: with SMTP id d62mr17143400itg.175.1557159081743; Mon, 06 May 2019 09:11:21 -0700 (PDT) Original-Received: from lylat ([2604:3d09:e37f:1500:1a72:4878:e793:7302]) by smtp.gmail.com with ESMTPSA id r6sm657799iog.38.2019.05.06.09.11.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 May 2019 09:11:20 -0700 (PDT) In-Reply-To: (Daniel Pittman's message of "Mon, 6 May 2019 10:13:04 -0400") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::12f X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:236198 Archived-At: Daniel Pittman writes: > If you wanted to explore the optimization (and because I was curious, personally): > https://godbolt.org/z/vC_yOg > > You can change the width of the representation, and possibly even use signed int color values (untested), to see the effect it has. spoiler alert, pretty much none, even with a 64-bit integer for each color value. > > Even using a relatively old compilers, gcc 4.1.2 from February 13, 2007, the compiled results are quite efficient. > See the LLVM-MCA analysis, but your costs seem well within reasonable limits to me. > > I don't think I'd cache it either: at around 14 cycles per conversion, it is around 5.3ns to run, and fetching from in the L1 cache is around 9ns, so your best case scenario is that you took 60 percent longer to fetch it than to convert it, excluding > CPU stalls from other activity. Thanks for exploring this! It's good to see that the results are efficient. > So, benchmark if you want, but I'm pretty sure you can't win much back by doing the conversion only once, rather than inline at execution time. The original plan was to avoid any conversion at all (no conversion necessary on the Emacs side to create the struct of doubles); would you still consider the difference between no conversion and 4 conversions to be negligible?