29 #ifndef VC_COMMON_LOADSTOREFLAGS_H_ 
   30 #define VC_COMMON_LOADSTOREFLAGS_H_ 
   32 #include "../traits/type_traits.h" 
   34 namespace Vc_VERSIONED_NAMESPACE
 
   48 namespace LoadStoreFlags
 
   51 struct StreamingFlag {};
 
   52 struct UnalignedFlag {};
 
   53 struct PrefetchFlagBase {};
 
   55 template<
size_t L1 = 8 * 64, 
size_t L2 = 64 * 64,
 
   58 template<
size_t L1 = 16 * 64, 
size_t L2 = 128 * 64,
 
   60     typename ExclusiveOrShared_ = 
void> 
struct PrefetchFlag : 
public PrefetchFlagBase
 
   62     typedef ExclusiveOrShared_ ExclusiveOrShared;
 
   63     static constexpr 
size_t L1Stride = L1;
 
   64     static constexpr 
size_t L2Stride = L2;
 
   65     static constexpr 
bool IsExclusive = std::is_same<ExclusiveOrShared, Exclusive>::value;
 
   66     static constexpr 
bool IsShared = std::is_same<ExclusiveOrShared, Shared>::value;
 
   69 template<
typename Base, 
typename Default, 
typename... LoadStoreFlags> 
struct ExtractType
 
   73 template<
typename Base, 
typename Default, 
typename T, 
typename... LoadStoreFlags> 
struct ExtractType<Base, Default, T, LoadStoreFlags...>
 
   75     typedef typename std::conditional<std::is_base_of<Base, T>::value, T, 
typename ExtractType<Base, Default, LoadStoreFlags...>::type>::type type;
 
   83 #pragma warning(disable: 177) 
   89 template<
typename... Flags> 
struct LoadStoreFlags
 
   94     typedef typename ExtractType<PrefetchFlagBase, PrefetchFlag<0, 0>, Flags...>::type Prefetch;
 
   97     constexpr LoadStoreFlags() {}
 
   99     static constexpr 
bool IsStreaming = !std::is_same<
typename ExtractType<StreamingFlag, void, Flags...>::type, 
void>::value;
 
  100     static constexpr 
bool IsUnaligned = !std::is_same<
typename ExtractType<UnalignedFlag, void, Flags...>::type, 
void>::value;
 
  101     static constexpr 
bool IsAligned = !IsUnaligned;
 
  102     static constexpr 
bool IsPrefetch = !std::is_same<
typename ExtractType<PrefetchFlagBase, void, Flags...>::type, 
void>::value;
 
  103     static constexpr 
bool IsExclusivePrefetch = Prefetch::IsExclusive;
 
  104     static constexpr 
bool IsSharedPrefetch = Prefetch::IsShared;
 
  105     static constexpr 
size_t L1Stride = Prefetch::L1Stride;
 
  106     static constexpr 
size_t L2Stride = Prefetch::L2Stride;
 
  108     typedef LoadStoreFlags<typename std::conditional<std::is_same<Flags, UnalignedFlag>::value, void, Flags>::type...> UnalignedRemoved;
 
  114     typedef typename std::conditional<IsAligned   && !IsStreaming, void *, void>::type EnableIfAligned;
 
  115     typedef typename std::conditional<IsAligned   &&  IsStreaming, void *, void>::type EnableIfStreaming;
 
  116     typedef typename std::conditional<IsUnaligned && !IsStreaming, void *, void>::type EnableIfUnalignedNotStreaming;
 
  117     typedef typename std::conditional<IsUnaligned &&  IsStreaming, void *, void>::type EnableIfUnalignedAndStreaming;
 
  118     typedef typename std::conditional<IsUnaligned                , void *, void>::type EnableIfUnaligned;
 
  119     typedef typename std::conditional<!IsUnaligned               , void *, void>::type EnableIfNotUnaligned;
 
  120     typedef typename std::conditional<IsPrefetch                 , void *, void>::type EnableIfPrefetch;
 
  121     typedef typename std::conditional<!IsPrefetch                , void *, void>::type EnableIfNotPrefetch;
 
  127 template<> 
struct LoadStoreFlags<>
 
  129     constexpr LoadStoreFlags() {}
 
  131     static constexpr 
bool IsStreaming = 
false;
 
  132     static constexpr 
bool IsUnaligned = 
false;
 
  133     static constexpr 
bool IsAligned = !IsUnaligned;
 
  134     static constexpr 
bool IsPrefetch = 
false;
 
  135     static constexpr 
bool IsExclusivePrefetch = 
false;
 
  136     static constexpr 
bool IsSharedPrefetch = 
false;
 
  137     static constexpr 
size_t L1Stride = 0;
 
  138     static constexpr 
size_t L2Stride = 0;
 
  139     typedef void* EnableIfAligned;
 
  140     typedef void* EnableIfNotUnaligned;
 
  141     typedef void* EnableIfNotPrefetch;
 
  152 template<
typename... LFlags, 
typename... RFlags>
 
  153 constexpr LoadStoreFlags<LFlags..., RFlags...> operator|(LoadStoreFlags<LFlags...>, LoadStoreFlags<RFlags...>)
 
  155     return LoadStoreFlags<LFlags..., RFlags...>();
 
  160 using LoadStoreFlags::PrefetchFlag;
 
  162 typedef LoadStoreFlags::LoadStoreFlags<> AlignedTag;
 
  163 typedef LoadStoreFlags::LoadStoreFlags<LoadStoreFlags::StreamingFlag> StreamingTag;
 
  164 typedef LoadStoreFlags::LoadStoreFlags<LoadStoreFlags::UnalignedFlag> UnalignedTag;
 
  226 template <size_t L1 = PrefetchFlag<>::L1Stride,
 
  227           size_t L2 = PrefetchFlag<>::L2Stride,
 
  228           typename ExclusiveOrShared = PrefetchFlag<>::ExclusiveOrShared>
 
  229 struct Prefetch : 
public LoadStoreFlags::LoadStoreFlags<PrefetchFlag<L1, L2, ExclusiveOrShared>>
 
  236 template <
typename... Ts>
 
  237 struct is_loadstoreflag_internal<LoadStoreFlags::LoadStoreFlags<Ts...>> : 
public std::true_type
 
  242 template <
size_t L1, 
size_t L2, 
typename ExclusiveOrShared>
 
  243 struct is_loadstoreflag_internal<Prefetch<L1, L2, ExclusiveOrShared>> : 
public std::true_type
 
  249 #endif // VC_COMMON_LOADSTOREFLAGS_H_ 
Hint for Prefetch to select prefetches that mark the memory as shared. 
 
UnalignedTag DefaultLoadTag
The default load tag type uses unaligned (non-streaming) loads. 
 
constexpr LoadStoreFlags::LoadStoreFlags< PrefetchFlag<> > PrefetchDefault
Use this object for a flags parameter to request default software prefetches to be emitted...
 
Hint for Prefetch to select prefetches that mark the memory as exclusive. 
 
UnalignedTag DefaultStoreTag
The default store tag type uses unaligned (non-streaming) stores. 
 
constexpr AlignedTag Aligned
Use this object for a flags parameter to request aligned loads and stores. 
 
constexpr StreamingTag Streaming
Use this object for a flags parameter to request streaming loads and stores. 
 
constexpr UnalignedTag Unaligned
Use this object for a flags parameter to request unaligned loads and stores.