Skip to content

Commit 0a24db2

Browse files
DianaChenigcbot
authored andcommitted
[Autobackout][FuncReg]Revert of change: 884fd4a
IGC: Support relocation on cross_thread_data_size In kernel's per-thread-load-payload, create a relocation for cross_thread_size (per_thread_payload_offset) in case of cross_thread_size is changed after compilation (e.g. gtpin inserted argument). The relocation can be resolved to the new cross_thread_size. - Add R_SYM_ADDR_16 relocation to support relocating mad's 16b imm source - Add relocation for cross_thread_size with symbol name "__INTEL_PER_THREAD_OFF" to indicate the usage of this relocation - Update ZEBinary spec
1 parent 884fd4a commit 0a24db2

File tree

10 files changed

+29
-52
lines changed

10 files changed

+29
-52
lines changed

IGC/AdaptorOCL/OCL/sp/zebin_builder.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,6 @@ void ZEBinaryBuilder::addRuntimeSymbols(const IGC::SOpenCLProgramInfo& annotatio
413413
if (annotations.m_hasCrossThreadOffsetRelocations)
414414
mBuilder.addSymbol(vISA::CROSS_THREAD_OFF_R0_RELOCATION_NAME, /*addr*/0, /*size*/0,
415415
llvm::ELF::STB_GLOBAL, llvm::ELF::STT_NOTYPE, /*sectionId*/-1);
416-
if (annotations.m_hasPerThreadOffsetRelocations)
417-
mBuilder.addSymbol(vISA::PER_THREAD_OFF_RELOCATION_NAME, /*addr*/0, /*size*/0,
418-
llvm::ELF::STB_GLOBAL, llvm::ELF::STT_NOTYPE, /*sectionId*/-1);
419416
}
420417

421418
void ZEBinaryBuilder::addProgramSymbols(const IGC::SOpenCLProgramInfo& annotations)
@@ -863,12 +860,12 @@ void ZEBinaryBuilder::addElfSections(void* elfBin, size_t elfSize)
863860
}
864861

865862
unsigned int relocType = relocEntry.r_info & 0xF;
866-
zebin::R_TYPE_ZEBIN zebinType = R_NONE;
863+
zebin::R_TYPE_ZEBIN zebinType = R_ZE_NONE;
867864

868865
if (relocType == ELF::R_X86_64_64)
869-
zebinType = R_SYM_ADDR;
866+
zebinType = R_ZE_SYM_ADDR;
870867
else if (relocType == ELF::R_X86_64_32)
871-
zebinType = R_SYM_ADDR_32;
868+
zebinType = R_ZE_SYM_ADDR_32;
872869
else
873870
IGC_ASSERT_MESSAGE(false, "Unsupported ELF relocation type");
874871

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6785,11 +6785,7 @@ namespace IGC
67856785
IGC_ASSERT(context->type == ShaderType::OPENCL_SHADER);
67866786
auto cl_context = static_cast<OpenCLProgramContext*>(context);
67876787
cl_context->m_programInfo.m_hasCrossThreadOffsetRelocations = true;
6788-
}
6789-
else if (reloc.r_symbol == vISA::PER_THREAD_OFF_RELOCATION_NAME) {
6790-
IGC_ASSERT(context->type == ShaderType::OPENCL_SHADER);
6791-
auto cl_context = static_cast<OpenCLProgramContext*>(context);
6792-
cl_context->m_programInfo.m_hasPerThreadOffsetRelocations = true;
6788+
break;
67936789
}
67946790
}
67956791
}

IGC/Compiler/CodeGenPublic.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,6 @@ namespace IGC
678678
LegacySymbolTable m_legacySymbolTable;
679679
ZEBinGlobalHostAccessTable m_zebinGlobalHostAccessTable;
680680
bool m_hasCrossThreadOffsetRelocations = false;
681-
bool m_hasPerThreadOffsetRelocations = false;
682681
};
683682

684683
class CBTILayout

