It sounds like the Altera FPGA environment might facilitate this. Anyone
interested ?
Specifically in making a system that executes python bytecode natively.
Mark (ex Symbolics but not in h/w division)
To see an example of a p14p program running two threads, look in the
system tests. src/tests/system/t075.c is the main() that runs two
threads. In this case, the callables that are run as threads are the
modules t075a.py and t075b.py
$ cd src/tests/system
$ make t075.out
../../tools/pmImgCreator.py -f ../../platform/desktop/pmfeatures.py -c
-u -o t075_img.c --native-file=t075_nat.c t075a.py t075b.py
cc -Os -fno-strict-aliasing -Wall -Wstrict-prototypes -Werror -I../../
vm -I../../platform/desktop -lm -o t075.out t075_nat.c t075_img.c
t075.c ../../platform/desktop/plat.o ../../vm/libpmvm_desktop.a
./t075.out
Thread B
-33417
Thread A
-99
The scheduler is simple round-robin. In order for the VM to be pre-
empted, the system tick must be operational; which means that the
platform interface must periodically call pm_vmPeriodic() giving the
period (in microseconds) as the argument. The common pattern is to
create a periodic timer interrupt on a microcontroller and call
pm_vmPeriodic() from within the ISR.
!!Dean
PS: Great job on the port to Nios. I know a handful of people have
asked if I've ported to Nios. This is the first port to Nios that
I've heard of.
> --
> You are subscribed to the "python-on-a-chip" (or p14p for short)
> Google Group.
> Site: http://groups.google.com/group/python-on-a-chip
The thing that will make hardware acceleration difficult is that many
bytecode operations have more than one purpose. For example, take the
modulo operator, '%'. It's primary operation is to perform numerical
modulus (remainder, in the case of an integer). But its secondary
operation is used more often. Can you think of what that is? String
formatting. This situation applies to a handful of operators.
BINARY_MULTIPLY also performs sequence repetition. BINARY_ADD also
performs string concatenation. My fear is that all these special
cases will impair an elegant hardware acceleration.
The first place I would want hardware assistance would be in resolving
a dictionary lookup. Right now, PyMite has a brain-dead linear search
for the key in the keys list and returns the value at the
corresponding index in the values list. Hardware could do two things
here: (1) Calculate a CRC-8 on immutable objects to use as a hash
key. (2) Assist hash-table lookup when a key is given.
Since namespaces and dicts are so prevalent throughout the VM and most
Pythonistas' application code. Making a faster Dict implementation
would be a huge first step.
!!Dean
The type of the tag indicates which data path the operands should follow.
SO modulo for strings can be concat, modulo for integers uses an integer
ALU and similarly for floats.
(I note the NIOS ALU does a single cycle multiply/divide so they would
take the same ALU but be packed differently.)
The lisp machines did this very well in hardware and were very efficient
- they died out for different reasons.
start here: http://en.wikipedia.org/wiki/Tagged_architecture
OK. so papers on this - 1985. but that's just because no one is doing
this right now as all GC etc is being done in s/w and tags do not hel[p
you unless you are in a OOP language at h/w level. The paper dispells
tagged architectures for languages other than LISP, APL, Icon and weighs
the cost of tags against the cost of dynamic type checking - which
Python also requires.
http://dl.acm.org/citation.cfm?id=327153.
- Browse it here:
http://www.deepdyve.com/lp/association-for-computing-machinery/tagged-architecture-how-compelling-are-its-advantages-9YkhdAibKc
>
> The first place I would want hardware assistance would be in resolving
> a dictionary lookup. Right now, PyMite has a brain-dead linear search
> for the key in the keys list and returns the value at the
> corresponding index in the values list. Hardware could do two things
> here: (1) Calculate a CRC-8 on immutable objects to use as a hash
> key. (2) Assist hash-table lookup when a key is given.
>
> Since namespaces and dicts are so prevalent throughout the VM and most
> Pythonistas' application code. Making a faster Dict implementation
> would be a huge first step.
Yes - sounds like a much better first step
Vern did you use:
http://www.altera.com/products/devkits/altera/kit-cyc3-embedded.html
or something else. Which FPGA are you using ?
The PyMite VM is faithful to the Python 2.6 bytecode.
http://docs.python.org/release/2.6/library/dis.html#python-bytecode-instructions
The thing that will make hardware acceleration difficult is that many bytecode operations have more than one purpose. For example, take the modulo operator, '%'. It's primary operation is to perform numerical modulus (remainder, in the case of an integer). But its secondary operation is used more often. Can you think of what that is? String formatting. This situation applies to a handful of operators. BINARY_MULTIPLY also performs sequence repetition. BINARY_ADD also performs string concatenation. My fear is that all these special cases will impair an elegant hardware acceleration.
The first place I would want hardware assistance would be in resolving a dictionary lookup. Right now, PyMite has a brain-dead linear search for the key in the key works list and returns the value at the corresponding index in the values list. Hardware could do two things here: (1) Calculate a CRC-8 on immutable objects to use as a hash key. (2) Assist hash-table lookup when a key is given.
--
"Si quieres viajar alrededor del mundo y ser invitado a hablar en un
monton de sitios diferentes, simplemente escribe un sistema operativo
Unix."
– Linus Tordvals, creador del sistema operativo Linux
I have been reading about treap at wikipedia and it seems to me just like a regular binary tree but also with a priority random float to be able to do some balancing and improve performance, and also it talks about randomized binary tree, that it's similar but with integers. It's not a bad idea, and we could use several options: python object id, key-value object inserted order in the dict... this has the disadvantage that all the numbers are increasing, so priority will increase also with every insertion and the tree will be suboptimal. One solution is to reuse the ids of deleted objects, so that give some randomization and also it would be posible to reuse their previous space in some cases. In any case the modification that it talk about generate a new priority id on every access to modify the tree and increase the priority of the more accessed ones it's really interesting for me... :-)
In any case, i have found also at wikipedia page a link for a implementation of the treap: http://code.google.com/p/treapdb/
Vern - I would be very keen to hear how you get on with this board and
python.