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

View File

@@ -0,0 +1,31 @@
# 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.
# We require cmake 3.2.0 or later
cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR)
set (RUNTIME_SRCS_ACCELERATORS
${CMAKE_CURRENT_SOURCE_DIR}/intel_accelerator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/intel_accelerator.h
${CMAKE_CURRENT_SOURCE_DIR}/intel_motion_estimation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/intel_motion_estimation.h
${CMAKE_CURRENT_SOURCE_DIR}/vebox_accelerator.h
PARENT_SCOPE
)

View File

@@ -0,0 +1,81 @@
/*
* 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 "runtime/accelerators/intel_accelerator.h"
#include "runtime/context/context.h"
#include "runtime/helpers/string.h"
#include "runtime/helpers/get_info.h"
namespace OCLRT {
cl_int IntelAccelerator::getInfo(cl_accelerator_info_intel paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet) const {
cl_int result = CL_SUCCESS;
size_t ret = 0;
switch (paramName) {
case CL_ACCELERATOR_DESCRIPTOR_INTEL: {
ret = getDescriptorSize();
result = ::getInfo(paramValue, paramValueSize, getDescriptor(), ret);
}
break;
case CL_ACCELERATOR_REFERENCE_COUNT_INTEL: {
auto v = getReference();
ret = sizeof(cl_uint);
result = ::getInfo(paramValue, paramValueSize, &v, ret);
}
break;
case CL_ACCELERATOR_CONTEXT_INTEL: {
ret = sizeof(cl_context);
cl_context ctx = static_cast<cl_context>(pContext);
result = ::getInfo(paramValue, paramValueSize, &ctx, ret);
}
break;
case CL_ACCELERATOR_TYPE_INTEL: {
auto v = getTypeId();
ret = sizeof(cl_accelerator_type_intel);
result = ::getInfo(paramValue, paramValueSize, &v, ret);
}
break;
default:
result = CL_INVALID_VALUE;
break;
}
if (paramValueSizeRet) {
*paramValueSizeRet = ret;
}
return result;
}
}

View File

@@ -0,0 +1,79 @@
/*
* 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.
*/
#pragma once
#include "runtime/api/cl_types.h"
#include "runtime/helpers/base_object.h"
//------------------------------------------------------------------------------
// cl_intel_accelerator Class Stuff
//------------------------------------------------------------------------------
namespace OCLRT {
class Context;
typedef struct TagAcceleratorObjParams {
cl_uint AcceleratorType;
cl_uint AcceleratorFlags;
} OCLRT_ACCELERATOR_OBJECT_PARAMS, *POCLRT_ACCELERATOR_OBJECT_PARAMS;
template <>
struct OpenCLObjectMapper<_cl_accelerator_intel> {
typedef class IntelAccelerator DerivedType;
};
class IntelAccelerator : public BaseObject<_cl_accelerator_intel> {
public:
IntelAccelerator(Context *context,
cl_accelerator_type_intel typeId,
size_t descriptorSize,
const void *descriptor) : pContext(context),
typeId(typeId),
descriptorSize(descriptorSize),
pDescriptor(descriptor) {}
IntelAccelerator() {}
static const cl_ulong objectMagic = 0xC6D72FA2E81EA569ULL;
cl_accelerator_type_intel getTypeId() const { return typeId; }
size_t getDescriptorSize() const { return descriptorSize; }
const void *getDescriptor() const { return pDescriptor; }
cl_int getInfo(cl_accelerator_info_intel paramName,
size_t paramValueSize,
void *paramValue,
size_t *paramValueSizeRet) const;
protected:
Context *pContext = nullptr;
const cl_accelerator_type_intel typeId = -1;
const size_t descriptorSize = 0;
const void *pDescriptor = nullptr;
private:
};
} // namespace OCLRT

View File

