Function templates are not seen by the auto-vectorization or the auto-parallelizer (/Qpar) engine in VS2013.
For example, this code:
void foo::someFunc(int a)
{
int myArray[1000000];
for (unsigned i = 0; i < 1000000; i++)
{
myArray[i] = i+1;
}
}
seems to be recognized and I get the appropriate output from /Qvec-report:2 and /Qpar-report:2:
foo.cpp
--- Analyzing function: void __cdecl foo::someFunc(int) __ptr64
c:\visual studio 2013\projects\autovectest\autovectest\foo.cpp(18) : info C5001: loop vectorized
c:\visual studio 2013\projects\autovectest\autovectest\foo.cpp(18) : info C5012: loop not parallelized due to reason '1007'
AutoVecTest.vcxproj -> c:\visual studio 2013\Projects\AutoVecTest\x64\Debug\AutoVecTest.dll
But, as soon as I turn someFunc()
into a function template:
template <class T>
void foo::someFunc(T a)
{
int myArray[1000000];
for (unsigned i = 0; i < 1000000; i++)
{
myArray[i] = i+1;
}
}
I get nothing from the auto-vectorizer or the auto-parallelizer in the logs:
foo.cpp
AutoVecTest.vcxproj -> c:\visual studio 2013\Projects\AutoVecTest\x64\Debug\AutoVecTest.dll
I am not using /GL as stated in Why would /Qvec-report:2 return nothing ? (MSVC 2012)