Skip to content

Commit 7ac7d6f

Browse files
committed
[SYCL] Add code examples for all SYCL FPGA loop attributes
This is a followup in intel#2715 (comment). This patch improves the documentation by adding code examples for all FPGA loop attributes that we did not have before. Signed-off-by: Soumi Manna <[email protected]>
1 parent 6e3f244 commit 7ac7d6f

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,6 +2380,17 @@ is unspecified and is therefore considered infinite.
23802380
In case of ivdep being applied both w/o an array variable and for a particular
23812381
array, the array variables that were not designated a separate ivdep will receive
23822382
the no-array ivdep's safelen, with the correspondent treatment by the backend.
2383+
2384+
.. code-block:: c++
2385+
2386+
void foo() {
2387+
int a[10];
2388+
[[intel::ivdep]] for (int i = 0; i != 10; ++i) { }
2389+
[[intel::ivdep(2)]] for (int i = 0; i != 10; ++i) { }
2390+
[[intel::ivdep(a)]] for (int i = 0; i != 10; ++i) { }
2391+
[[intel::ivdep(a, 2)]] for (int i = 0; i != 10; ++i) { }
2392+
}
2393+
23832394
}];
23842395
}
23852396

@@ -2390,6 +2401,14 @@ def SYCLIntelFPGAIIAttrDocs : Documentation {
23902401
This attribute applies to a loop. Indicates that the loop should be pipelined
23912402
with an initiation interval of N. N must be a positive integer. Cannot be
23922403
applied multiple times to the same loop.
2404+
2405+
.. code-block:: c++
2406+
2407+
void foo() {
2408+
int var = 0;
2409+
[[intel::ii(4)]] for (int i = 0; i < 10; ++i) var++;
2410+
}
2411+
23932412
}];
23942413
}
23952414

@@ -2401,6 +2420,14 @@ This attribute applies to a loop. Indicates that the loop should allow no more
24012420
than N threads or iterations to execute it simultaneously. N must be a non
24022421
negative integer. '0' indicates the max_concurrency case to be unbounded. Cannot
24032422
be applied multiple times to the same loop.
2423+
2424+
.. code-block:: c++
2425+
2426+
void foo() {
2427+
int a[10];
2428+
[[intel::max_concurrency(2)]] for (int i = 0; i != 10; ++i) a[i] = 0;
2429+
}
2430+
24042431
}];
24052432
}
24062433

@@ -2412,6 +2439,14 @@ This attribute applies to a loop. Indicates that the loop nest should be
24122439
coalesced into a single loop without affecting functionality. Parameter N is
24132440
optional. If specified, it shall be a positive integer, and indicates how many
24142441
of the nested loop levels should be coalesced.
2442+
2443+
.. code-block:: c++
2444+
2445+
void foo() {
2446+
int a[10];
2447+
[[intel::loop_coalesce]] for (int i = 0; i != 10; ++i) a[i] = 0;
2448+
}
2449+
24152450
}];
24162451
}
24172452

@@ -2423,6 +2458,14 @@ This attribute applies to a loop. Disables pipelining of the loop data path,
24232458
causing the loop to be executed serially. Cannot be used on the same loop in
24242459
conjunction with max_interleaving, speculated_iterations, max_concurrency, ii
24252460
or ivdep.
2461+
2462+
.. code-block:: c++
2463+
2464+
void foo() {
2465+
int var = 0;
2466+
[[intel::disable_loop_pipelining] for (int i = 0; i < 10; ++i) var++;
2467+
}
2468+
24262469
}];
24272470
}
24282471

@@ -2436,6 +2479,14 @@ mean that this attribute can only be applied to inner loops in user code - outer
24362479
loops in user code may still be contained in an implicit loop due to NDRange).
24372480
Parameter N is mandatory, and shall be non-negative integer. Cannot be
24382481
used on the same loop in conjunction with disable_loop_pipelining.
2482+
2483+
.. code-block:: c++
2484+
2485+
void foo() {
2486+
int a[10];
2487+
[[intel::max_interleaving(4)]] for (int i = 0; i != 10; ++i) a[i] = 0;
2488+
}
2489+
24392490
}];
24402491
}
24412492

@@ -2448,6 +2499,15 @@ iterations that will be in flight for a loop invocation (i.e. the exit
24482499
condition for these iterations will not have been evaluated yet).
24492500
Parameter N is mandatory, and may either be 0, or a positive integer. Cannot be
24502501
used on the same loop in conjunction with disable_loop_pipelining.
2502+
2503+
.. code-block:: c++
2504+
2505+
void foo() {
2506+
int var = 0;
2507+
[[intel::speculated_iterations(4)]]
2508+
for (int i = 0; i < 10; ++i) var++;
2509+
}
2510+
24512511
}];
24522512
}
24532513

@@ -2457,6 +2517,13 @@ def SYCLIntelFPGANofusionAttrDocs : Documentation {
24572517
let Content = [{
24582518
This attribute applies to a loop. Indicates that the annotated
24592519
loop should not be fused with any adjacent loop.
2520+
2521+
.. code-block:: c++
2522+
2523+
void foo() {
2524+
[[intel::nofusion]] for (int i=0; i<10;++i) { }
2525+
}
2526+
24602527
}];
24612528
}
24622529

0 commit comments

Comments
 (0)