Slashdot Mirror


Is Parallel Programming Just Too Hard?

pcause writes "There has been a lot of talk recently about the need for programmers to shift paradigms and begin building more parallel applications and systems. The need to do this and the hardware and systems to support it have been around for a while, but we haven't seen a lot of progress. The article says that gaming systems have made progress, but MMOGs are typically years late and I'll bet part of the problem is trying to be more parallel/distributed. Since this discussion has been going on for over three decades with little progress in terms of widespread change, one has to ask: is parallel programming just too difficult for most programmers? Are the tools inadequate or perhaps is it that it is very difficult to think about parallel systems? Maybe it is a fundamental human limit. Will we really see progress in the next 10 years that matches the progress of the silicon?"

121 of 680 comments (clear)

  1. Nope. by Anonymous Coward · · Score: 2, Insightful

    Parallel programming isn't all that hard, what is difficult is justifying it.

    What's hard, is trying to write multi-threaded java applications that work on my VT-100 terminal. :-)

    1. Re:Nope. by lmpeters · · Score: 5, Interesting

      It is not difficult to justify parallel programming. Ten years ago, it was difficult to justify because most computers had a single processor. Today, dual-core systems are increasingly common, and 8-core PC's are not unheard of. And software developers are already complaining because it's "too hard" to write parallel programs.

      Since Intel is already developing processors with around 80 cores, I think that multi-core (i.e. multi-processor) processors are only going to become more common. If software developers intend to write software that can take advantage of current and future processors, they're going to have to deal with parallel programming.

      I think that what's most likely to happen is we'll see the emergence of a new programming model, which allows us to specify an algorithm in a form resembling a Hasse diagram, where each point represent a step and each edge represents a dependency, so that a compiler can recognize what can and cannot be done in parallel and set up multiple threads of execution (or some similar construct) according to that.

    2. Re:Nope. by dch24 · · Score: 3, Funny

      Parallel programming isn't all that hard
      Then why is it that (as of right now) all the up-modded posts are laid out sequentially down the comment tree?
    3. Re:Nope. by poopdeville · · Score: 5, Interesting

      I think that what's most likely to happen is we'll see the emergence of a new programming model, which allows us to specify an algorithm in a form resembling a Hasse diagram, where each point represent a step and each edge represents a dependency, so that a compiler can recognize what can and cannot be done in parallel and set up multiple threads of execution (or some similar construct) according to that.

      This is more-or-less how functional programming works. You write your program using an XML-like tree syntax. The compiler utilizes the tree to figure out dependencies. See http://mitpress.mit.edu/sicp/full-text/book/book-Z -H-10.html#%25_sec_1.1.5. More parallelism can be drawn out if the interpreter "compiles" as yet unused functions while evaluating others. See the following section.

      --
      After all, I am strangely colored.
    4. Re:Nope. by Lost+Engineer · · Score: 5, Interesting

      It is still difficult to justify if you can more easily write more efficient single-threaded apps. What consumer-level apps out there really need more processing power than a single core of a modern CPU can provide? I already understand the enterprise need. In fact, multi-threaded solutions for enterprise and scientific apps are already prevalent, that market having had SMP for a long time.

    5. Re:Nope. by Gorshkov · · Score: 4, Insightful

      Then why is it that (as of right now) all the up-modded posts are laid out sequentially down the comment tree?
      Because one of the things TFM neglects to mention is that parallel programming, like any other programming method, is suitable for some things and not for others .... and the hard reality is, is that most application programmes you see on the desktop are basically serial, simply because of the way PEOPLE process tasks & information

      There is a very real limit as to how much you can parallelize standard office tasks.
    6. Re:Nope. by lmpeters · · Score: 3, Insightful

      What consumer-level apps out there really need more processing power than a single core of a modern CPU can provide?

      The iLife suite. Especially iMovie. And let's not forget the various consumer and professional incarnations of Photoshop--none of them support more than two cores.

    7. Re:Nope. by Anonymous Coward · · Score: 4, Informative

      Functional programming is no harder than procedural/OO programming. A good functional interpreter can already draw this kind of parallelism out of a program. And yes, there are compiled functional languages with parallelizing compilers. (Erlang and OCaml come to mind)

    8. Re:Nope. by Durandal64 · · Score: 3, Informative

      Multi-threaded programming is very difficult. But some things just shouldn't be done on multiple threads either. Multi-threading is a trade-off to get (generally) better efficiency and performance in exchange for vastly more complex control logic in many cases. This greater complexity means that the program is much more difficult to debug and maintain. Sometimes multi-threading a program is just a matter of replacing a function call with a call to pthread_create(...). But sometimes a program just can't be multi-threaded without introducing unacceptable complexity. A lot of the complaints of difficulty in multi-threading comes from people trying to multi-thread programs that can't be easily changed.

    9. Re:Nope. by RzUpAnmsCwrds · · Score: 3, Insightful

      Functional programming is no harder than procedural/OO programming.


      That's difficult to say because true functional programming is so vastly different. We have so much time and energy invested in imperative algorithms that it's difficult to know whether or not functional methods are easier or more difficult to design.

      In a sense, it's like saying that Hybrid Synergy Drive is simpler than a traditional transmission. It's true on a conceptual level, but Toyota hasn't tried to put HSD everywhere it has put a traditional transmission and therefore we may not fully understand the complexities of trying to extrapolate the results to the entire problem space.

      So, I think the bottom line is, functional programming probably wouldn't be any harder if it existed in a world where it was dominant.

      Remember, a large part of being an effective programmer is understanding how (and if) your problem has been solved before. It may be far from optimal, but CPUs are largely designed to look like they are executing sequential instructions. Multicore and multithreaded designs are changing that model, but it's not a change that happens overnight.
    10. Re:Nope. by chocobot · · Score: 2

      Parallel programming does not have to be hard. All that stuff you learn in programming basics about deadlocks and semaphores and stuff really is hard, but there are easier ways of parallel programming.
      Check out the communicating event loops of the E language or the actors of Scala. Asynchronous message passing removes the deadlock problem and makes relatively easy to understand programs.

    11. Re:Nope. by EvanED · · Score: 5, Insightful

      Yes, but that's an easy sort of parallelism. Heck, I wrote a fractal generator that did the generation in a separate thread in 11th grade after writing my first Win32 program 4 or 5 months previous. It was also my first experience with threads. I'm not even sure I really knew what they were before that. This isn't *really* paralleling the application in the sense TFA means.

      Closer is this: After some more work and a rewrite (for other reasons), I had "Fracked" running n threads, each rendering 1/n of the display. Data parallelism == easy parallelism.

      But a lot of problems don't fit these models, and need a LOT of thought put into how to parallelize them. It's likely that some problems in P are not efficiently parallelizable.

    12. Re:Nope. by Anonymous Coward · · Score: 2, Insightful

      Puppies are cute. You shouldn't use poison on everything. Fast food is convenient but makes you fat. More fat means you look fatter. Some things are easy. Some things are hard. Screen doors on submarines are unpopular.

    13. Re:Nope. by gnalre · · Score: 2, Insightful

      Most of the problems of parallel programming were solved decades ago. Unfortunately the industry can be very conservative with new programming methods and tends to shoe horn the tried and trusted on to new problems.

      The truth is languages such as C/C++ and Java(to lesser extent) are not good languages to write parallel code in. They do not have the constructs built in such as process communication links, mutexes, semaphores that parallel programs rely on. You end up writing aracne code to get this sort of functionality.

      The other problem is that the debugging tools make montoring multiple parallel programs difficult.

      20 years ago I was using a language called Occam that made writing multiple parallel programs a breeze, 10 years ago I was using erlang which again allowed us to easily generate thousands of lightweight threads.

      Today I am still struggling to write the same things in C++ using the standard windows process constructs.

      --
      Choose your allies carefully, it is highly unlikely you will be held accountable for the actions of your enemies
    14. Re:Nope. by Novus · · Score: 2, Informative

      Asynchronous message passing removes the deadlock problem
      Could you elaborate on your reasoning behind that? You can just as easily have processes deadlocked waiting for messages from each other as for semaphores or locks to be released (and I've seen hundreds of examples as a TA on a concurrent programming course).
    15. Re:Nope. by Anonymous Coward · · Score: 2, Interesting

      Don't forget that the makers of applications like that will probably see a multi-core version as something they can sell at a premium.
      So they first sell versions for a single CPU, then when the market for multi-core versions is sufficiently large they start selling new versions and upgrades.
      It is good to keep the clients waiting for some time, because they will feel that their special needs have been catered for. When they would put out two different boxes at a time almost nobody is interested yet, the negative feelings around "why does the multi-core version cost more" will hit them too much.

    16. Re:Nope. by chocobot · · Score: 2

      for me, deadlock is a situation where several objects compete for acquisition to a set of resources. AFAIK this can't happen if asynchronous message sending is used, as requests don't block the requesting party. What you describe is data lock, where two objects/threads/whatever wait for each other to answer before they can continue themselves. This situation is much more difficult to create than deadlocks, also the complete process should not grind to a halt, only the waits should accumulate. Also, live lock problems are consistent, reproducible, and therefore fixable, unlike the deadlocks that appear mysteriously when some incredibly arcane race condition occurs

    17. Re:Nope. by XchristX · · Score: 2, Insightful

      for me, deadlock is a situation where several objects compete for acquisition to a set of resources Well the wikipedia article certainly alludes to that definition (http://en.wikipedia.org/wiki/Deadlock) but the article may be general and not pertain to parallel computing (there is no mention of parallel computing in that article). I thought what you're describing fell into "race condition". The IBM Redbook on MPI (Page 26 of http://www.redbooks.ibm.com/abstracts/sg245380.htm l) explains deadlock as follows (pages 26, 27, 28):

      When two processes need to exchange data with each other, you have to be careful about deadlocks. When a deadlock occurs, processes involved in the deadlock will not proceed any further. Deadlocks can take place either due to incorrect order of send and receive... which is what I said in the last post

      ...,or due to the limited size of the system buffer The first pseudocode on page 27 basically shows what you called a "datalock", right? Also, see Michael Quinn "Parallel Computing in C with MPI and OpenMP" page 148 section 6.5.3 first para

      A Process is in a deadlock state if it is blocked waiting for a condition that will never become true Which seems to not cover your case... Maybe we're talking about different subsets of the same thing, not sure. I'm till rather new to parallel computing.
      --
      l'Homme n'est Rien l'Oeuvre Tout: Gustave Flaubert to George Sand
    18. Re:Nope. by stony3k · · Score: 3, Informative

      The truth is languages such as C/C++ and Java(to lesser extent) are not good languages to write parallel code in.
      To a certain extent Java is trying to correct that with the java.util.concurrent library. Unfortunately, not many people seem to have started using it yet.
      --
      Freedom is not worth having if it does not include the freedom to make mistakes. - Mahatma Gandhi
    19. Re: Nope. by Dolda2000 · · Score: 3, Informative
      It is definitely hard to justify parallel programming, even though many computers are gaining SMP capabilities. The thing isn't necessarily that it is particularly hard to write multi-threaded applications -- the thing is that it is a lot harder to write a multi-threaded program than to write a single-threaded program. Suddenly, you have to introduce locks in all shared data structures and ensure proper locking in all parts of the program. That kind of thing just adds a significant part to the complexity of a program, and it requires a lot more testing as well. Therefore, justification is definitely needed.

      The real question then, is: Is it justified? To be honest, for most programs, the answer is no. Most interactive programs have a CPU-time/real-time ratio of a lot less than 1% during their lifetime (and very likely far less than 10% during normal, active use), so any difference brought by parallelizing them won't even be noticed. Other programs, like compilers, don't need to be parallelized, since you can just run "make -j8" to use all of your 8 cores at once. I would also believe that there are indeed certain programs that are rather hard to parallelize, like games. I haven't written a game in a quite a long time now, and I don't know the advances that the industry has made as of late, but a game engine's step cycle usually involves a lot of small steps, where the execution of the next depends on the result of the previous one. You can't even coherently draw a scene before you know that the state of all game objects has been calculated in full. Not that I'm saying that it isn't parallelizable, but I would think it is, indeed, rather hard.

      So where does that leave us? I, for one, don't really see a great segment of programs that really need parallelizing. There may be a few interactive programs, like movie editors, where the program logic is heavy enough for it to warrant a separate UI thread to maintain interactive responsiveness, but I'd argue that segment is rather small. A single CPU core is often fast enough not to warrant parellelizing even many CPU-heavy programs. There definitely is a category of programs that do benefit from parellelization (e.g. database engines which serve multiple clients), but they are often parellelized already. For everyone else, there just isn't incentive enough.

    20. Re:Nope. by bcrowell · · Score: 2, Insightful

      It is still difficult to justify if you can more easily write more efficient single-threaded apps. What consumer-level apps out there really need more processing power than a single core of a modern CPU can provide?
      Agreed. I just replaced my old machine with a dual-core machine a few months ago, and I find that I basically always have one cpu idle. When things are slow, they're usually slow because they're waiting on I/O. At one point I thought I had a killer app, which was ripping MP3s from CDs. I would run cdparanoia from the command line to rip, and then when that was done, I would have 01.wav, 02.wav, 03.wav, etc. I wrote little one-liner scripts that would then run the MP3 encoder so that one cpu would be doing all the odd-numbered tracks, the other cpu all the evens. Worked great. But then I decided to automate the whole thing a little more, so I wrote a fancy perl script that would start three sub-processes, one for ripping and two for encoding the tracks as soon as they were done being written to disk. Well it turned out that a single cpu was almost always capable of keeping up with the speed of my cd drive, so I still ended up with one idle cpu after all. You might think, "Hey, you can use that other cpu to run your gui apps." Actually, the linux scheduler is good enough that as long as I run the MP3 encoder with "nice," it has zero impact on interactive jobs, even when they're sharing a cpu. Typing characters into a word-processor just isn't a very cpu-intensive application.

    21. Re:Nope. by smellotron · · Score: 4, Insightful

      But a lot of problems don't fit these models, and need a LOT of thought put into how to parallelize them. It's likely that some problems in P are not efficiently parallelizable.
      I would venture a guess that most problems would benefit from parallelizing basic data structure tasks:
      • anything (comparable) can be sorted using divide-and-conquer mergesort
      • scanning through an array-based collection (*not* a linked list) can be divided among processors—this is frequently done in hardware, e.g. for CPU cache hashtable lookups
      Further, there's a few other obvious ways to parallelize:
      • Split program into a chain of filters between producers and consumers, and give each filter its own thread/process. For example, create an event receiver thread, a "do-stuff" thread, and a display thread. At the very least, this will reduce UI response latency.
      • Split program processing into "1 event dispatcher + N worker threads", like Apache or Squid. This by itself would be a good way to reduce blocking in most applications. Why should the interface be locked up when expensive processing is happening in a program? Maybe while Photoshop/GIMP runs some filter on my image, I'd like to browse the help documents or scroll around the viewport.
      • Re-evaluate any processing as a dependency tree, and code it in something like Twisted, where every piece of code executes nonblocking snippets, and a reactor thread dispatches between them (this is basically like light-light-weight threads)

      The reason the problems don't fit these models is moreso that we're used to thinking about algorithms as an ordered list of steps, rather than a set of workers on an assembly line (operating as fast as the slowest individual worker).

    22. Re:Nope. by EricTheRed · · Score: 2, Insightful

      That is true. Over the last six months I've been doing interviews for a single developer position, and the one common question I've asked as about java.util.concurrent. In some 20 interviewees, only one had a vague idea what it was.

      Here we use it quite extensively because it's the best way to handle parallel code and shared data structures.

      It's probably the most useful things in Java 5 & 6, and the least used.

      --
      Java gaming nut - http://www.retep.org/ or for the rail http://uktra.in/
    23. Re:Nope. by poopdeville · · Score: 3, Informative

      Well, Lisp doesn't look like XML. But its s-expressions are able to deal with tree like structures just as easily. If you have some free time, I suggest reading http://www.defmacro.org/ramblings/lisp.html.

      --
      After all, I am strangely colored.
    24. Re:Nope. by pivo · · Score: 2, Interesting

      How much time have you spent writing Lisp? I ask because I was initially uncomfortable with s-expressions (as are many people) but after a certain amount of time something in my brain flipped, and now I'm much *more* comfortable with them. Part of it had to do with the fact that I'm drawn to writing code in the functional style (imperative code in Lisp *is* uncomfortable) and part was just getting my brain to see the structure in the parens.

  2. our brains aren't wired to think in parallel by rritterson · · Score: 5, Insightful

    I can't speak for the rest of the world, or even the programming community. That disclaimer spoken, however, I can say that parallel programming is indeed hard. The trivial examples, like simply running many processes in parallel that are doing the same thing (as in, for example, Monte Carlo sampling) are easy, but the more difficult examples of parallelized mathematical algorithms I've seen, such as those in linear algebra are difficult to conceptualize, let alone program. Trying to manage multiple threads and process communication in an efficient way when actually implementing it adds an additional level of complexity.

    I think the biggest reason why it is difficult is that people tend to process information in a linear fashion. I break large projects into a series of chronologically ordered steps and complete one at a time. Sometimes if I am working on multiple projects, I will multitask and do them in parallel, but that is really an example of trivial parallelization.

    Ironically, the best parallel programmers may be those good managers, who have to break exceptionally large projects into parallel units for their employees to simultaneously complete. Unfortunately, trying to explain any sort of technical algorithm to my managers usually exacts a look of panic and confusion.

    --
    -Ryan
    AUWYHSTOT (Acronyms are Useless When You Have to Spell Them Out Too)
    1. Re:our brains aren't wired to think in parallel by Anonymous Coward · · Score: 5, Informative

      I do a lot of multithreaded programming, this is my bread and butter really. It is not easy - it takes a specific mindset, though I would disagree that it has much to do with management. I am not a manager, never was one and never will be. It requires discipline and careful planning.

      That said, parallel processing is hardly a holy grail. On one hand, everything is parallel processing (you are reading this message in parallel with others, aren't you?). On the other, when we are talking about a single computer running a specific program, parallel usually means "serialized but switched really fast". At most there is a handful of processing units. That means, that whatever it is you are splitting among these units has to give itself well to splitting this number of ways. Do more - and you are overloading one of them, do less - and you are underutilizing resources. In the end, it would be easier often to do processing serially. Potential performance advantage is not always very high (I know, I get paid to squeeze this last bit), and is usually more than offset by difficulty in maintenance.

    2. Re:our brains aren't wired to think in parallel by Organic+Brain+Damage · · Score: 2, Interesting

      People may or may not process information in a linear fashion, but human brains are, apparently, massively parallel computational devices.

      Addressing architecture for Brain-like Massively Parallel Computers

      or from a brain-science perspective

      Natural and Artificial Parallel Computation

      The common tools (Java, C#, C++, Visual Basic) are still primitive for parallel programming. Not much more than semaphores and some basic multi-threading code (start/stop/pause/communicate from one thread to another via common variables). I've made programs, specifically, spiders, that can run 200-1,000 simultaneous threads usefully on a PC. They work ok, as long as the inter-thread coupling is minimized. Until we get enough exposure to parallel systems that we develop new languages to express the solutions, parallel programming will remain accessible to the few, the proud, the geeks. But I don't think it's because of our brains architecture.

    3. Re:our brains aren't wired to think in parallel by ubernostrum · · Score: 4, Insightful

      You may want to look into Erlang, which does two things that will interest you:

      • Concurrency is handled by lightweight thread-like pseudo-processes passing messages to one another, and supported directly in the language.
      • Shared state between these processes is absolutely forbidden.

      There are still concurrent problems which are hard, but generally it boils down to the problem being hard instead of the language making the problem harder to express.

    4. Re:our brains aren't wired to think in parallel by bladesjester · · Score: 2, Insightful

      you are reading this message in parallel with others, aren't you?

      I don't know about the rest of Slashdot, but I read comments in a linear fashion - one comment, then the next comment, etc. Most people that I have known read in a linear fashion.

      Walking and chewing gum is a parallel process. Reading is generally linear.

      --
      Everything I need to know I learned by killing smart people and eating their brains.
    5. Re:our brains aren't wired to think in parallel by Anonymous Coward · · Score: 2, Interesting

      In my exp it's not really that hard and it really doesn't come down to thinking in parallel except in cases where you are going for really fine-grained parallelism. Coarse grained parallelism is really easy and can give HUGE benefits to users... a simple example of this is creating a background thread to handle incremental saves... suddenly the app stays responsive as it's GUI thread is no longer being stalled by factors beyond it's control (ie: network load).

      Under C++ I use the boost threading libraries and they are excellent, allowing me to write once and run on all required platforms and when my Java hat is on it's a snap too because of the superb libraries available.... moral, it is hard if you don't use the right tools or try to split the task along poorly chosen boundaries.

      Granted that tasks like large matrix solves and the like are a brute to multi-thread... but fortunately people that are way smarter than me have already done it and I can handle plugging in a library.

    6. Re:our brains aren't wired to think in parallel by bloosqr · · Score: 3, Interesting

      Back when i was in graduate school we used to joke .. in the future everything will be monte carlo :)

      While everything perhaps can't be solved using monte carlo type integration tricks .. there is more that can be done w/ 'variations of the theme' than is perhaps obvious .. (or perhaps you can rephrase the problem and ask the same question a different way) .. perhaps if you are dreaming like .. what happens if i have a 100,000 processors at my disposal etc

    7. Re:our brains aren't wired to think in parallel by buswolley · · Score: 4, Insightful

      Our brains are massively parallel, but we do not consciously attend to more than a couple of things at a time.

      --

      A Good Troll is better than a Bad Human.

    8. Re:our brains aren't wired to think in parallel by jd · · Score: 5, Insightful
      Parallel programming is indeed hard. The standard approach these days is to decompose the parallel problem into a definite set of serial problems. The serial problems (applets) can then be coded more-or-less as normal, usually using message-passing rather than direct calls to communicate with other applets. Making sure that everything is scheduled correctly does indeed take managerial skills. The same techniques used to schedule projects (critical path analysis) can be used to minimize time overheads. The same techniques used to minimize the use of physical resources (SIMPLEX aka Operational Research) works just as well on software for physical resources there.

      The first problem is that people who make good managers make lousy coders. The second problem is that people who make good coders make lousy managers. The third problem is that plenty of upper management types (unfortunately, I regard the names I could mention as genuinely dangerous and unpredictable) simply have no understanding of programming in general, never mind the intricacies of parallelism.

      However, resource management and coding is not enough. These sorts of problems are typically either CPU-bound and not heavy on the networks, or light on the CPU but are network-killers. (Look at any HPC paper on cascading network errors for an example.) Typically, you get hardware which isn't ideally suited to either extreme, so the problem must be transformed into one that is functionally identical but within the limits of what equipment there is. (There is no such thing as a generic parallel app for a generic parallel architecture. There are headaches and there are high-velocity exploding neurons, but that's the range of choices.)

      --
      It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    9. Re:our brains aren't wired to think in parallel by buswolley · · Score: 2, Insightful

      Our brains may be massively parallel, but this doesn't not mean we can effectively attend to multiple problem domains at once. Especially, our conscious attentional processes tend to be able to focus on at most a couple of things at once, albeit at a high level of organizational description.

      --

      A Good Troll is better than a Bad Human.

    10. Re:our brains aren't wired to think in parallel by poopdeville · · Score: 5, Insightful

      That's debatable. You don't look at text one letter at a time to try to decipher the meaning, do you? You probably look at several letters, or even words, at a time. Understanding how the letters or words relate (spatially, syntactically, semantically) is a parallel process. Unless you're a very slow reader, your eyes have probably moved on from the words you're interpreting before you've understood their meaning. This is normal. This is how you establish a context for a particular word or phrase -- by looking at the surrounding words. Another parallel process.

      Every process is serial from a broad enough perspective. Eight hypothetical modems can send 8 bits per second. Or are they actually sending a single byte?

      --
      After all, I am strangely colored.
    11. Re:our brains aren't wired to think in parallel by bladesjester · · Score: 2, Insightful

      If you want to make that argument, you might as well make the argument that a computer doing the simple addition of two numbers is doing parallel processing.

      It could also be stated in a twisted manner of your view - looked at narrowly enough, anything can be considered to be parallel. However, realistically, we know that isn't really the case.

      --
      Everything I need to know I learned by killing smart people and eating their brains.
    12. Re:our brains aren't wired to think in parallel by Anonymous Coward · · Score: 5, Funny

      Our brains are massively parallel, but we do not consciously attend to more than a couple of things at a time.
      Speak for yourself, I forget to breathe whenever I'm doing someth...
    13. Re:our brains aren't wired to think in parallel by mwvdlee · · Score: 2, Informative

      You can eat and talk at the same time?
      Didn't your mother ever teach you not to?

      On a serious note; how conscious are you when you talk? Do you consciously trigger all required muscle movement or does you brain queue a "say 'word'" command which is then processed unconsciously? Probably neither, but the latter is likely closer to reality. There is actually VERY little that we do consciously.

      --
      Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
    14. Re:our brains aren't wired to think in parallel by EvanED · · Score: 5, Interesting

      I can eat, talk and think at the same time, all are pretty conscious actions

      True, but can you talk (perhaps reciting something from memory) at the same time you are listening to something? Even if it's not a volume issue; you're wearing headphones say.

      Feynman has a chapter in "What do you care what other people think" where he talks about some informal experimentation he did where he tried to figure out what he could do at the same time as accurately timing out a minute. Essentially, the same time as counting. He found that (1) he could be very consistent about timing out a given time, and that (2) he could do most things while counting. But what he couldn't do is talk. On discussion with other people in his dorm/frat/house/whatever, there was another person who could talk, but couldn't read while timing things out. Turns out that the reason it differed was because they counted differently; Feynman was hearing "one, two, three, ..." while this other guy was watching the numbers pass in front of his eyes.

      Activities are localized in the brain; it seems that these areas are largely independent, but try two tasks that use the same area and you're SOL.

    15. Re:our brains aren't wired to think in parallel by Lars512 · · Score: 2, Funny

      I think the biggest reason why it is difficult is that people tend to process information in a linear fashion. I break large projects into a series of chronologically ordered steps and complete one at a time. Sometimes if I am working on multiple projects, I will multitask and do them in parallel, but that is really an example of trivial parallelization.

      That's because you have a global interpreter lock.

    16. Re:our brains aren't wired to think in parallel by Eivind · · Score: 2, Interesting

      Sure. Short-term we could learn to do a lot of simple tasks better in parallell. Drawing the circle and square at the same time is hard, but it gets a lot easier even with just a few hours of practice.

      Longer term, we'd *evolve* better handling of parallellism if it gave us significant survival-benefits (well, really reproductive-benefits, but you get the idea)

      When we *do* manage many things at a time it is mostly by practicing them to the point where as much as possible about them become automatic, "muscle memory" (which isn't really, but atleast it's subconscious)

      A trained driver can;

      • Change gears (manual)
      • Operate blinkers
      • Turn wheel
      • Adjust speed (gas or brake)
      • Check mirrors
      • Judge intentions, speed, curve of other trafficants
      • Observe yield-signs
      More or less all simultaneously. But that is only possible because so much of it is automatic.

      The newbie-driver thinks "I'm in second, third is *there*, revs are high, better shift, clutch in, gas out, shift, touch of gas, declutch", he may even be able to do it smoothly without the car jumping after a few tries. But he *won't* be able to have his full attention elsewhere while doing it.

      The trained driver thinks at most "shift", oftentimes not even that. He is rarely consciously even aware of what gear he is running, the entire sequence of steps required to smoothly shift has been internalised as a single action, and even the invoking of that actions is on semi-automatic. (I realize many americans drive an automatic, I'm assuming a driver used to manual here)

      What I'm saying is that, drawing a (rough!) circle is very easy for an adult. Drawing a rough rectangle is very easy too. So you'd expect to be able to do both *without* having to train it. Certainly any one of them taxes much less than half your mental capacity. Only that ain't so.

    17. Re:our brains aren't wired to think in parallel by hey! · · Score: 2, Insightful

      Our brains may be parallel, but is our consciousness parallel? I don't think so.

      The problem isn't that our brains our consciousness is unable to do this, however. All programming involves interactions between details that potentially is too much for us to handle. Good programming is limiting interactions to a small number of well defined interfaces, and very good programming reduces the amount of context you have to consider to what you can visually scan in a few seconds.

      The problem is that the paradigms for interacting parts are not familiar.

      I've been through this several times in my career. When I started most programs were of a filter-ish nature; they started at the top and fell to the bottom, with a number of abstracted side trips via subroutine calls. Then came the GUI, and even basic programs became systems like operating systems, in that they ran for an indeterminate length of time, orchestrating responses to a stream of events of unpredictable, potentially unlimited length. This was a massive shift for programmers; many thought it was impossibly difficult for a typical programmer to work on this kind of system.

      Same thing happened when web applications came along. We supposedly couldn't use the "simple" model of a single process working in a common address space anymore as applications started to take on a distributed flavor, distributed not across address spaces, but application hosts: browser based javascript, web application container, web services hosts, database hosts etc.

      Parallel programming isn't the last new paradigm programmers will be asked to absorb. People will do it, then move on to complain about the next big thing.

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
    18. Re:our brains aren't wired to think in parallel by Hoi+Polloi · · Score: 2, Funny

      Actually I parallel process when I read most Slashdot comments. Right now for instance I was reading your comment but thinking about cupcakes. Ummm, cupcakes...

      --
      It is by the juice of the coffee bean that thoughts acquire speed, the teeth acquire stains. The stains become a warning
    19. Re:our brains aren't wired to think in parallel by Reivec · · Score: 2, Interesting

      By this logic, it seems like maybe we are not designing our multi-core processors effectively. It may be more effective if we designed different cores for different tasks, much like our brains. If you could describe to a programmer 4 cores on a processor and that each core was really only good at ONE type of processing, then that programmer would logically break up his design into peices for each core to do individually. Even if they had to be done in serial, each core may process its peice faster than a general CPU and thus make the whole process faster. If you were running other programs at the same time that were also serial, they may not be asking for the same cores all the time either.

      I realize this is over simplified and would probably have lots of problems in practice. However I know that there are plans to combine CPU and GPU cores for very much the same reasons, they are good in some areas and bad in others.

    20. Re:our brains aren't wired to think in parallel by ubernostrum · · Score: 2, Interesting

      I've read through the first five or so chapters from the Erlang book (it's almost impossible to find in the States, but Amazon.co.uk will print it for you on-demand) but haven't done much work with it other than a few toy programs.

      Yeah, I've been doing tutorials and bought the beta PDF edition of Joe Armstrong's book, but at one point I stopped to go back and do The Little Schemer to refresh my ability to frame everything in terms of recursion on lists. Haven't gotten back to Erlang yet, but I've been keeping an eye out for something useful to do with it as a first non-trivial application. You'd think it'd be easy for a web-dev geek to come up with problems that are well-suited to the pseudo-functional concurrent style, but it's harder than it looks :)

      I've also been playing off and on with Scala, which is a pretty neat little language; it runs on the JVM (and has seamless importing of Java classes, which is quite nice), but has first-class and higher-order functions, anonymous functions, pattern matching (including pattern matching on classes, which is wicked cool), list comprehensions and the ability to use either Java's Thread API or its own Actor-based concurrency model. It's definitely worth looking at if you've been enjoying Erlang.

      By the way, do you happen to know of shops running Erlang? I've heard that Amazon is using it, but I don't know of anyone in the Chicago area using Erlang other than Orbitz.

      Not off the top of my head, but I'm also somewhat sidetracked by an ongoing effort to pull the news industry off Java and onto Python :)

  3. Two words: map-reduce by Anonymous Coward · · Score: 3, Interesting

    Implement it, add CPUs, earn billion$. Just Google it.

    1. Re:Two words: map-reduce by allenw · · Score: 5, Informative
      Implementing MapReduce is much easier these days: just install and contribute to the Hadoop project. This is an open source, Java-based MapReduce implementation, including a distrbuted filesystem called HDFS.

      Even though it is implemented in Java, you can use just about anything with it, using the Hadoop streaming functionality.

    2. Re:Two words: map-reduce by LarsWestergren · · Score: 2, Insightful

      Two words: map-reduce
      (Score:4, Interesting)
      by Anonymous Coward on 07-05-29 6:29 (#19305183)
      Implement it, add CPUs, earn billion$. Just Google it.


      Wow, fantastic. Turns out parallel programming was really really easy after all. I guess we can make all future computer science courses one week then, since every problem can be solved by map-reduce! The AC has finally found the silver bullet. Bravo, mods.

      --

      Being bitter is drinking poison and hoping someone else will die

    3. Re:Two words: map-reduce by pchan- · · Score: 2, Funny

      I guess we can make all future computer science courses one week then, since every problem can be solved by map-reduce!

      What do you mean? I just wrote a clone of Half-Life 2 using only Map-Reduce. It works great, but it requires 600 exabytes of pre-computed index values and data sets and about 200 high end machines to reach decent frame rates.

  4. Have some friggin' patience by Corydon76 · · Score: 4, Insightful

    Oh noes! Software doesn't get churned out immediately upon the suggestion of parallel programming! Programmers might actually be debugging their own code!

    There's nothing new here: just somebody being impatient. Parallel code is getting written. It is not difficult, nor are the tools inadequate. What we have is non-programmers not understanding that it takes a while to write new code.

    If anything, that the world hasn't exploded with massive amounts of parallel code is a good thing: it means that proper engineering practice is being used to develop sound programs, and the jonny-come-lately programmers aren't able to fake their way into the marketplace with crappy code, like they did 10 years ago.

  5. It's not trivial, and often not necessary by Opportunist · · Score: 5, Interesting

    Aside from my usual lament that people already call themselves programmers when they can fire up Visual Studio, parallelizing your tasks opens quite a few cans of worms. Many things can't be done simultanously, many side effects can occur if you don't take care and generally, programmers don't really enjoy multithreaded applications, for exactly those reasons.

    And often enough, it's far from necessary. Unless you're actually dealing with an application that does a lot of "work", calculate or display, preferable simultanously (games would be one of the few applications that come to my mind), most of the time, your application is waiting. Either for input from the user or for data from a slow source, like a network or even the internet. The average text processor or database client is usually not in the situation that it needs more than the processing power of one core. Modern machines are by magnitudes faster than anything you usually need.

    Generally, we'll have to deal with this issue sooner or later, especially if our systems become more and more overburdened with "features" while the advance of processing speed will not keep up with it. I don't see the overwhelming need for parallel processing within a single application for most programs, though.

    --
    We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
  6. Not justifyable by dj245 · · Score: 3, Interesting

    I can see this going down in cubicles all through the gaming industry. The game is mostly coming together, the models have been tuned, textures drawn, code is coming together, and the coder goes to the pointy haired boss.

    Coder: We need more time to make this game multithreaded!
    PHB: Why? Can it run on one core of a X?
    Coder: Well I suppose it can but...
    PHB: Shove it out the door then.

    If flight simulator X is any indication (a game that should have been easy to parallize) this conversation happens all the time and games are launched taking advantage of only one core.

    --
    Even those who arrange and design shrubberies are under considerable economic stress at this period in history.
    1. Re:Not justifyable by Grave · · Score: 4, Insightful

      I seem to recall comments from Tim Sweeney and John Carmack that parallelism needed to start from the beginning of the code - IE, if you weren't thinking about it and implementing it when you started the engine, it was too late. You can't just tack it on as a feature. Unreal Engine 3 is a prime example of an engine that is properly parallelized. It was designed from the ground up to take full advantage of multiple processing cores.

      If your programmers are telling you they need more time to turn a single-threaded game into a multi-threaded one, then the correct solution IS to push the game out the door, because it won't benefit performance to try to do it at the end of a project. It's a fundamental design choice that has to be made early on.

    2. Re:Not justifyable by LarsWestergren · · Score: 2, Insightful

      PHB: Why? Can it run on one core of a X?
      Coder: Well I suppose it can but...
      PHB: Shove it out the door then.


      I think the PHB may have a point. Games are expensive to make, gamers are fickle, and if reviews say a game "looks dated" it is a death sentence for sales. Rewriting an engine to be multi-threaded after it is done will take a lot of time and money, and most PCs out there have more dated hardware than you think, so most current players won't see any benefints whatsoever from it anyway.

      --

      Being bitter is drinking poison and hoping someone else will die

    3. Re:Not justifyable by smallfries · · Score: 2, Informative

      Given that it is an example of an embarrasingly parallel algorithm, like ray-tracing. No, it is not the best example. The difficulty in parallel programming is trying to divide up the work when your sub-problems are not entirely independent of each other.

      --
      Slashdot: where don knuth is an idiot because he cant grasp the awesome power of php
  7. Are Serial Programmers Just Too Dumb? by ArmorFiend · · Score: 4, Interesting

    For this generation of "average" programmers, yes its too hard. Its the programming language, stupid. The average programming language has come a remarkably short distance in the last 30 years. Java and Fortran really aren't very different, and neither is well suited to paralellizing programs.

    Why isn't there a mass stampede to Erlang or Haskell, languages that address this problem in a serious way? My conclusion is that most programmers are just too dumb to do major mind-bending once they've burned their first couple languages into their ROMs.

    Wait for the next generation, or make yourself above average.

    1. Re:Are Serial Programmers Just Too Dumb? by Opportunist · · Score: 2, Interesting

      That's maybe due to most programmers nowadays not being programmers but people who learned how to write code. When the IT biz was the make-money-fast scheme, people picked up any kind of computer skill that more or less fit them, some went into web based programming since that's where the really big bucks were, they learned PHP and a few tidbits of logic.

      Then dot.com blew up and they were dead in the water. Today you need a fraction of the PHP artists that were sought after in 2000. So they picked up C, in a sorta-kinda-way, since it's "about the same" and now they push into the programming market as cheap workforce.

      Well, you get what you pay for.

      --
      We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
  8. Programmers by Anonymous Coward · · Score: 2, Insightful

    Well, the way they 'teach' programming nowadays, programmers are simply just typists.

    No need to worry about memory management, java will do it for you.

    No need to worry about data location, let the java technology of the day do it for you.

    No need to worry about how/which algorithm you use, just let java do it for you, no need to optimize your code.

    Problem X => Java cookbook solution Y

  9. Parallel Language... by vortex2.71 · · Score: 3, Insightful

    Though there are many very good parallel programmers who make excellent use of the Message Passing Interface, we are entering a new era of parallel computing where MPI will soon be unusable. Consider when the switch was made from assembly language to a programming language - when the "processor" contained too many components to be effectively programmed with machine language. That same threshold has long since passed with parallel computers. Now that we have computers with more than 100 thousand processors and are working to build computers with more than a million processors, MPI has become the assembly language of parallel programming. It hence, needs to be replaced with a new parallel language that can controll great numbers of processors.

  10. Yes, difficult, but our brains are not limited. by themoneyish · · Score: 2, Insightful

    In one word, the answer is yes. It's difficult for people who are used to programming for a single CPU.

    Programmers that are accustomed to non-parallel programming environments forget to think about the synchronization issues that come up in parallel programming. Several conventional programs do not take into account synchronization of the shared memory or message passing requirements that come up for these programs to work correctly in a parallel environment.

    This is not to say that there will not be any progress in this field. There will be and there has been. The design techniques and best practices differ for parallel programming than for the conventional programming. Also currently there is limited IDE support for debugging purposes. There are already several books on this topic and classes in the universities. As the topic becomes more and more important, computer science students will be required to take such classes (as opposed to it being optional) and more and more programmers that know and are experts in parallel programming will be churned out. It's just not as popular because the universities don't currently seem to make it a required subject. But that will change because of the advancement in hardware and more market demand for expert parallel programmers.

    Our brains might be limited about other things, but this is just a matter of better education. 'Nuff said.

  11. Clusters? by bill_mcgonigle · · Score: 3, Insightful

    Since this discussion has been going on for over three decades with little progress in terms of widespread change

    Funny, I've seen an explosion in the number of compute clusters in the past decade. Those employ parallelism, of differing types and degrees. I guess I'm not focused as much on the games scene - is this somebody from the Cell group writing in?

    I mean, when there's an ancient Slashdot joke about something there has to be some entrenchment.

    The costs are just getting to the point where lots of big companies and academic departments can afford compute clusters. Just last year the price of multi-core CPU's made it into mainstream desktops (ironically, more in laptops so far). Don't be so quick to write off a technology that's just out of its first year of being on the desktop.

    Now, that doesn't mean that all programmers are going to be good at it - generally programmers have a specialty. I'm told the guys who write microcode are very special, are well fed, and generally left undisturbed in their dark rooms, for fear that they might go look for a better employer, leaving the current one to sift through a stack of 40,000 resumes to find another. I probably wouldn't stand a chance at it, and they might not do well in my field, internet applications - yet we both need to understand parallelism - they in their special languages and me, perhaps with Java this week, doing a multithreaded network server.

    --
    My God, it's Full of Source!
    OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
  12. Yes and no. Languages help (or hinder). by Anonymous Coward · · Score: 2, Insightful

    It's very easy to just say "Parallel programming is too hard", and try to ignore it. But consider this: the languages we use today are designed to work in the same way as the CPUs of old: one step at a time, in sequence, from start to finish.

    A special case of this is seen in the vector units found in today's CPUs: MMX, SSE, Altivec, and so forth. You can't write a C compiler that takes advantage of these units (not easily, anyway), because the design of C means that a programmer takes the mathematics and splits it up into a bunch of sequential instructions. Fortran, on the other hand, is readily adapted, because the language is designed for mathematics; you tell it what you need to do, but not how to do it.

    In the same way, trying to cram parallelism into a program written in C is a nightmare. Semaphores, exclusive zones, shared variables, locking, deadlocks ... there's a hell of a lot to think about, and you only have to get it wrong once to introduce a very hard to reproduce and debug problem. Other languages are more abstract, and have much greater opportunities for compilers to extract the inherent parallelism; it's just that they have had more use to date in academia to illustrate principles than in the real world to solve problems.

    As time marches on, and the reality of the situation becomes increasingly obvious, I would expect that performance-intensive apps will start to be written in languages better suited to the domain of parallel programming. Single threaded apps will remain - eg, Word doesn't really need any more processing power (MS' best efforts to the contrary notwithstanding) - and C-like languages will still be used in that domain, but I don't think inherently sequential languages, like C, C++, and others of that nature, will be as common in five or ten years as they are today, simply because of the rise of the parallel programming domain necessitating the rise of languages that mimic that domain better than C does.

  13. Yes and No by synx · · Score: 5, Interesting

    The problem with parallel programming is we don't have the right set of primitives. Right now the primitives are threads, mutexes, semaphores, shared memory and queues. This is the machine language of concurrency - it's too primitive to effective write lots of code by anyone who isn't a genius.

    What we need is more advanced primitives. Here are my 2 or 3 top likely suspects:

    - Concurrent Sequential Programs - CSP. This is the programming model behind Erlang - one of the most successful concurrent programming languages available. Writing large, concurrent, robust apps is as simple as 'hello world' in Erlang. There is a whole new way of thinking that is pretty much mind bending. However, it is that new methodology that is key to the concurrency and robustness of the end applications. Be warned, it's functional!
    - Highly optimizing functional languages (HOFL) - These are in the proto-phase, and there isn't much available, but I think this will be the key to extremely high performance parallel apps. Erlang is nice, but not high performance computing, but HOFLs won't be as safe as Erlang. You get one or the other. The basic concept is most computation in high performance systems is bound up in various loops. A loop is a 'noop' from a semantic point of view. To get efficient highly parallel systems Cray uses loop annotations and special compilers to get more information about loops. In a functional language (such as Haskel) you would use map/fold functions or list comprehensions. Both of which convey more semantic meaning to the compiler. The compiler can auto-parallelize a functional-map where each individual map-computation is not dependent on any other.
    - Map-reduce - the paper is elegant and really cool. It seems like this is a half way model between C++ and HOFLs that might tide people over.

    In the end, the problem is the abstractions. People will consider threads and mutexes as dangerous and unnecessary as we consider manual memory allocation today.

    1. Re:Yes and No by GileadGreene · · Score: 2, Interesting

      Concurrent Sequential Programs - CSP. This is the programming model behind Erlang
      Technically speaking, Erlang has more in common with the Actor model than with CSP. The Actor model (like Erlang) is based on named actors (cf Erlang pids) that communicate via asynchronous passing of messages sent to specific names. CSP is based on anonymous processes that communicate via synchronized passing of messages sent through names channels. Granted, you can essentially simulate one model within the other. But it pays to be clear about which model we're discussing.

      There is a whole new way of thinking that is pretty much mind bending.
      It's really not that new. CSP has been around in the literature since at least 1978 (the date of Hoare's first paper on the topic). Hewitt's Actor model predates that by a number of years. Languages implementing both CSP and the Actor model have been around for at least 20 years. They just haven't seen widespread use so far.

      Be warned, it's functional!
      Not necessarily. Erlang is certainly implemented that way. But it's not a requirement. The 20-year old occam programming language, which was based pretty heavily on CSP, is basically an imperative language. The E programming language is OO to the core. The Oz language freely mixes functional, imperative, and OO constructs. All three permit message-passing concurrency in the Actor or CSP style.

      The compiler can auto-parallelize a functional-map where each individual map-computation is not dependent on any other.
      This can help to improve the performance of computational tasks. But it doesn't address the fact that (a) the world is fundamentally concurrent, and (b) most modern apps (web browsers, word processors, games) have a large interactive component that could really benefit from a concurrent design. Too much emphasis is being placed on pure computational speed in discussions like this one, when in most cases computation isn't the bottleneck - it's I/O and interactivity. As Joe Armstrong (the guy behind Erlang) has said, "In Concurrency Oriented Programming, the concurrent structure of the program should follow the concurrent structure of the application. It is particularly suited to programming applications which model or interact with the real world."
  14. It's still the wild west... by Max+Romantschuk · · Score: 2, Interesting

    Parallel programming and construction share one crucial fundamental requirement: Proper communication. But building a house is much easier to grasp. Programming is abstract.

    I think part of the problem is, that many programmers tend to be lone wolves, and having to take other people (and their code, processes, and threads) into consideration is a huge psychological hurdle.

    Just think about traffic: If everyone were to cooperate and people wouldn't cut lanes and fuck around in general we'd all be better off. But traffic laws are still needed.

    I figure what we really need is to develop proper guidelines and "laws" for increased parallelism.

    Disclaimer: This is all totally unscientific coming from the top of my head...

    --
    .: Max Romantschuk :: http://max.romantschuk.fi/
  15. Yes, because programmers are too conservative by Coryoth · · Score: 5, Insightful

    Parallel programming doesn't have to be quite as painful as it currently is. The catch is that you have to face the fact that you can't go on thinking with a sequential paradigm and have some tool, library, or methodology magically make everything work. And now, I'm not talking about functional programming. Functional programming is great, and has a lot going for it, but solving concurrent programming issues is not one of those things. Functional programming deals with concurrency issues by simply avoiding them. For problems that have no state and can be coded purely functionally this is fine, but for a large number of problems you end up either tainting the purity of your functions, or wrapping things up in monads which end up having the same concurrency issues all over again. It does have the benefit that you can isolate the state, and code that doesn't need it is fine, but it doesn't solve the issue of concurrent programming.

    No, the different sorts of paradigms I'm talking about no shared state, message passing concurrency models ala CSP and pi Calculus and the Actor Model. That sort of approach in terms of how to think about the problem shows up in languages like Erlang, and Oz which handle concurrency well. The aim here is to make message passing and threads lightweight and integrated right into the language. You think in terms actors passing data, and the language supports you in thinking this way. Personally I'm rather fond of SCOOP for Eiffel which elegantly integrates this idea into OO paradigms (an object making a method call is, ostensibly, passing a message after all). That's still research work though (only available as a preprocessor and library, with promises of eventually integrating it into the compiler). At least it makes thinking about concurrency easier, while still staying somewhat close more traditional paradigms (it's well worth having a look at if you've never heard of it).

    The reality, however, is that these new languages which provide the newer and better paradigms for thinking and reasoning about concurrent code, just aren't going to get developer uptake. Programmers are too conservative and too wedded to their C, C++, and Java to step off and think as differently as the solution really requires. No, what I expect we'll get is kluginess retrofitted on to existing languages in a slipshod way that sort of work, in as much as it is an improvement over previous concurrent programming in that language, but doesn't really make the leap required to make the problem truly significantly easier.

  16. Amdahl's law by apsmith · · Score: 5, Insightful

    I've worked with parallel software for years - there are lots of ways to do it, lots of good programming tools around even a couple of decades back (my stuff ranged from custom message passing in C to using "Connection-Machine Fortran"; now it's java threads) but the fundamental problem was stated long ago by Gene Amdahl - if half the things you need to do are simply not parallelizable, then it doesn't matter how much you parallelize everything else, you'll never go more than twice as fast as using a single thread.

    Now there's been lots of work on eliminating those single-threaded bits in our algorithms, but every new software problem needs to be analyzed anew. It's just another example of the no-silver-bullet problem of software engineering...

    --

    Energy: time to change the picture.

  17. Too much emphasis on instruction flow by putaro · · Score: 3, Interesting

    I've been doing true parallel programming for the better part of 20 years now. I started off writing kernel code on multi-processors and have moved on to writing distributed systems.

    Multi-threaded code is hard. Keeping track of locks, race conditions and possible deadlocks is a bitch. Working on projects with multiple programmers passing data across threads is hard (I remember one problem that took days to track down where a programmer passed a pointer to something on his stack across threads. Every now and then by the time the other thread went to read the data it was not what was expected. But most of the time it worked).

    At the same time we are passing comments back and forth here on Slashdot between thousands of different processors using a system written in Perl. Why does this work when parallel programming is so hard?

    Traditional multi-threaded code places way too much emphasis on synchronization of INSTRUCTION streams, rather than synchronization of data flow. It's like having a bunch of blind cooks in a kitchen and trying to work it so that you can give them instructions so that if they follow the instructions each cook will be in exactly the right place at the right time. They're passing knives and pots of boiling hot soup between them. One misstep and, ouch, that was a carving knife in the ribs.

    In contrast, distributed programming typically puts each blind cook in his own area with well defined spots to use his knives that no one else enters and well defined places to put that pot of boiling soup. Often there are queues between cooks so that one cook can work a little faster for a while without messing everything up.

    As we move into this era of cheap, ubiquitous parallel chips we're going to have to give up synchronizing instruction streams and start moving to programming models based on data flow. It may be a bit less efficient but it's much easier to code for and much more forgiving of errors.

    1. Re:Too much emphasis on instruction flow by underflowx · · Score: 3, Interesting

      My experience with data flow is LabVIEW. As a language designed to handle simultaneous slow hardware communication and fast dataset processing, it's a natural for multi-threading. Parallelization is automated within the compiler based on program structure. The compiler's not all that great at it (limited to 5 explicit threads plus whatever internal tweaking is done), but... the actual writing of the code is just damn easy. Not to excuse the LabVIEW compiler: closed architecture, tight binding to the IDE, strong typing that's really painful, memory copies everywhere. But the overall model for dataflow is just superior for parallel applications. It's unfortunate that there seems to be little alternative out there with similar support for data flow, but more overall utility.

    2. Re:Too much emphasis on instruction flow by mvarga · · Score: 2, Interesting

      Programmers aren't so bad. There is a paper coming from the Berkeley University, which mathematically proves that a multithreaded program cannot be thoroughly tested, so after a very strict testing procedure, there can still be deadlocks or other synchronization problems in the program. I am just working on a framework which would practically hides the need of mutexes and other synchronization primitives, and tries to provide a "fool-proof" parallel programming framework. Do you think that making it an open-source project (eg. on SourceForge) could be useful? I am not sure whether a new paradigm which does not come from a software giant could gain any attention...

  18. Errors are difficult to find out in such systems by himanshuarora · · Score: 2, Informative

    Well, I was a Teaching Assistant of 'Concurrent Algorithms'. There used to be 30 students for that class. For a given assignment there used to be 30 different solutions and many used to be wrong.

    It is difficult to find out errors in these kind of algorithms. There has been some papers published in big conferences and it was found that some mathematical proofs were wrong because they could not think of some scenarios where it can fail.

    --
    Spam: Any activity on internet to gain popularity without paying to advertising companies like Google.
  19. bad education by nanosquid · · Score: 3, Insightful

    No, parallel programming isn't "too hard", it's just that programmers never learn how to do it because they spend all their time on mostly useless crap: enormous and bloated APIs, enormous IDEs, gimmicky tools, and fancy development methodologies and management speak. Most of them, however, don't understand even the fundamentals of non-procedural programming, parallel programming, elementary algorithms, or even how a CPU works.

    These same programmers often think that ideas like "garbage collection", "extreme programming", "visual GUI design", "object relational mappings", "unit testing", "backwards stepping debuggers", and "refactoring IDEs" (to name just a few) are innovations of the last few years, when in reality, many of them have been around for a quarter of a century or more. And, to add insult to injury, those programmers are often the ones that are the most vocal opponents of the kinds of technologies that make parallel programming easier: declarative programming and functional programming (not that they could actually define those terms, they just reject any language that offers such features).

    If you learn the basics of programming, then parallel programming isn't "too hard". But if all you have ever known is how to throw together some application in Eclipse or Visual Studio, then it's not surprising that you find it too hard.

    1. Re:bad education by ad0le · · Score: 2, Insightful

      I've read several comments like yours in this thread. I just picked a random one to comment on. It's important to realize that the majority of professional developers are paid to produce a product, that works, in the shortest amount of time possible, with the mindset that things will need to change quickly to accommodate clients needs. As well, most professional developers aren't really low level guys and deal mostly with glorified database frontends with scattered business logic thrown about. Things like ORMs, RAD IDEs and extreme programming allow for this type of hostile environment with a relatively quick turnaround. It's a competitive market and not everyone can, or even needs, work at the machine level.

      I get the feeling allot of you hardcore guys miss the idea that multicore systems are still very helpful, regardless of rather a thread model is implemented or not. When a machine is responsible for running a RDBMS, webserver, FTP server, mail server and an application pool, adding a threading model to your application can become a serious bottleneck.

      I would venture to guess, that the majority of professional (not at an academic, student or research level) would hardly ever have the need for parallel systems.

      The point I am trying to make, is; the benefits of a multicore machine, go FAR beyond individual applications in the real world.

      --
      My mother never saw the irony in calling me a son-of-a-bitch.
    2. Re:bad education by xtracto · · Score: 3, Insightful

      Yes, and my point is that tools like Eclipse, Visual Studio, XML libraries, GUI designers, etc. probably hurt programmer productivity. Their real benefit is to reduce the amount of training people need initially, but whether that is a good tradeoff overall is unclear; one highly skilled programmer may well be more productive and cost-effective overall than ten average programmers.

      Not to be misunderstood: I do think there is a place for good tools to support working programmers, it's just that the tools that are widespread are mainly aimed at getting people "hooked" on them, not at supporting experienced professional programmers optimally.


      I think you are misunderstanding the objective of the tools you are naming... they have been conceived to help developers in their work. It is not Microsoft's or Eclipse foundation (or the Gnome guys) that wannabe "code monkeys" play with their tools for 2 weeks and add them as a skill in their curriculum. Look at those tools as if they were carpenter tools like an electric drill or handsaw. They are conceived to make easier the work of the carpenter, but yo *do* need to *know* what you are doing. You can not say that they hurt the carpenters productivity because they incite people that do not know anything about woodworking to grab a DIY book and put an add on the newspaper...

      --
      Ubuntu is an African word meaning 'I can't configure Debian'
  20. Two Problems by SRA8 · · Score: 3, Insightful

    I've encountered two problems with parallel programming 1. For applications which are constantly being changed under tight deadlines, parallel programming becomes an obstacle. Parallelism adds complexity which hinders quick changes to applications. This is a very broad generalization, but often the case. 2. Risk. Parallelism introduces a lot of risk, things that arent easy to debug. Some problems I faced happened only once every couple of weeks, and involved underlying black-box libraries. For financial applications, this was absolutely too much risk to bear. I would never do parallel programming for financial applications unless management was behind it fully (as they are for HUGE efforts such as monte carlo simulations and VaR apps.)

  21. A Case Study by iamdrscience · · Score: 2, Informative

    My brother just recently started doing IT stuff for the research psych department at a respected university I won't name. They do a lot of mathematical simulations with Matlab and in order to speed these up they decided to buy several Mac Pro towers with dual quad core Xeons at $15,000*. The problem is, their simulations aren't multithreaded (I don't know if this is a limitation of Matlab or of their programming abilities -- maybe both) so while one core is cranking on their simulations to the max, the other 7 are sitting there idle! So while a big part of this ridiculous situation is just uninformed people not understanding their computing needs, it also shows that there are plenty of programmers stuck playing catch-up since computers with multiple cores (i.e. Core 2 Duo, Athlon X2, etc.) have made their way onto the desktops of normal users.

    I think this is a temporary situation though, and something that has happened before, there have been many cases where new powerful hardware seeps into the mainstream before programmers are prepared to use it.



    *I know what you're thinking: "How the hell do you spend $15,000 on a Mac?". I wouldn't have thought it was possible either, but basically all you have to do is buy a Mac with every single option that no sane person would buy: max out the overpriced RAM, buy the four 750GB hard drives at 100% markup, throw in a $1700 Nvidia Quadro FX 4500, get the $1K quad fibre channel card, etc.

  22. And what of the other limit? by holophrastic · · Score: 2, Insightful

    I would argue that most user tasks cannot be fundamentally parallel. Quite simply, if a user highlights some text, and hits the bold button, there really isn't anything to split across multiple cores. No matter how much processing is necessary to make the text bold (or to build the table, or to check the spelling of a word, or to format a report, or to calculate a number, or to make a decision -- as in A.I.) it's a serial concept, and a serial algorithm, and cannot be anything more. Serial is cool too remember.

    So we're looking at multiple tasks. Obvious gaming and operating systems get to split by engine (graphics, network, interface, each type of sound, A.I., et cetera). I'd guess that there is a limit of about 25 such engines that anyone can dream up. Obviously raytracing gets to have something like 20 cores per pixel, which is really really cool. But that's clearly the exception.

    So really, in my semi-expert and wholy professional opinion, I think priming is the way to go. That is, it takes the user up to a second to click a mouse button. So if the mouse is over a word, start guessing. Get ready to bold it, underline it, turn it into a table, look up related information, pronounce it, stretch it, whatever.

    Think of it as: "we have up to a full second to do something. We don't know what it's going to be, but we have all of these cores just sitting here. So we'll just start doing stuff." It's the off-screen buffering of the user task world.

    Which results in just about any task, no matter how complicated, can be instantly presented -- having already been calculated.

    Doesn't exactly save power, but hey, the whole point is to utilize power. And power requires power. There must be someone's law -- the conservation of power, or power conversion, or something that discusses converting power between various abstract or unrelated forms -- muscle to crank to generator to battery to floatig point to computing to management to food et cetera; whatever.

    Right, so priming / off-screen buffering / preloading. Might as well parse every document in the directory when you open the first one. Might as well load every application on start-up. Can't have idle cores lying around just for fun.

    Has anyone ever thought that maybe we won't run out of copper after all? I'd bet that at some point in the next twenty years, we go back to clock speed improvement. I'd guess that it's when core busing becomes rediculous.

    I still don't understand how we went from shared RAM as the greatest thing in the world to GPU's with on-board RAM, to CPU's with three levels of on-chip RAM, to cores each with their own on-core RAM.

    Hail to the bus driver; bus driver man.

  23. The Bill comes due by stox · · Score: 4, Insightful

    After years of driving the programming profession to its least common denominator, and eliminating anything that was considered non-essential, somebody is surprised that current professionals are not elastic enough to quickly adapt to a changing environment in hardware. Whoda thunk it? The ones, you may have left, with some skills are nearing retirement.

    --
    "To those who are overly cautious, everything is impossible. "
  24. Just look around by const · · Score: 2, Informative

    A lot of efforts are being done to simplify the parallel programming, both on micro scale and component scale. Just look through lambda-the-ultimate archives. Micro scale is mostly invisible to application programmers, and it is mostly done by compilers when they use SSE and friends, one of notable efforts of making it more explicit is OpenMP. On component scale, most of them are based on the message passing concurrency model (after you grok it, it is really really simple). The best effort that I have seen from point of view of usability is E programming language. I tried to clone its core ideas in my pet project AsyncObjects Framework, but usability is less than E's one because of the framework clutter.

  25. What kind of parallel programming? by david.emery · · Score: 3, Insightful

    Many of the responses here, frankly, demonstrate how poorly people understand both the problem and the potential solutions.

    Are we talking about situations that lend themselves to data flow techniques? Or Single Instruction/Multiple Data (e.g. vector) techniques? Or problems that can be broken down and distributed, requiring explicit synchronization or avoidance?

    I agree with other posters (and I've said it elsewhere on /.) that for parallel/distributed processing, Language Does Matter. (And UML is clearly part of the problem...)

    Then there's the related issue of long-lived computation. Many of the interesting problems in the real-world take more than a couple of seconds to run, even on today's machines. So you have to worry about faults, failures, timeouts, etc.

    One place to start for distributed processing kinds of problems, including fault tolerance, is the work of Nancy Lynch of MIT. She has 2 books out (unfortunately not cheap), "Distributed Algorithms" and "Atomic Transactions". (No personal/financial connection, but I've read & used results from her papers for many years...)

    I get the sense that parallelism/distributed computation is not taught at the undergrad level (it's been a long time since I was an undergrad, and mine is not a computer science/software engineering/computer engineering degree.) And that's a big part of the problem...

            dave

    1. Re:What kind of parallel programming? by david.emery · · Score: 2, Interesting

      If you continue to depend on C and C++ for doing this kind of work, you can continue to expect these kinds of results.

      Ada95 is a -much better- choice for this kind of programming, with a rich set of concurrency primitives (for both synchronization (rendezvous) and avoidance (protected objects), integrated into both a strong typing system and an object-oriented approach. And there's a good compliler in the GNU compiler family.

      But programming language research seems to have been abandoned over the last 20 years, as if C++ and Java represented the final solution.

      C/C++ and even Java thread models are truly appalling, and they were known to be bug-ridden back in the 90s when they were being standardized. I remember during a POSIX meeting, the people working on the Ada binding detected a race condition anomoly in the C/Pthreads specification. Ted Baker sketched the problem out in terms of Ada tasks and we went back, looked at the C & text, and verified Ted's observation. We called in some representatives from the C/Pthreads group, and it took them about 30 minutes just to work out a 'language'/notation to reason about their own standard. After that 30 minute discussion, they came back and looked at our work, and said "Geez, you're right!".

      Another area where we need better tools are for the debugging of concurrent, parallel and distributed programs, preferrably starting with analytical tools that prevent, or at least detect before runtime, these kinds of problems. Debugging should be an embarrassment to an professional programmer, as it's basically a representation that you don't know what your code is actually doing.

      I'm no fan of "model-driven architecture" in general, but model-driven approaches, coupled with the right kind of source code analysis tools, have real promise here. (Look at how Microsoft, a company I rarely praise, has used this for checking out device drivers...)

                dave

  26. Three basic problems by bm_luethke · · Score: 2, Interesting

    There are three basic "problems" and to some extent I think they are unsolvable.

    First is debugging tools. People are used to having a nice neat step through debugger - press some key to execute the next statement. Because a large part of parallel processing does not conform to that process you have to add in your own debug code (even if using one of the parallel debuggers out there). I see no way around this one - you can not have a deterministic debugger on a non-deterministic system and I see no way for parallel systems to generally be deterministic in the sense of "press F8 to execute next line". This increases cost as you can not simply hire a cheap "code monkey" to do the job.

    Second is just general complexity, things like file locks, critical sections, race conditions, etc. Even if you deal with them every single day and have been doing it for the last 20 years these are still complex issue when something fails. I also see no way around this one, though there have been some really nice advances in recent times and there is still a long way to go before I think we have mostly maxed out the tools. Somebody has to deal with this and a good deal will eventually be shoved off to the tools, but when that happens figuring out where the error is will be a real bitch (ask anyone who eventually found an esoteric bug in a standard library how much work *that* took). While quite solvable, this also increases cost.

    Lastly you have Amdahl's law - basically you can not parallelize everything and performance degrades quickly the more serialization you have. I do not think that the real performance of SMP's or multi-core systems for the average user is going to come in single application performance - you just can not parallelize the typical applications that much. Where the performance comes in is allowing several things to go on at a time, basically that really large system tray many people run will be going across multiple processors or cores and not degrade performance that much. Though this really helps - I've ran two processor systems on my home systems for years and it is interesting how little processor power I need for games compared to the minimum specs even when I do not bother with paying attention to what is currently running.

    So, in short, not really too hard, it's a level of complexity that many have done well with in the past and will continue to do so, but that the problem space doesn't map well to parallelization. There is some level of "too hard" when you are asking if VB only people who think that HTML should be listed as a programming language and can not survive without Microsoft's wizard (note that using VB isn't the bad part - lots and lots of really good programmers use it at work because that is what will sale), but competent programmers/software engineers are quite capable of using it. I do not think that the benefits within most single applications are worth the cost, though as an overall system it will help quite a bit.

    --
    ------- Sorry about the spelling, I suffer from two problems. Dyslexia makes it difficult to spell well, lazy makes it
  27. We don't think in recursion either by TheMCP · · Score: 4, Interesting

    Most programmers have difficulty thinking about recursive processes as well, but there are still some who don't and we still have use for them. I should say "us", as I make many other programmers batty by using recursion frequently. Programmers tell me all the time that they find recursion difficult - difficult to write, difficult to trace, difficult to understand, difficult to debug. Conversely, I find it easier - all I have to do is reduce the problem to its simplest form and determine the end case, and a tiny snip of code will do where a huge mess of iterative code would otherwise have been required. So, I don't understand why anyone would want to write iterative code when recursion can solve the problem.

    I suspect that parallel programming may be similar - some programmers will "get it", others won't. Those who "get it" will find it fun and easy and be unable to understand why everyone else finds it hard.

    Also, most developement tools were created with a single processor system in mind: IDEs for parallel programming are a new-ish concept and there are few. As more are developed we'll learn about how the computer can best help the programmer to create code for a parallel system, and the whole process can become more efficient. Or maybe automated entirely; at least in some cases, if the code can be effectively profiled the computer may be able to determine how to parallelize it and the programmer may not have to worry about it. So, I think it's premature to argue about whether parallel programming is hard or not - it's different, but until we have taken the time to further develop the relevant tools, we won't know if it's really hard or not.

    And of course, for a lot of tasks it simply won't *matter* - anything with a live user sitting there, for example, only has to be fast enough that the person perceives it as being instantaneous. Any faster than that is essentially useless. So, for anything that has states requiring user input, there is a "fast enough" beyond which we need not bother optimizing unless we're just trying to speed up the system as a whole, and that sort of optimization is usually done at the compiler level. It is only for software requiring unusually large amounts of computation or for systems which have been abstracted to the point of being massively inefficient beneath the surface that the fastest possible computing speed is really required, and those are the sorts of systems to which specialist programmers could be applied.

    1. Re:We don't think in recursion either by gnalre · · Score: 2, Insightful

      Brought up programming C and Fortran I struggled for a long time with recursion. When I moved on to using functional languages(erlang to be specific) because recursion is integral(no loop construct) I eventually became quite comfortable with it.

      It goes to show to become a better programmer investigate as many programming paradigms as possible.

      --
      Choose your allies carefully, it is highly unlikely you will be held accountable for the actions of your enemies
  28. Not too hard at all by JustNiz · · Score: 3, Interesting

    Parallel programming is NOT too hard. Yes its harder than a single-threaded approach sometimes, but in my experience usually the problem maps more naturally into a multi-threaded paradigm.
    The real probelm is this: I've seen time and again that the real problem is that most companies do not require, recognise, or reward high technical skill, experience and ability instead they favour minimal cost and speed of product delivery times over quality.
    Also it seems most Human Resources staff/agents don't have the necessary skills to actually identify skilled Software Developers compared to useless Software Developers that have a few matching buzzwords on their resume, because they themselves don't understand enough to ask the right questions so resort to resume-keyword matching.
    The consequence is that the whole notion of Software Development being a skilled profession is being undermined and devalued. This is allowing a vast amount of people to be employed as Software Developers that don't have the natural ability and/or proper training to do the job.
    To those people, parallel programming IS hard. To anyone with some natural ability, the proper understanding of the issues (you get from say a BS Computer Science degree) and a naturally rigorus approach, no it really isn't.

  29. Re:A different approach to parallel programming by StarfishOne · · Score: 3, Insightful

    "Perhaps having a Chinese character represent a simple block of pre-compiled code that does one simple thing."

    Basically like a compiled function?

  30. Parallel Programming is EASY (APL, J, K langauges) by SimBuddha · · Score: 2, Insightful

    I've been programming using parallel techniques for more than 25 years using APL.
    I was so imnpressed with APL that I implemented an APL like derivative language
    called Simmunity which is a hybrid compiler for an APL like syntax. Simmunity
    can be targeted at a parallel processor implemented in FPGA's that provides
    multiple simultaneously executing vector/matrix operations in parallel...
    (stay tuned for more info)

    The quintessential parallel database programming language available is clearly
    KxSystems Q and KDB+
    See the faq at http://kx.com/faq/ and tutorial at http://kx.com/q/d/primer.htm

    Ken Iverson invented APL and then the J language which anyone interested in
    really discussing parallel programming should look at closely. The Connection
    Machine LISP had many of the APL operators/functions and certainly Map/Reduce
    that it added to provide a convienent parallel expression langauge

    Most programmers think in terms of sequential code execution with threads and
    processes. APL incourages the programmer to conceive of programming using
    vector and matrix operations to process strings and numbers and manipulate
    data like a spreadsheet. An application that people might be familiar with
    is Lotus Improv which provided naturally parallel expressions based on a subset
    of APL operations.

    Cheers, Simbuddha

  31. Patience is not a goal here. by tempest69 · · Score: 2, Insightful

    Oh noes! Software doesn't get churned out immediately upon the suggestion of parallel programming! Programmers might actually be debugging their own code! There's nothing new here: just somebody being impatient. Parallel code is getting written. It is not difficult, nor are the tools inadequate. What we have is non-programmers not understanding that it takes a while to write new code. If anything, that the world hasn't exploded with massive amounts of parallel code is a good thing: it means that proper engineering practice is being used to develop sound programs, and the jonny-come-lately programmers aren't able to fake their way into the marketplace with crappy code, like they did 10 years ago.
    1. Parallel code is being written, agreed, but it is specialty engines that are getting it. General purpose parallel code isnt out there.. we just have pet projects that include parallelism but for the most part are ported serial code

    2. Parallel code is a monster to write. I'm not talking simple scatter-gather data spreaders. Imaging Adobe photoshop running across a 400 machine cluster, handling hundreds of users at a time. The data concurency issues, data residence, locking, message handling, message reordering Total bloody nightmare...., If youve parallelized a markov model it doesn't really compare.

    3. The tools arent adequate. tracing a data race, or deadlock in a cluster is a beast. MPI and PVM are nice but are really narrow in the scope that they handle problems.

    4. It isnt just non-programmers.. Parallel is a whole different scale of complexity... Almost everything I see is a "parallelize the brute zones of a specialty engine once it works in serial"..... Its an important baby step and it really blows non-programmers for a loop. But we are a far sight from having an implicitly parallel version of MS-word.

    5. Parallel isnt new, dual cpu boxes have been in userspace since the late 90's, it has been mostly ignored by applications. The use of network resources is horribly behind the times. The ability to aggregate resources on the fly is a total joke compared to where it should be.

    Storm

  32. Re:A different approach to parallel programming by jlarocco · · Score: 4, Informative

    I've often wondered if parallel programming would be easier if it were done in Chinese characters instead of English/European alphabetical characters.

    Perhaps having a Chinese character represent a simple block of pre-compiled code that does one simple thing. Then the characters could be placed in two-dimensional order to form parallel threads. This would require a completely different approach to compiler development. But that would be OK because compilers are stuck in the 1970s anyway.

    Maybe I'm a "bit thick", but that doesn't make any sense to me. It's an interesting idea, but I just don't see how it'd help parrallelize things. At the very least, it seems to be solving the wrong problem.

    The biggest problem right now is that it's really hard to split most tasks into parts that can be performed at the same time. Once a parrallel algorithm is devised, it's relatively easy to write a program that performs the task in parrallel.

    Also, I don't know what you mean about compilers being stuck in the 70s. There have been massive improvements to compilers in the last 40 years.

    Just getting away from the idea of having code based on a very limited set of alphanumeric characters strung together like beads on a string might help unlock a whole new era of innovative approaches to parallel program development strategies.

    But programming doesn't work like that. Individual characters in a programming language are almost irrelevant.

  33. Re:Non-Repeatable Errors by GileadGreene · · Score: 3, Insightful

    How do we chase and choke out race conditions and deadlocks in testing?
    Using testing to iron out concurrency errors is a losing proposition. You're better off trying prevent race conditions and deadlocks getting into your design in the first place, and making the design robust to those errors that do slip through. A few ideas (by no means a complete solution):
    • Use interaction patterns which are known to be free of deadlock (Welch's IO-Seq and IO-Par patterns, client-server structures, E's event-loop concurrency).
    • Model your design in something like CSP or Promela, and then model-check it to detect and eliminate potential race conditions or deadlocks.
    • If it's too late to model the design, then use a model-checker like Java Pathfinder to actually model-check your code, or extract a model from your code and model-check it with SPIN.
    • Develop a design that is robust to the concurrency errors that slip through the modeling and analysis process - see Erlang's approach to supervised process networks for one example.
  34. "Dragged Kicking and Screaming" by netfunk · · Score: 4, Interesting

    Tom Leonard, a programmer from Valve, gave a fascinating talk about this at GDC this year, about retrofitting multicore support into Half-Life 2 (specifically, into the Source Engine, which powers Half-Life 2). Not surprisingly, this talk was named "Dragged Kicking and Screaming" ...

    There was a lot of really good wisdom in there, whether you are writing a game or something else that needs to get every possible performance boost.

    I'm sure they probably drew from 20+ years worth of whitepapers (and some newer ones about "lock-free" mutexes, see chapter 1.1 of "Game Programming Gems 6"), but what I walked away from the talk with was the question: "why the hell didn't _i_ think of that?"

    There were several techniques they used that, once you built a framework to support it, made parallelizing tasks dirt simple. A lot of it involves putting specific jobs onto queues and letting worker threads pick them up when they are idle, and being able to assign specific jobs to specific cores to protect your investment in CPU cache.

    Most of the rest of the work is building things that don't need a result immediately, and trying to build things that can be processed without having to compete for various pieces of state...sometimes easier said than done, sure. But after hearing his talk, I was of the opinion that while parallelism is always more complex than single-threaded code, doing this well is something most developers aren't even _thinking_ about yet. In most cases, we're not even at the point where we can talk about _languages_ and _tools_, since we aren't even using the ones we have well.

    --ryan.

    --
    Don't say, "don't quote me," because if no one quotes you, you probably haven't said a thing worth saying.
  35. No. No. No. by Duncan3 · · Score: 3, Interesting

    We've had a steady stream of multi-core guests here at Stanford lecturing on the horror and panic in the industry about multi-core, and how the world is ending. I've seen Intel guys practically shit themselves on stage, they are so terrified we can't find them a new killer multi-core app in time. That's BS. OK so it's a hour lecture, maybe two if you're not that fast. Parallel/SMP is not that hard, you just have to be careful and follow one rule, and it's not even a hard rule. There are even software tools to check you followed the rule!

    But that's not the problem...

    The problem is, a multi-year old desktop PC is still doing IM, email, web surfing, Excel, facebook/myspace, and even video playing fast enough a new one won't "feel" any faster once you load up all the software, not one bit. For everyone but the hardcore momma's basement dwelling gamers, the PC on your home/work desk is already fast enough. All the killer apps are now considered low-CPU, bandwidth is the problem.

    Now sure, I use 8-core systems at the lab, and sit on top of the 250k-node Folding@home so it sounds like I've lost my mind, but you know what, us super/distributed computing science geeks are still 0% of the computer market if you round. (and we'll always need every last TFLOP of computation on earth, and still need more)

    That's it. Simple. Sweet. And a REAL crisis - but only to the bottom line. The market has nowhere to go but lower wattage lower cost systems which means lower profits. Ouch.

    --
    - Adam L. Beberg - The Cosm Project - http://www.mithral.com/
    1. Re:No. No. No. by GigsVT · · Score: 3, Insightful

      Games have been driving PC performance lately. You shouldn't be opposed to such things.

      You can get a 4 core chip for under $600 now because of it. If you are into high performance computing then you should beg the game developers for something that can use as many cores as you can throw at it. Because as you said, you are 0% of the market, and gamers are a huge chunk of it.

      --
      I've had enough abrasive sigs. Kittens are cute and fuzzy.
  36. A simple starting point by 12357bd · · Score: 2, Interesting

    could be to add a especifically parallel iterator keyword to programming languages, ie:

    for-every a in list; do something(a); done;

    The compiler then assumes that something(a) can be safely executed in parallel for every element in the list.

    Is not rocket science, it could lead to parallel spagheti, but is a straightforward method to promote parallel programming.

    --
    What's in a sig?
    1. Re:A simple starting point by TeknoHog · · Score: 2, Interesting

      Something like this exists in many languages, for example Fortran with its built-in matrix math and the map() construct in Python. The problem is that people don't use these languages, and while they stick with something like C they are forced to reinvent the wheel with things like explicit threads.

      --
      Escher was the first MC and Giger invented the HR department.
  37. Re:A different approach to parallel programming by try_anything · · Score: 3, Interesting

    How would a string of Chinese characters like beads on a string be any better than a string of alphanumeric characters like beads on a string? Many (most?) Chinese words are written using multiple characters, so a language that had a special use for lone characters would end up looking a lot like Fortran 77 anyway. (What does the FSSCRD function do?)

    I think you're reasoning from some notion about the way "Oriental" people think differently from "Western" people. I tend to doubt that idea based on the kinds of people who have enthusiastically pushed it: originally imperialist racists of various groups, each bent on proving the superiority of their group, and more recently western PC racists who compulsively idealize everything non-Western. Despite the taint of racism, the idea may have some basis in fact as well -- there is ongoing research that occasionally manages to produce some evidence for it -- but the sad fact is that we have only been able to create programming languages that express a very tiny subset of the way "Western" people supposedly think anyway. The problem is not a lack of nonlinear, context-sensitive ways of thinking; the problem is that before we can use a given way of thinking to communicate with a computer, we must essentially enable the computer to think the same way. If you buy into the western PC version of the dualism, "Oriental = nonlinear, inclusive, sensitive, flexible, context-sensitive; Western = linear, exclusive, autistic, rigid, blinkered," then digital computers are quintessentially Western beings that cannot be made to appreciate Eastern ways of thinking, at least not without a few more decades of AI research and performance improvements.

    The Chinese government might very well be hard at work creating a quintessentially Chinese programming language, but it's a bad idea to pin your hopes on political science. It tends to suck. On top of that, many excellent programming languages have been doomed by much smaller barriers to entry than learning an entirely new system of writing. On top of that, your 2D array of characters is doomed by the multitudes of multicharacter words in Chinese. To add yet more on top of that, another poster just pointed out that the idea that it expresses has already been expressed in other languages using ASCII.

    I wouldn't have bothered piling on you like this if your post didn't strike me as racist. The commonly accepted story about the differences between Eastern and Western ways of thinking is propagated by uninformed repitition. Chinese, Americans, left-wingers, right-wingers, everybody has learned to love it and interpret it to flatter their side, so they all repeat it in unison. It pollutes the discourse. Wouldn't it be nice if everyone who didn't have firsthand experience just shut the hell up? Then we might hear something different from the standard story that gets passed around like a centuries-old fruitcake. Or we might hear the same thing, but then at least it would mean something.

  38. Nitpick by Ihlosi · · Score: 2, Insightful
    Over 10 years ago, I was using a "visual programming language" created by National Instruments called LabView.



    The language isn't called LabView, it's called "G". LabView is the whole package (G interpreter/compiler, drivers, libraries, etc).

    And, yeah, G is pretty cool. National Instruments offers a slightly dated, but otherwise completely functional version of LabView for free for noncommercial use.

  39. That's irrelevant. by Estanislao+Mart�nez · · Score: 5, Insightful

    Our cognitive system does many things at the same time, yes. That doesn't answer the question that's being posed here: whether explicit, conscious reasoning about parallel processing is hard for people.

    1. Re:That's irrelevant. by LionMage · · Score: 3, Interesting

      Much of the work of programming is taking an parallel process (i.e. pretty much anything you want a program to do) and translating it into the sequential model used by most programming languages.

      Well, that statement makes a gross assumption. Every software developer (programmer/engineer) thinks that their particular domain is representative of what computer programmers do in general. However, if you in fact write software that automates common business tasks, the software is directly analogous to the process it seeks to model and/or replace. Most business tasks are sequential, so procedural single-threaded programming is a perfectly fine model to use.

      Yes, for the things that most casual users and computer scientists think are "interesting," there is some inherent level of parallelism that can get pretty high. For a few choice types of tasks (ray tracing, rendering certain fractals), the problem itself is embarrassingly parallel because there is no direct coupling between the solutions of sub-problems. However, at some level you can't decompose your problem any further, and you can extract no more parallelism.

      The vast majority of computer software these days is written for businesses. Most of it is not the stuff you see on the shelf at the local computer store, but is written custom to solve a specific business need. Most business processes are inherently serial operations: you perform one step, then you perform another step that depends on the previous step. Occasionally, you get lucky and you discover multiple steps that can be done simultaneously. However, making such processes explicitly parallel might not be the most advantageous move; after all, most modern CPU architectures are adept at out-of-order execution, and can analyze instruction streams to figure out dependencies dynamically. Heck, most modern CPU architectures support multiple in-flight instructions, and allow multiple instructions to complete simultaneously, which extracts parallelism at a very low level.

      When I first learnt to program, I remember learning a little about function and then later discovering that they completed synchronously. I was surprised by this, because it just didn't seem to make any sense; a function has a deadline by which it needs to complete (when I use the result), but it can run in the background until then and join with the calling thread.

      You can still explicitly use this technique in modern programming languages; Java, for example, has Thread.join() which is used for precisely such situations. However, just because you can do something doesn't mean that you should; there is overhead associated with spawning threads of execution and synchronizing threads when some result is needed. If the computation being performed by a function call is long-lived, then it makes sense to spawn a thread to perform that computation -- assuming that there are sufficient computational resources to truly run that thread concurrently (e.g., another CPU core able to perform that computation). Otherwise, you're burning more computational resources and probably making your code actually slower in the process (due to management overhead). And if you're multitasking on a single CPU core, spawning another thread will almost certainly result in a slower-running program (because you still have all the overhead of managing another thread, but none of the benefit of true hardware-level concurrency).

      Most programming tasks are inherently parallel. I can't think of a single piece of code I've written recently that hasn't been a solution to a parallel problem.

      The first sentence is really an unsupported conjecture. The second sentence is an attempt to provide anecdotal evidence drawn from your own experiences to support the conjecture in the first. My own life experience is vastly different from yours, but then again, that too is anecdotal evidence; neither your nor my personal experiences are really "proof" o

  40. High performance multiprocessing by Cafe+Alpha · · Score: 2, Informative

    I've worked on a high performance multiprocessor system.

    There are a few principles and tools that make much of it manageable, and then there's some parts that are inherently nearly impossible.

    A few principles:

    1. Task switches are very very time consuming, at least under preemptive multitasking, and especially when that preemption (as it does in Windows) involves process switches. Since mutexes rely on task switches, they're very expensive, although exact implementation matters too.

    2. It's possible to come up with non-blocking algorithms that require no mutexes (though you do need low level access to interlocked instructions, or barriers). Unfortunately that's where it gets nearly impossible because proving that a non-blocking algorithm is correct requires a combinatorial analysis. I could go into the some of the principles of non-blocking algorithms, but they're still very hard even when you know what you're doing. Still it's useful to understand some basic interlocked instructions because people often use mutexes when a simple interlocked instruction would do the same task infinitely quicker.

    3. Having a few basic non-blocking queue algorithms (LIFO and FIFO) up your sleeve can suffice to allow rather separate tasks to communicate cheaply. There are even nonblocking queues that allow an unlimited number of processors to compete for each end of the queue simultaneously, and so you can have common banks of work to be balanced between processors, for instance.

    4. It's often a win to give very separate tasks to each processor, and have a single process per processor. Put all IO on one processor, for instance and have it communicate with the other processors through non-blocking queues.

    5. Even though fair preemptive multitasking is expensive (because of the task switches), in special cases you can use cooperative multitasking (fibers, green threading) and save the time. One advantage to cooperative multitasking is that you can control exactly when a fiber wakes up. In some benchmarks I've seen (producer-consumer), green threading outraces preemptive multitasking by over an order of magnitude.

    6. If you can all tie all interrupts to a single processor (which is possible in Windows) and lock specific processes to each processor, then you can (almost) guarantee that certain processors won't interrupted, and thus those processors are the ones that are cheapest to use for any task that the other processors will have to wait for.

    7. Aggregate. There are some tasks that can not be accomplished in parallel with the usual work. It's useful to save up a bunch of work like that so that you don't have to shut down the other tasks too often.

    8. State machines with atomic arcs. This gets closer to the harder sort of algorithms, but its useful to talk about what's easy. If you need a bunch of processors to cooperate, it's useful to have a state machine description of the global state. If the state can be stored in a single double word, then transitions between states can be accomplished atomically with a CAS instruction (compare and swap), and then it doesn't matter which processor changes the state. They may all try, and one will succeed. If one of the states is too complicated to fit in a double word, then you can either have a spin-lock intermediate state or in some cases, the state double word can include a pointer (but this gets complicated).

    9. Cache delays. Multiprocessor systems have to keep the caches coherent. Because of this situations like a CPU reading a value that's dirty in another processor's cache can bring all of the processors to a halt while they transfer data. I'm a few years out of date on what the newest processors do, but it's probably still true, and still true that these pauses are much longer on systems like the Sparc that allow hundreds of processors than it is in x86 machines that are more limited in the number of processors. In any case it's a win to keep data memory use separate between processors when possible.

  41. Actually it's just pipelined by Moraelin · · Score: 5, Insightful

    Actually, it's more like pipelined. The fact that your eyes already moved to the next letter, just says that the old one is still going through the pipeline. Yeah, there'll be some bayesian prediction and pre-fetching involved, but it's nowhere near consciously doing things in parallel.

    Try reading two different texts side by side, at the same time, and it won't work that neatly parallel any more.

    Heck, there were some recent articles about why most Powerpoint presentations are a disaster: in a nutshell, because your brain isn't that parallel, or doesn't have the bandwidth for it. If you try to read _and_ hear someone saying something (slightly) different at the same time, you just get overloaded and do neither well. The result is those time-wasting meetings where everyone goes fuzzy-brained and forgets everything as soon as the presentation flipped to the next chart.

    To get back to the pipeline idea, the brain seems to be quite the pipelined design. Starting from say, the eyes, you just don't have the bandwidth to consciously process the raw stream of pixels. There are several stages of buffering, filtering out the irrelevant bits (e.g., if you focus on the blonde in the car, you won't even notice the pink gorilla jumping up and down in the background), "tokenizing" it, matching and cross-referencing it, etc, and your conscious levels work on the pre-processed executive summary.

    We already know, for example, that the shortest term buffer can store about 8 seconds worth of raw data in transit. And that after about 8 seconds it will discard that data, whether it's been used or not. (Try closing your eyes while moving around a room, and for about 8 seconds you're still good. After that, you no longer know where you are and what the room looks like.)

    There's a lot of stuff done in parallel at each stage, yes, but the overall process is really just a serial pipeline.

    At any rate, yeah, your eyes may already be up to 8 seconds ahead of what your brain currently processes. It doesn't mean you're that much of a lean, mean, parallel-processing machine, it just means that some data is buffered in transit.

    Even time-slicing won't really work that well, because of that (potential) latency and the finite buffers. If you want to suddenly focus on another bit of the picture, or switch context to think of something else, you'll basically lose some data in the process. Your pipeline still has the old data in it, and it's going right to the bit bucket. That or both streams get thrashed because there's simply not enough processing power and bandwidth for both to go through the pipeline at the same time.

    Again, you only need to look at the fuzzy-brain effect of bad Powerpoint presentations to see just that in practice. Forced to try to process two streams at the same time (speech and text), people just make a hash of both.

    --
    A polar bear is a cartesian bear after a coordinate transform.
    1. Re:Actually it's just pipelined by Mattintosh · · Score: 3, Funny

      Again, you only need to look at the fuzzy-brain effect of bad Powerpoint presentations to see just that in practice. Forced to try to process two streams at the same time (speech and text), people just make a hash of both.

      There's way more to it than that. The brain is an efficient organizer and sorter. It also tends to be great at estimating the relative importance of things and discarding the lesser ones it can't deal with. Thus, 99.999999999% of the time, I ignore Powerpoint presentations. It goes in my eyes, the brain deciphers the signal, decides that the Powerpoint stuff is useless drivel, and it continues processing the audio (in parallel!) and terminates the visual processing thread. Shortly thereafter, the audio signal is also determined to be of minimal benefit and is discarded as useless drivel as well, leaving more processing time for other things. Things like pondering the answer to the age-old question, "What's for lunch?"

    2. Re:Actually it's just pipelined by tknd · · Score: 2, Interesting

      From what we know about the brain it takes advantage of many different techniques but I wouldn't necessarily agree that it is pipelined. Pipelining is a parallelization technique for making a serial set of operations execute faster through a processor by changing how the processor executes each instruction. When the brain processes information, it is basically a giant circuit that does all the processing for vision only, nothing else--break anything in the chain and the "vision" capability is either hindered or stopped.

      The brain has two separate pathways "vision" data takes: one path determines things like dimensional properties (as in how far away a cup is from you) while the other path determines identification (is what you're looking at a cup?). There have been documented cases where one pathway was lesioned and the patient could identify the object, but could not physically reach out and grab it while if the other pathway was broken the patient could physically catch a ball thrown at them and they could catch it, but they could not recognize what object was thrown at them until they used their other senses (like touch) to determine it.

      Each processing unit in the brain does some sort of processing on the data rather than contributing to make the final product. When you "see" an image, you are actual interpreting many different senses from your vision pathways. The only processing that might potentially be shared (as far as I know) is the processing done by the retina like edge detection. All of the other areas are very specialized at what they do and are only designed to do that one task. That's way different from pipelining where each unit is reused for different instructions giving the cpu its general purpose traits.

      I'd say multiple processors/cores is more how the brain operates but does not necessarily model how "we" think. What I mean by "we" is that each person has a pre-frontal cortex in their brain has that is where their personality and where their actual "thinking" as a person goes on. The rest of the brain is specialized to do other tasks. Some of those tasks are controlling emotions, labeling and highlighting memories, vision processing, motor skills, and so on. For example, when you first learned to write, you were probably intensely utilizing your prefrontal cortex to write letters. That's because the motor section of your brain specializing in hand-finger motions for writing the letter had not been trained yet. However, as time goes on, you no longer have to think in order to write the letter, in fact you could probably close your eyes and start writing--no prefrontal cortex processing is needed because the motor section now has it programmed in.

      So when you're thinking, you're really just utilizing your prefrontal cortex, but if the operation or task your performing is repetitive and can be memorized, at some point that task will be programmed into a specialized unit in your brain leading you to require less or no thinking at all. I'd say the brain itself is designed as a massively parallel unit with multiple areas that can be trained to perform specialized operations.

      Now, you may be thinking if each section of the brain can be trained to do something, can they be retrained to do other things? The answer is yes. There have also been cases where due to some reason, people lost a need to utilize one portion of their brain but started utilizing those portions to do other things. For example say a person lost their arms, well now their motor section for their arms is completely useless in their brain. But, because they must not be forced to use their feet and legs in ways they hadn't before, eventually the parts of the brain trained to do arm and hand motions will gradually be utilized to learn and control feet and leg movements. In fact, if you were to map out the amount of brain space used for each portion of the body, you would get a huge proportion devoted to things like hands and mouth where other portions of the body would utilize an insanely small portion of th

  42. Re:A different approach to parallel programming by MillionthMonkey · · Score: 2, Interesting

    Perhaps having a Chinese character represent a simple block of pre-compiled code that does one simple thing. Then the characters could be placed in two-dimensional order to form parallel threads. This would require a completely different approach to compiler development. But that would be OK because compilers are stuck in the 1970s anyway.

    I see neither a connection between the choice of character set and parallel programming, nor anything in your post that is beyond trivial to do in ASCII:

    - For vertical side-by-side alignment, check your editor prefs in your IDE). If it is important that the source code itself be laid out horizontally like drapes, two dimensional languages in ASCII have already been tried and you can look into what happened with those.
    - Typically many of these threads are running the same code, so a separate column for each thread is of dubious value.
    - Even single threaded code forks around way too much to be visually representable by a column of glyphs.
    - Why not just use English words? They exist in comparable numbers to Chinese characters.
    - Existing compilers already convert methods into compressed representations of code that are basically equivalent to anything you're suggesting.
    - What's this about the 1970s? Compilers have a lot of optimizations now including the ability to recognize code written by dumb or lazy coders. If you're complaining about language design that's not the fault of the compiler which is just doing its job for a given language.

    Just getting away from the idea of having code based on a very limited set of alphanumeric characters strung together like beads on a string might help unlock a whole new era of innovative approaches to parallel program development strategies.

    It reminds me of the time I was on here arguing with a guy who said files would be easier to compress if they were converted to Chinese characters first, because then the file would be shorter. Exploding the set of characters, and having individual characters represent chunks of pre-compiled code as you're suggesting, would basically be like having thousands of reserved words and global functions. It sounds like hell the more I think about it. The actual character encoding system with left-right top-bottom semantics doesn't really get in the way of anything at a fundamental level.

    It does go without saying that Chinese programmers would have an incredible advantage in any new system of programming that is based on Chinese characters.

    Aha- here we see the motive behind the evil subversive plan for global compilation dominance...

    It may be possible that this subject is already a project under development in China.

    Maybe someone is working on such a thing- who knows? Why even bother? There are more English speakers in China than in the U.S. And you don't have to know much of a natural language to just code in a programming language that draws on it for its symbols. It's not like asking for a taxi or interviewing for a job in that natural language. Ruby was invented in Japan and is ASCII based, and the Chinese have an easy time picking it up because they're already used to ASCII languages and there are no Hiragana characters in Ruby itself AFAIK, not even in variable names.

  43. Lack of skill in the field by node159 · · Score: 5, Informative

    I've seen it over and over in the industry, there is a distinct lack of parallel programming skill and knowledge, and even senior developers with years under their belt struggle with the fundamentals.

    Parallel programming does add a layer of complexity and its inherent lack of general solutions does make abstracting its complexity away difficult, but I suspect that the biggest issue is the lack of training of the work force. It isn't something you can pick up easily without a steep learning curve with many hard lessons in it, definitely not something that can be incorporated as a new thing to be learnt on the fly with deadlines looming.
    Another aspect is that its fundamental to the design, parallelism can and often will dictate the design and if the software architects are not actively designing for it or are not experienced enough to ensure that it remains a viable future option, future attempts to parallelise can be difficult at best.

    Ultimately the key issues are:
    * Lack of skill and training in the work force (including the understanding that there are no general solutions)
    * Lack of mature development tool to easy the development process (debugging tools especially)

    --
    GPLv2: I want my rights, I want my phone call! DRM: What use is a phone call, if you are unable to speak?
    1. Re:Lack of skill in the field by CodeBuster · · Score: 2, Interesting

      Lack of skill and training in the work force (including the understanding that there are no general solutions)

      You may be shocked then to discover that a substantial percentage of the lecturers and professors in computer science programs at American (and probably foreign as well) universities have little or no *practical* experience in programming large multithreaded applications as well (they know what it is of course and they wave their hands while describing it but the programming details are often left as an exercise for the student to figure out on his own). Is it any wonder that their students, while familiar with the concept, also lack that experience or even practical training? The exceptions are professors whose area of interest or research involves operating systems, real time systems, or linear programming whereas many other disciplines in computer science, being more theoretical in nature, do not rely on practical mulithreaded programming abilities to advance the state of the art (or if it does occasionally come up then there are always a couple of grad students around who can do that grunt work for you in exchange for saying nice things about their research assistance on their PhD evaluations).

      Lack of mature development tool to easy the development process (debugging tools especially)

      Modern professional IDEs, such as Visual Studio, have really improved in this area (especially in the last five (5) years with the introduction of the .NET Framework) although the demand (the explicit demand anyway), relative to the many other types of development project that occur in the business world, remains relatively speaking quite low. If a particular programmer is able and willing and if the project allows for this type of solution then he may choose a multithreaded approach to solve the problem and if he succeeds then the management never knows that the application is multithreaded (most of them do not understand the concept in any more detail than some vague notion of multitasking anyway). It is rare for multithreaded to be an explicit project requirement, especially in the more common types of business applications. Of course, if the project fails and it is found that multithreading is involved then the progammer might take some heat, so why improve efficiency at the cost of project failure when you can do something that you know will work even if it doesn't hit the theoretical maximum efficiency? That last 10% of performance is frequently too expensive for all but the most critical applications (i.e. those that specify it as a project requirement).

      The *real* question is this, if you need someone with a high level of skill in parallel programming are you willing to pay a substantial premium for that person over a more average programmer or do you just expect every programmer who works professionally to have those skills? In the same way that not every lawyer is a constitutional scholar, not every programmer is a multithreading, operating system kernel hacking, real time Jedi programming master. If you want (and need) master Yoda, then you have to be willing to pay him what he is worth.

  44. It is hard, but doable by WH44 · · Score: 2, Insightful
    I've done a lot of multithreaded programming over the past 20 years, slowly progressing from a rare occurrence to pretty much my daily diet. I work in a shop with 6 full time programmers, plus several externals. At first I was the only one who could do any multithreaded programming, having learned the principles in college some 25 years ago (*ouch* I'm old!). Now others are producing reasonable multithreaded code, but I'm still the one they run to when there's a problem.

    Looking at the proposals for switching languages, they just shift the problem around (as another poster has already mentioned). The only thing new that might be useful is the idea of "Guards" from Haskell (for why, see below). But you don't need a new programming language to implement that, with a little imagination you can build it into a C++ library.

    In my experience, 99% of the problems are due to two problems: overlooked shared resources and deadlocks. An example of the first problem might be when two threads are pushing/popping from the same queue, causing duplicates or skips. An example of the second would be thread A has resource X and is waiting for resource Y, while thread B has resource Y and is waiting for resource X. Guards could possibly make it easier to avoid some forms of deadlock by making it easier to acquire multiple resources simultaneously with less risk of deadlock. I think I have a new library to go code now... ;-)

  45. A better approach to parallel programming by MOBE2001 · · Score: 2, Insightful

    The problem with programming is that we are forced to use programming languages. Parallel programming is what programming should have been in the first place. We find it difficult because the tools are inherently sequential. Why? Because they are based on languages (usually English) and languages are inherently sequential. Just the fact that most programmers have to learn a computer language based on English (why not Chinese or French?) should be a clue that the linguistic approach is fundamentally flawed. The way a program works has nothing to do with what language you understand.

    What is needed is a new software paradigm that uses parallelism to start with. It should be a system based on elementary communicating objects. And the best way to depict parallel objects and signal pathways is to do it graphically. I say that the entrire computer industry have been doing it wrong from the beginning (since Lady Ada Lovelace). It is time to move away from the algorithmic model and adopt a non-algorithmic, synchronous software model. Even our processors should be redesigned for the new model. Only then will find that parallel programming is not onl y easy but the only way to do it.

  46. Object Oriented Programming is part of the problem by the+agent+man · · Score: 2, Interesting

    because it can make you jump to conclusions regarding how to conceptualize computation. You can end up all too easily with objects and interactions between these objects that are hard to parallelize. With Antiobjects we try to move from the computational foreground into the background. This way one can implement, for instance, game AI, by mapping computation onto dozens, hundreds or thousands of CPU/cores with very little overhead.

  47. Re:I blame the tools by TheRaven64 · · Score: 2, Interesting
    Take a look in the Étoilé SVN. I've contributed code that does exactly this with Objective-C objects (the EtoileThread module). It's still a work-in-progress, but it works in a lot of cases. You create an object in its own thread. Every message you send to it[1] is added to a queue, and a proxy object is returned immediately. When you send a message to the proxy object, it blocks until the first call completes.

    I remember when I was around 10 discovering that this wasn't how procedure calls worked in normal languages, and being disappointed. While I was playing with the Objective-C runtime, I realised there was no reason this had to be the case, and added it. It works on both Apple and GNU runtimes.

    Of course, if you use a language like Erlang, then you get this kind of semantic natively, and it's trivial to write hugely-parallel code.


    [1] That's 'method you call' for people more familiar with cargo-cult OO languages.

    --
    I am TheRaven on Soylent News
  48. Re:I blame the tools by ensignyu · · Score: 3, Informative

    FYI, that programming model is called futures.

  49. Threads can simplify by DusterBar · · Score: 2, Interesting

    Threads (multiple threads) can actually simplify the software rather than making it more complex. Or, rather, simplify writing the software.

    Ok, so maybe I am an old hand at multi-threaded programming (over 20 years of doing this stuff) but it just makes sense for so many things. Past examples that the general public may have seen are things I wrote on the Amiga, machines with interrupts, Apache, etc. (Imaging writing a high-volume web server without multiple threads!)

    There was a Hockey game on the Amiga that had each player on the ice having its own thread and own IA behavior. The code became so much easier than the traditional multiple interlocking state machines that such simulation games had to run that in order to port it to the PC they ended up writing their own multi-threading environment that ran on top of DOS.

    Personally, I think that too many people are scared away from multi-threaded programming because of the "horror stories" and a few "old guard" that don't feel comfortable in such an environment. For me, many problems are so much easier in the multi-threaded solution space that I rarely think of non-multi-threading. (Well, co-routines are sometimes required when the platform does not support true multi-threading)

  50. Re:I blame the tools by autocracy · · Score: 2, Insightful

    Look up Semaphores?

    --
    SIG: HUP
  51. Programming is hard by ebunga · · Score: 2, Insightful

    Most "programmers" seem to have a difficult time churning out normal, non-parallel code that runs, much less code that is bug free. Do you seriously think your average code monkey reusing snippets from the language-of-the-week cookbook is going to be able to wrap his head around something that actually requires a little thought?

  52. Re:I blame the tools by DaChesserCat · · Score: 5, Interesting

    I was using a potential answer to this in 1990. I was working for a small company in the Provo/Orem area, called Computer System Architects, which was selling Transputer hardware. For those who haven't heard of Transputers, they were small, 16- or 32-bit processors, with a small amount of built-in RAM (not a cache; this was actually in the memory map and you could do small tasks on a Transputer without any external RAM), 2-4 high-speed serial channels (easily implemented with 4 wires) and a stack-based architecture. Adding megabytes of external RAM was easy, and it was embarrassingly easy to connect up networks of these things, even on one board (in a single ISA slot), and build cluster. An external card cage, in those days, could hold 20 slots, which would hold up to 80 Transputers, using our products.

    I did some Assembly and some C, but the kicker language for this chip was called Occam II. Among other things, it used the indentation in the code to determine block structure. A quick example:

    PAR
        step A
        step B
        step C
        SEQ
            step D
            step E

    In this example, steps A, B and C would all be executed in parallel with another task which ran step D then step E. If you had one Transputer in your machine, it would multi-task. If you had multiple CPU's available, it would spread the task across the CPU's.

    It also has a basic construct called a Channel. These were very easy to set up and use. These were how the different tasks communicated with each other.

    It was not difficult to spawn thousands of tasks, each one doing a relatively small part of an overall task, with full communication and synchronization. Again, if you had multiple CPU's available, it would spread the tasks across them. A board with multiple Transputers was usually doing ray-tracing or rendering Mandelbrot fractals as a demo anytime we went to a trade or tech show. They could knock it down to one processor, and things got done relatively quickly. Then, they'd kick in 4 or 16 CPU's and blow people's minds.

    This was in 1990. A 386DX-33 was high-end, back then. The Transputer didn't run DOS or Windows, so it didn't survive in the market of the time. That was a shame; I benchmarked a variety of them, then ran identical benchmarks on various other machines as technology marched on. A T805 running 30 MHz (the top end Transputer I ever got to play with) blasted through mixed integer/floating-point calculations about as fast a 486DX2-66 (which didn't come on the market for another couple years). There was an occasion where I had 16 of those T805's sitting my machine. You'd need a Pentium II to be able to match that occasion. It was well over a decade later that the P-II became available.

    Cool tech, but the programming tools were what allowed you to really use the parallelization. It was typical to achieve over 95% linear speedup (i.e. 20 CPU's gave real-world 19x performance); sometimes we went over 99%. Most Intel SMP machines are lucky if they give 80% linear speedup (4 CPU's = 3.2x total performance).

    --
    ... by the Dew of Mountains the thoughts acquire speed, the hands acquire shakes, the shakes become a warning
  53. Multics by Mybrid · · Score: 3, Informative
    Multics was the precursor to Unix. Multics was a massively parallel operating system. It was designed to be an OS for a public utility. The thinking back then was all Americans would have computer terminals like a vt100 and plug into a municipal computer over a network.

    Multics was designed for long lived processes. Short lived processes are something we take for granted today but wasn't assumed back then. Today we assume that the sequence is we open a program, perform a task, close the program. Microsoft Outlook, for example, relies on Outlook being closed for its queue when to purge email that's been deleted. Programs are not designed to be up years-on-end. In fact, Microsoft reboots their OS every month with Windows Update. I've often speculated that the reboot is often requested not because the patch requires it but because Microsoft knows that its OS needs rebooted, often.

    Why? Why wouldn't one just leave every application you've ever opened, opened?

    The reason is that programmers cannot reliably write long running process code. Programs crashed all the time in Multics. Something Multics wasn't very good at handling back in the 1960s. There was some research done and it was observed that programmers could write code for short lived processes fairly well but not long lived.

    So, one lessoned learn from from the failure Multics is that programmers do not write reliable, long running code.

    Parallel processing is a processing better suited to long running processes. Since humans are not good at writing long running processes it makes sense then that parallel processing is rare. The innovation to deal with this sticky dilemma was the client-server model. Only the server needs to be up for long periods of time. The clients can and should perform short lived tasks and only the server needs to be reliably programmed to run 24/7. Consequently you see servers have clusters, RAID storage, SAN storage and other parallel engineering and clients do not. In some sense, Windows is the terminal they were thinking of back in the Multics days. The twist is that given humans are not very good at writing long running processes then the client OS, Windows, is designed around short lived processes. Open, perform task, close. I leave Firefox open for more than a couple of days and it is using 300MB of memory and slowing my machine down. I close and reopen Firefox daily.

    Threads didn't exist in the computing word until Virtual Memory with it's program isolation came to be. What happened before threads? What happened before threads is that programmers were in a shared, non-isolated environment. Where Multics gave isolation to every program, Unix just recognizes two users: root and everyone else. Before Virtual Memory, this meant that all user programs could easily step on each other and programs could bring each down. Which happened a lot.

    Virtual Memory is one of the greatest computing advances because it specifically deals with a short coming in human nature. Humans are not very good at programming memory directly, i.e. pointers.

    It wasn't very long after VM came out that threads were invented to allow intra-application memory sharing. Here's the irony though. There still as no advancement in getting humans to perform reliable programming. Humans today are still not very good at programming memory directly, even with monitors, semaphores and other OS helpers.

    When I was in my graduate OS class the question was raised then of "when do you invoke a thread?" given you probably shouldn't to avoid instability.

    The answer was to think about threads then as "light weight processes". The teaching was that given this a thread was appropriate for:

    1. IO blocked requests.

      Have one thread per IO device like keyboard, mouse, monitor, etc. There should be one thread dedicated to CPU only and the CPU thread controls all the IO threads. The IO threads should be given the simple task of servicing requests on behalf of the CPU thread.

    2. Performance

      Onl

  54. System of Systems by Zarf · · Score: 2, Interesting

    System of Systems is a philosophy that should look a helluva lot like the Unix Philosophy because... it is the same philosophy... and people do write code for these environments. If you want Parallel Programming to succeed make it work as systems of systems interacting to create a complex whole. Create environments where independent "objects" or code units can interact with each other asynchronously.

    Otherwise, as discussed in TFA there are certain problems that just don't parallelize. However, there are whole classes of algorithms that aren't developed in modern Computer Science because such stuff is too radical a departure from classical mathematics. Consider HTA as a computing model. It is just too far away from traditional programming.

    Parallel programing is just alien to traditional procedural declarative programming models. One solution is to abandon traditional programming languages and/or models as inadequate to represent more complex parallel problems. Another is to isolate procedural code to message each other asynchronously. Another is to create a system of systems... or combinations of both.

    If there is a limitation it is in the declarative sequential paradigm and that limitation is partially addressed by all the latest work in asynchronous 'net technologies. These distributed paradigms still haven't filtered through the whole industry.

    --
    [signature]
  55. Apply a limited threading paradigm to processes by NNland · · Score: 2, Interesting

    Having written MPI and Linda work-alike libraries, developed parallel and distributed systems, and being a heavy user of threads and remote procedure calls (via xml-rpc), I will say that the general issue that all of these different systems try to handle is one of API. How does one have data X handled by function Y in thread/process Z. In the realm of threading, we use queues with locks. MPI/PVM/Linda/XML-RPC all use sockets to pass data between processes, and all but Linda requires that you specify the destination process explicitly.

    One interesting recent development is the processing package for Python: http://www.python.org/pypi/processing/ . The idea is that you create processes like you would threads, then use shared queues, key-value mappings, etc., to pass data between the processes like you would threads. By sticking with generalizations that are seen to be 'easy' to understand and use (primarily queues), they bypass the majority of the difficulty people have when using threads and processes. Of course it doesn't hurt that the data transfer is pretty fast.

    The only limiting factors with the particular implementation is that it relies on fork in *nix, and the transfer of code as data in Windows (which isn't generally possible for all languages, especially with the NX processor extension). If Windows had a usable fork, and if there was a 'fork across machines' (think mosix), many of these discussions would result in "just program it like you had a thread and use shared queues and the processing package for your language".

  56. Time-to-market issue by anars · · Score: 2, Informative

    Pardon me if this point has already been made.

    What's the most important thing in high-performance computing nowadays; is it super-optimized low-level parallel programming or is it just plain parallel programming? I'm talking about any high-level framework which allows for easy multi-threading in applications which need it. A framework that will not only heighten developer productivity, but also utilize the additional cores in a computer system with a minimal effort. Wouldn't that be better than not doing it at all? The C-omega language http://research.microsoft.com/Comega/ by Microsoft Research Labs does exactly this.

    I have to agree, though, that the problem here is us - the programmers. The implementation of the language can only as smart as it is, and potential side-effects in terms of data dependencies etc. will definately occour. I'm not aware of any languages which implement a degree of Data Flow Analysis http://en.wikipedia.org/wiki/Data_flow_analysis, which allows the compiler to alert of such "stupidities" propagated by us--or perhaps even optimize them for the better.

    As several of you pointed out, matrix calculations can easily be distributed onto n number of cores, computers, or whatnot without any problems. I can't mention any real-life application where fast matrix calculations could save lives, but hey..