mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
A few small fixes to a) prevent throwing in ctors and dtors of the threading code, and b) supporting matrix exponential on platforms with 113 bits of mantissa for long doubles.
This commit is contained in:
@@ -42,7 +42,7 @@ class ThreadPoolTempl : public Eigen::ThreadPoolInterface {
|
||||
// indices as (t + coprime) % num_threads, we will cover all threads without
|
||||
// repetitions (effectively getting a presudo-random permutation of thread
|
||||
// indices).
|
||||
eigen_assert(num_threads_ < kMaxThreads);
|
||||
eigen_plain_assert(num_threads_ < kMaxThreads);
|
||||
for (int i = 1; i <= num_threads_; ++i) {
|
||||
all_coprimes_.emplace_back(i);
|
||||
ComputeCoprimes(i, &all_coprimes_.back());
|
||||
@@ -85,7 +85,7 @@ class ThreadPoolTempl : public Eigen::ThreadPoolInterface {
|
||||
}
|
||||
|
||||
void SetStealPartitions(const std::vector<std::pair<unsigned, unsigned>>& partitions) {
|
||||
eigen_assert(partitions.size() == static_cast<std::size_t>(num_threads_));
|
||||
eigen_plain_assert(partitions.size() == static_cast<std::size_t>(num_threads_));
|
||||
|
||||
// Pass this information to each thread queue.
|
||||
for (int i = 0; i < num_threads_; i++) {
|
||||
@@ -112,11 +112,11 @@ class ThreadPoolTempl : public Eigen::ThreadPoolInterface {
|
||||
} else {
|
||||
// A free-standing thread (or worker of another pool), push onto a random
|
||||
// queue.
|
||||
eigen_assert(start < limit);
|
||||
eigen_assert(limit <= num_threads_);
|
||||
eigen_plain_assert(start < limit);
|
||||
eigen_plain_assert(limit <= num_threads_);
|
||||
int num_queues = limit - start;
|
||||
int rnd = Rand(&pt->rand) % num_queues;
|
||||
eigen_assert(start + rnd < limit);
|
||||
eigen_plain_assert(start + rnd < limit);
|
||||
Queue& q = thread_data_[start + rnd].queue;
|
||||
t = q.PushBack(std::move(t));
|
||||
}
|
||||
@@ -182,9 +182,9 @@ class ThreadPoolTempl : public Eigen::ThreadPoolInterface {
|
||||
}
|
||||
|
||||
void AssertBounds(int start, int end) {
|
||||
eigen_assert(start >= 0);
|
||||
eigen_assert(start < end); // non-zero sized partition
|
||||
eigen_assert(end <= num_threads_);
|
||||
eigen_plain_assert(start >= 0);
|
||||
eigen_plain_assert(start < end); // non-zero sized partition
|
||||
eigen_plain_assert(end <= num_threads_);
|
||||
}
|
||||
|
||||
inline void SetStealPartition(size_t i, unsigned val) {
|
||||
@@ -253,7 +253,7 @@ class ThreadPoolTempl : public Eigen::ThreadPoolInterface {
|
||||
#ifndef EIGEN_THREAD_LOCAL
|
||||
std::unique_ptr<PerThread> new_pt(new PerThread());
|
||||
per_thread_map_mutex_.lock();
|
||||
eigen_assert(per_thread_map_.emplace(GlobalThreadIdHash(), std::move(new_pt)).second);
|
||||
eigen_plain_assert(per_thread_map_.emplace(GlobalThreadIdHash(), std::move(new_pt)).second);
|
||||
per_thread_map_mutex_.unlock();
|
||||
init_barrier_->Notify();
|
||||
init_barrier_->Wait();
|
||||
@@ -337,7 +337,7 @@ class ThreadPoolTempl : public Eigen::ThreadPoolInterface {
|
||||
unsigned inc = all_coprimes_[size - 1][r % all_coprimes_[size - 1].size()];
|
||||
|
||||
for (unsigned i = 0; i < size; i++) {
|
||||
eigen_assert(start + victim < limit);
|
||||
eigen_plain_assert(start + victim < limit);
|
||||
Task t = thread_data_[start + victim].queue.PopBack();
|
||||
if (t.f) {
|
||||
return t;
|
||||
@@ -371,7 +371,7 @@ class ThreadPoolTempl : public Eigen::ThreadPoolInterface {
|
||||
// time to exit (returns false). Can optionally return a task to execute in t
|
||||
// (in such case t.f != nullptr on return).
|
||||
bool WaitForWork(EventCount::Waiter* waiter, Task* t) {
|
||||
eigen_assert(!t->f);
|
||||
eigen_plain_assert(!t->f);
|
||||
// We already did best-effort emptiness check in Steal, so prepare for
|
||||
// blocking.
|
||||
ec_.Prewait(waiter);
|
||||
|
||||
Reference in New Issue
Block a user