Skip to content

Commit fc1e9dc

Browse files
authored
[SYCL][NFC] Add code examples for all FPGA Memory Attributes (#3136)
This patch adds code examples for all SYCL FPGA memory attributes that we did not have before to improve the documentation about memory attributes. Signed-off-by: Soumi Manna <[email protected]>
1 parent 798b4c5 commit fc1e9dc

File tree

1 file changed

+160
-0
lines changed

1 file changed

+160
-0
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,6 +2055,17 @@ let Category = DocCatVariable;
20552055
This attribute may be attached to a variable or struct member declaration and
20562056
instructs the backend to implement the variable or struct member in a memory
20572057
that is clocked at twice the rate of its accessors.
2058+
2059+
.. code-block:: c++
2060+
2061+
void bar() {
2062+
[[intel::doublepump]] int var_doublepump;
2063+
}
2064+
2065+
struct foo {
2066+
[[intel::doublepump]] unsigned int doublepump[64];
2067+
};
2068+
20582069
}];
20592070
}
20602071

@@ -2065,6 +2076,17 @@ let Category = DocCatVariable;
20652076
This attribute may be attached to a variable or struct member declaration and
20662077
instructs the backend to implement the variable or struct member in a memory
20672078
that is clocked at the same rate as its accessors.
2079+
2080+
.. code-block:: c++
2081+
2082+
void bar() {
2083+
[[intel::singlepump]] int var_singlepump;
2084+
}
2085+
2086+
struct foo {
2087+
[[intel::singlepump]] unsigned int singlepump[64];
2088+
};
2089+
20682090
}];
20692091
}
20702092

@@ -2076,6 +2098,19 @@ This attribute may be attached to a variable or struct member declaration and
20762098
instructs the backend to implement the variable or struct member in memory
20772099
rather than promoting to register(s). If the optional parameter is specified
20782100
it indicates what type of memory to use.
2101+
2102+
.. code-block:: c++
2103+
2104+
void bar() {
2105+
[[intel::fpga_memory]] int memory;
2106+
}
2107+
2108+
struct foo {
2109+
[[intel::fpga_memory]] unsigned int memory[64];
2110+
[[intel::fpga_memory("MLAB")]] unsigned int memory_mlab[64];
2111+
[[intel::fpga_memory("BLOCK_RAM")]] unsigned int mem_blockram[32];
2112+
};
2113+
20792114
}];
20802115
}
20812116

@@ -2086,6 +2121,17 @@ def IntelFPGARegisterAttrDocs : Documentation {
20862121
This attribute may be attached to a variable or struct member declaration and
20872122
instructs the backend to promote the variable or struct member to register(s)
20882123
if possible.
2124+
2125+
.. code-block:: c++
2126+
2127+
void bar() {
2128+
[[intel::fpga_register]] int var_reg;
2129+
}
2130+
2131+
struct foo {
2132+
[[intel::fpga_register]] unsigned int reg[64];
2133+
};
2134+
20892135
}];
20902136
}
20912137

@@ -2096,6 +2142,18 @@ def IntelFPGABankWidthAttrDocs : Documentation {
20962142
This attribute may be attached to a variable or struct member declaration and
20972143
instructs the backend to implement the variable or struct member in a memory
20982144
with banks that are N bytes wide.
2145+
2146+
.. code-block:: c++
2147+
2148+
struct foo {
2149+
[[intel::bankwidth(4)]] unsigned int bankwidth[32];
2150+
};
2151+
2152+
template <int N>
2153+
void bar() {
2154+
[[intel::bankwidth(N)]] unsigned int bank_bits_width;
2155+
}
2156+
20992157
}];
21002158
}
21012159

@@ -2106,6 +2164,18 @@ def IntelFPGANumBanksAttrDocs : Documentation {
21062164
This attribute may be attached to a variable or struct member declaration and
21072165
instructs the backend to implement the variable or struct member in a memory
21082166
with N banks.
2167+
2168+
.. code-block:: c++
2169+
2170+
struct foo {
2171+
[[intel::numbanks(8)]] unsigned int numbanks[64];
2172+
};
2173+
2174+
template <int N>
2175+
void bar() {
2176+
[[intel::numbanks(N)]] unsigned int numbanks;
2177+
}
2178+
21092179
}];
21102180
}
21112181

@@ -2117,6 +2187,18 @@ This attribute may be attached to a variable or struct member declaration and
21172187
instructs the backend to replicate the memory generated for the variable or
21182188
struct member sufficiently to enable the specified number of simultaneous
21192189
threads or loop iterations.
2190+
2191+
.. code-block:: c++
2192+
2193+
struct foo {
2194+
[[intel::private_copies(4)]] unsigned int private_copies[64];
2195+
};
2196+
2197+
template <int N>
2198+
void bar() {
2199+
[[intel::private_copies(N)]] unsigned int private_copies;
2200+
}
2201+
21202202
}];
21212203
}
21222204

