Skip to content

Commit

Permalink
revert loop MD translation changes, rename function MD
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenxue-intel committed Oct 5, 2023
1 parent b046edb commit c0f05bf
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lib/SPIRV/SPIRVInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ const static char PreferDSP[] = "prefer_dsp";
const static char PropDSPPref[] = "propagate_dsp_preference";
const static char InitiationInterval[] = "initiation_interval";
const static char MaxConcurrency[] = "max_concurrency";
const static char DisableKernelPipelining[] = "disable_kernel_pipelining";
const static char PipelineKernel[] = "pipeline_kernel";
const static char IntelFPGAIPInterface[] = "ip_interface";
} // namespace kSPIR2MD

Expand Down
8 changes: 4 additions & 4 deletions lib/SPIRV/SPIRVReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,8 @@ void SPIRVToLLVM::setLLVMLoopMetadata(const LoopInstType *LM,
if (LC & LoopControlPipelineEnableINTELMask) {
Metadata.push_back(llvm::MDNode::get(
*Context,
getMetadataFromNameAndParameter("llvm.loop.intel.pipelining.disable",
static_cast<SPIRVWord>(!LoopControlParameters[NumParam++]))));
getMetadataFromNameAndParameter("llvm.loop.intel.pipelining.enable",
LoopControlParameters[NumParam++])));
assert(NumParam <= LoopControlParameters.size() &&
"Missing loop control parameter!");
}
Expand Down Expand Up @@ -4531,8 +4531,8 @@ bool SPIRVToLLVM::transFPGAFunctionMetadata(SPIRVFunction *BF, Function *F) {
if (BF->hasDecorate(DecorationPipelineEnableINTEL)) {
auto Literals = BF->getDecorationLiterals(DecorationPipelineEnableINTEL);
std::vector<Metadata *> MetadataVec;
MetadataVec.push_back(ConstantAsMetadata::get(getInt32(M, !Literals[0])));
F->setMetadata(kSPIR2MD::DisableKernelPipelining,
MetadataVec.push_back(ConstantAsMetadata::get(getInt32(M, Literals[0])));
F->setMetadata(kSPIR2MD::PipelineKernel,
MDNode::get(*Context, MetadataVec));
}
return true;
Expand Down
11 changes: 5 additions & 6 deletions lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,12 +1029,11 @@ void LLVMToSPIRVBase::transFPGAFunctionMetadata(SPIRVFunction *BF,
BF->addDecorate(new SPIRVDecorateMaxConcurrencyINTEL(BF, Invocations));
}
}
if (MDNode *DisableKernelPipelining =
F->getMetadata(kSPIR2MD::DisableKernelPipelining)) {
if (MDNode *PipelineKernel = F->getMetadata(kSPIR2MD::PipelineKernel)) {
if (BM->isAllowedToUseExtension(
ExtensionID::SPV_INTEL_fpga_invocation_pipelining_attributes)) {
size_t Disable = getMDOperandAsInt(DisableKernelPipelining, 0);
BF->addDecorate(new SPIRVDecoratePipelineEnableINTEL(BF, !Disable));
size_t Pipeline = getMDOperandAsInt(PipelineKernel, 0);
BF->addDecorate(new SPIRVDecoratePipelineEnableINTEL(BF, Pipeline));
}
}

Expand Down Expand Up @@ -1614,10 +1613,10 @@ LLVMToSPIRVBase::getLoopControl(const BranchInst *Branch,
unsigned SafeLen = IVDep.getSafeLen();
for (auto &ArrayId : IVDep.getArrayVariables())
DependencyArrayParameters.emplace_back(ArrayId, SafeLen);
} else if (S == "llvm.loop.intel.pipelining.disable") {
} else if (S == "llvm.loop.intel.pipelining.enable") {
BM->addExtension(ExtensionID::SPV_INTEL_fpga_loop_controls);
BM->addCapability(CapabilityFPGALoopControlsINTEL);
size_t I = !getMDOperandAsInt(Node, 1);
size_t I = getMDOperandAsInt(Node, 1);
ParametersToSort.emplace_back(spv::LoopControlPipelineEnableINTELMask,
I);
LoopControl |= spv::LoopControlPipelineEnableINTELMask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ attributes #4 = { nounwind }
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.ivdep.safelen", i32 2}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.intel.pipelining.disable", i32 0}
!20 = !{!"llvm.loop.intel.pipelining.enable", i32 1}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.coalesce.count", i32 4}
!23 = distinct !{!23, !24}
Expand Down Expand Up @@ -580,7 +580,7 @@ attributes #4 = { nounwind }
; CHECK-LLVM: ![[MD_D]] = distinct !{![[MD_D]], ![[MD_ivdep:[0-9]+]]}
; CHECK-LLVM: ![[MD_ivdep]] = !{!"llvm.loop.ivdep.safelen", i32 2}
; CHECK-LLVM: ![[MD_E]] = distinct !{![[MD_E]], ![[MD_pipelining:[0-9]+]]}
; CHECK-LLVM: ![[MD_pipelining]] = !{!"llvm.loop.intel.pipelining.disable", i32 0}
; CHECK-LLVM: ![[MD_pipelining]] = !{!"llvm.loop.intel.pipelining.enable", i32 1}
; CHECK-LLVM: ![[MD_F]] = distinct !{![[MD_F]], ![[MD_loop_coalesce_count:[0-9]+]]}
; CHECK-LLVM: ![[MD_loop_coalesce_count]] = !{!"llvm.loop.coalesce.count", i32 4}
; CHECK-LLVM: ![[MD_G]] = distinct !{![[MD_G]], ![[MD_loop_coalesce:[0-9]+]]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
;; intel::loop_fuse_independent(3),
;; intel::initiation_interval(10),
;; intel::max_concurrency(12),
;; intel::disable_kernel_pipelining]] void operator()() {}
;; intel::pipeline_kernel]] void operator()() {}
;; };
;;
;; template <typename name, typename Func>
Expand Down Expand Up @@ -62,23 +62,23 @@
; CHECK-LLVM-SAME: !stall_enable ![[ONEMD:[0-9]+]] !loop_fuse ![[FUSE:[0-9]+]]
; CHECK-LLVM-SAME: !initiation_interval ![[II:[0-9]+]]
; CHECK-LLVM-SAME: !max_concurrency ![[MAXCON:[0-9]+]]
; CHECK-LLVM-SAME: !disable_kernel_pipelining ![[ONEMD]]
; CHECK-LLVM-SAME: !pipeline_kernel ![[ONEMD2:[0-9]+]]
; CHECK-LLVM-SAME: !max_work_group_size ![[MAXWG:[0-9]+]]
; CHECK-LLVM-SAME: !no_global_work_offset ![[OFFSET:[0-9]+]]
; CHECK-LLVM-SAME: !max_global_work_dim ![[ONEMD]] !num_simd_work_items ![[NUMSIMD:[0-9]+]]
; CHECK-LLVM-SAME: !scheduler_target_fmax_mhz ![[MAXMHZ:[0-9]+]]
; CHECK-LLVM-NOT: define spir_kernel void {{.*}}kernel_name2 {{.*}} !no_global_work_offset {{.*}}
; CHECK-LLVM: define spir_kernel void {{.*}}kernel_name3()
; CHECK-LLVM-SAME: !disable_kernel_pipelining ![[ONEMD2:[0-9]+]]
; CHECK-LLVM-SAME: !pipeline_kernel ![[ONEMD]]
; CHECK-LLVM: ![[OFFSET]] = !{}
; CHECK-LLVM: ![[ONEMD]] = !{i32 1}
; CHECK-LLVM: ![[FUSE]] = !{i32 3, i32 1}
; CHECK-LLVM: ![[II]] = !{i32 10}
; CHECK-LLVM: ![[MAXCON]] = !{i32 12}
; CHECK-LLVM: ![[ONEMD2]] = !{i32 0}
; CHECK-LLVM: ![[MAXWG]] = !{i32 1, i32 1, i32 1}
; CHECK-LLVM: ![[NUMSIMD]] = !{i32 8}
; CHECK-LLVM: ![[MAXMHZ]] = !{i32 1000}
; CHECK-LLVM: ![[ONEMD2]] = !{i32 0}

