December 2012

Shevlin Park: A C++ AMP Implementation in Clang/LLVM Using OpenCL -- Dillon Sharlet

At the November 2012 LLVM Developers' Meeting, Dillon Sharlet of Intel gave a presentation on Shevlin Park, a prototype implementation of C++ AMP in Clang/LLVM using OpenCL. In this talk Dillon briefly discusses C++ AMP in comparison to OpenCL, details the implementation and shows the results of performance analysis on the prototype implementation.

Shevlin Park: A C++ AMP implementation in Clang/LLVM using OpenCL (MP4 video) (PDF slides)

Dillon Sharlet - Intel

We describe “Shevlin Park,” a prototype implementation of Microsoft’s C++ AMP built on Clang, LLVM, and OpenCL.

We fully describe Shevlin Park’s implementation including how Clang/LLVM can be augmented to easily accommodate C++ AMP programming constructs, how C++ AMP computation can be expressed as OpenCL compute kernels, and finally how the C++ AMP runtime library can be easily implemented on an OpenCL runtime.

Using several benchmarks, we evaluate Shevlin Park’s performance, Microsoft’s DirectX based C++ AMP, and also conventional OpenCL.

Another Alternative to Lambda Move Capture -- John Bandela

[Ed.: John Bandela correctly points out some hazards of one approach to capture-by-move in C++11 lambdas. In this blog post, he offers his own safer solution.]

Another Alternative to Lambda Move Capture

by John Bandela

Today the post on isocpp.org called Learn How to Capture By Move caught my attention. I found the post informative and thought provoking, and you should go and read it before reading the rest of this post.

The problem is how do we lambda capture a large object we want to avoid copying?

The motivating example is below:

function<void()> CreateLambda()  
{  
  vector<HugeObject> hugeObj;  
  // ...preparation of hugeObj...  
  auto toReturn = [hugeObj] { /*...operate on hugeObj...*/ };  
  return toReturn;  
}

The solution proposed is a template class move_on_copy that is used like this:

auto moved = make_move_on_copy(move(hugeObj));
auto toExec = [moved] { /*...operate on moved.value...*/ };

However, there are problems with this approach, mainly in safety. The move_on_copy acts as auto_ptr and silently performs moves instead of copies (by design).

I present here a different take on the problem which accomplishes much of the above safely, however, with a little more verbosity in exchange for more clarity and safety.

Continue reading...

 

Modules update video available -- Doug Gregor

MP4 video of Doug Gregor's talk on Modules is now available via llvm.org. Combining links here:

Modules (MP4 video) (PDF slides)

Doug Gregor - Apple

The C preprocessor has long been a source of problems for programmers and tools alike.

Programmers must contend with widespread macro pollution and #include-ordering problems due to ill-behaved headers. Developers habitually employ various preprocessor workarounds, such as LONG_MACRO_PREFIXES, #include guards, and the occasional #undef of a library macro to mitigate these problems.

Tools, on the other hand, must cope with the inherent scalability problems associated with parsing the same headers repeatedly, because each different preprocessing context could effect how a header is interpreted – even though the programmer rarely wants it.

Modules seeks to solve this problem by isolating the interface of a particular library and compiling it (once) into an efficient, serialized representation that can be efficiently imported whenever that library is used, improving both the programmer’s experience and the scalability of the compilation process.

 

C++11 tempts OSS: KDevelop 4.6 IDE, KDE Frameworks 5, Qt 5.0 (Phoronix)

HT to Michael Larabel and Phoronix: It's great to see more projects moving to adopt modern C++11, from C++98/03 and even from C. Here are three fairly well-known projects in the "thinking about" stage of taking the plunge.

More Open-Source Projects Eyeing Up C++11

by Michael Larabel

KDE developers are currently contemplating the idea of allowing a subset of the C++11 language to be used within the KDevelop code-base. This C++11 change would happen for the KDevelop 4.6 integrated development environment release. Reasons are shared in this article for why one should consider using C++11 code.

[...]

Qt 5.0 is taking advantage of C++11 too, but there it's being handled in a backwards compatible manner so the code will still build as C++03 on older compilers. There is also more Qt C++11 developer information shared via slides from the recent Qt Developer Days event.

KDE Frameworks 5 may also use C++11.

Continue reading...

Tour of C++: Second chapter posted

This 2nd chapter of my Tour of C++ introduces the basic C++ abstraction mechanisms. If you have a 1990s view of C++, you are in for a few surprises: the integrated set of abstraction mechanisms in C++11 allows for simpler and more powerful abstractions than previously. For starters, pointers basically disappear from sight (hiding inside resource handles). Naturally, this is achieved without loss of performance. Enjoy!

Constructive comments would be most welcome.