Skip to content

Commit b24a5d4

Browse files
MrSidimsvmaksimo
authored andcommitted
Add SchedulerTargetFmaxMhzINTEL execution mode
Indicates the target clock frequency (Fmax) for the kernel, in MHz. Only valid with the Kernel Execution Model. Spec: https://github.com/KhronosGroup/SPIRV-Registry/blob/master/extensions/INTEL/SPV_INTEL_kernel_attributes.asciidoc Signed-off-by: Dmitry Sidorov <dmitry.sidorov@intel.com>
1 parent 91a6c71 commit b24a5d4

File tree

7 files changed

+28
-12
lines changed

7 files changed

+28
-12
lines changed

llvm-spirv/lib/SPIRV/PreprocessMetadata.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,17 @@ void PreprocessMetadata::visit(Module *M) {
219219
.add(getMDOperandAsInt(NumSIMDWorkitemsINTEL, 0))
220220
.done();
221221
}
222+
223+
// !{void (i32 addrspace(1)*)* @kernel, i32 scheduler_target_fmax_mhz,
224+
// i32 num}
225+
if (MDNode *SchedulerTargetFmaxMhzINTEL =
226+
Kernel.getMetadata(kSPIR2MD::FmaxMhz)) {
227+
EM.addOp()
228+
.add(&Kernel)
229+
.add(spv::ExecutionModeSchedulerTargetFmaxMhzINTEL)
230+
.add(getMDOperandAsInt(SchedulerTargetFmaxMhzINTEL, 0))
231+
.done();
232+
}
222233
}
223234
}
224235

llvm-spirv/lib/SPIRV/SPIRVInternal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ const static char NoGlobalOffset[] = "no_global_work_offset";
399399
const static char MaxWGDim[] = "max_global_work_dim";
400400
const static char NumSIMD[] = "num_simd_work_items";
401401
const static char StallEnable[] = "stall_enable";
402+
const static char FmaxMhz[] = "scheduler_target_fmax_mhz";
402403
} // namespace kSPIR2MD
403404

404405
enum Spir2SamplerKind {

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3929,6 +3929,12 @@ bool SPIRVToLLVM::transMetadata() {
39293929
F->setMetadata(kSPIR2MD::NumSIMD,
39303930
getMDNodeStringIntVec(Context, EM->getLiterals()));
39313931
}
3932+
// Generate metadata for scheduler_target_fmax_mhz
3933+
if (auto EM =
3934+
BF->getExecutionMode(ExecutionModeSchedulerTargetFmaxMhzINTEL)) {
3935+
F->setMetadata(kSPIR2MD::FmaxMhz,
3936+
getMDNodeStringIntVec(Context, EM->getLiterals()));
3937+
}
39323938
}
39333939
NamedMDNode *MemoryModelMD =
39343940
M->getOrInsertNamedMetadata(kSPIRVMD::MemoryModel);

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3192,16 +3192,8 @@ bool LLVMToSPIRV::transExecutionMode() {
31923192
BF->addExecutionMode(BM->add(
31933193
new SPIRVExecutionMode(BF, static_cast<ExecutionMode>(EMode), X)));
31943194
} break;
3195-
case spv::ExecutionModeNumSIMDWorkitemsINTEL: {
3196-
if (BM->isAllowedToUseExtension(
3197-
ExtensionID::SPV_INTEL_kernel_attributes)) {
3198-
unsigned X;
3199-
N.get(X);
3200-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
3201-
BF, static_cast<ExecutionMode>(EMode), X)));
3202-
BM->addCapability(CapabilityFPGAKernelAttributesINTEL);
3203-
}
3204-
} break;
3195+
case spv::ExecutionModeNumSIMDWorkitemsINTEL:
3196+
case spv::ExecutionModeSchedulerTargetFmaxMhzINTEL:
32053197
case spv::ExecutionModeMaxWorkDimINTEL: {
32063198
if (BM->isAllowedToUseExtension(
32073199
ExtensionID::SPV_INTEL_kernel_attributes)) {

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVEntry.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ void SPIRVExecutionMode::decode(std::istream &I) {
511511
case ExecutionModeSubgroupSize:
512512
case ExecutionModeMaxWorkDimINTEL:
513513
case ExecutionModeNumSIMDWorkitemsINTEL:
514+
case ExecutionModeSchedulerTargetFmaxMhzINTEL:
514515
WordLiterals.resize(1);
515516
break;
516517
default:

llvm-spirv/lib/SPIRV/libSPIRV/spirv.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ enum ExecutionMode {
172172
ExecutionModeMaxWorkDimINTEL = 5894,
173173
ExecutionModeNoGlobalOffsetINTEL = 5895,
174174
ExecutionModeNumSIMDWorkitemsINTEL = 5896,
175+
ExecutionModeSchedulerTargetFmaxMhzINTEL = 5903,
175176
ExecutionModeVectorComputeFastCompositeKernelINTEL = 8088,
176177
ExecutionModeMax = 0x7fffffff,
177178
};

llvm-spirv/test/transcoding/IntelFPGAFunctionAttributes.ll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
;; intel::max_work_group_size(1,1,1),
77
;; intel::num_simd_work_items(8)
88
;; intel::stall_enable]] void operator()() {}
9+
;; intel::scheduler_target_fmax_mhz(1000)]] void operator()() {}
910
;; };
1011
;;
1112
;; template <typename name, typename Func>
@@ -37,15 +38,17 @@
3738
; CHECK-SPIRV: 4 ExecutionMode [[FUNCENTRY]] 5894 1
3839
; CHECK-SPIRV: 3 ExecutionMode [[FUNCENTRY]] 5895
3940
; CHECK-SPIRV: 4 ExecutionMode [[FUNCENTRY]] 5896 8
41+
; CHECK-SPIRV: 4 ExecutionMode [[FUNCENTRY]] 5903 1000
4042
; CHECK-SPIRV: 3 Decorate [[FUNCENTRY]] StallEnableINTEL
4143
; CHECK-SPIRV: 5 Function {{.*}} [[FUNCENTRY]] {{.*}}
4244

