Geeks With Blogs
Josh Reuben

·        For the last decade, the majority of my dev work has leveraged the .NET Framework for construction of information systems. However, my interest has lain in numerical computing.

·        Is it possible to have an increasingly higher level of abstraction and at the same time achieve underlying high performance computing? The prevailing winds say no: C# is aimed at productivity, and C++ is for performance. Garbage collection was great, but do we still need it with the availability of smart pointers? Would you like to leverage GPGPU from .NET ? Yes, there is 3rd party Brahma.NET (LINQ to GPU - http://ananthonline.net/2010/09/29/new-brahma-syntaxusage/ ) ,  but not much from MS – Accelerator (http://research.microsoft.com/en-us/projects/accelerator/) never made it out of MS Research, and the company is pushing C++ AMP for GPGPU. That’s C++ AMP, not C# AMP. The Win 8 status of XNA is in doubt (via ominous silence), so the only way to program a sufficiently advanced UI for a metro app (i.e. something dazzling that gives competitive advantage by having high barriers of entry, not a XAML LOB form!) so far will be via DirectX, which is only supported in C++.

·        Aside from interop, I hadn’t done much in C++ since the 1990s (ATL and DirectX). I spent the last couple of weeks revising. This post describes the resources I used to get back up to speed in an unmanaged world.

October – My Grand C++ Cram

ANSI C++ Language Tutorial

·        I started with http://www.cplusplus.com/doc/tutorial/ - These tutorials explain the C++ language from its basics up to ANSI-C++ 2003, including basic concepts such as arrays or classes and advanced concepts such as polymorphism or templates.

·        Coming from C#, there are a lot of C++ oddities that this tutorial allowed me to revise and reacquaint myself with. I will blog about these differences in a future post.

·        Basics of C++

o   Structure of a program

o   Variables. Data types.

o   Constants

o   Operators

o   Basic Input/Output

·       Control Structures

o   Control Structures

o   Functions (I)

o   Functions (II)

·       Compound Data Types

o   Arrays

o   Character Sequences

o   Pointers

o   Dynamic Memory

o   Data Structures

o   Other Data Types

·       Object Oriented Programming

o   Classes (I)

o   Classes (II)

o   Friendship and inheritance

o   Polymorphism

·       Intermediate Concepts

o   Templates

o   Namespaces

o   Exceptions

o   Type Casting

o   Preprocessor directives

o   Input/Output with files

 

STL Reference

·        http://www.cplusplus.com/reference/

·        The Standard template library is kind of like System.Collections.Generic for C++. The STL is a collection of functions, constants, classes, objects and templates that extends the C++ language providing basic functionality to perform several tasks, like classes to interact with the operating system, data containers, manipulators to operate with them and algorithms commonly needed. The declarations of the different elements provided by the library are split in several headers that shall be included in the code in order to have access to its components

·        C Library

·        C++ Standard Library: Standard Template Library (STL)

·        C++ Standard Library: Input/Output Stream Library - Provides functionality to use an abstraction called   streams   specially designed to perform input and output operations on sequences of character, like files or strings.

Visual C++ reference for Windows Runtime

·        Allot of detritus has accumulated in the C++ APIs pile over the past 2 decades. MS is pushing 'modern C++', forcing Win8 C++ developers to use better practices. Visual C++ in Visual Studio 11 for Windows Developer Preview has a new programming model for creating Metro style apps and components. One of the primary features of the new model is the abstract binary interface, or ABI, which defines an interface for inter-language communication. The new programming model is based on an updated version of COM, but the way that you program against this new model is more simple and natural than old-style COM programming. 

·        Windows Runtime objects and ref new

·        Numeric Types

·        Ref classes

·        Value structs

·        Strings

·        Properties

·        Interfaces and Parameterized Interfaces

·        Arrays

·        Enums

·        Delegates

·        Events

·        Collections

·        Exceptions

·        Platform::Uri and Guid types

·        Casting between C++ and WinRT types

·        Inheritance

·        Partial classes