IGC/ZEBinWriter/zebin/source/ZEELF.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,10 @@ enum SHT_ZEBIN : uint32_t
4141
// ELF relocation type for ELF32_Rel::ELF32_R_TYPE
4242
enum R_TYPE_ZEBIN
4343
{
44-
R_NONE = 0,
45-
R_SYM_ADDR = 1, // 64-bit type address
46-
R_SYM_ADDR_32 = 2, // 32-bit address or lower 32-bit of a 64-bit address.
47-
R_SYM_ADDR_32_HI = 3, // higher 32 bits of 64-bit address
48-
R_PER_THREAD_PAYLOAD_OFFSET_32 = 4, // *** Deprecated. Do Not Use. ***
49-
R_GLOBAL_IMM_32 = 5, // 32-bit global immediate
50-
R_SEND = 6, // send instruction offset, used for BTI patching
51-
R_SYM_ADDR_16 = 7 // 16-bit address or immediate
44+
R_ZE_NONE = 0,
45+
R_ZE_SYM_ADDR = 1, // 64-bit type address
46+
R_ZE_SYM_ADDR_32 = 2, // lower 32-bit of 64-bit address.
47+
R_ZE_SYM_ADDR_32_HI = 3 // higher 32bits of 64-bit address
5248
};
5349

