mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Allow calling attributes of dynamic size objects from device
This commit is contained in:
@@ -83,6 +83,7 @@ namespace Eigen {
|
||||
|
||||
namespace internal {
|
||||
|
||||
EIGEN_DEVICE_FUNC
|
||||
inline void throw_std_bad_alloc()
|
||||
{
|
||||
#ifdef EIGEN_EXCEPTIONS
|
||||
@@ -515,33 +516,33 @@ template<typename T> struct smart_copy_helper<T,false> {
|
||||
{ std::copy(start, end, target); }
|
||||
};
|
||||
|
||||
// intelligent memmove. falls back to std::memmove for POD types, uses std::copy otherwise.
|
||||
template<typename T, bool UseMemmove> struct smart_memmove_helper;
|
||||
|
||||
template<typename T> void smart_memmove(const T* start, const T* end, T* target)
|
||||
{
|
||||
smart_memmove_helper<T,!NumTraits<T>::RequireInitialization>::run(start, end, target);
|
||||
}
|
||||
|
||||
template<typename T> struct smart_memmove_helper<T,true> {
|
||||
static inline void run(const T* start, const T* end, T* target)
|
||||
{ std::memmove(target, start, std::ptrdiff_t(end)-std::ptrdiff_t(start)); }
|
||||
};
|
||||
|
||||
template<typename T> struct smart_memmove_helper<T,false> {
|
||||
static inline void run(const T* start, const T* end, T* target)
|
||||
{
|
||||
if (uintptr_t(target) < uintptr_t(start))
|
||||
{
|
||||
std::copy(start, end, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ptrdiff_t count = (std::ptrdiff_t(end)-std::ptrdiff_t(start)) / sizeof(T);
|
||||
std::copy_backward(start, end, target + count);
|
||||
}
|
||||
}
|
||||
};
|
||||
// intelligent memmove. falls back to std::memmove for POD types, uses std::copy otherwise.
|
||||
template<typename T, bool UseMemmove> struct smart_memmove_helper;
|
||||
|
||||
template<typename T> void smart_memmove(const T* start, const T* end, T* target)
|
||||
{
|
||||
smart_memmove_helper<T,!NumTraits<T>::RequireInitialization>::run(start, end, target);
|
||||
}
|
||||
|
||||
template<typename T> struct smart_memmove_helper<T,true> {
|
||||
static inline void run(const T* start, const T* end, T* target)
|
||||
{ std::memmove(target, start, std::ptrdiff_t(end)-std::ptrdiff_t(start)); }
|
||||
};
|
||||
|
||||
template<typename T> struct smart_memmove_helper<T,false> {
|
||||
static inline void run(const T* start, const T* end, T* target)
|
||||
{
|
||||
if (uintptr_t(target) < uintptr_t(start))
|
||||
{
|
||||
std::copy(start, end, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ptrdiff_t count = (std::ptrdiff_t(end)-std::ptrdiff_t(start)) / sizeof(T);
|
||||
std::copy_backward(start, end, target + count);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user