·        Compiler and Linker options

·        Boxing

C++/CLI

·        Allot of the modern C++ stuff seems similar to C++/ CLI, so I revised that for good measure - C++/CLI for the C# programmer - http://www.c-sharpcorner.com/UploadFile/b942f9/9697/

·        I also looked at the Differences between C++/CLI and WinRT C++ - http://social.msdn.microsoft.com/Forums/en-GB/winappswithnativecode/thread/0aec2f93-de7e-4f2b-8090-17ceb34ed759

 

C++ 11

·        http://en.wikipedia.org/wiki/C%2B%2B11

·        The next thing I looked into was the latest version of C++. The Wikipedia article was a very informative source.  I would say the biggest change here is the inclusion for a very powerful expression of Lambda Functions in C++. Heres the TOC:

·        1   Candidate changes for the impending standard update

·        2   Extensions to the C++ core language

·        3   Core language runtime performance enhancements

o   3.1   Rvalue references and move constructors

o   3.2   Generalized constant expressions

o   3.3   Modification to the definition of plain old data

·        4   Core language build time performance enhancements

o   4.1   Extern template

·        5   Core language usability enhancements

o   5.1   Initializer lists

o   5.2   Uniform initialization

o   5.3   Type inference

o   5.4   Range-based for-loop

o   5.5   Lambda functions and expressions

o   5.6   Alternative function syntax

o   5.7   Object construction improvement

o   5.8   Explicit overrides and final

o   5.9   Null pointer constant

o   5.10   Strongly typed enumerations

o   5.11   Right angle bracket

o   5.12   Explicit conversion operators

o   5.13   Template aliases

o   5.14   Unrestricted unions

o   5.15   Identifiers with special meaning

·        6   Core language functionality improvements

o   6.1   Variadic templates

o   6.2   New string literals

o   6.3   User-defined literals

o   6.4   Multitasking memory model

o   6.5   Thread-local storage

o   6.6   Explicitly defaulted and deleted special member functions

o   6.7   Type long longint

o   6.8   Static assertions

o   6.9   Allow sizeof to work on members of classes without an explicit object

o   6.10   Allow garbage collected implementations

·        7   C++ standard library changes

o   7.1   Upgrades to standard library components

o   7.2   Threading facilities

o   7.3   Tuple types

o   7.4   Hash tables

o   7.5   Regular expressions

o   7.6   General-purpose smart pointers

o   7.7   Extensible random number facility

o   7.8   Wrapper reference

o   7.9   Polymorphic wrappers for function objects

o   7.10   Type traits for metaprogramming

o   7.11   Uniform method for computing the return type of function objects

·        8   Features planned but removed or not included

·        9   Features to be removed or deprecated

 

C++ Programming Wiki booklets

·        I found some nice resources on esoteric C++ topics here:

·        STL - http://en.wikibooks.org/wiki/C++_Programming/STL

o   The   Standard Template Library   (STL) offers collections of algorithms, containers, iterators, and other fundamental components, implemented as templates, classes, and functions essential to extend functionality and standardization to C++. STL main focus is to provide improvements implementation standardization with emphasis in performance and correctness.

·        TMP - http://en.wikibooks.org/wiki/C%2B%2B_Programming/Templates/Template_Meta-Programming

o   Template meta-programming refers to uses of the C++ template system to perform computation at compile-time within the code.

·        Smart Pointers - http://en.wikibooks.org/wiki/C++_Programming/Operators/Pointers/Smart_Pointers

o   Using raw pointers to store allocated data and then cleaning them up in the destructor can generally be considered a very bad idea since it is error-prone. Even temporarily storing allocated data in a raw pointer and then deleting it when done with it should be avoided for this reason. For example, if your code throws an exception, it can be cumbersome to properly catch the exception and delete all allocated objects. Smart pointers can alleviate this headache by using the compiler and language semantics to ensure the pointer content is automatically released when the pointer itself goes out of scope.

·        RTTI - http://en.wikibooks.org/wiki/C++_Programming/RTTI

