[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: JIT compilation with callbacks into Scheme
From: |
Jan Wedekind |
Subject: |
Re: JIT compilation with callbacks into Scheme |
Date: |
Fri, 21 Oct 2016 13:13:22 +0100 (BST) |
User-agent: |
Alpine 2.11 (DEB 23 2013-08-11) |
On Fri, 21 Oct 2016, Amirouche Boubekki wrote:
Héllo Jan!
On 2016-10-20 22:14, Jan Wedekind wrote:
Hi,
I managed to implement JIT compilation of method calls into the
Guile interpreter (AIscm 0.8.2 [1]):
(use-modules (oop goops) (aiscm sequence) (aiscm obj) (aiscm jit))
(<< 1 (* 10 (seq <obj> 1 2 4 8)))
;#<sequence<obj>>:
;(1024 1048576 1099511627776 1208925819614629174706176)
Types can also be composed using Scheme objects:
(use-modules (oop goops) (aiscm sequence) (aiscm obj) (aiscm
complex) (aiscm jit))
(* (seq (complex <obj>) 1+2i 3+4i) 5)
;#<sequence<complex<obj>>>:
;(5.0+10.0i 15.0+20.0i)
In the same way native types can be composed:
(use-modules (oop goops) (aiscm sequence) (aiscm rgb) (aiscm int)
(aiscm jit))
(make (multiarray (rgb (integer 8 unsigned)) 2) #:shape '(3 2))
;#<sequence<sequence<rgb<int<8,unsigned>>>>>:
;(((rgb 160 85 191) (rgb 10 0 0) (rgb 0 0 0))
; ((rgb 0 0 0) (rgb 0 0 0) (rgb 0 0 0)))
Let me know if you have any suggestions or comments.
Regards
Jan
[1] http://wedesoft.github.io/aiscm/
How does this compare with numpy?
TIA!
--
Amirouche ~ amz3 ~ http://www.hyperdev.fr
First of all numpy supports native floating point operations and this
work does not yet do that ;)
In terms of performance I previously posted some benchmarks comparing
with C programs [1].
Numpy is statically compiled and uses generic functions and function
pointers to implement binary operations for combinations of types [1].
np.array([1,2,3],dtype=np.uint8) + np.array([1,2,3],dtype=np.int16)
# array([2, 4, 6], dtype=int16)
When instead using a JIT (e.g. Python Theano) the resulting software is
more generic and composable in terms of operations (tensors, composite
operations) and in terms of datatypes (RGB, complex values, arrays,
hypercomplex values, ...).
Here's a technical report [3] with more details and motivation (in that
case libJIT and Ruby was used).
Please let me know if you have some interesting applications in mind :)
Regards
Jan
[1] https://lists.gnu.org/archive/html/guile-user/2016-06/msg00019.html
[2]
https://github.com/numpy/numpy/blob/master/numpy/core/src/multiarray/calculation.c#L534
[3] http://www.wedesoft.de/downloads/tensors_libjit.pdf