cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Stib
Journeyman III

Help with learning OpenCL, and C++

I'm a noob, help me please!

I have Windows 7 64-bit, Ms Visual Studio Professional Edition, an the latest Ati Stream SDK isntalled, on a Core2Duo E8400 system, with an EAH4850 graphic card. The samples are running, theres no problem with that.

 

I start VS, and click File->New->Project...

there Visual C++->Win32->Win32 Console Application, lets name it Test,

in the wizard i click empty project.

Now i right click on Test->Properties->Configuration Properties->

->C/C++->Genereal, and there, i add the include directory of Ati Stream, to the Additional Include Directories.

 

I can build, and run this sample code:

"#include

int main()
{
}

"

 

When i try

"#include

int main()
{
    cl_int a;
    cl_uint n_e=10;
    cl_platform_id *p=NULL;
    cl_uint *n_p=NULL;
    a=clGetPlatformIDs(n_e,p,n_p);
}
"

this code (may be buggy, sorry, im a noob), i get:

1>------ Build started: Project: Test, Configuration: Debug Win32 ------
1>Compiling...
1>Proba.cpp
1>Linking...
1>Proba.obj : error LNK2019: unresolved external symbol __imp__clGetPlatformIDs@12 referenced in function _main
1>C:\Users\Stib\Documents\Visual Studio 2008\Projects\Test\Debug\Test.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\Stib\Documents\Visual Studio 2008\Projects\Test\Test\Debug\BuildLog.htm"
1>Test - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 

What am i doing wrong? Can someone help me?

 

UPDATE: my 2 includes are the CL/cl.h

0 Likes
56 Replies
Stib
Journeyman III

I'm trying the C++ bindings. I use, the code at the end of the post, and i'm getting similar errors:

 

1>------ Build started: Project: Test, Configuration: Release Win32 ------
1>Compiling...
1>Proba.cpp
1>Linking...
1>Proba.obj : error LNK2001: unresolved external symbol __imp__clCreateContextFromType@24
1>Proba.obj : error LNK2001: unresolved external symbol __imp__clReleaseContext@4
1>C:\Users\Stib\Documents\Visual Studio 2008\Projects\Test\Release\Test.exe : fatal error LNK1120: 2 unresolved externals
1>Build log was saved at "file://c:\Users\Stib\Documents\Visual Studio 2008\Projects\Test\Test\Release\BuildLog.htm"
1>Test - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

#include <CL/cl.hpp> int main() { cl::Context context = cl::Context(CL_DEVICE_TYPE_CPU); }

0 Likes

Have you specified the OpenCL library to link to?

If not, add OpenCL.lib in additional dependencies under Properties->Linker->input

and

"$(ATISTREAMSDKROOT)/lib/x86" to addtional library directories under Properties->Linker->General

0 Likes

That solved the problem, thank you! If i have another problem/question, i post it here. 

0 Likes
Stib
Journeyman III

Ok, next issue: the first C++ binding seems to work. By the second, i get:

1>------ Build started: Project: Test, Configuration: Release Win32 ------
1>Compiling...
1>Proba.cpp
1>.\Proba.cpp(13) : error C2783: 'detail::Param_traits::Param_type cl::Context::getInfo(cl_int *) const' : could not deduce template argument for 'name'
1>        C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(1612) : see declaration of 'cl::Context::getInfo'
1>.\Proba.cpp(13) : error C2780: 'cl_int cl::Context::getInfo(cl_context_info,T *) const' : expects 2 arguments - 0 provided
1>        C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(1583) : see declaration of 'cl::Context::getInfo'
1>Build log was saved at "file://c:\Users\Stib\Documents\Visual Studio 2008\Projects\Test\Test\Release\BuildLog.htm"
1>Test - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Here is, where i work from:

LINK

#include <CL/cl.hpp> #include <stdlib.h> int main() { /*cl_int a; cl_uint n_e=10; cl_platform_id *p=NULL; cl_uint *n_p=NULL; a=clGetPlatformIDs(n_e,p,n_p);*/ cl::Context context = cl::Context(CL_DEVICE_TYPE_CPU); // this alone throws no error std::vector<cl::Device> devices = context.getInfo(); }

0 Likes

The error is because of incorrect usage. The code given there is pseudocode, you can find the source code at the bottom of the same page.

0 Likes

THX again! I'm using that source code from now on, for my learning.

0 Likes
Stib
Journeyman III

Hi!

New issue...

