Loop unrolling is a loop optimization strategy.
Questions tagged [loop-unrolling]
164 questions
0
votes
1 answer
CUDA loop unrolling on triangular region
Is it possible to unroll a loop on a triangular region, such as:
for (int i = 0; i < ROW_LENGTH; i++)
{
for (int j = 0; j < i; j++)
{
// Some array operation here
}
}
where ROW_LENGTH is a constant defined at compile time? As it…

AnimatedRNG
- 1,859
- 3
- 26
- 39
0
votes
2 answers
Oracle JDK8: unrolled loop converted to NOOP by JVM?
I've got a little program that is a fairly pointless exercise in simple number crunching that has thrown me for a loop.
The program spawns a bunch of worker threads that do simple mathematical operations. Recently I changed the inner loop of one…

user3765373
- 353
- 1
- 2
- 9
0
votes
0 answers
Loop Unrolling in GCC
I am trying to see how unrolling is done in GCC. I have written a C code to add elements of an array to do this.
for (i=0;i<16384;i++)
c[i] = a[i]+b[i];
I have compiled it with -o2 flag and -funroll-all-loops.
gcc -o2 -funroll-all-loops…

Hegde
- 481
- 1
- 8
- 17
0
votes
2 answers
code optimalization and loop unrolling
I am trying to get familiar with programming in assembler. At the beginning I chose random code and tried to update it. Also I read some things about loop unrolling but I do not really know where to start.
This is my code that I already modified a…

NULLexit
- 1
0
votes
0 answers
What causes the retired instructions to increase?
I have a 496*O(N^3) loop. I am performing a blocking optimization technique where I'm operating 2 images at a time instead of 1. In raw terms, I am unrolling the outer loop. (The non-unrolled version of the code is as shown below: ) b.t.w I'm using…

quantumshiv
- 97
- 10
0
votes
0 answers
Looping vs unrolling in fragment shader in iOS
One of my fragment shaders emulates some of the basic OpenGL ES 1.1 multi-texturing features.
As part of that, I have the following GLSL function declared:
void applyTexture(int tuIdx) {
lowp vec4 texColor = texture2D(s_cc3Textures[tuIdx],…

Bill Hollings
- 2,344
- 17
- 25
0
votes
1 answer
Non recursive factorial in C
I have a simple question for you. I made this code to calculate the factorial of a number without recursion.
int fact2(int n){
int aux=1, total = 1;
int i;
int limit = n - 1;
for (i=1; i<=limit; i+=2){
aux = i*(i+1);
…

franpen
- 322
- 1
- 4
- 18
0
votes
2 answers
Loop Unrolling Multi Dimesional Array
I recently tried unrolling the inner i and j loops within this multi-dimensional array, but the filter->get(i,j) always messes up the texture of the image. Can anyone assist me with unrolling the i and j loop? Thanks.
My…

user2998285
- 15
- 1
- 7
0
votes
1 answer
Loop unrolling with dependent loops
I am working on a large application for which I need to perform loop unrolling on subsequent dependent loops for a certain procedure. I have written below a small sample piece of code to replicate the larger version.
Consider the original code:
void…

PGOnTheGo
- 805
- 1
- 11
- 25
-1
votes
1 answer
matrix optimization - segmentation fault when using intrinsics and loop unrolling
I'm currently trying to optimize matrix operations with intrinsics and loop unrolling. There was segmentation fault which I couldn't figure out. Here is the code I made change:
const int UNROLL = 4;
void outer_product(matrix *vec1, matrix *vec2,…

Aria Lin
- 29
- 3
-2
votes
1 answer
Whether I did it right or wrong in 3-address code?
Today, I'm done with my Compiler Construction finals paper at university.
The finals paper included a question that asked me to convert a for loop into 3-address code.
The function it asked me to convert was:
for(i=1;i<=10;i++) x=y+z
So, I did loop…

Sania Bilal
- 1
- 2
-2
votes
1 answer
loop unrolling not giving expected speedup for floating-point dot product
/* Inner product. Accumulate in temporary */
void inner4(vec_ptr u, vec_ptr v, data_t *dest)
{
long i;
long length = vec_length(u);
data_t *udata = get_vec_start(u);
data_t *vdata = get_vec_start(v);
data_t sum = (data_t)…

Encipher
- 1,370
- 1
- 14
- 31
-2
votes
1 answer
Optimization of C loop
I have the following function to calculate coefficients:
void CalculateCoefficients(LinearFit *DataSet, double *A, double *B)
{
/* Declare and initialize sum variables */
double S_XX = 0.0;
double S_XY = 0.0;
double S_X = 0.0;
…

Sara Fuerst
- 5,688
- 8
- 43
- 86