<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2921572463043602988</id><updated>2012-02-16T09:20:24.638+01:00</updated><category term='ctypes'/><category term='gsoc'/><category term='proposal'/><category term='jitffi'/><category term='pypy'/><category term='intro'/><title type='text'>Hack Me</title><subtitle type='html'>or not.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://hack.bartskowron.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2921572463043602988/posts/default'/><link rel='alternate' type='text/html' href='http://hack.bartskowron.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Bartosz SKOWRON</name><uri>http://www.blogger.com/profile/12162244894264676683</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2921572463043602988.post-7483239179487466433</id><published>2010-07-09T20:31:00.001+02:00</published><updated>2010-07-09T20:37:39.952+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jitffi'/><category scheme='http://www.blogger.com/atom/ns#' term='ctypes'/><category scheme='http://www.blogger.com/atom/ns#' term='gsoc'/><category scheme='http://www.blogger.com/atom/ns#' term='pypy'/><title type='text'>Various types of arguments and cache</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;Good news! &lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;So, I have finally managed how to omit the limitation of RPython to pass arguments of various type to the called functions. The limitation was due to passing the arguments as a list (which has to have elements of the same type in RPython). Instead of this, internally the &lt;i&gt;jitffi module&lt;/i&gt; fishes elements from the passed list (this is a wrapped list from app-level) and pushes them directly to the calling stack.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;I have added a simple cache for compiled loops. It's a bit primitive but it works. Simple, once the loop is compiled it has been stored in the cache and then before the whole compiling operation, we check if there is already compiled code (if the result type and arguments are the same).&lt;/div&gt;&lt;div style="text-align: justify;"&gt;It still needs some extra work, e.g. once we pushed something to the cache, it has never been removed from. So the cache can grow infinitely. I will try to add some cleaning operation later. It's not really important for now.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;And this week..&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;I will continue my work to have C pointers working as arguments for calling functions.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;That's all.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Have a nice weekend!&lt;/div&gt;&lt;div style="text-align: justify;"&gt;bart.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2921572463043602988-7483239179487466433?l=hack.bartskowron.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hack.bartskowron.com/feeds/7483239179487466433/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hack.bartskowron.com/2010/07/various-types-of-arguments-and-cache.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2921572463043602988/posts/default/7483239179487466433'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2921572463043602988/posts/default/7483239179487466433'/><link rel='alternate' type='text/html' href='http://hack.bartskowron.com/2010/07/various-types-of-arguments-and-cache.html' title='Various types of arguments and cache'/><author><name>Bartosz SKOWRON</name><uri>http://www.blogger.com/profile/12162244894264676683</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2921572463043602988.post-2709344315783479971</id><published>2010-07-05T10:18:00.001+02:00</published><updated>2010-07-09T20:46:15.362+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jitffi'/><category scheme='http://www.blogger.com/atom/ns#' term='ctypes'/><category scheme='http://www.blogger.com/atom/ns#' term='gsoc'/><category scheme='http://www.blogger.com/atom/ns#' term='pypy'/><title type='text'>What have I done...</title><content type='html'>&lt;div style="text-align: justify;"&gt;...sa far :)&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;As you see I'm not really into blogging however I would like to share about the progress with &lt;i&gt;&lt;b&gt;PyPy - fast ctypes&lt;/b&gt;&lt;/i&gt; project.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The code lives in a branch at codespeak and you can simple take a look at:&lt;/div&gt;&lt;blockquote&gt;&lt;a href="https://codespeak.net/viewvc/pypy/branch/fast-ctypes/"&gt;https://codespeak.net/viewvc/pypy/branch/fast-ctypes/&lt;/a&gt;&lt;/blockquote&gt;&lt;div style="text-align: justify;"&gt;or even better check it out:&lt;/div&gt;&lt;blockquote&gt;svn co http://codespeak.net/svn/pypy/branch/fast-ctypes&lt;/blockquote&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;What is already done?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;I guess not too much :-) I've started a new &lt;i&gt;Foreign Function Interface&lt;/i&gt; called &lt;b&gt;jitffi&lt;/b&gt; which you can find in &lt;i&gt;pypy/rlib/rjitffi.py&lt;/i&gt;. For object space go to &lt;i&gt;pypy/module/jitffi/&lt;/i&gt;. It uses the &lt;i&gt;&lt;b&gt;PyPy JIT&lt;/b&gt;&lt;/i&gt; to call functions.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;With this module we can simply load dynamic C libraries and call functions from the loaded library. There are some limitations such as all function arguments have to be the same type. Other limitation is that &lt;b&gt;jitffi&lt;/b&gt; supports only &lt;i&gt;int&lt;/i&gt; and &lt;i&gt;float&lt;/i&gt; types (and &lt;i&gt;void&lt;/i&gt; obviously) so far.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Here is a sample to see how we can use it:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;blockquote&gt;import jitffi&lt;br /&gt;lib = jitffi.CDLL('library_name.so')&lt;br /&gt;&lt;br /&gt;func = lib.get('func_name1', ['int', 'int'], 'int')&lt;br /&gt;func.call([1,2]) # return int&lt;br /&gt;&lt;br /&gt;func = lib.get('func_name2', ['int'])&lt;br /&gt;func.call([10]) # return None (as it's equivalent to C void)&lt;/blockquote&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;This API is completely unstable and changes are made from time to time, or rather from commit to commit :-) The best way is to check appropriate tests to see the current API and how to use it.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;What am I doing now?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;The next &lt;/span&gt;step is to drop the limitation of same type of passing arguments. The problem is that the RPython lists can store only elements of the same type in one instance. &lt;/div&gt;&lt;div style="text-align: justify;"&gt;The idea is to fish the passed arguments from app-level and push it onto the stack. I'm working on it now.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Next? The &lt;i&gt;&lt;b&gt;PyPy JIT&lt;/b&gt;&lt;/i&gt; supports &lt;i&gt;ints&lt;/i&gt;, &lt;i&gt;floats&lt;/i&gt; and &lt;i&gt;pointers&lt;/i&gt;. So, I will go to give a support for the latter.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;This is it. The plan for the next week.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2921572463043602988-2709344315783479971?l=hack.bartskowron.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hack.bartskowron.com/feeds/2709344315783479971/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hack.bartskowron.com/2010/07/what-have-i-done.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2921572463043602988/posts/default/2709344315783479971'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2921572463043602988/posts/default/2709344315783479971'/><link rel='alternate' type='text/html' href='http://hack.bartskowron.com/2010/07/what-have-i-done.html' title='What have I done...'/><author><name>Bartosz SKOWRON</name><uri>http://www.blogger.com/profile/12162244894264676683</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2921572463043602988.post-5316334899709206532</id><published>2010-05-26T23:10:00.004+02:00</published><updated>2010-07-04T13:51:03.461+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ctypes'/><category scheme='http://www.blogger.com/atom/ns#' term='gsoc'/><category scheme='http://www.blogger.com/atom/ns#' term='pypy'/><category scheme='http://www.blogger.com/atom/ns#' term='proposal'/><title type='text'>Google Summer of Code 2010 - fact ctypes</title><content type='html'>&lt;div style="text-align: justify;"&gt;So, this is my third time with GSoC program. Last year I was chosen by &lt;i&gt;&lt;b&gt;Umit Project&lt;/b&gt;&lt;/i&gt; and &lt;i&gt;&lt;b&gt;PyPy&lt;/b&gt;&lt;/i&gt; (through &lt;i&gt;Python Software Foundation&lt;/i&gt;) and I had to choose where to go. I decided to go with Umit Project and finish my project which was born during GSoC 2007 edition. The main reason was that I needed it to my Master Thesis.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;So, this year I gave a try with PyPy again and fortunately I was chosen again! Thanks guys!&lt;/div&gt;&lt;div style="text-align: justify;"&gt;And here is my project proposal for this year...&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-size: medium;"&gt;Project Name&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;PyPy - fast ctypes&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-size: medium;"&gt;Introduction&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;The PyPy project aims at  producing a flexible and fast Python implementation. The guiding idea is  to translate a Python-level description of the Python language itself  to lower level languages.&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;PyPy project's main part is not  Python interpreter implementation, but its configurable translator. It  provides a good way to avoid writing interpreter for every language and  platform. It provides tool-chain for translating front-end dynamic  language into one of the back-ends (e.g. C, CLI).&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;Since 1.2 release[1], PyPy has  provided &lt;i&gt;Just-In-Time&lt;/i&gt; compiler (actually it's a 5th generation,  also called pyjitpl5)[2]. Currently the speed up for Python applications  is massive[3], however it doesn't mean that the PyPy has reached the  limits. One of the way to give a boost is to speed up ctypes[4]. And  this is a main goal of the proposal.&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-size: medium;"&gt;Project Details&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;Current  implementation of &lt;i&gt;pypy/lib/_ctypes&lt;/i&gt; uses &lt;i&gt;libffi&lt;/i&gt;[5] library  through &lt;i&gt;_rawffi&lt;/i&gt; module. The idea is to give a chance to JIT in  supporting ctypes. This can be reached by rewriting ctypes in RPython  and avoiding to use libffi.&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;The rewriting process ain't  that simple due to restrictions in RPython language[6]. One of the  obvious issues which has to be solved in the project is dynamic amount  of arguments in calling functions. Python allows to use dynamic amount  of arguments, so does JIT. Unfortunately, there is RPython in the middle  which is enough restricted and static to forbid this. The issue to  solve is how to transport dynamic amount of arguments through RPython.&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;In  fact that the goal is to speed up ctypes especially by using JIT,  special attention is needed during the porting process. From the  beginning, RPython's ctypes should be written with the JIT in mind. The  JIT should be able to trace ctypes since first incarnation of the new  ctypes. This fact will impact on some implementation details.&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-size: medium;"&gt;References&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;[1]  http://codespeak.net/pypy/trunk/pypy/doc/release-1.2.0.html&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;[2]  http://codespeak.net/pypy/trunk/pypy/doc/jit/pyjitpl5.html&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;[3] http://speed.pypy.org&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;[4] http://python.net/crew/theller/ctypes/&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;[5]  http://sourceware.org/libffi/&lt;/div&gt;&lt;div class="Standard" style="text-align: justify;"&gt;[6]  http://codespeak.net/pypy/dist/pypy/doc/coding-guide.html#restricted-python&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2921572463043602988-5316334899709206532?l=hack.bartskowron.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hack.bartskowron.com/feeds/5316334899709206532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hack.bartskowron.com/2010/05/google-summer-of-code-2010-fact-ctypes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2921572463043602988/posts/default/5316334899709206532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2921572463043602988/posts/default/5316334899709206532'/><link rel='alternate' type='text/html' href='http://hack.bartskowron.com/2010/05/google-summer-of-code-2010-fact-ctypes.html' title='Google Summer of Code 2010 - fact ctypes'/><author><name>Bartosz SKOWRON</name><uri>http://www.blogger.com/profile/12162244894264676683</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2921572463043602988.post-5560661633796930938</id><published>2010-05-26T19:32:00.000+02:00</published><updated>2010-05-26T19:32:46.936+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gsoc'/><category scheme='http://www.blogger.com/atom/ns#' term='intro'/><title type='text'>The Blog</title><content type='html'>Seems like I was more or less forced to start a technical blog. So, here I am :)&lt;br /&gt;&lt;br /&gt;Mostly, I will use this blog for status updates of my GSoC project. But we will see what future will bring :-)&lt;br /&gt;&lt;br /&gt;Enjoy hacking!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2921572463043602988-5560661633796930938?l=hack.bartskowron.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hack.bartskowron.com/feeds/5560661633796930938/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hack.bartskowron.com/2010/05/blog.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2921572463043602988/posts/default/5560661633796930938'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2921572463043602988/posts/default/5560661633796930938'/><link rel='alternate' type='text/html' href='http://hack.bartskowron.com/2010/05/blog.html' title='The Blog'/><author><name>Bartosz SKOWRON</name><uri>http://www.blogger.com/profile/12162244894264676683</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
