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

The next issue:

std::cout << "Kernel local mem size:\t" << kernel.getWorkGroupInfo<CL_KERNEL_LOCAL_MEM_SIZE>(devices[0]) << " byte\n"; This should work, but by building i get: 1>.\Proba.cpp(355) : error C2770: invalid explicit template argument(s) for 'detail::param_traits<cl::detail::cl_kernel_work_group_info,name>::param_type cl::Kernel::getWorkGroupInfo(const cl::Device &,cl_int *) const' 1> C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3170) : see declaration of 'cl::Kernel::getWorkGroupInfo' 1>.\Proba.cpp(355) : error C2780: 'cl_int cl::Kernel::getWorkGroupInfo(const cl::Device &,cl_kernel_work_group_info,T *) const' : expects 3 arguments - 1 provided 1> C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3141) : see declaration of 'cl::Kernel::getWorkGroupInfo'

0 Likes
Stib
Journeyman III

I have created my first tutorial kernel, and tried to run it on both CPU and GPU. I post the results, and the kernel itself. It is not what it should be i think.

 

 

kernel: #pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable __constant char hw[] = "Hello World\n"; __kernel void hello(__global char * out) { size_t tid = get_global_id(0); out[tid] = hw[tid]; } The output from my application: Loading and compiling CL source Kernel Function name: hello Number of kernel args: 1 Kernel reference count: 1 Device #1 Kernel max work group size: 1024 Kernel compile work group size: ( 0, 0, 0 ) Profiling enabled Running CL program Hello World 'hello' run time: 10902 nanosec Device #2 Kernel max work group size: 64 Kernel compile work group size: ( 0, 0, 0 ) Profiling enabled Running CL program ???l???o??? ??'hello' run time: 23379 nanosec Done Passed!

0 Likes

You should check whether device #2 supports byte addressable stores or not.

0 Likes

Originally posted by: n0thing You should check whether device #2 supports byte addressable stores or not.

 

Yeah, you're right. My EAH4850 card seems not to support it.

And my other question? And the issue with the cl.hpp file?

0 Likes

I just checked, the flag : CL_KERNEL_LOCAL_MEM_SIZE is not defined in cl.hpp so the header actually corresponds to OpenCL specification revision 33. This flag was added in rev 43 of the spec.

0 Likes

Thank you again!

If i'm using cl.hpp rev. 45, why does it still not work? (i replaced the original with the one from Khronos OpenCL API registry)

And in my original version CL_KERNEL_LOCAL_MEM_SIZE was alredy defined. It had another issue, what i exploited in another topic, but i will copy it here too.

"At the beginning, there are some differencies, by the copyrights comments. But because they are comments, its nothing in particular. The next, and first issue is: Khronos, row 3146: &::clGetKernelWorkGroupInfo, object_, device(), name, param), Stream, row 3125: &::clGetKernelWorkGroupInfo, device(), object_, name, param), The order of the arguments is not exact the same. I don't really know if it matters or not, but i thought i mention it... And the next, and last issue is (surprise), with one of the getWorkGroupInfo functors: Khronos, starting at row 3169: detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type getWorkGroupInfo(const Device& device, cl_int* err = NULL) const { typename detail::param_traits< detail::cl_kernel_work_group_info, name>::param_type param; cl_int result = getWorkGroupInfo(device, name, &param); if (err != NULL) { *err = result; } return param; } And Stream, starting at row 3148: detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type getWorkGroupInfo(cl_int* err = NULL) const { typename detail::param_traits< detail::cl_kernel_work_group_info, name>::param_type param; cl_int result = getWorkGroupInfo(name, &param); if (err != NULL) { *err = result; } return param; } I hope this helps to correct this error in the future relases of Stream 2.0! "

0 Likes

Hi Stib,

The issue has been reported our developers and you can expect to see these fixed in an upcoming release. Thanks for reporting.

0 Likes

Originally posted by: Stib I checked the buildlog, it says : Link failed

 

 

