Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

The distance calculation in the get_distance is probably incorrect #23

@zjing14

Description

@zjing14

I found there may be bugs (see below) in the get_distance function of MIOpenGEMM that makes MIOpenGEMM cannot find the best config in the kernel cache. I think there are some “==” should be “!=”.

double Geometry::get_distance(const Geometry& g2) const
{
 
  double distance = 0;
  if (same_transposes(g2) == false)
  {
    distance = std::numeric_limits<double>::max();
  }
 
  else
  {
 
    for (unsigned i = 0; i < 6; ++i)
    {
      distance += std::abs(metric_co[i] - g2.metric_co[i]);
    }
    for (size_t x : {2, 4, 8})
    {
      for (auto emat : {Mat::E::A, Mat::E::B, Mat::E::C})
      {
        distance += 0.2 * ((ldX[emat] % x == 0) != (g2.ldX[emat] % x == 0));
      }
    }
 
    for (size_t x : {256, 512, 1024})
    {
      for (auto emat : {Mat::E::A, Mat::E::B, Mat::E::C})
      {
       //should be “!=” here
        distance += 0.2 * (std::min<size_t>(ldX[emat] % x, x - ldX[emat] % x) % 4 ==
                           std::min<size_t>(g2.ldX[emat] % x, x - g2.ldX[emat] % x) % 4);
      }
    }
 
    for (size_t i = 0; i < wSpaceSufficient.size(); ++i)
{
     //should be “!=” here
      distance += 0.2 * (wSpaceSufficient[i] == g2.wSpaceSufficient[i]);
    }
  }
 
  distance += 1e-5 * (std::log(wSpaceSize + 1.1) - std::log(g2.wSpaceSize + 1.1));
 
  return distance;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions