tgriggs at keyww.com
Tue Jun 2 17:44:25 UTC 1998
> -----Original Message-----
> From: Eric King [mailto:rex at smallandmighty.com]
> Sent: Tuesday, June 02, 1998 6:21 AM
> To: squeak at cs.uiuc.edu
> Subject: Re: floatarray primitives
> :I am looking for floatarray which are implemented in
> primitives for speed.
> :I want to use them for intensive vector and matrix type calculations.
> I'm also interested in some capabilities like this, but
> I don't think it's
> very high on the Squeak team's to-do list, and I haven't
> found any third
> parties who've attempted this yet. There's also the question
> as to how much
> such a library would bloat the Squeak VM.
> Personally, I think a high-speed & portable math
> library would be a
> wonderful addition to Squeak and go a long way towards increasing its
> performance. I am willing to help out on such a project but
> how should such
> a library be structured? Matrix routines seem like a good
> place to start,
> but what sorts of matrix routines? You mention a floatarray
> class, should
> it be strictly one dimensional for simplicity, or n-dimensional for
> generality? (I'm a voxel person, so I have an interest in seeing fast
> support for 3D arrays ;))
Have any of you looked at ST/X. I'm not suggesting you use ST/X
necessarily, I recognize that the goal is to do this in Squeak. But it
is interesting how ST/X solves this. ST/X does have FloatArray. In fact,
it has a TypedArray classes for each kind of base C number type. The
difference in ST/X is there inline-C. I'm not a VM/C hacker, otherwise
I'd love to see something like this benefit the Squeak community.
ST/X has a processing program called STC, that takes Smalltalk source
and turns it into ANSI (maybe K&R actually) source. This is similiar in
principle to the C translation capabilities of Squeak. IMO, STC has the
edge, because it does not require you to write your Smalltalk in a C
like way, or restrict use of certain Smalltalk constructs. You can do
blocks, and all of the other cool Smalltalk stuff that we love. What
this means is that you can also embedd fragments of code in your
Smalltalk code, that are not meant to be translated, because they are
written in C already. When the parser/compiler sees a method that has
the embedded C tokens in it, it automatically converts the entire method
to C and compiles it using your favorite C compiler, right there while
you watch. Rather than interpreted, or JIT'ed, it's force compiled.
I have found this to be extremely cool as I have played with it. A long
time ago, since we do alot of numerical processing where I work, we
taught collections how to add, multiply, subtract, divide, etc, ala
numeric vectors. Adding this behavior, as primitives, was so easy, it
made me laugh. In VW, to do this, we had to code up a DLL, an
ExternalInterface, blah, blah, blah. I looked at doing the same thing in
Squeak. STP even posted a good description of how to write your own
primitives. But that required rebooting the image, recompiling the VM,
picking a prim number, c'mon.... In ST/X I just typed in the simple C
loop to add the argument to the recievers elements, and return the new
array as an object, hit the accept button, and was off and running.
Ultimately, I would love to see this kind of approach to the Smalltalk-C
bridge in Squeak. The down side, is that you leave the developer open to
write C code in methods. It's fair to argue that this is just as
portable as the current philosophy, since the Squeak CTranslator
converts things to C anyway. The upside, is that you can change (at
least some of) the VM on the fly. For grins one day, I changed the
basicNew C code to add 2 bytes of fluff to each object, and print out
the memory address of the new object to STDOUT. I hit accept, and tada,
STDOUT started scrolling tons of numbers. I didn't have to reboot the
VM, decide that this was esoteric primitive number 666. It was an
extremely vindicating feeling. I could not have done this in Squeak.
Anyway, if you want to do FloatArray primitives, that IMO is the way to
Key Technology, Inc.
tgriggs at keyww.com
To Smalltalk! - and Beyond!
More information about the Squeak-dev