Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Inline and no inline warning

Max_S
Beginner
2,262 Views

In the header only library I am writing, all methods are declared and defined inside of the structures.

For some methods I want to turn of the automatic inline since this provides a performance boost.

The problem is, that the intel Compiler issues a lot of warnings like (gcc, clang are fine):

intelExample.cpp(36): warning #2196: routine is both "inline" and "noinline"

Usually they are very long and are produced in in the range of millions for larger projects. Clustering the error log:

../include/codi/tapes/chunkVector.hpp(369): warning #2196: routine is both "inline" and "noinline"
          nextChunk();
          ^
          detected during:
            instantiation of "void codi::ChunkVector<ChunkData, NestedVector>::reserveItems(size_t={unsigned long}) [with ChunkData=codi::Chunk1<double>, NestedVector=codi::ChunkVector<codi::Chunk1<double>, codi::ChunkVector<codi::Chunk1<int>, codi::ChunkVector<codi::Chunk4<int, double, const codi::ExpressionHandle<codi::ReverseTapeTypes<double, codi::Direction<double, 4UL>, codi::ReuseIndexHandlerUseCount<int>>> *, codi::StatementInt={uint8_t={unsigned char}}>, codi::Empty
                      line 698 of "../include/codi/tapes/modules/primalValueModule.hpp"
            instantiation of "void codi::PrimalValueModule<TapeTypes, Tape>::store(codi::PrimalValueModule<TapeTypes, Tape>::Real &, codi::PrimalValueModule<TapeTypes, Tape>::Index &, const Rhs &) [with TapeTypes=codi::IndexPrimalValueTapeTypes<codi::ReverseTapeTypes<double, codi::Direction<double, 4UL>, codi::ReuseIndexHandlerUseCount<int>>, codi::StaticObjectHandleFactory, codi::ChunkVector>, Tape=codi::PrimalValueIndexTape<codi::IndexPrimalValueTapeTypes<codi::ReverseTap
                      codi::Direction<double, 4UL>, codi::ReuseIndexHandlerUseCount<int>>, codi::StaticObjectHandleFactory, codi::ChunkVector>>, Rhs=codi::BinaryOp01<double, codi::ActiveReal<codi::PrimalValueIndexTape<codi::IndexPrimalValueTapeTypes<codi::ReverseTapeTypes<double, codi::Direction<double, 4UL>, codi::ReuseIndexHandlerUseCount<int>>, codi::StaticObjectHandleFactory, codi::ChunkVector>>>, codi::Multiply>]" at line 399 of "../include/codi/activeReal.hpp"
            instantiation of "codi::ActiveReal<Tape> &codi::ActiveReal<Tape>::operator=(const codi::Expression<codi::ActiveReal<Tape>::Real, R> &) [with Tape=codi::PrimalValueIndexTape<codi::IndexPrimalValueTapeTypes<codi::ReverseTapeTypes<double, codi::Direction<double, 4UL>, codi::ReuseIndexHandlerUseCount<int>>, codi::StaticObjectHandleFactory, codi::ChunkVector>>, R=codi::BinaryOp01<double,
                      codi::ActiveReal<codi::PrimalValueIndexTape<codi::IndexPrimalValueTapeTypes<codi::ReverseTapeTypes<double, codi::Direction<double, 4UL>, codi::ReuseIndexHandlerUseCount<int>>, codi::StaticObjectHandleFactory, codi::ChunkVector>>>, codi::Multiply>]" at line 414 of "../include/codi/activeReal.hpp"
            instantiation of "codi::ActiveReal<Tape> &codi::ActiveReal<Tape>::operator=(const codi::ActiveReal<Tape> &) [with Tape=codi::PrimalValueIndexTape<codi::IndexPrimalValueTapeTypes<codi::ReverseTapeTypes<double, codi::Direction<double, 4UL>, codi::ReuseIndexHandlerUseCount<int>>, codi::StaticObjectHandleFactory, codi::ChunkVector>>]" at line 41 of "tests/basic/TestOutput.cpp"

 

An example for this warning is:

#include <iostream>

template<typename T>
struct S1 {
  void func() { std::cout<< "Creates no warning, is inlined" << std::endl;}
};

template<typename T>
struct S2 {
  __attribute__((noinline)) void func() { 
    std::cout<< "Creates warning, is not inlined" << std::endl;
  }
};

template<typename T>
struct S3 {
  __attribute__((noinline)) void func();
};

template<typename T>
void S3<T>::func() { std::cout<< "Creates no warning, is not inlined" << std::endl;}

int main(int nargs, char** args) {
  S1<int> s1;
  s1.func();

  S2<int> s2;
  s2.func();

  S3<int> s3;
  s3.func();
}

 

As I see it, the intention of the developer is to mark the method as not inlined by overwriting the default. I only would expect this warning if a developer writes something like:

template<typename T>
struct S2 {
  inline __attribute__((noinline)) void func() { 
    std::cout<< "Creates warning, is not inlined" << std::endl;
  }
};

 

I tried to suppress the warning with:

#pragma warning push
#pragma warning disable 2196
template<typename T>
struct S2 {
  __attribute__((noinline)) void func() { 
    std::cout<< "Creates warning, is not inlined" << std::endl;
  }
};
#pragma warning pop

 

But the pop will enable the warning again for the instantiation. Also when the pop is put at the end of the compilation unit. Since this is a header only library I am developing, I think it is bad practice to disable a warning for the application that uses the library.

 

Is there an other way to suppress the warning or could the compiler be fixed such that the warning is not issued when the user just wants to overwrite the default behavior?

 

Cheers

 

Max

0 Kudos
7 Replies
RahulV_intel
Moderator
2,231 Views

Hi,


Like you mentioned, ICC does emit additional warnings and it wouldn't be feasible to ignore all the warnings generated by the application (using -w flag).


Also, the disable warning pragma didn't help either. ( Maybe its not possible to ignore some specific warnings and this could be one of them.)


Please note that I have forwarded your concern to the compiler team.


Meanwhile, I'd suggest you to use Intel ICPX compiler (based on clang technology). I have tried with ICPX and it doesn't seem to emit any such warning.



Thanks & Regards,

Rahul


0 Kudos
Max_S
Beginner
2,212 Views

`-w` is not an option, since usually -pedantic -Wall is used. `-w` is the exact opposite. This message clutters the output logs so that the real warnings are not seen.

The pragma works fine by itself only with the push and pop it does not work. I tried to place the pop at the end of the file also with the result that the warning is still there.

Thanks for forwarding this.

Yes with the icpx compiler the warning is not there. I can provides this as an additional workaround.

0 Kudos
Viet_H_Intel
Moderator
2,221 Views

You can turn it off by adding -diag-disable=2196 to your command line.

Thanks,


0 Kudos
Max_S
Beginner
2,215 Views

Yes this is an option, but it still not solves the problem, that the `#pragma warning pop` will `enable` the warning again.

As I have written `#pragma warning disable 2196` will disable the warning. But it should work with the push and pop, so that the library can be written in a clean state. That is, the library does not modify how the Intel compiler behaves in other code parts.

0 Kudos
Viet_H_Intel
Moderator
2,204 Views

I think icpc correctly emits that warning at default and also when pragma warning pop is used, because pop restores the state of the warning to what it was at the begin of the program.


0 Kudos
Viet_H_Intel
Moderator
1,963 Views

Let us know if this is still an issue. Otherwise, we will close it.


Thanks,


0 Kudos
Viet_H_Intel
Moderator
1,946 Views

We will no longer respond to this thread.  

If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.

Thanks,


0 Kudos
Reply