[SE] Add getName method to Device class

Reviewers: jhen

Subscribers: parallel_libs-commits

Differential Revision: https://reviews.llvm.org/D24240

llvm-svn: 280872
GitOrigin-RevId: fe51c2f7b406f7b1f0e5a69218cc016877c87026
diff --git a/streamexecutor/include/streamexecutor/Device.h b/streamexecutor/include/streamexecutor/Device.h
index e431a45..9774128 100644
--- a/streamexecutor/include/streamexecutor/Device.h
+++ b/streamexecutor/include/streamexecutor/Device.h
@@ -30,6 +30,9 @@
   explicit Device(PlatformDevice *PDevice);
   virtual ~Device();
 
+  /// Gets the name of this device.
+  std::string getName() const { return PDevice->getName(); }
+
   /// Creates a kernel object for this device.
   template <typename KernelT>
   Expected<typename std::enable_if<std::is_base_of<KernelBase, KernelT>::value,
diff --git a/streamexecutor/lib/unittests/DeviceTest.cpp b/streamexecutor/lib/unittests/DeviceTest.cpp
index 08f870d..5b16c3c 100644
--- a/streamexecutor/lib/unittests/DeviceTest.cpp
+++ b/streamexecutor/lib/unittests/DeviceTest.cpp
@@ -74,6 +74,10 @@
 using llvm::ArrayRef;
 using llvm::MutableArrayRef;
 
+TEST_F(DeviceTest, GetName) {
+  EXPECT_EQ(Device.getName(), "SimpleHostPlatformDevice");
+}
+
 TEST_F(DeviceTest, AllocateAndFreeDeviceMemory) {
   se::Expected<se::GlobalDeviceMemory<int>> MaybeMemory =
       Device.allocateDeviceMemory<int>(10);