locked
parallel programming in Visual C++ Windows forms RRS feed

  • Question

  • I've spent several days going in circles trying to find how to do a simple parallel programming problem, such as a matrix multiplication, using Visual C++ WindowsForms in Visual Studio 2010.

    I'm brand new to Visual C++. Can anyone direct me to a sample of code that will get me started?


    Don Ritchie
    Friday, May 13, 2011 7:59 PM

Answers

  • Hi Don,

    when you are using Windows Forms you are developping a managed C++ application with C++/CLI, right?

    As you are using managed code you can use the .NET Task<T> type, the Parallel class etc. The problem is, all of those constructs make massive use of lambda expressions which are not well supported in C++/CLI. (VS 2010 has suppport for C++ 0x lamabdas, but they are not really compatible with .NET Action<T>, Func<T> and so on.

    If you used native C++ (i.e. with MFC for the UI) you could use the concurrent runtime and PPL, e.g. But this is not supported for managed C++.

    So I think that you have the following options:

    - use native C++ and ConCRT / PPL for your calculations, stick to Windows Forms and C++/CLI for the UI and do some interop (but it is difficult to pass constructs like tasks around between C++ native and managed code)

    - use native C++, MFC and ConCRT /PPL, that should work

    - use C#, Windows Forms and .NET TPL

    - use an external, optimized parallel library for matrix opertions (maybe take a look at Intel MKL) and use that library from native or managed C++

    The topic "Parallel Programming" in MSDN is good starting point: http://msdn.microsoft.com/en-us/library/ee856607.aspx

    Best regards,
    Bernd

    • Marked as answer by Don Ritchie Saturday, May 14, 2011 12:24 PM
    Saturday, May 14, 2011 11:48 AM

All replies

  • Hi Don,

    when you are using Windows Forms you are developping a managed C++ application with C++/CLI, right?

    As you are using managed code you can use the .NET Task<T> type, the Parallel class etc. The problem is, all of those constructs make massive use of lambda expressions which are not well supported in C++/CLI. (VS 2010 has suppport for C++ 0x lamabdas, but they are not really compatible with .NET Action<T>, Func<T> and so on.

    If you used native C++ (i.e. with MFC for the UI) you could use the concurrent runtime and PPL, e.g. But this is not supported for managed C++.

    So I think that you have the following options:

    - use native C++ and ConCRT / PPL for your calculations, stick to Windows Forms and C++/CLI for the UI and do some interop (but it is difficult to pass constructs like tasks around between C++ native and managed code)

    - use native C++, MFC and ConCRT /PPL, that should work

    - use C#, Windows Forms and .NET TPL

    - use an external, optimized parallel library for matrix opertions (maybe take a look at Intel MKL) and use that library from native or managed C++

    The topic "Parallel Programming" in MSDN is good starting point: http://msdn.microsoft.com/en-us/library/ee856607.aspx

    Best regards,
    Bernd

    • Marked as answer by Don Ritchie Saturday, May 14, 2011 12:24 PM
    Saturday, May 14, 2011 11:48 AM
  • Bernd:

         Although that isn't the answer I hoped for, it will end the frustration of trying to do something that can't be done. Many thanks for saving me a LOT of hassle.

    I'll look into the options you mention. MFC looks like a viable route.


    Don Ritchie
    Saturday, May 14, 2011 12:30 PM