Skip to content

Commit b648551

Browse files
Publish the cl_img_bitwise_ops extension specification. (#1200)
* Publish the cl_img_bitwise_ops extension specification. * Update extensions/cl_img_bitwise_ops.asciidoc Listing the initial extension version. Co-authored-by: Ben Ashbaugh <[email protected]> --------- Co-authored-by: Ben Ashbaugh <[email protected]>
1 parent 2b99fdb commit b648551

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
:data-uri:
2+
:icons: font
3+
include::../config/attribs.txt[]
4+
:source-highlighter: coderay
5+
6+
= cl_img_bitwise_ops
7+
8+
== Name Strings
9+
10+
`cl_img_bitwise_ops`
11+
12+
== Contact
13+
14+
Imagination Technologies Developer Forum: +
15+
https://forums.imgtec.com/
16+
17+
Tomasz Platek, Imagination Technologies (Tomasz.Platek 'at' imgtec.com)
18+
19+
== Contributors
20+
21+
CY Cheng, Imagination Technologies. +
22+
Tomasz Platek, Imagination Technologies.
23+
24+
== Notice
25+
26+
Copyright (c) 2024 Imagination Technologies Ltd. All Rights Reserved.
27+
28+
== Status
29+
30+
Final Draft
31+
32+
== Version
33+
34+
Built On: {docdate} +
35+
Version: 1.0.0
36+
37+
== Dependencies
38+
39+
This extension is written against the OpenCL C Specification Version V3.0.16.
40+
41+
== Overview
42+
43+
This extension adds built-in functions that expose the bitwise operations of Imagination GPU IP that are not accessible by standard OpenCL C functions.
44+
45+
== New OpenCL C Feature Names
46+
47+
[source,c]
48+
----
49+
__opencl_img_bit_interleave
50+
----
51+
52+
== New OpenCL C Functions
53+
54+
Performs the bit interleave operation:
55+
56+
[source,c]
57+
----
58+
gentype img_bit_interleave(gentype a, gentype b);
59+
----
60+
61+
== Modifications to the OpenCL C Specification
62+
63+
(Add to Table 16 - Built-in Scalar and Vector Argument Common Functions in Section 6.15.4 - Common Functions) ::
64+
+
65+
--
66+
[cols="1,2",options="header"]
67+
|====
68+
| Function | Description
69+
| gentype *img_bit_interleave*(gentype a, gentype b)
70+
a| `img_bit_interleave` interleaves the first `n` bits from two sources where `n` is half of the size of gentype in bits.
71+
72+
For `a` and `b`, where a0 and b0 are the least significant bits:
73+
[source]
74+
----
75+
a = a(N-1)\|a(N-2)\|a(N-3)\|...\|a3\|a2\|a1\|a0
76+
b = b(N-1)\|b(N-2)\|b(N-3)\|...\|b3\|b2\|b1\|b0
77+
----
78+
79+
the output is:
80+
[source]
81+
----
82+
res = b(N/2-1)\|a(N/2-1)\|b(N/2-2)\|a(N/2-2)\|b(N/2-3)\|a(N/2-3)\|...\|b3\|a3\|b2\|a2\|b1\|a1\|b0\|a0
83+
----
84+
so the sizes of `a`,`b`, and `res` are equal.
85+
86+
Requires that the `__opencl_img_bit_interleave` feature macro is defined.
87+
|====
88+
--
89+
90+
== Coding Sample
91+
92+
This coding sample shows how to use the *img_bit_interleave* function:
93+
[source]
94+
----
95+
int4 a = (int4) ( 0x00000000, 0x00000000, 0x0000FFFF, 0xFFFFFFFF);
96+
int4 b = (int4) ( 0xFFFFFFFF, 0x0000FFFF, 0x00000000, 0x00000000);
97+
98+
int4 res = img_bit_interleave(a,b);
99+
100+
printf("res = [ 0x%x 0x%x 0x%x 0x%x]\n", res.s0, res.s1, res.s2, res.s3);
101+
----
102+
103+
Executing a work-item of this kernel gives the following result:
104+
[source]
105+
----
106+
res = [ 0xaaaaaaaa 0xaaaaaaaa 0x55555555 0x55555555]
107+
----
108+
109+
== Version History
110+
111+
[cols="5,15,15,70"]
112+
[grid="rows"]
113+
[options="header"]
114+
|====
115+
| Version | Date | Author | Changes
116+
| 1.0.0 | 2024-06-19 | Tomasz Platek | *Initial revision*
117+
|====
118+

extensions/extensions.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ include::cl_arm_scheduling_controls.asciidoc[]
6161
== Imagination Technologies Extensions
6262
:leveloffset: 2
6363
<<<
64+
include::cl_img_bitwise_ops.asciidoc[]
65+
<<<
6466
include::cl_img_cached_allocations.asciidoc[]
6567
<<<
6668
include::cl_img_cancel_command.asciidoc[]

0 commit comments

Comments
 (0)