|
|
@ -30,6 +30,7 @@ struct CPUPlace {
|
|
|
|
// needed for variant equality comparison
|
|
|
|
// needed for variant equality comparison
|
|
|
|
inline bool operator==(const CPUPlace &) const { return true; }
|
|
|
|
inline bool operator==(const CPUPlace &) const { return true; }
|
|
|
|
inline bool operator!=(const CPUPlace &) const { return false; }
|
|
|
|
inline bool operator!=(const CPUPlace &) const { return false; }
|
|
|
|
|
|
|
|
inline bool operator<(const CPUPlace &) const { return false; }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct CUDAPlace {
|
|
|
|
struct CUDAPlace {
|
|
|
@ -42,6 +43,7 @@ struct CUDAPlace {
|
|
|
|
return device == o.device;
|
|
|
|
return device == o.device;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
inline bool operator!=(const CUDAPlace &o) const { return !(*this == o); }
|
|
|
|
inline bool operator!=(const CUDAPlace &o) const { return !(*this == o); }
|
|
|
|
|
|
|
|
inline bool operator<(const CUDAPlace &o) const { return device < o.device; }
|
|
|
|
|
|
|
|
|
|
|
|
int device;
|
|
|
|
int device;
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -52,6 +54,7 @@ struct CUDAPinnedPlace {
|
|
|
|
// needed for variant equality comparison
|
|
|
|
// needed for variant equality comparison
|
|
|
|
inline bool operator==(const CUDAPinnedPlace &) const { return true; }
|
|
|
|
inline bool operator==(const CUDAPinnedPlace &) const { return true; }
|
|
|
|
inline bool operator!=(const CUDAPinnedPlace &) const { return false; }
|
|
|
|
inline bool operator!=(const CUDAPinnedPlace &) const { return false; }
|
|
|
|
|
|
|
|
inline bool operator<(const CUDAPinnedPlace &) const { return false; }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct IsCUDAPlace : public boost::static_visitor<bool> {
|
|
|
|
struct IsCUDAPlace : public boost::static_visitor<bool> {
|
|
|
@ -89,18 +92,6 @@ bool is_cuda_pinned_place(const Place &);
|
|
|
|
bool places_are_same_class(const Place &, const Place &);
|
|
|
|
bool places_are_same_class(const Place &, const Place &);
|
|
|
|
bool is_same_place(const Place &, const Place &);
|
|
|
|
bool is_same_place(const Place &, const Place &);
|
|
|
|
|
|
|
|
|
|
|
|
struct PlaceHash {
|
|
|
|
|
|
|
|
std::size_t operator()(const Place &p) const {
|
|
|
|
|
|
|
|
constexpr size_t num_dev_bits = 4;
|
|
|
|
|
|
|
|
std::hash<int> ihash;
|
|
|
|
|
|
|
|
size_t dev_id = 0;
|
|
|
|
|
|
|
|
if (is_gpu_place(p)) {
|
|
|
|
|
|
|
|
dev_id = boost::get<CUDAPlace>(p).device;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ihash(dev_id << num_dev_bits | p.which());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::ostream &operator<<(std::ostream &, const Place &);
|
|
|
|
std::ostream &operator<<(std::ostream &, const Place &);
|
|
|
|
|
|
|
|
|
|
|
|
template <typename Visitor>
|
|
|
|
template <typename Visitor>
|
|
|
|