| 60 | } |
| 61 | |
| 62 | const Eigen::ThreadPoolDevice* DeviceBase::eigen_cpu_device() { |
| 63 | // Based on GetPerThreadMaxParallelism(), we return a different |
| 64 | // pre-allocated Eigen::ThreadPoolDevice. All these ThreadPoolDevice |
| 65 | // use the same underlying threadpool. But they use different |
| 66 | // nominal numThreads() hoping that the user of the returned |
| 67 | // Eigen::ThreadPoolDevice may not aggressively occupy all the |
| 68 | // threads in the underlying threadpool. |
| 69 | const int parallelism = std::max<int>( |
| 70 | 1, |
| 71 | std::min<int>(GetPerThreadMaxParallelism(), eigen_cpu_devices_.size())); |
| 72 | return eigen_cpu_devices_[parallelism - 1]; |
| 73 | } |
| 74 | |
| 75 | namespace { |
| 76 | |