@@ -0,0 +1,79 @@
/*
* 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 "runtime/accelerators/intel_motion_estimation.h"
namespace OCLRT {
cl_int VmeAccelerator::validateVmeArgs(Context *context,
cl_accelerator_type_intel typeId,
size_t descriptorSize,
const void *descriptor) {
const cl_motion_estimation_desc_intel *descObj =
(const cl_motion_estimation_desc_intel *)descriptor;
DEBUG_BREAK_IF(!context);
DEBUG_BREAK_IF(typeId != CL_ACCELERATOR_TYPE_MOTION_ESTIMATION_INTEL);
if ((descriptorSize != sizeof(cl_motion_estimation_desc_intel)) ||
(descriptor == NULL)) {
return CL_INVALID_ACCELERATOR_DESCRIPTOR_INTEL;
}
switch (descObj->mb_block_type) {
case CL_ME_MB_TYPE_16x16_INTEL:
case CL_ME_MB_TYPE_8x8_INTEL:
case CL_ME_MB_TYPE_4x4_INTEL:
break;
default:
return CL_INVALID_ACCELERATOR_DESCRIPTOR_INTEL;
}
switch (descObj->subpixel_mode) {
case CL_ME_SUBPIXEL_MODE_INTEGER_INTEL:
case CL_ME_SUBPIXEL_MODE_HPEL_INTEL:
case CL_ME_SUBPIXEL_MODE_QPEL_INTEL:
break;
default:
return CL_INVALID_ACCELERATOR_DESCRIPTOR_INTEL;
}
switch (descObj->sad_adjust_mode) {
case CL_ME_SAD_ADJUST_MODE_NONE_INTEL:
case CL_ME_SAD_ADJUST_MODE_HAAR_INTEL:
break;
default:
return CL_INVALID_ACCELERATOR_DESCRIPTOR_INTEL;
}
switch (descObj->search_path_type) {
case CL_ME_SEARCH_PATH_RADIUS_2_2_INTEL:
case CL_ME_SEARCH_PATH_RADIUS_4_4_INTEL:
case CL_ME_SEARCH_PATH_RADIUS_16_12_INTEL:
break;
default:
return CL_INVALID_ACCELERATOR_DESCRIPTOR_INTEL;
}
return CL_SUCCESS;
}
}

View File

@@ -0,0 +1,72 @@
/*
* 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.
*/
#pragma once
#include "runtime/accelerators/intel_accelerator.h"
//------------------------------------------------------------------------------
// VmeAccelerator Class Stuff
//------------------------------------------------------------------------------
namespace OCLRT {
class Context;
class VmeAccelerator : public IntelAccelerator {
public:
static VmeAccelerator *create(Context *context,
cl_accelerator_type_intel typeId,
size_t descriptorSize,
const void *descriptor,
cl_int &result) {
result = validateVmeArgs(context, typeId, descriptorSize, descriptor);
VmeAccelerator *acc = nullptr;
if (result == CL_SUCCESS) {
acc = new VmeAccelerator(
context,
typeId,
descriptorSize,
descriptor);
}
return acc;
}
protected:
private:
VmeAccelerator(Context *context,
cl_accelerator_type_intel typeId,
size_t descriptorSize,
const void *descriptor) : IntelAccelerator(context,
typeId,
descriptorSize,
descriptor) {
}
static cl_int validateVmeArgs(Context *context,
cl_accelerator_type_intel typeId,
size_t descriptorSize,
const void *descriptor);
};
}

View File

@@ -0,0 +1,66 @@
/*
* 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.
*/
#pragma once
#include "runtime/accelerators/intel_accelerator.h"
//------------------------------------------------------------------------------
// VeboxAccelerator Class Stuff
//------------------------------------------------------------------------------
namespace OCLRT {
class Context;
class VeboxAccelerator : public IntelAccelerator {
public:
static VeboxAccelerator *create(Context *context,
cl_accelerator_type_intel typeId,
size_t descriptorSize,
const void *descriptor,
cl_int &result) {
DEBUG_BREAK_IF(!context);
DEBUG_BREAK_IF(!descriptor);
VeboxAccelerator *acc = new VeboxAccelerator(
context,
typeId,
descriptorSize,
descriptor);
result = CL_SUCCESS;
return acc;
}
protected:
private:
VeboxAccelerator(Context *context,
cl_accelerator_type_intel typeId,
size_t descriptorSize,
const void *descriptor) : IntelAccelerator(context,
typeId,
descriptorSize,
descriptor) {
}
};
}