Initial commit

Change-Id: I4bf1707bd3dfeadf2c17b0a7daff372b1925ebbd
This commit is contained in:
Brandon Fliflet
2017-12-21 00:45:38 +01:00
commit 7e9ad41290
1350 changed files with 233156 additions and 0 deletions

100
runtime/dll/linux/devices.m Normal file
View File

@@ -0,0 +1,100 @@
/*
* Copyright (c) 2017, 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.
*/
// clang-format off
#ifdef SUPPORT_GEN9
#ifdef SUPPORT_SKL
DEVICE( ISKL_GT1_DESK_DEVICE_F0_ID, SKL_1x2x6, GTTYPE_GT1 )
DEVICE( ISKL_GT1_DT_DEVICE_F0_ID, SKL_1x2x6, GTTYPE_GT1 )
DEVICE( ISKL_GT1_SERV_DEVICE_F0_ID, SKL_1x2x6, GTTYPE_GT1 )
DEVICE( ISKL_GT1_5_DT_DEVICE_F0_ID, SKL_1x3x6, GTTYPE_GT1_5 )
DEVICE( ISKL_GT2_DESK_DEVICE_F0_ID, SKL_1x3x8, GTTYPE_GT2 )
DEVICE( ISKL_GT2_DT_DEVICE_F0_ID, SKL_1x3x8, GTTYPE_GT2 )
DEVICE( ISKL_GT2_WRK_DEVICE_F0_ID, SKL_1x3x8, GTTYPE_GT2 )
DEVICE( ISKL_GT2_SERV_DEVICE_F0_ID, SKL_1x3x8, GTTYPE_GT2 )
DEVICE( ISKL_GT3_DESK_DEVICE_F0_ID, SKL_2x3x8, GTTYPE_GT3 )
DEVICE( ISKL_GT3_SERV_DEVICE_F0_ID, SKL_2x3x8, GTTYPE_GT3 )
DEVICE( ISKL_GT3_MEDIA_SERV_DEVICE_F0_ID, SKL_2x3x8, GTTYPE_GT3 )
DEVICE( ISKL_GT4_DESK_DEVICE_F0_ID, SKL_3x3x8, GTTYPE_GT4 )
DEVICE( ISKL_GT4_DT_DEVICE_F0_ID, SKL_3x3x8, GTTYPE_GT4 )
DEVICE( ISKL_GT4_WRK_DEVICE_F0_ID, SKL_3x3x8, GTTYPE_GT4 )
DEVICE( ISKL_GT4_SERV_DEVICE_F0_ID, SKL_3x3x8, GTTYPE_GT4 )
DEVICE( ISKL_GT2_ULT_DEVICE_F0_ID, SKL_1x3x8, GTTYPE_GT2 )
DEVICE( ISKL_GT2F_ULT_DEVICE_F0_ID, SKL_1x3x8, GTTYPE_GT2 )
DEVICE( ISKL_GT2_ULX_DEVICE_F0_ID, SKL_1x3x8, GTTYPE_GT2 )
DEVICE( ISKL_GT1_ULT_DEVICE_F0_ID, SKL_1x2x6, GTTYPE_GT1 )
DEVICE( ISKL_GT1_ULX_DEVICE_F0_ID, SKL_1x2x6, GTTYPE_GT1 )
DEVICE( ISKL_GT1_5_ULT_DEVICE_F0_ID, SKL_1x3x6, GTTYPE_GT1_5 )
DEVICE( ISKL_GT1_5_ULX_DEVICE_F0_ID, SKL_1x3x6, GTTYPE_GT1_5 )
DEVICE( ISKL_GT3_ULT_DEVICE_F0_ID, SKL_2x3x8, GTTYPE_GT3 )
DEVICE( ISKL_GT3e_ULT_DEVICE_F0_ID_540, SKL_2x3x8, GTTYPE_GT3 )
DEVICE( ISKL_GT3e_ULT_DEVICE_F0_ID_550, SKL_2x3x8, GTTYPE_GT3 )
DEVICE( ISKL_GT1_HALO_MOBL_DEVICE_F0_ID, SKL_1x2x6, GTTYPE_GT1 )
DEVICE( ISKL_GT2_HALO_MOBL_DEVICE_F0_ID, SKL_1x3x8, GTTYPE_GT2 )
DEVICE( ISKL_GT3_HALO_MOBL_DEVICE_F0_ID, SKL_2x3x8, GTTYPE_GT3 )
DEVICE( ISKL_GT4_HALO_MOBL_DEVICE_F0_ID, SKL_3x3x8, GTTYPE_GT4 )
DEVICE( ISKL_LP_DEVICE_F0_ID, SKL_1x3x8, GTTYPE_GT2 )
#endif
#ifdef SUPPORT_KBL
DEVICE( IKBL_GT1_ULT_DEVICE_F0_ID, KBL_1x2x6, GTTYPE_GT1 )
DEVICE( IKBL_GT1_5_ULT_DEVICE_F0_ID, KBL_1x3x6, GTTYPE_GT1_5 )
DEVICE( IKBL_GT2_ULT_DEVICE_F0_ID, KBL_1x3x8, GTTYPE_GT2 )
DEVICE( IKBL_GT2F_ULT_DEVICE_F0_ID, KBL_1x3x8, GTTYPE_GT2 )
DEVICE( IKBL_GT3_15W_ULT_DEVICE_F0_ID, KBL_2x3x8, GTTYPE_GT3 )
DEVICE( IKBL_GT1_ULX_DEVICE_F0_ID, KBL_1x3x6, GTTYPE_GT1 )
DEVICE( IKBL_GT1_5_ULX_DEVICE_F0_ID, KBL_1x2x6, GTTYPE_GT1_5 )
DEVICE( IKBL_GT2_ULX_DEVICE_F0_ID, KBL_1x3x8, GTTYPE_GT2 )
DEVICE( IKBL_GT1_DT_DEVICE_F0_ID, KBL_1x2x6, GTTYPE_GT1 )
DEVICE( IKBL_GT2_R_ULT_DEVICE_F0_ID, KBL_1x3x8, GTTYPE_GT2 )
DEVICE( IKBL_GT2_DT_DEVICE_F0_ID, KBL_1x3x8, GTTYPE_GT2 )
DEVICE( IKBL_GT1_HALO_DEVICE_F0_ID, KBL_1x2x6, GTTYPE_GT1 )
DEVICE( IKBL_GT1F_HALO_DEVICE_F0_ID, KBL_1x2x6, GTTYPE_GT1 )
DEVICE( IKBL_GT2_HALO_DEVICE_F0_ID, KBL_1x3x8, GTTYPE_GT2 )
DEVICE( IKBL_GT4_HALO_DEVICE_F0_ID, KBL_3x3x8, GTTYPE_GT4 )
DEVICE( IKBL_GT1_SERV_DEVICE_F0_ID, KBL_1x2x6, GTTYPE_GT1 )
DEVICE( IKBL_GT2_SERV_DEVICE_F0_ID, KBL_1x3x8, GTTYPE_GT2 )
DEVICE( IKBL_GT2_WRK_DEVICE_F0_ID, KBL_1x3x8, GTTYPE_GT2 )
DEVICE( IKBL_GT3_ULT_DEVICE_F0_ID, KBL_2x3x8, GTTYPE_GT3 )
DEVICE( IKBL_GT3_28W_ULT_DEVICE_F0_ID, KBL_2x3x8, GTTYPE_GT3 )
DEVICE( IKBL_GT4_DT_DEVICE_F0_ID, KBL_3x3x8, GTTYPE_GT4 )
DEVICE( IKBL_GT3_HALO_DEVICE_F0_ID, KBL_2x3x8, GTTYPE_GT3 )
DEVICE( IKBL_GT3_SERV_DEVICE_F0_ID, KBL_2x3x8, GTTYPE_GT3 )
DEVICE( IKBL_GT4_SERV_DEVICE_F0_ID, KBL_3x3x8, GTTYPE_GT4 )
DEVICE( IKBL_GT4_WRK_DEVICE_F0_ID, KBL_3x3x8, GTTYPE_GT4 )
#endif
#ifdef SUPPORT_BXT
DEVICE(IBXT_P_3x6_DEVICE_ID, BXT_1x3x6, GTTYPE_GTA) //18EU APL
DEVICE(IBXT_P_12EU_3x6_DEVICE_ID, BXT_1x2x6, GTTYPE_GTA) //12EU APL
#endif
#endif
#ifdef SUPPORT_GEN8
DEVICE( IBDW_GT1_HALO_MOBL_DEVICE_F0_ID, BDW_1x2x6, GTTYPE_GT1 )
DEVICE( IBDW_GT1_ULT_MOBL_DEVICE_F0_ID, BDW_1x2x6, GTTYPE_GT1 )
DEVICE( IBDW_GT2_HALO_MOBL_DEVICE_F0_ID, BDW_1x3x8, GTTYPE_GT2 )
DEVICE( IBDW_GT2_ULT_MOBL_DEVICE_F0_ID, BDW_1x3x8, GTTYPE_GT2 )
DEVICE( IBDW_GT2_ULX_DEVICE_F0_ID, BDW_1x3x8, GTTYPE_GT2 )
DEVICE( IBDW_GT3_HALO_MOBL_DEVICE_F0_ID, BDW_2x3x8, GTTYPE_GT3 )
DEVICE( IBDW_GT3_ULT_MOBL_DEVICE_F0_ID, BDW_2x3x8, GTTYPE_GT3 )
DEVICE( IBDW_GT3_SERV_DEVICE_F0_ID, BDW_2x3x8, GTTYPE_GT3 )
DEVICE( IBDW_GT3_ULT25W_MOBL_DEVICE_F0_ID, BDW_2x3x8, GTTYPE_GT3 )
#endif
// clang-format on

