diff --git a/opencl/source/api/api.cpp b/opencl/source/api/api.cpp index d34573c0cd..dc8eb4f960 100644 --- a/opencl/source/api/api.cpp +++ b/opencl/source/api/api.cpp @@ -4668,6 +4668,11 @@ cl_mem CL_API_CALL clCreatePipe(cl_context context, } auto pDevice = pContext->getDevice(0); + if (pDevice->arePipesSupported() == false) { + retVal = CL_INVALID_OPERATION; + break; + } + if (pipePacketSize > pDevice->getDeviceInfo().pipeMaxPacketSize) { retVal = CL_INVALID_PIPE_SIZE; break; diff --git a/opencl/source/cl_device/cl_device.cpp b/opencl/source/cl_device/cl_device.cpp index ff591c6db4..9582d321d4 100644 --- a/opencl/source/cl_device/cl_device.cpp +++ b/opencl/source/cl_device/cl_device.cpp @@ -187,4 +187,8 @@ bool ClDevice::isDeviceEnqueueSupported() const { return device.getHardwareInfo().capabilityTable.supportsDeviceEnqueue; } +bool ClDevice::arePipesSupported() const { + return device.getHardwareInfo().capabilityTable.supportsPipes; +} + } // namespace NEO diff --git a/opencl/source/cl_device/cl_device.h b/opencl/source/cl_device/cl_device.h index be56037a10..935c99c840 100644 --- a/opencl/source/cl_device/cl_device.h +++ b/opencl/source/cl_device/cl_device.h @@ -119,6 +119,7 @@ class ClDevice : public BaseObject<_cl_device_id> { std::unique_ptr syncBufferHandler; DeviceBitfield getDeviceBitfield() const; bool isDeviceEnqueueSupported() const; + bool arePipesSupported() const; protected: void initializeCaps(); diff --git a/opencl/source/cl_device/cl_device_caps.cpp b/opencl/source/cl_device/cl_device_caps.cpp index bbe98223c7..fb8d4f111f 100644 --- a/opencl/source/cl_device/cl_device_caps.cpp +++ b/opencl/source/cl_device/cl_device_caps.cpp @@ -294,11 +294,18 @@ void ClDevice::initializeCaps() { // cl_khr_image2d_from_buffer deviceInfo.imagePitchAlignment = hwHelper.getPitchAlignmentForImage(&hwInfo); deviceInfo.imageBaseAddressAlignment = 4; - deviceInfo.maxPipeArgs = 16; - deviceInfo.pipeMaxPacketSize = 1024; - deviceInfo.pipeMaxActiveReservations = 1; deviceInfo.queueOnHostProperties = CL_QUEUE_PROFILING_ENABLE | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; + if (arePipesSupported()) { + deviceInfo.maxPipeArgs = 16; + deviceInfo.pipeMaxPacketSize = 1024; + deviceInfo.pipeMaxActiveReservations = 1; + } else { + deviceInfo.maxPipeArgs = 0; + deviceInfo.pipeMaxPacketSize = 0; + deviceInfo.pipeMaxActiveReservations = 0; + } + deviceInfo.linkerAvailable = true; deviceInfo.svmCapabilities = hwInfo.capabilityTable.ftrSvm * CL_DEVICE_SVM_COARSE_GRAIN_BUFFER; if (hwInfo.capabilityTable.ftrSvm) { diff --git a/opencl/source/gen11/hw_info_ehl.inl b/opencl/source/gen11/hw_info_ehl.inl index 3bd0212967..750d944c20 100644 --- a/opencl/source/gen11/hw_info_ehl.inl +++ b/opencl/source/gen11/hw_info_ehl.inl @@ -70,6 +70,7 @@ const RuntimeCapabilityTable EHL::capabilityTable{ false, // supportCacheFlushAfterWalker true, // supportsImages true, // supportsDeviceEnqueue + false, // supportsPipes true // hostPtrTrackingEnabled }; diff --git a/opencl/source/gen11/hw_info_icllp.inl b/opencl/source/gen11/hw_info_icllp.inl index 9614cc6703..f6d3f6537f 100644 --- a/opencl/source/gen11/hw_info_icllp.inl +++ b/opencl/source/gen11/hw_info_icllp.inl @@ -71,6 +71,7 @@ const RuntimeCapabilityTable ICLLP::capabilityTable{ false, // supportCacheFlushAfterWalker true, // supportsImages true, // supportsDeviceEnqueue + true, // supportsPipes true // hostPtrTrackingEnabled }; diff --git a/opencl/source/gen11/hw_info_lkf.inl b/opencl/source/gen11/hw_info_lkf.inl index fd0054cee5..b5fde8fb12 100644 --- a/opencl/source/gen11/hw_info_lkf.inl +++ b/opencl/source/gen11/hw_info_lkf.inl @@ -70,6 +70,7 @@ const RuntimeCapabilityTable LKF::capabilityTable{ false, // supportCacheFlushAfterWalker true, // supportsImages true, // supportsDeviceEnqueue + false, // supportsPipes true // hostPtrTrackingEnabled }; diff --git a/opencl/source/gen12lp/hw_info_tgllp.inl b/opencl/source/gen12lp/hw_info_tgllp.inl index 44b7652149..f3139752fa 100644 --- a/opencl/source/gen12lp/hw_info_tgllp.inl +++ b/opencl/source/gen12lp/hw_info_tgllp.inl @@ -72,6 +72,7 @@ const RuntimeCapabilityTable TGLLP::capabilityTable{ false, // supportCacheFlushAfterWalker true, // supportsImages true, // supportsDeviceEnqueue + false, // supportsPipes false // hostPtrTrackingEnabled }; diff --git a/opencl/source/gen8/hw_info_bdw.inl b/opencl/source/gen8/hw_info_bdw.inl index b567e670ef..daa1cc1506 100644 --- a/opencl/source/gen8/hw_info_bdw.inl +++ b/opencl/source/gen8/hw_info_bdw.inl @@ -75,6 +75,7 @@ const RuntimeCapabilityTable BDW::capabilityTable{ false, // supportCacheFlushAfterWalker true, // supportsImages true, // supportsDeviceEnqueue + true, // supportsPipes true // hostPtrTrackingEnabled }; diff --git a/opencl/source/gen9/hw_info_bxt.inl b/opencl/source/gen9/hw_info_bxt.inl index d5319c28f9..e1eb1161f7 100644 --- a/opencl/source/gen9/hw_info_bxt.inl +++ b/opencl/source/gen9/hw_info_bxt.inl @@ -72,6 +72,7 @@ const RuntimeCapabilityTable BXT::capabilityTable{ false, // supportCacheFlushAfterWalker true, // supportsImages false, // supportsDeviceEnqueue + false, // supportsPipes true // hostPtrTrackingEnabled }; diff --git a/opencl/source/gen9/hw_info_cfl.inl b/opencl/source/gen9/hw_info_cfl.inl index be3e2ab147..86d447364d 100644 --- a/opencl/source/gen9/hw_info_cfl.inl +++ b/opencl/source/gen9/hw_info_cfl.inl @@ -67,6 +67,7 @@ const RuntimeCapabilityTable CFL::capabilityTable{ false, // supportCacheFlushAfterWalker true, // supportsImages true, // supportsDeviceEnqueue + true, // supportsPipes true // hostPtrTrackingEnabled }; diff --git a/opencl/source/gen9/hw_info_glk.inl b/opencl/source/gen9/hw_info_glk.inl index 09eb5a062e..cca4f6dd67 100644 --- a/opencl/source/gen9/hw_info_glk.inl +++ b/opencl/source/gen9/hw_info_glk.inl @@ -67,6 +67,7 @@ const RuntimeCapabilityTable GLK::capabilityTable{ false, // supportCacheFlushAfterWalker true, // supportsImages false, // supportsDeviceEnqueue + false, // supportsPipes true // hostPtrTrackingEnabled }; diff --git a/opencl/source/gen9/hw_info_kbl.inl b/opencl/source/gen9/hw_info_kbl.inl index d331164639..d8b9ba3087 100644 --- a/opencl/source/gen9/hw_info_kbl.inl +++ b/opencl/source/gen9/hw_info_kbl.inl @@ -67,6 +67,7 @@ const RuntimeCapabilityTable KBL::capabilityTable{ false, // supportCacheFlushAfterWalker true, // supportsImages true, // supportsDeviceEnqueue + true, // supportsPipes true // hostPtrTrackingEnabled }; diff --git a/opencl/source/gen9/hw_info_skl.inl b/opencl/source/gen9/hw_info_skl.inl index b0c3cc0f8f..97cb93b56c 100644 --- a/opencl/source/gen9/hw_info_skl.inl +++ b/opencl/source/gen9/hw_info_skl.inl @@ -75,6 +75,7 @@ const RuntimeCapabilityTable SKL::capabilityTable{ false, // supportCacheFlushAfterWalker true, // supportsImages true, // supportsDeviceEnqueue + true, // supportsPipes true // hostPtrTrackingEnabled }; WorkaroundTable SKL::workaroundTable = {}; diff --git a/opencl/test/unit_test/api/cl_create_pipe_tests.inl b/opencl/test/unit_test/api/cl_create_pipe_tests.inl index c1436fc729..ee1b0e592a 100644 --- a/opencl/test/unit_test/api/cl_create_pipe_tests.inl +++ b/opencl/test/unit_test/api/cl_create_pipe_tests.inl @@ -11,12 +11,15 @@ #include "opencl/source/context/context.h" #include "opencl/source/helpers/base_object.h" #include "opencl/test/unit_test/mocks/mock_platform.h" +#include "opencl/test/unit_test/test_macros/test_checks_ocl.h" #include "cl_api_tests.h" using namespace NEO; -typedef api_tests clCreatePipeTests; +struct clCreatePipeTests : api_tests { + VariableBackup supportsPipesBackup{&defaultHwInfo->capabilityTable.supportsPipes, true}; +}; namespace ClCreatePipeTests { @@ -27,6 +30,7 @@ class clCreatePipeWithParamTests : public ApiFixture<>, public testing::TestWith void TearDown() override { ApiFixture::TearDown(); } + VariableBackup supportsPipesBackup{&defaultHwInfo->capabilityTable.supportsPipes, true}; }; class clCreatePipeWithParamNegativeTests : public ApiFixture<>, public testing::TestWithParam { @@ -36,6 +40,7 @@ class clCreatePipeWithParamNegativeTests : public ApiFixture<>, public testing:: void TearDown() override { ApiFixture::TearDown(); } + VariableBackup supportsPipesBackup{&defaultHwInfo->capabilityTable.supportsPipes, true}; }; TEST_P(clCreatePipeWithParamTests, GivenValidFlagsWhenCreatingPipeThenPipeIsCreatedAndSuccessIsReturned) { @@ -136,6 +141,18 @@ TEST_F(clCreatePipeTests, GivenPipePropertiesNotNullWhenCreatingPipeThenInvalidV clReleaseMemObject(pipe); } +TEST_F(clCreatePipeTests, GivenDeviceNotSupportingPipesWhenCreatingPipeThenInvalidOperationErrorIsReturned) { + auto hardwareInfo = *defaultHwInfo; + hardwareInfo.capabilityTable.supportsPipes = false; + + auto pClDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(&hardwareInfo, 0)); + MockContext mockContext{pClDevice.get(), false}; + + auto pipe = clCreatePipe(&mockContext, 0, 1, 20, nullptr, &retVal); + EXPECT_EQ(nullptr, pipe); + EXPECT_EQ(CL_INVALID_OPERATION, retVal); +} + TEST_F(clCreatePipeTests, GivenPipePacketSizeGreaterThanAllowedWhenCreatingPipeThenInvalidPipeSizeErrorIsReturned) { cl_uint packetSize = pContext->getDevice(0)->getDeviceInfo().pipeMaxPacketSize; cl_mem_flags flags = CL_MEM_READ_WRITE; @@ -171,7 +188,7 @@ TEST(clCreatePipeTest, givenPlatformWithoutDevicesWhenClCreatePipeIsCalledThenDe executionEnvironment->prepareRootDeviceEnvironments(1); auto device = std::make_unique(*Device::create(executionEnvironment, 0u), platform()); const ClDeviceInfo &devInfo = device->getDeviceInfo(); - if (devInfo.svmCapabilities == 0) { + if (devInfo.svmCapabilities == 0 || device->getHardwareInfo().capabilityTable.supportsPipes == false) { GTEST_SKIP(); } cl_device_id clDevice = device.get(); diff --git a/opencl/test/unit_test/api/cl_get_pipe_info_tests.inl b/opencl/test/unit_test/api/cl_get_pipe_info_tests.inl index bf1f61560f..a5faa0eb66 100644 --- a/opencl/test/unit_test/api/cl_get_pipe_info_tests.inl +++ b/opencl/test/unit_test/api/cl_get_pipe_info_tests.inl @@ -7,12 +7,15 @@ #include "opencl/source/context/context.h" #include "opencl/source/mem_obj/pipe.h" +#include "opencl/test/unit_test/test_macros/test_checks_ocl.h" #include "cl_api_tests.h" using namespace NEO; -typedef api_tests clGetPipeInfoTests; +struct clGetPipeInfoTests : api_tests { + VariableBackup supportsPipesBackup{&defaultHwInfo->capabilityTable.supportsPipes, true}; +}; namespace ULT { diff --git a/opencl/test/unit_test/device/device_caps_tests.cpp b/opencl/test/unit_test/device/device_caps_tests.cpp index e17529686e..50b9c191c1 100644 --- a/opencl/test/unit_test/device/device_caps_tests.cpp +++ b/opencl/test/unit_test/device/device_caps_tests.cpp @@ -161,6 +161,16 @@ TEST_F(DeviceGetCapsTest, WhenCreatingDeviceThenCapsArePopulatedCorrectly) { EXPECT_EQ(static_cast(0), caps.queueOnDeviceProperties); } + if (defaultHwInfo->capabilityTable.supportsPipes) { + EXPECT_EQ(16u, caps.maxPipeArgs); + EXPECT_EQ(1024u, caps.pipeMaxPacketSize); + EXPECT_EQ(1u, caps.pipeMaxActiveReservations); + } else { + EXPECT_EQ(0u, caps.maxPipeArgs); + EXPECT_EQ(0u, caps.pipeMaxPacketSize); + EXPECT_EQ(0u, caps.pipeMaxActiveReservations); + } + EXPECT_EQ(64u, caps.preferredGlobalAtomicAlignment); EXPECT_EQ(64u, caps.preferredLocalAtomicAlignment); EXPECT_EQ(64u, caps.preferredPlatformAtomicAlignment); diff --git a/opencl/test/unit_test/test_macros/test_checks_ocl.h b/opencl/test/unit_test/test_macros/test_checks_ocl.h index 4960765aec..8656669010 100644 --- a/opencl/test/unit_test/test_macros/test_checks_ocl.h +++ b/opencl/test/unit_test/test_macros/test_checks_ocl.h @@ -21,6 +21,7 @@ bool supportsOcl21(const Context *pContext); bool supportsDeviceEnqueue(const ClDevice *pClDevice); bool supportsDeviceEnqueue(const Context *pContext); bool supportsDeviceEnqueue(const std::unique_ptr &pHardwareInfo); +bool supportsPipes(const ClDevice *pClDevice); } // namespace TestChecks } // namespace NEO diff --git a/shared/source/helpers/hw_info.h b/shared/source/helpers/hw_info.h index 2559a07776..bad1d9c6c8 100644 --- a/shared/source/helpers/hw_info.h +++ b/shared/source/helpers/hw_info.h @@ -54,6 +54,7 @@ struct RuntimeCapabilityTable { bool supportCacheFlushAfterWalker; bool supportsImages; bool supportsDeviceEnqueue; + bool supportsPipes; bool hostPtrTrackingEnabled; };