Skip to content

Commit

Permalink
Skip USM alignment tests over 64K on Windows
Browse files Browse the repository at this point in the history
Related-To: NEO-8431

Signed-off-by: Wenbin Lu <[email protected]>
  • Loading branch information
lyu committed Jun 28, 2024
1 parent 6fe343d commit b582f33
Showing 1 changed file with 62 additions and 37 deletions.
99 changes: 62 additions & 37 deletions conformance_tests/core/test_memory/src/test_memory.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
/*
*
* Copyright (C) 2019-2023 Intel Corporation
* Copyright (C) 2019-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/

#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <chrono>
#include <thread>

#include "gtest/gtest.h"

Expand Down Expand Up @@ -61,6 +59,11 @@ class zeDriverAllocDeviceMemAlignmentTests
TEST_P(zeDriverAllocDeviceMemAlignmentTests,
GivenSizeAndAlignmentWhenAllocatingDeviceMemoryThenPointerIsAligned) {
EXPECT_NE(nullptr, memory_);
#if defined(_WIN32)
if (alignment_ > (1ul << 16)) {
GTEST_SKIP() << "Alignment > 64KB is not supported on Windows yet";
}
#endif
if (alignment_ != 0) {
EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(memory_) % alignment_);
}
Expand Down Expand Up @@ -266,29 +269,43 @@ class zeDriverAllocSharedMemAlignmentTests
: public ::testing::Test,
public ::testing::WithParamInterface<
std::tuple<ze_device_mem_alloc_flag_t, ze_host_mem_alloc_flag_t,
size_t, size_t>> {};
size_t, size_t>> {
protected:
void SetUp() override {
const ze_device_mem_alloc_flag_t dev_flags = std::get<0>(GetParam());
const ze_host_mem_alloc_flag_t host_flags = std::get<1>(GetParam());
size_ = std::get<2>(GetParam());
alignment_ = std::get<3>(GetParam());

TEST_P(zeDriverAllocSharedMemAlignmentTests,
GivenSizeAndAlignmentWhenAllocatingSharedMemoryThenPointerIsAligned) {
auto driver = lzt::get_default_driver();
auto device = lzt::get_default_device(driver);
context_ = lzt::create_context();
memory_ = lzt::allocate_shared_memory(size_, alignment_, dev_flags,
host_flags, device, context_);
}

const ze_device_mem_alloc_flag_t dev_flags = std::get<0>(GetParam());
const ze_host_mem_alloc_flag_t host_flags = std::get<1>(GetParam());
const size_t size = std::get<2>(GetParam());
const size_t alignment = std::get<3>(GetParam());
void TearDown() override {
lzt::free_memory(context_, memory_);
lzt::destroy_context(context_);
}

void *memory = nullptr;
auto driver = lzt::get_default_driver();
auto device = lzt::get_default_device(driver);
auto context = lzt::create_context();
size_t size_;
size_t alignment_;
void *memory_ = nullptr;
ze_context_handle_t context_;
};

memory = lzt::allocate_shared_memory(size, alignment, dev_flags, host_flags,
device, context);
EXPECT_NE(nullptr, memory);
if (alignment != 0) {
EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(memory) % alignment);
TEST_P(zeDriverAllocSharedMemAlignmentTests,
GivenSizeAndAlignmentWhenAllocatingSharedMemoryThenPointerIsAligned) {
EXPECT_NE(nullptr, memory_);
#if defined(_WIN32)
if (alignment_ > (1ul << 16)) {
GTEST_SKIP() << "Alignment > 64KB is not supported on Windows yet";
}
#endif
if (alignment_ != 0) {
EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(memory_) % alignment_);
}
lzt::free_memory(context, memory);
lzt::destroy_context(context);
}

INSTANTIATE_TEST_SUITE_P(zeDriverAllocSharedMemTestVarySizeAndAlignment,
Expand Down Expand Up @@ -433,26 +450,34 @@ INSTANTIATE_TEST_SUITE_P(
ZE_HOST_MEM_ALLOC_FLAG_BIAS_WRITE_COMBINED),
lzt::memory_allocation_sizes, lzt::memory_allocation_alignments));

class zeDriverAllocHostMemAlignmentTests : public zeDriverAllocHostMemTests {};

TEST_P(zeDriverAllocHostMemAlignmentTests,
GivenSizeAndAlignmentWhenAllocatingHostMemoryThenPointerIsAligned) {

const ze_host_mem_alloc_flag_t flags = std::get<0>(GetParam());
class zeDriverAllocHostMemAlignmentTests : public zeDriverAllocHostMemTests {
protected:
void SetUp() override {
const ze_host_mem_alloc_flag_t flags = std::get<0>(GetParam());
size_ = std::get<1>(GetParam());
alignment_ = std::get<2>(GetParam());
memory_ = lzt::allocate_host_memory(size_, alignment_, flags, nullptr,
lzt::get_default_context());
}

const size_t size = std::get<1>(GetParam());
const size_t alignment = std::get<2>(GetParam());
void TearDown() override { lzt::free_memory(memory_); }

void *memory = nullptr;
memory = lzt::allocate_host_memory(size, alignment, flags, nullptr,
lzt::get_default_context());
size_t size_;
size_t alignment_;
void *memory_ = nullptr;
};

EXPECT_NE(nullptr, memory);
if (alignment != 0) {
EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(memory) % alignment);
TEST_P(zeDriverAllocHostMemAlignmentTests,
GivenSizeAndAlignmentWhenAllocatingHostMemoryThenPointerIsAligned) {
EXPECT_NE(nullptr, memory_);
#if defined(_WIN32)
if (alignment_ > (1ul << 16)) {
GTEST_SKIP() << "Alignment > 64KB is not supported on Windows yet";
}
#endif
if (alignment_ != 0) {
EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(memory_) % alignment_);
}

lzt::free_memory(memory);
}

INSTANTIATE_TEST_SUITE_P(zeDriverAllocHostMemTestVarySizeAndAlignment,
Expand Down

0 comments on commit b582f33

Please sign in to comment.