Skip to content

Commit d336f5f

Browse files
author
Artem Gindinson
committed
Revert " ZEBinary: support implicit arguments const_base and global_base"
This reverts commit 08fca25.
1 parent bbafb47 commit d336f5f

File tree

7 files changed

+34
-53
lines changed

7 files changed

+34
-53
lines changed

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,31 +1660,18 @@ namespace IGC
16601660
payloadPosition, kernelArg->getAllocateSize());
16611661
break;
16621662

1663-
case KernelArg::ArgType::IMPLICIT_CONSTANT_BASE:
1664-
case KernelArg::ArgType::IMPLICIT_GLOBAL_BASE: {
1665-
auto zeArgType =
1666-
kernelArg->getArgType() ==
1667-
KernelArg::ArgType::IMPLICIT_CONSTANT_BASE
1668-
? zebin::PreDefinedAttrGetter::ArgType::const_base
1669-
: zebin::PreDefinedAttrGetter::ArgType::global_base;
1670-
zebin::zeInfoPayloadArgument &arg =
1671-
zebin::ZEInfoBuilder::addPayloadArgumentImplicit(
1672-
m_kernelInfo.m_zePayloadArgs, zeArgType, payloadPosition,
1673-
kernelArg->getAllocateSize());
1674-
SOpenCLKernelInfo::SResourceInfo resInfo =
1675-
getResourceInfo(kernelArg->getAssociatedArgNo());
1676-
unsigned btiValue = getBTI(resInfo);
1677-
if (btiValue != 0xffffffff)
1678-
arg.bti_value = btiValue;
1679-
break;
1680-
}
1681-
16821663
// We don't need these in ZEBinary, can safely skip them
16831664
case KernelArg::ArgType::IMPLICIT_R0:
16841665
case KernelArg::ArgType::R1:
16851666
case KernelArg::ArgType::STRUCT:
16861667
break;
16871668

1669+
// FIXME: should these be supported?
1670+
// CONSTANT_BASE and GLOBAL_BASE are not required that we should export
1671+
// all globals and constants and let the runtime relocate them when enabling
1672+
// ZEBinary
1673+
case KernelArg::ArgType::IMPLICIT_CONSTANT_BASE:
1674+
case KernelArg::ArgType::IMPLICIT_GLOBAL_BASE:
16881675
case KernelArg::ArgType::IMPLICIT_STAGE_IN_GRID_ORIGIN:
16891676
case KernelArg::ArgType::IMPLICIT_STAGE_IN_GRID_SIZE:
16901677
default:

IGC/Compiler/Optimizer/OpenCLPasses/ProgramScopeConstants/ProgramScopeConstantAnalysis.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -248,26 +248,26 @@ bool ProgramScopeConstantAnalysis::runOnModule(Module& M)
248248
IGC::appendToUsed(M, globalArray);
249249
}
250250

251-
// Kernels and Subroutines:
252-
// Add the implicit arg to the function argument list if a constant buffer is created and there
253-
// is no stack calls
254-
//
255-
// Stackcalls:
256-
// Stackcall ABI does not allow implicit args, so rely on relocation for global variable access
257-
258-
// Workaround: When there is stringConstants in the module, do not insert
259-
// implicit arguments to prevent const vars getting promoted
260-
// at statelessToStateful pass. In zebin path, stateful promotion
261-
// of const vars can't work well with printf strings.
262-
bool skipConstBuffer =
263-
Ctx->enableZEBinary() && !m_pModuleMd->stringConstants.empty();
264-
265-
if (!skipConstBuffer && hasInlineConstantBuffer)
251+
// Check if zebin is enabled
252+
bool zebinEnable = Ctx->enableZEBinary();
253+
254+
// patch-token-path:
255+
// Just add the implicit argument to each function if a constant
256+
// buffer has been created. This will technically burn a patch
257+
// token on kernels that don't actually use the buffer but it saves
258+
// us having to walk the def-use chain (we can't just check if a
259+
// constant is used in the kernel; for example, a global buffer
260+
// may contain pointers that in turn point into the constant
261+
// address space).
262+
// zebinary path:
263+
// Don't add the implicit arguments and rely solely on relocations
264+
// for global variable reference since the implicit arguments were
265+
// removed from zebinary.
266+
if (!zebinEnable && hasInlineConstantBuffer)
266267
{
267268
for (auto& pFunc : M)
268269
{
269270
if (pFunc.isDeclaration()) continue;
270-
271271
// Skip functions called from function marked with stackcall attribute
272272
if (AddImplicitArgs::hasStackCallInCG(&pFunc, *Ctx)) continue;
273273

@@ -278,7 +278,7 @@ bool ProgramScopeConstantAnalysis::runOnModule(Module& M)
278278
}
279279
}
280280

