Skip to content

Commit ff9e975

Browse files
jaladreipsigcbot
authored andcommitted
Internal metadata changes
Internal metadata changes
1 parent a60bdf9 commit ff9e975

File tree

7 files changed

+189
-1
lines changed

7 files changed

+189
-1
lines changed

IGC/AdaptorCommon/RayTracing/API/ADT/Array.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ template <typename T> class Array {
198198
inline typename iterator::pointer allocate(size_t NumElts) {
199199
return static_cast<typename iterator::pointer>(::operator new(NumElts * sizeof(typename iterator::value_type)));
200200
}
201+
202+
template <typename A, typename B> friend class UnorderedMap;
201203
};
202204

205+
203206
} // namespace Interface
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
/*========================== begin_copyright_notice ============================
2+
3+
Copyright (C) 2020-2025 Intel Corporation
4+
5+
SPDX-License-Identifier: MIT
6+
7+
============================= end_copyright_notice ===========================*/
8+
9+
//===----------------------------------------------------------------------===//
10+
///
11+
/// This is a simplified unordered map container that is suitable for use in an
12+
/// interface with the UMD. It uses the Array class for internal storage.
13+
///
14+
//===----------------------------------------------------------------------===//
15+
16+
#pragma once
17+
18+
#include "Array.h"
19+
#include <utility>
20+
21+
namespace Interface {
22+
23+
template <typename KeyT, typename ValueT>
24+
class UnorderedMap {
25+
private:
26+
Array<KeyT> Keys;
27+
Array<ValueT> Values;
28+
29+
public:
30+
using key_type = KeyT;
31+
using mapped_type = ValueT;
32+
using value_type = std::pair<const key_type, mapped_type>;
33+
using reference_type = std::pair<const key_type &, mapped_type &>;
34+
using const_reference_type = std::pair<const key_type &, const mapped_type &>;
35+
36+
UnorderedMap() = default;
37+
38+
void destroy() {
39+
Keys.destroy();
40+
Values.destroy();
41+
}
42+
43+
size_t size() const { return Keys.size(); }
44+
bool empty() const { return Keys.empty(); }
45+
46+
// Find index of key, or size() if not found
47+
size_t findIndex(const key_type& key) const {
48+
for (size_t i = 0; i < Keys.size(); ++i) {
49+
if (Keys[i] == key)
50+
return i;
51+
}
52+
return Keys.size();
53+
}
54+
55+
// Returns pointer to value if found, nullptr otherwise
56+
mapped_type* find(const key_type& key) {
57+
size_t idx = findIndex(key);
58+
if (idx < Values.size())
59+
return &Values[idx];
60+
return nullptr;
61+
}
62+
const mapped_type* find(const key_type& key) const {
63+
size_t idx = findIndex(key);
64+
if (idx < Values.size())
65+
return &Values[idx];
66+
return nullptr;
67+
}
68+
69+
// Insert or assign
70+
void insert(const key_type& key, const mapped_type& value) {
71+
size_t idx = findIndex(key);
72+
if (idx < Keys.size()) {
73+
Values[idx] = value;
74+
} else {
75+
// Grow arrays by 1
76+
Array<KeyT> newKeys(Keys.size() + 1);
77+
Array<ValueT> newValues(Values.size() + 1);
78+
for (size_t i = 0; i < Keys.size(); ++i) {
79+
newKeys[i] = Keys[i];
80+
newValues[i] = Values[i];
81+
}
82+
newKeys[Keys.size()] = key;
83+
newValues[Values.size()] = value;
84+
Keys.destroy();
85+
Values.destroy();
86+
Keys = std::move(newKeys);
87+
Values = std::move(newValues);
88+
}
89+
}
90+
91+
// Insert or assign
92+
void insert(const key_type& key, mapped_type&& value) {
93+
size_t idx = findIndex(key);
94+
if (idx < Keys.size()) {
95+
Values[idx] = std::move(value);
96+
} else {
97+
// Grow arrays by 1
98+
Array<KeyT> newKeys(Keys.size() + 1);
99+
Array<ValueT> newValues(Values.size() + 1);
100+
for (size_t i = 0; i < Keys.size(); ++i) {
101+
newKeys[i] = Keys[i];
102+
newValues[i] = std::move(Values[i]);
103+
}
104+
newKeys[Keys.size()] = key;
105+
newValues[Values.size()] = std::move(value);
106+
Keys.destroy();
107+
Values.destroy();
108+
Keys = std::move(newKeys);
109+
Values = std::move(newValues);
110+
}
111+
}
112+
113+
// operator[]
114+
mapped_type& operator[](const key_type& key) {
115+
size_t idx = findIndex(key);
116+
if (idx < Values.size())
117+
return Values[idx];
118+
// Insert default value
119+
insert(key, std::move(mapped_type()));
120+
return Values[Values.size() - 1];
121+
}
122+
123+
struct iterator {
124+
125+
private:
126+
using keyIt = typename Array<KeyT>::iterator;
127+
using ValueIt = typename Array<ValueT>::iterator;
128+
129+
keyIt m_k;
130+
ValueIt m_v;
131+
132+
public:
133+
134+
iterator(keyIt k, ValueIt v) : m_k(k), m_v(v) {}
135+
reference_type operator*() const { return reference_type(*m_k, *m_v); }
136+
iterator &operator++() {
137+
m_k++;
138+
m_v++;
139+
return *this;
140+
}
141+
142+
bool operator==(const iterator &other) const { return m_k == other.m_k && m_v == other.m_v; }
143+
bool operator!=(const iterator &other) const { return !(*this == other); }
144+
};
145+
146+
iterator begin() { return iterator(Keys.begin(), Values.begin()); }
147+
iterator end() { return iterator(Keys.end(), Values.end()); }
148+
149+
struct const_iterator {
150+
151+
private:
152+
using keyIt = typename Array<KeyT>::const_iterator;
153+
using ValueIt = typename Array<ValueT>::const_iterator;
154+
155+
keyIt m_k;
156+
ValueIt m_v;
157+
158+
public:
159+
const_iterator(keyIt k, ValueIt v) : m_k(k), m_v(v) {}
160+
const_reference_type operator*() const { return const_reference_type(*m_k, *m_v); }
161+
const_iterator &operator++() {
162+
m_k++;
163+
m_v++;
164+
return *this;
165+
}
166+
167+
bool operator==(const const_iterator &other) const { return m_k == other.m_k && m_v == other.m_v; }
168+
bool operator!=(const const_iterator &other) const { return !(*this == other); }
169+
};
170+
171+
const_iterator begin() const { return const_iterator(Keys.begin(), Values.begin()); }
172+
const_iterator end() const { return const_iterator(Keys.end(), Values.end()); }
173+
};
174+
175+
} // namespace Interface