o   RTTI refers to the ability of the system to report on the dynamic type of an object and to provide information about that type at runtime (as opposed to at compile time), when utilized consistently can be a powerful tool to ease the work of the programmer in managing resources.

·        C++ Garbage Collection ( a little sparse) - http://en.wikibooks.org/wiki/C++_Programming/Compiler/Linker/Libraries/Garbage_Collection

·        Libraries (including popular 3rd party libraries) - http://en.wikibooks.org/wiki/C++_Programming/Compiler/Linker/Libraries

o   Additional functionality that goes beyond the standard libraries (like garbage collection) are available (often free) by third party libraries, preventing wheel (and square wheel) re-invention.

·        The Boost Library (nice overview!) - http://en.wikibooks.org/wiki/C++_Programming/Libraries/Boost

o   The   Boost library   ( http://www.boost.org/ ) provides free,   peer-reviewed ,   open source   libraries   that extend the functionality of C++. Boost is like the BCL for C++.

·        Optimization - http://en.wikibooks.org/wiki/C++_Programming/Optimization

o   the use of virtual member functions, the right container, etc

·        Win32 - http://en.wikibooks.org/wiki/C++_Programming/Code/API/Win32

o   most direct way to interact with Windows for   software applications . Lower level access to a   Windows   system, mostly required for   device drivers , is provided by the   Windows Driver Model   .

·        C++ Programming/Threading

o   http://en.wikibooks.org/wiki/C++_Programming/Threading

 

Concurrency Runtime

·        Next I read through the section on MSDN that discussed parallelism on the CPU - http://msdn.microsoft.com/en-us/library/ee207192.aspx - this set of APIs raises the level of abstraction so that you do not have to manage the infrastructure details that are related to concurrency. You can also use it to specify scheduling policies that meet the quality of service demands of your applications. Coming from TPL, the were a lot of programmatic similarities that were evident. CCR goes a step further than the TPL though: It exposes UMS (user mode scheduling), allowing you to set task priority, and preemptively release the CPU from a non-busy thread.

·        Parallel Patterns Library (PPL) - http://msdn.microsoft.com/en-us/library/dd492418.aspx

o   builds on the scheduling and resource management components of the Concurrency Runtime

·        Asynchronous Agents Library - http://msdn.microsoft.com/en-us/library/dd492627.aspx

o   a template library that promotes an actor-based programming model and in-process message passing for coarse-grained dataflow and pipelining tasks. Very similar concepts to Axum, MPI.NET, TPL 4.5 DataFlow and F# DataFlowVariable<T>

 

·        Task Scheduler (Concurrency Runtime) - http://msdn.microsoft.com/en-us/library/dd984036.aspx

 

C++ AMP

·        Following this I got round to GPGPU – I read through

·        http://msdn.microsoft.com/en-us/library/hh265137(VS.110).aspx and , http://www.danielmoth.com/Blog/

·        C++ Accelerated Massive Parallelism accelerates execution of C++ code by taking advantage of the data-parallel hardware that is generally present as a GPU on a discrete graphics card. The C++ AMP programming model includes multidimensional arrays, indexing, memory transfer, tiling, and a mathematical function library. C++ AMP language extensions and compiler restrictions enable you to control how data is moved from the CPU to the GPU and back, which enables you to control the performance impact of moving the data back and forth.

·        Basically this is a C++ abstraction over HLSL for GPGPU – just like OpenCL is over CUDA. I must say that the programmatic concepts easily transferred across from what I had previously learned by going through MS Accelerator, but allot more configurable.

·        I especially liked the tile_static modifier – a type of shared memory for a subset of GPU threads – think rollup and linear algebra block matrices !

 

Windows Programming in C++

·        Currently going through using the Win32 API - http://msdn.microsoft.com/en-us/library/ff381399(VS.85).aspx

o   Introduction to Windows Programming in C++     - describes some of the basic terminology and coding conventions used in Windows programming.

o   Module 1. Your First Windows Program   - create a simple Windows program that shows a blank window.

o   Module 2. Using COM in Your Windows Program - introduces how COM underlies many of the modern Windows APIs.

o   Module 3. Windows Graphics     - Windows graphics architecture, with a focus on Direct2D.

o   Module 4. User Input   - mouse and keyboard input.

·        At some point, I'll get back to that Windows Internals book too!

Next Month

October's nearly over, and aside from reading the Roslyn docs and a JQuery book, (and my day job!!) , I've learned and relearned allot of C++. So whats next?

COM

·        I'm rearing to revise this stuff – its been a while since my programming life revolved around COM (I vaguely remember monikers, IDL etc) - http://msdn.microsoft.com/en-us/library/ee663262(VS.85).aspx. Heres some links:

o   Component Object Model (COM)             COM is a platform-independent, distributed, object-oriented system for creating binary software components that can interact. COM is the foundation technology for Microsoft's OLE (compound documents) and ActiveX (Internet-enabled components) technologies.

o   Automation   - enables software packages to expose their unique features to scripting tools and other applications..

o   Microsoft Interface Definition Language (MIDL)    - defines interfaces between client and server programs. The MIDL compiler in the Platform SDK enables you to create the interface definition language (IDL) files and application configuration files (ACF) required for RPC interfaces and COM/DCOM interfaces. MIDL also supports the generation of type libraries for OLE Automation.

o   Structured Storage       - provides file and data persistence in COM by handling a single file as a structured collection of objects known as storages and streams.

DirectX

·        I recently gave a course on XNA, so am ready to deep dive back into this platform - http://msdn.microsoft.com/en-us/library/ee663274(VS.85).aspx

 

The Boost C++ Libraries

·        You just cannot be proficient in C++ without Boost - http://en.highscore.de/cpp/boost/frontpage.html. As I stated, this is the BCL of C++.

o   Chapter 1: Introduction

o   Chapter 2: Smart Pointers

o   Chapter 3: Function Objects

o   Chapter 4: Event Handling

o   Chapter 5: String Handling

o   Chapter 6: Multithreading

o   Chapter 7: Asynchronous Input and Output

o   Chapter 8: Interprocess Communication

o   Chapter 9: Filesystem

o   Chapter 10: Date and Time

o   Chapter 11: Serialization

o   Chapter 12: Parser

o   Chapter 13: Containers

o   Chapter 14: Data Structures

o   Chapter 15: Error Handling

o   Chapter 16: Cast Operators

 

WDK – Windows Driver Kit

·        I know next to nothing about this !!!http://msdn.microsoft.com/en-us/library/ff557573(VS.85).aspx – I am very curious about how to write code in kernel mode.

 

Optimizing C++ Wikibook

·        To master something , you have to know how to tweak it - http://en.wikibooks.org/wiki/Optimizing_C%2B%2B

·        Optimization life cycle

·        Writing efficient code

o   Performance improving features

o   Performance worsening features

o   Constructions and destructions

o   Allocations and deallocations

o   Memory access

o   Thread usage

·        General optimization techniques

o   Input/Output

o   Memoization

o   Sorting

o   Other techniques

·        Code optimization

o   Allocations and deallocations

o   Run-time support

o   Instruction count

o   Constructions and destructions

o   Pipeline

o   Memory access

o   Faster operations

 

As Yoda stated – C# devs:  "You must unlearn what you have learned" - http://www.youtube.com/watch?v=FDezrybpuO8

Cheers,

Josh

 

Posted on Saturday, October 29, 2011 9:59 PM Technical Readings , Parallelism , C++ | Back to top


Comments on this post: Post-Build C++ Skill Rebuild

# re: Post-Build C++ Skill Rebuild
Requesting Gravatar...
It is really something great to learn a useful process like this now. - Antiquities of California
Left by Robert Nyers on Jan 10, 2017 2:35 PM

Your comment:
 (will show your gravatar)


Copyright © JoshReuben | Powered by: GeeksWithBlogs.net