Questions tagged [loop-unrolling]

Loop unrolling is a loop optimization strategy.

164 questions
1
vote
1 answer

cuda - loop unrolling issue

I have a kernel with a #pragma unroll 80 and I'm running it with NVIDIA GT 285, compute capability 1.3, with grid architecture: dim3 thread_block( 16, 16 ) and dim3 grid( 40 , 30 ) and it works fine. When I tried running it with NVIDIA GT 580,…
user1280671
  • 69
  • 2
  • 15
1
vote
3 answers

(c++) any way to optimize this loop? can't use function pointer as its inside a class

Trying to optimize the fun_a1() function. The variable j does not change in the scope of fun_a1(). So, checking j==1 or 2 or 3 for each 'i' iteration is obviously a waste of CPU cycles. But if I try to bring the condition evaluation outside the…
Anon Y.
  • 99
  • 1
  • 7
1
vote
1 answer

looping on flattened fortran matrices

I have a bit of code that looks like this: DO I=0,500 arg1((I*54+1):(I*54+54)) = premultz*sinphi(I+1) ENDDO In short, I have an array premultz of dimension 54. I have an array sinphi of dimension 501. I want to take the first value of of…
1
vote
1 answer

Why does gcc4 not unroll this loop?

In the gcc 4.4.6 docs it is stated: -funroll-all-loops: Unroll all loops, even if their number of iterations is uncertain when the loop isentered. I am compiling this code: int unroll(){ int i = 0; int array[1000]; do { …
franka
  • 1,867
  • 3
  • 17
  • 31
1
vote
1 answer

Loop unrolling and its effects on pipelining and CPE (have the solution, but don't understand it)

Below the line is a question on a practice test. The table actually has all the solutions filled in. However, I need clarification upon why the solutions are what they are. (Read the question below the horizontal line). For example, I would really…
1
vote
2 answers

How to be sure that a parameter will be treated as a constant during the compilation in C++?

I wonder if the two following implementations will produce exactly the same thing with the same performances whatever the compiler I use : template MyClass1 { static const unsigned int size_const = 0; public: …
Vincent
  • 57,703
  • 61
  • 205
  • 388
1
vote
1 answer

Why does memcmp have duplicated lines in bionic?

I found memcmp.c in bionic is like this: 30 int memcmp(const void *s1, const void *s2, size_t n) 31 { 32 const unsigned char* p1 = s1; 33 const unsigned char* end1 = p1 + n; 34 const unsigned char* p2 = s2; 35 int …
Victor S
  • 4,021
  • 15
  • 43
  • 54
1
vote
1 answer

Effects of Loop unrolling on memory bound data

I have been working with a piece of code which is intensively memory bound. I am trying to optimize it within a single core by manually implementing cache blocking, sw prefetching, loop unrolling etc. Even though cache blocking gives significant…
Anusuya
  • 11
  • 1
0
votes
1 answer

Loop unrolling to achieve parallelism

During a lecture my professor gave us the following loop: for (int i = 0; i < 100; i++) { a[i] = a[i] + b[i]; b[i + 1] = c[i] + d[i]; } He pointed out the dependency between iterations of the loop because line three sets a value that is…
Joe P
  • 1
0
votes
3 answers

optimization tool

I wonder there are any tool to optimize my program in term of loop unrolling, and how can I use it? I have the following python code: for i in range(0, 1000): a = a * 10 + a%4 + i for j in range(0, 1000): j = j + a for b in range(0,…
user1041338
0
votes
1 answer

Unrolling loops in one file

I'm writing Objective-C code with LLVM. I have one file full of very performance-critical code. Is it possible to turn on compiler optimizations (specifically, loop unrolling) for just this one file, without setting a project-wide value?
Bill
  • 44,502
  • 24
  • 122
  • 213
0
votes
0 answers

Is there some kind of data structure in a fragment shader where I can store processed data that will not cause loops to unroll?

Basically I am trying to create an SDF shader that runs entirely off a data stream. The problem is the inside the mapping function is a loop to process and unify the data from the various shapes. However the results from each shape need to be stored…
Simon
  • 1
  • 1
0
votes
1 answer

How do I force the GCC compiler to unroll loops?

I'm writing a C program and want a loop unrolled. I need to force the compiler to unroll a loop where the number of iterations is known at compile time. I've tried compiling using "-O0 -funroll-all-loops". I've tried using #pragma GCC unroll, I've…
alon
  • 1
  • 1
0
votes
0 answers

Optimize Horner Method to Reduce CPE (CSAPP)

Using loop unrolling to reduce the CPE of Horner Method enter image description here I have to optimize a question using Horner Method. Its original solution was: void poly(const double a[], double x, long degree, double *result) { long i; …
Cius
  • 1
  • 1
0
votes
2 answers

Optimization Loop unrolling to find the inverse of a matrix by the gauss jordan method

I am trying to apply the loop unrolling to find the inverse of a matrix by the Gauss Jorda method, to reduce the number of memory accesses (bottleneck) when the size of the matrices is very large and does not fit in the caches. I get it to go…