From 71bb1d2460cc7be61efef30d44c24f9e46fe4ab1 Mon Sep 17 00:00:00 2001 From: Jason Henline Date: Tue, 13 Sep 2016 19:25:43 +0000 Subject: [SE] Add .clang-format Summary: The .clang-tidy file is copied from the top-level LLVM source directory. Also fix warnings generated by clang-format: * Moved SimpleHostPlatformDevice.h so its header include guard could have the right format. * Changed signatures of methods taking llvm::Twine by value to take it by const ref instead. * Add "noexcept" to some move constructors and assignment operators. * Removed a bunch of places where single-statement loops and conditionals were surrounded with braces. (This was not found by the current clang-tidy, but with a local patch that I hope to upstream soon.) Reviewers: jlebar, jprice Subscribers: parallel_libs-commits Differential Revision: https://reviews.llvm.org/D24468 --- parallel-libs/.clang-tidy | 17 +++ .../streamexecutor/include/streamexecutor/Device.h | 6 +- .../include/streamexecutor/DeviceMemory.h | 16 ++- .../streamexecutor/include/streamexecutor/Error.h | 2 +- .../include/streamexecutor/HostMemory.h | 4 +- .../streamexecutor/include/streamexecutor/Kernel.h | 15 ++- .../include/streamexecutor/KernelSpec.h | 3 +- .../streamexecutor/include/streamexecutor/Stream.h | 6 +- .../unittests/CoreTests/SimpleHostPlatformDevice.h | 138 +++++++++++++++++++++ parallel-libs/streamexecutor/lib/Device.cpp | 3 +- parallel-libs/streamexecutor/lib/DeviceMemory.cpp | 3 +- parallel-libs/streamexecutor/lib/Error.cpp | 5 +- parallel-libs/streamexecutor/lib/HostMemory.cpp | 3 +- parallel-libs/streamexecutor/lib/Kernel.cpp | 4 +- parallel-libs/streamexecutor/lib/KernelSpec.cpp | 11 +- parallel-libs/streamexecutor/lib/Stream.cpp | 4 +- .../unittests/CoreTests/DeviceTest.cpp | 86 +++++-------- .../CoreTests/PackedKernelArgumentArrayTest.cpp | 2 +- .../unittests/CoreTests/SimpleHostPlatformDevice.h | 138 --------------------- .../unittests/CoreTests/StreamTest.cpp | 77 ++++-------- 20 files changed, 255 insertions(+), 288 deletions(-) create mode 100644 parallel-libs/.clang-tidy create mode 100644 parallel-libs/streamexecutor/include/streamexecutor/unittests/CoreTests/SimpleHostPlatformDevice.h delete mode 100644 parallel-libs/streamexecutor/unittests/CoreTests/SimpleHostPlatformDevice.h (limited to 'parallel-libs') diff --git a/parallel-libs/.clang-tidy b/parallel-libs/.clang-tidy new file mode 100644 index 00000000000..53a5a7ebbca --- /dev/null +++ b/parallel-libs/.clang-tidy @@ -0,0 +1,17 @@ +Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming' +CheckOptions: + - key: readability-identifier-naming.ClassCase + value: CamelCase + - key: readability-identifier-naming.EnumCase + value: CamelCase + - key: readability-identifier-naming.FunctionCase + value: lowerCase + - key: readability-identifier-naming.MemberCase + value: CamelCase + - key: readability-identifier-naming.ParameterCase + value: CamelCase + - key: readability-identifier-naming.UnionCase + value: CamelCase + - key: readability-identifier-naming.VariableCase + value: CamelCase + diff --git a/parallel-libs/streamexecutor/include/streamexecutor/Device.h b/parallel-libs/streamexecutor/include/streamexecutor/Device.h index 83840e82d01..53c0c2f1cd2 100644 --- a/parallel-libs/streamexecutor/include/streamexecutor/Device.h +++ b/parallel-libs/streamexecutor/include/streamexecutor/Device.h @@ -40,9 +40,8 @@ public: KernelT>::type> createKernel(const MultiKernelLoaderSpec &Spec) { Expected MaybeKernelHandle = PDevice->createKernel(Spec); - if (!MaybeKernelHandle) { + if (!MaybeKernelHandle) return MaybeKernelHandle.takeError(); - } return KernelT(PDevice, *MaybeKernelHandle, Spec.getKernelName()); } @@ -68,9 +67,8 @@ public: Expected> registerHostMemory(llvm::MutableArrayRef Memory) { if (Error E = PDevice->registerHostMemory(Memory.data(), - Memory.size() * sizeof(T))) { + Memory.size() * sizeof(T))) return std::move(E); - } return RegisteredHostMemory(this, Memory.data(), Memory.size()); } diff --git a/parallel-libs/streamexecutor/include/streamexecutor/DeviceMemory.h b/parallel-libs/streamexecutor/include/streamexecutor/DeviceMemory.h index bad6f6c99a1..d8f7cefc398 100644 --- a/parallel-libs/streamexecutor/include/streamexecutor/DeviceMemory.h +++ b/parallel-libs/streamexecutor/include/streamexecutor/DeviceMemory.h @@ -143,7 +143,7 @@ protected: : TheDevice(D), Handle(Handle), ByteCount(ByteCount) {} /// Transfer ownership of the underlying handle. - GlobalDeviceMemoryBase(GlobalDeviceMemoryBase &&Other) + GlobalDeviceMemoryBase(GlobalDeviceMemoryBase &&Other) noexcept : TheDevice(Other.TheDevice), Handle(Other.Handle), ByteCount(Other.ByteCount) { Other.TheDevice = nullptr; @@ -151,7 +151,7 @@ protected: Other.ByteCount = 0; } - GlobalDeviceMemoryBase &operator=(GlobalDeviceMemoryBase &&Other) { + GlobalDeviceMemoryBase &operator=(GlobalDeviceMemoryBase &&Other) noexcept { TheDevice = Other.TheDevice; Handle = Other.Handle; ByteCount = Other.ByteCount; @@ -178,8 +178,8 @@ class GlobalDeviceMemory : public GlobalDeviceMemoryBase { public: using ElementTy = ElemT; - GlobalDeviceMemory(GlobalDeviceMemory &&Other) = default; - GlobalDeviceMemory &operator=(GlobalDeviceMemory &&Other) = default; + GlobalDeviceMemory(GlobalDeviceMemory &&) noexcept; + GlobalDeviceMemory &operator=(GlobalDeviceMemory &&) noexcept; /// Returns the number of elements of type ElemT that constitute this /// allocation. @@ -203,6 +203,14 @@ private: : GlobalDeviceMemoryBase(D, Handle, ElementCount * sizeof(ElemT)) {} }; +template +GlobalDeviceMemory::GlobalDeviceMemory( + GlobalDeviceMemory &&) noexcept = default; + +template +GlobalDeviceMemory &GlobalDeviceMemory:: +operator=(GlobalDeviceMemory &&) noexcept = default; + /// A class to represent the size of a dynamic shared memory buffer of elements /// of type T on a device. /// diff --git a/parallel-libs/streamexecutor/include/streamexecutor/Error.h b/parallel-libs/streamexecutor/include/streamexecutor/Error.h index b2d1ebb830d..d33a5a6a79a 100644 --- a/parallel-libs/streamexecutor/include/streamexecutor/Error.h +++ b/parallel-libs/streamexecutor/include/streamexecutor/Error.h @@ -178,7 +178,7 @@ using llvm::Expected; using llvm::Twine; /// Makes an Error object from an error message. -Error make_error(Twine Message); +Error make_error(const Twine &Message); /// Consumes the input error and returns its error message. /// diff --git a/parallel-libs/streamexecutor/include/streamexecutor/HostMemory.h b/parallel-libs/streamexecutor/include/streamexecutor/HostMemory.h index cea98f4ed74..18ff184ba68 100644 --- a/parallel-libs/streamexecutor/include/streamexecutor/HostMemory.h +++ b/parallel-libs/streamexecutor/include/streamexecutor/HostMemory.h @@ -151,14 +151,14 @@ public: RegisteredHostMemory(const RegisteredHostMemory &) = delete; RegisteredHostMemory &operator=(const RegisteredHostMemory &) = delete; - RegisteredHostMemory(RegisteredHostMemory &&Other) + RegisteredHostMemory(RegisteredHostMemory &&Other) noexcept : TheDevice(Other.TheDevice), Pointer(Other.Pointer), ElementCount(Other.ElementCount) { Other.TheDevice = nullptr; Other.Pointer = nullptr; } - RegisteredHostMemory &operator=(RegisteredHostMemory &&Other) { + RegisteredHostMemory &operator=(RegisteredHostMemory &&Other) noexcept { TheDevice = Other.TheDevice; Pointer = Other.Pointer; ElementCount = Other.ElementCount; diff --git a/parallel-libs/streamexecutor/include/streamexecutor/Kernel.h b/parallel-libs/streamexecutor/include/streamexecutor/Kernel.h index d8cbb8ad26b..eb023816428 100644 --- a/parallel-libs/streamexecutor/include/streamexecutor/Kernel.h +++ b/parallel-libs/streamexecutor/include/streamexecutor/Kernel.h @@ -41,8 +41,8 @@ public: KernelBase(const KernelBase &Other) = delete; KernelBase &operator=(const KernelBase &Other) = delete; - KernelBase(KernelBase &&Other); - KernelBase &operator=(KernelBase &&Other); + KernelBase(KernelBase &&Other) noexcept; + KernelBase &operator=(KernelBase &&Other) noexcept; ~KernelBase(); @@ -68,10 +68,17 @@ public: llvm::StringRef Name) : KernelBase(D, PlatformKernelHandle, Name) {} - Kernel(Kernel &&Other) = default; - Kernel &operator=(Kernel &&Other) = default; + Kernel(Kernel &&Other) noexcept; + Kernel &operator=(Kernel &&Other) noexcept; }; +template +Kernel::Kernel(Kernel &&) noexcept = default; + +template +Kernel &Kernel:: +operator=(Kernel &&) noexcept = default; + } // namespace streamexecutor #endif // STREAMEXECUTOR_KERNEL_H diff --git a/parallel-libs/streamexecutor/include/streamexecutor/KernelSpec.h b/parallel-libs/streamexecutor/include/streamexecutor/KernelSpec.h index e3d2beca04b..c4b6722caf6 100644 --- a/parallel-libs/streamexecutor/include/streamexecutor/KernelSpec.h +++ b/parallel-libs/streamexecutor/include/streamexecutor/KernelSpec.h @@ -200,9 +200,8 @@ private: class MultiKernelLoaderSpec { public: std::string getKernelName() const { - if (TheKernelName) { + if (TheKernelName) return *TheKernelName; - } return ""; } diff --git a/parallel-libs/streamexecutor/include/streamexecutor/Stream.h b/parallel-libs/streamexecutor/include/streamexecutor/Stream.h index c293464d364..bdff7ff9701 100644 --- a/parallel-libs/streamexecutor/include/streamexecutor/Stream.h +++ b/parallel-libs/streamexecutor/include/streamexecutor/Stream.h @@ -66,8 +66,8 @@ public: Stream(const Stream &Other) = delete; Stream &operator=(const Stream &Other) = delete; - Stream(Stream &&Other); - Stream &operator=(Stream &&Other); + Stream(Stream &&Other) noexcept; + Stream &operator=(Stream &&Other) noexcept; ~Stream(); @@ -288,7 +288,7 @@ private: /// Sets the error state from an error message. /// /// Does not overwrite the error if it is already set. - void setError(llvm::Twine Message) { + void setError(const llvm::Twine &Message) { llvm::sys::ScopedWriter WriterLock(*ErrorMessageMutex); if (!ErrorMessage) ErrorMessage = Message.str(); diff --git a/parallel-libs/streamexecutor/include/streamexecutor/unittests/CoreTests/SimpleHostPlatformDevice.h b/parallel-libs/streamexecutor/include/streamexecutor/unittests/CoreTests/SimpleHostPlatformDevice.h new file mode 100644 index 00000000000..3c3f736e469 --- /dev/null +++ b/parallel-libs/streamexecutor/include/streamexecutor/unittests/CoreTests/SimpleHostPlatformDevice.h @@ -0,0 +1,138 @@ +//===-- SimpleHostPlatformDevice.h - Host device for testing ----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// The SimpleHostPlatformDevice class is a streamexecutor::PlatformDevice that +/// is really just the host processor and memory. It is useful for testing +/// because no extra device platform is required. +/// +//===----------------------------------------------------------------------===// + +#ifndef STREAMEXECUTOR_UNITTESTS_CORETESTS_SIMPLEHOSTPLATFORMDEVICE_H +#define STREAMEXECUTOR_UNITTESTS_CORETESTS_SIMPLEHOSTPLATFORMDEVICE_H + +#include +#include + +#include "streamexecutor/PlatformDevice.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 createStream() override { + return nullptr; + } + + streamexecutor::Expected + allocateDeviceMemory(size_t ByteCount) override { + return std::malloc(ByteCount); + } + + streamexecutor::Error freeDeviceMemory(const void *Handle) override { + std::free(const_cast(Handle)); + return streamexecutor::Error::success(); + } + + streamexecutor::Error registerHostMemory(void *Memory, + size_t ByteCount) override { + return streamexecutor::Error::success(); + } + + streamexecutor::Error unregisterHostMemory(const void *Memory) override { + return streamexecutor::Error::success(); + } + + streamexecutor::Error copyD2H(const void *StreamHandle, + const void *DeviceHandleSrc, + size_t SrcByteOffset, void *HostDst, + size_t DstByteOffset, + size_t ByteCount) override { + std::memcpy(static_cast(HostDst) + DstByteOffset, + static_cast(DeviceHandleSrc) + SrcByteOffset, + ByteCount); + return streamexecutor::Error::success(); + } + + streamexecutor::Error copyH2D(const void *StreamHandle, const void *HostSrc, + size_t SrcByteOffset, + const void *DeviceHandleDst, + size_t DstByteOffset, + size_t ByteCount) override { + std::memcpy(static_cast(const_cast(DeviceHandleDst)) + + DstByteOffset, + static_cast(HostSrc) + SrcByteOffset, ByteCount); + return streamexecutor::Error::success(); + } + + streamexecutor::Error + copyD2D(const void *StreamHandle, const void *DeviceHandleSrc, + size_t SrcByteOffset, const void *DeviceHandleDst, + size_t DstByteOffset, size_t ByteCount) override { + std::memcpy(static_cast(const_cast(DeviceHandleDst)) + + DstByteOffset, + static_cast(DeviceHandleSrc) + SrcByteOffset, + ByteCount); + return streamexecutor::Error::success(); + } + + streamexecutor::Error synchronousCopyD2H(const void *DeviceHandleSrc, + size_t SrcByteOffset, void *HostDst, + size_t DstByteOffset, + size_t ByteCount) override { + std::memcpy(static_cast(HostDst) + DstByteOffset, + static_cast(DeviceHandleSrc) + SrcByteOffset, + ByteCount); + return streamexecutor::Error::success(); + } + + streamexecutor::Error synchronousCopyH2D(const void *HostSrc, + size_t SrcByteOffset, + const void *DeviceHandleDst, + size_t DstByteOffset, + size_t ByteCount) override { + std::memcpy(static_cast(const_cast(DeviceHandleDst)) + + DstByteOffset, + static_cast(HostSrc) + SrcByteOffset, ByteCount); + return streamexecutor::Error::success(); + } + + streamexecutor::Error synchronousCopyD2D(const void *DeviceHandleSrc, + size_t SrcByteOffset, + const void *DeviceHandleDst, + size_t DstByteOffset, + size_t ByteCount) override { + std::memcpy(static_cast(const_cast(DeviceHandleDst)) + + DstByteOffset, + static_cast(DeviceHandleSrc) + SrcByteOffset, + ByteCount); + return streamexecutor::Error::success(); + } + + /// Gets the value at the given index from a GlobalDeviceMemory instance + /// created by this class. + template + static T getDeviceValue(const streamexecutor::GlobalDeviceMemory &Memory, + size_t Index) { + return static_cast(Memory.getHandle())[Index]; + } +}; + +} // namespace test +} // namespace streamexecutor + +#endif // STREAMEXECUTOR_UNITTESTS_CORETESTS_SIMPLEHOSTPLATFORMDEVICE_H diff --git a/parallel-libs/streamexecutor/lib/Device.cpp b/parallel-libs/streamexecutor/lib/Device.cpp index 260c1ba17cd..2bed3e7be16 100644 --- a/parallel-libs/streamexecutor/lib/Device.cpp +++ b/parallel-libs/streamexecutor/lib/Device.cpp @@ -29,9 +29,8 @@ Device::~Device() = default; Expected Device::createStream() { Expected MaybePlatformStream = PDevice->createStream(); - if (!MaybePlatformStream) { + if (!MaybePlatformStream) return MaybePlatformStream.takeError(); - } return Stream(PDevice, *MaybePlatformStream); } diff --git a/parallel-libs/streamexecutor/lib/DeviceMemory.cpp b/parallel-libs/streamexecutor/lib/DeviceMemory.cpp index 62b702b8acf..8447a60b1ca 100644 --- a/parallel-libs/streamexecutor/lib/DeviceMemory.cpp +++ b/parallel-libs/streamexecutor/lib/DeviceMemory.cpp @@ -19,10 +19,9 @@ namespace streamexecutor { GlobalDeviceMemoryBase::~GlobalDeviceMemoryBase() { - if (Handle) { + if (Handle) // TODO(jhen): How to handle errors here. consumeError(TheDevice->freeDeviceMemory(*this)); - } } } // namespace streamexecutor diff --git a/parallel-libs/streamexecutor/lib/Error.cpp b/parallel-libs/streamexecutor/lib/Error.cpp index 1f9d4a7834d..0d728fab669 100644 --- a/parallel-libs/streamexecutor/lib/Error.cpp +++ b/parallel-libs/streamexecutor/lib/Error.cpp @@ -44,14 +44,13 @@ char StreamExecutorError::ID = 0; namespace streamexecutor { -Error make_error(Twine Message) { +Error make_error(const Twine &Message) { return llvm::make_error(Message.str()); } std::string consumeAndGetMessage(Error &&E) { - if (!E) { + if (!E) return "success"; - } std::string Message; llvm::handleAllErrors(std::move(E), [&Message](const StreamExecutorError &SEE) { diff --git a/parallel-libs/streamexecutor/lib/HostMemory.cpp b/parallel-libs/streamexecutor/lib/HostMemory.cpp index f7fbe044aa3..8eba7e6b563 100644 --- a/parallel-libs/streamexecutor/lib/HostMemory.cpp +++ b/parallel-libs/streamexecutor/lib/HostMemory.cpp @@ -20,9 +20,8 @@ namespace internal { void destroyRegisteredHostMemoryInternals(Device *TheDevice, void *Pointer) { // TODO(jhen): How to handle errors here? - if (Pointer) { + if (Pointer) consumeError(TheDevice->unregisterHostMemory(Pointer)); - } } } // namespace internal diff --git a/parallel-libs/streamexecutor/lib/Kernel.cpp b/parallel-libs/streamexecutor/lib/Kernel.cpp index 55a83514f48..911ac6656aa 100644 --- a/parallel-libs/streamexecutor/lib/Kernel.cpp +++ b/parallel-libs/streamexecutor/lib/Kernel.cpp @@ -33,7 +33,7 @@ KernelBase::KernelBase(PlatformDevice *D, const void *PlatformKernelHandle, "cannot construct a kernel object with a null platform kernel handle"); } -KernelBase::KernelBase(KernelBase &&Other) +KernelBase::KernelBase(KernelBase &&Other) noexcept : PDevice(Other.PDevice), PlatformKernelHandle(Other.PlatformKernelHandle), Name(std::move(Other.Name)), DemangledName(std::move(Other.DemangledName)) { @@ -41,7 +41,7 @@ KernelBase::KernelBase(KernelBase &&Other) Other.PlatformKernelHandle = nullptr; } -KernelBase &KernelBase::operator=(KernelBase &&Other) { +KernelBase &KernelBase::operator=(KernelBase &&Other) noexcept { PDevice = Other.PDevice; PlatformKernelHandle = Other.PlatformKernelHandle; Name = std::move(Other.Name); diff --git a/parallel-libs/streamexecutor/lib/KernelSpec.cpp b/parallel-libs/streamexecutor/lib/KernelSpec.cpp index d2715aa88a5..b5753a489d1 100644 --- a/parallel-libs/streamexecutor/lib/KernelSpec.cpp +++ b/parallel-libs/streamexecutor/lib/KernelSpec.cpp @@ -25,9 +25,8 @@ CUDAPTXInMemorySpec::CUDAPTXInMemorySpec( llvm::StringRef KernelName, const llvm::ArrayRef SpecList) : KernelLoaderSpec(KernelName) { - for (const auto &Spec : SpecList) { + for (const auto &Spec : SpecList) PTXByComputeCapability.emplace(Spec.TheComputeCapability, Spec.PTXCode); - } } const char *CUDAPTXInMemorySpec::getCode(int ComputeCapabilityMajor, @@ -35,9 +34,8 @@ const char *CUDAPTXInMemorySpec::getCode(int ComputeCapabilityMajor, auto PTXIter = PTXByComputeCapability.find(CUDAPTXInMemorySpec::ComputeCapability{ ComputeCapabilityMajor, ComputeCapabilityMinor}); - if (PTXIter == PTXByComputeCapability.end()) { + if (PTXIter == PTXByComputeCapability.end()) return nullptr; - } return PTXIter->second; } @@ -50,12 +48,11 @@ OpenCLTextInMemorySpec::OpenCLTextInMemorySpec(llvm::StringRef KernelName, : KernelLoaderSpec(KernelName), Text(Text) {} void MultiKernelLoaderSpec::setKernelName(llvm::StringRef KernelName) { - if (TheKernelName) { + if (TheKernelName) assert(KernelName.equals(*TheKernelName) && "different kernel names in one MultiKernelLoaderSpec"); - } else { + else TheKernelName = llvm::make_unique(KernelName); - } } MultiKernelLoaderSpec &MultiKernelLoaderSpec::addCUDAPTXInMemory( diff --git a/parallel-libs/streamexecutor/lib/Stream.cpp b/parallel-libs/streamexecutor/lib/Stream.cpp index 96aad044c9c..fe135b4d0af 100644 --- a/parallel-libs/streamexecutor/lib/Stream.cpp +++ b/parallel-libs/streamexecutor/lib/Stream.cpp @@ -27,7 +27,7 @@ Stream::Stream(PlatformDevice *D, const void *PlatformStreamHandle) "cannot construct a stream object with a null platform stream handle"); } -Stream::Stream(Stream &&Other) +Stream::Stream(Stream &&Other) noexcept : PDevice(Other.PDevice), PlatformStreamHandle(Other.PlatformStreamHandle), ErrorMessageMutex(std::move(Other.ErrorMessageMutex)), ErrorMessage(std::move(Other.ErrorMessage)) { @@ -35,7 +35,7 @@ Stream::Stream(Stream &&Other) Other.PlatformStreamHandle = nullptr; } -Stream &Stream::operator=(Stream &&Other) { +Stream &Stream::operator=(Stream &&Other) noexcept { PDevice = Other.PDevice; PlatformStreamHandle = Other.PlatformStreamHandle; ErrorMessageMutex = std::move(Other.ErrorMessageMutex); diff --git a/parallel-libs/streamexecutor/unittests/CoreTests/DeviceTest.cpp b/parallel-libs/streamexecutor/unittests/CoreTests/DeviceTest.cpp index 8537f0a3af0..306a9567d20 100644 --- a/parallel-libs/streamexecutor/unittests/CoreTests/DeviceTest.cpp +++ b/parallel-libs/streamexecutor/unittests/CoreTests/DeviceTest.cpp @@ -15,9 +15,9 @@ #include #include -#include "SimpleHostPlatformDevice.h" #include "streamexecutor/Device.h" #include "streamexecutor/PlatformDevice.h" +#include "streamexecutor/unittests/CoreTests/SimpleHostPlatformDevice.h" #include "gtest/gtest.h" @@ -96,15 +96,13 @@ TEST_F(DeviceTest, RegisterAndUnregisterHostMemory) { TEST_F(DeviceTest, SyncCopyD2HToMutableArrayRefByCount) { EXPECT_NO_ERROR( Device.synchronousCopyD2H(DeviceA5, MutableArrayRef(Host5), 5)); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(HostA5[I], Host5[I]); - } EXPECT_NO_ERROR( Device.synchronousCopyD2H(DeviceB5, MutableArrayRef(Host5), 2)); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(HostB5[I], Host5[I]); - } EXPECT_ERROR( Device.synchronousCopyD2H(DeviceA7, MutableArrayRef(Host5), 7)); @@ -119,9 +117,8 @@ TEST_F(DeviceTest, SyncCopyD2HToMutableArrayRefByCount) { TEST_F(DeviceTest, SyncCopyD2HToMutableArrayRef) { EXPECT_NO_ERROR( Device.synchronousCopyD2H(DeviceA5, MutableArrayRef(Host5))); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(HostA5[I], Host5[I]); - } EXPECT_ERROR( Device.synchronousCopyD2H(DeviceA7, MutableArrayRef(Host5))); @@ -132,9 +129,8 @@ TEST_F(DeviceTest, SyncCopyD2HToMutableArrayRef) { TEST_F(DeviceTest, SyncCopyD2HToPointer) { EXPECT_NO_ERROR(Device.synchronousCopyD2H(DeviceA5, Host5, 5)); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(HostA5[I], Host5[I]); - } EXPECT_ERROR(Device.synchronousCopyD2H(DeviceA5, Host7, 7)); } @@ -142,15 +138,13 @@ TEST_F(DeviceTest, SyncCopyD2HToPointer) { TEST_F(DeviceTest, SyncCopyD2HSliceToMutableArrayRefByCount) { EXPECT_NO_ERROR(Device.synchronousCopyD2H( DeviceA5.asSlice().slice(1), MutableArrayRef(Host5 + 1, 4), 4)); - for (int I = 1; I < 5; ++I) { + for (int I = 1; I < 5; ++I) EXPECT_EQ(HostA5[I], Host5[I]); - } EXPECT_NO_ERROR(Device.synchronousCopyD2H(DeviceB5.asSlice().drop_back(1), MutableArrayRef(Host5), 2)); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(HostB5[I], Host5[I]); - } EXPECT_ERROR(Device.synchronousCopyD2H(DeviceA7.asSlice(), MutableArrayRef(Host5), 7)); @@ -165,9 +159,8 @@ TEST_F(DeviceTest, SyncCopyD2HSliceToMutableArrayRefByCount) { TEST_F(DeviceTest, SyncCopyD2HSliceToMutableArrayRef) { EXPECT_NO_ERROR(Device.synchronousCopyD2H(DeviceA7.asSlice().slice(1, 5), MutableArrayRef(Host5))); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(HostA7[I + 1], Host5[I]); - } EXPECT_ERROR(Device.synchronousCopyD2H(DeviceA7.asSlice().drop_back(1), MutableArrayRef(Host5))); @@ -179,9 +172,8 @@ TEST_F(DeviceTest, SyncCopyD2HSliceToMutableArrayRef) { TEST_F(DeviceTest, SyncCopyD2HSliceToPointer) { EXPECT_NO_ERROR( Device.synchronousCopyD2H(DeviceA5.asSlice().slice(1), Host5 + 1, 4)); - for (int I = 1; I < 5; ++I) { + for (int I = 1; I < 5; ++I) EXPECT_EQ(HostA5[I], Host5[I]); - } EXPECT_ERROR(Device.synchronousCopyD2H(DeviceA5.asSlice(), Host7, 7)); } @@ -190,14 +182,12 @@ TEST_F(DeviceTest, SyncCopyD2HSliceToPointer) { TEST_F(DeviceTest, SyncCopyH2DToArrayRefByCount) { EXPECT_NO_ERROR(Device.synchronousCopyH2D(ArrayRef(Host5), DeviceA5, 5)); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]); - } EXPECT_NO_ERROR(Device.synchronousCopyH2D(ArrayRef(Host5), DeviceB5, 2)); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(getDeviceValue(DeviceB5, I), Host5[I]); - } EXPECT_ERROR(Device.synchronousCopyH2D(ArrayRef(Host7), DeviceA5, 7)); @@ -208,9 +198,8 @@ TEST_F(DeviceTest, SyncCopyH2DToArrayRefByCount) { TEST_F(DeviceTest, SyncCopyH2DToArrayRef) { EXPECT_NO_ERROR(Device.synchronousCopyH2D(ArrayRef(Host5), DeviceA5)); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]); - } EXPECT_ERROR(Device.synchronousCopyH2D(ArrayRef(Host5), DeviceA7)); @@ -219,9 +208,8 @@ TEST_F(DeviceTest, SyncCopyH2DToArrayRef) { TEST_F(DeviceTest, SyncCopyH2DToPointer) { EXPECT_NO_ERROR(Device.synchronousCopyH2D(Host5, DeviceA5, 5)); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]); - } EXPECT_ERROR(Device.synchronousCopyH2D(Host7, DeviceA5, 7)); } @@ -229,15 +217,13 @@ TEST_F(DeviceTest, SyncCopyH2DToPointer) { TEST_F(DeviceTest, SyncCopyH2DSliceToArrayRefByCount) { EXPECT_NO_ERROR(Device.synchronousCopyH2D(ArrayRef(Host5 + 1, 4), DeviceA5.asSlice().slice(1), 4)); - for (int I = 1; I < 5; ++I) { + for (int I = 1; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]); - } EXPECT_NO_ERROR(Device.synchronousCopyH2D( ArrayRef(Host5), DeviceB5.asSlice().drop_back(1), 2)); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(getDeviceValue(DeviceB5, I), Host5[I]); - } EXPECT_ERROR( Device.synchronousCopyH2D(ArrayRef(Host7), DeviceA5.asSlice(), 7)); @@ -252,9 +238,8 @@ TEST_F(DeviceTest, SyncCopyH2DSliceToArrayRefByCount) { TEST_F(DeviceTest, SyncCopyH2DSliceToArrayRef) { EXPECT_NO_ERROR( Device.synchronousCopyH2D(ArrayRef(Host5), DeviceA5.asSlice())); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]); - } EXPECT_ERROR( Device.synchronousCopyH2D(ArrayRef(Host5), DeviceA7.asSlice())); @@ -265,9 +250,8 @@ TEST_F(DeviceTest, SyncCopyH2DSliceToArrayRef) { TEST_F(DeviceTest, SyncCopyH2DSliceToPointer) { EXPECT_NO_ERROR(Device.synchronousCopyH2D(Host5, DeviceA5.asSlice(), 5)); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]); - } EXPECT_ERROR(Device.synchronousCopyH2D(Host7, DeviceA5.asSlice(), 7)); } @@ -276,14 +260,12 @@ TEST_F(DeviceTest, SyncCopyH2DSliceToPointer) { TEST_F(DeviceTest, SyncCopyD2DByCount) { EXPECT_NO_ERROR(Device.synchronousCopyD2D(DeviceA5, DeviceB5, 5)); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I)); - } EXPECT_NO_ERROR(Device.synchronousCopyD2D(DeviceA7, DeviceB7, 2)); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I)); - } EXPECT_ERROR(Device.synchronousCopyD2D(DeviceA5, DeviceB5, 7)); @@ -294,9 +276,8 @@ TEST_F(DeviceTest, SyncCopyD2DByCount) { TEST_F(DeviceTest, SyncCopyD2D) { EXPECT_NO_ERROR(Device.synchronousCopyD2D(DeviceA5, DeviceB5)); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I)); - } EXPECT_ERROR(Device.synchronousCopyD2D(DeviceA7, DeviceB5)); @@ -306,15 +287,13 @@ TEST_F(DeviceTest, SyncCopyD2D) { TEST_F(DeviceTest, SyncCopySliceD2DByCount) { EXPECT_NO_ERROR( Device.synchronousCopyD2D(DeviceA5.asSlice().slice(1), DeviceB5, 4)); - for (int I = 0; I < 4; ++I) { + for (int I = 0; I < 4; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I + 1), getDeviceValue(DeviceB5, I)); - } EXPECT_NO_ERROR( Device.synchronousCopyD2D(DeviceA7.asSlice().drop_back(1), DeviceB7, 2)); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I)); - } EXPECT_ERROR(Device.synchronousCopyD2D(DeviceA5.asSlice(), DeviceB5, 7)); @@ -326,9 +305,8 @@ TEST_F(DeviceTest, SyncCopySliceD2DByCount) { TEST_F(DeviceTest, SyncCopySliceD2D) { EXPECT_NO_ERROR( Device.synchronousCopyD2D(DeviceA7.asSlice().drop_back(2), DeviceB5)); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB5, I)); - } EXPECT_ERROR( Device.synchronousCopyD2D(DeviceA7.asSlice().slice(1), DeviceB5)); @@ -340,15 +318,13 @@ TEST_F(DeviceTest, SyncCopySliceD2D) { TEST_F(DeviceTest, SyncCopyD2DSliceByCount) { EXPECT_NO_ERROR( Device.synchronousCopyD2D(DeviceA5, DeviceB7.asSlice().slice(2), 5)); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB7, I + 2)); - } EXPECT_NO_ERROR( Device.synchronousCopyD2D(DeviceA7, DeviceB7.asSlice().drop_back(3), 2)); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I)); - } EXPECT_ERROR(Device.synchronousCopyD2D(DeviceA5, DeviceB5.asSlice(), 7)); @@ -360,9 +336,8 @@ TEST_F(DeviceTest, SyncCopyD2DSliceByCount) { TEST_F(DeviceTest, SyncCopyD2DSlice) { EXPECT_NO_ERROR( Device.synchronousCopyD2D(DeviceA5, DeviceB7.asSlice().drop_back(2))); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB7, I)); - } EXPECT_ERROR(Device.synchronousCopyD2D(DeviceA7, DeviceB5.asSlice())); @@ -372,15 +347,13 @@ TEST_F(DeviceTest, SyncCopyD2DSlice) { TEST_F(DeviceTest, SyncCopySliceD2DSliceByCount) { EXPECT_NO_ERROR( Device.synchronousCopyD2D(DeviceA5.asSlice(), DeviceB5.asSlice(), 5)); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I)); - } EXPECT_NO_ERROR( Device.synchronousCopyD2D(DeviceA7.asSlice(), DeviceB7.asSlice(), 2)); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I)); - } EXPECT_ERROR( Device.synchronousCopyD2D(DeviceA5.asSlice(), DeviceB5.asSlice(), 7)); @@ -395,9 +368,8 @@ TEST_F(DeviceTest, SyncCopySliceD2DSliceByCount) { TEST_F(DeviceTest, SyncCopySliceD2DSlice) { EXPECT_NO_ERROR( Device.synchronousCopyD2D(DeviceA5.asSlice(), DeviceB5.asSlice())); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I)); - } EXPECT_ERROR( Device.synchronousCopyD2D(DeviceA7.asSlice(), DeviceB5.asSlice())); diff --git a/parallel-libs/streamexecutor/unittests/CoreTests/PackedKernelArgumentArrayTest.cpp b/parallel-libs/streamexecutor/unittests/CoreTests/PackedKernelArgumentArrayTest.cpp index dd6d0e1c655..dd8521668af 100644 --- a/parallel-libs/streamexecutor/unittests/CoreTests/PackedKernelArgumentArrayTest.cpp +++ b/parallel-libs/streamexecutor/unittests/CoreTests/PackedKernelArgumentArrayTest.cpp @@ -12,11 +12,11 @@ /// //===----------------------------------------------------------------------===// -#include "SimpleHostPlatformDevice.h" #include "streamexecutor/Device.h" #include "streamexecutor/DeviceMemory.h" #include "streamexecutor/PackedKernelArgumentArray.h" #include "streamexecutor/PlatformDevice.h" +#include "streamexecutor/unittests/CoreTests/SimpleHostPlatformDevice.h" #include "llvm/ADT/Twine.h" diff --git a/parallel-libs/streamexecutor/unittests/CoreTests/SimpleHostPlatformDevice.h b/parallel-libs/streamexecutor/unittests/CoreTests/SimpleHostPlatformDevice.h deleted file mode 100644 index 60064804fbe..00000000000 --- a/parallel-libs/streamexecutor/unittests/CoreTests/SimpleHostPlatformDevice.h +++ /dev/null @@ -1,138 +0,0 @@ -//===-- SimpleHostPlatformDevice.h - Host device for testing ----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -/// -/// \file -/// The SimpleHostPlatformDevice class is a streamexecutor::PlatformDevice that -/// is really just the host processor and memory. It is useful for testing -/// because no extra device platform is required. -/// -//===----------------------------------------------------------------------===// - -#ifndef STREAMEXECUTOR_LIB_UNITTESTS_SIMPLEHOSTPLATFORMDEVICE_H -#define STREAMEXECUTOR_LIB_UNITTESTS_SIMPLEHOSTPLATFORMDEVICE_H - -#include -#include - -#include "streamexecutor/PlatformDevice.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 createStream() override { - return nullptr; - } - - streamexecutor::Expected - allocateDeviceMemory(size_t ByteCount) override { - return std::malloc(ByteCount); - } - - streamexecutor::Error freeDeviceMemory(const void *Handle) override { - std::free(const_cast(Handle)); - return streamexecutor::Error::success(); - } - - streamexecutor::Error registerHostMemory(void *Memory, - size_t ByteCount) override { - return streamexecutor::Error::success(); - } - - streamexecutor::Error unregisterHostMemory(const void *Memory) override { - return streamexecutor::Error::success(); - } - - streamexecutor::Error copyD2H(const void *StreamHandle, - const void *DeviceHandleSrc, - size_t SrcByteOffset, void *HostDst, - size_t DstByteOffset, - size_t ByteCount) override { - std::memcpy(static_cast(HostDst) + DstByteOffset, - static_cast(DeviceHandleSrc) + SrcByteOffset, - ByteCount); - return streamexecutor::Error::success(); - } - - streamexecutor::Error copyH2D(const void *StreamHandle, const void *HostSrc, - size_t SrcByteOffset, - const void *DeviceHandleDst, - size_t DstByteOffset, - size_t ByteCount) override { - std::memcpy(static_cast(const_cast(DeviceHandleDst)) + - DstByteOffset, - static_cast(HostSrc) + SrcByteOffset, ByteCount); - return streamexecutor::Error::success(); - } - - streamexecutor::Error - copyD2D(const void *StreamHandle, const void *DeviceHandleSrc, - size_t SrcByteOffset, const void *DeviceHandleDst, - size_t DstByteOffset, size_t ByteCount) override { - std::memcpy(static_cast(const_cast(DeviceHandleDst)) + - DstByteOffset, - static_cast(DeviceHandleSrc) + SrcByteOffset, - ByteCount); - return streamexecutor::Error::success(); - } - - streamexecutor::Error synchronousCopyD2H(const void *DeviceHandleSrc, - size_t SrcByteOffset, void *HostDst, - size_t DstByteOffset, - size_t ByteCount) override { - std::memcpy(static_cast(HostDst) + DstByteOffset, - static_cast(DeviceHandleSrc) + SrcByteOffset, - ByteCount); - return streamexecutor::Error::success(); - } - - streamexecutor::Error synchronousCopyH2D(const void *HostSrc, - size_t SrcByteOffset, - const void *DeviceHandleDst, - size_t DstByteOffset, - size_t ByteCount) override { - std::memcpy(static_cast(const_cast(DeviceHandleDst)) + - DstByteOffset, - static_cast(HostSrc) + SrcByteOffset, ByteCount); - return streamexecutor::Error::success(); - } - - streamexecutor::Error synchronousCopyD2D(const void *DeviceHandleSrc, - size_t SrcByteOffset, - const void *DeviceHandleDst, - size_t DstByteOffset, - size_t ByteCount) override { - std::memcpy(static_cast(const_cast(DeviceHandleDst)) + - DstByteOffset, - static_cast(DeviceHandleSrc) + SrcByteOffset, - ByteCount); - return streamexecutor::Error::success(); - } - - /// Gets the value at the given index from a GlobalDeviceMemory instance - /// created by this class. - template - static T getDeviceValue(const streamexecutor::GlobalDeviceMemory &Memory, - size_t Index) { - return static_cast(Memory.getHandle())[Index]; - } -}; - -} // namespace test -} // namespace streamexecutor - -#endif // STREAMEXECUTOR_LIB_UNITTESTS_SIMPLEHOSTPLATFORMDEVICE_H diff --git a/parallel-libs/streamexecutor/unittests/CoreTests/StreamTest.cpp b/parallel-libs/streamexecutor/unittests/CoreTests/StreamTest.cpp index f353ec28c90..9d306053900 100644 --- a/parallel-libs/streamexecutor/unittests/CoreTests/StreamTest.cpp +++ b/parallel-libs/streamexecutor/unittests/CoreTests/StreamTest.cpp @@ -14,12 +14,12 @@ #include -#include "SimpleHostPlatformDevice.h" #include "streamexecutor/Device.h" #include "streamexecutor/Kernel.h" #include "streamexecutor/KernelSpec.h" #include "streamexecutor/PlatformDevice.h" #include "streamexecutor/Stream.h" +#include "streamexecutor/unittests/CoreTests/SimpleHostPlatformDevice.h" #include "gtest/gtest.h" @@ -80,23 +80,18 @@ protected: se::GlobalDeviceMemory DeviceB7; }; -using llvm::ArrayRef; -using llvm::MutableArrayRef; - // D2H tests TEST_F(StreamTest, CopyD2HToRegisteredRefByCount) { Stream.thenCopyD2H(DeviceA5, RegisteredHost5, 5); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(HostA5[I], Host5[I]); - } Stream.thenCopyD2H(DeviceB5, RegisteredHost5, 2); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(HostB5[I], Host5[I]); - } Stream.thenCopyD2H(DeviceA7, RegisteredHost5, 7); EXPECT_FALSE(Stream.isOK()); @@ -105,9 +100,8 @@ TEST_F(StreamTest, CopyD2HToRegisteredRefByCount) { TEST_F(StreamTest, CopyD2HToRegistered) { Stream.thenCopyD2H(DeviceA5, RegisteredHost5); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(HostA5[I], Host5[I]); - } Stream.thenCopyD2H(DeviceA5, RegisteredHost7); EXPECT_FALSE(Stream.isOK()); @@ -117,15 +111,13 @@ TEST_F(StreamTest, CopyD2HSliceToRegiseredSliceByCount) { Stream.thenCopyD2H(DeviceA5.asSlice().slice(1), RegisteredHost5.asSlice().slice(1, 4), 4); EXPECT_TRUE(Stream.isOK()); - for (int I = 1; I < 5; ++I) { + for (int I = 1; I < 5; ++I) EXPECT_EQ(HostA5[I], Host5[I]); - } Stream.thenCopyD2H(DeviceB5.asSlice().drop_back(1), RegisteredHost5, 2); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(HostB5[I], Host5[I]); - } Stream.thenCopyD2H(DeviceA5.asSlice(), RegisteredHost7, 7); EXPECT_FALSE(Stream.isOK()); @@ -134,9 +126,8 @@ TEST_F(StreamTest, CopyD2HSliceToRegiseredSliceByCount) { TEST_F(StreamTest, CopyD2HSliceToRegistered) { Stream.thenCopyD2H(DeviceA7.asSlice().slice(1, 5), RegisteredHost5); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(HostA7[I + 1], Host5[I]); - } Stream.thenCopyD2H(DeviceA5.asSlice(), RegisteredHost7); EXPECT_FALSE(Stream.isOK()); @@ -147,15 +138,13 @@ TEST_F(StreamTest, CopyD2HSliceToRegistered) { TEST_F(StreamTest, CopyH2DFromRegisterdByCount) { Stream.thenCopyH2D(RegisteredHost5, DeviceA5, 5); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]); - } Stream.thenCopyH2D(RegisteredHost5, DeviceB5, 2); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(getDeviceValue(DeviceB5, I), Host5[I]); - } Stream.thenCopyH2D(RegisteredHost7, DeviceA5, 7); EXPECT_FALSE(Stream.isOK()); @@ -164,9 +153,8 @@ TEST_F(StreamTest, CopyH2DFromRegisterdByCount) { TEST_F(StreamTest, CopyH2DFromRegistered) { Stream.thenCopyH2D(RegisteredHost5, DeviceA5); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]); - } Stream.thenCopyH2D(RegisteredHost7, DeviceA5); EXPECT_FALSE(Stream.isOK()); @@ -176,15 +164,13 @@ TEST_F(StreamTest, CopyH2DFromRegisteredSliceToSlice) { Stream.thenCopyH2D(RegisteredHost5.asSlice().slice(1, 4), DeviceA5.asSlice().slice(1), 4); EXPECT_TRUE(Stream.isOK()); - for (int I = 1; I < 5; ++I) { + for (int I = 1; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]); - } Stream.thenCopyH2D(RegisteredHost5, DeviceB5.asSlice().drop_back(1), 2); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(getDeviceValue(DeviceB5, I), Host5[I]); - } Stream.thenCopyH2D(RegisteredHost5, DeviceA5.asSlice(), 7); EXPECT_FALSE(Stream.isOK()); @@ -193,9 +179,8 @@ TEST_F(StreamTest, CopyH2DFromRegisteredSliceToSlice) { TEST_F(StreamTest, CopyH2DRegisteredToSlice) { Stream.thenCopyH2D(RegisteredHost5, DeviceA5.asSlice()); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]); - } Stream.thenCopyH2D(RegisteredHost7, DeviceA5.asSlice()); EXPECT_FALSE(Stream.isOK()); @@ -206,15 +191,13 @@ TEST_F(StreamTest, CopyH2DRegisteredToSlice) { TEST_F(StreamTest, CopyD2DByCount) { Stream.thenCopyD2D(DeviceA5, DeviceB5, 5); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I)); - } Stream.thenCopyD2D(DeviceA7, DeviceB7, 2); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I)); - } Stream.thenCopyD2D(DeviceA7, DeviceB5, 7); EXPECT_FALSE(Stream.isOK()); @@ -223,9 +206,8 @@ TEST_F(StreamTest, CopyD2DByCount) { TEST_F(StreamTest, CopyD2D) { Stream.thenCopyD2D(DeviceA5, DeviceB5); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I)); - } Stream.thenCopyD2D(DeviceA7, DeviceB5); EXPECT_FALSE(Stream.isOK()); @@ -234,15 +216,13 @@ TEST_F(StreamTest, CopyD2D) { TEST_F(StreamTest, CopySliceD2DByCount) { Stream.thenCopyD2D(DeviceA5.asSlice().slice(1), DeviceB5, 4); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 4; ++I) { + for (int I = 0; I < 4; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I + 1), getDeviceValue(DeviceB5, I)); - } Stream.thenCopyD2D(DeviceA7.asSlice().drop_back(1), DeviceB7, 2); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I)); - } Stream.thenCopyD2D(DeviceA5.asSlice(), DeviceB5, 7); EXPECT_FALSE(Stream.isOK()); @@ -251,9 +231,8 @@ TEST_F(StreamTest, CopySliceD2DByCount) { TEST_F(StreamTest, CopySliceD2D) { Stream.thenCopyD2D(DeviceA7.asSlice().drop_back(2), DeviceB5); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB5, I)); - } Stream.thenCopyD2D(DeviceA5.asSlice().drop_back(1), DeviceB7); EXPECT_FALSE(Stream.isOK()); @@ -262,15 +241,13 @@ TEST_F(StreamTest, CopySliceD2D) { TEST_F(StreamTest, CopyD2DSliceByCount) { Stream.thenCopyD2D(DeviceA5, DeviceB7.asSlice().slice(2), 5); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB7, I + 2)); - } Stream.thenCopyD2D(DeviceA7, DeviceB7.asSlice().drop_back(3), 2); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I)); - } Stream.thenCopyD2D(DeviceA5, DeviceB7.asSlice(), 7); EXPECT_FALSE(Stream.isOK()); @@ -279,9 +256,8 @@ TEST_F(StreamTest, CopyD2DSliceByCount) { TEST_F(StreamTest, CopyD2DSlice) { Stream.thenCopyD2D(DeviceA5, DeviceB7.asSlice().drop_back(2)); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB7, I)); - } Stream.thenCopyD2D(DeviceA5, DeviceB7.asSlice()); EXPECT_FALSE(Stream.isOK()); @@ -290,15 +266,13 @@ TEST_F(StreamTest, CopyD2DSlice) { TEST_F(StreamTest, CopySliceD2DSliceByCount) { Stream.thenCopyD2D(DeviceA5.asSlice(), DeviceB5.asSlice(), 5); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I)); - } Stream.thenCopyD2D(DeviceA7.asSlice(), DeviceB7.asSlice(), 2); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 2; ++I) { + for (int I = 0; I < 2; ++I) EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I)); - } Stream.thenCopyD2D(DeviceA7.asSlice(), DeviceB5.asSlice(), 7); EXPECT_FALSE(Stream.isOK()); @@ -307,9 +281,8 @@ TEST_F(StreamTest, CopySliceD2DSliceByCount) { TEST_F(StreamTest, CopySliceD2DSlice) { Stream.thenCopyD2D(DeviceA5.asSlice(), DeviceB5.asSlice()); EXPECT_TRUE(Stream.isOK()); - for (int I = 0; I < 5; ++I) { + for (int I = 0; I < 5; ++I) EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I)); - } Stream.thenCopyD2D(DeviceA5.asSlice(), DeviceB7.asSlice()); EXPECT_FALSE(Stream.isOK()); -- cgit v1.2.3