HelloCL sample is having issues running with GPU, this has been reported to the developers and they are fixing it. You can expect it to be working on an upcoming refresh.

0 Likes

Originally posted by: omkaranathan
Originally posted by: Stib I checked the buildlog, it says : Link failed

 

 

 

 

 

 

HelloCL sample is having issues running with GPU, this has been reported to the developers and they are fixing it. You can expect it to be working on an upcoming refresh.

 

 

OK, Thanks for the info! And my own application Test? (in previous post alias Proba)

The problem seems to be with the code at the end, what i copied from HelloCL.

0 Likes

The code is fine, it compiles fine for me. Can you compare the project properties with that of the samples coming with the SDK and make sure that you have not set any of the properties wrong? 

0 Likes

I used BitonicSort for sample. The things i found different:

Conf. Prop. -> General Inherited Project Property Sheets empty by me Character Set Use Unicode Character Set by me ->C/C++ -->General Additional Include Diractories empty by sample Debug Information Format Program Database (/Zi) by me Warning Level Level 3 (/W3) by me -->Preprocessor Preprocessor Definitions WIN32;NDEBUG;_CONSOLE by sample -->Command Line /O2 /Oi /GL /I "C:\Program Files (x86)\ATI Stream\include" /I "C:\Users\Stib\Documents\ATI Stream\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FD /EHsc /MD /Gy /Fo"Release\\" /Fd"Release\vc90.pdb" /W3 /nologo /c /Zi /TP /errorReport:prompt by me ->Linker -->General Enable Invremental Linking No (/INCREMENTAL:NO) by me Additional Library Directories empty by sample -->Input Additional Dependencies empty by sample -->System SubSystem Console (/SUBSYSTEM:CONSOLE) by me -->Optimization References Eliminate Unreferenced Data (/OPT:REF) by me Enable COMDAT Folding Remove Redundant COMDATs (/OPT:ICF) by me -->Command Line /OUT:"C:\Users\Stib\Documents\Visual Studio 2008\Projects\Test\Release\Test.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\Program Files (x86)\ATI Stream\lib\x86" /LIBPATH:"C:\Users\Stib\Documents\ATI Stream\lib\x86" /MANIFEST /MANIFESTFILE:"Release\Test.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Stib\Documents\Visual Studio 2008\Projects\Test\Release\Test.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT OpenCL.lib SDKUtil.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib by me ->Build Events ->Post-Build Event Command Line empty by me

0 Likes
Stib
Journeyman III

Did you set the last part of the code into comment? My code builds, and runs, if i do that, but if not, it gives the errors mentioned above.

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

Can you just replace the code in HelloCL sample with your code and check? Also while comparing, you will have to see the vsprops files under 'samples\opencl\common' directory for the properties of SDK samples. 

0 Likes

The code that gives the errors, is from HelloCL, so my code should work there. I check what you suggested.

I found a few interesting lines in openclsdk_debug.vsprops Optimization="0" (if this is what i think it is, i did set it to Disabled) BasicRuntimeChecks="3" (I set this to "Both (/RTC1, equiv. to /RTCsu)", i hope it is the 3) PreprocessorDefinitions="ATI_OS_WIN" (i did set this too) DebugInformationFormat="4" (I set this to "Program Database for Edit & Continue (/ZI)") RuntimeLibrary="1" (I did dont foud this, or i do not know what properti this is) The rest seems to be what by me is set.

0 Likes
Stib
Journeyman III

This is what i found. Maybe i create a new project with the vsprops, and see if my code works...

0 Likes

Try setting Runtime Library to multi-threaded debug (/MTd).

You can find this option in : project properties->C/C++->Code Generation

0 Likes

Originally posted by: n0thing Try setting Runtime Library to multi-threaded debug (/MTd).

 

You can find this option in : project properties->C/C++->Code Generation

 

 

That...WORKED! What did i just do? Could you try to explain it to me?

0 Likes