當前位置: 首頁>>代碼示例>>C++>>正文


C++ __builtin_prefetch函數代碼示例

本文整理匯總了C++中__builtin_prefetch函數的典型用法代碼示例。如果您正苦於以下問題:C++ __builtin_prefetch函數的具體用法?C++ __builtin_prefetch怎麽用?C++ __builtin_prefetch使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了__builtin_prefetch函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: foo

void foo (char *p)
{
  __builtin_prefetch (p, 0, 0);
  __builtin_prefetch (p, 0, 1);
  __builtin_prefetch (p, 0, 2);
  __builtin_prefetch (p, 0, 3);
  __builtin_prefetch (p, 1, 0);
  __builtin_prefetch (p, 1, 1);
  __builtin_prefetch (p, 1, 2);
  __builtin_prefetch (p, 1, 3);
}
開發者ID:VargMon,項目名稱:dd-wrt,代碼行數:11,代碼來源:i386-pf-athlon-1.c

示例2: __builtin_prefetch

//list get next is just a macro that either calls this for maps, or returns Node->next
ListNode *MapGetNext(ListNode *CurrItem)
{
    ListNode *SubNode, *Head;

    if (! CurrItem) return(NULL);

    if (CurrItem->Next)
    {
        if (CurrItem->Next->Next)
        {
            //it's unlikely that we will be looking up the same item again, because maps maintain seperate chains of items
            //and the likelyhood of hitting the same chain twice is low. THIS IS NOT TRUE FOR REPEATED LOOKUPS ON A LIST
            //because with a list we go through the same items over and over again whenever looking for items in the chain

            //Thus for maps we call this prefetch code, which prefetches into the L1 cache, but not into the larger, long-term
            //L2 cache. As we're unlikely to be revisiting this chain in the near future, we don't want to pollute the L2
            //cache with it

            //This is a disaster for straight forward lists though, because they have only one chain that gets revisited on
            //every search for an item

            __builtin_prefetch (CurrItem->Next->Next, 0, 0);
            if (CurrItem->Next->Next->Tag) __builtin_prefetch (CurrItem->Next->Next->Tag, 0, 0);
        }
        return(CurrItem->Next);
    }

    if (CurrItem->Flags & LIST_FLAG_MAP_HEAD)
    {
        CurrItem=(ListNode *) CurrItem->Item;
        if (CurrItem->Next) return(CurrItem->Next);
    }

//'Head' here points to a BUCKET HEADER. These are marked with this flag, except the last one
//so we know when we've reached the end
    Head=ListGetHead(CurrItem);
    while (Head->Flags & LIST_FLAG_MAP_CHAIN)
    {
        Head++;
        if (Head->Next) return(Head->Next);
    }

    return(NULL);
}
開發者ID:ColumPaget,項目名稱:Crayonizer,代碼行數:45,代碼來源:List.c

示例3: foo

int foo() {
  int a;
  __builtin_prefetch(&a);
  __builtin_prefetch(&a, 1);
  __builtin_prefetch(&a, 1, 2);
  __builtin_prefetch(&a, 1, 9, 3); // expected-error{{too many arguments to function}}
  __builtin_prefetch(&a, "hello", 2); // expected-error{{argument to __builtin_prefetch must be a constant integer}}
  __builtin_prefetch(&a, 2); // expected-error{{argument should be a value from 0 to 1}}
  __builtin_prefetch(&a, 0, 4); // expected-error{{argument should be a value from 0 to 3}}
  __builtin_prefetch(&a, -1, 4); // expected-error{{argument should be a value from 0 to 1}}
}
開發者ID:aosm,項目名稱:clang,代碼行數:11,代碼來源:builtin-prefetch.c

示例4: dmx_set_send_data

void dmx_set_send_data(const uint8_t *data, uint16_t length) {
	do {
		dmb();
	} while (dmx_send_state != IDLE && dmx_send_state != DMXINTER);

	__builtin_prefetch(data);
	memcpy(dmx_data[0].data, data, (size_t)length);

	dmx_set_send_data_length(length);
}
開發者ID:vanvught,項目名稱:rpidmx512,代碼行數:10,代碼來源:dmx.c

