Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
7646 Discussions

can't generate the auto-vectorization reports ...

MikITGeek
Beginner
286 Views

I am trying to generate the auto-vectorization report for the below snippet; however, I don't seem to get any vectorization report.

 

Please let me know if you have any clue .... 

#include <cstdio>
#include <ctime>
#include <cstdlib>

#define NUMEL	100000

int main(char *argv[], int argc){
	float *a, *b, *c;
	a = (float*) _mm_malloc(NUMEL*sizeof(float), 128);
	b = (float*) _mm_malloc(NUMEL*sizeof(float), 128);
	c = (float*) _mm_malloc(NUMEL*sizeof(float), 128);

	clock_t start = clock();
	for(int i = 0; i < NUMEL; i++){
		c[i] = a[i] / (b[i]+1);
	}
	clock_t end = clock();
	printf("Loop Done1! \n");
	printf("Time taken: %f \n", (double)(end-start)/CLOCKS_PER_SEC);
    return 0;
}

 

Here is the command I use:

 

C:\tmp>icl -Qopt-report:1 -Qopt-report-phase:vec  test.cpp && cat test.optrpt
Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.1.2.254 Build 20200623
Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.

icl: remark #10397: optimization reports are generated in *.optrpt files in the output location
test.cpp
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:test.exe
test.obj

C:\tmp>

 

0 Kudos
3 Replies
Gopika_Intel
Moderator
249 Views

Hi,

Thank you for reaching out. The vectorization report is not generated because the loop is a dead code and the compiler removes it. Either initialize the arrays or add a print statement in the loop, the vectorization report will be generated.

Initialization in the loop

	clock_t start = clock();
	for(int i = 0; i < NUMEL; i++){
		a[i] = 10.0;  //change 1
		b[i] = 4.0;   //change 2
		c[i] = a[i] / (b[i]+1);
	}
	clock_t end = clock();

 

 

OR

printing in the loop

	clock_t start = clock();
	for(int i = 0; i < NUMEL; i++){
		printf ("c is %f\n", c[NUMEL]);
		c[i] = a[i] / (b[i]+1);
	}
	clock_t end = clock();

Compiling and displaying the results(same command that you've followed): 

 

 

icl -Qopt-report:1 -Qopt-report-phase:vec  test.cpp && cat test.optrpt

 

 

Compiler version: Intel(R) C++ Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.1 Build 20201112_000000

Copyright (C) 1985-2020 Intel Corporation. All rights reserved.

 

For more information on vectorization reports: https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-auto-vectorization-t...

Regards

Gopika

 

Gopika_Intel
Moderator
221 Views

Hi,

Has the solution provided helped? Please let us know if the issue persists.

Regards

Gopika


Gopika_Intel
Moderator
202 Views

Hi,

I have not heard back from you, so I will close this query now. If you need further assistance, please post a new question.

Regards

Gopika


Reply