Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

Trouble understanding warning message

$
0
0

Hello,

I'm trying to modernize some of my codes, and face to a strange warning when compiling this simplified version of a pimpl implementation using unique_ptr.

The message is

icpc -xHOST pimpl.cpp
pimpl.cpp(42): warning #2261: __assume expression with side effects discarded
      __assume_aligned(static_cast<const void*>(pimpl->data), ALIGN_SIZE);
                                                              ^

and the code:

#include <memory>

#define NCHANNELS 100
#define ALIGN_SIZE 64

// Main class definition (normally in header)
class LT {
public:
  LT();
  ~LT();
  
  void run();
  
private:
  struct pimpl_LT;
  std::unique_ptr<pimpl_LT> pimpl;
};

// pimpl definition (normally in source file)
struct LT::pimpl_LT {
  double *data;
  
  pimpl_LT(){
    // Alloc data
    data = reinterpret_cast<double*>(_mm_malloc(NCHANNELS * sizeof(double), ALIGN_SIZE));
  };
  
  ~pimpl_LT() {    
    // Free data
    _mm_free(data);
  }
};


LT::LT() : pimpl(new pimpl_LT) {}

LT::~LT() = default;

void LT::run() {
  #pragma ivdep
  for (int i = 0; i < NCHANNELS; ++i) {
    __assume_aligned(static_cast<const void*>(pimpl->data), ALIGN_SIZE);
    pimpl->data[i] = i;
  }
}


//peruse of LT in program
int main() {
 LT lt;

 lt.run(); 
}

As long as I'm not using unique_ptr no error message. In my full code, I need the assume_aligned for vectorization to take place. I don't see why alignment should not be satisfied in unique_ptr elements or I'm missing some important point on the usage of __assume_aligned.

Any enlightenment would be appreciated.

Daniel

 


Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>