示例5: prefetch

  void prefetch(void const* pointer)
  {
#ifdef BOOST_SIMD_ARCH_X86
    #ifdef __GNUC__
      __builtin_prefetch(pointer, 0, 0);
    #elif defined( BOOST_SIMD_HAS_SSE_SUPPORT )
      _mm_prefetch( static_cast<char const *>(pointer), Strategy);
    #endif
#endif
  }
開發者ID:KWMalik,項目名稱:nt2,代碼行數:10,代碼來源:prefetch.hpp

示例6: good_enum

void
good_enum (const int *p)
{
    __builtin_prefetch (p, read, none);
    __builtin_prefetch (p, read, low);
    __builtin_prefetch (p, read, moderate);
    __builtin_prefetch (p, read, high);
    __builtin_prefetch (p, write, none);
    __builtin_prefetch (p, write, low);
    __builtin_prefetch (p, write, moderate);
    __builtin_prefetch (p, write, high);
}
開發者ID:alpine9000,項目名稱:BitOS,代碼行數:12,代碼來源:builtin-prefetch-1.c

示例7: good

void
good (int *p)
{
  __builtin_prefetch (p, 0, 0);
  __builtin_prefetch (p, 0, 1);
  __builtin_prefetch (p, 0, 2);
  __builtin_prefetch (p, 0, 3);
  __builtin_prefetch (p, 1, 0);
  __builtin_prefetch (p, 1, 1);
  __builtin_prefetch (p, 1, 2);
  __builtin_prefetch (p, 1, 3);
}
開發者ID:VargMon,項目名稱:dd-wrt,代碼行數:12,代碼來源:builtin-prefetch-1.c

示例8: good_const

void
good_const (const int *p)
{
  __builtin_prefetch (p, 0, 0);
  __builtin_prefetch (p, 0, 1);
  __builtin_prefetch (p, 0, 2);
  __builtin_prefetch (p, READ_ACCESS, 3);
  __builtin_prefetch (p, 1, NO_TEMPORAL_LOCALITY);
  __builtin_prefetch (p, 1, LOW_TEMPORAL_LOCALITY);
  __builtin_prefetch (p, 1, MODERATE_TEMPORAL_LOCALITY);
  __builtin_prefetch (p, WRITE_ACCESS, HIGH_TEMPORAL_LOCALITY);
}
開發者ID:alpine9000,項目名稱:BitOS,代碼行數:12,代碼來源:builtin-prefetch-1.c

示例9: __builtin_prefetch

void GLMatrix<GLfloat>::glVertex3v(int num, const GLfloat* v_arr)
{
#ifdef GLMATRIX_USE_SSE
    __builtin_prefetch(v_arr);

    sse_vector r0,r1,r2;
    register sse_v4sf m_col0,m_col1,m_col2,m_col3;

    m_col0 = __builtin_ia32_loadaps(m);
    m_col1 = __builtin_ia32_loadaps(m+4);
    m_col2 = __builtin_ia32_loadaps(m+8);
    m_col3 = __builtin_ia32_loadaps(m+12);

    for(register int k = 0; k < num; ++k)
    {
        //load x,y,z
        r0.v4sf = __builtin_ia32_loadss(v_arr);
        r1.v4sf = __builtin_ia32_loadss(v_arr+1);
        r2.v4sf = __builtin_ia32_loadss(v_arr+2);
        //extend into all 4 single floats
        r0.v4sf = __builtin_ia32_shufps(r0.v4sf,r0.v4sf,0x00);
        r1.v4sf = __builtin_ia32_shufps(r1.v4sf,r1.v4sf,0x00);
        r2.v4sf = __builtin_ia32_shufps(r2.v4sf,r2.v4sf,0x00);

        //do the mults
        r0.v4sf = __builtin_ia32_mulps(r0.v4sf,m_col0);
        v_arr+=3;
        r1.v4sf = __builtin_ia32_mulps(r1.v4sf,m_col1);
        //add it all up and, voila
        r2.v4sf = __builtin_ia32_mulps(r2.v4sf,m_col2);
        r0.v4sf = __builtin_ia32_addps(r0.v4sf,r1.v4sf);
        r2.v4sf = __builtin_ia32_addps(r2.v4sf,m_col3);
        r0.v4sf = __builtin_ia32_addps(r0.v4sf,r2.v4sf);

        ::glVertex4fv(r0.f);
    }

#else
    register GLfloat ret[3];
    register GLfloat recip;
    for(register int k = 0; k < num; ++k)
    {
        ret[0] = v_arr[k*3]*m0 + v_arr[1+k*3]*m4 + v_arr[2+k*3]*m8 + m12;
        ret[1] = v_arr[k*3]*m1 + v_arr[1+k*3]*m5 + v_arr[2+k*3]*m9 + m13;
        ret[2] = v_arr[k*3]*m2 + v_arr[1+k*3]*m6 + v_arr[2+k*3]*m10 + m14;

        recip = 1/(v_arr[k*3]*m3 + v_arr[1+k*3]*m7 + v_arr[2+k*3]*m11 + m15);

        ret[0] *= recip;
        ret[1] *= recip;
        ret[2] *= recip;
        ::glVertex3fv(ret);
    }
#endif
}
開發者ID:porst17,項目名稱:realsurf,代碼行數:55,代碼來源:GLMatrix.cpp

