summaryrefslogtreecommitdiffstats
path: root/parallel-libs/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h
diff options
context:
space:
mode:
authorJason Henline <jhen@google.com>2016-09-01 23:27:39 +0000
committerJason Henline <jhen@google.com>2016-09-01 23:27:39 +0000
commite091f8e814fec8bca64af7fa245edd35c6d15a68 (patch)
tree6a58bb7c5f23655d19358a08c65e5588947d7612 /parallel-libs/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h
parentddd0c125e36808cd56bf434ee38125d464331a78 (diff)
downloadbcm5719-llvm-e091f8e814fec8bca64af7fa245edd35c6d15a68.tar.gz
bcm5719-llvm-e091f8e814fec8bca64af7fa245edd35c6d15a68.zip
[StreamExecutor] Read dev array directly in test
Summary: Step 2 of getting GlobalDeviceMemory to own its handle. Use the SimpleHostPlatformDevice allocate methods to create device arrays for tests, and check for successful copies by dereferncing the device array handle directly because we know it is really a host pointer. Reviewers: jlebar Subscribers: jprice, parallel_libs-commits Differential Revision: https://reviews.llvm.org/D24148 llvm-svn: 280428
Diffstat (limited to 'parallel-libs/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h')
-rw-r--r--parallel-libs/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/parallel-libs/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h b/parallel-libs/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h
index a2dd3c8738f..184c2d7f273 100644
--- a/parallel-libs/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h
+++ b/parallel-libs/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h
@@ -22,12 +22,16 @@
#include "streamexecutor/PlatformInterfaces.h"
+namespace streamexecutor {
+namespace test {
+
/// A streamexecutor::PlatformDevice that simply forwards all operations to the
/// host platform.
///
/// The allocate and copy methods are simple wrappers for std::malloc and
/// std::memcpy.
class SimpleHostPlatformDevice : public streamexecutor::PlatformDevice {
+public:
std::string getName() const override { return "SimpleHostPlatformDevice"; }
streamexecutor::Expected<
@@ -130,6 +134,17 @@ class SimpleHostPlatformDevice : public streamexecutor::PlatformDevice {
ByteCount);
return streamexecutor::Error::success();
}
+
+ /// Gets the value at the given index from a GlobalDeviceMemory<T> instance
+ /// created by this class.
+ template <typename T>
+ static T getDeviceValue(const streamexecutor::GlobalDeviceMemory<T> &Memory,
+ size_t Index) {
+ return static_cast<const T *>(Memory.getHandle())[Index];
+ }
};
+} // namespace test
+} // namespace streamexecutor
+
#endif // STREAMEXECUTOR_LIB_UNITTESTS_SIMPLEHOSTPLATFORMDEVICE_H
OpenPOWER on IntegriCloud