mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-11 03:09:01 +08:00
Provide EIGEN_OVERRIDE and EIGEN_FINAL macros to mark virtual function overrides
This commit is contained in:
parent
626942d9dd
commit
2c083ace3e
@ -638,6 +638,15 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef EIGEN_HAS_CXX11_OVERRIDE_FINAL
|
||||||
|
#if EIGEN_MAX_CPP_VER>=11 && \
|
||||||
|
(__cplusplus >= 201103L || EIGEN_COMP_MSVC >= 1700)
|
||||||
|
#define EIGEN_HAS_CXX11_OVERRIDE_FINAL 1
|
||||||
|
#else
|
||||||
|
#define EIGEN_HAS_CXX11_OVERRIDE_FINAL 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(EIGEN_CUDACC) && EIGEN_HAS_CONSTEXPR
|
#if defined(EIGEN_CUDACC) && EIGEN_HAS_CONSTEXPR
|
||||||
// While available already with c++11, this is useful mostly starting with c++14 and relaxed constexpr rules
|
// While available already with c++11, this is useful mostly starting with c++14 and relaxed constexpr rules
|
||||||
#if defined(__NVCC__)
|
#if defined(__NVCC__)
|
||||||
@ -1095,6 +1104,15 @@ bool all(T t, Ts ... ts){ return t && all(ts...); }
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if EIGEN_HAS_CXX11_OVERRIDE_FINAL
|
||||||
|
// provide override and final specifiers if they are available:
|
||||||
|
# define EIGEN_OVERRIDE override
|
||||||
|
# define EIGEN_FINAL final
|
||||||
|
#else
|
||||||
|
# define EIGEN_OVERRIDE
|
||||||
|
# define EIGEN_FINAL
|
||||||
|
#endif
|
||||||
|
|
||||||
// Wrapping #pragma unroll in a macro since it is required for SYCL
|
// Wrapping #pragma unroll in a macro since it is required for SYCL
|
||||||
#if defined(__SYCL_DEVICE_ONLY__)
|
#if defined(__SYCL_DEVICE_ONLY__)
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
|
@ -97,7 +97,7 @@ class ThreadPoolTempl : public Eigen::ThreadPoolInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Schedule(std::function<void()> fn) {
|
void Schedule(std::function<void()> fn) EIGEN_OVERRIDE {
|
||||||
ScheduleWithHint(std::move(fn), 0, num_threads_);
|
ScheduleWithHint(std::move(fn), 0, num_threads_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ class ThreadPoolTempl : public Eigen::ThreadPoolInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cancel() {
|
void Cancel() EIGEN_OVERRIDE {
|
||||||
cancelled_ = true;
|
cancelled_ = true;
|
||||||
done_ = true;
|
done_ = true;
|
||||||
|
|
||||||
@ -149,9 +149,9 @@ class ThreadPoolTempl : public Eigen::ThreadPoolInterface {
|
|||||||
ec_.Notify(true);
|
ec_.Notify(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int NumThreads() const final { return num_threads_; }
|
int NumThreads() const EIGEN_FINAL { return num_threads_; }
|
||||||
|
|
||||||
int CurrentThreadId() const final {
|
int CurrentThreadId() const EIGEN_FINAL {
|
||||||
const PerThread* pt = const_cast<ThreadPoolTempl*>(this)->GetPerThread();
|
const PerThread* pt = const_cast<ThreadPoolTempl*>(this)->GetPerThread();
|
||||||
if (pt->pool == this) {
|
if (pt->pool == this) {
|
||||||
return pt->thread_id;
|
return pt->thread_id;
|
||||||
|
@ -18,12 +18,12 @@ using Eigen::Tensor;
|
|||||||
|
|
||||||
class TestAllocator : public Allocator {
|
class TestAllocator : public Allocator {
|
||||||
public:
|
public:
|
||||||
~TestAllocator() override {}
|
~TestAllocator() EIGEN_OVERRIDE {}
|
||||||
EIGEN_DEVICE_FUNC void* allocate(size_t num_bytes) const override {
|
EIGEN_DEVICE_FUNC void* allocate(size_t num_bytes) const EIGEN_OVERRIDE {
|
||||||
const_cast<TestAllocator*>(this)->alloc_count_++;
|
const_cast<TestAllocator*>(this)->alloc_count_++;
|
||||||
return internal::aligned_malloc(num_bytes);
|
return internal::aligned_malloc(num_bytes);
|
||||||
}
|
}
|
||||||
EIGEN_DEVICE_FUNC void deallocate(void* buffer) const override {
|
EIGEN_DEVICE_FUNC void deallocate(void* buffer) const EIGEN_OVERRIDE {
|
||||||
const_cast<TestAllocator*>(this)->dealloc_count_++;
|
const_cast<TestAllocator*>(this)->dealloc_count_++;
|
||||||
internal::aligned_free(buffer);
|
internal::aligned_free(buffer);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user