Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1infHq-0006hO-RE for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Jan 2020 08:59:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1infHp-0003y4-8C for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Jan 2020 08:59:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1infHo-0003xx-Ve for pgsql-hackers@lists.postgresql.org; Sat, 04 Jan 2020 08:59:57 +0000 Received: from courriel.mines-paristech.fr ([77.158.173.149] helo=antispam-1.ensmp.fr) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1infHg-0003ZH-Oo for pgsql-hackers@lists.postgresql.org; Sat, 04 Jan 2020 08:59:55 +0000 Received: from smtp-5.mines-paristech.fr (smtp.mines-paristech.fr [77.158.173.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by antispam-1.ensmp.fr (antispam.mines-paristech.fr) with ESMTPS id C270455F2F; Sat, 4 Jan 2020 09:59:47 +0100 (CET) Received: from pseudo (149.64.203.77.rev.sfr.net [77.203.64.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp-5.mines-paristech.fr (Postfix) with ESMTPSA id 5DFB22005E; Sat, 4 Jan 2020 09:59:47 +0100 (CET) Date: Sat, 4 Jan 2020 09:59:46 +0100 (CET) From: Fabien COELHO X-X-Sender: fabien@pseudo To: Tom Lane cc: Andres Freund , Vik Fearing , Stephen Frost , Dean Rasheed , Chapman Flack , PostgreSQL Hackers Subject: Re: Greatest Common Divisor In-Reply-To: <15070.1578097070@sss.pgh.pa.us> Message-ID: References: <5E08D947.9000902@anastigmatix.net> <20200102145712.GN3195@tamriel.snowman.net> <16242.1577977961@sss.pgh.pa.us> <6855727c-3836-21cc-18f9-e79227b99079@2ndquadrant.com> <5bf72c6b-1290-2ba0-770b-8a13e899fd98@2ndquadrant.com> <13445.1578095358@sss.pgh.pa.us> <20200104001001.wzkk5nrea323hwyx@alap3.anarazel.de> <15070.1578097070@sss.pgh.pa.us> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-CLAMAV-SCAN: ok X-VRSPAM-SCORE: -100 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrvdeggedguddviecutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepfffhvffujgfkfhgfgggtsehttdertddtredvnecuhfhrohhmpefhrggsihgvnhcuvefqgffnjffquceotghovghlhhhosegtrhhirdgvnhhsmhhprdhfrheqnecuffhomhgrihhnpegrghhnvghrrdhorhhgnecukfhppeejjedrvddtfedrieegrddugeelnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhht X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello Tom, >> Which architecture has single cycle division? I think it's way above >> that, based on profiles I've seen. And Agner seems to back me up: >> https://www.agner.org/optimize/instruction_tables.pdf >> That lists a 32/64 idiv with a latency of ~26/~42-95 cycles, even on a >> moder uarch like skylake-x. > > Huh. I figured Intel would have thrown sufficient transistors at that > problem by now. It is not just a problem of number of transistors, division is intrisically iterative (with various kind of iterations used in division algorithms), involving some level of guessing and other arithmetics, so the latency can only be bad, and the possibility of implementing that in 1 cycle at 3 GHz looks pretty remote. -- Fabien.