L
L
lemon_spb2015-12-11 16:02:32
Qt
lemon_spb, 2015-12-11 16:02:32

Basics of OpenCL( C++, Qt 5). How to build a simple program?

Colleagues, it is not possible to fully launch an elementary program.
What is:
Windows 7 64
Qt 5.5.1 Desktop MSVC2013 64bit (tested with MinGW 32 bit as well)
Nvidia GeForce 540
CUDA drivers installed for 64 bit.
In Visual Studio 2013 CUDA, the examples compile and work.
This program is also assembled from QtCreator and launched, displaying the "Using platform: NVIDIA CUDA"
Pro file on the screen:

QT += core
QT -= gui

TARGET = QtTestCuda
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app

SOURCES += main.cpp

QMAKE_CXXFLAGS += -std=c++0x

LIBS += -L$$PWD/ -L"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/lib/x64" -lOpenCL
INCLUDEPATH += $$PWD/ "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/include"

DEPENDPATH += $$PWD/ "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/include"

main.cpp:
#include <CL/cl.hpp>

#include <iostream>
#include <vector>
//#define __NO_STD_VECTOR

int main(int argc, char *argv[])
{
    //get all platforms (drivers)
     std::vector<cl::Platform> all_platforms;
     cl::Platform::get(&all_platforms);
     if(all_platforms.size()==0){
         std::cout<<" No platforms found. Check OpenCL installation!\n";
         exit(1);
     }
     cl::Platform default_platform=all_platforms[0];
     std::cout << "Using platform: "<<default_platform.getInfo<CL_PLATFORM_NAME>()<<"\n";

     //get default device of the default platform     
     std::vector<cl::Device> all_devices;
     default_platform.getDevices(CL_DEVICE_TYPE_ALL, &all_devices);//!!!!!!!!!!!!!!
     return 0;
}

but as soon as I uncomment the penultimate line with "!!!!!!!!!!" - then it comes out
"Failed to get the identifier of the slave process: The parameter is incorrect.", Or
"..../QtTestCuda.exe ended with the code -1073741511"
I would be grateful for the hints. Already exhausted.
UPD:
In studio 2013 the situation is similar - without the line "!!!!!" everything works, and with it - a message pops up
d6c17989ef5a4e6982a404aa95a93dc6

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Martyanov, 2015-12-11
@limon_spb

Judging by the error message, I would venture to suggest that you have an old / poorly installed OpenCL. As far as I remember, enumeration of platforms can only be done through the registry, OpenCL itself is not needed. But getting devices already requires OpenCL, and then the error falls out. Do you even have a file called opencl.dll?

V
Vladusch, 2015-12-11
@Vladusch

The 540th GeFors should keep OpenCL 1.1. The first thing that comes to mind is to install up-to-date and stable drivers for the video card. I also advise you to install the Intel OpeCL SDK and / or AMD APP SDK (AMD supports both its processors and graphics, and Intel processors) - then you will have at least one platform with at least one device supporting OpenCL.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question