1 Reply Latest reply on Jul 10, 2017 2:39 AM by dipak

    Found a misused OpenCL API in MIOpen. Need help reaching the team

    marty1885

      Hello. I have been studying MIOpen's source code since it's launch. After a while, I found that MIOpen built with OpenCL will fail half of it's test. with something throwing std::bad_alloc.

      Digging into the source. I found the following code snippet.

       

      /* First, get the size of device list data */
          size_t deviceListSize;
          if(clGetContextInfo(
                 impl->context.get(), CL_CONTEXT_NUM_DEVICES, sizeof(size_t), &deviceListSize, nullptr) !=
             CL_SUCCESS)
          {
              MIOPEN_THROW("Error: Getting Handle Info (device list size, clGetContextInfo)");
          }
      
      
          if(deviceListSize == 0)
          {
              MIOPEN_THROW("Error: No devices found.");
          }
          std::vector<cl_device_id> devices(deviceListSize);
      

       

      But according to OpenCL's API documentation(clGetContextInfo). When param_name is CL_CONTEXT_NUM_DEVICES, return type is cl_uint . not size_t.

      This causes deviceListSize being not set correctly. And thus being a really large value, causing the std::vector trying to allocate really really large amount of memory and thus throwing.

      The MIOpen repo seems to be just there to publish the code. Can anyone here help me to reach the team?

       

      Best, Martin