[Parallel_libs-commits] [parallel-libs] r280737 - [SE] Rename PlatformInterfaces to PlatformDevice

Jason Henline via Parallel_libs-commits parallel_libs-commits at lists.llvm.org
Tue Sep 6 12:27:00 PDT 2016


Author: jhen
Date: Tue Sep  6 14:27:00 2016
New Revision: 280737

URL: http://llvm.org/viewvc/llvm-project?rev=280737&view=rev
Log:
[SE] Rename PlatformInterfaces to PlatformDevice

Summary:
The only interface that we ever plan to have in this file is
PlatformDevice, so it makes sense to rename the file to reflect that.

Reviewers: jprice

Subscribers: parallel_libs-commits

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

Added:
    parallel-libs/trunk/streamexecutor/include/streamexecutor/PlatformDevice.h
      - copied, changed from r280719, parallel-libs/trunk/streamexecutor/include/streamexecutor/PlatformInterfaces.h
    parallel-libs/trunk/streamexecutor/lib/PlatformDevice.cpp
      - copied, changed from r280719, parallel-libs/trunk/streamexecutor/lib/PlatformInterfaces.cpp
Removed:
    parallel-libs/trunk/streamexecutor/include/streamexecutor/PlatformInterfaces.h
    parallel-libs/trunk/streamexecutor/lib/PlatformInterfaces.cpp
Modified:
    parallel-libs/trunk/streamexecutor/include/streamexecutor/Device.h
    parallel-libs/trunk/streamexecutor/include/streamexecutor/Stream.h
    parallel-libs/trunk/streamexecutor/lib/CMakeLists.txt
    parallel-libs/trunk/streamexecutor/lib/Device.cpp
    parallel-libs/trunk/streamexecutor/lib/Kernel.cpp
    parallel-libs/trunk/streamexecutor/lib/unittests/DeviceTest.cpp
    parallel-libs/trunk/streamexecutor/lib/unittests/PackedKernelArgumentArrayTest.cpp
    parallel-libs/trunk/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h
    parallel-libs/trunk/streamexecutor/lib/unittests/StreamTest.cpp

Modified: parallel-libs/trunk/streamexecutor/include/streamexecutor/Device.h
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/include/streamexecutor/Device.h?rev=280737&r1=280736&r2=280737&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/include/streamexecutor/Device.h (original)
+++ parallel-libs/trunk/streamexecutor/include/streamexecutor/Device.h Tue Sep  6 14:27:00 2016
@@ -18,7 +18,7 @@
 #include <type_traits>
 
 #include "streamexecutor/KernelSpec.h"