cl_uint num_entries=10; cl_platform_id platforms; cl_uint num_platforms; clGetPlatformIDs(num_entries, &platforms, &num_platforms); I'm using this code, to get the platform id. The OpenCL API says, that platforms get a list, of available platforms. I have only one available platform, so the code above works. But how could i use it, if num_platforms was higher, than 1? I tried many things with pointers, but nothing worked. Please, could someone give me an example code for getting more than 1 platform id, if available? The second issue. I tested the device info, and i got for vendor id 4098 by my cpu, and gpu also. How can it be? Is it not a UNIQUE ID?? Here are the results i got from my application: Platform profile: FULL_PROFILE Platform version: OpenCL 1.0 ATI-Stream-v2.0-beta4 Platform name: ATI Stream Platform vendor: Advanced Micro Devices, Inc. Platform extensions: Number of devices: 2 Device #1: CPU Vendor ID: 4098 Max compute units: 2 Max work item dimensions: 3 Max work item sizes: ( 1024, 1024, 1024 ) Max work group size: 1024 Max clock requency: 3005 MHz Address bits: 32 Max mem alloc size: 512 MB Image support: FALSE Max parameter size: 4096 byte Mem base addr align: 1024 bit Min data type align size: 128 byte Denorms supported: TRUE INF and quiet NaNs supported: TRUE Round to nearest supported: TRUE Round to zero supported: FALSE Round to +/- inf supported: FALSE IEEE754-2008 FMA supported: FALSE Global mem cache type: Read and Write Size of global mem cache line: 64 byte Size of global mem cache: 64 KB Global mem size: 1024 MB Max size of a const buff alloc: 64 KB Max number of const args: 8 Local memory type: Global Local memory size: 32 KB Error correction support: FALSE Resolution of device timer: 1 nanosec Litle endian device: TRUE Device available: TRUE Compiler available: TRUE Can execute OpenCL kernels: TRUE Can execute native kernels: FALSE Out of order exec enabled: FALSE Queue profiling enabled: TRUE Associated platform: ATI Stream Device name: Intel(R) Core(TM)2 Duo CPU E8400 @ 3.00GHz Vendor: GenuineIntel Driver version: 1.0 Supported profile: FULL_PROFILE Supported OpenCL version: OpenCL 1.0 ATI-Stream-v2.0-beta4 Extensions: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store Context reference count: 1 Device #2: GPU Vendor ID: 4098 Max compute units: 10 Max work item dimensions: 3 Max work item sizes: ( 256, 256, 256 ) Max work group size: 256 Max clock requency: 625 MHz Address bits: 32 Max mem alloc size: 128 MB Image support: FALSE Max parameter size: 1024 byte Mem base addr align: 32768 bit Min data type align size: 128 byte Denorms supported: FALSE INF and quiet NaNs supported: TRUE Round to nearest supported: TRUE Round to zero supported: FALSE Round to +/- inf supported: FALSE IEEE754-2008 FMA supported: FALSE Global mem cache type: None Size of global mem cache line: 0 byte Size of global mem cache: 0 KB Global mem size: 128 MB Max size of a const buff alloc: 64 KB Max number of const args: 8 Local memory type: Global Local memory size: 16 KB Error correction support: FALSE Resolution of device timer: 1 nanosec Litle endian device: TRUE Device available: TRUE Compiler available: TRUE Can execute OpenCL kernels: TRUE Can execute native kernels: FALSE Out of order exec enabled: FALSE Queue profiling enabled: TRUE Associated platform: ATI Stream Device name: ATI RV770 Vendor: Advanced Micro Devices, Inc. Driver version: CAL 1.4.467 Supported profile: FULL_PROFILE Supported OpenCL version: OpenCL 1.0 ATI-Stream-v2.0-beta4 Extensions: Context reference count: 1

0 Likes

cl_uint num_entries=10;//in your code this should be 1
cl_platform_id platforms[10]; //make array of ten paltform id
cl_uint num_platforms;
clGetPlatformIDs(num_entries, platforms, &num_platforms);

0 Likes
Stib
Journeyman III

The 10 is fine, it means, that up to 10 available platforms can be added, to the list. The thing with the array works not, tried it.

0 Likes

how do you mean it didnt work? currently you can obtain only one platform even if you have for example ATi and nvidia card in system.

0 Likes
Stib
Journeyman III

Even if i can only get 1 platform, the code should work, only for one. But when i tested it, my program crashed. It does not work with arrays, or i do not know.

 

UPDATE: I tryed again, and it seems to work now, but it did not worked earlyer...interesting.

So, thanx for the help with the first issue nou!

*beer*


 

And the other issue with the Vendor IDs?

And if i have cl_command_queue_properties, how can i view what it contains? How do i know what property to change, when i do not know the status of them? cout chrashes, and i did not found a function to view it.

0 Likes
Stib
Journeyman III

And here is the next!

#define __CL_ENABLE_EXCEPTIONS #include <CL/cl.hpp> #include <cstdlib> #include <iostream> int main() {... cl::CommandQueue cq=cl::CommandQueue(context,devices[0]); cl_int err=CL_SUCCESS; try { err=cq.setProperty(CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,CL_TRUE); } catch(cl::Error err) { std::cerr << err.what() << "\t" << err.err() << std::endl; } } What is wrong with the code above? It's only a part of the whole, but everything else works fine. It builds, and by running, it crashes.