示例10: iter_next

/* Returns 1 when element exists.
   Returns 0 when endpoint reached. */
int iter_next (iterator_t *itr, void **addr)
{
    assert (itr);

    if (itr->current_index >= itr->val->next_insert_pos)
    {
        /* Should hop to a different chunk. */
        if (itr->val->next_val)
        {
            /* Hop to next chunk on the same list. */
            itr->val = itr->val->next_val;
            itr->current_index = 0;

            /* Prefetch next chunk on the same list. */
            if (itr->val->next_val) {
                __builtin_prefetch (itr->val->next_val->array, 0, 0);
            }
        }
        else if (itr->current_list + 1 < itr->next_insert_pos)
        {
            /* Hop to the first block of next list. */
            itr->current_list += 1;
            itr->val = itr->list_array[itr->current_list]->vals;
            itr->current_index = 0;

            /* Prefetch next chunk on the same list. */
            if (itr->val->next_val) {
                __builtin_prefetch (itr->val->next_val->array, 0, 0);
            }
        }
        else
        {
            /* Endpoint reached. */
            *addr = NULL;
            return 0;
        }
    }

    *addr = itr->val->array[itr->current_index++];

    return 1;
}
開發者ID:MrOptifyGitHub,項目名稱:elastic-phoenix,代碼行數:44,代碼來源:iterator.c

示例11: prefetch

inline void prefetch(const void *ptr, size_t offset = 32*10)
{
#if defined __GNUC__
    __builtin_prefetch(reinterpret_cast<const char*>(ptr) + offset);
#elif defined _MSC_VER && defined CAROTENE_NEON
    __prefetch(reinterpret_cast<const char*>(ptr) + offset);
#else
    (void)ptr;
    (void)offset;
#endif
}
開發者ID:cyberCBM,項目名稱:DetectO,代碼行數:11,代碼來源:common.hpp

示例12: mypp_dsymv

void mypp_dsymv(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,
	      const int N, const double alpha, const double *A,
	      const int lda, const double *X, const int incX,
	      const double beta, double *Y, const int incY)
{
	// limited implementation 
	assert(Order==CblasRowMajor);
	assert(Uplo==CblasUpper);
	assert(N==lda);

	__builtin_prefetch (Y, 1, 3);
	__builtin_prefetch (X, 1, 3);
	int i,j;
	double temp, reg1, reg2;
	const double *pA, *pX;
	double* pY = Y;
	pA = A;
	pX = X;

	// y = beta*y
	for(i=0;i<lda;i++,pY+=incY)
		(*pY) = beta * (*pY);

	// reset pointers
	pY = Y;

	for(i=0;i<lda;i++,pA+=i,pY+=incY)
	{
		pX = X + i*incX;
		reg1 = (*pX++);
		(*pY) += alpha * (*pA++) * reg1;
		temp = 0.0;
		for(j=i+1;j<N;j++,pA++,pX+=incX)
		{
			reg2 = alpha * (*pA);
			temp += reg2 * (*pX);
			Y[j*incY] += reg2 * reg1;
		}
		(*pY) += temp;
	}
}
開發者ID:albertzaharovits,項目名稱:dsymv_benchmarking,代碼行數:41,代碼來源:mypp_dsymv.c

