In the case the 2 or more platforms is aviailable

What a case is it expected when the API function clGetPlatformIDs returns the value that the num_platforms is 2 or more?

The Compute working group at Khronos is working on a ICD that will allow mutiple vendor implementations to be present on the same machine and these will be exposed through platforms. For example, vendor A may take platform ID 1, vendor B platform ID 2, and so on.

The folllowing code, using the C++ bindings shows how to enumerate all present platforms:

    cl_int err;

    // Plaform info
    cl::vector<cl::Platform> platforms;
    err = cl::Platform::get(&platforms);

        err && (platforms.size() == 0 ? -1 : CL_SUCCESS),

    // Iteratate over platforms
    std::cout << "Number of platforms:				 " 
              << platforms.size() 
              << std::endl;
    for (cl::vector<cl::Platform>::iterator i = platforms.begin(); 
         i != platforms.end(); 
         ++i) {
        std::cout << "  Plaform Profile:				 "    
                  << (*i).getInfo<CL_PLATFORM_PROFILE>().c_str() 
                  << std::endl; 
        std::cout << "  Plaform Version:				 "    
                  << (*i).getInfo<CL_PLATFORM_VERSION>().c_str() 
                  << std::endl; 
        std::cout << "  Plaform Name:					 "     
                  << (*i).getInfo<CL_PLATFORM_NAME>().c_str() 
                  << std::endl; 
        std::cout << "  Plaform Vendor:				 "   
                  << (*i).getInfo<CL_PLATFORM_VENDOR>().c_str() << std::endl; 
        if ((*i).getInfo<CL_PLATFORM_EXTENSIONS>().size() > 0) {
            std::cout << "  Plaform Extensions:			 " 
                      << (*i).getInfo<CL_PLATFORM_EXTENSIONS>().c_str() 
                      << std::endl; 

I hope this helps.


Thank you very much. I can understand.

But it’s not completely.

If,for example

(1) 1 PC is connected with 2 graphic cards,NVIDIA and ATI. Both card are available.

I had thought that this case has 1 host and 1 platform. Then There is 1 platform ID.
I think the specification says 1 platform has 1 host.
But I changed my notion, the ‘host’ is not physical machine.Then this case may have 2 platforms and 2 hosts.

I have confused, please help.

allow mutiple vendor implementations to be present on the same machine

std::cout << " Plaform Vendor: "
<< (*i).getInfo<CL_PLATFORM_VENDOR>().c_str() << std::endl;

The OpenCL “platform” is the drivers supplied for the vendor.

On Mac OS X, there is one platform:

  • Apple’s supports AMD GPUs, Nvidia GPUs, and Intel CPUs
    On linux/windows, there are two platforms:
  • Nvidia’s supports Nvidia GPUs
  • AMD’s supports AMD GPUs and CPUs

So if you have both Nvidia’s and AMD’s platform installed (once the platform layer is actually working, which it isn’t currently) you should see two platforms. Each platform may have multiple devices. The host is the device that is executing your application. If you are using a CPU device in OpenCL then the CPU is doing both the host work and the OpenCL device work.

Thank you very much.

It is difficult to try 2 platform situation for me actually.
Because of your help, I understood well.