2007-05-17 00:11:38 +00:00
|
|
|
// This code is in the public domain -- castanyo@yahoo.es
|
|
|
|
|
|
|
|
#ifndef NV_CORE_PREFETCH_H
|
|
|
|
#define NV_CORE_PREFETCH_H
|
|
|
|
|
|
|
|
#include <nvcore/nvcore.h>
|
2007-04-17 08:49:19 +00:00
|
|
|
|
|
|
|
// nvPrefetch
|
|
|
|
#if NV_CC_GNUC
|
|
|
|
|
|
|
|
#define nvPrefetch(ptr) __builtin_prefetch(ptr)
|
|
|
|
|
|
|
|
#elif NV_CC_MSVC
|
|
|
|
|
2008-12-29 11:20:06 +00:00
|
|
|
// Uses SSE Intrinsics for both x86 and x86_64
|
|
|
|
#include <xmmintrin.h>
|
|
|
|
|
2007-04-17 08:49:19 +00:00
|
|
|
__forceinline void nvPrefetch(const void * mem)
|
|
|
|
{
|
2008-12-29 11:20:06 +00:00
|
|
|
_mm_prefetch(static_cast<const char*>(mem), _MM_HINT_T0); /* prefetcht0 */
|
|
|
|
// _mm_prefetch(static_cast<const char*>(mem), _MM_HINT_NTA); /* prefetchnta */
|
2007-04-17 08:49:19 +00:00
|
|
|
}
|
2008-12-29 11:20:06 +00:00
|
|
|
#else
|
2007-04-17 08:49:19 +00:00
|
|
|
|
|
|
|
// do nothing in other case.
|
2008-04-17 18:39:01 +00:00
|
|
|
#define nvPrefetch(ptr)
|
2007-04-17 08:49:19 +00:00
|
|
|
|
|
|
|
#endif // NV_CC_MSVC
|
|
|
|
|
2007-05-17 00:11:38 +00:00
|
|
|
#endif // NV_CORE_PREFETCH_H
|