From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jan Wedekind Newsgroups: gmane.lisp.guile.user Subject: "AIscm" array JIT Date: Wed, 8 Jun 2016 22:16:04 +0100 (BST) Message-ID: Reply-To: Jan Wedekind NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII X-Trace: ger.gmane.org 1465420944 5665 80.91.229.3 (8 Jun 2016 21:22:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Jun 2016 21:22:24 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Jun 08 23:22:06 2016 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bAkvN-0001fa-4E for guile-user@m.gmane.org; Wed, 08 Jun 2016 23:22:05 +0200 Original-Received: from localhost ([::1]:59575 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAkvL-0003A5-Ny for guile-user@m.gmane.org; Wed, 08 Jun 2016 17:22:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAkpg-00070r-HX for guile-user@gnu.org; Wed, 08 Jun 2016 17:16:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAkpd-00081U-9t for guile-user@gnu.org; Wed, 08 Jun 2016 17:16:12 -0400 Original-Received: from basicbox4.server-home.net ([195.137.212.26]:38693) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAkpd-00080Z-0t for guile-user@gnu.org; Wed, 08 Jun 2016 17:16:09 -0400 Original-Received: from wedemob.default (unknown [95.150.201.158]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by basicbox4.server-home.net (Postfix) with ESMTPSA id 2BFE01530714 for ; Wed, 8 Jun 2016 23:16:05 +0200 (CEST) X-X-Sender: jan@wedemob User-Agent: Alpine 2.11 (DEB 23 2013-08-11) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 195.137.212.26 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:12604 Archived-At: Hi, I am working on a compact library [1] for JIT compilation of array operations. It only runs on AMD64 processors. Currently it supports array operations using booleans, integers, and integer RGB and integer complex numbers. There are still important things missing: floating point numbers, compiling calls to C methods (e.g. sin, cos, ...), tensor operations, convolutions, ... I would like to eventually do numerical processing similar to Python's NumPy (but more generic), Theano (but more compact syntax as facilitated by macros), and OpenCV. Here is an example adding an integer to each element of a 2D array and returning the result: scheme@(guile-user)> (use-modules (oop goops) (aiscm jit) (aiscm int) (aiscm pointer) (aiscm sequence)) scheme@(guile-user)> (+ (arr (2 3 5) (7 11 13)) 3) $1 = #>>>: ((5 6 8) (10 14 16)) The fallback method for the GOOPS generic "+" adds a JIT compiled plus operation for the specific array types to the generic and then calls "+" again. The corresponding machine code to produce the unsigned byte array is shown below: 0: 4c 89 64 24 f0 mov QWORD PTR [rsp-0x10],r12 5: 48 89 6c 24 e8 mov QWORD PTR [rsp-0x18],rbp a: 4c 89 7c 24 e0 mov QWORD PTR [rsp-0x20],r15 f: 4c 89 74 24 d8 mov QWORD PTR [rsp-0x28],r14 14: 4c 89 6c 24 d0 mov QWORD PTR [rsp-0x30],r13 19: 48 89 5c 24 c8 mov QWORD PTR [rsp-0x38],rbx 1e: 48 89 7c 24 f8 mov QWORD PTR [rsp-0x8],rdi 23: 4c 8b 64 24 08 mov r12,QWORD PTR [rsp+0x8] 28: 48 8b 7c 24 18 mov rdi,QWORD PTR [rsp+0x18] 2d: 48 8b 6c 24 20 mov rbp,QWORD PTR [rsp+0x20] 32: 8a 44 24 28 mov al,BYTE PTR [rsp+0x28] 36: 48 6b de 01 imul rbx,rsi,0x1 3a: 49 8b f0 mov rsi,r8 3d: 4d 6b cc 01 imul r9,r12,0x1 41: 4c 8b fd mov r15,rbp 44: 49 be 00 00 00 00 00 movabs r14,0x0 4b: 00 00 00 4e: 4c 8b 44 24 f8 mov r8,QWORD PTR [rsp-0x8] 53: 4d 3b f0 cmp r14,r8 56: 74 3e je 0x96 58: 49 ff c6 inc r14 5b: 4c 6b d9 01 imul r11,rcx,0x1 5f: 4c 8b ee mov r13,rsi 62: 4c 6b d7 01 imul r10,rdi,0x1 66: 4d 8b e7 mov r12,r15 69: 48 bd 00 00 00 00 00 movabs rbp,0x0 70: 00 00 00 73: 48 3b ea cmp rbp,rdx 76: 74 16 je 0x8e 78: 48 ff c5 inc rbp 7b: 45 8a 04 24 mov r8b,BYTE PTR [r12] 7f: 44 02 c0 add r8b,al 82: 45 88 45 00 mov BYTE PTR [r13+0x0],r8b 86: 4d 03 eb add r13,r11 89: 4d 03 e2 add r12,r10 8c: eb e5 jmp 0x73 8e: 48 03 f3 add rsi,rbx 91: 4d 03 f9 add r15,r9 94: eb b8 jmp 0x4e 96: 4c 8b 64 24 f0 mov r12,QWORD PTR [rsp-0x10] 9b: 48 8b 6c 24 e8 mov rbp,QWORD PTR [rsp-0x18] a0: 4c 8b 7c 24 e0 mov r15,QWORD PTR [rsp-0x20] a5: 4c 8b 74 24 d8 mov r14,QWORD PTR [rsp-0x28] aa: 4c 8b 6c 24 d0 mov r13,QWORD PTR [rsp-0x30] af: 48 8b 5c 24 c8 mov rbx,QWORD PTR [rsp-0x38] b4: c3 ret Any comments,suggestions, and feedback are welcome! Regards Jan [1] https://github.com/wedesoft/aiscm