示例13: hash_table_find_or_insert

hkey_t hash_table_find_or_insert(HashTable *ht, const BinaryKmer key,
                                 bool *found)
{
  const BinaryKmer *ptr;
  size_t i;
  uint_fast32_t h;

  #ifdef HASH_PREFETCH
    uint_fast32_t h2 = binary_kmer_hash(key,ht->seed+0) & ht->hash_mask;
    __builtin_prefetch(ht_bckt_ptr(ht, h2), 0, 1);
  #endif

  for(i = 0; i < REHASH_LIMIT; i++)
  {
    #ifdef HASH_PREFETCH
      h = h2;
      if(ht->buckets[h][HT_BSIZE] == ht->bucket_size) {
        h2 = binary_kmer_hash(key,ht->seed+i+1) & ht->hash_mask;
        __builtin_prefetch(ht_bckt_ptr(ht, h2), 0, 1);
      }
    #else
      h = binary_kmer_hash(key,ht->seed+i) & ht->hash_mask;
    #endif

    ptr = hash_table_find_in_bucket_mt(ht, h, key);

    if(ptr != NULL)  {
      *found = true;
      return (hkey_t)(ptr - ht->table);
    }
    else if(ht->buckets[h][HT_BITEMS] < ht->bucket_size) {
      *found = false;
      ptr = hash_table_insert_in_bucket(ht, h, key);
      ht->collisions[i]++; // only increment collisions when inserting
      ht->num_kmers++;
      return (hkey_t)(ptr - ht->table);
    }
  }

  rehash_error_exit(ht);
}
開發者ID:hksale001,項目名稱:mccortex,代碼行數:41,代碼來源:hash_table.c

示例14: prefetch

            void prefetch() const
            {
#if defined(__x86_64__)
                HPX_ASSERT(sizeof(void*) == 8);
#else
                HPX_ASSERT(sizeof(void*) == 4);
#endif

                __builtin_prefetch(m_sp, 1, 3);
                __builtin_prefetch(m_sp, 0, 3);
                __builtin_prefetch(static_cast<void**>(m_sp) + 64 / sizeof(void*), 1, 3);
                __builtin_prefetch(static_cast<void**>(m_sp) + 64 / sizeof(void*), 0, 3);
#if !defined(__x86_64__)
                __builtin_prefetch(static_cast<void**>(m_sp) + 32 / sizeof(void*), 1, 3);
                __builtin_prefetch(static_cast<void**>(m_sp) + 32 / sizeof(void*), 0, 3);
                __builtin_prefetch(static_cast<void**>(m_sp) - 32 / sizeof(void*), 1, 3);
                __builtin_prefetch(static_cast<void**>(m_sp) - 32 / sizeof(void*), 0, 3);
#endif
                __builtin_prefetch(static_cast<void**>(m_sp) - 64 / sizeof(void*), 1, 3);
                __builtin_prefetch(static_cast<void**>(m_sp) - 64 / sizeof(void*), 0, 3);
            }
開發者ID:atrantan,項目名稱:hpx,代碼行數:21,代碼來源:context_linux_x86.hpp

示例15: bitset_cache_prefetch

// tries to put array of words in cache
void bitset_cache_prefetch(bitset_container_t* B) {
#ifdef IS_X64
    const int32_t CACHELINESIZE =
        computecacheline();  // 64 bytes per cache line
#else
    const int32_t CACHELINESIZE = 64;
#endif
    for (int32_t k = 0; k < BITSET_CONTAINER_SIZE_IN_WORDS;
         k += CACHELINESIZE / (int32_t)sizeof(uint64_t)) {
        __builtin_prefetch(B->array + k);
    }
}
開發者ID:RoaringBitmap,項目名稱:CRoaring,代碼行數:13,代碼來源:bitset_container_benchmark.c


注:本文中的__builtin_prefetch函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。