Figure 3–16 – Altera Nios II C2H Compiler User Manual
Page 76

3–36
9.1
Altera Corporation
Nios II C2H Compiler User Guide
November 2009
Scheduling
Figure 3–16. Pointers Always Depend on Themselves
In this example, the C2H Compiler cannot schedule the two read
operations in parallel, because it assumes that the two address
expressions of
my_ptr
could overlap. Assuming that
offset_a
never
equals
offset_b
, to make these operations execute in parallel, you need
to declare another restricted pointer.
shows the dependency graph for
, which
introduces a new restricted pointer,
my_ptr_b
, to prevent the data
.
Example 3–31. Using Another Pointer to Avoid Self-Dependence
void foo(int * _ _ restrict_ _ my_ptr,
int offset_a,
int offset_b)
{
int a, b;
int * _ _ restrict_ _ my_ptr_b = my_ptr;
a = my_ptr[offset_a];
my_ptr[offset_a] = a + 7;
b = my_ptr_b[offset_b];
my_ptr_b[offset_b] = b + 8;
}