cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

settle
Challenger

unresolved external symbol clIcdGetPlatformIDsKHR...

Jump to solution

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!

0 Likes
1 Solution

Accepted Solutions
Wenju
Elite

Re: unresolved external symbol clIcdGetPlatformIDsKHR...

Jump to solution

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.

View solution in original post

0 Likes
8 Replies
Wenju
Elite

Re: unresolved external symbol clIcdGetPlatformIDsKHR...

Jump to solution

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.

0 Likes
settle
Challenger

Re: unresolved external symbol clIcdGetPlatformIDsKHR...

Jump to solution

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!

0 Likes
Wenju
Elite

Re: unresolved external symbol clIcdGetPlatformIDsKHR...

Jump to solution

Hi settle,

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

Thank you.

0 Likes
settle
Challenger

Re: unresolved external symbol clIcdGetPlatformIDsKHR...

Jump to solution

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!

0 Likes
Wenju
Elite

Re: unresolved external symbol clIcdGetPlatformIDsKHR...

Jump to solution

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.

settle
Challenger

Re: unresolved external symbol clIcdGetPlatformIDsKHR...

Jump to solution

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!

0 Likes
Wenju
Elite

Re: unresolved external symbol clIcdGetPlatformIDsKHR...

Jump to solution

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.

0 Likes
settle
Challenger

Re: unresolved external symbol clIcdGetPlatformIDsKHR...

Jump to solution

Thank you Wenju!  I finally got it working on my side thanks to your tips. 

0 Likes