mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
feature: zexDeviceGetAggregatedCopyOffloadIncrementValue implementation
Related-To: NEO-14557 Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
cfb3dade30
commit
3717187cbc
@@ -12,12 +12,15 @@
|
||||
#include "shared/source/memory_manager/unified_memory_manager.h"
|
||||
|
||||
#include "level_zero/core/source/context/context_imp.h"
|
||||
#include "level_zero/core/source/device/device.h"
|
||||
#include "level_zero/core/source/device/bcs_split.h"
|
||||
#include "level_zero/core/source/device/device_imp.h"
|
||||
#include "level_zero/core/source/driver/driver_handle.h"
|
||||
#include "level_zero/core/source/event/event.h"
|
||||
#include "level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper.h"
|
||||
#include "level_zero/core/source/helpers/default_descriptors.h"
|
||||
|
||||
#include <numeric>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
ze_result_t ZE_APICALL
|
||||
@@ -184,7 +187,38 @@ ze_result_t ZE_APICALL zexCounterBasedEventCloseIpcHandle(ze_event_handle_t hEve
|
||||
}
|
||||
|
||||
ze_result_t ZE_APICALL zexDeviceGetAggregatedCopyOffloadIncrementValue(ze_device_handle_t hDevice, uint32_t *incrementValue) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
auto device = static_cast<DeviceImp *>(Device::fromHandle(hDevice));
|
||||
if (!device || !incrementValue) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (device->getAggregatedCopyOffloadIncrementValue() == 0) {
|
||||
uint32_t numTiles = std::max(device->getNEODevice()->getNumSubDevices(), 1u);
|
||||
auto bcsSplit = device->bcsSplit.get();
|
||||
uint32_t bcsSplitEngines = 1;
|
||||
uint64_t lcmResult = 1;
|
||||
|
||||
if (device->getNEODevice()->isBcsSplitSupported()) {
|
||||
if (bcsSplit->cmdLists.empty()) {
|
||||
auto csr = device->getNEODevice()->tryGetRegularEngineGroup(NEO::EngineGroupType::copy)->engines[0].commandStreamReceiver;
|
||||
UNRECOVERABLE_IF(!csr);
|
||||
bcsSplit->setupDevice(csr, false);
|
||||
UNRECOVERABLE_IF(bcsSplit->cmdLists.empty());
|
||||
}
|
||||
bcsSplitEngines = static_cast<uint32_t>(bcsSplit->cmdLists.size());
|
||||
}
|
||||
|
||||
for (uint32_t i = 2; i <= bcsSplitEngines; i++) {
|
||||
lcmResult = std::lcm(lcmResult, i);
|
||||
}
|
||||
|
||||
UNRECOVERABLE_IF(lcmResult * numTiles > std::numeric_limits<uint32_t>::max());
|
||||
|
||||
device->setAggregatedCopyOffloadIncrementValue(static_cast<uint32_t>(lcmResult * numTiles));
|
||||
}
|
||||
|
||||
*incrementValue = device->getAggregatedCopyOffloadIncrementValue();
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -162,6 +162,8 @@ struct Device : _ze_device_handle_t {
|
||||
uint32_t getIdentifier() const { return identifier; }
|
||||
ze_result_t getPriorityLevels(int32_t *lowestPriority,
|
||||
int32_t *highestPriority);
|
||||
uint32_t getAggregatedCopyOffloadIncrementValue() const { return aggregatedCopyIncValue; }
|
||||
void setAggregatedCopyOffloadIncrementValue(uint32_t val) { aggregatedCopyIncValue = val; }
|
||||
|
||||
protected:
|
||||
NEO::Device *neoDevice = nullptr;
|
||||
@@ -173,6 +175,7 @@ struct Device : _ze_device_handle_t {
|
||||
std::mutex inOrderAllocatorMutex;
|
||||
std::mutex syncDispatchTokenMutex;
|
||||
std::atomic<uint32_t> syncDispatchQueueIdAllocator = 0;
|
||||
uint32_t aggregatedCopyIncValue = 0;
|
||||
uint32_t identifier = 0;
|
||||
int32_t queuePriorityHigh = 0;
|
||||
int32_t queuePriorityLow = 1;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h"
|
||||
#include "level_zero/core/test/unit_tests/sources/helper/ze_object_utils.h"
|
||||
#include "level_zero/driver_experimental/zex_event.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
@@ -1015,6 +1016,38 @@ HWTEST2_F(AggregatedBcsSplitTests, givenLimitedEnginesCountWhenCreatingBcsSplitT
|
||||
bcsSplit.releaseResources();
|
||||
}
|
||||
|
||||
HWTEST2_F(AggregatedBcsSplitTests, givenUninitializedBcsSplitCallingZexDeviceGetAggregatedCopyOffloadIncrementValueThenInitialize, IsAtLeastXeHpcCore) {
|
||||
uint32_t incValue = 0;
|
||||
bcsSplit->releaseResources();
|
||||
EXPECT_TRUE(bcsSplit->cmdLists.empty());
|
||||
|
||||
EXPECT_EQ(0u, device->getAggregatedCopyOffloadIncrementValue());
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zexDeviceGetAggregatedCopyOffloadIncrementValue(device->toHandle(), &incValue));
|
||||
EXPECT_FALSE(bcsSplit->cmdLists.empty());
|
||||
|
||||
EXPECT_NE(0u, incValue);
|
||||
EXPECT_EQ(device->getAggregatedCopyOffloadIncrementValue(), incValue);
|
||||
|
||||
for (uint32_t i = 1; i <= bcsSplit->cmdLists.size(); i++) {
|
||||
EXPECT_TRUE(incValue % i == 0);
|
||||
}
|
||||
|
||||
auto cachedIncValue = incValue;
|
||||
incValue = 0;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zexDeviceGetAggregatedCopyOffloadIncrementValue(device->toHandle(), &incValue));
|
||||
EXPECT_EQ(cachedIncValue, incValue);
|
||||
EXPECT_EQ(cachedIncValue, device->getAggregatedCopyOffloadIncrementValue());
|
||||
}
|
||||
|
||||
HWTEST2_F(AggregatedBcsSplitTests, givenBcsSplitDisabledWhenCallingZexDeviceGetAggregatedCopyOffloadIncrementValueThenRetrunOne, IsAtLeastXeHpcCore) {
|
||||
uint32_t incValue = 0;
|
||||
|
||||
debugManager.flags.SplitBcsCopy.set(0);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zexDeviceGetAggregatedCopyOffloadIncrementValue(device->toHandle(), &incValue));
|
||||
EXPECT_EQ(incValue, 1u); // single tile
|
||||
}
|
||||
|
||||
HWTEST2_F(AggregatedBcsSplitTests, givenCopyOffloadEnabledWhenCreatingCmdListThenEnableBcsSplit, IsAtLeastXeHpcCore) {
|
||||
debugManager.flags.ForceCopyOperationOffloadForComputeCmdList.set(1);
|
||||
|
||||
@@ -1455,5 +1488,28 @@ HWTEST2_F(MultiTileAggregatedBcsSplitTests, givenIncorrectNumberOfTilesWhenCreat
|
||||
EXPECT_EQ(0u, bcsSplit->cmdLists.size());
|
||||
}
|
||||
|
||||
HWTEST2_F(MultiTileAggregatedBcsSplitTests, givenMultiTileDeviceWhenCallingZexDeviceGetAggregatedCopyOffloadIncrementValueThenReturnCorrectValue, IsAtLeastXeHpcCore) {
|
||||
uint32_t incValue = 0;
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zexDeviceGetAggregatedCopyOffloadIncrementValue(device->toHandle(), &incValue));
|
||||
|
||||
EXPECT_NE(0u, incValue);
|
||||
|
||||
EXPECT_TRUE(incValue % expectedTileCount == 0);
|
||||
|
||||
for (uint32_t i = 1; i <= bcsSplit->cmdLists.size(); i++) {
|
||||
EXPECT_TRUE(incValue % i == 0);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(MultiTileAggregatedBcsSplitTests, givenBcsSplitDisabledWhenCallingZexDeviceGetAggregatedCopyOffloadIncrementValueThenReturnTileCount, IsAtLeastXeHpcCore) {
|
||||
uint32_t incValue = 0;
|
||||
|
||||
debugManager.flags.SplitBcsCopy.set(0);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zexDeviceGetAggregatedCopyOffloadIncrementValue(device->toHandle(), &incValue));
|
||||
EXPECT_EQ(incValue, expectedTileCount);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
@@ -6450,9 +6450,10 @@ HWTEST_F(InOrderCmdListTests, givenCounterBasedEventWhenAskingForEventAddressAnd
|
||||
EXPECT_EQ(deviceAlloc->getGpuAddress() + events[0]->inOrderAllocationOffset, address);
|
||||
}
|
||||
|
||||
HWTEST_F(InOrderCmdListTests, whenCallingZexDeviceGetAggregatedCopyOffloadIncrementValueThenReturnError) {
|
||||
HWTEST_F(InOrderCmdListTests, givenIncorrectArgumentswhenCallingZexDeviceGetAggregatedCopyOffloadIncrementValueThenReturnError) {
|
||||
uint32_t incValue = 0;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zexDeviceGetAggregatedCopyOffloadIncrementValue(device->toHandle(), &incValue));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zexDeviceGetAggregatedCopyOffloadIncrementValue(device->toHandle(), nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zexDeviceGetAggregatedCopyOffloadIncrementValue(nullptr, &incValue));
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, InOrderCmdListTests, wWhenUsingImmediateCmdListThenDontAddCmdsToPatch) {
|
||||
|
||||
Reference in New Issue
Block a user