octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JIT - automated mexing


From: Fotios Kasolis
Subject: Re: JIT - automated mexing
Date: Thu, 24 Jun 2010 22:29:33 +0200

On Jun 24, 2010, at 10:11 PM, David Bateman wrote:

> Fotios Kasolis wrote:
>> On Jun 24, 2010, at 9:46 PM, David Bateman wrote:
>> 
>>  
>>> Fotios Kasolis wrote:
>>>    
>>>> Is there someone that is planing to introduce (or already implementing) 
>>>> JIT in Octave? If not, i ll place that on my MOST_DESIRED list. 
>>>> Unfortunately i do not have the knowledge (yet) to do it but i ll start 
>>>> working on that whenever i find some time (any help: links, books, 
>>>> whatever ;D).
>>>> 
>>>> An idea (which i do not know if implementable but sounds so)
>>>> Instead of a traditional JIT what about automated mexing? Sth like
>>>> 
>>>>       
>>>>> mex_my_loops(myfunc)
>>>>>           
>>>> will replace all (replaceable) loops by mexed ones? Does this sound 
>>>> reasonable (if not why?)? At least it sounds relatively easier than JIT 
>>>> and more user oriented (it is always good to have a choice)
>>>> 
>>>> /Fotios
>>>> 
>>>>       
>>> I think JIT is a lot harder than you think. There is no strict variable 
>>> typing in Octave and so you need to discover what types are used before you 
>>> can call the appropriate compiled functions. Also variable types can be 
>>> polymorphic. Consider something like
>>> 
>>> a = 1
>>> for i = 0:.1:2
>>> a += asin(i);
>>> endfor
>>> 
>>> Yes I know its an artifical example, but consider what happens to the type 
>>> of a when i=1.1.... There is a JIT in FreeMat but FreeMat essentially got 
>>> rid of there logical and single precision types to simplify the detection 
>>> of code where the JIT compiler might be applied.
>>> 
>>> I'd suggest you look at the JIT code in FreeMat in any case for 
>>> inspiration, at
>>> 
>>> http://freemat.svn.sourceforge.net/viewvc/freemat/branches/ArraySimplification/libs/libMatC/
>>> 
>>> Regards
>>> David
>>> 
>>>    
>> 
>> I think of JIT as hard as it is but no more than that! But what about  the 
>> automated mex code solution?
>> 
>> /Fotios
>>  
> What is automatic mexing but a use of a piece of compiled code in a JIT.. I 
> don't really see the distinction. The hard bits are still the same (variable 
> type discover, loop optimisation, etc).. Lucky LLVM does a lot  of this stuff 
> already
> 
> D.
> 
> -- 
> David Bateman                                address@hidden
> 35 rue Gambetta                              +33 1 46 04 02 18 (Home)
> 92100 Boulogne-Billancourt FRANCE            +33 6 72 01 06 33 (Mob)
> 

1) First automated mexing will be done by the user if he/she really wants by 
calling function so the idea of just in time is absent.
2) What i was thinking is sth like:
    - Parse file and find loops (and to make it easy) that do not call any 
functions!
    - analyze <for> blocks
    - based on gathered info write mex functions with proper arguments 
(iterators, vectors, matrices) that implement the same loops.
    - system("mex myfunc.mex")
    - make new function file with loops replaced by function calls to mex 
functions.

I m not 100% sure but this sounds much easier than embedding JIT. So we just 
replace loops with function calls. 








reply via email to

[Prev in Thread] Current Thread [Next in Thread]