1 Reply Latest reply on Jun 2, 2015 5:33 AM by evoliptic

    undefined reference to clEnqueueMakeBuffersResidentAMD?


      hello everybody,


      i'm getting this error on compilation however i think i have the right includes. any hint?


      here is the code (simplified) :


      #include <string.h>
      #include <stdio.h>
      #include "CL/cl.h"
      #include "CL/cl_ext.h"
      #include "CL/cl_platform.h"
      #include "CL/cl_gl.h"
      #include "CL/opencl.h"
      #define DATA_SIZE 10
      const char *KernelSource =
      "__kernel void hello(__global float *input, __global float *output)\n"\
      "  size_t id = get_global_id(0);\n"\
      "  output[id] = input[id] * input[id];\n"\
      int main(void)
         cl_context context;
         cl_context_properties properties[3];
         cl_kernel kernel;
         cl_command_queue command_queue;
         cl_program program;
         cl_int err;
         cl_uint num_of_platforms=0;
         cl_platform_id platform_id;
         cl_device_id device_id;
         cl_uint num_of_devices=0;
         cl_mem input, output, host;
         size_t global;
         float inputData[DATA_SIZE]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
         float results[DATA_SIZE]={0};
          int i;
      clGetPlatformIDs(1, &platform_id, &num_of_platforms);
       clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id,
            &num_of_devices) ;
          properties[0]= CL_CONTEXT_PLATFORM;
          properties[1]= (cl_context_properties) platform_id;
          properties[2]= 0;
         context = clCreateContext(properties,1,&device_id,NULL,NULL,&err);
         command_queue = clCreateCommandQueue(context, device_id, 0, &err);
         program = clCreateProgramWithSource(context,1,(const char **)
         &KernelSource, NULL, &err);
      clBuildProgram(program, 0, NULL, NULL, NULL, NULL);
         kernel = clCreateKernel(program, "hello", &err);
         input = clCreateBuffer(context, CL_MEM_BUS_ADDRESSABLE_AMD,
          sizeof(float) * DATA_SIZE, NULL, NULL);
          cl_bus_address_amd busadress;
          memset(&busadress, 0 , sizeof(cl_bus_address_amd));
          clEnqueueMakeBuffersResidentAMD(command_queue,1 ,&input , CL_TRUE, busadress, 0,0,0);
          printf(" adress : surface : %l, marker : %l\n",busadress.surface_bus_address, busadress.marker_bus_address);
        • Re: undefined reference to clEnqueueMakeBuffersResidentAMD?

          ok, i have found:


          you need to declare the three functions used in the directGMA like this, certainly at the beginning of your main :

          clGetGLContextInfoKHR_fn         clGetGLContextInfoKHR       = NULL;
          clEnqueueWaitSignalAMD_fn        clEnqueueWaitSignalAMD      = NULL;
          clEnqueueWriteSignalAMD_fn       clEnqueueWriteSignalAMD     = NULL;

          clEnqueueMakeBuffersResidentAMD_fn   clEnqueueMakeBuffersResidentAMD = NULL;

          hope this could help.