; ModuleID = 'kernel-attrs.cpp'
source_filename = "kernel-attrs.cpp"
Expand All @@ -91,7 +91,7 @@ target triple = "spir64-unknown-linux"
$_ZN3FooclEv = comdat any

; Function Attrs: nounwind
define spir_kernel void @_ZTSZ3barvE11kernel_name() #0 !kernel_arg_addr_space !4 !kernel_arg_access_qual !4 !kernel_arg_type !4 !kernel_arg_base_type !4 !kernel_arg_type_qual !4 !num_simd_work_items !5 !max_work_group_size !6 !max_global_work_dim !7 !no_global_work_offset !4 !stall_enable !7 !scheduler_target_fmax_mhz !12 !loop_fuse !13 !initiation_interval !14 !max_concurrency !15 !disable_kernel_pipelining !7 {
define spir_kernel void @_ZTSZ3barvE11kernel_name() #0 !kernel_arg_addr_space !4 !kernel_arg_access_qual !4 !kernel_arg_type !4 !kernel_arg_base_type !4 !kernel_arg_type_qual !4 !num_simd_work_items !5 !max_work_group_size !6 !max_global_work_dim !7 !no_global_work_offset !4 !stall_enable !7 !scheduler_target_fmax_mhz !12 !loop_fuse !13 !initiation_interval !14 !max_concurrency !15 !pipeline_kernel !16 {
entry:
%Foo = alloca %class._ZTS3Foo.Foo, align 1
call void @llvm.lifetime.start.p0(i64 1, ptr %Foo) #4
Expand Down Expand Up @@ -135,7 +135,7 @@ entry:
}

