错误:未在此范围内声明'_mm_prefetch'

error: '_mm_prefetch' was not declared in this scope

本文关键字:mm prefetch 声明 范围内 错误      更新时间:2023-10-16

我正在用g++4.7在redhat Linux上编译一段算法代码,但是遇到了一些问题。一个c++文件使用的头文件如下:

但是在编译时,会出现一些错误,例如

 error: '_mm_prefetch' was not declared in this scope
 error: '_MM_HINT_T0' was not declared in this scope

我怎样才能解决这个问题?非常感谢!!

#include <cmath>
#include <memory>
#include <iostream>
#include <mmintrin.h>
#include "space.h"
#include "knnquery.h"
#include "rangequery.h"
#include "ported_boost_progress.h"
#include "method/small_world_rand.h"
#include "sort_arr_bi.h"
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <typeinfo>
//#define START_WITH_E0
#define START_WITH_E0_AT_QUERY_TIME
#define USE_BITSET_FOR_INDEXING 1
//#define USE_ALTERNATIVE_FOR_INDEXING 
namespace similarity {
using namespace std;
template <typename dist_t>
struct IndexThreadParamsSW {
  const Space<dist_t>&                        space_;
  SmallWorldRand<dist_t>&                     index_;
const ObjectVector& data_;
在这个c++文件中,有一个地方使用了这些代码:
for (MSWNode* neighbor : (currEv.getMSWNode())->getAllFriends()) {
        _mm_prefetch(reinterpret_cast<const char*>(const_cast<const Object*>(neighbor->getData())), _MM_HINT_T0);
      }
      for (MSWNode* neighbor : (currEv.getMSWNode())->getAllFriends()) {
        _mm_prefetch(const_cast<const char*>(neighbor->getData()->data()), _MM_HINT_T0);
}

除了<mmintrin.h>,您还需要包括<xmmintrin.h>