-#include "streamexecutor/PlatformInterfaces.h"
+#include "streamexecutor/PlatformDevice.h"
 #include "streamexecutor/Utils/Error.h"
 
 namespace streamexecutor {

Copied: parallel-libs/trunk/streamexecutor/include/streamexecutor/PlatformDevice.h (from r280719, parallel-libs/trunk/streamexecutor/include/streamexecutor/PlatformInterfaces.h)
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/include/streamexecutor/PlatformDevice.h?p2=parallel-libs/trunk/streamexecutor/include/streamexecutor/PlatformDevice.h&p1=parallel-libs/trunk/streamexecutor/include/streamexecutor/PlatformInterfaces.h&r1=280719&r2=280737&rev=280737&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/include/streamexecutor/PlatformInterfaces.h (original)
+++ parallel-libs/trunk/streamexecutor/include/streamexecutor/PlatformDevice.h Tue Sep  6 14:27:00 2016
@@ -1,4 +1,4 @@
-//===-- PlatformInterfaces.h - Interfaces to platform impls -----*- C++ -*-===//
+//===-- PlatformDevice.h - PlatformDevice class -----------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -8,20 +8,16 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// Interfaces to platform-specific implementations.
+/// Declaration of the PlatformDevice class.
 ///
-/// The general pattern is that the functions in these interfaces take raw
-/// handle types as parameters. This means that these types and functions are
-/// not intended for public use. Instead, corresponding methods in public types
-/// like Stream, StreamExecutor, and Kernel use C++ templates to create
-/// type-safe public interfaces. Those public functions do the type-unsafe work
-/// of extracting raw handles from their arguments and forwarding those handles
-/// to the methods defined in this file in the proper format.
+/// Each specific platform such as CUDA or OpenCL must subclass PlatformDevice
+/// and override streamexecutor::Platform::getDevice to return an instance of
+/// their PlatformDevice subclass.
 ///
 //===----------------------------------------------------------------------===//
 
-#ifndef STREAMEXECUTOR_PLATFORMINTERFACES_H
-#define STREAMEXECUTOR_PLATFORMINTERFACES_H
+#ifndef STREAMEXECUTOR_PLATFORMDEVICE_H
+#define STREAMEXECUTOR_PLATFORMDEVICE_H
 
 #include "streamexecutor/DeviceMemory.h"
 #include "streamexecutor/Kernel.h"
@@ -33,9 +29,6 @@ namespace streamexecutor {
 
 /// Raw executor methods that must be implemented by each platform.
 ///
-/// This class defines the platform interface that supports executing work on a
-/// device.
-///
 /// The public Device and Stream classes have the type-safe versions of the
 /// functions in this interface.
 class PlatformDevice {
@@ -184,4 +177,4 @@ public:
 
 } // namespace streamexecutor
 
-#endif // STREAMEXECUTOR_PLATFORMINTERFACES_H
+#endif // STREAMEXECUTOR_PLATFORMDEVICE_H

Removed: parallel-libs/trunk/streamexecutor/include/streamexecutor/PlatformInterfaces.h
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/include/streamexecutor/PlatformInterfaces.h?rev=280736&view=auto
==============================================================================
--- parallel-libs/trunk/streamexecutor/include/streamexecutor/PlatformInterfaces.h (original)
+++ parallel-libs/trunk/streamexecutor/include/streamexecutor/PlatformInterfaces.h (removed)
@@ -1,187 +0,0 @@
-//===-- PlatformInterfaces.h - Interfaces to platform impls -----*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file
-/// Interfaces to platform-specific implementations.
-///
-/// The general pattern is that the functions in these interfaces take raw
-/// handle types as parameters. This means that these types and functions are
-/// not intended for public use. Instead, corresponding methods in public types
-/// like Stream, StreamExecutor, and Kernel use C++ templates to create
-/// type-safe public interfaces. Those public functions do the type-unsafe work
-/// of extracting raw handles from their arguments and forwarding those handles
-/// to the methods defined in this file in the proper format.
-///
-//===----------------------------------------------------------------------===//
-
-#ifndef STREAMEXECUTOR_PLATFORMINTERFACES_H
-#define STREAMEXECUTOR_PLATFORMINTERFACES_H
-
-#include "streamexecutor/DeviceMemory.h"
-#include "streamexecutor/Kernel.h"
-#include "streamexecutor/LaunchDimensions.h"
-#include "streamexecutor/PackedKernelArgumentArray.h"
-#include "streamexecutor/Utils/Error.h"
-
-namespace streamexecutor {
-
-/// Raw executor methods that must be implemented by each platform.
-///
-/// This class defines the platform interface that supports executing work on a
-/// device.
-///
-/// The public Device and Stream classes have the type-safe versions of the
-/// functions in this interface.
-class PlatformDevice {
-public:
-  virtual ~PlatformDevice();
-
-  virtual std::string getName() const = 0;
-
-  /// Creates a platform-specific kernel.
-  virtual Expected<const void *>
-  createKernel(const MultiKernelLoaderSpec &Spec) {
-    return make_error("createKernel not implemented for platform " + getName());
-  }
-
-  virtual Error destroyKernel(const void *Handle) {
-    return make_error("destroyKernel not implemented for platform " +
-                      getName());
-  }
-
-  /// Creates a platform-specific stream.
-  virtual Expected<const void *> createStream() {
-    return make_error("createStream not implemented for platform " + getName());
-  }
-
-  virtual Error destroyStream(const void *Handle) {
-    return make_error("destroyStream not implemented for platform " +
-                      getName());
-  }
-
-  /// Launches a kernel on the given stream.
-  virtual Error launch(const void *PlatformStreamHandle,
-                       BlockDimensions BlockSize, GridDimensions GridSize,
-                       const void *PKernelHandle,
-                       const PackedKernelArgumentArrayBase &ArgumentArray) {
-    return make_error("launch not implemented for platform " + getName());
-  }
-
-  /// Copies data from the device to the host.
-  ///
-  /// HostDst should have been allocated by allocateHostMemory or registered
-  /// with registerHostMemory.
-  virtual Error copyD2H(const void *PlatformStreamHandle,
-                        const void *DeviceSrcHandle, size_t SrcByteOffset,
-                        void *HostDst, size_t DstByteOffset, size_t ByteCount) {
-    return make_error("copyD2H not implemented for platform " + getName());
-  }
-
-  /// Copies data from the host to the device.
-  ///
-  /// HostSrc should have been allocated by allocateHostMemory or registered
-  /// with registerHostMemory.
-  virtual Error copyH2D(const void *PlatformStreamHandle, const void *HostSrc,
-                        size_t SrcByteOffset, const void *DeviceDstHandle,
-                        size_t DstByteOffset, size_t ByteCount) {
-    return make_error("copyH2D not implemented for platform " + getName());
-  }
-
-  /// Copies data from one device location to another.
-  virtual Error copyD2D(const void *PlatformStreamHandle,
-                        const void *DeviceSrcHandle, size_t SrcByteOffset,
-                        const void *DeviceDstHandle, size_t DstByteOffset,
-                        size_t ByteCount) {
-    return make_error("copyD2D not implemented for platform " + getName());
-  }
-
-  /// Blocks the host until the given stream completes all the work enqueued up
-  /// to the point this function is called.
-  virtual Error blockHostUntilDone(const void *PlatformStreamHandle) {
-    return make_error("blockHostUntilDone not implemented for platform " +
-                      getName());
-  }
-
-  /// Allocates untyped device memory of a given size in bytes.
-  virtual Expected<void *> allocateDeviceMemory(size_t ByteCount) {
-    return make_error("allocateDeviceMemory not implemented for platform " +
-                      getName());
-  }
-
-  /// Frees device memory previously allocated by allocateDeviceMemory.
-  virtual Error freeDeviceMemory(const void *Handle) {
-    return make_error("freeDeviceMemory not implemented for platform " +
-                      getName());
-  }
-
-  /// Allocates untyped host memory of a given size in bytes.
-  ///
-  /// Host memory allocated via this method is suitable for use with copyH2D and
-  /// copyD2H.
-  virtual Expected<void *> allocateHostMemory(size_t ByteCount) {
-    return make_error("allocateHostMemory not implemented for platform " +
-                      getName());
-  }
-
-  /// Frees host memory allocated by allocateHostMemory.
-  virtual Error freeHostMemory(void *Memory) {
-    return make_error("freeHostMemory not implemented for platform " +
-                      getName());
-  }
-
-  /// Registers previously allocated host memory so it can be used with copyH2D
-  /// and copyD2H.
-  virtual Error registerHostMemory(void *Memory, size_t ByteCount) {
-    return make_error("registerHostMemory not implemented for platform " +
-                      getName());
-  }
-
-  /// Unregisters host memory previously registered with registerHostMemory.
-  virtual Error unregisterHostMemory(void *Memory) {
-    return make_error("unregisterHostMemory not implemented for platform " +
-                      getName());
-  }
-
-  /// Copies the given number of bytes from device memory to host memory.
-  ///
-  /// Blocks the calling host thread until the copy is completed. Can operate on
-  /// any host memory, not just registered host memory or host memory allocated
-  /// by allocateHostMemory. Does not block any ongoing device calls.
-  virtual Error synchronousCopyD2H(const void *DeviceSrcHandle,
-                                   size_t SrcByteOffset, void *HostDst,
-                                   size_t DstByteOffset, size_t ByteCount) {
-    return make_error("synchronousCopyD2H not implemented for platform " +
-                      getName());
-  }
-
-  /// Similar to synchronousCopyD2H(const void *, size_t, void
-  /// *, size_t, size_t), but copies memory from host to device rather than
-  /// device to host.
-  virtual Error synchronousCopyH2D(const void *HostSrc, size_t SrcByteOffset,
-                                   const void *DeviceDstHandle,
-                                   size_t DstByteOffset, size_t ByteCount) {
-    return make_error("synchronousCopyH2D not implemented for platform " +
-                      getName());
-  }
-
-  /// Similar to synchronousCopyD2H(const void *, size_t, void
-  /// *, size_t, size_t), but copies memory from one location in device memory
-  /// to another rather than from device to host.
-  virtual Error synchronousCopyD2D(const void *DeviceDstHandle,
-                                   size_t DstByteOffset,
-                                   const void *DeviceSrcHandle,
-                                   size_t SrcByteOffset, size_t ByteCount) {
-    return make_error("synchronousCopyD2D not implemented for platform " +
-                      getName());
-  }
-};
-
-} // namespace streamexecutor
-
-#endif // STREAMEXECUTOR_PLATFORMINTERFACES_H

Modified: parallel-libs/trunk/streamexecutor/include/streamexecutor/Stream.h
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/include/streamexecutor/Stream.h?rev=280737&r1=280736&r2=280737&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/include/streamexecutor/Stream.h (original)
+++ parallel-libs/trunk/streamexecutor/include/streamexecutor/Stream.h Tue Sep  6 14:27:00 2016
@@ -38,7 +38,7 @@
 #include "streamexecutor/Kernel.h"
 #include "streamexecutor/LaunchDimensions.h"
 #include "streamexecutor/PackedKernelArgumentArray.h"
-#include "streamexecutor/PlatformInterfaces.h"
+#include "streamexecutor/PlatformDevice.h"
 #include "streamexecutor/Utils/Error.h"
 
 #include "llvm/ADT/Optional.h"

Modified: parallel-libs/trunk/streamexecutor/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/lib/CMakeLists.txt?rev=280737&r1=280736&r2=280737&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/lib/CMakeLists.txt (original)
+++ parallel-libs/trunk/streamexecutor/lib/CMakeLists.txt Tue Sep  6 14:27:00 2016
@@ -12,7 +12,7 @@ add_library(
     KernelSpec.cpp
     PackedKernelArgumentArray.cpp
     Platform.cpp
-    PlatformInterfaces.cpp
+    PlatformDevice.cpp
     PlatformManager.cpp
     Stream.cpp)
 target_link_libraries(streamexecutor ${llvm_libs})

Modified: parallel-libs/trunk/streamexecutor/lib/Device.cpp
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/lib/Device.cpp?rev=280737&r1=280736&r2=280737&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/lib/Device.cpp (original)
+++ parallel-libs/trunk/streamexecutor/lib/Device.cpp Tue Sep  6 14:27:00 2016
@@ -16,7 +16,7 @@
 
 #include <cassert>
 
-#include "streamexecutor/PlatformInterfaces.h"
+#include "streamexecutor/PlatformDevice.h"
 #include "streamexecutor/Stream.h"
 
 #include "llvm/ADT/STLExtras.h"

Modified: parallel-libs/trunk/streamexecutor/lib/Kernel.cpp
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/lib/Kernel.cpp?rev=280737&r1=280736&r2=280737&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/lib/Kernel.cpp (original)
+++ parallel-libs/trunk/streamexecutor/lib/Kernel.cpp Tue Sep  6 14:27:00 2016
@@ -16,7 +16,7 @@
 
 #include "streamexecutor/Device.h"
 #include "streamexecutor/Kernel.h"
-#include "streamexecutor/PlatformInterfaces.h"
+#include "streamexecutor/PlatformDevice.h"
 
 #include "llvm/DebugInfo/Symbolize/Symbolize.h"
 

Copied: parallel-libs/trunk/streamexecutor/lib/PlatformDevice.cpp (from r280719, parallel-libs/trunk/streamexecutor/lib/PlatformInterfaces.cpp)
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/lib/PlatformDevice.cpp?p2=parallel-libs/trunk/streamexecutor/lib/PlatformDevice.cpp&p1=parallel-libs/trunk/streamexecutor/lib/PlatformInterfaces.cpp&r1=280719&r2=280737&rev=280737&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/lib/PlatformInterfaces.cpp (original)
+++ parallel-libs/trunk/streamexecutor/lib/PlatformDevice.cpp Tue Sep  6 14:27:00 2016
@@ -1,4 +1,4 @@
-//===-- PlatformInterfaces.cpp - Platform interface implementations -------===//
+//===-- PlatformDevice.cpp - Platform interface implementations -----------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -8,11 +8,11 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// Implementation file for PlatformInterfaces.h.
+/// Implementation file for PlatformDevice.h.
 ///
 //===----------------------------------------------------------------------===//
 
-#include "streamexecutor/PlatformInterfaces.h"
+#include "streamexecutor/PlatformDevice.h"
 
 namespace streamexecutor {
 

Removed: parallel-libs/trunk/streamexecutor/lib/PlatformInterfaces.cpp
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/lib/PlatformInterfaces.cpp?rev=280736&view=auto
==============================================================================
--- parallel-libs/trunk/streamexecutor/lib/PlatformInterfaces.cpp (original)
+++ parallel-libs/trunk/streamexecutor/lib/PlatformInterfaces.cpp (removed)
@@ -1,21 +0,0 @@
-//===-- PlatformInterfaces.cpp - Platform interface implementations -------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file
-/// Implementation file for PlatformInterfaces.h.
-///
-//===----------------------------------------------------------------------===//
-
-#include "streamexecutor/PlatformInterfaces.h"
-
-namespace streamexecutor {
-
-PlatformDevice::~PlatformDevice() = default;
-
-} // namespace streamexecutor

Modified: parallel-libs/trunk/streamexecutor/lib/unittests/DeviceTest.cpp
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/lib/unittests/DeviceTest.cpp?rev=280737&r1=280736&r2=280737&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/lib/unittests/DeviceTest.cpp (original)
+++ parallel-libs/trunk/streamexecutor/lib/unittests/DeviceTest.cpp Tue Sep  6 14:27:00 2016
@@ -17,7 +17,7 @@
 
 #include "SimpleHostPlatformDevice.h"
 #include "streamexecutor/Device.h"
-#include "streamexecutor/PlatformInterfaces.h"
+#include "streamexecutor/PlatformDevice.h"
 
 #include "gtest/gtest.h"
 

Modified: parallel-libs/trunk/streamexecutor/lib/unittests/PackedKernelArgumentArrayTest.cpp
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/lib/unittests/PackedKernelArgumentArrayTest.cpp?rev=280737&r1=280736&r2=280737&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/lib/unittests/PackedKernelArgumentArrayTest.cpp (original)
+++ parallel-libs/trunk/streamexecutor/lib/unittests/PackedKernelArgumentArrayTest.cpp Tue Sep  6 14:27:00 2016
@@ -16,7 +16,7 @@
 #include "streamexecutor/Device.h"
 #include "streamexecutor/DeviceMemory.h"
 #include "streamexecutor/PackedKernelArgumentArray.h"
-#include "streamexecutor/PlatformInterfaces.h"
+#include "streamexecutor/PlatformDevice.h"
 
 #include "llvm/ADT/Twine.h"
 

Modified: parallel-libs/trunk/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h?rev=280737&r1=280736&r2=280737&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h (original)
+++ parallel-libs/trunk/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h Tue Sep  6 14:27:00 2016
@@ -20,7 +20,7 @@
 #include <cstdlib>
 #include <cstring>
 
-#include "streamexecutor/PlatformInterfaces.h"
+#include "streamexecutor/PlatformDevice.h"
 
 namespace streamexecutor {
 namespace test {

Modified: parallel-libs/trunk/streamexecutor/lib/unittests/StreamTest.cpp
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/lib/unittests/StreamTest.cpp?rev=280737&r1=280736&r2=280737&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/lib/unittests/StreamTest.cpp (original)
+++ parallel-libs/trunk/streamexecutor/lib/unittests/StreamTest.cpp Tue Sep  6 14:27:00 2016
@@ -18,7 +18,7 @@
 #include "streamexecutor/Device.h"
 #include "streamexecutor/Kernel.h"
 #include "streamexecutor/KernelSpec.h"
-#include "streamexecutor/PlatformInterfaces.h"
+#include "streamexecutor/PlatformDevice.h"
 #include "streamexecutor/Stream.h"
 
 #include "gtest/gtest.h"




More information about the Parallel_libs-commits mailing list