Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions opencl/extensions/public/cl_ext_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,4 +421,10 @@ typedef struct _cl_kernel_allocation_info_intel {
// cl_device bfloat16 atomic capabilities
#if !defined(CL_DEVICE_BFLOAT16_FP_ATOMIC_CAPABILITIES_EXT)
#define CL_DEVICE_BFLOAT16_FP_ATOMIC_CAPABILITIES_EXT 0x10012

/******************************************************
* cl_intel_bindless_images extension *
******************************************************/
#define CL_MEM_BINDLESS_IMAGE_INTEL 0x4220

#endif
6 changes: 5 additions & 1 deletion opencl/source/helpers/api_specific_config_ocl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "shared/source/device/device.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/helpers/compiler_product_helper.h"
#include "shared/source/release_helper/release_helper.h"

#include "opencl/source/os_interface/ocl_reg_path.h"

Expand All @@ -20,7 +21,10 @@ StackVec<const char *, 4> validClPrefixes;
StackVec<NEO::DebugVarPrefix, 4> validClPrefixTypes;

bool ApiSpecificConfig::getGlobalBindlessHeapConfiguration(const ReleaseHelper &releaseHelper) {
return false;
if (debugManager.flags.UseExternalAllocatorForSshAndDsh.get() != -1) {
return debugManager.flags.UseExternalAllocatorForSshAndDsh.get();
}
return releaseHelper.isGlobalBindlessAllocatorEnabled();
}

bool ApiSpecificConfig::getBindlessMode(const Device &device) {
Expand Down
9 changes: 6 additions & 3 deletions opencl/source/helpers/cl_memory_properties_helpers.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2024 Intel Corporation
* Copyright (C) 2021-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -24,7 +24,7 @@ bool ClMemoryPropertiesHelper::parseMemoryProperties(const cl_mem_properties_int
uint64_t handleType = 0;
uintptr_t hostptr = 0;
std::vector<Device *> devices;

bool bindlessImage = false;
if (properties != nullptr) {
for (int i = 0; properties[i] != 0; i += 2) {
switch (properties[i]) {
Expand Down Expand Up @@ -73,6 +73,9 @@ bool ClMemoryPropertiesHelper::parseMemoryProperties(const cl_mem_properties_int
i++;
}
break;
case CL_MEM_BINDLESS_IMAGE_INTEL: // Avoiding get a false when using bindless image extension
bindlessImage = true;
break;
default:
return false;
}
Expand All @@ -84,7 +87,7 @@ bool ClMemoryPropertiesHelper::parseMemoryProperties(const cl_mem_properties_int
memoryProperties.handle = handle;
memoryProperties.hostptr = hostptr;
memoryProperties.associatedDevices = devices;

memoryProperties.flags.bindlessImage = bindlessImage;
switch (objectType) {
case ClMemoryPropertiesHelper::ObjType::buffer:
return isFieldValid(flags, MemObjHelper::validFlagsForBuffer) &&
Expand Down
13 changes: 13 additions & 0 deletions opencl/source/mem_obj/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,19 @@ Image *Image::create(Context *context,

setImageProperties(image, *imageDesc, imgInfo, parentImage, parentBuffer, hostPtrRowPitch, hostPtrSlicePitch, imageCount, hostPtrMinSize);

auto defaultRootDeviceEnv = defaultDevice->getExecutionEnvironment()->rootDeviceEnvironments[defaultRootDeviceIndex].get();
auto bindlessHelper = defaultRootDeviceEnv->getBindlessHeapsHelper();
if (bindlessHelper && image && memoryProperties.flags.bindlessImage) {
auto allocation = image->getGraphicsAllocation(defaultRootDeviceIndex);
auto memManager = context->getMemoryManager();
if (memManager->allocateBindlessSlot(allocation)) {
if (allocation->getBindlessOffset() != std::numeric_limits<uint64_t>::max()) {
image->bindlessInfo = std::make_unique<SurfaceStateInHeapInfo>(allocation->getBindlessInfo());
image->bindlessImage = true;
}
}
}

errcodeRet = CL_SUCCESS;
auto &defaultHwInfo = defaultDevice->getHardwareInfo();
if (context->isProvidingPerformanceHints()) {
Expand Down
6 changes: 6 additions & 0 deletions opencl/source/mem_obj/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#pragma once
#include "shared/source/helpers/bindless_heaps_helper.h"
#include "shared/source/memory_manager/graphics_allocation.h"

#include "opencl/source/helpers/surface_formats.h"
Expand Down Expand Up @@ -205,6 +206,9 @@ class Image : public MemObj {
void fillImageRegion(size_t *region) const;

static bool validateHandleType(MemoryProperties &memoryProperties, UnifiedSharingMemoryDescription &extMem);
SurfaceStateInHeapInfo *getBindlessSlot() const { return bindlessInfo.get(); }
uint64_t getBindlessHandle() const { return bindlessInfo ? bindlessInfo->surfaceStateOffset : 0; }
bool isBindlessImage() const { return bindlessImage; }
void setAs3DUavOrRtvImage(bool isUavOrRtv);
void setIsPackedFormat(bool isPackedFormat) { this->isPackedFormat = isPackedFormat; }

Expand Down Expand Up @@ -248,6 +252,8 @@ class Image : public MemObj {
ImagePlane plane = ImagePlane::noPlane;
bool is3DUAVOrRTV = false;
bool isPackedFormat = false;
std::unique_ptr<SurfaceStateInHeapInfo> bindlessInfo;
bool bindlessImage = false;

static bool isValidSingleChannelFormat(const cl_image_format *imageFormat);
static bool isValidIntensityFormat(const cl_image_format *imageFormat);
Expand Down
13 changes: 13 additions & 0 deletions opencl/test/unit_test/helpers/api_specific_config_ocl_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/memory_manager/allocation_properties.h"
#include "shared/source/memory_manager/compression_selector.h"
#include "shared/source/release_helper/release_helper.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/mocks/mock_release_helper.h"

#include "opencl/source/os_interface/ocl_reg_path.h"

Expand Down Expand Up @@ -57,4 +59,15 @@ TEST(ApiSpecificConfigOclTests, WhenCheckingIfDeviceUsmPoolingIsEnabledThenRetur
EXPECT_TRUE(ApiSpecificConfig::isDeviceUsmPoolingEnabled());
}

TEST(ApiSpecificConfigOclTests, WhenGettingGlobalBindlessHeapConfigurationWithDebugFlagThenReturnDebugFlagValue) {
DebugManagerStateRestore restorer;
MockReleaseHelper releaseHelper;

debugManager.flags.UseExternalAllocatorForSshAndDsh.set(1);
EXPECT_TRUE(ApiSpecificConfig::getGlobalBindlessHeapConfiguration(releaseHelper));

debugManager.flags.UseExternalAllocatorForSshAndDsh.set(0);
EXPECT_FALSE(ApiSpecificConfig::getGlobalBindlessHeapConfiguration(releaseHelper));
}

} // namespace NEO
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/mocks/ult_device_factory.h"

#include "opencl/extensions/public/cl_ext_private.h"
#include "opencl/source/helpers/cl_memory_properties_helpers.h"
#include "opencl/source/mem_obj/mem_obj_helper.h"
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
Expand Down Expand Up @@ -599,3 +600,20 @@ TEST_F(MemoryPropertiesHelperTests, givenSubDeviceIdWhenParsingExtraMemoryProper
EXPECT_EQ(0b10u, memoryProperties.pDevice->getDeviceBitfield().to_ulong());
EXPECT_EQ(&context.pSubDevice1->getDevice(), memoryProperties.pDevice);
}
TEST_F(MemoryPropertiesHelperTests, givenBindlessImagePropertyWhenParsingMemoryPropertiesForImageThenTrueIsReturnedAndFlagIsSet) {
cl_mem_properties_intel properties[] = {
CL_MEM_BINDLESS_IMAGE_INTEL, 1,
0};
EXPECT_TRUE(ClMemoryPropertiesHelper::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
ClMemoryPropertiesHelper::ObjType::image, context));
EXPECT_TRUE(memoryProperties.flags.bindlessImage);
}

TEST_F(MemoryPropertiesHelperTests, givenNoBindlessImagePropertyWhenParsingMemoryPropertiesForImageThenBindlessFlagIsNotSet) {
cl_mem_properties_intel properties[] = {
CL_MEM_FLAGS, CL_MEM_READ_WRITE,
0};
EXPECT_TRUE(ClMemoryPropertiesHelper::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
ClMemoryPropertiesHelper::ObjType::image, context));
EXPECT_FALSE(memoryProperties.flags.bindlessImage);
}
1 change: 1 addition & 0 deletions shared/source/helpers/memory_properties_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct MemoryFlags {
uint32_t compressedHint : 1;
uint32_t uncompressedHint : 1;
uint32_t ipcSupportedAllocationByDefault : 1;
uint32_t bindlessImage : 1;

bool operator==(const MemoryFlags &) const = default;
};
Expand Down