5450
// ELF note type for INTELGT

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ struct zeInfoContainer
241241
KernelsMiscInfoTy kernels_misc_info;
242242
};
243243
struct PreDefinedAttrGetter{
244-
static zeinfo_str_t getVersionNumber() { return "1.44"; }
244+
static zeinfo_str_t getVersionNumber() { return "1.43"; }
245245

246246
enum class ArgThreadSchedulingMode {
247247
age_based,

IGC/ZEBinWriter/zebin/spec/elf.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,11 @@ lower than 2.
221221
Relocation type for **ELF32_R_TYPE** or **ELF64_R_TYPE**
222222
~~~
223223
enum GenRelocType {
224-
R_NONE = 0,
225-
R_SYM_ADDR = 1, // 64-bit address
226-
R_SYM_ADDR_32 = 2, // 32-bit address or lower 32-bit of a 64-bit address
227-
R_SYM_ADDR_32_HI = 3 // higher 32bits of a 64-bit address
228-
R_PER_THREAD_PAYLOAD_OFFSET_32 = 4, // *** Deprecated ***
229-
R_GLOBAL_IMM_32 = 5, // 32-bit global immediate
230-
R_SEND = 6, // send instruction offset, used for BTI patching
231-
R_SYM_ADDR_16 = 7 // 16-bit address or immediate
224+
R_ZE_NONE = 0,
225+
R_ZE_SYM_ADDR = 1, // 64-bit address
226+
R_ZE_SYM_ADDR_32 = 2, // 32-bit address or lower 32-bit of a 64-bit address
227+
R_ZE_SYM_ADDR_32_HI = 3 // higher 32bits of a 64-bit address
228+
R_PER_THREAD_PAYLOAD_OFFSET_32 = 4 // 32-bit field of payload offset of per-thread data
232229
};
233230
~~~
234231

IGC/ZEBinWriter/zebin/spec/version.md

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

99
# ZEBIN Version
10-
Version 1.44
10+
Version 1.43
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.44**: Add relocation type "R_SYM_ADDR_16" and update supported relocation types.
1918
- **Version 1.43**: Internal changes.
2019
- **Version 1.42**: Enable is_ptr attribute in indirect payload arguments.
2120
- **Version 1.41**: Add intel_reqd_thread_group_dispatch_size to user_attributes.

visa/FlowGraph.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4580,15 +4580,6 @@ uint32_t RelocationEntry::getTargetOffset(const IR_Builder &builder) const {
45804580
vASSERT(opndPos == 1);
45814581
// Src1.imm[31:0] mapped to Instruction [127:96]
45824582
return 12;
4583-
case G4_mad:
4584-
vASSERT(relocType == R_SYM_ADDR_16);
4585-
// Src0.imm[15:0] mapped to Instruction [79:64]
4586-
// Src2.imm[15:0] mapped to Instruction [127:112]
4587-
if (opndPos == 1)
4588-
return 8;
4589-
else if (opndPos == 3)
4590-
return 14;
4591-
break;
45924583
case G4_send:
45934584
case G4_sendc:
45944585
case G4_sends:
@@ -4621,8 +4612,6 @@ const char *RelocationEntry::getTypeString(RelocationType relocType) {
46214612
return "R_GLOBAL_IMM_32";
46224613
case RelocationType::R_SEND:
46234614
return "R_SEND";
4624-
case RelocationType::R_SYM_ADDR_16:
4625-
return "R_SYM_ADDR_16";
46264615
default:
46274616
vISA_ASSERT_UNREACHABLE("unhandled relocation type");
46284617
return "??";

visa/PrologEpilog.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -887,17 +887,24 @@ class PayloadLoader
887887
// inserted argument), the relocation need to be resolved to the new
888888
// cross_thread_size.
889889
G4_Operand *addSrc1 =
890-
builder.createRelocImm(GenRelocType::R_SYM_ADDR_32,
891-
PER_THREAD_OFF_RELOCATION_NAME, perThreadOffsetMem, Type_UD);
890+
builder.createRelocImm(GenRelocType::R_PER_THREAD_PAYLOAD_OFFSET_32,
891+
kernel.getName(), perThreadOffsetMem, Type_UD);
892892
auto addDst = builder.createDst(rtmp->getRegVar(), 0, 2, 1, Type_UD);
893893
// instruction has relocation must not be compacted
894894
auto addInst =
895895
builder.createBinOp(G4_add, g4::SIMD1, addDst, addSrc0, addSrc1,
896896
InstOpt_WriteEnable | InstOpt_NoCompact, false);
897-
RelocationEntry::createRelocation(builder.kernel, *addInst, 1,
898-
PER_THREAD_OFF_RELOCATION_NAME,
899-
GenRelocType::R_SYM_ADDR_32);
900897

898+
// FIXME: before RT supports the R_PER_THREAD_PAYLOAD_OFFSET_32 relocation,
899+
// we create relocation only when GTPin option is given to avoid the test
900+
// failure. We can remove this option check once RT supports it.
901+
if (kernel.getOption(vISA_GetFreeGRFInfo)) {
902+
// Relocation with the target symbol set to kernel symbol. Note that
903+
// currently only ZEBinary will produce kernel symbols
904+
RelocationEntry::createRelocation(
905+
kernel, *addInst, 1, kernel.getName(),
906+
GenRelocType::R_PER_THREAD_PAYLOAD_OFFSET_32);
907+
}
901908
instBuffer.push_back(addInst);
902909

903910
if (kernel.getOption(vISA_emitCrossThreadOffR0Reloc)) {

visa/include/RelocationInfo.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ namespace vISA {
2424
static const uint32_t MAX_SYMBOL_NAME_LENGTH = 1024;
2525
constexpr const char *CROSS_THREAD_OFF_R0_RELOCATION_NAME =
2626
"__INTEL_PATCH_CROSS_THREAD_OFFSET_OFF_R0";
27-
constexpr const char *PER_THREAD_OFF_RELOCATION_NAME =
28-
"__INTEL_PER_THREAD_OFF";
2927

3028
/// GenSymType - Specify the symbol's type
3129
enum GenSymType {
@@ -55,10 +53,9 @@ enum GenRelocType {
5553
R_SYM_ADDR = 1, // 64-bit type address
5654
R_SYM_ADDR_32 = 2, // 32-bit address or lower 32-bit of a 64-bit address.
5755
R_SYM_ADDR_32_HI = 3, // higher 32 bits of 64-bit address
58-
R_PER_THREAD_PAYLOAD_OFFSET_32 = 4, // *** Deprecated. Do Not Use. ***
56+
R_PER_THREAD_PAYLOAD_OFFSET_32 = 4, // 32-bit offset of per-thread data
5957
R_GLOBAL_IMM_32 = 5, // 32-bit global immediate
60-
R_SEND = 6, // send instruction offset, used for BTI patching
61-
R_SYM_ADDR_16 = 7 // 16-bit address or immediate
58+
R_SEND = 6 // send instruction offset, used for BTI patching
6259
};
6360

6461
/// GenRelocEntry - An relocation table entry

0 commit comments

Comments
 (0)