mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Add method to get device bitfield from context
Related-To: NEO-4484 Change-Id: I5079c5bff48b552ed5326b2252bcd9401ea66c7d Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
@ -415,7 +415,16 @@ ClDevice *Context::getSubDeviceByIndex(uint32_t subDeviceIndex) const {
|
|||||||
return (foundDeviceIterator != devices.end() ? *foundDeviceIterator : nullptr);
|
return (foundDeviceIterator != devices.end() ? *foundDeviceIterator : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncEventsHandler &Context::getAsyncEventsHandler() {
|
AsyncEventsHandler &Context::getAsyncEventsHandler() const {
|
||||||
return *static_cast<ClExecutionEnvironment *>(devices[0]->getExecutionEnvironment())->getAsyncEventsHandler();
|
return *static_cast<ClExecutionEnvironment *>(devices[0]->getExecutionEnvironment())->getAsyncEventsHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeviceBitfield Context::getDeviceBitfieldForAllocation() const {
|
||||||
|
DeviceBitfield deviceBitfield{};
|
||||||
|
for (const auto &pDevice : devices) {
|
||||||
|
deviceBitfield |= pDevice->getDeviceBitfield();
|
||||||
|
}
|
||||||
|
|
||||||
|
return deviceBitfield;
|
||||||
|
}
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||||
|
#include "shared/source/helpers/common_types.h"
|
||||||
#include "shared/source/helpers/vec.h"
|
#include "shared/source/helpers/vec.h"
|
||||||
|
|
||||||
#include "opencl/source/cl_device/cl_device_vector.h"
|
#include "opencl/source/cl_device/cl_device_vector.h"
|
||||||
@ -14,8 +15,6 @@
|
|||||||
#include "opencl/source/context/driver_diagnostics.h"
|
#include "opencl/source/context/driver_diagnostics.h"
|
||||||
#include "opencl/source/helpers/base_object.h"
|
#include "opencl/source/helpers/base_object.h"
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
|
||||||
class AsyncEventsHandler;
|
class AsyncEventsHandler;
|
||||||
@ -144,7 +143,9 @@ class Context : public BaseObject<_cl_context> {
|
|||||||
bool isDeviceAssociated(const ClDevice &clDevice) const;
|
bool isDeviceAssociated(const ClDevice &clDevice) const;
|
||||||
ClDevice *getSubDeviceByIndex(uint32_t subDeviceIndex) const;
|
ClDevice *getSubDeviceByIndex(uint32_t subDeviceIndex) const;
|
||||||
|
|
||||||
AsyncEventsHandler &getAsyncEventsHandler();
|
AsyncEventsHandler &getAsyncEventsHandler() const;
|
||||||
|
|
||||||
|
DeviceBitfield getDeviceBitfieldForAllocation() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Context(void(CL_CALLBACK *pfnNotify)(const char *, const void *, size_t, void *) = nullptr,
|
Context(void(CL_CALLBACK *pfnNotify)(const char *, const void *, size_t, void *) = nullptr,
|
||||||
|
@ -225,7 +225,7 @@ Buffer *Buffer::create(Context *context,
|
|||||||
if (!memory) {
|
if (!memory) {
|
||||||
AllocationProperties allocProperties = MemoryPropertiesParserHelper::getAllocationProperties(rootDeviceIndex, memoryProperties,
|
AllocationProperties allocProperties = MemoryPropertiesParserHelper::getAllocationProperties(rootDeviceIndex, memoryProperties,
|
||||||
allocateMemory, size, allocationType, context->areMultiStorageAllocationsPreferred(),
|
allocateMemory, size, allocationType, context->areMultiStorageAllocationsPreferred(),
|
||||||
context->getDevice(0)->getHardwareInfo(), context->getDevice(0)->getDeviceBitfield());
|
context->getDevice(0)->getHardwareInfo(), context->getDeviceBitfieldForAllocation());
|
||||||
memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties, hostPtr);
|
memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties, hostPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ Buffer *Buffer::create(Context *context,
|
|||||||
AllocationProperties allocProperties = MemoryPropertiesParserHelper::getAllocationProperties(rootDeviceIndex, memoryProperties,
|
AllocationProperties allocProperties = MemoryPropertiesParserHelper::getAllocationProperties(rootDeviceIndex, memoryProperties,
|
||||||
true, // allocateMemory
|
true, // allocateMemory
|
||||||
size, allocationType, context->areMultiStorageAllocationsPreferred(),
|
size, allocationType, context->areMultiStorageAllocationsPreferred(),
|
||||||
context->getDevice(0)->getHardwareInfo(), context->getDevice(0)->getDeviceBitfield());
|
context->getDevice(0)->getHardwareInfo(), context->getDeviceBitfieldForAllocation());
|
||||||
memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties);
|
memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +293,7 @@ Buffer *Buffer::create(Context *context,
|
|||||||
false, // allocateMemory
|
false, // allocateMemory
|
||||||
size, GraphicsAllocation::AllocationType::MAP_ALLOCATION,
|
size, GraphicsAllocation::AllocationType::MAP_ALLOCATION,
|
||||||
false, // isMultiStorageAllocation
|
false, // isMultiStorageAllocation
|
||||||
context->getDevice(0)->getDeviceBitfield()};
|
context->getDeviceBitfieldForAllocation()};
|
||||||
properties.flags.flushL3RequiredForRead = properties.flags.flushL3RequiredForWrite = true;
|
properties.flags.flushL3RequiredForRead = properties.flags.flushL3RequiredForWrite = true;
|
||||||
mapAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, hostPtr);
|
mapAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, hostPtr);
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ Image *Image::create(Context *context,
|
|||||||
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(rootDeviceIndex, imgInfo,
|
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(rootDeviceIndex, imgInfo,
|
||||||
false, // allocateMemory
|
false, // allocateMemory
|
||||||
memoryProperties, context->getDevice(0)->getHardwareInfo(),
|
memoryProperties, context->getDevice(0)->getHardwareInfo(),
|
||||||
context->getDevice(0)->getDeviceBitfield());
|
context->getDeviceBitfieldForAllocation());
|
||||||
|
|
||||||
memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties, hostPtr);
|
memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties, hostPtr);
|
||||||
|
|
||||||
@ -289,7 +289,7 @@ Image *Image::create(Context *context,
|
|||||||
false, // allocateMemory
|
false, // allocateMemory
|
||||||
imgInfo.size, GraphicsAllocation::AllocationType::SHARED_CONTEXT_IMAGE,
|
imgInfo.size, GraphicsAllocation::AllocationType::SHARED_CONTEXT_IMAGE,
|
||||||
false, // isMultiStorageAllocation
|
false, // isMultiStorageAllocation
|
||||||
context->getDevice(0)->getDeviceBitfield()},
|
context->getDeviceBitfieldForAllocation()},
|
||||||
hostPtr);
|
hostPtr);
|
||||||
memory->setDefaultGmm(gmm);
|
memory->setDefaultGmm(gmm);
|
||||||
zeroCopy = true;
|
zeroCopy = true;
|
||||||
@ -299,7 +299,7 @@ Image *Image::create(Context *context,
|
|||||||
false, // allocateMemory
|
false, // allocateMemory
|
||||||
hostPtrMinSize, GraphicsAllocation::AllocationType::MAP_ALLOCATION,
|
hostPtrMinSize, GraphicsAllocation::AllocationType::MAP_ALLOCATION,
|
||||||
false, // isMultiStorageAllocation
|
false, // isMultiStorageAllocation
|
||||||
context->getDevice(0)->getDeviceBitfield()};
|
context->getDeviceBitfieldForAllocation()};
|
||||||
properties.flags.flushL3RequiredForRead = properties.flags.flushL3RequiredForWrite = true;
|
properties.flags.flushL3RequiredForRead = properties.flags.flushL3RequiredForWrite = true;
|
||||||
mapAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, hostPtr);
|
mapAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, hostPtr);
|
||||||
}
|
}
|
||||||
@ -307,7 +307,7 @@ Image *Image::create(Context *context,
|
|||||||
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(rootDeviceIndex, imgInfo,
|
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(rootDeviceIndex, imgInfo,
|
||||||
true, // allocateMemory
|
true, // allocateMemory
|
||||||
memoryProperties, context->getDevice(0)->getHardwareInfo(),
|
memoryProperties, context->getDevice(0)->getHardwareInfo(),
|
||||||
context->getDevice(0)->getDeviceBitfield());
|
context->getDeviceBitfieldForAllocation());
|
||||||
memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties);
|
memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties);
|
||||||
|
|
||||||
if (memory && MemoryPool::isSystemMemoryPool(memory->getMemoryPool())) {
|
if (memory && MemoryPool::isSystemMemoryPool(memory->getMemoryPool())) {
|
||||||
|
@ -340,7 +340,7 @@ void *MemObj::getBasePtrForMap(uint32_t rootDeviceIndex) {
|
|||||||
false, // allocateMemory
|
false, // allocateMemory
|
||||||
getSize(), GraphicsAllocation::AllocationType::MAP_ALLOCATION,
|
getSize(), GraphicsAllocation::AllocationType::MAP_ALLOCATION,
|
||||||
false, //isMultiStorageAllocation
|
false, //isMultiStorageAllocation
|
||||||
context->getDevice(0)->getDeviceBitfield()};
|
context->getDeviceBitfieldForAllocation()};
|
||||||
|
|
||||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, memory);
|
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, memory);
|
||||||
setMapAllocation(allocation);
|
setMapAllocation(allocation);
|
||||||
|
@ -63,7 +63,7 @@ Pipe *Pipe::create(Context *context,
|
|||||||
true, // allocateMemory
|
true, // allocateMemory
|
||||||
size, GraphicsAllocation::AllocationType::PIPE,
|
size, GraphicsAllocation::AllocationType::PIPE,
|
||||||
false, // isMultiStorageAllocation
|
false, // isMultiStorageAllocation
|
||||||
context->getDevice(0)->getHardwareInfo(), context->getDevice(0)->getDeviceBitfield());
|
context->getDevice(0)->getHardwareInfo(), context->getDeviceBitfieldForAllocation());
|
||||||
GraphicsAllocation *memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties);
|
GraphicsAllocation *memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties);
|
||||||
if (!memory) {
|
if (!memory) {
|
||||||
errcodeRet = CL_OUT_OF_HOST_MEMORY;
|
errcodeRet = CL_OUT_OF_HOST_MEMORY;
|
||||||
|
@ -44,7 +44,7 @@ class D3DBuffer : public D3DSharing<D3D> {
|
|||||||
0, // size
|
0, // size
|
||||||
GraphicsAllocation::AllocationType::SHARED_BUFFER,
|
GraphicsAllocation::AllocationType::SHARED_BUFFER,
|
||||||
false, // isMultiStorageAllocation
|
false, // isMultiStorageAllocation
|
||||||
context->getDevice(0)->getDeviceBitfield()};
|
context->getDeviceBitfieldForAllocation()};
|
||||||
auto alloc = context->getMemoryManager()->createGraphicsAllocationFromSharedHandle(toOsHandle(sharedHandle), properties, true);
|
auto alloc = context->getMemoryManager()->createGraphicsAllocationFromSharedHandle(toOsHandle(sharedHandle), properties, true);
|
||||||
|
|
||||||
auto d3dBufferObj = new D3DBuffer<D3D>(context, d3dBuffer, bufferStaging, sharedResource);
|
auto d3dBufferObj = new D3DBuffer<D3D>(context, d3dBuffer, bufferStaging, sharedResource);
|
||||||
|
@ -86,7 +86,7 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo
|
|||||||
0u, // size
|
0u, // size
|
||||||
GraphicsAllocation::AllocationType::SHARED_IMAGE,
|
GraphicsAllocation::AllocationType::SHARED_IMAGE,
|
||||||
false, // isMultiStorageAllocation
|
false, // isMultiStorageAllocation
|
||||||
context->getDevice(0)->getDeviceBitfield());
|
context->getDeviceBitfieldForAllocation());
|
||||||
alloc = context->getMemoryManager()->createGraphicsAllocationFromSharedHandle(toOsHandle(surfaceInfo->shared_handle), allocProperties,
|
alloc = context->getMemoryManager()->createGraphicsAllocationFromSharedHandle(toOsHandle(surfaceInfo->shared_handle), allocProperties,
|
||||||
false);
|
false);
|
||||||
updateImgInfoAndDesc(alloc->getDefaultGmm(), imgInfo, imagePlane, 0u);
|
updateImgInfoAndDesc(alloc->getDefaultGmm(), imgInfo, imagePlane, 0u);
|
||||||
@ -103,7 +103,7 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo
|
|||||||
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(rootDeviceIndex, imgInfo,
|
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(rootDeviceIndex, imgInfo,
|
||||||
true, // allocateMemory
|
true, // allocateMemory
|
||||||
memoryProperties, context->getDevice(0)->getHardwareInfo(),
|
memoryProperties, context->getDevice(0)->getHardwareInfo(),
|
||||||
context->getDevice(0)->getDeviceBitfield());
|
context->getDeviceBitfieldForAllocation());
|
||||||
allocProperties.allocationType = GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY;
|
allocProperties.allocationType = GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY;
|
||||||
|
|
||||||
alloc = context->getMemoryManager()->allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr);
|
alloc = context->getMemoryManager()->allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr);
|
||||||
|
@ -77,7 +77,7 @@ Image *D3DTexture<D3D>::create2d(Context *context, D3DTexture2d *d3dTexture, cl_
|
|||||||
0u, // size
|
0u, // size
|
||||||
GraphicsAllocation::AllocationType::SHARED_IMAGE,
|
GraphicsAllocation::AllocationType::SHARED_IMAGE,
|
||||||
false, // isMultiStorageAllocation
|
false, // isMultiStorageAllocation
|
||||||
context->getDevice(0)->getDeviceBitfield());
|
context->getDeviceBitfieldForAllocation());
|
||||||
alloc = memoryManager->createGraphicsAllocationFromSharedHandle(toOsHandle(sharedHandle), allocProperties, false);
|
alloc = memoryManager->createGraphicsAllocationFromSharedHandle(toOsHandle(sharedHandle), allocProperties, false);
|
||||||
}
|
}
|
||||||
DEBUG_BREAK_IF(!alloc);
|
DEBUG_BREAK_IF(!alloc);
|
||||||
@ -147,7 +147,7 @@ Image *D3DTexture<D3D>::create3d(Context *context, D3DTexture3d *d3dTexture, cl_
|
|||||||
0u, // size
|
0u, // size
|
||||||
GraphicsAllocation::AllocationType::SHARED_IMAGE,
|
GraphicsAllocation::AllocationType::SHARED_IMAGE,
|
||||||
false, // isMultiStorageAllocation
|
false, // isMultiStorageAllocation
|
||||||
context->getDevice(0)->getDeviceBitfield());
|
context->getDeviceBitfieldForAllocation());
|
||||||
alloc = memoryManager->createGraphicsAllocationFromSharedHandle(toOsHandle(sharedHandle), allocProperties, false);
|
alloc = memoryManager->createGraphicsAllocationFromSharedHandle(toOsHandle(sharedHandle), allocProperties, false);
|
||||||
}
|
}
|
||||||
DEBUG_BREAK_IF(!alloc);
|
DEBUG_BREAK_IF(!alloc);
|
||||||
|
@ -141,7 +141,7 @@ GraphicsAllocation *GlBuffer::createGraphicsAllocation(Context *context, unsigne
|
|||||||
0u, // size
|
0u, // size
|
||||||
GraphicsAllocation::AllocationType::SHARED_BUFFER,
|
GraphicsAllocation::AllocationType::SHARED_BUFFER,
|
||||||
false, // isMultiStorageAllocation
|
false, // isMultiStorageAllocation
|
||||||
context->getDevice(0)->getDeviceBitfield()};
|
context->getDeviceBitfieldForAllocation()};
|
||||||
// couldn't find allocation for reuse - create new
|
// couldn't find allocation for reuse - create new
|
||||||
graphicsAllocation =
|
graphicsAllocation =
|
||||||
context->getMemoryManager()->createGraphicsAllocationFromSharedHandle(bufferInfo.globalShareHandle, properties, true);
|
context->getMemoryManager()->createGraphicsAllocationFromSharedHandle(bufferInfo.globalShareHandle, properties, true);
|
||||||
|
@ -55,7 +55,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl
|
|||||||
0u, // size
|
0u, // size
|
||||||
GraphicsAllocation::AllocationType::SHARED_IMAGE,
|
GraphicsAllocation::AllocationType::SHARED_IMAGE,
|
||||||
false, // isMultiStorageAllocation
|
false, // isMultiStorageAllocation
|
||||||
context->getDevice(0)->getDeviceBitfield());
|
context->getDeviceBitfieldForAllocation());
|
||||||
auto alloc = memoryManager->createGraphicsAllocationFromSharedHandle(texInfo.globalShareHandle, allocProperties, false);
|
auto alloc = memoryManager->createGraphicsAllocationFromSharedHandle(texInfo.globalShareHandle, allocProperties, false);
|
||||||
|
|
||||||
if (alloc == nullptr) {
|
if (alloc == nullptr) {
|
||||||
|
@ -45,7 +45,7 @@ GraphicsAllocation *UnifiedSharing::createGraphicsAllocation(Context *context, U
|
|||||||
0u, // size
|
0u, // size
|
||||||
allocationType,
|
allocationType,
|
||||||
false, // isMultiStorageAllocation
|
false, // isMultiStorageAllocation
|
||||||
context->getDevice(0)->getDeviceBitfield()};
|
context->getDeviceBitfieldForAllocation()};
|
||||||
return memoryManager->createGraphicsAllocationFromSharedHandle(toOsHandle(description.handle), properties, false);
|
return memoryManager->createGraphicsAllocationFromSharedHandle(toOsHandle(description.handle), properties, false);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -66,7 +66,7 @@ Image *VASurface::createSharedVaSurface(Context *context, VASharingFunctions *sh
|
|||||||
AllocationProperties properties(context->getDevice(0)->getRootDeviceIndex(),
|
AllocationProperties properties(context->getDevice(0)->getRootDeviceIndex(),
|
||||||
false, // allocateMemory
|
false, // allocateMemory
|
||||||
imgInfo, GraphicsAllocation::AllocationType::SHARED_IMAGE,
|
imgInfo, GraphicsAllocation::AllocationType::SHARED_IMAGE,
|
||||||
context->getDevice(0)->getDeviceBitfield());
|
context->getDeviceBitfieldForAllocation());
|
||||||
|
|
||||||
auto alloc = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false);
|
auto alloc = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false);
|
||||||
|
|
||||||
|
@ -218,7 +218,6 @@ TEST(clSvmAllocTest, givenSubDeviceWhenCreatingSvmAllocThenProperDeviceBitfieldI
|
|||||||
REQUIRE_SVM_OR_SKIP(defaultHwInfo.get());
|
REQUIRE_SVM_OR_SKIP(defaultHwInfo.get());
|
||||||
UltClDeviceFactory deviceFactory{1, 2};
|
UltClDeviceFactory deviceFactory{1, 2};
|
||||||
auto device = deviceFactory.subDevices[1];
|
auto device = deviceFactory.subDevices[1];
|
||||||
auto expectedDeviceBitfield = device->getDeviceBitfield();
|
|
||||||
|
|
||||||
auto executionEnvironment = device->getExecutionEnvironment();
|
auto executionEnvironment = device->getExecutionEnvironment();
|
||||||
auto memoryManager = new MockMemoryManager(*executionEnvironment);
|
auto memoryManager = new MockMemoryManager(*executionEnvironment);
|
||||||
@ -227,6 +226,7 @@ TEST(clSvmAllocTest, givenSubDeviceWhenCreatingSvmAllocThenProperDeviceBitfieldI
|
|||||||
std::swap(memoryManagerBackup, executionEnvironment->memoryManager);
|
std::swap(memoryManagerBackup, executionEnvironment->memoryManager);
|
||||||
|
|
||||||
MockContext context(device);
|
MockContext context(device);
|
||||||
|
auto expectedDeviceBitfield = context.getDeviceBitfieldForAllocation();
|
||||||
EXPECT_NE(expectedDeviceBitfield, memoryManager->recentlyPassedDeviceBitfield);
|
EXPECT_NE(expectedDeviceBitfield, memoryManager->recentlyPassedDeviceBitfield);
|
||||||
auto svmPtr = clSVMAlloc(&context, CL_MEM_READ_WRITE, MemoryConstants::pageSize, MemoryConstants::cacheLineSize);
|
auto svmPtr = clSVMAlloc(&context, CL_MEM_READ_WRITE, MemoryConstants::pageSize, MemoryConstants::cacheLineSize);
|
||||||
EXPECT_NE(nullptr, svmPtr);
|
EXPECT_NE(nullptr, svmPtr);
|
||||||
|
@ -419,4 +419,23 @@ TEST(Context, givenContextWhenIsDeviceAssociatedIsCalledWithNotAssociatedDeviceT
|
|||||||
MockContext context1;
|
MockContext context1;
|
||||||
EXPECT_FALSE(context0.isDeviceAssociated(*context1.getDevice(0)));
|
EXPECT_FALSE(context0.isDeviceAssociated(*context1.getDevice(0)));
|
||||||
EXPECT_FALSE(context1.isDeviceAssociated(*context0.getDevice(0)));
|
EXPECT_FALSE(context1.isDeviceAssociated(*context0.getDevice(0)));
|
||||||
|
}
|
||||||
|
TEST(Context, givenContextWithSingleDevicesWhenGettingDeviceBitfieldForAllocationThenDeviceBitfieldForDeviceIsReturned) {
|
||||||
|
UltClDeviceFactory deviceFactory{1, 3};
|
||||||
|
auto device = deviceFactory.subDevices[1];
|
||||||
|
auto expectedDeviceBitfield = device->getDeviceBitfield();
|
||||||
|
MockContext context(device);
|
||||||
|
EXPECT_EQ(expectedDeviceBitfield.to_ulong(), context.getDeviceBitfieldForAllocation().to_ulong());
|
||||||
|
}
|
||||||
|
TEST(Context, givenContextWithMultipleSubDevicesWhenGettingDeviceBitfieldForAllocationThenMergedDeviceBitfieldIsReturned) {
|
||||||
|
UltClDeviceFactory deviceFactory{1, 3};
|
||||||
|
cl_int retVal;
|
||||||
|
cl_device_id devices[]{deviceFactory.subDevices[0], deviceFactory.subDevices[2]};
|
||||||
|
ClDeviceVector deviceVector(devices, 2);
|
||||||
|
auto expectedDeviceBitfield = deviceFactory.subDevices[0]->getDeviceBitfield() | deviceFactory.subDevices[2]->getDeviceBitfield();
|
||||||
|
auto context = Context::create<Context>(0, deviceVector, nullptr, nullptr, retVal);
|
||||||
|
EXPECT_NE(nullptr, context);
|
||||||
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||||
|
EXPECT_EQ(expectedDeviceBitfield.to_ulong(), context->getDeviceBitfieldForAllocation().to_ulong());
|
||||||
|
context->release();
|
||||||
}
|
}
|
Reference in New Issue
Block a user