@@ -2129,6 +2211,19 @@ instructs the backend to merge the memories used to implement any variable or
21292211
struct members that are annotated with this attribute and the same first
21302212
argument. The second argument indicates if the memories should be merged in a
21312213
depth-wise or width-wise manner.
2214+
2215+
.. code-block:: c++
2216+
2217+
void bar() {
2218+
[[intel::merge("mrg1", "depth")]] int merge_depth;
2219+
[[intel::merge("mrg2", "width")]] int merge_width;
2220+
}
2221+
2222+
struct foo {
2223+
[[intel::merge("mrg1", "depth")]] unsigned int merge_depth[64];
2224+
[[intel::merge("mrg2", "width")]] unsigned int merge_width[64];
2225+
};
2226+
21322227
}];
21332228
}
21342229

@@ -2140,6 +2235,18 @@ This attribute may be attached to a variable or struct member declaration and
21402235
instructs the backend to replicate the memory generated for the variable or
21412236
struct member no more than the specified maximum number of times to enable
21422237
simultaneous accesses from different load/store sites in the program.
2238+
2239+
.. code-block:: c++
2240+
2241+
struct foo {
2242+
[[intel::max_replicates(2)]] unsigned int max_replicates[64];
2243+
};
2244+
2245+
template <int N>
2246+
void bar() {
2247+
[[intel::max_replicates(N)]] unsigned int max_replicates;
2248+
}
2249+
21432250
}];
21442251
}
21452252

@@ -2151,6 +2258,17 @@ This attribute may be attached to a variable or struct member declaration and
21512258
instructs the backend to implement the variable or struct member in a memory
21522259
with simple dual port configuration (no memory port services both stores and
21532260
loads).
2261+
2262+
.. code-block:: c++
2263+
2264+
void bar() {
2265+
[[intel::simple_dual_port]] int var_dual_port;
2266+
}
2267+
2268+
struct foo {
2269+
[[intel::simple_dual_port]] unsigned int dual_port[64];
2270+
};
2271+
21542272
}];
21552273
}
21562274

@@ -2162,6 +2280,23 @@ This attribute may be attached to a variable or struct member declaration and
21622280
instructs the backend to implement the variable or struct member in a banked
21632281
memory with 2^(N+1) banks, where the (b0, ..., bn) bits specified determine the
21642282
pointer address bits to bank on.
2283+
2284+
.. code-block:: c++
2285+
2286+
void bar() {
2287+
[[intel::bank_bits(2, 3)]] int var_bank_bits;
2288+
}
2289+
2290+
struct foo {
2291+
[[intel::bank_bits(1, 2)]] unsigned int bb_bb[4]
2292+
[[intel::bank_bits(2, 3, 4, 5)]] unsigned int bankbits[64];
2293+
};
2294+
2295+
template <int N>
2296+
void bar() {
2297+
[[intel::bank_bits(N, 3)]] unsigned int bank_bits;
2298+
}
2299+
21652300
}];
21662301
}
21672302

@@ -2173,15 +2308,40 @@ This attribute may be attached to a variable or struct member declaration and
21732308
provides explicit control over the geometry of memory blocks used in a given
21742309
memory system.
21752310

2311+
.. code-block:: c++
2312+
2313+
struct foo {
2314+
[[intel::force_pow2_depth(1)]] int var_force_p2d;
2315+
[[intel::force_pow2_depth(1)]] const int const_force_p2d[64] = {0, 1};
2316+
};
2317+
2318+
template <int N>
2319+
void bar() {
2320+
[[intel::force_pow2_depth(N)]] unsigned int reg_force_p2d[64];
2321+
}
2322+
21762323
In the presence of this attribute, the compiler:
21772324

21782325
1. Will automatically size the memory depth to the next largest power of 2 if
21792326
force_pow2_depth is set to 1, and will prefer width-stitching of RAM blocks
21802327
over depth-stitching.
21812328

2329+
.. code-block:: c++
2330+
2331+
void func() {
2332+
[[intel::force_pow2_depth(1)]] unsigned int arr_force_p2d_1[64];
2333+
}
2334+
21822335
2. Will not size the memory to the next largest power of 2 if force_pow2_depth
21832336
is set to 0, and will prefer depth-stitching over width-stitching if RAM usage
21842337
can be lowered.
2338+
2339+
.. code-block:: c++
2340+
2341+
void func() {
2342+
[[intel::force_pow2_depth(0)]] unsigned int arr_force_p2d_0[64];
2343+
}
2344+
21852345
}];
21862346
}
21872347

0 commit comments

Comments
 (0)