9 Replies Latest reply on Jul 5, 2012 3:00 AM by settle

    unresolved external symbol clIcdGetPlatformIDsKHR...

    settle

      I'm trying to experiment using clIcdGetPlatformIDsKHR, but I can't even seem to get my first test code to compile.  I'm using the Visual Studio 2010 with the AMD APP SDK 2.6 and Catalyst 12.4--installed after the SDK.  I've added $(AMDAPPSDKROOT)include and $(AMDAPPSDKROOT)lib\x86_64 (for x64) to the include and library directories, respectively, and added the OpenCL.lib to the linked libraries.  Here's the short source code

      #pragma OPENCL EXTENSION cl_khr_icd : enable

       

      #if defined(__APPLE__) || defined(__MACOSX)

      #include <OpenCL/opencl.h>

      #else

      #include <CL/opencl.h>

      #endif

       

      int main(int argc, char *argv[])

      {

          cl_int status = CL_SUCCESS;

       

          cl_uint num_platforms = 0;

          cl_platform_id *platforms = NULL;

       

          status |= clIcdGetPlatformIDsKHR(num_platforms, platforms, &num_platforms);

          platforms = new cl_platform_id[num_platforms];

          status |= clIcdGetPlatformIDsKHR(num_platforms, platforms, &num_platforms);

       

          delete [] platforms;

       

          return status;

      }

       

      and error

      error LNK2019: unresolved external symbol clIcdGetPlatformIDsKHR referenced in function main

       

      Could anyone guess as to what's causing this error and how I could fix it?  Thanks!

        • Re: unresolved external symbol clIcdGetPlatformIDsKHR...
          Wenju

          Hi settle,

          Could you check if the cl_khr_icd is supported in your environment? Try "clinfo" in CMD. It will show all the extensions that you supported.

          Thank you.

            • Re: unresolved external symbol clIcdGetPlatformIDsKHR...
              settle

              Hi Wenju,

               

              Yes, cl_khr_icd appears as one of the platform extensions from clinfo.  I get this same error under linux (linking with  libOpenCL.so using -lOpenCL).

               

              Thanks!

                • Re: unresolved external symbol clIcdGetPlatformIDsKHR...
                  Wenju

                  Hi settle,

                  A10 and HD 7970 dont support cl_khr_icd, and your graphics card is? Just show more information.

                  Thank you.

                    • Re: unresolved external symbol clIcdGetPlatformIDsKHR...
                      settle

                      I've tried with AMD Radeon HD 5970, 6850, 7750, 6750M GPUs and A8-3530mx and FX-8120 CPUs.

                      Number of platforms:  

                        1
                        Platform Profile:  

                        FULL_PROFILE
                        Platform Version:  

                        OpenCL 1.2 AMD-APP (923.1)
                        Platform Name:  

                        AMD Accelerated Parallel Processing
                        Platform Vendor:  

                        Advanced Micro Devices, Inc.
                        Platform Extensions:  

                        cl_khr_icd cl_amd_event_callback cl_amd_offline_devices

                      BTW, since cl_khr_icd is a platform extension, why is it dependent on the device in that platform?  If I recall correctly I thought that the OpenCL spec stated that if a platform extension is supported then it applies to every device in that platform.

                       

                      Thanks!

                        • Re: unresolved external symbol clIcdGetPlatformIDsKHR...
                          Wenju

                          Hi settle,

                          I'm sorry that I have given you some wrong messages, cl_khr_icd is supported on A10 and HD7970. Please follow the steps shown in sample Devicefission , the codes as following:

                              static clIcdGetPlatformIDsKHR_fn pfn_clIcdGetPlatformIDsKHR = NULL;

                              INIT_CL_EXT_FCN_PTR(clIcdGetPlatformIDsKHR);

                              cl_uint num_platforms = 2;

                              cl_platform_id *platforms = NULL;

                           

                              status |= pfn_clIcdGetPlatformIDsKHR(num_platforms, platforms, &num_platforms);

                              platforms = new cl_platform_id[num_platforms];

                              status |= pfn_clIcdGetPlatformIDsKHR(num_platforms, platforms, &num_platforms);

                          So please just have a try, thank you.

                          1 of 1 people found this helpful
                            • Re: unresolved external symbol clIcdGetPlatformIDsKHR...
                              settle

                              Hi Wenju,

                               

                              I'm sorry for the late reply.

                               

                              I found the example in Devicefission (although INIT_CL_EXT_FCN_PTR is defined but never used) and I tried what you suggested above.  However, after it compiles and I try to run it, I get the following run-time error: "Unhandled exception at 0x00000000 in HelloICD.exe: 0xC0000005: Access violation."  This error occurs at the first function call to pfn_clIcdGetPlatformIDsKHR.

                               

                              Any further suggestions?  Thanks!

                                • Re: unresolved external symbol clIcdGetPlatformIDsKHR...
                                  Wenju

                                  Hi settle,

                                  The solution I told you last time just can make the program to complie successfully. But when I run it, it has some errors. And the reason is

                                  #define INIT_CL_EXT_FCN_PTR(name) \

                                      if(!pfn_##name) { \

                                          pfn_##name = (name##_fn) clGetExtensionFunctionAddress(#name); \

                                          if(!pfn_##name) { \

                                              std::cout << "Cannot get pointer to ext. fcn. " #name << std::endl; \

                                              return SDK_FAILURE; \

                                          } \

                                      }

                                  ,and you can see clGetExtensionFunctionAddress(), this function return the true address of the function you passed.

                                  But for clIcdGetPlatformIDsKHR, I think we should use clGetExtensionFunctionAddressForPlatform(). So I modified the code as following:

                                  static clIcdGetPlatformIDsKHR_fn pfn_clIcdGetPlatformIDsKHR = NULL;

                                  pfn_clIcdGetPlatformIDsKHR = (clIcdGetPlatformIDsKHR_fn) clGetExtensionFunctionAddressForPlatform(platform,"clIcdGetPlatformIDsKHR");

                                      cl_uint num_platforms = 2;

                                      cl_platform_id *platforms = NULL;

                                   

                                      status |= pfn_clIcdGetPlatformIDsKHR(num_platforms, platforms, &num_platforms);

                                      platforms = new cl_platform_id[num_platforms];

                                      status |= pfn_clIcdGetPlatformIDsKHR(num_platforms, platforms, &num_platforms);

                                  Have a try.