1#ifndef PROTEUS_HASHING_H
2#define PROTEUS_HASHING_H
9#include <llvm/ADT/ArrayRef.h>
10#if LLVM_VERSION_MAJOR >= 18
11#include <llvm/ADT/StableHashing.h>
13#include <llvm/CodeGen/StableHashing.h>
27 inline HashT(
const stable_hash HashValue) { Value = HashValue; }
28 inline HashT(
const StringRef &S) { S.getAsInteger(0, Value); }
29 inline stable_hash
getValue()
const {
return Value; }
30 inline std::string
toString()
const {
return std::to_string(Value); }
34#if PROTEUS_ENABLE_CUDA
41 return Value == Other.Value;
45 return Value < Other.Value;
53#if LLVM_VERSION_MAJOR >= 20
54 ArrayRef<uint8_t> Bytes(
reinterpret_cast<const uint8_t *
>(S.data()),
56 return xxh3_64bits(Bytes);
58 return stable_hash_combine_string(S);
65inline std::enable_if_t<std::is_scalar<T>::value,
HashT>
hashValue(
const T &V) {
66 return hashValue(StringRef{
reinterpret_cast<const char *
>(&V),
sizeof(T)});
79 StringRef{
reinterpret_cast<const char *
>(RC.
ArrInfo.
Blob.get()),
91 StringRef{
reinterpret_cast<const char *
>(RC.
ObjInfo.
Blob.get()),
101 return hashRuntimeConstantArray<bool>(RC);
103 return hashRuntimeConstantArray<int8_t>(RC);
105 return hashRuntimeConstantArray<int32_t>(RC);
107 return hashRuntimeConstantArray<int64_t>(RC);
109 return hashRuntimeConstantArray<float>(RC);
111 return hashRuntimeConstantArray<double>(RC);
120 StringRef{
reinterpret_cast<const char *
>(&RC.
Value),
sizeof(RC.
Value)});
131 for (
int I = 1, E = Arr.size(); I < E; ++I)
132 HashValue = stable_hash_combine(HashValue.
getValue(),
167template <
typename FirstT,
typename... RestTs>
#define TIMESCOPE(...)
Definition TimeTracing.h:66
bool specializeArgs() const
Definition Config.h:260
bool specializeDimsRange() const
Definition Config.h:262
bool specializeLaunchBounds() const
Definition Config.h:263
std::optional< const std::string > optPipeline() const
Definition Config.h:266
bool specializeDims() const
Definition Config.h:261
char optLevel() const
Definition Config.h:264
CodegenOption codeGenOption() const
Definition Config.h:259
int codeGenOptLevel() const
Definition Config.h:265
std::string toString() const
Definition Hashing.h:30
bool operator==(const HashT &Other) const
Definition Hashing.h:40
stable_hash getValue() const
Definition Hashing.h:29
bool operator<(const HashT &Other) const
Definition Hashing.h:44
HashT(const stable_hash HashValue)
Definition Hashing.h:27
HashT(const StringRef &S)
Definition Hashing.h:28
std::string toMangledSuffix() const
Definition Hashing.h:33
Definition CompiledLibrary.h:7
Definition MemoryCache.h:27
HashT hashValue(const HashT &H)
Definition Hashing.h:49
@ ARRAY
Definition CompilerInterfaceTypes.h:33
@ VECTOR
Definition CompilerInterfaceTypes.h:32
@ INT32
Definition CompilerInterfaceTypes.h:25
@ INT64
Definition CompilerInterfaceTypes.h:26
@ FLOAT
Definition CompilerInterfaceTypes.h:27
@ STATIC_ARRAY
Definition CompilerInterfaceTypes.h:31
@ INT8
Definition CompilerInterfaceTypes.h:24
@ BOOL
Definition CompilerInterfaceTypes.h:23
@ OBJECT
Definition CompilerInterfaceTypes.h:34
@ DOUBLE
Definition CompilerInterfaceTypes.h:28
HashT hash(FirstT &&First, RestTs &&...Rest)
Definition Hashing.h:168
void reportFatalError(const llvm::Twine &Reason, const char *FILE, unsigned Line)
Definition Error.cpp:14
HashT hashRuntimeSpecializationConfig(const CodeGenerationConfig &CGConfig)
Definition Hashing.h:152
HashT hashCodeGenConfig(const CodeGenerationConfig &CGConfig)
Definition Hashing.h:142
HashT hashArrayRefElement(const RuntimeConstant &RC)
Definition Hashing.h:95
HashT hashCombine(HashT A, HashT B)
Definition Hashing.h:138
std::string toString(CodegenOption Option)
Definition Config.h:28
HashT hashRuntimeConstantObject(const RuntimeConstant &RC)
Definition Hashing.h:83
bool isScalarRuntimeConstantType(RuntimeConstantType RCType)
Definition RuntimeConstantTypeHelpers.h:148
HashT hashRuntimeConstantArray(const RuntimeConstant &RC)
Definition Hashing.h:70
int32_t NumElts
Definition CompilerInterfaceTypes.h:42
RuntimeConstantType EltType
Definition CompilerInterfaceTypes.h:43
std::shared_ptr< unsigned char[]> Blob
Definition CompilerInterfaceTypes.h:44
std::shared_ptr< unsigned char[]> Blob
Definition CompilerInterfaceTypes.h:53
int32_t Size
Definition CompilerInterfaceTypes.h:51
Definition CompilerInterfaceTypes.h:72
ArrayInfo ArrInfo
Definition CompilerInterfaceTypes.h:78
RuntimeConstantValue Value
Definition CompilerInterfaceTypes.h:73
RuntimeConstantType Type
Definition CompilerInterfaceTypes.h:74
ObjectInfo ObjInfo
Definition CompilerInterfaceTypes.h:79
std::size_t operator()(const proteus::HashT &Key) const
Definition Hashing.h:186