Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼


Multi-Core OO: Part 3

John Gross is chief engineer and Jeremy Orme chief architect at Connective Logic Systems. They can be contacted at [email protected] and [email protected], 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.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.