-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Daniel Chabrowski [email protected] Related-To: NEO-6591
- Loading branch information
1 parent
3e8a668
commit 10e7b9d
Showing
6 changed files
with
167 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
opencl/test/unit_test/os_interface/linux/device_command_stream_fixture_context.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2022 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
*/ | ||
|
||
#include "opencl/test/unit_test/os_interface/linux/device_command_stream_fixture_context.h" | ||
|
||
#include "third_party/uapi/prelim/drm/i915_drm.h" | ||
|
||
int DrmMockCustomPrelimContext::ioctlExtra(unsigned long request, void *arg) { | ||
switch (request) { | ||
case PRELIM_DRM_IOCTL_I915_GEM_CREATE_EXT: { | ||
auto createExtParams = reinterpret_cast<prelim_drm_i915_gem_create_ext *>(arg); | ||
createExtSize = createExtParams->size; | ||
createExtHandle = createExtParams->handle; | ||
createExtExtensions = createExtParams->extensions; | ||
} break; | ||
case PRELIM_DRM_IOCTL_I915_GEM_VM_BIND: { | ||
} break; | ||
case PRELIM_DRM_IOCTL_I915_GEM_VM_UNBIND: { | ||
} break; | ||
case PRELIM_DRM_IOCTL_I915_GEM_WAIT_USER_FENCE: { | ||
const auto wait = reinterpret_cast<prelim_drm_i915_gem_wait_user_fence *>(arg); | ||
receivedGemWaitUserFence = WaitUserFence{ | ||
wait->extensions, | ||
wait->addr, | ||
wait->ctx_id, | ||
wait->op, | ||
wait->flags, | ||
wait->value, | ||
wait->mask, | ||
wait->timeout, | ||
}; | ||
gemWaitUserFenceCalled++; | ||
} break; | ||
default: { | ||
std::cout << std::hex << DRM_IOCTL_I915_GEM_WAIT << std::endl; | ||
std::cout << "unexpected IOCTL: " << std::hex << request << std::endl; | ||
UNRECOVERABLE_IF(true); | ||
} break; | ||
} | ||
return 0; | ||
} | ||
|
||
void DrmMockCustomPrelimContext::execBufferExtensions(void *arg) { | ||
const auto execbuf = reinterpret_cast<drm_i915_gem_execbuffer2 *>(arg); | ||
if ((execbuf->flags | I915_EXEC_USE_EXTENSIONS) && | ||
(execbuf->cliprects_ptr != 0)) { | ||
i915_user_extension *base = reinterpret_cast<i915_user_extension *>(execbuf->cliprects_ptr); | ||
if (base->name == PRELIM_DRM_I915_GEM_EXECBUFFER_EXT_USER_FENCE) { | ||
prelim_drm_i915_gem_execbuffer_ext_user_fence *userFenceExt = | ||
reinterpret_cast<prelim_drm_i915_gem_execbuffer_ext_user_fence *>(execbuf->cliprects_ptr); | ||
this->completionAddress = userFenceExt->addr; | ||
this->completionValue = userFenceExt->value; | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
opencl/test/unit_test/os_interface/linux/device_command_stream_fixture_context.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (C) 2022 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "shared/test/common/libult/linux/drm_mock_prelim_context.h" | ||
|
||
struct DrmMockCustomPrelimContext { | ||
//PRELIM_DRM_IOCTL_I915_GEM_CREATE_EXT | ||
uint64_t createExtSize = 0; | ||
uint32_t createExtHandle = 0; | ||
uint64_t createExtExtensions = 0; | ||
|
||
//PRELIM_DRM_IOCTL_I915_GEM_WAIT_USER_FENCE | ||
WaitUserFence receivedGemWaitUserFence{}; | ||
uint32_t gemWaitUserFenceCalled = 0; | ||
|
||
//PRELIM_DRM_I915_GEM_EXECBUFFER_EXT_USER_FENCE | ||
uint64_t completionAddress = 0; | ||
uint64_t completionValue = 0; | ||
|
||
int ioctlExtra(unsigned long request, void *arg); | ||
void execBufferExtensions(void *arg); | ||
}; |
37 changes: 37 additions & 0 deletions
37
opencl/test/unit_test/os_interface/linux/device_command_stream_fixture_prelim.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) 2022 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h" | ||
|
||
#include "opencl/test/unit_test/os_interface/linux/device_command_stream_fixture_context.h" | ||
|
||
class DrmMockCustomPrelim : public DrmMockCustom { | ||
public: | ||
using Drm::cacheInfo; | ||
using Drm::ioctlHelper; | ||
using Drm::memoryInfo; | ||
|
||
DrmMockCustomPrelim(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMockCustom(rootDeviceEnvironment) { | ||
setupIoctlHelper(IGFX_UNKNOWN); | ||
} | ||
|
||
void getPrelimVersion(std::string &prelimVersion) override { | ||
prelimVersion = "2.0"; | ||
} | ||
|
||
int ioctlExtra(unsigned long request, void *arg) override { | ||
return context.ioctlExtra(request, arg); | ||
} | ||
|
||
void execBufferExtensions(void *arg) override { | ||
return context.execBufferExtensions(arg); | ||
} | ||
|
||
DrmMockCustomPrelimContext context{}; | ||
}; |
33 changes: 33 additions & 0 deletions
33
opencl/test/unit_test/os_interface/linux/drm_buffer_object_tests_prelim.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (C) 2022 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
*/ | ||
|
||
#include "shared/source/os_interface/os_interface.h" | ||
#include "shared/test/common/libult/linux/drm_mock.h" | ||
#include "shared/test/common/os_interface/linux/drm_buffer_object_fixture.h" | ||
#include "shared/test/common/test_macros/test.h" | ||
|
||
#include "opencl/test/unit_test/os_interface/linux/device_command_stream_fixture_prelim.h" | ||
|
||
using namespace NEO; | ||
|
||
using DrmBufferObjectPrelimFixture = DrmBufferObjectFixture<DrmMockCustomPrelim>; | ||
using DrmBufferObjectPrelimTest = Test<DrmBufferObjectPrelimFixture>; | ||
|
||
TEST_F(DrmBufferObjectPrelimTest, GivenCompletionAddressWhenCallingExecThenReturnIsCorrect) { | ||
mock->ioctl_expected.total = 1; | ||
mock->ioctl_res = 0; | ||
|
||
constexpr uint64_t completionAddress = 0x1230; | ||
constexpr uint32_t completionValue = 33; | ||
constexpr uint64_t expectedCompletionValue = completionValue; | ||
|
||
drm_i915_gem_exec_object2 execObjectsStorage = {}; | ||
auto ret = bo->exec(0, 0, 0, false, osContext.get(), 0, 1, nullptr, 0u, &execObjectsStorage, completionAddress, completionValue); | ||
EXPECT_EQ(0, ret); | ||
EXPECT_EQ(completionAddress, mock->context.completionAddress); | ||
EXPECT_EQ(expectedCompletionValue, mock->context.completionValue); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters