Add support for GT-Pin Callbacks [1/n]
- Also fixes bug when returning version of supported GT-Pin interface Change-Id: Ib471a11a3b51d69240dcd2f800a8e28eefdeed57
This commit is contained in:
parent
11e7a5f1d9
commit
17c6142191
|
@ -2,4 +2,4 @@
|
|||
neoDependenciesRev='727168-748'
|
||||
strategy='EQUAL'
|
||||
allowedF=49
|
||||
allowedCD=374
|
||||
allowedCD=373
|
||||
|
|
|
@ -250,10 +250,19 @@ set (RUNTIME_SRCS_EXECUTION_MODEL
|
|||
|
||||
if(GTPIN_HEADERS_DIR)
|
||||
set (RUNTIME_SRCS_GTPIN
|
||||
gtpin/gtpin_init.cpp
|
||||
gtpin/gtpin_init.h
|
||||
gtpin/gtpin_callbacks.cpp
|
||||
gtpin/gtpin_helpers.cpp
|
||||
gtpin/gtpin_helpers.h
|
||||
gtpin/gtpin_hw_helper.cpp
|
||||
gtpin/gtpin_hw_helper.h
|
||||
gtpin/gtpin_init.cpp
|
||||
gtpin/gtpin_init.h
|
||||
gtpin/gtpin_notify.h
|
||||
)
|
||||
else(GTPIN_HEADERS_DIR)
|
||||
set (RUNTIME_SRCS_GTPIN
|
||||
gtpin/gtpin_callback_stubs.cpp
|
||||
gtpin/gtpin_notify.h
|
||||
)
|
||||
endif(GTPIN_HEADERS_DIR)
|
||||
|
||||
|
@ -803,6 +812,12 @@ if(${GENERATE_EXECUTABLE})
|
|||
|
||||
if(GTPIN_HEADERS_DIR)
|
||||
list (APPEND RUNTIME_SRCS_DLL gtpin/gtpin_init.cpp)
|
||||
foreach(GEN_NUM RANGE ${MAX_GEN} 0 -1)
|
||||
GEN_CONTAINS_PLATFORMS("SUPPORTED" ${GEN_NUM} GENX_HAS_PLATFORMS)
|
||||
if(${GENX_HAS_PLATFORMS})
|
||||
list(APPEND RUNTIME_SRCS_GTPIN gtpin/gtpin_setup_gen${GEN_NUM}.cpp)
|
||||
endif(${GENX_HAS_PLATFORMS})
|
||||
endforeach(GEN_NUM)
|
||||
endif(GTPIN_HEADERS_DIR)
|
||||
|
||||
add_library(${NEO_DYNAMIC_LIB_NAME} SHARED
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "runtime/context/driver_diagnostics.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/device_queue/device_queue.h"
|
||||
#include "runtime/gtpin/gtpin_notify.h"
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/helpers/get_info.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
|
@ -289,6 +290,9 @@ cl_context CL_API_CALL clCreateContext(const cl_context_properties *properties,
|
|||
|
||||
DeviceVector allDevs(devices, numDevices);
|
||||
context = Context::create<Context>(properties, allDevs, funcNotify, userData, retVal);
|
||||
if (context != nullptr) {
|
||||
gtpinNotifyContextCreate(context);
|
||||
}
|
||||
} while (false);
|
||||
|
||||
if (errcodeRet) {
|
||||
|
@ -314,7 +318,7 @@ cl_context CL_API_CALL clCreateContextFromType(const cl_context_properties *prop
|
|||
}
|
||||
|
||||
cl_uint numDevices = 0;
|
||||
/* Querry the number of device first. */
|
||||
/* Query the number of device first. */
|
||||
retVal = clGetDeviceIDs(nullptr, deviceType, 0, nullptr, &numDevices);
|
||||
if (retVal != CL_SUCCESS) {
|
||||
break;
|
||||
|
@ -329,6 +333,9 @@ cl_context CL_API_CALL clCreateContextFromType(const cl_context_properties *prop
|
|||
|
||||
DeviceVector allDevs(supportedDevs.begin(), numDevices);
|
||||
pContext = Context::create<Context>(properties, allDevs, funcNotify, userData, retVal);
|
||||
if (pContext != nullptr) {
|
||||
gtpinNotifyContextCreate((cl_context)pContext);
|
||||
}
|
||||
} while (false);
|
||||
|
||||
if (errcodeRet) {
|
||||
|
@ -353,6 +360,7 @@ cl_int CL_API_CALL clReleaseContext(cl_context context) {
|
|||
Context *pContext = castToObject<Context>(context);
|
||||
if (pContext) {
|
||||
pContext->release();
|
||||
gtpinNotifyContextDestroy(context);
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "CL/cl.h"
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
void gtpinNotifyContextCreate(cl_context context) {
|
||||
}
|
||||
|
||||
void gtpinNotifyContextDestroy(cl_context context) {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "gtpin_dx11_interface.h"
|
||||
#include "CL/cl.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/device/device_info.h"
|
||||
#include "runtime/gtpin/gtpin_hw_helper.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
|
||||
using namespace gtpin;
|
||||
|
||||
namespace OCLRT {
|
||||
extern bool isGTPinInitialized;
|
||||
extern gtpin::dx11::gtpin_events_t GTPinCallbacks;
|
||||
|
||||
igc_init_t *pIgcInfo = nullptr;
|
||||
|
||||
void gtpinNotifyContextCreate(cl_context context) {
|
||||
if (isGTPinInitialized) {
|
||||
platform_info_t gtpinPlatformInfo;
|
||||
auto pPlatform = platform();
|
||||
auto pDevice = pPlatform->getDevice(0);
|
||||
GFXCORE_FAMILY genFamily = pDevice->getHardwareInfo().pPlatform->eRenderCoreFamily;
|
||||
GTPinHwHelper >pinHelper = GTPinHwHelper::get(genFamily);
|
||||
gtpinPlatformInfo.gen_version = (gtpin::GTPIN_GEN_VERSION)gtpinHelper.getGenVersion();
|
||||
gtpinPlatformInfo.device_id = static_cast<uint32_t>(pDevice->getHardwareInfo().pPlatform->usDeviceID);
|
||||
|
||||
(*GTPinCallbacks.onContextCreate)((context_handle_t)context, >pinPlatformInfo, &pIgcInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void gtpinNotifyContextDestroy(cl_context context) {
|
||||
if (isGTPinInitialized) {
|
||||
(*GTPinCallbacks.onContextDestroy)((context_handle_t)context);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -49,7 +49,7 @@ GTPIN_DI_STATUS gtpinCreateBuffer(context_handle_t context, uint32_t reqSize, re
|
|||
return GTPIN_DI_SUCCESS;
|
||||
}
|
||||
|
||||
GTPIN_DI_STATUS gtpinFreeBuffer(gtpin::context_handle_t context, gtpin::resource_handle_t resource) {
|
||||
GTPIN_DI_STATUS gtpinFreeBuffer(context_handle_t context, resource_handle_t resource) {
|
||||
cl_mem buffer = (cl_mem)resource;
|
||||
Context *pContext = castToObject<Context>((cl_context)context);
|
||||
if ((pContext == nullptr) || (buffer == nullptr)) {
|
||||
|
@ -64,7 +64,7 @@ GTPIN_DI_STATUS gtpinFreeBuffer(gtpin::context_handle_t context, gtpin::resource
|
|||
return GTPIN_DI_SUCCESS;
|
||||
}
|
||||
|
||||
GTPIN_DI_STATUS gtpinMapBuffer(gtpin::context_handle_t context, gtpin::resource_handle_t resource, uint8_t **pAddress) {
|
||||
GTPIN_DI_STATUS gtpinMapBuffer(context_handle_t context, resource_handle_t resource, uint8_t **pAddress) {
|
||||
cl_mem buffer = (cl_mem)resource;
|
||||
Context *pContext = castToObject<Context>((cl_context)context);
|
||||
if ((pContext == nullptr) || (buffer == nullptr) || (pAddress == nullptr)) {
|
||||
|
@ -78,7 +78,7 @@ GTPIN_DI_STATUS gtpinMapBuffer(gtpin::context_handle_t context, gtpin::resource_
|
|||
return GTPIN_DI_SUCCESS;
|
||||
}
|
||||
|
||||
GTPIN_DI_STATUS gtpinUnmapBuffer(gtpin::context_handle_t context, gtpin::resource_handle_t resource) {
|
||||
GTPIN_DI_STATUS gtpinUnmapBuffer(context_handle_t context, resource_handle_t resource) {
|
||||
cl_mem buffer = (cl_mem)resource;
|
||||
Context *pContext = castToObject<Context>((cl_context)context);
|
||||
if ((pContext == nullptr) || (buffer == nullptr)) {
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtime/gtpin/gtpin_hw_helper.h"
|
||||
|
||||
namespace OCLRT {
|
||||
GTPinHwHelper *gtpinHwHelperFactory[IGFX_MAX_CORE] = {};
|
||||
|
||||
GTPinHwHelper >PinHwHelper::get(GFXCORE_FAMILY gfxCore) {
|
||||
return *gtpinHwHelperFactory[gfxCore];
|
||||
}
|
||||
} // namespace OCLRT
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/gen_common/hw_cmds.h"
|
||||
|
||||
namespace OCLRT {
|
||||
class GTPinHwHelper {
|
||||
public:
|
||||
static GTPinHwHelper &get(GFXCORE_FAMILY gfxCore);
|
||||
virtual uint32_t getGenVersion() = 0;
|
||||
|
||||
protected:
|
||||
GTPinHwHelper(){};
|
||||
};
|
||||
|
||||
template <typename GfxFamily>
|
||||
class GTPinHwHelperHw : public GTPinHwHelper {
|
||||
public:
|
||||
static GTPinHwHelper &get() {
|
||||
static GTPinHwHelperHw<GfxFamily> gtpinHwHelper;
|
||||
return gtpinHwHelper;
|
||||
}
|
||||
uint32_t getGenVersion() override;
|
||||
|
||||
private:
|
||||
GTPinHwHelperHw(){};
|
||||
};
|
||||
} // namespace OCLRT
|
|
@ -33,28 +33,17 @@ using namespace OCLRT;
|
|||
|
||||
namespace OCLRT {
|
||||
bool isGTPinInitialized = false;
|
||||
gtpin::dx11::gtpin_events_t GTPinCallbacks = {0};
|
||||
}
|
||||
|
||||
GTPIN_DI_STATUS GTPin_Init(gtpin::dx11::gtpin_events_t *pGtpinEvents, driver_services_t *pDriverServices,
|
||||
uint32_t *pDriverVersion) {
|
||||
char ver[128] = {'\0'};
|
||||
uint32_t driverVersion = 0;
|
||||
|
||||
if (isGTPinInitialized) {
|
||||
return GTPIN_DI_ERROR_INSTANCE_ALREADY_CREATED;
|
||||
}
|
||||
if (pDriverVersion != nullptr) {
|
||||
// GT-Pin is asking to obtain driver version
|
||||
auto pPlatform = platform();
|
||||
Device *pDevice = pPlatform->getDevice(0);
|
||||
pDevice->getDeviceInfo(CL_DRIVER_VERSION, sizeof(ver), &ver[0], nullptr);
|
||||
uint32_t nums[3] = {0};
|
||||
int numVerSegments = sscanf(&ver[0], "%u.%u.%u", &nums[0], &nums[1], &nums[2]);
|
||||
for (int verSeg = 0; verSeg < numVerSegments; verSeg++) {
|
||||
driverVersion <<= 8;
|
||||
driverVersion |= nums[verSeg];
|
||||
}
|
||||
*pDriverVersion = driverVersion;
|
||||
// GT-Pin is asking to obtain GT-Pin Interface version that is supported
|
||||
*pDriverVersion = gtpin::dx11::GTPIN_DX11_INTERFACE_VERSION;
|
||||
|
||||
if ((pDriverServices == nullptr) || (pGtpinEvents == nullptr)) {
|
||||
return GTPIN_DI_SUCCESS;
|
||||
|
@ -78,6 +67,7 @@ GTPIN_DI_STATUS GTPin_Init(gtpin::dx11::gtpin_events_t *pGtpinEvents, driver_ser
|
|||
pDriverServices->bufferMap = OCLRT::gtpinMapBuffer;
|
||||
pDriverServices->bufferUnMap = OCLRT::gtpinUnmapBuffer;
|
||||
|
||||
GTPinCallbacks = *pGtpinEvents;
|
||||
isGTPinInitialized = true;
|
||||
|
||||
return GTPIN_DI_SUCCESS;
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace OCLRT {
|
||||
void gtpinNotifyContextCreate(cl_context context);
|
||||
void gtpinNotifyContextDestroy(cl_context context);
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "gtpin_dx11_interface.h"
|
||||
#include "runtime/gtpin/gtpin_hw_helper.h"
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
extern GTPinHwHelper *gtpinHwHelperFactory[IGFX_MAX_CORE];
|
||||
|
||||
typedef BDWFamily Family;
|
||||
static const auto gfxFamily = IGFX_GEN8_CORE;
|
||||
|
||||
template <>
|
||||
uint32_t GTPinHwHelperHw<Family>::getGenVersion() {
|
||||
return gtpin::GTPIN_GEN_8;
|
||||
}
|
||||
|
||||
template class GTPinHwHelperHw<Family>;
|
||||
|
||||
struct GTPinEnableGen8 {
|
||||
GTPinEnableGen8() {
|
||||
gtpinHwHelperFactory[gfxFamily] = >PinHwHelperHw<Family>::get();
|
||||
}
|
||||
};
|
||||
|
||||
static GTPinEnableGen8 gtpinEnable;
|
||||
|
||||
} // namespace OCLRT
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "gtpin_dx11_interface.h"
|
||||
#include "runtime/gtpin/gtpin_hw_helper.h"
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
extern GTPinHwHelper *gtpinHwHelperFactory[IGFX_MAX_CORE];
|
||||
|
||||
typedef SKLFamily Family;
|
||||
static const auto gfxFamily = IGFX_GEN9_CORE;
|
||||
|
||||
template <>
|
||||
uint32_t GTPinHwHelperHw<Family>::getGenVersion() {
|
||||
return gtpin::GTPIN_GEN_9;
|
||||
}
|
||||
|
||||
template class GTPinHwHelperHw<Family>;
|
||||
|
||||
struct GTPinEnableGen9 {
|
||||
GTPinEnableGen9() {
|
||||
gtpinHwHelperFactory[gfxFamily] = >PinHwHelperHw<Family>::get();
|
||||
}
|
||||
};
|
||||
|
||||
static GTPinEnableGen9 gtpinEnable;
|
||||
|
||||
} // namespace OCLRT
|
|
@ -179,6 +179,15 @@ foreach(GEN_NUM RANGE 0 ${MAX_GEN} 1)
|
|||
endif(${GENX_HAS_PLATFORMS})
|
||||
endforeach(GEN_NUM)
|
||||
|
||||
if(GTPIN_HEADERS_DIR)
|
||||
foreach(GEN_NUM RANGE ${MAX_GEN} 0 -1)
|
||||
GEN_CONTAINS_PLATFORMS("SUPPORTED" ${GEN_NUM} GENX_HAS_PLATFORMS)
|
||||
if(${GENX_HAS_PLATFORMS})
|
||||
list(APPEND IGDRCL_SRCS_tests ${IGDRCL_SOURCE_DIR}/runtime/gtpin/gtpin_setup_gen${GEN_NUM}.cpp)
|
||||
endif(${GENX_HAS_PLATFORMS})
|
||||
endforeach(GEN_NUM)
|
||||
endif(GTPIN_HEADERS_DIR)
|
||||
|
||||
add_executable(igdrcl_tests
|
||||
${IGDRCL_SRCS_tests}
|
||||
$<TARGET_OBJECTS:igdrcl_libult>
|
||||
|
|
|
@ -79,4 +79,12 @@ TEST_F(clCreateContextFromTypeTests, noRet) {
|
|||
retVal = clReleaseContext(context);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST_F(clCreateContextFromTypeTests, givenInvalidContextCreationPropertiesThenContextCreationFails) {
|
||||
cl_context_properties invalidProperties[3] = {CL_CONTEXT_PLATFORM, (cl_context_properties) nullptr, 0};
|
||||
auto context = clCreateContextFromType(invalidProperties, CL_DEVICE_TYPE_GPU, nullptr, nullptr, &retVal);
|
||||
EXPECT_EQ(CL_INVALID_PLATFORM, retVal);
|
||||
EXPECT_EQ(nullptr, context);
|
||||
}
|
||||
|
||||
} // namespace ULT
|
||||
|
|
|
@ -94,4 +94,12 @@ TEST_F(clCreateContextTests, nullUserData) {
|
|||
retVal = clReleaseContext(context);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST_F(clCreateContextTests, givenInvalidContextCreationPropertiesThenContextCreationFails) {
|
||||
cl_context_properties invalidProperties[3] = {CL_CONTEXT_PLATFORM, (cl_context_properties) nullptr, 0};
|
||||
auto context = clCreateContext(invalidProperties, num_devices, devices, nullptr, nullptr, &retVal);
|
||||
EXPECT_EQ(CL_INVALID_PLATFORM, retVal);
|
||||
EXPECT_EQ(nullptr, context);
|
||||
}
|
||||
|
||||
} // namespace ULT
|
||||
|
|
|
@ -43,10 +43,15 @@ extern bool isGTPinInitialized;
|
|||
|
||||
namespace ULT {
|
||||
|
||||
int ContextCreateCallbackCount = 0;
|
||||
int ContextDestroyCallbackCount = 0;
|
||||
|
||||
void OnContextCreate(context_handle_t context, platform_info_t *platformInfo, igc_init_t **igcInit) {
|
||||
ContextCreateCallbackCount++;
|
||||
}
|
||||
|
||||
void OnContextDestroy(context_handle_t context) {
|
||||
ContextDestroyCallbackCount++;
|
||||
}
|
||||
|
||||
void OnKernelCreate(context_handle_t context, const instrument_params_in_t *paramsIn, instrument_params_out_t *paramsOut) {
|
||||
|
@ -100,6 +105,7 @@ class GTPinFixture : public ContextFixture, public MemoryManagementFixture {
|
|||
ContextFixture::TearDown();
|
||||
pPlatform->shutdown();
|
||||
MemoryManagementFixture::TearDown();
|
||||
OCLRT::isGTPinInitialized = false;
|
||||
}
|
||||
|
||||
Platform *pPlatform = nullptr;
|
||||
|
@ -159,15 +165,15 @@ TEST_F(GTPinTests, givenInvalidArgumentsWhenVersionArgumentIsProvidedThenGTPinIn
|
|||
|
||||
retFromGtPin = GTPin_Init(nullptr, nullptr, &ver);
|
||||
EXPECT_EQ(GTPIN_DI_SUCCESS, retFromGtPin);
|
||||
EXPECT_NE(0u, ver);
|
||||
EXPECT_EQ(gtpin::dx11::GTPIN_DX11_INTERFACE_VERSION, ver);
|
||||
|
||||
retFromGtPin = GTPin_Init(>pinCallbacks, nullptr, &ver);
|
||||
EXPECT_EQ(GTPIN_DI_SUCCESS, retFromGtPin);
|
||||
EXPECT_NE(0u, ver);
|
||||
EXPECT_EQ(gtpin::dx11::GTPIN_DX11_INTERFACE_VERSION, ver);
|
||||
|
||||
retFromGtPin = GTPin_Init(nullptr, &driverServices, &ver);
|
||||
EXPECT_EQ(GTPIN_DI_SUCCESS, retFromGtPin);
|
||||
EXPECT_NE(0u, ver);
|
||||
EXPECT_EQ(gtpin::dx11::GTPIN_DX11_INTERFACE_VERSION, ver);
|
||||
}
|
||||
|
||||
TEST_F(GTPinTests, givenValidAndCompleteArgumentsThenGTPinInitSucceeds) {
|
||||
|
@ -468,4 +474,78 @@ TEST_F(GTPinTests, givenValidArgumentsForBufferUnMapWhenCallSequenceIsCorrectThe
|
|||
EXPECT_EQ(GTPIN_DI_SUCCESS, retFromGtPin);
|
||||
}
|
||||
|
||||
TEST_F(GTPinTests, givenUninitializedGTPinInterfaceThenGTPinContextCallbackIsNotCalled) {
|
||||
int prevCount = ContextCreateCallbackCount;
|
||||
cl_device_id device = (cl_device_id)pDevice;
|
||||
auto context = clCreateContext(nullptr, 1, &device, nullptr, nullptr, &retVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_NE(nullptr, context);
|
||||
EXPECT_EQ(ContextCreateCallbackCount, prevCount);
|
||||
|
||||
prevCount = ContextDestroyCallbackCount;
|
||||
retVal = clReleaseContext(context);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(ContextDestroyCallbackCount, prevCount);
|
||||
}
|
||||
|
||||
TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenContextCreationArgumentsAreInvalidThenGTPinContextCallbackIsNotCalled) {
|
||||
gtpinCallbacks.onContextCreate = OnContextCreate;
|
||||
gtpinCallbacks.onContextDestroy = OnContextDestroy;
|
||||
gtpinCallbacks.onKernelCreate = OnKernelCreate;
|
||||
gtpinCallbacks.onDraw = OnDraw;
|
||||
gtpinCallbacks.onKernelSubmit = OnKernelSubmit;
|
||||
gtpinCallbacks.onCommandBufferCreate = OnCommandBufferCreate;
|
||||
gtpinCallbacks.onCommandBufferSubmit = OnCommandBufferSubmit;
|
||||
retFromGtPin = GTPin_Init(>pinCallbacks, &driverServices, nullptr);
|
||||
EXPECT_EQ(GTPIN_DI_SUCCESS, retFromGtPin);
|
||||
|
||||
int prevCount = ContextCreateCallbackCount;
|
||||
cl_device_id device = (cl_device_id)pDevice;
|
||||
cl_context_properties invalidProperties[3] = {CL_CONTEXT_PLATFORM, (cl_context_properties) nullptr, 0};
|
||||
auto contextZ = clCreateContext(invalidProperties, 1, &device, nullptr, nullptr, &retVal);
|
||||
EXPECT_EQ(CL_INVALID_PLATFORM, retVal);
|
||||
EXPECT_EQ(nullptr, contextZ);
|
||||
EXPECT_EQ(ContextCreateCallbackCount, prevCount);
|
||||
|
||||
contextZ = clCreateContextFromType(invalidProperties, CL_DEVICE_TYPE_GPU, nullptr, nullptr, &retVal);
|
||||
EXPECT_EQ(CL_INVALID_PLATFORM, retVal);
|
||||
EXPECT_EQ(nullptr, contextZ);
|
||||
EXPECT_EQ(ContextCreateCallbackCount, prevCount);
|
||||
}
|
||||
|
||||
TEST_F(GTPinTests, givenInitializedGTPinInterfaceThenGTPinContextCallbackIsCalled) {
|
||||
gtpinCallbacks.onContextCreate = OnContextCreate;
|
||||
gtpinCallbacks.onContextDestroy = OnContextDestroy;
|
||||
gtpinCallbacks.onKernelCreate = OnKernelCreate;
|
||||
gtpinCallbacks.onDraw = OnDraw;
|
||||
gtpinCallbacks.onKernelSubmit = OnKernelSubmit;
|
||||
gtpinCallbacks.onCommandBufferCreate = OnCommandBufferCreate;
|
||||
gtpinCallbacks.onCommandBufferSubmit = OnCommandBufferSubmit;
|
||||
retFromGtPin = GTPin_Init(>pinCallbacks, &driverServices, nullptr);
|
||||
EXPECT_EQ(GTPIN_DI_SUCCESS, retFromGtPin);
|
||||
|
||||
int prevCount = ContextCreateCallbackCount;
|
||||
cl_device_id device = (cl_device_id)pDevice;
|
||||
auto context = clCreateContext(nullptr, 1, &device, nullptr, nullptr, &retVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_NE(nullptr, context);
|
||||
EXPECT_EQ(ContextCreateCallbackCount, prevCount + 1);
|
||||
|
||||
prevCount = ContextDestroyCallbackCount;
|
||||
retVal = clReleaseContext(context);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(ContextDestroyCallbackCount, prevCount + 1);
|
||||
|
||||
prevCount = ContextCreateCallbackCount;
|
||||
context = clCreateContextFromType(nullptr, CL_DEVICE_TYPE_GPU, nullptr, nullptr, &retVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_NE(nullptr, context);
|
||||
EXPECT_EQ(ContextCreateCallbackCount, prevCount + 1);
|
||||
|
||||
prevCount = ContextDestroyCallbackCount;
|
||||
retVal = clReleaseContext(context);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(ContextDestroyCallbackCount, prevCount + 1);
|
||||
}
|
||||
|
||||
} // namespace ULT
|
||||
|
|
Loading…
Reference in New Issue