Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mathematica and Multiprocessor Computers

35 views
Skip to first unread message

Dave Rosky

unread,
Oct 30, 1996, 3:00:00 AM10/30/96
to

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,
gro...@tsc.tdk.com


Ian Collier

unread,
Oct 31, 1996, 3:00:00 AM10/31/96
to

In article <innclip556opu$p...@dragonfly.wolfram.com>, Dave Rosky
<dave....@tsc.tdk.com> wrote:

> [ Clipped from: comp.soft-sys.math.mathematica ]

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["####@host", LinkMode->Connect , LinkProtocol->"TCP"]

Note that the ####@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 ia...@wolfram.com
Wolfram Research Home Page: http://www.wolfram.com/
-----------------------------------------------------------


0 new messages