MathGroup Archive 1996

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

Search the Archive

Re: Mathematica and Multiprocessor Computers

  • To: mathgroup at smc.vnet.net
  • Subject: [mg5122] Re: Mathematica and Multiprocessor Computers
  • From: ianc (Ian Collier)
  • Date: Wed, 30 Oct 1996 22:04:50 -0500
  • Organization: Wolfram Research, Inc.
  • Sender: owner-wri-mathgroup at wolfram.com

In article <innclip556opu$p3a at dragonfly.wolfram.com>, Dave Rosky
<dave.rosky at tsc.tdk.com> wrote:

> [ Clipped from: comp.soft-sys.math.mathematica ]
> 
> I am wondering if anyone has any knowlege about whether Mathematica
> (particularly version 3) has any inherent capability to take advantage
> of
> multiple processors on machines which have them -- other than the
> obvious
> case of running two completely separate Mathematica sessions on the
> two CPU's.  I will be receiving a pentium-pro machine which is dual-
> processor capable and it would be nice to know if a second processor
> would provide any speed improvement.  If there is no inherent
> capability,
> perhaps there is a way to link two kernels together to provide some
> parallelism??  Appologies if this question has
> already been asked; our news server only keeps articles for seven days.
> 
> Thanks in advance for any info.
> 
> David,
> groskyd at tsc.tdk.com

The following is taken from the Technical Support FAQ area of Wolfram 
Research's web site <http://www.wolfram.com/support>. The specific URL is:


http://www.wolfram.com/support/2.2/MathLink/Tips/parallelprocessing.html



Can you run Mathematica on parallel processors?


Mathematica kernels can communicate with each other to
simulate parallel processing (assuming you run each kernel on
a different processor or a different machine). You must do the
work to split the problem up into component parts each kernel
can calculate, however. There is no way to get Mathematica to
automatically split up a general program and communicate
over parallel processors for you. If you're willing and able to do
this, then here's a short tutorial on how to communicate
between two kernels. Note that this can be generalized to
communicating between any number of kernels. 

In order to open communications channels between two copies
of Mathematica, you would do the following: 

(on kernel 1) 

link=LinkOpen[LinkMode->Listen,LinkProtocol->"TCP"]

(on kernel 2) 

link=LinkOpen["#### at host", LinkMode->Connect , LinkProtocol->"TCP"]

Note that the #### at host in the second command comes from
the output of the LinkOpen command on the first kernel.
Incidentally, opening this channel of communication requires
that both computers are equipped with the ability to do TCP
network from within Windows. 

Now, to write an expression, on kernel 1, type: 

        LinkWrite[link, 1234]

On kernel 2, type: 

        LinkRead[link]

Note that the first time you do this, the LinkWrite command
might freeze. This is because the kernel 2 needs to give an initial
acknowledgment before data can be passed over the link. 

You can pass any expression over the link, no matter how
complicated. Note, however, that if you're passing an
expression to be evaluated, the LinkWrite command by default
evaluates the argument before it's sent over the link. That is, if
you do: 

        LinkWrite[link, FindRoot[Sin[x] == 0, {x, 1}]]

what actually gets sent over the link is not 

        FindRoot[Sin[x] == 0, {x, 1}]

but is instead: 

        {x->0}

If you want to keep it from evaluating until it gets to the other
side (probably very important for this application), then you'd
want to do: 

        LinkWriteHeld[link, Hold[FindRoot[Sin[x] == 0, {x, 1}]]]

This writes the command over without the Hold statement, so
that a LinkRead on the other side immediately evaluates the
FindRoot. If you want to read the link, but not evaluate it
immediately, use LinkReadHeld instead of LinkRead.
LinkReadHeld immediately wraps the expression in a Hold[],
which can be later released with ReleaseHold[]. 

Hold and ReleaseHold are documented in the book. The link
reading and writing commands are documented in the
MathLink Reference Guide (also avaliable from MathSource as
item number 0204-398) , which should have come with your
copy of Mathematica. 

This can be a bit overwhelming when you first get into it, so if
you have any questions, feel contact Technical Support. 



I hope this helps.

--Ian

-----------------------------------------------------------
Ian Collier
Wolfram Research, Inc.
-----------------------------------------------------------
tel:(217) 398-0700   fax:(217) 398-0747    ianc at wolfram.com
Wolfram Research Home Page:         http://www.wolfram.com/
-----------------------------------------------------------


  • Prev by Date: package for normal form analysis?
  • Next by Date: Mathematica and Multiprocessor Computers
  • Previous by thread: package for normal form analysis?
  • Next by thread: Mathematica and Multiprocessor Computers