0 Likes

i think reason that vendor id is same for GPU and CPU even if its intel processor is that implemntation of OpenCL is from AMD so it return AMD vedor id.

cl_command_queue_propertis which is cl_bitfield which is cl_ulong which is 64 bit unigned int. so cout should print out it.

if(com_queue_prop & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE)cout << "out of order is enabled";

0 Likes
Stib
Journeyman III

THX again! It is great, that here i can ask, and learn!

I found to the exception thing this:

"warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)"

Could be the source of the problem this?

 

UPDATE: I found out, that i get random chrashes, by running my application. This explains that some of your solutions seemed not to work for me earlyer. Can it be because OpenCL is only beta??

UPDATE2: It works now. I dont know why, but it does. I did not do anything...

0 Likes

you must track down where it is crash. i dont help you with C++ binding.

0 Likes
Stib
Journeyman III

Thank you nou for all your help!

"UPDATE2: It works now. I dont know why, but it does. I did not do anything..."

I think i got the source of the mysterious crash:

I experimented with this part of the code: cl_uint num_entries=10; cl_platform_id platforms[10]; cl_uint num_platforms; clGetPlatformIDs(num_entries, platforms, &num_platforms); I modyfied it to: cl_uint num_entries=10; cl_platform_id *platforms; cl_uint num_platforms; clGetPlatformIDs(num_entries, platforms, &num_platforms); It worked for a time, then nothing. I HATE pointers! 😄

0 Likes

no wonder it crash. you create "wild" pointer that point to random place in memory.

0 Likes
Stib
Journeyman III

I tought, that the function allocates the memory space for himself, copy the result, and gives only the pointer back. But if i know, that i MUST allocate the memory space i want to use, it all gives sense. I try to learn from Khronos's OpenCL specification 1.0 Rev.:43, opencl 1.0 c++ bindings Documentation, and from sample codes. It is not easy, with my not so good english skills, and C++ is new too for me. I learned ANSI C at the University, and i forgot many things by the time. The pointers are the hardest part from all...

Anyways, i see a future for OpenCL, i hope i'm right, and it is worth for me to learn it now. I read the discussion in the other topic, that OpenCL is slow compared to other Computing languages. I hope this will improve, because OpenCL did amaze me with its performance (i did not even heard of CUDA, or Brook+ up to that point). I want to use it on high performance level, and i do not would like to learn a "better" language for that.

Huh. So much OFF... Sorry.

0 Likes

Great thread

Know I knew where to start

0 Likes

I tryed the sample program HelloCL. In its original form, it builds, and runs as it should. But when i changed the device type to be used, i got an error while running.

 

I changed this cl::Context context(CL_DEVICE_TYPE_CPU, 0, NULL, NULL, &err); into this cl::Context context(CL_DEVICE_TYPE_GPU, 0, NULL, NULL, &err); By the run i got: HelloCL! Creating a context Getting device info Loading and compiling CL source Program::build() failed (-11) Error -11 is CL_BUILD_PROGRAM_FAILURE. Why do i get it? What could be the problem?

0 Likes
Stib
Journeyman III

Another issue:

 

I copyed this: std::cout<<"Loading and compiling CL source\n"; streamsdk::SDKFile file; if (!file.open("HelloCL_Kernels.cl")) { std::cerr << "We couldn't load CL source code\n"; return SDK_FAILURE; } from HelloCL into my test application on wich i'm trying things, and learning. I included exact the same libraries as in HelloCL. When i try to build the application, i get: "error LNK2001: unresolved external symbol "public: bool __thiscall streamsdk::SDKFile::open(char const *)" (?open@SDKFile@streamsdk@@QAE_NPBD@Z)" Why do i get it, when by HelloCL not??

0 Likes
Stib
Journeyman III

Still nothing??

0 Likes

Originally posted by: Stib I tryed the sample program HelloCL. In its original form, it builds, and runs as it should. But when i changed the device type to be used, i got an error while running.

  Error -11 is CL_BUILD_PROGRAM_FAILURE. Why do i get it? What could be the problem?

Do check the buildlog in case of clBuildProgram failures, using clGetProgramBuildInfo API call.

Originally posted by: Stib Another issue:

 

  from HelloCL into my test application on wich i'm trying things, and learning. I included exact the same libraries as in HelloCL. When i try to build the application, i get:

"error LNK2001: unresolved external symbol "public: bool __thiscall streamsdk::SDKFile:pen(char const *)" (?open@SDKFile@streamsdk@@QAE_NPBD@Z)"

Why do i get it, when by HelloCL not??

 

Have you included SDKUtil.lib in linker options?

0 Likes