; Function Attrs: nounwind
define spir_kernel void @_ZTSZ3barvE11kernel_name3() #0 !disable_kernel_pipelining !16 {
define spir_kernel void @_ZTSZ3barvE11kernel_name3() #0 !pipeline_kernel !7 {
entry:
%Foo = alloca %class._ZTS3Foo.Foo, align 1
call void @llvm.lifetime.start.p0(i64 1, ptr %Foo) #4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ entry:
!10 = !{i32 5919, i32 1}
!11 = !{i32 5917, i32 2}

; CHECK-SPV-IR: define spir_kernel void @k(float %a, float %b, float %c) {{.*}} !initiation_interval ![[II:[0-9]+]] !disable_kernel_pipelining ![[DISABLE_KERNEL_PIPELINING:[0-9]+]] {
; CHECK-SPV-IR: define spir_kernel void @k(float %a, float %b, float %c) {{.*}} !initiation_interval ![[II:[0-9]+]] !pipeline_kernel ![[PIPELINE_KERNEL:[0-9]+]] {
; CHECK-SPV-IR-DAG: ![[II]] = !{i32 2}
; CHECK-SPV-IR-DAG: ![[DISABLE_KERNEL_PIPELINING]] = !{i32 0}
; CHECK-SPV-IR-DAG: ![[PIPELINE_KERNEL]] = !{i32 1}

; CHECK-LLVM-NOT: define spir_kernel void @k(float %a, float %b, float %c) {{.*}} !spirv.Decorations ![[DecoListId:[0-9]+]] {
; CHECK-LLVM: define spir_kernel void @k(float %a, float %b, float %c) {{.*}} {

0 comments on commit c0f05bf

Please sign in to comment.