Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. (Solved) C++ AMP in Qt
Forum Update on Monday, May 27th 2025

(Solved) C++ AMP in Qt

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 3.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    technovelist
    wrote on 5 Dec 2014, 14:24 last edited by
    #1

    Hi all,

    My Qt project could benefit from GPU acceleration, for which I'm attempting to use C++ AMP. I'm using code taken straight from the documentation on C++ AMP ("http://blogs.msdn.com/b/nativeconcurrency/archive/2012/03/04/quot-hello-world-quot-in-c-amp.aspx":http://blogs.msdn.com/b/nativeconcurrency/archive/2012/03/04/quot-hello-world-quot-in-c-amp.aspx). However, my test program fails when trying to create the array_view object. It works fine as a Visual C++ 2013 program but blows up when running inside my Qt project (which is using the VS2013 compiler):

    @#include <iostream>
    #include <amp.h>
    using namespace concurrency;

    #include "amptest.h"

    void AMPTest()
    {
    int v[11] = {'G', 'd', 'k', 'k', 'n', 31, 'v', 'n', 'q', 'k', 'c'};

    array_view<int> av(11, v);
    parallel_for_each(av.extent, [=](index<1> idx) restrict(amp)
    {
      av[idx] += 1;
    });
    
    for(unsigned int i = 0; i < 11; i++)
      std::cout << static_cast<char>(av[i]);
    

    }

    @

    Any assistance would be welcomed.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 5 Dec 2014, 15:09 last edited by
      #2

      I just tried that in a fresh app created with widget app wizard and it works fine, apart from the D3D errors landing on the output that are "apparently fine":https://social.msdn.microsoft.com/Forums/vstudio/en-US/d9f0315e-e97b-4fad-af5c-f810835808cd/updates-to-c-ampdirectx-samples-needed-to-run-on-windows-81-vs2013-preview?forum=parallelcppnative in Debug mode.

      How exactly does it "blow up"? It produces wrong results or doesn't compile at all and what errors the compiler gives if that is the case?

      1 Reply Last reply
      0
      • T Offline
        T Offline
        technovelist
        wrote on 5 Dec 2014, 16:10 last edited by
        #3

        It compiles fine but throws an exception on the line:

        @ array_view<int> av(11, v);@

        I'll post the call stack when I'm back at home and can re-run the code.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          technovelist
          wrote on 6 Dec 2014, 16:55 last edited by
          #4

          Here's the call stack:

          @0 RaiseException KERNELBASE 0x7510c42d
          1 _CxxThrowException msvcrt 0x7692359c
          2 ThrowFailure d3d11 0x68a77bdc
          3 CDevice::LLOCompleteLayerConstruction d3d11 0x68a7eb7b
          4 CBridgeImpl<ILayeredLockOwner,ID3D11LayeredDevice,CLayeredObject<CDevice>>::LLOCompleteLayerConstruction d3d11 0x68a72529
          5 NDXGI::CDevice::LLOCompleteLayerConstruction d3d11 0x68a76df7
          6 CBridgeImpl<ILayeredLockOwner,ID3D11LayeredDevice,CLayeredObject<NDXGI::CDevice>>::LLOCompleteLayerConstruction d3d11 0x68a726d6
          7 NDebug::CDevice::LLOCompleteLayerConstruction D3D11_1SDKLayers 0x7779e046
          8 CBridgeImpl<ILayeredLockOwner,ID3D11LayeredDevice,CLayeredObject<NDebug::CDevice>>::LLOCompleteLayerConstruction D3D11_1SDKLayers 0x77786617
          9 NOutermost::CDevice::LLOCompleteLayerConstruction d3d11 0x68aac134
          10 NOutermost::CDevice::FinalConstruct d3d11 0x68a766c3
          11 TComObjectNOutermost::CDevice::TComObjectNOutermost::CDevice d3d11 0x68a73922
          12 TComObjectNOutermost::CDevice::CreateInstance d3d11 0x68a734f9
          13 D3D11CreateLayeredDevice d3d11 0x68a6faa6
          14 D3D11CoreCreateLayeredDevice d3d11 0x68a6fd93
          15 D3D11CoreCreateDevice d3d11 0x68a719b7
          16 D3D11CreateDeviceAndSwapChain d3d11 0x68a71e4e
          17 D3D11CreateDevice d3d11 0x68a71bdd
          18 Concurrency::details::_D3D11_engine::_D3D11_engine d3d_engine.cpp 686 0x7792d7dc
          19 Concurrency::details::_D3D_engine::_Create d3d_engine.cpp 361 0x7792cbc1
          20 Concurrency::details::_D3D_accelerator_impl::_Create_D3D_engine d3d_compute_device.cpp 144 0x778c330c
          21 Concurrency::details::_D3D_accelerator_impl::_Create_D3D_accelerator_view d3d_compute_device.cpp 163 0x778c33b2
          22 Concurrency::details::_D3D_accelerator_impl::_D3D_accelerator_impl d3d_compute_device.cpp 41 0x778c2f74
          23 Concurrency::details::_D3D_accelerator_impl::_Create_D3D_accelerator_impl d3d_compute_device.cpp 185 0x778c3492
          24 Concurrency::details::_DPC_runtime_factory::_DPC_runtime_factory dpc_runtime_factory.cpp 537 0x778e4f7a
          25 Concurrency::details::_SingletonConcurrency::details::_DPC_runtime_factory::_Get_object dpcrt_impl.h 607 0x778e78b2
          26 Concurrency::details::_DPC_runtime_factory::_Get_factory dpc_runtime_factory.cpp 807 0x778e6408
          27 Concurrency::accelerator::_Init dpcrt.cpp 62 0x778f2bcf
          28 Concurrency::accelerator::accelerator amprt.h 1135 0xb851a9
          29 Concurrency::details::_Array_view_base<1,1>::_Array_view_base<1,1> amp.h 1768 0xb848a9
          30 Concurrency::array_view<int,1>::array_view<int,1> amp.h 2435 0xb84db1
          31 AMPTest AMPtest.cpp 12 0xb83a56
          32 MainWindow::AMPTester mainwindow.cpp 1454 0xb6070c
          33 MainWindow::qt_static_metacall moc_mainwindow.cpp 121 0xb875e9
          34 QMetaObject::activate qobject.cpp 3681 0x66aca819
          35 QMetaObject::activate qobject.cpp 3547 0x66aca271
          36 QAbstractButton::clicked moc_qabstractbutton.cpp 297 0x652717cb
          37 QAbstractButtonPrivate::emitClicked qabstractbutton.cpp 544 0x64f1b3a7
          38 QAbstractButtonPrivate::click qabstractbutton.cpp 536 0x64f1a92b
          39 QAbstractButton::mouseReleaseEvent qabstractbutton.cpp 1141 0x64f19d92
          40 QWidget::event qwidget.cpp 7966 0x64e0b9bc
          41 QAbstractButton::event qabstractbutton.cpp 1098 0x64f198f1
          42 QPushButton::event qpushbutton.cpp 682 0x64fdc50b
          43 QApplicationPrivate::notify_helper qapplication.cpp 3499 0x64dc3a4e
          44 QApplication::notify qapplication.cpp 3066 0x64dc024e
          45 QCoreApplication::notifyInternal qcoreapplication.cpp 935 0x66a7f9f7
          46 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 240 0x66b96db8
          47 QApplicationPrivate::sendMouseEvent qapplication.cpp 2539 0x64dc4cb3
          48 QWidgetWindow::handleMouseEvent qwidgetwindow.cpp 507 0x64e4862b
          49 QWidgetWindow::event qwidgetwindow.cpp 180 0x64e4780e
          50 QApplicationPrivate::notify_helper qapplication.cpp 3499 0x64dc3a4e
          51 QApplication::notify qapplication.cpp 2952 0x64dbfc17
          52 QCoreApplication::notifyInternal qcoreapplication.cpp 935 0x66a7f9f7
          53 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 240 0x66b96db8
          54 QGuiApplicationPrivate::processMouseEvent qguiapplication.cpp 1748 0xf56aaaf
          55 QGuiApplicationPrivate::processWindowSystemEvent qguiapplication.cpp 1549 0xf56c9e9
          56 QWindowSystemInterface::sendWindowSystemEvents qwindowsysteminterface.cpp 579 0xf54f241
          57 QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 89 0x774da7e1
          58 qt_internal_proc qeventdispatcher_win.cpp 421 0x66b174e0
          59 InternalCallWinProc USER32 0x750162fa
          60 UserCallWinProcCheckWow USER32 0x75016d3a
          61 DispatchMessageWorker USER32 0x750177c4
          62 DispatchMessageW USER32 0x7501788a
          63 QEventDispatcherWin32::processEvents qeventdispatcher_win.cpp 795 0x66b17fcf
          64 QWindowsGuiEventDispatcher::processEvents qwindowsguieventdispatcher.cpp 80 0x774da6fc
          65 QEventLoop::processEvents qeventloop.cpp 137 0x66a7b87c
          66 QEventLoop::exec qeventloop.cpp 212 0x66a7ba72
          67 QCoreApplication::exec qcoreapplication.cpp 1188 0x66a7e002
          68 QGuiApplication::exec qguiapplication.cpp 1484 0xf569678
          69 QApplication::exec qapplication.cpp 2745 0x64dbf719
          70 main main.cpp 10 0xb57078
          71 WinMain qtmain_win.cpp 131 0xb89a0a
          72 __tmainCRTStartup crtexe.c 618 0xb88edf
          73 WinMainCRTStartup crtexe.c 466 0xb88c9d
          74 BaseThreadInitThunk kernel32 0x74ed338a
          75 __RtlUserThreadStart ntdll 0x77199f72
          76 _RtlUserThreadStart ntdll 0x77199f45

          @

          1 Reply Last reply
          0
          • T Offline
            T Offline
            technovelist
            wrote on 7 Dec 2014, 17:15 last edited by
            #5

            As I like developing in VS, I decided to switch to the VS addin, which runs the C++ AMP code without crashing.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              develooper
              wrote on 16 May 2015, 15:12 last edited by
              #6
              1. Can I download amp lib. and use in qt creator?
              2. Can I download amp lib. and use in qt creator in linux?
              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved