
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.
Figure 3–17 shows the dependency graph for Example 3–31, which
introduces a new restricted pointer, my_ptr_b, to prevent the data
dependency present in Figure 3–16.
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;
}
Comentarios a estos manuales