caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Hurt <brian.hurt@qlogic.com>
To: <cashin@cs.uga.edu>
Cc: James Leifer <James.Leifer@inria.fr>, <caml-list@inria.fr>
Subject: Re: [Caml-list] Re: feature priorities (multithreading)
Date: Wed, 19 Feb 2003 11:25:11 -0600 (CST)	[thread overview]
Message-ID: <Pine.LNX.4.33.0302191106080.2037-100000@eagle.ancor.com> (raw)
In-Reply-To: <87fzqk5icy.fsf@uga.edu>

On Wed, 19 Feb 2003 cashin@cs.uga.edu wrote:

> James Leifer <James.Leifer@inria.fr> writes:
> 
> ...
> > What kind of multithreading features do you need?  It would be
> > interesting to understand what would be useful in Ocaml, especially
> > from people who have worked with Erlang, for example.
> 
> Personally, I try to avoid threads because they usually make my
> programs less portable and sometimes more complex.  But many people
> who do parallelizable computation, like scientific computations
> involving matrices, like to increase performance by taking advantage
> of SMP architectures.
> 
> If the threads in a program only run on one processor, then all you
> have is the overhead.  If they run on different processors at the same
> time, with access to the same main memory but with independent caches,
> then the performance benefits start to compensate for the extra
> complexity of multithreading.
> 

With the increasing popularity of SMT CPUs (for example, the P4, and
comming soon the Power5), multithreading for performance will become more
usefull.  For multithreading for performance, I like the cilk interface
myself:

http://supertech.lcs.mit.edu/cilk/

I still haven't wrapped my brain around JoCaml yet, so I can't say which 
is better.  What I like about Cilk is that it allows you to effectively 
use a single CPU, or hundreds, with the same executable.

There is a second use for multithreading: responsiveness.  In a GUI
program, you have multiple threads going at once.  One is responding to
GUI events, the others are performing various time consuming tasks.  The
alternative is to be continually polling the GUI- and if you forget to do
that, you annoy your users.  An example of this would be browsers- one (or
more) threads are downloading files from the web server, while another
thread is waiting on the GUI.  So when you hit 'stop', the GUI can wake up
and actually stop downloading the pages.  Note that cilk style
multithreading would *not* be usefull for solving this problem- cilk is
purely a speed improvement.  This is more why Java added multithreading.

Note that cilk-style multithreading only makes sense with SMP, or at least 
SMT, environments and kernel-level threads.  Java-style multithreading 
works just fine with userspace threads.

Multithreading is more difficult to program than single threading, there 
is no doubt about that.  Although, interestingly enough, I think purely 
functional programs would be easier to multithread than imperitive 
programs.  The big bugbear of multithreaded programs- race conditions- are 
a side effect of, well, side effects.

I've toyed occassional with the idea of having the compiler or run time 
environment add synchronization automatically.  If possible, this would be 
the holy grail of multithreaded programming.  The idea would be that 
objects only visible to one thread don't need any sort of synchronization.  
It's objects visible from two or more threads that need synchronization.  
So a garbage collection like algorithm could detect those objects that 
need synchronization and add it.  Static analysis might also be usefull- I 
don't know.

Brian


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  parent reply	other threads:[~2003-02-19 17:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-10 18:52 [Caml-list] Request: matrix_init function in Array Brian Hurt
2003-02-10 23:22 ` Pierre Weis
2003-02-11  2:37   ` Chris Hecker
2003-02-13  8:33     ` Pierre Weis
2003-02-13 16:50       ` Chris Hecker
2003-02-13 17:13         ` feature priorities (was Re: [Caml-list] Request: matrix_init function in Array) Ed L Cashin
2003-02-14 17:52           ` brogoff
2003-02-14 20:22             ` rich
2003-02-16 23:07               ` Alessandro Baretta
     [not found]                 ` <Pine.LNX.4.53L.0302170500360.32142@ontil.ihep.su>
2003-02-17 22:27                   ` Alessandro Baretta
2003-02-19  9:18           ` [Caml-list] Re: feature priorities (multithreading) James Leifer
2003-02-19 16:46             ` cashin
2003-02-19 17:14               ` Ranjan Bagchi
2003-02-19 17:45                 ` Brian Hurt
2003-02-19 18:17                   ` Will Benton
2003-02-19 19:26                     ` Brian Hurt
2003-02-19 17:25               ` Brian Hurt [this message]
2003-02-19 17:26                 ` Noel Welsh
2003-02-20  8:00               ` Michel Schinz
2003-02-20 16:26                 ` Brian Hurt
2003-02-13 17:38         ` [Caml-list] Request: matrix_init function in Array Brian Hurt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.33.0302191106080.2037-100000@eagle.ancor.com \
    --to=brian.hurt@qlogic.com \
    --cc=James.Leifer@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=cashin@cs.uga.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).