Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

MathLink speed issues

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19207] MathLink speed issues
  • From: "Roberto Abraham" <abraham at ast.cam.ac.uk>
  • Date: Tue, 10 Aug 1999 02:52:58 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Hi -

I'm finding some rather curious behaviour when using MathLink to communicate
with an external program, and I'm wondering if anyone else understands what
is going on or is experiencing similar behaviour. In a nutshell, what I'm
finding is that the speed with which MathLink transfers large amounts of
machine precision data depends markedly upon the specific floating point
numbers being sent. Without understanding what is going on in detail, I'm
guessing this has something to do with the algorithm used by MathLink to
compress data sent over the link.

Here is the context in which I've noticed this behaviour. I'm doing some
image analysis with Mathematica and to make my life a little easier I've
written a simple OpenGL-based image viewer that communicates with
Mathematica via MathLink. The idea is to create an image in Mathematica,
then use MathLink to send the image to my image viewer,  where I can click
on various parts of the image and send pixel values back to Mathematica
(again via MathLink). The point is to be able to access pixel values and
extract regions from the image without having to mess around with the usual
(in my view somewhat awkward) method of rendering the image in a notebook,
selecting the image with the mouse, control-clicking on points in the image,
then explicitly copy and pasting the pixel positions back into the notebook.

My image viewer seems to work reasonably well --- I'm impressed with the
ease with which one can interface external code to Mathematica. However I've
noticed that certain images transfer over the link at systematically much
greater speeds than other images of identical size.  This behaviour seems
reproducible and depends on specific images.  It seems to be that specific
images just want to get sent over the link more quickly than other images of
identical size. All these images are simple Mathematica packed arrays - ie.
they are all two dimensional images made up of machine precision real
numbers.  But I get a roughly factor of 4 difference in time taken to
transfer identically-sized images, depending on which image I choose to send
over the link.

As an example, it usually takes around 3 seconds for me to display a certain
300x300 image in my external viewer. However if I take that image and
manipulate it by taking the logarithm of the image values, then the
resulting image takes much longer to transfer across the link (tyically
around a factor of 3 longer).  I've verified that the image is stored as a
packed array of real numbers both before and after being manipulated, so I
think I'm comparing apples with apples.

Does the behaviour I'm seeing originate in the way MathLink compresses data
before transferring it? If so, is there any way for me to ensure that I'm
always transferring my images across the link in an optimal way?

Many thanks ---

Bob Abraham


--
---------------------------------------------------------------------------
Roberto Abraham            |  E-mail: abraham at ast.cam.ac.uk
Institute of Astronomy     |  Tel (direct)    +44-(0)-1223-766667
Cambridge University       |      (secretary) +44-(0)-1223-337548
Madingley Road, Cambridge  |  FAX             +44-(0)-1223-337523
CB3 OHA  United Kingdom    |  Mobile                  0467-371014
--------------------------------------------------------------------------
"What gets us into trouble is not what we don't know.
 It's what we know for sure that just ain't so."
 - Yogi Berra
--------------------------------------------------------------------------




  • Prev by Date: Re: Equation Font
  • Next by Date: Re: Table extraction
  • Previous by thread: RE: almost ok
  • Next by thread: Hidden Cells and scrolling