43-
; CHECK-LLVM: define spir_kernel void {{.*}}kernel_name() {{.*}} !stall_enable ![[ONEMD:[0-9]+]] !max_work_group_size ![[MAXWG:[0-9]+]] !no_global_work_offset ![[OFFSET:[0-9]+]] !max_global_work_dim ![[ONEMD:[0-9]+]] !num_simd_work_items ![[NUMSIMD:[0-9]+]]
45+
; CHECK-LLVM: define spir_kernel void {{.*}}kernel_name() {{.*}} !stall_enable ![[ONEMD:[0-9]+]] !max_work_group_size ![[MAXWG:[0-9]+]] !no_global_work_offset ![[OFFSET:[0-9]+]] !max_global_work_dim ![[ONEMD:[0-9]+]] !num_simd_work_items ![[NUMSIMD:[0-9]+]] !scheduler_target_fmax_mhz ![[MAXMHZ:[0-9]+]]
4446
; CHECK-LLVM-NOT: define spir_kernel void {{.*}}kernel_name2 {{.*}} !no_global_work_offset {{.*}}
4547
; CHECK-LLVM: ![[OFFSET]] = !{}
4648
; CHECK-LLVM: ![[ONEMD]] = !{i32 1}
4749
; CHECK-LLVM: ![[MAXWG]] = !{i32 1, i32 1, i32 1}
4850
; CHECK-LLVM: ![[NUMSIMD]] = !{i32 8}
51+
; CHECK-LLVM: ![[MAXMHZ]] = !{i32 1000}
4952

5053
; ModuleID = 'kernel-attrs.cpp'
5154
source_filename = "kernel-attrs.cpp"
@@ -58,7 +61,7 @@ target triple = "spir64-unknown-linux-sycldevice"
5861
$_ZN3FooclEv = comdat any
5962

6063
; Function Attrs: nounwind
61-
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 {
64+
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 {
6265
entry:
6366
%Foo = alloca %class._ZTS3Foo.Foo, align 1
6467
%0 = bitcast %class._ZTS3Foo.Foo* %Foo to i8*
@@ -128,3 +131,4 @@ attributes #4 = { nounwind }
128131
!9 = !{!"any pointer", !10, i64 0}
129132
!10 = !{!"omnipotent char", !11, i64 0}
130133
!11 = !{!"Simple C++ TBAA"}
134+
!12 = !{i32 1000}

0 commit comments

Comments
 (0)