aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported
diff options
context:
space:
mode:
authorGravatar Rasmus Munk Larsen <rmlarsen@google.com>2020-12-02 11:04:04 -0800
committerGravatar Rasmus Munk Larsen <rmlarsen@google.com>2020-12-02 11:04:04 -0800
commit71c85df4c1ce4efa41bb4adc8e9cb224c3ca9a2d (patch)
treec0f768dccd1dbca1fe17621bf8638c9102b8f170 /unsupported
parent70fbcf82ed0a95b27ee68e20199a4e8e1e913268 (diff)
Clean up the Tensor header and get rid of the EIGEN_SLEEP macro.
Diffstat (limited to 'unsupported')
-rw-r--r--unsupported/Eigen/CXX11/Tensor6
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorDeviceGpu.h2
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorMacros.h9
-rw-r--r--unsupported/test/cxx11_non_blocking_thread_pool.cpp4
-rw-r--r--unsupported/test/cxx11_tensor_notification.cpp8
5 files changed, 11 insertions, 18 deletions
diff --git a/unsupported/Eigen/CXX11/Tensor b/unsupported/Eigen/CXX11/Tensor
index 2640f9565..beed2308a 100644
--- a/unsupported/Eigen/CXX11/Tensor
+++ b/unsupported/Eigen/CXX11/Tensor
@@ -33,10 +33,13 @@
* Much of the documentation can be found \ref eigen_tensors "here".
*/
+#include <atomic>
+#include <chrono>
#include <cmath>
#include <cstddef>
#include <cstring>
#include <random>
+#include <thread>
#ifdef _WIN32
typedef __int16 int16_t;
@@ -48,7 +51,6 @@ typedef unsigned __int64 uint64_t;
#include <windows.h>
#else
#include <stdint.h>
-#include <unistd.h>
#endif
#ifdef _WIN32
@@ -70,8 +72,6 @@ typedef unsigned __int64 uint64_t;
#else
#include <cuda_runtime.h>
#endif
- #include <atomic>
- #include <unistd.h>
#endif
#include "src/Tensor/TensorMacros.h"
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceGpu.h b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceGpu.h
index 7f3394438..9422dcd7a 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceGpu.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceGpu.h
@@ -83,7 +83,7 @@ static void initializeDeviceProp() {
// Wait for the other thread to inititialize the properties.
while (!m_devicePropInitialized) {
std::atomic_thread_fence(std::memory_order_acquire);
- EIGEN_SLEEP(1000);
+ std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
}
}
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorMacros.h b/unsupported/Eigen/CXX11/src/Tensor/TensorMacros.h
index 76d15f114..73ff3d2db 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorMacros.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorMacros.h
@@ -43,15 +43,6 @@
#define EIGEN_SFINAE_ENABLE_IF( __condition__ ) \
typename internal::enable_if< ( __condition__ ) , int >::type = 0
-
-#if EIGEN_OS_WIN || EIGEN_OS_WIN64
-#define EIGEN_SLEEP(n) Sleep(n)
-#elif EIGEN_OS_GNULINUX
-#define EIGEN_SLEEP(n) usleep(n * 1000);
-#else
-#define EIGEN_SLEEP(n) sleep(std::max<unsigned>(1, n/1000))
-#endif
-
// Define a macro to use a reference on the host but a value on the device
#if defined(SYCL_DEVICE_ONLY)
#define EIGEN_DEVICE_REF
diff --git a/unsupported/test/cxx11_non_blocking_thread_pool.cpp b/unsupported/test/cxx11_non_blocking_thread_pool.cpp
index 90b330fdc..993ee1789 100644
--- a/unsupported/test/cxx11_non_blocking_thread_pool.cpp
+++ b/unsupported/test/cxx11_non_blocking_thread_pool.cpp
@@ -109,7 +109,9 @@ static void test_cancel()
// Schedule a large number of closure that each sleeps for one second. This
// will keep the thread pool busy for much longer than the default test timeout.
for (int i = 0; i < 1000; ++i) {
- tp.Schedule([]() { EIGEN_SLEEP(2000); });
+ tp.Schedule([]() {
+ std::this_thread::sleep_for(std::chrono::milliseconds(2000));
+ });
}
// Cancel the processing of all the closures that are still pending.
diff --git a/unsupported/test/cxx11_tensor_notification.cpp b/unsupported/test/cxx11_tensor_notification.cpp
index 2bade8dc7..8e8165302 100644
--- a/unsupported/test/cxx11_tensor_notification.cpp
+++ b/unsupported/test/cxx11_tensor_notification.cpp
@@ -23,7 +23,7 @@ static void test_notification_single()
Eigen::Notification n;
auto func = [&n, &counter](){ n.Wait(); ++counter;};
thread_pool.Schedule(func);
- EIGEN_SLEEP(1000);
+ std::this_thread::sleep_for(std::chrono::milliseconds(1000));
// The thread should be waiting for the notification.
VERIFY_IS_EQUAL(counter, 0);
@@ -31,7 +31,7 @@ static void test_notification_single()
// Unblock the thread
n.Notify();
- EIGEN_SLEEP(1000);
+ std::this_thread::sleep_for(std::chrono::milliseconds(1000));
// Verify the counter has been incremented
VERIFY_IS_EQUAL(counter, 1);
@@ -50,10 +50,10 @@ static void test_notification_multiple()
thread_pool.Schedule(func);
thread_pool.Schedule(func);
thread_pool.Schedule(func);
- EIGEN_SLEEP(1000);
+ std::this_thread::sleep_for(std::chrono::milliseconds(1000));
VERIFY_IS_EQUAL(counter, 0);
n.Notify();
- EIGEN_SLEEP(1000);
+ std::this_thread::sleep_for(std::chrono::milliseconds(1000));
VERIFY_IS_EQUAL(counter, 4);
}