ActionScript 3.0 and Parallel Programming: Get Ready for Decomposition

Decomposing a solution for multicore processing
I’ve been looking at a lot of materials on parallel programming attempting to sort out the issues involved. One of the big issues is granularity, and not only does granularity affect the way we think about design patterns, it also impacts algorithms. To make matters even more interesting, granularity is affected by the number of cores your computer has, and so not only is it important to consider the level of granularity for a general level of programming efficiency, it’s also important to consider the hardware.
I don’t want to re-visit the issue of first learning OOP and Design Patterns to get away from concerns of tweaking algorithms and extracting the last electron of speed, but let’s face it, not only are we tossed back into the algorithm business, but we’re programming down to the metal. So even if Adobe came along tomorrow and told us, ActionScript 3.0 is now totally hooked into multicore access, it’d be a while before we could spool up to the point where we could be anywhere near as efficient as we are now with single core programming. In some respects, Adobe has saved our bacon because while it’s getting ready to provide parallel programming for ActionScript, we have time to learn how to think about using multiple cores.
The Free Ride is Over
Sometimes a phrase is uttered and at some level I understand it, but I really don’t appreciate it.
Last year in a video on parallel programming, Ralph Johnson said, ‘The free ride is over’ and now I get it.
Learning OOP and design patterns has come close to guaranteeing that once you mastered them, your programs would become increasingly more effective (in getting them done and revised), more available to re-use, and for participation in team projects. They would also become more efficient over time because Moore’s law was hard at work doubling processor capability every two years or so. Using OOP and design patterns helped us effectively organize our code into neat programs and we didn’t have to think too much about algorithms and certainly not our processor. Programming had become wholly divorced from the hardware—along with the OS and brand and clock-speeds. Those things took care of themselves. That was the “free ride”—no changes in our programming behavior.
Now, we have to think about things like the number of cores in our stupid processors. Let’s hope we don’t have to worry too much about OOP and design patterns—if they stay relatively stable, we can now begin to focus on these multiple cores. The free ride is indeed over.
Granularity
The last time I thought about granularity, I was thinking about the number of child classes in a design pattern. That’s not what granularity is in parallel programming.
In parallel computing, granularity is a qualitative measure of the ratio of computation to communication. Blaise Barney, Lawrence Livermore National Laboratory
Fortunately, we’ve been using OOP, and so are clear on the concept of communication between objects. (If you’re still doing sequential programming, bump up to OOP, quick!) What the conversation is about the time that your processor(s) is working through an algorithm or data processing and the amount of time it’s communicating to the other objects about the computations. The polar types are:
- Coarse: relatively large amounts of computational work are done between communication events
- Fine: relatively small amounts of computational work are done between communication events
We need to begin this conversation. How coarse or fine should a program be? What criteria do we use? Is there a handy formula? Just leave OOP and design patterns alone for the time being. Treat them as immutable but essential; later on we can start tweaking them for parallel programming.
Domain Decomposition
Since we don’t have to think about what actually happens to our program—it’ll be handled by the OS and we cannot direct threads to cores anyway. We can pretend to do so, and that’s all that counts right now. In the next post on parallel programming (and on subsequent ones) I’d like to write some programs in ActionScript 3.0 that illustrate domain decomposition as a first step. This will involve taking a process and breaking it down into smaller parts and processing each one separately, and then joining the results. Not only will this be an example of targeting multiple cores, but it is a very clear illustration of what computational and communication processes look like. In the meantime, think about the new kind of thinking required to optimize a program where using more than a single processor is the only way to improve performance—the end of the free ride.
Related posts:

Bill Sanders
Is this discussion not similar to the SOA discussions but on a smaller scale? Certainly the trade offs with levels of granularity is identical, and the considerations between the two will be the same also.
We are pretty much at this point replicating what HW engineers have spent years on perfecting in chips. That is the example we should be following!
Hi Gregor,
You’re right about the HW/SOA discussions, and I have borrowed from them. (I believe the division into domain, tasks and pipelining are HW discussions.)
However, I’m keeping open to a lot of new discussions about DP and PP. In particular, I’ve been interested to see what’s going on over at the .NET shop, and I’m very interested in seeing the tact that Adobe is moving.
We’re in very exciting times, but I’m not about to either re-invent the wheel or ignore some new ideas emerging in parallel programming.
Kindest regards,
Bill
Interesting subject; looking forward to your follow-ups (and as3 divinity on multiple cores!)
Hi Parker,
AS3 divinity is right! (How about crossing my fingers and hoping that Adobe engineers are as focused as I hope they are on parallel programming.)
There’s so much going on right now as parallel programming concepts filter down to us lumpenproletariat who labor in both the mines of single core access and delusions of multicore pipe dreams.
Cheers,
Bill
I agree that parallel programming support for AS3 is the future! In college I did one subject on parallel programing paradigms, concepts and patterns. The essential theory is definitely out there, for quite some time actually. Now is time for us, AS3 programmers, to study it and implement it.
Here some links I found while looking at the subject:
C/C++: http://openmp.org/wp/about-openmp/
Java (port of openmp): http://www2.epcc.ed.ac.uk/computing/research_activities/jomp/index_1.html
Java (grid): http://www.jppf.org/
MPI (messaging): http://en.wikipedia.org/wiki/Message_Passing_Interface
Cheers!
Hi Bill,
Thanks for the comments and the links. I traced parallel programming and concurrency all the way back to 1967; so indeed it’s nothing new. For the sake of discussion, I think that we can set the starting point for a real need of parallel programming to about 2005 (it’s convenient) when multicore processors were becoming a standard.
I think that the real challenge is going to be on the macro level. The HW folks that Gregor mentioned are more closely wedded to micro solutions—namely how to accommodate the growing number of cores and write programs that fully employ each one. While that’s important, higher level concepts like OOP and DP need to be integrated ASAP. Otherwise, we end up back at square one with assembly language solutions.
I’ve been trying to move ahead with the new book by Colin Campbell, Ralph Johnson, Ade Miller and Stephen Toub (The Quad Core–4C)?, Parallel Programming with Microsoft .NET: Design Patterns for Decomposition and Coordination on Multicore Architectures. It is a Microsoft set of solutions tied to a number of MS technologies (e.g., PLINQ), but the design patterns are aimed at decomposition. It looks like the technologies that the programmers can touch are dependent on what MS has done with .NET, and as far as accomplishing real work, that’s a good thing. What concerns me is that when you’re dealing with such technologies, the concepts get bent by them and don’t exactly apply in a more general context of programming. With higher level constructs like design patterns, though, I believe that you can integrate more general concepts independent of a language or its implementations. We’ll see.
Kindest regards,
Bill