PDA

View Full Version : In the case the 2 or more platforms is aviailable



ikedanaruki
10-20-2009, 08:53 PM
What a case is it expected when the API function clGetPlatformIDs returns the value that the num_platforms is 2 or more?

bgaster
10-20-2009, 08:59 PM
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);

checkErr(
err && (platforms.size() == 0 ? -1 : CL_SUCCESS),
"cl::Platform::get()");

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


I hope this helps.

ikedanaruki
10-21-2009, 04:18 AM
bgaster,

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:\t\t\t\t "
<< (*i).getInfo<CL_PLATFORM_VENDOR>().c_str() << std::endl;

dbs2
10-21-2009, 05:38 AM
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.

ikedanaruki
10-23-2009, 12:02 AM
Thank you very much.

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