Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: OpenCL initialisation problem on Ubuntu 12.04 (NVIDIA GS 7100 card)

  1. #1
    Member Regular Contributor
    Join Date
    Jan 2011
    Location
    Paris, France
    Posts
    250

    OpenCL initialisation problem on Ubuntu 12.04 (NVIDIA GS 7100 card)

    Hi, I have a problem with OpenCL on my Ubuntu 12.04 box and a NVIDIA 7100 GS card

    I use this very basic source :
    Code :
    #define CL_USE_DEPRECATED_OPENCL_1_1_APIS
    #include <CL/cl.h>
    #include <CL/cl.hpp>
     
     
    int main(int argc, char *argv[])
    {
        int err;
        cl_uint platforms;
        cl_platform_id platform = NULL;
        char cBuffer[1024];
     
     
        err = clGetPlatformIDs( 1, &platform, &platforms );
        if (err != CL_SUCCESS)
        {
            printf("Error in OpenCL call!\n");
            return EXIT_FAILURE;
        }
        printf("Number of platforms: %d\n", platforms);
     
     
        err = clGetPlatformInfo( platform, CL_PLATFORM_NAME, sizeof(cBuffer), cBuffer, NULL );
        if (err != CL_SUCCESS)
        {
            printf("Error in OpenCL call!\n");
            return EXIT_FAILURE;
        }
        printf("CL_PLATFORM_NAME :\t %s\n", cBuffer);
     
     
        err = clGetPlatformInfo( platform, CL_PLATFORM_VERSION,     sizeof(cBuffer), cBuffer, NULL );
        if (err != CL_SUCCESS)
        {
            printf("Error in OpenCL call!\n");
            return EXIT_FAILURE;
        }
        printf("CL_PLATFORM_VERSION :\t %s\n", cBuffer);
    }

    And compile it using this makefile :
    Code :
    all : test1
     
     
    test1 : test1.cpp
        g++ test1.cpp -L/etc/alternatives -lOpenCL -o test1
     
     
    clean : test1
        rm test1


    This compile "fine" (cf. only the CL_USE_DEPRECATED_OPENCL_1_1_APIS warning, but I have a lot of compilations errors without this ...)
    Code :
    yannoo@Ubuntoo:~/OPENCL/v2$ make
    g++ test1.cpp -L/etc/alternatives -lOpenCL -o test1
    In file included from /usr/include/CL/opencl.h:43:0,
                     from /usr/include/CL/cl.hpp:164,
                     from test1.cpp:6:
    /usr/include/CL/cl_gl.h:107:2: attention : #warning CL_USE_DEPRECATED_OPENCL_1_1_APIS is defined. These APIs are unsupported and untested in OpenCL 1.2! [-Wcpp]

    But when I run the executable, it's like it cannot find a valid OpenCL context
    Code :
    yannoo@Ubuntoo:~/OPENCL/v2$ ./test1
    Error in OpenCL call!

    => so the problem is here
    Code :
    err = clGetPlatformIDs( 1, &platform, &platforms );
     
    if (err != CL_SUCCESS)
    {
        printf("Error in OpenCL call!\n");
        return EXIT_FAILURE;
    }


    Note that I have the same type of error with another source lesson1.cpp :
    Code :
    #include <utility>
     
     
    #define __NO_STD_VECTOR // Use cl::vector instead of STL version
    #define CL_USE_DEPRECATED_OPENCL_1_1_APIS
    #include <CL/cl.h>
    #include <CL/cl.hpp>
     
     
    #include <cstdio>
    #include <cstdlib>
    #include <fstream>
    #include <iostream>
    #include <string>
    #include <iterator>
     
     
    const std::string hw("Hello World\n");
     
     
    inline void
    checkErr(cl_int err, const char * name)
    {
        if (err != CL_SUCCESS) {
            std::cerr << "ERROR : " << name
                     << " (" << err << ")" << std::endl;
            exit(EXIT_FAILURE);
        }
    }
     
     
    int
    main(void)
    {
        cl_int err;
        cl::vector< cl::Platform > platformList;
        cl::Platform::get(&platformList);
        checkErr(platformList.size()!=0 ? CL_SUCCESS : -1, "cl::Platform::get");
        std::cerr << "Platform number is: " << platformList.size() << std::endl;
     
        std::string platformVendor;
        platformList[0].getInfo((cl_platform_info)CL_PLATFORM_VENDOR, &platformVendor);
        std::cerr << "Platform is by: " << platformVendor << "\n";
        cl_context_properties cprops[3] = 
            {CL_CONTEXT_PLATFORM, (cl_context_properties)(platformList[0])(), 0};
     
        cl::Context context(
           CL_DEVICE_TYPE_CPU, 
           cprops,
           NULL,
           NULL,
           &err);
        checkErr(err, "Conext::Context()");   
     
     
     
     
     
     
     
     
     char * outH = new char[hw.length()+1];
        cl::Buffer outCL(
            context,
            CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR,
            hw.length()+1,
            outH,
            &err);
            checkErr(err, "Buffer::Buffer()");
     
     
     
     
     
     
     cl::vector<cl::Device> devices;
        devices = context.getInfo<CL_CONTEXT_DEVICES>();
        checkErr(
            devices.size() > 0 ? CL_SUCCESS : -1, "devices.size() > 0");
     
     
     
     
     
     
      std::ifstream file("lesson1_kernels.cl");
        checkErr(file.is_open() ? CL_SUCCESS:-1, "lesson1_kernel.cl");
     
        std::string prog(
            std::istreambuf_iterator<char>(file),
            (std::istreambuf_iterator<char>()));
     
        cl::Program::Sources source(
     
            1,
            std::make_pair(prog.c_str(), prog.length()+1));
     
        cl::Program program(context, source);
        err = program.build(devices,"");
        checkErr(file.is_open() ? CL_SUCCESS : -1, "Program::build()");
     
     
     
     
    cl::Kernel kernel(program, "hello", &err);
        checkErr(err, "Kernel::Kernel()");
     
        err = kernel.setArg(0, outCL);
        checkErr(err, "Kernel::setArg()");
     
     
     
     
    cl::CommandQueue queue(context, devices[0], 0, &err);
        checkErr(err, "CommandQueue::CommandQueue()");
     
     
     
        cl::Event event;
        err = queue.enqueueNDRangeKernel(
            kernel, 
            cl::NullRange,
            cl::NDRange(hw.length()+1),
             cl::NDRange(1, 1), 
            NULL, 
            &event);
        checkErr(err, "ComamndQueue::enqueueNDRangeKernel()");
     
     
     
     
     
     
      event.wait();    
        err = queue.enqueueReadBuffer(
            outCL,
            CL_TRUE,
            0,
            hw.length()+1,
            outH);
        checkErr(err, "ComamndQueue::enqueueReadBuffer()");
        std::cout << outH;
        return EXIT_SUCCESS;
    }

    lesson1_kernel.cl
    Code :
    #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];
    }



    Using this makefile :
    Code :
    all : lesson1
     
     
    lesson1 : lesson1.cpp
        g++ lesson1.cpp -L/etc/alternatives -lOpenCL -o lesson1
     
     
    clean : lesson1
        rm lesson1





    That give at the execution :
    Code :
    yannoo@Ubuntoo:~/OPENCL$ make
    g++ lesson1.cpp -L/etc/alternatives -lOpenCL -o lesson1
    In file included from /usr/include/CL/opencl.h:43:0,
                     from /usr/include/CL/cl.hpp:164,
                     from lesson1.cpp:6:
    /usr/include/CL/cl_gl.h:107:2: attention : #warning CL_USE_DEPRECATED_OPENCL_1_1_APIS is defined. These APIs are unsupported and untested in OpenCL 1.2! [-Wcpp]
    yannoo@Ubuntoo:~/OPENCL$ ./lesson1
    *ERROR : cl::Platform::get (-1)

    And a third code test :
    Code :
    #include <stdio.h>
    #include <stdlib.h>
     
    #ifdef __APPLE__
    #include <OpenCL/opencl.h>
    #else
    #include <CL/cl.h>
    #endif
     
     
     
     
    int main(void) {
     
        // Get platform and device information
        cl_platform_id platform_id = NULL;
        cl_device_id device_id = NULL;   
        cl_uint ret_num_devices;
        cl_uint ret_num_platforms;
        cl_int ret;
     
     
        ret = clGetPlatformIDs(1, &platform_id, &ret_num_platforms);
        printf("plateform_id=%x, ret_num_plareform=%d, ret=%d \n", (int)platform_id, ret_num_platforms, ret); 
     
     
        ret = clGetDeviceIDs( platform_id, CL_DEVICE_TYPE_DEFAULT, 1, &device_id, &ret_num_devices);
       printf("platform_id=%x, device_id=%x , ret_num_devices=%x, ret=%d \n", (int)platform_id, (int)device_id, ret_num_devices, ret);
     
        return(0);
    }

    That give at execution :
    Code :
    plateform_id=0, ret_num_plareform=0, ret=-1001 
    platform_id=0, device_id=0 , ret_num_devices=1, ret=-32



    My graphic card is not compatible with OpenCL or it's another thing ?
    Code :
    yannoo@Ubuntoo:~/OPENCL$ lspci | grep VGA
    01:00.0 VGA compatible controller: NVIDIA Corporation NV44 [GeForce 7100 GS] (rev a1)
    Last edited by The Little Body; 12-06-2012 at 06:59 PM.
    @+
    Yannoo

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,220
    Geforce 7 is too old. General purpose compute capability started with GeForce 8 IIRC:

    * https://developer.nvidia.com/cuda-gpus

  3. #3
    Member Regular Contributor
    Join Date
    Jan 2011
    Location
    Paris, France
    Posts
    250
    Thank for the link, Dark Photon

    => this seem to me a valid reason "to invest" into a new graphic card in the beginning of the last year


    But why standards OpenCL funcs cannot to be emulated on "olds" cards like this is make since the beginning in OpenGL ?
    (only the core funcs, not the very hardware/vendor specifics/extended funcs of course)
    @+
    Yannoo

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,220
    Quote Originally Posted by The Little Body View Post
    But why standards OpenCL funcs cannot to be emulated on "olds" cards like this is make since the beginning in OpenGL ? (only the core funcs, not the very hardware/vendor specifics/extended funcs of course)
    Not an expert here, but IIRC Pre SM-4.0 cards such as GeForce 7 and earlier didn't have unified stream processors (read: lots of fixed function hardware) which made it problematic to implement the GPGPU-type functionality needed for CUDA, OpenCL, Compute shaders, etc.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,128
    As an aside, what CPU do you have? Judging from your setup code, you don't seem to have one of those either, right?

  6. #6
    Member Regular Contributor
    Join Date
    Jan 2011
    Location
    Paris, France
    Posts
    250
    Thanks for your response, Dark Photon


    This effectively seem a good reason for not to have a too negative accelleration because the need to using a software emulation on "old" hardware

    Thokra, it's a Pentium 4 3.06 Ghz
    (ok, it's certainly now very far from the best CPU but I don't think that it can be view as a really too old computer)
    [on other side, I see at https://www.osadl.org/?id=1226 that the Intel i7 @3.47 GHz have 6933.79 bogomips on each core where cpuinfo say 6111.98 bogomips on each core on the mine ... but ok with 12 core on the i7 vs only two for my P4 @3.06 GHz => my CPU can now really to be considered as too old ?]

    And isn't the GeForce GS 7100 (nv44) a true GeForce 7 card ???
    (I have take a look at http://en.wikipedia.org/wiki/GeForce_7_Series and http://en.wikipedia.org/wiki/GeForce_8_Series and seen that my card is relatively old, something like 2006/2007)

    ==> I really need a more recent graphic card
    (and perhaps a newer CPU/computer but I don't have planned to buy a newer computer in the near future)
    Last edited by The Little Body; 12-11-2012 at 02:21 PM.
    @+
    Yannoo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •