Python + AVX back
Board: Board index ‹ Ray tracing ‹ Considered harmful
(L) [2011/04/13] [Tahir] [Python + AVX] Wayback!Today are almost all renderer's written in C/C++ because of performance.
To achieve maximum performance on CPU you must use AVX, SSE instructions.
I was wondering if you can use AVX, SSE instructions from Python is this will be better option because
programming in Python is lots easier than in C++?
I develop framework for Python so you can dynamically generate machine code and execute it, basically
you write assembly code that you translate to machine code in runtime and execute it.
Only problem is that you must know how to write assembly code! [SMILEY :D]
I know that today lots renderer are developed for GPU but I think that CPU/GPU is also good combination.
I would like to know do you think is it worth to try option Python + AVX + SSE or do you think it make no sense at all?
P.S. I already implement some experiment for simple rendering and it was 300-500 times faster than pure python implementation and
that was just SSE instructions.  [SMILEY :D]
(L) [2011/04/13] [ingenious] [Python + AVX] Wayback!Well, I guess there are two aspects of that thing. The first one is getting the Python code and directly compiling it to machine instructions. The other one is handling SSE/AVX on top of that (by exposing the SIMD instructions to Python?). I suppose the speedup you got was not because of using SSE, but because of optimizing the original Python code.
Now, if you provide a (ultimately JIT) compiler that makes it possible to execute Python code as fast as C++ code, that's awesome! (although others like Google have been dealing with that for some time) And if you also add SIMD support, then I guess it'll be awesome++ [SMILEY :lol:]
(L) [2011/04/13] [Tahir] [Python + AVX] Wayback!I know that Google and others try to speed up Python.
All that I did is JIT assembler for Python. You can see on [LINK http://www.tahir007.com/] how assembler is used from Python.
New version that I currently working on has lots new features that help me to develop complex programs like ray tracer and very soon i will put it on web.
Assembler support 32 and 64-bit code, all SSE instructions,  AVX instructions, structures(similar to those in C) etc....
I got 300-500 speed up because when I run program Python generate assembly code that i wrote before manually.
I know that writing assembly code is not easy but it's also not very hard like the others thinks. I currently working on tool that can allow me to interactive
create functions in assembly code. With this tool I think I can quickly develop functions(fragments) in assembly that I will need for ray tracer.
(L) [2011/04/14] [ingenious] [Python + AVX] Wayback!Oh, OK, I see what you meant. You essentially added support for inline assembly in Python.
But now I'm wondering how I could use that thing... I cannot write the ray tracer in Python, because it will be slow. But I cannot write it in assembly either, because it will be slow... to write [SMILEY :)] I feel a bit like you're giving me a Rolls Royce along with a toolbox to adjust valves and oil pressure. Why ditching the good old Ford Sierra Cosworth? [SMILEY :)]
(L) [2011/04/14] [Tahir] [Python + AVX] Wayback!I must admit you are right about toolbox and Rolls Royce. [SMILEY :D]
You are also right that development of assembly code is slow but very soon i will upload code that i
currently working on that will have lots of fragments of assembly code like intersection routines, so people
can concentrate more on developing just alogorithms and not developing code that allways stays the same.
Even more important they will be able to se how it is easy [SMILEY :D]  to create complex programs in assembly
using this framework.
(L) [2011/09/15] [Tahir] [Python + AVX] Wayback!I must admit that developing Ray tracer using Python + ASM is slower than developing just in C++ but on the other hand it's not slow to abounded this approach.
Using this approach basically whole ray tracer is like one big shader and because of that it's extremely flexible without sacrificing extreme performance.   
 
Here is git repository so you can see how assembler is incorporated in Ray tracer.
[LINK mailto:git@github.com git@github.com]:mario007/renmas.git
Maybe development is slow because I developing ray tracer only in my free time!!!:-)
back