I checked the buildlog, it says : Link failed

Ihope this is the information you wanted.

By the other program, i added by the Additional Library Directories:

"C:\Users\Stib\Documents\ATI Stream\lib\x86_64"

And by Input->Additional Dependencies i added SDKUtil.lib

I still get:

"error LNK2001: unresolved external symbol "public: bool __thiscall streamsdk::SDKFile::open(char const *)" (?open@SDKFile@streamsdk@@QAE_NPBD@Z)"

0 Likes
Stib
Journeyman III

I played a bit with the libraries by my test program.

At first, i tried x86_64 directories, but they semmed not to work. Interesting, because my E8400 should be an X64 architecture.

Now, with the x86 (only) directories, i get a whole new world of error messages...

 

Instead: "error LNK2001: unresolved external symbol "public: bool __thiscall streamsdk::SDKFile::open(char const *)" (?open@SDKFile@streamsdk@@QAE_NPBD@Z)" I get now: "1>Linking... 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: static bool __cdecl std::char_traits<char>::eq_int_type(int const &,int const &)" (?eq_int_type@?$char_traits@D@std@@SA_NABH0@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: static int __cdecl std::char_traits<char>::eof(void)" (?eof@?$char_traits@D@std@@SAHXZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: __thiscall std::_Container_base_secure::_Container_base_secure(void)" (??0_Container_base_secure@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: void __thiscall std::_Container_base_secure::_Orphan_all(void)const " (?_Orphan_all@_Container_base_secure@std@@QBEXXZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: bool __thiscall std::ios_base::good(void)const " (?good@ios_base@std@@QBE_NXZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: int __thiscall std::ios_base::flags(void)const " (?flags@ios_base@std@@QBEHXZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: class std::basic_streambuf<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " (?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Unlock(void)" (?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " (?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Lock(void)" (?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: __thiscall std::_Container_base_secure::~_Container_base_secure(void)" (??1_Container_base_secure@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(char const *)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>SDKUtil.lib(SDKFile.obj) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::_Container_base_secure::_Orphan_all(void)const " (?_Orphan_all@_Container_base_secure@std@@QBEXXZ) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::_Container_base_secure::~_Container_base_secure(void)" (??1_Container_base_secure@std@@QAE@XZ) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: static bool __cdecl std::char_traits<char>::eq_int_type(int const &,int const &)" (?eq_int_type@?$char_traits@D@std@@SA_NABH0@Z) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: static int __cdecl std::char_traits<char>::eof(void)" (?eof@?$char_traits@D@std@@SAHXZ) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_streambuf<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " (?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::ios_base::flags(void)const " (?flags@ios_base@std@@QBEHXZ) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " (?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: bool __thiscall std::ios_base::good(void)const " (?good@ios_base@std@@QBE_NXZ) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Lock(void)" (?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Unlock(void)" (?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(char const *)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::_Container_base_secure::_Container_base_secure(void)" (??0_Container_base_secure@std@@QAE@XZ) already defined in SDKUtil.lib(SDKFile.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::locale::facet * __thiscall std::locale::facet::_Decref(void)" (?_Decref@facet@locale@std@@QAEPAV123@XZ) already defined in SDKUtil.lib(SDKFile.obj) 1>libcpmtd.lib(locale0.obj) : error LNK2005: "void __cdecl _AtModuleExit(void (__cdecl*)(void))" (?_AtModuleExit@@YAXP6AXXZ@Z) already defined in msvcprtd.lib(locale0_implib.obj) 1>libcpmtd.lib(locale0.obj) : error LNK2005: __Fac_tidy already defined in msvcprtd.lib(locale0_implib.obj) 1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static void __cdecl std::locale::facet::facet_Register(class std::locale::facet *)" (?facet_Register@facet@locale@std@@CAXPAV123@@Z) already defined in msvcprtd.lib(locale0_implib.obj) 1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(void)" (?_Init@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmtd.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmtd.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)" (?_Locinfo_dtor@_Locinfo@std@@SAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmtd.lib(ios.obj) : error LNK2005: "private: static void __cdecl std::ios_base::_Ios_base_dtor(class std::ios_base *)" (?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmtd.lib(ios.obj) : error LNK2005: "public: static void __cdecl std::ios_base::_Addstd(class std::ios_base *)" (?_Addstd@ios_base@std@@SAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>LIBCMTD.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __CrtSetCheckCount already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMTD.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(invarg.obj) : error LNK2005: __invalid_parameter already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined in MSVCRTD.lib(crtexe.obj) 1>LIBCMTD.lib(errmode.obj) : error LNK2005: ___set_app_type already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(dbgrptw.obj) : error LNK2005: __CrtDbgReportW already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(fflush.obj) : error LNK2005: _fflush already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library 1>LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library 1>C:\Users\Stib\Documents\Visual Studio 2008\Projects\Test\Debug\Test.exe : fatal error LNK1169: one or more multiply defined symbols found"

0 Likes

Could you post the complete source code?

0 Likes

Sure!

First, my modyfied HelloCL

#include <CL/cl.hpp> #include <cstdio> #include <cstdlib> #include <iostream> #include <SDKUtil/SDKFile.hpp> #include <SDKUtil/SDKCommon.hpp> int main() { cl_int err; std::cout<<"HelloCL!\nCreating a context\n"; cl::Context context(CL_DEVICE_TYPE_GPU, 0, NULL, NULL, &err); if (err != CL_SUCCESS) { std::cerr << "Context::Context() failed (" << err << ")\n"; return SDK_FAILURE; } std::cout<<"Getting device info\n"; std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>(); if (err != CL_SUCCESS) { std::cerr << "Context::getInfo() failed (" << err << ")\n"; return SDK_FAILURE; } if (devices.size() == 0) { std::cerr << "No device available\n"; return SDK_FAILURE; } std::cout<<"Loading and compiling CL source\n"; streamsdk::SDKFile file; if (!file.open("HelloCL_Kernels.cl")) { std::cerr << "We couldn't load CL source code\n"; return SDK_FAILURE; } cl::Program::Sources sources( 1, std::make_pair(file.source().data(), file.source().size())); cl::Program* pProgram; pProgram = new cl::Program(context, sources); if (err != CL_SUCCESS) { std::cerr << "Program::Program() failed (" << err << ")\n"; return SDK_FAILURE; } cl::Program& program = *pProgram; err = program.build(devices); if (err != CL_SUCCESS) { std::cerr << "Program::build() failed (" << err << ")\n"; cl_build_status bs=program.getBuildInfo<CL_PROGRAM_BUILD_STATUS>(devices[0]); std::cout << "Build status:\t"; switch(bs) { case CL_BUILD_NONE: std::cout << "None\n"; break; case CL_BUILD_ERROR: std::cout << "Build error\n"; break; case CL_BUILD_SUCCESS: std::cout << "Success\n"; break; case CL_BUILD_IN_PROGRESS: std::cout << "Build in progress\n"; default: std::cout << "ERROR\n"; break; } std::cout << "Build options:\t" << program.getBuildInfo<CL_PROGRAM_BUILD_OPTIONS>(devices[0]) << std::endl; std::cout << "Build log:\t" << program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(devices[0]) << std::endl; return SDK_FAILURE; } cl::Kernel kernel(program, "hello", &err); if (err != CL_SUCCESS) { std::cerr << "Kernel::Kernel() failed (" << err << ")\n"; return SDK_FAILURE; } if (err != CL_SUCCESS) { std::cerr << "Kernel::setArg() failed (" << err << ")\n"; return SDK_FAILURE; } cl::CommandQueue queue(context, devices[0], 0, &err); if (err != CL_SUCCESS) { std::cerr << "CommandQueue::CommandQueue() failed (" << err << ")\n"; } std::cout<<"Running CL program\n"; err = queue.enqueueNDRangeKernel( kernel, cl::NullRange, cl::NDRange(4, 4), cl::NDRange(2, 2) ); if (err != CL_SUCCESS) { std::cerr << "CommandQueue::enqueueNDRangeKernel()" \ " failed (" << err << ")\n"; return SDK_FAILURE; } err = queue.finish(); if (err != CL_SUCCESS) { std::cerr << "Event::wait() failed (" << err << ")\n"; } delete pProgram; std::cout<<"Done\nPassed!\n"; return SDK_SUCCESS; }

0 Likes
Stib
Journeyman III

Second, my learning project's source, Proba:

#include <CL/cl.hpp> #include <cstdlib> #include <iostream> #include <cstdio> #include <SDKUtil/SDKFile.hpp> #include <SDKUtil/SDKCommon.hpp> int main() { cl_uint num_entries=10; cl_platform_id platforms[10]; cl_uint num_platforms; clGetPlatformIDs(num_entries, platforms, &num_platforms); std::cout << "\n\nAvailable platforms:\t\t" << num_platforms << std::endl << std::endl; cl::Platform platform = cl::Platform(platforms[0]); std::cout << "Platform profile:\t\t" << platform.getInfo<CL_PLATFORM_PROFILE>() << std::endl; std::cout << "Platform version:\t\t" << platform.getInfo<CL_PLATFORM_VERSION>() << std::endl; std::cout << "Platform name:\t\t\t" << platform.getInfo<CL_PLATFORM_NAME>() << std::endl; std::cout << "Platform vendor:\t\t" << platform.getInfo<CL_PLATFORM_VENDOR>() << std::endl; std::cout << "Platform extensions:\t" << platform.getInfo<CL_PLATFORM_EXTENSIONS>() << std::endl; cl::Context context = cl::Context(CL_DEVICE_TYPE_ALL); std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>(); std::cout << std::endl << "Number of devices:\t\t" << devices.size() << std::endl << std::endl; for(unsigned int i=0;i<devices.size();++i) { cl::Device dev = devices; cl_device_type p; dev.getInfo(CL_DEVICE_TYPE,&p); std::cout << "Device #" << i+1 << ":\t\t\t"; switch(p) { case CL_DEVICE_TYPE_CPU: std::cout << "CPU\n"; break; case CL_DEVICE_TYPE_GPU: std::cout << "GPU\n"; break; default: std::cout << "UNKNOWN\n"; } std::cout << "Vendor ID:\t\t\t" << dev.getInfo<CL_DEVICE_VENDOR_ID>() << std::endl; std::cout << "Max compute units:\t\t" << dev.getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>() << std::endl; std::cout <<"Max work item dimensions:\t" << dev.getInfo<CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS>() << std::endl; size_t size[3]; dev.getInfo(CL_DEVICE_MAX_WORK_ITEM_SIZES,&size); std::cout << "Max work item sizes:\t\t" << "( " << size[0] << ", " << size[1] << ", " << size[2] << " )\n"; std::cout << "Max work group size:\t\t" << dev.getInfo<CL_DEVICE_MAX_WORK_GROUP_SIZE>() << std::endl; std::cout << "Max clock requency:\t\t" << dev.getInfo<CL_DEVICE_MAX_CLOCK_FREQUENCY>() << " MHz\n"; std::cout << "Address bits:\t\t\t" << dev.getInfo<CL_DEVICE_ADDRESS_BITS>() << std::endl; std::cout << "Max mem alloc size:\t\t" << dev.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()/1024/1024 << " MB\n"; std::cout << "Image support:\t\t\t"; if(dev.getInfo<CL_DEVICE_IMAGE_SUPPORT>()==CL_TRUE) { std::cout << "TRUE\n"; } else { std::cout << "FALSE\n"; } std::cout << "Max parameter size:\t\t" << dev.getInfo<CL_DEVICE_MAX_PARAMETER_SIZE>() << " byte\n"; std::cout << "Mem base addr align:\t\t" << dev.getInfo<CL_DEVICE_MEM_BASE_ADDR_ALIGN>() << " bit\n"; std::cout << "Min data type align size:\t" << dev.getInfo<CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE>() << " byte\n"; cl_device_fp_config fp_conf=dev.getInfo<CL_DEVICE_SINGLE_FP_CONFIG>(); std::cout << "Denorms supported:\t\t"; if(fp_conf&CL_FP_DENORM) { std::cout << "TRUE\n"; } else { std::cout << "FALSE\n"; } std::cout << "INF and quiet NaNs supported:\t"; if(fp_conf&CL_FP_INF_NAN) { std::cout << "TRUE\n"; } else { std::cout << "FALSE\n"; } std::cout << "Round to nearest supported:\t"; if(fp_conf&CL_FP_ROUND_TO_NEAREST) { std::cout << "TRUE\n"; } else { std::cout << "FALSE\n"; } std::cout << "Round to zero supported:\t"; if(fp_conf&CL_FP_ROUND_TO_ZERO) { std::cout << "TRUE\n"; } else { std::cout << "FALSE\n"; } std::cout << "Round to +/- inf supported:\t"; if(fp_conf&CL_FP_ROUND_TO_INF) { std::cout << "TRUE\n"; } else { std::cout << "FALSE\n"; } std::cout << "IEEE754-2008 FMA supported:\t"; if(fp_conf&CL_FP_FMA) { std::cout << "TRUE\n"; } else { std::cout << "FALSE\n"; } cl_device_mem_cache_type cache_type=dev.getInfo<CL_DEVICE_GLOBAL_MEM_CACHE_TYPE>(); std::cout << "Global mem cache type:\t\t"; switch(cache_type) { case CL_NONE: std::cout << "None\n"; break; case CL_READ_ONLY_CACHE: std::cout << "Read only\n"; break; case CL_READ_WRITE_CACHE: std::cout << "Read and Write\n"; break; default: std::cout << "ERROR\n"; } std::cout << "Size of global mem cache line:\t" << dev.getInfo<CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE>() << " byte\n"; std::cout << "Size of global mem cache:\t" << dev.getInfo<CL_DEVICE_GLOBAL_MEM_CACHE_SIZE>()/1024 << " KB\n"; std::cout << "Global mem size:\t\t" << dev.getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>()/1024/1024 << " MB\n"; std::cout << "Max size of a const buff alloc:\t" << dev.getInfo<CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE>()/1024 << " KB\n"; std::cout << "Max number of const args:\t" << dev.getInfo<CL_DEVICE_MAX_CONSTANT_ARGS>() << std::endl; std::cout << "Local memory type:\t\t"; cl_device_local_mem_type mem_type=dev.getInfo<CL_DEVICE_LOCAL_MEM_TYPE>(); switch(mem_type) { case CL_LOCAL: std::cout << "Local\n"; break; case CL_GLOBAL: std::cout << "Global\n"; break; default: std::cout << "ERROR\n"; break; } std::cout << "Local memory size:\t\t" << dev.getInfo<CL_DEVICE_LOCAL_MEM_SIZE>()/1024 << " KB\n"; std::cout << "Error correction support:\t"; if(dev.getInfo<CL_DEVICE_ERROR_CORRECTION_SUPPORT>()==CL_TRUE) { std::cout << "TRUE\n"; } else { std::cout << "FALSE\n"; } std::cout << "Resolution of device timer:\t" << dev.getInfo<CL_DEVICE_PROFILING_TIMER_RESOLUTION>() << " nanosec\n"; std::cout << "Litle endian device:\t\t"; if(dev.getInfo<CL_DEVICE_ENDIAN_LITTLE>()==CL_TRUE) { std::cout << "TRUE\n"; } else { std::cout << "FALSE\n"; } std::cout << "Device available:\t\t"; if(dev.getInfo<CL_DEVICE_AVAILABLE>()==CL_TRUE) { std::cout << "TRUE\n"; } else { std::cout << "FALSE\n"; } std::cout << "Compiler available:\t\t"; if(dev.getInfo<CL_DEVICE_COMPILER_AVAILABLE>()==CL_TRUE) { std::cout << "TRUE\n"; } else { std::cout << "FALSE\n"; } cl_device_exec_capabilities exec_cap=dev.getInfo<CL_DEVICE_EXECUTION_CAPABILITIES>(); std::cout << "Can execute OpenCL kernels:\t"; if(exec_cap&CL_EXEC_KERNEL) { std::cout << "TRUE\n"; } else { std::cout << "FALSE\n"; } std::cout << "Can execute native kernels:\t"; if(exec_cap&CL_EXEC_NATIVE_KERNEL) { std::cout << "TRUE\n"; } else { std::cout << "FALSE\n"; } cl_command_queue_properties queue_prop=dev.getInfo<CL_DEVICE_QUEUE_PROPERTIES>(); std::cout << "Out of order exec enabled:\t"; if(queue_prop&CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) { std::cout << "TRUE\n"; } else { std::cout << "FALSE\n"; } std::cout << "Queue profiling enabled:\t"; if(queue_prop&CL_QUEUE_PROFILING_ENABLE) { std::cout << "TRUE\n"; } else { std::cout << "FALSE\n"; } std::cout << "Associated platform:\t\t" << cl::Platform(dev.getInfo<CL_DEVICE_PLATFORM>()).getInfo<CL_PLATFORM_NAME>() << std::endl; std::cout << "Device name:\t\t\t" << dev.getInfo<CL_DEVICE_NAME>() << std::endl; std::cout << "Vendor:\t\t\t\t" << dev.getInfo<CL_DEVICE_VENDOR>() << std::endl; std::cout << "Driver version:\t\t\t" << dev.getInfo<CL_DRIVER_VERSION>() << std::endl; std::cout << "Supported profile:\t\t" << dev.getInfo<CL_DEVICE_PROFILE>() << std::endl; std::cout << "Supported OpenCL version:\t" << dev.getInfo<CL_DEVICE_VERSION>() << std::endl; std::cout << "Extensions:\t\t\t" << dev.getInfo<CL_DEVICE_EXTENSIONS>() << std::endl; std::cout << std::endl << std::endl; std::cout << "Context reference count:\t" << context.getInfo<CL_CONTEXT_REFERENCE_COUNT>() << std::endl; } cl::CommandQueue cq=cl::CommandQueue(context,devices[0]); //cq.setProperty(CL_QUEUE_PROFILING_ENABLE,CL_TRUE); //cl_command_queue_properties cqp=cq.getInfo<CL_QUEUE_PROPERTIES>(); //if(cqp&CL_QUEUE_PROFILING_ENABLE)std::cout << "profiling enabled\n"; std::cout<<"Loading and compiling CL source\n"; streamsdk::SDKFile file; if (!file.open("HelloCL_Kernels.cl")) { std::cerr << "We couldn't load CL source code\n"; return SDK_FAILURE; } }

0 Likes

Originally posted by: Stib I played a bit with the libraries by my test program.

 

At first, i tried x86_64 directories, but they semmed not to work. Interesting, because my E8400 should be an X64 architecture. Now, with the x86 (only) directories, i get a whole new world of error messages...

 

You get those errors because SDKUtil.lib was compiled with a different runtime library flag than you are currently using in your project. (It was actually compiled with static runtime library flag and you are probably using dynamic library)

See property sheets(vprops files) to get the required runtime library flag.

0 Likes

It is not easy to learn this all. Thank you all, that you have patiance with my noobness, and for all your help!

0 Likes
Stib
Journeyman III

How can i get:

"Loading and compiling CL source
Program::build() failed (-11)
Build status:    Success
Build options:   
Build log:   
"

?? Can it be the error HelloCL is producing also?

The end of my code:

std::cout<<"Loading and compiling CL source\n"; streamsdk::SDKFile file; if (!file.open("HelloCL_Kernels.cl")) { std::cerr << "We couldn't load CL source code\n"; return SDK_FAILURE; } cl_int err=CL_SUCCESS; cl::Program::Sources sources(1, std::make_pair(file.source().data(), file.source().size())); cl::Program* pProgram; pProgram = new cl::Program(context, sources); if (err != CL_SUCCESS) { std::cerr << "Program::Program() failed (" << err << ")\n"; return SDK_FAILURE; } cl::Program& program = *pProgram; err = program.build(devices); if (err != CL_SUCCESS) { std::cout << "Program::build() failed (" << err << ")\n"; cl_build_status bs=program.getBuildInfo<CL_PROGRAM_BUILD_STATUS>(devices[0]); std::cout << "Build status:\t"; switch(bs) { case CL_BUILD_NONE: std::cout << "None\n"; break; case CL_BUILD_ERROR: std::cout << "Build error\n"; break; case CL_BUILD_SUCCESS: std::cout << "Success\n"; break; case CL_BUILD_IN_PROGRESS: std::cout << "Build in progress\n"; default: std::cout << "ERROR\n"; break; } std::cout << "Build options:\t" << program.getBuildInfo<CL_PROGRAM_BUILD_OPTIONS>(devices[0]) << std::endl; std::cout << "Build log:\t" << program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(devices[0]) << std::endl; return SDK_FAILURE; }

0 Likes
Stib
Journeyman III

Got it. I was the moron, for questioning the CPU Instead of the GPU...sorry.

And its the same as by HelloCL. Then, continue learning with CPU, and waiting for update...

0 Likes
Stib
Journeyman III

See below...

std::cout << "Kernel work group size:\t" << kernel.getWorkGroupInfo<CL_KERNEL_WORK_GROUP_SIZE>() << std::endl; By building i get: 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3153) : error C2780: 'detail::param_traits<cl::detail::cl_kernel_work_group_info,name>::param_type cl::Kernel::getWorkGroupInfo(cl_int *) const' : expects 1 arguments - 2 provided 1> C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3149) : see declaration of 'cl::Kernel::getWorkGroupInfo' 1> .\Proba.cpp(351) : see reference to function template instantiation 'cl::detail::param_traits<cl::detail::cl_kernel_work_group_info,4528>::param_type cl::Kernel::getWorkGroupInfo<4528>(cl_int *) const' being compiled 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3153) : error C2780: 'cl_int cl::Kernel::getWorkGroupInfo(const cl::Device &,cl_kernel_work_group_info,T *) const' : expects 3 arguments - 2 provided 1> C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3120) : see declaration of 'cl::Kernel::getWorkGroupInfo' Does this querie not work as the others? What is the missing parameter?

0 Likes
Stib
Journeyman III

The question still remains...

0 Likes
Stib
Journeyman III

Does no answer exist?

0 Likes

Note the correct usage of getWorkgroupInfo function :

syntax : cl_int cl::Kernel::GetWorkGroupInfo<typename T>(const cl::Device &device, cl_kernel_work_group_info name, T* param) Example : cl_int err; int workGroupSize; err = kernel.getWorkGroupInfo<int>(devices[0], CL_KERNEL_WORK_GROUP_SIZE, &workGroupSize);

0 Likes

Thank you, but that was not the answer i was looking for. If you look, i tried to use the ANOTHER functor!

syntax: detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type cl::Kernel::getWorkGroupInfo(const Device& device, cl_int* err = NULL) Example: ???

0 Likes
Stib
Journeyman III

I think i found the problems source.

My cl.hhp seems not up to date. At the head of the file, both say: * \brief C++ bindings for OpenCL 1.0 (rev 45) * \author Benedict R. Gaster and Laurent Morichetti * \version 0.3 * \date July 2009 But for some reason, in my cl.hhp instead detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type getWorkGroupInfo(const Device& device, cl_int* err = NULL) i have detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type getWorkGroupInfo(cl_int* err = NULL) I replace the lib, and try it.

0 Likes
Stib
Journeyman III

It works now.

syntax: detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type getWorkGroupInfo(const Device& device, cl_int* err = NULL) Example: std::cout << "Kernel work group size:\t" << kernel.getWorkGroupInfo<CL_KERNEL_WORK_GROUP_SIZE>(devices[0]) << std::endl;

0 Likes