Skip to content

Commit 1c28cd3

Browse files
mbelickigfxbot
authored andcommitted
Enabling OpReadClockKRH SPRIV instruction
Change-Id: I6d023803aba1999f640750bf30568fa1a5fb8ae1
1 parent 94d0063 commit 1c28cd3

File tree

7 files changed

+52
-1
lines changed

7 files changed

+52
-1
lines changed

IGC/AdaptorOCL/SPIRV/SPIRVInternal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ _SPIRV_OP(OpGenericCastToPtrExplicit)
406406
// Ballot extension
407407
_SPIRV_OP(OpSubgroupBallotKHR)
408408
_SPIRV_OP(OpSubgroupFirstInvocationKHR)
409+
// Shader clock extension
410+
_SPIRV_OP(OpReadClockKHR)
409411
#undef _SPIRV_OP
410412

411413
#define _SPIRV_OP(x, y) add(Op##y, #x);

IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVInstruction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,6 +1726,7 @@ _SPIRV_OP(LifetimeStart, false, 3)
17261726
_SPIRV_OP(LifetimeStop, false, 3)
17271727
_SPIRV_OP(SelectionMerge, false, 3)
17281728
_SPIRV_OP(VectorTimesScalar, true, 5)
1729+
_SPIRV_OP(ReadClockKHR, true, 4)
17291730
#undef _SPIRV_OP
17301731

17311732
class SPIRVBallotInstBase : public SPIRVInstTemplateBase

IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVOpCodeEnum.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ _SPIRV_OP(ModuleProcessed, 330)
329329
//Ballot extension
330330
_SPIRV_OP(SubgroupBallotKHR, 4421)
331331
_SPIRV_OP(SubgroupFirstInvocationKHR, 4422)
332+
// Shader clock extension
333+
_SPIRV_OP(ReadClockKHR, 5055)
332334
_SPIRV_OP(Forward, 1024) // Internal only
333335
_SPIRV_OP(SubgroupShuffleINTEL, 5571)
334336
_SPIRV_OP(SubgroupShuffleDownINTEL, 5572)

IGC/BiFModule/Headers/spirv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7936,5 +7936,8 @@ void __builtin_spirv_OpenCL_prefetch_p1v8f64_i64(const global double8* p, ulong
79367936
void __builtin_spirv_OpenCL_prefetch_p1v16f64_i64(const global double16* p, ulong num_elements);
79377937
#endif // defined(cl_khr_fp64)
79387938

7939+
uint __builtin_spirv_OpReadClockKHR_i32(uint scope);
7940+
ulong __builtin_spirv_OpReadClockKHR_i64(uint scope);
7941+
79397942
#endif // __SPIRV_H__
79407943

IGC/BiFModule/Implementation/IBiF_Impl.cl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
109109
#include "IGCBiF_Math_64bitDiv.cl"
110110
#endif
111111

112+
//*****************************************************************************/
113+
// Read Clock Extension Opcodes
114+
//*****************************************************************************/
115+
#include "clock.cl"
116+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*===================== begin_copyright_notice ==================================
2+
3+
Copyright (c) 2017 Intel Corporation
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a
6+
copy of this software and associated documentation files (the
7+
"Software"), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included
14+
in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
24+
25+
======================= end_copyright_notice ==================================*/
26+
27+
/* Shader clock extension */
28+
__attribute__((always_inline))
29+
ulong __builtin_spirv_OpReadClockKHR_i64(uint scope) {
30+
(void) scope;
31+
return as_ulong(__builtin_IB_read_cycle_counter());
32+
}
33+
34+
__attribute__((always_inline))
35+
uint __builtin_spirv_OpReadClockKHR_i32(uint scope) {
36+
return (uint) __builtin_spirv_OpReadClockKHR_i64(scope);
37+
}
38+

IGC/BiFModule/Languages/OpenCL/IBiF_Impl.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ uint __get_pipe_max_packets(pipe int pipe_, uint bytes, uint alignment)
719719
__attribute__((always_inline))
720720
ulong OVERLOADABLE intel_get_cycle_counter( void )
721721
{
722-
return as_ulong(__builtin_IB_read_cycle_counter());
722+
return __builtin_spirv_OpReadClockKHR_i64(0);
723723
}
724724

725725
__attribute__((always_inline))

0 commit comments

Comments
 (0)