mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
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:
32
runtime/gtpin/gtpin_callback_stubs.cpp
Normal file
32
runtime/gtpin/gtpin_callback_stubs.cpp
Normal file
@ -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) {
|
||||
}
|
||||
}
|
58
runtime/gtpin/gtpin_callbacks.cpp
Normal file
58
runtime/gtpin/gtpin_callbacks.cpp
Normal file
@ -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)) {
|
||||
|
31
runtime/gtpin/gtpin_hw_helper.cpp
Normal file
31
runtime/gtpin/gtpin_hw_helper.cpp
Normal file
@ -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
|
48
runtime/gtpin/gtpin_hw_helper.h
Normal file
48
runtime/gtpin/gtpin_hw_helper.h
Normal file
@ -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;
|
||||
|
28
runtime/gtpin/gtpin_notify.h
Normal file
28
runtime/gtpin/gtpin_notify.h
Normal file
@ -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);
|
||||
}
|
48
runtime/gtpin/gtpin_setup_gen8.cpp
Normal file
48
runtime/gtpin/gtpin_setup_gen8.cpp
Normal file
@ -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
|
48
runtime/gtpin/gtpin_setup_gen9.cpp
Normal file
48
runtime/gtpin/gtpin_setup_gen9.cpp
Normal file
@ -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
|
Reference in New Issue
Block a user