From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Re: Bignum performance (was: Shrinking the C core) Date: Mon, 14 Aug 2023 18:51:14 +0200 Message-ID: <87msyth8jh.fsf@dataswamp.org> References: <87bkfartof.fsf@localhost> <175cf474-29c8-a482-072e-0de784ac59e8@gmail.com> <87o7jaqc31.fsf@localhost> <2d419e12-9239-de3e-47d0-38815a00025f@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23827"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: emacs-devel@gnu.org Cancel-Lock: sha1:cXpCm1MBWiW4Zr34SorWyfiOaBg= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Aug 14 19:46:36 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qVbeG-00062M-CP for ged-emacs-devel@m.gmane-mx.org; Mon, 14 Aug 2023 19:46:36 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qVbdT-0002CS-7c; Mon, 14 Aug 2023 13:45:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qVan7-0007J0-0R for emacs-devel@gnu.org; Mon, 14 Aug 2023 12:51:41 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qVan3-00026O-39 for emacs-devel@gnu.org; Mon, 14 Aug 2023 12:51:40 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1qVan1-0005uG-Fc for emacs-devel@gnu.org; Mon, 14 Aug 2023 18:51:35 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Mail-Copies-To: never Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 14 Aug 2023 13:45:45 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:308742 Archived-At: Gerd Möllmann wrote: >> Sorry, but I do not know how to do it. Not familiar >> with CL. >> > Ok. I used the code from > https://dataswamp.org/~incal/cl/fib.cl/fib.cl Yikes, how did that happen, some slip involving symbolic links ... Here it is: https://dataswamp.org/~incal/cl/bench/fib.cl And timing is done with this: https://dataswamp.org/~incal/cl/bench/timing.cl Note the ugly absolute path in fib.cl BTW, otherwise you get the path not of the file but of SBCL or Slime, maybe. I think one is supposed to use ASDF, but surely there must some easy way to just load a file using a relative path to the current file? (load "~/public_html/cl/bench/timing.cl") > is the declaration (unsigned-byte 53). > > The declaration means we are lying to the compiler because > Z gets bigger than 53 bits eventually. And all bets are off > because of the OPTIMIZE declaration. The result is that > everything is done in fixnums on 64-bit machines. A very impressive optimization indeed, and expressed in a cryptic way. > ; disassembly for FIB > ; Size: 92 bytes. Origin: #x700530086C ; FIB > ; 6C: 030080D2 MOVZ NL3, #0 > ; 70: 040080D2 MOVZ NL4, #0 > ; 74: 0E000014 B L3 > ; 78: L0: 410080D2 MOVZ NL1, #2 > ; 7C: E20301AA MOV NL2, NL1 > ; 80: EB030CAA MOV R1, R2 > ; 84: 651100D1 SUB NL5, R1, #4 > ; 88: 000080D2 MOVZ NL0, #0 > ; 8C: 05000014 B L2 > ; 90: L1: 2300028B ADD NL3, NL1, NL2 > ; 94: E20301AA MOV NL2, NL1 > ; 98: E10303AA MOV NL1, NL3 > ; 9C: 00080091 ADD NL0, NL0, #2 > ; A0: L2: 1F0005EB CMP NL0, NL5 > ; A4: 6BFFFF54 BLT L1 > ; A8: 84080091 ADD NL4, NL4, #2 > ; AC: L3: 9F000AEB CMP NL4, R0 > ; B0: 4BFEFF54 BLT L0 > ; B4: EA0303AA MOV R0, NL3 > ; B8: FB031AAA MOV CSP, CFP > ; BC: 5A7B40A9 LDP CFP, LR, [CFP] > ; C0: BF0300F1 CMP NULL, #0 > ; C4: C0035FD6 RET > > Tada! How do you see only fixnums are used? Are we talking 1 word = 2 bytes = 16 bits here, s2c? If so, the range of fixnums are -32 768 to 32 767 inclusive, so those are hardly huge numbers. -- underground experts united https://dataswamp.org/~incal