Page MenuHomePhabricator

[mlir][GPU] Make MMAMatrixStorage hash unique for a given type.
AbandonedPublic

Authored by ThomasRaoux on May 21 2021, 4:19 PM.

Details

Summary

MMAMatrixStorage cannot use pointer or stringref in its hash otherwise we cannot have unique type for a given set of parameters. This solve the problem and limit the type to only two dimensions.
Instead of storing a string in the storeType replace it by an enum.

Diff Detail

Event Timeline

ThomasRaoux created this revision.May 21 2021, 4:19 PM
ThomasRaoux requested review of this revision.May 21 2021, 4:19 PM
ThomasRaoux retitled this revision from [GPU] Make MMAMatrixStorage hash unique for a given type. to [mlir][GPU] Make MMAMatrixStorage hash unique for a given type..May 21 2021, 6:25 PM

Hi @ThomasRaoux,

Great to see this, But I am not fully sure why the earlier key did not work? Isn't the underlying data used to generate the hashCode for ArrayRef<> and StirngRef<>. Here are some references from llvm/include/llvm/ADT/ArrayRef.h and llvm/lib/Support/StringRef.cpp.

template <typename T> hash_code hash_value(ArrayRef<T> S) {
  return hash_combine_range(S.begin(), S.end());
}
// Implementation of StringRef hashing.
hash_code llvm::hash_value(StringRef S) {
  return hash_combine_range(S.begin(), S.end());
}

Also, I remember before moving to tablegen, MemRefTypeStorage was using this as the KeyTy,

std::tuple<ArrayRef<int64_t>, Type, ArrayRef<AffineMap>, unsigned>

and now its,

std::tuple<::llvm::ArrayRef<int64_t>, Type, ::llvm::ArrayRef<AffineMap>, Attribute>

It seems like the earlier key would have worked. Please let me know If I am missing something.

Thanks!

bondhugula requested changes to this revision.May 23 2021, 4:57 AM
bondhugula added a subscriber: bondhugula.
bondhugula added inline comments.
mlir/include/mlir/Dialect/GPU/GPUDialect.h
104–105

Is this the number of rows and columns? getRow() and getColumn() don't sound meaningful.

104–105

Separate doc comments please. Doxygen uses them to generate doc that goes online on mlir.llvm.org. In this case, the wrong comment would appear for getRow.

This revision now requires changes to proceed.May 23 2021, 4:57 AM
bondhugula added inline comments.May 23 2021, 5:03 AM
mlir/include/mlir/Dialect/GPU/GPUDialect.h
85

Typo: column

91

Likewise - typo here.

100

nRows, nColumns ? row, column don't appear meaningful.

mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
55–56

Likewise.

Hi @ThomasRaoux,

Great to see this, But I am not fully sure why the earlier key did not work? Isn't the underlying data used to generate the hashCode for ArrayRef<> and StirngRef<>. Here are some references from llvm/include/llvm/ADT/ArrayRef.h and llvm/lib/Support/StringRef.cpp.

template <typename T> hash_code hash_value(ArrayRef<T> S) {
  return hash_combine_range(S.begin(), S.end());
}
// Implementation of StringRef hashing.
hash_code llvm::hash_value(StringRef S) {
  return hash_combine_range(S.begin(), S.end());
}

Also, I remember before moving to tablegen, MemRefTypeStorage was using this as the KeyTy,

std::tuple<ArrayRef<int64_t>, Type, ArrayRef<AffineMap>, unsigned>

and now its,

std::tuple<::llvm::ArrayRef<int64_t>, Type, ::llvm::ArrayRef<AffineMap>, Attribute>

It seems like the earlier key would have worked. Please let me know If I am missing something.

Thanks!

Hi @navdeepkk, you are right it looks like I was doing something wrong while trying to simplify the MMAMatrixType. I'll abandon this patch for now since it doesn't seem needed at the time. Thanks for reviewing.

ThomasRaoux abandoned this revision.May 24 2021, 5:48 AM