1 /*
2 * Copyright (C) 2019-2021 Intel Corporation
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8 #include "shared/test/common/test_macros/test.h"
9
10 #include "opencl/test/unit_test/aub_tests/fixtures/unified_memory_fixture.h"
11
12 namespace NEO {
13 class UnifiedMemoryCopyAubTest : public UnifiedMemoryAubFixture,
14 public ::testing::TestWithParam<std::tuple<InternalMemoryType, InternalMemoryType>> {
15 public:
16 void *srcPtr, *dstPtr;
17 InternalMemoryType srcMemoryType, dstMemoryType;
18 std::vector<char> srcValues, dstValues;
19
SetUp()20 void SetUp() override {
21 UnifiedMemoryAubFixture::SetUp();
22
23 srcMemoryType = std::get<0>(GetParam());
24 dstMemoryType = std::get<1>(GetParam());
25
26 srcPtr = this->allocateUSM(srcMemoryType);
27 dstPtr = this->allocateUSM(dstMemoryType);
28
29 srcValues = std::vector<char>(dataSize, 11);
30 dstValues = std::vector<char>(dataSize, 22);
31
32 this->writeToUsmMemory(srcValues, srcPtr, srcMemoryType);
33 this->writeToUsmMemory(dstValues, dstPtr, dstMemoryType);
34 }
35
TearDown()36 void TearDown() override {
37 this->freeUSM(srcPtr, srcMemoryType);
38 this->freeUSM(dstPtr, dstMemoryType);
39 UnifiedMemoryAubFixture::TearDown();
40 }
41 };
42
HWTEST_P(UnifiedMemoryCopyAubTest,givenTwoUnifiedMemoryAllocsWhenCopyingOneToAnotherThenValuesMatch)43 HWTEST_P(UnifiedMemoryCopyAubTest, givenTwoUnifiedMemoryAllocsWhenCopyingOneToAnotherThenValuesMatch) {
44 clEnqueueMemcpyINTEL(this->pCmdQ, true, dstPtr, srcPtr, dataSize, 0, nullptr, nullptr);
45 expectMemory<FamilyType>(dstPtr, srcValues.data(), dataSize);
46 }
47
48 InternalMemoryType memoryTypes[] = {InternalMemoryType::HOST_UNIFIED_MEMORY,
49 InternalMemoryType::DEVICE_UNIFIED_MEMORY,
50 InternalMemoryType::SHARED_UNIFIED_MEMORY,
51 InternalMemoryType::NOT_SPECIFIED};
52
53 INSTANTIATE_TEST_CASE_P(UnifiedMemoryCopyAubTest,
54 UnifiedMemoryCopyAubTest,
55 ::testing::Combine(::testing::ValuesIn(memoryTypes),
56 ::testing::ValuesIn(memoryTypes)));
57 } // namespace NEO
58