IGC/AdaptorCommon/RayTracing/API/API.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ SPDX-License-Identifier: MIT
1111
#include "common/EmUtils.h"
1212

1313
#include "ADT/Array.h"
14+
#include "ADT/UnorderedMap.h"
1415
#include "ADT/Optional.h"
1516

1617
#include "BVHInfo.h"

IGC/Compiler/CISACodeGen/DriverInfo.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ class CDriverInfo {
390390
virtual bool supportsVRT() const { return true; }
391391

392392
virtual bool supportsUniformPrivateMemorySpace() const { return false; }
393-
virtual uint32_t maxNumCoherenceHintBitsForReorderThread() const { return 0; }
393+
394394

395395
virtual bool UseNewTraceRayInlineLoweringInRaytracingShaders() const {
396396
return (IGC_GET_FLAG_VALUE(UseNewInlineRaytracing) & static_cast<uint32_t>(NewInlineRaytracingMask::RTShaders)) !=

IGC/Compiler/CodeGenPublic.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,10 @@ struct SBindlessProgram : SKernelProgram {
487487
// a collection of other names that they go by.
488488
std::vector<std::string> Aliases;
489489

490+
// if the shader was created by cloning another shader
491+
// this will contain the name of the original shader
492+
std::string OriginatingShaderName;
493+
490494
// We maintain this information to provide to GTPin. These are all
491495
// offsets in bytes from the base of GRF.
492496
uint32_t GlobalPtrOffset = 0; // pointer to RTGlobals

IGC/DriverInterface/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ set(IGC_BUILD__HDR__DriverInterface
115115
)
116116
set(IGC_BUILD__HDR__RAYTRACING_API__ADT
117117
"${CMAKE_CURRENT_SOURCE_DIR}/../AdaptorCommon/RayTracing/API/ADT/Array.h"
118+
"${CMAKE_CURRENT_SOURCE_DIR}/../AdaptorCommon/RayTracing/API/ADT/UnorderedMap.h"
118119
"${CMAKE_CURRENT_SOURCE_DIR}/../AdaptorCommon/RayTracing/API/ADT/Optional.h"
119120
)
120121

IGC/common/MDFrameWork.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ enum class ShaderTypeMD
324324

325325
// for continuations used in ReorderThread, this field indicates the maximum value of the coherence hint
326326
uint32_t NumCoherenceHintBits = 0;
327+
328+
// if the function was created by cloning another function
329+
// this will contain the name of the original shader
330+
std::string OriginatingShaderName;
327331
};
328332

329333
struct ConstantAddress

0 commit comments

Comments
 (0)