2019-10-07 14:23:51 +02:00
|
|
|
/*
|
2020-01-07 12:54:43 +01:00
|
|
|
* Copyright (C) 2019-2020 Intel Corporation
|
2019-10-07 14:23:51 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "unified_buffer.h"
|
|
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/gmm_helper/gmm.h"
|
|
|
|
|
#include "shared/source/helpers/get_info.h"
|
|
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2020-02-22 22:50:57 +01:00
|
|
|
#include "opencl/source/context/context.h"
|
|
|
|
|
#include "opencl/source/mem_obj/buffer.h"
|
2019-10-07 14:23:51 +02:00
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
using namespace NEO;
|
|
|
|
|
|
|
|
|
|
Buffer *UnifiedBuffer::createSharedUnifiedBuffer(Context *context, cl_mem_flags flags, UnifiedSharingMemoryDescription extMem, cl_int *errcodeRet) {
|
|
|
|
|
ErrorCodeHelper errorCode(errcodeRet, CL_SUCCESS);
|
|
|
|
|
|
2020-01-08 12:58:37 +01:00
|
|
|
auto graphicsAllocation = UnifiedBuffer::createGraphicsAllocation(context, extMem, GraphicsAllocation::AllocationType::SHARED_BUFFER);
|
2019-10-07 14:23:51 +02:00
|
|
|
if (!graphicsAllocation) {
|
|
|
|
|
errorCode.set(CL_INVALID_MEM_OBJECT);
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UnifiedSharingFunctions *sharingFunctions = context->getSharing<UnifiedSharingFunctions>();
|
|
|
|
|
auto sharingHandler = new UnifiedBuffer(sharingFunctions, extMem.type);
|
2020-07-15 12:53:15 +02:00
|
|
|
auto rootDeviceIndex = graphicsAllocation->getRootDeviceIndex();
|
|
|
|
|
auto multiGraphicsAllocation = MultiGraphicsAllocation(rootDeviceIndex);
|
|
|
|
|
multiGraphicsAllocation.addAllocation(graphicsAllocation);
|
|
|
|
|
|
2020-07-16 23:56:26 +02:00
|
|
|
return Buffer::createSharedBuffer(context, flags, sharingHandler, std::move(multiGraphicsAllocation));
|
2019-10-07 14:23:51 +02:00
|
|
|
}
|