John Gross is chief engineer and Jeremy Orme chief architect at Connective Logic Systems. They can be contacted at firstname.lastname@example.org and email@example.com, respectively.
This multi-part article introduces Blueprint, a technology developed Connective Logic Systems (where we work) that provides an alternative approach to multi-core development. The Blueprint toolset is built on the premise that we actually have no problem understanding complex concurrency -- until we project it into the one-dimensional world of text. For this reason, a visual representation is much easier to work with than its textual equivalent. There are some cases where text is obviously more intuitive -- such as parallelizing data-parallel loops. In these cases, technologies such as Microsoft's Task Parallel Library (TPL) and Intel's Threaded Building Blocks, can be intuitive and productive. In this installment, we consider an "infrastructural" class equivalent that rectifies the problems just decribed by transparently distributing its processing load across the available hardware and communicating asynchronously with adjacent infrastructural classes through strongly prototyped connections. Blueprint requires Visual Studio 2005 Standard Edition (or greater), Visual Studio 2005 Service Pack 1, Visual Studio 2005 Service Pack 1 for Vista (if using Windows Vista), and/or Microsoft .NET Framework 2.0 (or greater), and is available in beta for download here.
Conceptually at least, standard object-oriented models let objects invoke adjacent objects by sending messages to their member functions; and so at its highest level of abstraction OO has an inherently concurrent view of the world that is divorced from its eventual mapping to processes and hence CPU cores. Unfortunately the potential parallelism of OO's model is difficult to realize from this high level view alone because there is insufficient information to precisely describe the communication and synchronization which is required to ensure correct scheduling. Applications that do assume particular memory models (distributed or shared), network topologies, core counts, operating systems, and other such details will almost inevitably be tied to them and so all of these issues have to be abstracted out.
Freedom from the Platform
Traditionally, OO has thrived where it has been possible to assume a single core, single machine environment. In such environments, synchronous function calling can replace the asynchronous invocation idealized in the original OO model and the stack takes care of data lifetimes:
However, the advent of multi-core has led programmers to demand OO to work in an environment where synchronous invocation is no longer viable because it would stall threads and waste time and/or resources.
Blueprint was designed to let developers work at the highest levels of OO abstraction and be able to make optimal use of multi-core hardware without needing to consider low level details like threading, message-passing and arbitration (semaphores and locks).
To achieve this, it has to enable developers to describe synchronization and communication at a very high level of abstraction using a visual metaphor. The "heavy lifting" required to implement the lower level synchronization is performed by the diagram translator which can generate C++ and/or C# as required.
This means that the notion of a "class" needs to be extended to include the additional information required by the translator. Blueprint's concurrent equivalents of classes are referred to as "circuits".
What Is A Circuit?
Most developers will be familiar with the concept of a "class" in an OO sense, and the intention of Blueprint circuitry is to provide a concurrent (infrastructural) equivalent. Their purpose is therefore to localize, encapsulate, archive and re-use program logic (algorithmic and infrastructural).
A C++ class consists of a declaration where its members are specified and a definition where the code within those class members resides. Similarly, a circuit has a prototype that describes its public interface and it has a definition that contains the executable concurrent code.
Circuits may contain any of the following items:
- Blueprint's intrinsic primitives
- Instantiations of other circuit definitions
- References to other circuit definitions.
The primitive symbols provide the fundamental language for defining the concurrent behavior of the circuitry. Instantiations and references allow encapsulated circuitry to be re-used by creating a new instance of the circuitry or connecting to an instance that was created elsewhere.
When a new instance of a class is created, it is allocated memory for its data members. This means that any number of classes can be instantiated and they all work on their own area of memory. Similarly, circuits have a concept of definitive state so there is no limit to the number of named circuit instances that can be created.
Circuit instances can be joined together in any way, provided that the prototypes at each end are compatible. This means that the complex array output of an FFT for example, can be directly connected to the input of a complex array filter, an RSS feed adaptor component could be connected to any number of business processes, and so on.
Classes are used for both modeling data (e.g., data collected from a sensor) and for defining active behavioral components (e.g., a sonar beam-former). Circuits can be freely interchanged with the classes but data classes are typically left as classes and exchanged between circuits that implement the active behavior. Due to this interchangeability, migration from legacy application classes to their circuit-equivalents can be performed incrementally. Conventional classes can invoke circuits; and vice-versa.
Design Recent Articles
This month's Dr. Dobb's Journal
, and much more!
Download the latest issue today. >>
- Plan and Deploy a Most Cost-Effective 4G Infrastructure - 4G World
- Join the Conference for 4G/LTE Professionals at CTIA - 4G World
- Come to Interop New York, Sept 29 - Oct 3, 2014 - Interop New York
- Learn to Maximize Your Next-Gen Network Investments - 4G World
- Tower & Small Cell Summit - Tower & Small Cell Summit
Most Recent Premium Content
- May - Testing
- February - Languages
- Open Source
- Windows and .NET programming
- The Design of Messaging Middleware and 10 Tips from Tech Writers
- Parallel Array Operations in Java 8 and Android on x86: Java Native Interface and the Android Native Development Kit
- January - Mobile Development
- February - Parallel Programming
- March - Windows Programming
- April - Programming Languages
- May - Web Development
- June - Database Development
- July - Testing
- August - Debugging and Defect Management
- September - Version Control
- October - DevOps
- November- Really Big Data
- December - Design
- January - C & C++
- February - Parallel Programming
- March - Microsoft Technologies
- April - Mobile Development
- May - Database Programming
- June - Web Development
- July - Security
- August - ALM & Development Tools
- September - Cloud & Web Development
- October - JVM Languages
- November - Testing
- December - DevOps
Dr. Dobb's Journal
Dr. Dobb's Tech Digest