281-
if (hasInlineGlobalBuffer)
281+
if (!zebinEnable && hasInlineGlobalBuffer)
282282
{
283283
for (auto& pFunc : M)
284284
{

IGC/Compiler/Optimizer/OpenCLPasses/ProgramScopeConstants/ProgramScopeConstantResolution.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ bool ProgramScopeConstantResolution::runOnModule(Module& M)
7979
return false;
8080
}
8181

82+
if (pCtx->enableZEBinary())
83+
{
84+
// ZEBinary always relies on relocation, so we can ignore this pass
85+
return false;
86+
}
87+
88+
8289
if (RunCautiously) {
8390
if (!needRunConservatively(M))
8491
return false;

IGC/ZEBinWriter/zebin/source/autogen/ZEInfo.hpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct zeInfoPayloadArgument
7676
{
7777
bool operator==(const zeInfoPayloadArgument& other) const
7878
{
79-
return arg_type == other.arg_type && offset == other.offset && size == other.size && arg_index == other.arg_index && addrmode == other.addrmode && addrspace == other.addrspace && access_type == other.access_type && sampler_index == other.sampler_index && source_offset == other.source_offset && slm_alignment == other.slm_alignment && image_type == other.image_type && image_transformable == other.image_transformable && sampler_type == other.sampler_type && is_pipe == other.is_pipe && is_ptr == other.is_ptr && bti_value == other.bti_value;
79+
return arg_type == other.arg_type && offset == other.offset && size == other.size && arg_index == other.arg_index && addrmode == other.addrmode && addrspace == other.addrspace && access_type == other.access_type && sampler_index == other.sampler_index && source_offset == other.source_offset && slm_alignment == other.slm_alignment && image_type == other.image_type && image_transformable == other.image_transformable && sampler_type == other.sampler_type && is_pipe == other.is_pipe && is_ptr == other.is_ptr;
8080
}
8181
zeinfo_str_t arg_type;
8282
zeinfo_int32_t offset = 0;
@@ -93,7 +93,6 @@ struct zeInfoPayloadArgument
9393
zeinfo_str_t sampler_type;
9494
zeinfo_bool_t is_pipe = false;
9595
zeinfo_bool_t is_ptr = false;
96-
zeinfo_int32_t bti_value = -1;
9796
};
9897
struct zeInfoPerThreadPayloadArgument
9998
{
@@ -236,7 +235,7 @@ struct zeInfoContainer
236235
KernelsMiscInfoTy kernels_misc_info;
237236
};
238237
struct PreDefinedAttrGetter{
239-
static zeinfo_str_t getVersionNumber() { return "1.28"; }
238+
static zeinfo_str_t getVersionNumber() { return "1.26"; }
240239

241240
enum class ArgThreadSchedulingMode {
242241
age_based,
@@ -276,9 +275,7 @@ struct PreDefinedAttrGetter{
276275
flat_image_pitch,
277276
sampler_address,
278277
sampler_normalized,
279-
sampler_snap_wa,
280-
const_base,
281-
global_base
278+
sampler_snap_wa
282279
};
283280
enum class ArgAddrMode {
284281
stateless,
@@ -430,10 +427,6 @@ struct PreDefinedAttrGetter{
430427
return "sampler_normalized";
431428
case ArgType::sampler_snap_wa:
432429
return "sampler_snap_wa";
433-
case ArgType::const_base:
434-
return "const_base";
435-
case ArgType::global_base:
436-
return "global_base";
437430
default:
438431
break;
439432
}

IGC/ZEBinWriter/zebin/source/autogen/ZEInfoYAML.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ void MappingTraits<zeInfoPayloadArgument>::mapping(IO& io, zeInfoPayloadArgument
9898
io.mapOptional("sampler_type", info.sampler_type, std::string());
9999
io.mapOptional("is_pipe", info.is_pipe, false);
100100
io.mapOptional("is_ptr", info.is_ptr, false);
101-
io.mapOptional("bti_value", info.bti_value, -1);
102101
}
103102
void MappingTraits<zeInfoPerThreadPayloadArgument>::mapping(IO& io, zeInfoPerThreadPayloadArgument& info)
104103
{

IGC/ZEBinWriter/zebin/spec/version.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@ SPDX-License-Identifier: MIT
77
============================= end_copyright_notice ==========================-->
88

99
# ZEBIN Version
10-
Version 1.28
10+
Version 1.26
1111

1212
## Versioning
1313
Format: \<_Major number_\>.\<_Minor number_\>
1414
- Major number: Increase when non-backward-compatible features are added. For example, rename attributes or remove attributes.
1515
- Minor number: Increase when backward-compatible features are added. For example, add new attributes.
1616

1717
## Change Note
18-
- **Version 1.28**: Add const_base and global_base to payload arguments.
19-
- **Version 1.27**: Add has_sample to execution_env.
2018
- **Version 1.26**: Add rt_global_buffer to payload arguments.
2119
- **Version 1.25**: Add is_ptr attribute to payload arguments.
2220
- **Version 1.24**: Add eu_thread_count to execution_env.

IGC/ZEBinWriter/zebin/spec/zeinfo.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ If an attribute is **Required**, it must be present in payload arguments. If it'
175175
| sampler_type | <sampler_type> | Optional | | Present when addrspace is "sampler" |
176176
| is_pipe | bool | Optional | false | Present when arg_type is "arg_bypointer" and type qualifier is pipe |
177177
| is_ptr | bool | Optional | false | Present when arg_type is "arg_byvalue" and arg is used as pointer |
178-
| bti_value | int32 | Optional | -1 | Present when arg_type is "const_base", "global_base" and when the buffer is promoted to BTI |
179178
<!--- PayloadArgument PayloadArguments -->
180179

181180
### Supported argument types:
@@ -216,8 +215,6 @@ Supported <argument_type> of payload_arguments or per_thread_payload_arguments.
216215
| sampler_address | | Sampler descriptor specifying the image addressing mode |
217216
| sampler_normalized | | Sampler descriptor specifying whether the coordinates are passed in as normalized or unnormalized values |
218217
| sampler_snap_wa | | Sampler descriptor specifying whether snap coordinate workaround is required |
219-
| const_base | | The base address of constant buffer |
220-
| global_base | | The base address of global buffer |
221218
<!--- <argument_type> ArgType -->
222219

223220
arg_byvalue and arg_bypointer are user arguments that are explicitly passed in from the applications. Other kinds of arguments are implicit arguments that are passed in by runtime.

0 commit comments

Comments
 (0)