Hi Jan,
Am Sonntag, den 07.09.2008, 11:28 +0100 schrieb Jan Wedekind:
5AHi,
I'm developing a Ruby-extension for doing computer vision [1] with the
Ruby programming language and I am thinking about replacing the current
C++ template implementation with an implementation based on
libjit and ruby-libjit [2].
I need to generate code to do element-wise unary operations
(such as +,-) and binary (scalar-array,array-scalar,array-array)
operations (such as +,-,*,/,**,minor,major). The element-types of the
two arrays can be various combinations of char, unsigned char, unsigned
short int, ...
I noted that adding to 8-bit values with libjit results in a 32 bit
integer. Since I don't want to overwrite succeeding elements in the array,
I need to convert the result back to 8-bit. A performance comparison shows
that this also has an impact on the performance (see below).
I had a look at the methods "common_binary" and "apply_arith" and I am
wondering whether one could extend the code to support coercions resulting
in 8- or 16-bit values as well.
We'll have to add all arithmetic opcodes for 8bit and 16bit values too which
will about double the number of opcodes for integer arithmetics (and the
corresponding intrinsics).
The next step would be supporting backend specific addressing modes for
arithmetic
operations to be able to emit code like add 0x10(%ecx, %edx, 4), %eax on x86
instead of loading 0x10(%ecx, %edx, 4) to a register first.
Please let me know what you think and tell me if I overlooked something.
It would be really cool if I could get the same performance as a C/C++
implementation.
Libjit is still a just in time compiler where the time needed for code
generation has to be taken into account too.
Any suggestions are welcome.
Klaus