7 Replies Latest reply on May 14, 2010 8:53 AM by eldecog

    hello world example

    eldecog

      Hi

      I just started to learn opencl and I tryed to run the hello world example provided by Benedict Gaster.

      http://developer.amd.com/GPU/ATISTREAMSDK/pages/TutorialOpenCL.aspx

      but I got a compilation error

      no matching function for call to 'cl:latform::getInfo(int, std::string*)'

       

      note: candidates are: cl_int cl:latform::getInfo(cl_platform_info, cl::STRING_CLASS*) const

       

       

      I use ubuntu 10.04 with all the latest drivers  and software installed

      thank you

        • hello world example
          omkaranathan

           

          Modify the line 
          platformList[0].getInfo(CL_PLATFORM_VENDOR, &platformVendor);
          to
          platformList[0].getInfo((cl_platform_info)CL_PLATFORM_VENDOR, &platformVendor);
          Also remove the line #define __NO_STD_STRING added above.


            • hello world example
              eldecog

              ok thank you for this.

              Now it works better but I still have error for the last lines of the code:

               

              main.cpp:118: warning: ignoring #pragma OPENCL EXTENSION

              main.cpp:119: error: expected constructor, destructor, or type conversion before ‘char’

              main.cpp:120: error: expected constructor, destructor, or type conversion before ‘void’

               

               



              #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]; }

                • hello world example
                  omkaranathan

                  lesson1_kernels.cl is a separate file. You have included it in main.cpp it seems.

                    • hello world example
                      eldecog

                      right!!

                      I have now other problems:

                       

                      main.o: In function `cl::detail::ReferenceHandler<_cl_context*>::release(_cl_context*)': /usr/local/include/CL/cl.hpp:1085: undefined reference to `clReleaseContext' main.o: In function `cl::detail::ReferenceHandler<_cl_command_queue*>::release(_cl_command_queue*)': /usr/local/include/CL/cl.hpp:1094: undefined reference to `clReleaseCommandQueue' main.o: In function `cl::detail::ReferenceHandler<_cl_mem*>::retain(_cl_mem*)': /usr/local/include/CL/cl.hpp:1101: undefined reference to `clRetainMemObject' main.o: In function `cl::detail::ReferenceHandler<_cl_mem*>::release(_cl_mem*)': /usr/local/include/CL/cl.hpp:1103: undefined reference to `clReleaseMemObject' main.o: In function `cl::detail::ReferenceHandler<_cl_program*>::release(_cl_program*)': /usr/local/include/CL/cl.hpp:1121: undefined reference to `clReleaseProgram' main.o: In function `cl::detail::ReferenceHandler<_cl_kernel*>::release(_cl_kernel*)': /usr/local/include/CL/cl.hpp:1130: undefined reference to `clReleaseKernel' main.o: In function `cl::detail::ReferenceHandler<_cl_event*>::release(_cl_event*)': /usr/local/include/CL/cl.hpp:1139: undefined reference to `clReleaseEvent' main.o: In function `cl::Platform::getInfo(unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const': /usr/local/include/CL/cl.hpp:1392: undefined reference to `clGetPlatformInfo' main.o: In function `cl::Platform::get(cl::vector<cl::Platform, 10u>*)': /usr/local/include/CL/cl.hpp:1549: undefined reference to `clGetPlatformIDs' /usr/local/include/CL/cl.hpp:1556: undefined reference to `clGetPlatformIDs' main.o: In function `Context': /usr/local/include/CL/cl.hpp:1700: undefined reference to `clCreateContextFromType' main.o: In function `cl::Event::wait() const': /usr/local/include/CL/cl.hpp:2007: undefined reference to `clWaitForEvents' main.o: In function `Buffer': /usr/local/include/CL/cl.hpp:2206: undefined reference to `clCreateBuffer' main.o: In function `Program': /usr/local/include/CL/cl.hpp:3567: undefined reference to `clCreateProgramWithSource' main.o: In function `cl::Program::build(cl::vector<cl::Device, 10u> const&, char const*, void (*)(_cl_program*, void*), void*) const': /usr/local/include/CL/cl.hpp:3747: undefined reference to `clBuildProgram' main.o: In function `Kernel': /usr/local/include/CL/cl.hpp:3923: undefined reference to `clCreateKernel' main.o: In function `CommandQueue': /usr/local/include/CL/cl.hpp:3976: undefined reference to `clCreateCommandQueue' main.o: In function `cl::CommandQueue::enqueueReadBuffer(cl::Buffer const&, unsigned int, unsigned long, unsigned long, void*, cl::vector<cl::Event, 10u> const*, cl::Event*) const': /usr/local/include/CL/cl.hpp:4167: undefined reference to `clEnqueueReadBuffer' main.o: In function `cl::CommandQueue::enqueueNDRangeKernel(cl::Kernel const&, cl::NDRange const&, cl::NDRange const&, cl::NDRange const&, cl::vector<cl::Event, 10u> const*, cl::Event*) const': /usr/local/include/CL/cl.hpp:5114: undefined reference to `clEnqueueNDRangeKernel' main.o: In function `int cl::Kernel::setArg<cl::Buffer>(unsigned int, cl::Buffer)': /usr/local/include/CL/cl.hpp:3401: undefined reference to `clSetKernelArg' main.o: In function `int cl::Context::getInfo<cl::vector<cl::Device, 10u> >(unsigned int, cl::vector<cl::Device, 10u>*) const': /usr/local/include/CL/cl.hpp:1755: undefined reference to `clGetContextInfo' collect2: ld returned 1 exit status