[ale] OT: Multi-core Utilization

Ed Cashin ecashin at noserose.net
Fri Mar 8 16:23:49 EST 2013


On Fri, Mar 8, 2013 at 12:15 PM, Ron Frazier (ALE) <
atllinuxenthinfo at techstarship.com> wrote:

> The go language is supposed to be good for parallel processing but I don't
> know exactly how it works.
>

I've been learning Go as a hobby for a few months and will comment with
regard to this post and the original post (OP), although the OP doesn't
mention Go.  I find Go's concurrency support to be maybe the most fun and
significant programming language feature I have seen in a long time.  I'll
add links for folks who want more info.

Rob Pike, who is maybe most closely associated with the concurrency support
in Go, goes to great lengths to emphasize that parallelism and concurrency
are different concepts.

  http://talks.golang.org/2012/concurrency.slide#1

The problem the OP is talking about is stated in terms of parallelism,
because you want simultaneous execution of different parts of the problem,
but Go's features are presented in terms of concurrency, and you get the
ability to easily do parallelism as a side effect of concurrent programming.

In the case the OP mentions, the strategy for attacking the problem using
idiomatic Go program design would be something like this:

  * decompose the problem into sequential sequences that need to be done
     These will become your goroutines.

    http://golang.org/ref/spec#Go_statements
    http://tour.golang.org/#62

  * identify communication points between the sequences
    These will be places where the goroutines send values through channels.

    http://golang.org/ref/spec#Channel_types
    http://tour.golang.org/#63
    http://golang.org/doc/codewalk/sharemem/

  * share memory for efficiency but pass "ownership" through channels

Finally, you'd need a trick I use to get real parallelism on many versions
of the go runtime.  It schedules goroutines onto O.S. processes.  Tell the
runtime to use more than one process, or you'll have concurrency without
parallelism.  See lines 75 and 79 below.

  https://github.com/ecashin/go-getting/blob/master/bakery.go#L75

But so many people do this in scientific computing that there are probably
libraries that do it faster than you'd be able to code up in less than
months.  I am assuming the OP is motivated by the desire to learn how to
implement stuff like that, not just to do matrix math in parallel.

-- 
  Ed Cashin <ecashin at noserose.net>
  http://noserose.net/e/
  http://www.coraid.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20130308/d0c58b72/attachment.html>


More information about the Ale mailing list