cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

takercena
Journeyman III

Too many opencl devices reported, what happen?

Based on these code, OpenCL report 2046 devices on AMD platform. What happen?

    int ctr = 0;

    cl_uint selectedPlatform = 0;

    char param[50];

    for(ctr; ctr < num_platforms; ctr++)

    {

        clGetPlatformInfo(platforms[ctr], CL_PLATFORM_VENDOR, sizeof(param), &param, NULL);

        printf("%s\n", param);

        if(strncmp(param, "NVIDIA", 6) == 0)

        {

            printf("nVidia\n");

            selectedPlatform = ctr;

        }

        else if (strncmp(param, "Advanced", 😎 == 0)

        {

            printf("Advanced Micro Devices\n");

            clGetDeviceIDs(platforms[ctr], CL_DEVICE_TYPE_ALL, 5, NULL, &num_devices);

            printf("Consist of %d OpenCL devices\n", num_devices);

        }

        else if (strncmp(param, "Intel", 5) == 0)

        {

            printf("Intel\n");

        }

    }

0 Likes
1 Solution
gbilotta
Adept III

What is happening is that in

clGetDeviceIDs(platforms[ctr], CL_DEVICE_TYPE_ALL, 5, NULL, &num_devices);

you are asking at the same time for the name of 5 devices (not to be stored anywhere) and for the number of devices, and this probably confuses the OpenCL implementation, so that num_devices is not properly initialized or getting a bogus value. Try using 0 instead of 5 as third parameter.

The specification is not explicit on this, but I see no reason why num_devices should not be correctly initialized even when num_entries is present, which is why I think this is a bug in the implementation.

View solution in original post

0 Likes
2 Replies
gbilotta
Adept III

What is happening is that in

clGetDeviceIDs(platforms[ctr], CL_DEVICE_TYPE_ALL, 5, NULL, &num_devices);

you are asking at the same time for the name of 5 devices (not to be stored anywhere) and for the number of devices, and this probably confuses the OpenCL implementation, so that num_devices is not properly initialized or getting a bogus value. Try using 0 instead of 5 as third parameter.

The specification is not explicit on this, but I see no reason why num_devices should not be correctly initialized even when num_entries is present, which is why I think this is a bug in the implementation.

0 Likes

Yea, that fixed it.

0 Likes