View File

@@ -0,0 +1,222 @@
/*
* Copyright (c) 2017, 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 "hw_cmds.h"
#include "runtime/helpers/hw_info.h"
#include "runtime/helpers/options.h"
#include "runtime/os_interface/linux/drm_neo.h"
#include "runtime/os_interface/linux/drm_null_device.h"
#include "drm/i915_drm.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include <stdio.h>
#include <limits.h>
#include <array>
namespace OCLRT {
static struct DeviceDescriptor {
unsigned short deviceId;
const HardwareInfo *pHwInfo;
void (*setupGtSystemInfo)(GT_SYSTEM_INFO *);
GTTYPE eGtType;
} const DeviceDescriptorTable[] = {
#define DEVICE(devId, gt, gtType) {devId, &gt::hwInfo, &gt::setupGtSystemInfo, gtType},
#include "devices.m"
#undef DEVICE
{0, nullptr, nullptr, GTTYPE_UNDEFINED}};
static std::array<Drm *, 1> drms = {{nullptr}};
Drm::~Drm() {
if (lowPriorityContextId)
contextDestroy();
close(fd);
fd = -1;
}
Drm *Drm::get(int32_t deviceOrdinal) {
if (static_cast<uint32_t>(deviceOrdinal) >= drms.size())
return nullptr;
return drms[deviceOrdinal % drms.size()];
}
void Drm::closeDevice(int32_t deviceOrdinal) {
if (static_cast<uint32_t>(deviceOrdinal) >= drms.size())
return;
if (drms[deviceOrdinal % drms.size()] != nullptr) {
delete drms[deviceOrdinal % drms.size()];
drms[deviceOrdinal % drms.size()] = nullptr;
}
}
bool Drm::isi915Version(int fd) {
drm_version_t version = {};
int ret;
version.name = reinterpret_cast<char *>(calloc(1, 5));
version.name_len = 5;
ret = ::ioctl(fd, DRM_IOCTL_VERSION, &version);
if (ret) {
free(version.name);
return false;
}
version.name[4] = '\0';
if (!strcmp(version.name, "i915")) {
free(version.name);
return true;
}
free(version.name);
return false;
}
int Drm::getDeviceFd(const int devType) {
int fd = -1;
char fullPath[PATH_MAX];
const char *pathPrefix;
unsigned int startNum;
const unsigned int maxDrmDevices = 64;
switch (devType) {
case 0:
startNum = 128;
pathPrefix = "/dev/dri/renderD";
break;
default:
startNum = 0;
pathPrefix = "/dev/dri/card";
break;
}
for (unsigned int i = 0; i < maxDrmDevices; i++) {
snprintf(fullPath, PATH_MAX, "%s%d", pathPrefix, i + startNum);
if ((fd = ::open(fullPath, O_RDWR)) >= 0) {
if (isi915Version(fd)) {
break;
}
::close(fd);
fd = -1;
}
}
return fd;
}
int Drm::openDevice() {
int fd = -1;
fd = getDeviceFd(0);
if (fd < 0) {
fd = getDeviceFd(1);
}
return fd;
}
Drm *Drm::create(int32_t deviceOrdinal) {
//right now we support only one device
if (deviceOrdinal != 0)
return nullptr;
if (drms[deviceOrdinal % drms.size()] != nullptr)
return drms[deviceOrdinal % drms.size()];
auto fd = openDevice();
if (fd == -1) {
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot open device!\n");
return nullptr;
}
Drm *drmObject = nullptr;
if (DebugManager.flags.EnableNullHardware.get() == true) {
drmObject = new DrmNullDevice(fd);
} else {
drmObject = new Drm(fd);
}
// Get HW version (I915_drm.h)
int ret = drmObject->getDeviceID(drmObject->deviceId);
if (ret != 0) {
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query device ID parameter!\n");
delete drmObject;
return nullptr;
}
// Get HW Revision (I915_drm.h)
ret = drmObject->getDeviceRevID(drmObject->revisionId);
if (ret != 0) {
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query device Rev ID parameter!\n");
delete drmObject;
return nullptr;
}
const DeviceDescriptor *device = nullptr;
GTTYPE eGtType = GTTYPE_UNDEFINED;
for (auto &d : DeviceDescriptorTable) {
if (drmObject->deviceId == d.deviceId) {
device = &d;
eGtType = d.eGtType;
break;
}
}
if (device) {
platformDevices[0] = device->pHwInfo;
device->setupGtSystemInfo(const_cast<GT_SYSTEM_INFO *>(platformDevices[0]->pSysInfo));
drmObject->setGtType(eGtType);
} else {
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Unknown device: deviceId: %04x, revisionId: %04x\n",
drmObject->deviceId, drmObject->revisionId);
delete drmObject;
return nullptr;
}
// Detect device parameters
int hasExecSoftPin = 0;
ret = drmObject->getExecSoftPin(hasExecSoftPin);
if (ret != 0) {
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query Soft Pin parameter!\n");
delete drmObject;
return nullptr;
}
if (!hasExecSoftPin) {
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Device doesn't support Soft-Pin but this is required.\n");
delete drmObject;
return nullptr;
}
// Activate the Turbo Boost Frequency feature
ret = drmObject->enableTurboBoost();
if (ret != 0) {
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to request OCL Turbo Boost\n");
}
drms[deviceOrdinal % drms.size()] = drmObject;
return drms[deviceOrdinal % drms.size()];
}
} // namespace OCLRT

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2017, 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.
*/
{
global:
clGetExtensionFunctionAddress;
clIcdGetPlatformIDsKHR;
GTPin_Init;
local: *;
};