0

I would like to analyze the effect, if any, #pragma GCC unroll n has on a simple for-loop summation program in C. From my research, I learned of the IACA tool and have downloaded it but I am having a hard time getting an analysis report as it is shown here.

Issue number 1: Configuring IACA. I noticed IACA is an app and not a collection of libraries but the app doesn't open, (should I be able to interact with it?). I extracted IACA files into its own folder in OS and No squiggly lines appeared under

#include <iacaMarks.h>

So I assumed it was on the right path but when I run the program I get the following error:

a.c:2:23: fatal error: iacaMarks.h: No such file or directory
#include <iacaMarks.h>
                      ^
compilation terminated.

Issue number 2: Which command prompt will produce the analysis report? From the IACA guide. I gathered the command prompt iaca -trace filename.c which I used in the terminal but received an error:

iaca : The term 'iaca' is not recognized as the name of a cmdlet..... most likely because it has not been integrated properly. 

I am getting a bit overwhelmed and could use some help.

  1. What am I doing wrong here?
  2. Is there an easier or another way to analyze performance changes due to loop unrolling? I have a limited capability of reading assembly code, but should I be able to gather any information regarding latency and throughput from it?

I am using a Windows machine with 64-bit operating system and x64-based processor. I have a GCC compiler and am using vs-code for c code and VS for assembly code. I don't think there is anything wrong with the C code but clearly, I am no expert so here it is:

#include <stdio.h>
#include <iacaMarks.h>

int main(){
int arr[50]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49};
int result=0;
#pragma GCC unroll 2
for(int i=0; i< 50; i++){
    IACA_VC64_START
result+=arr[i]; 

}
IACA_VC64_END

return 0;

}

To try get IACA on the right path did this: I created an IACA folder in OS and extracted the files there. There are 2 items in the folder, the first is the IACA app, and the 2nd is iacaMarks.c. Then I added

"C:\\iaca\\iaca-win64"

under Include path in c_cpp_preperties.json file.

Anton Menshov
  • 2,266
  • 14
  • 34
  • 55
Jin
  • 13
  • 2
  • The `c_cpp_properties.json` file is only to configure the VSCode C++ plugin and the IntelliSense. It's unrelated to building, for which you need to edit the `tasks.json` file. If you use VSCode with MinGW on Windows, please [read this documentation](https://code.visualstudio.com/docs/cpp/config-mingw). – Some programmer dude Dec 08 '22 at 18:11
  • Have you looked at [What is IACA and how do I use it?](https://stackoverflow.com/q/26021337) ? You have to tell the compiler about the include path for `iacaMarks.h`. Also, you're compiling with GCC, so you want `IACA_START`, not the MSVC-specific IACA_VC64_START. – Peter Cordes Dec 08 '22 at 18:12
  • 1
    And BTW, uiCA is a better analyzer than IACA (with a more accurate model of the front-end, for example). You can copy/paste the asm for a loop into https://uica.uops.info/. That website also has IACA and LLVM-MCA set up. – Peter Cordes Dec 08 '22 at 18:14

0 Answers0