Compile kernels per platform type (core/lp)

compiled kernels are in (binary dir)/(family name with type) folder

Change-Id: Ied1827ab7f4ecc5c1de4c3535b1c0ba3b5cd86ee
This commit is contained in:
Mateusz Jablonski
2018-04-17 18:11:50 +02:00
committed by sys_ocldev
parent 34ff5852eb
commit abbc0a5471
26 changed files with 297 additions and 220 deletions

View File

@ -200,11 +200,11 @@ std::unique_ptr<Program> BuiltinsLib::createProgramFromCode(const BuiltinCode &b
BuiltinResourceT BuiltinsLib::getBuiltinResource(EBuiltInOps builtin, BuiltinCode::ECodeType requestedCodeType, Device &device) {
BuiltinResourceT bc;
std::string resourceNameGeneric = createBuiltinResourceName(builtin, BuiltinCode::getExtension(requestedCodeType));
std::string resourceNameForPlatform = createBuiltinResourceName(builtin, BuiltinCode::getExtension(requestedCodeType), device.getProductAbbrev());
std::string resourceNameForPlatformAndStepping = createBuiltinResourceName(builtin, BuiltinCode::getExtension(requestedCodeType), device.getProductAbbrev(),
device.getHardwareInfo().pPlatform->usRevId);
std::string resourceNameForPlatformType = createBuiltinResourceName(builtin, BuiltinCode::getExtension(requestedCodeType), device.getFamilyNameWithType());
std::string resourceNameForPlatformTypeAndStepping = createBuiltinResourceName(builtin, BuiltinCode::getExtension(requestedCodeType), device.getFamilyNameWithType(),
device.getHardwareInfo().pPlatform->usRevId);
for (auto &rn : {resourceNameForPlatformAndStepping, resourceNameForPlatform, resourceNameGeneric}) { // first look for dedicated version, only fallback to generic one
for (auto &rn : {resourceNameForPlatformTypeAndStepping, resourceNameForPlatformType, resourceNameGeneric}) { // first look for dedicated version, only fallback to generic one
for (auto &s : allStorages) {
bc = s.get()->load(rn);
if (bc.size() != 0) {

View File

@ -42,14 +42,13 @@ if(COMPILE_BUILT_INS)
add_subdirectory(kernels)
endif()
macro(macro_for_each_platform)
foreach(GENERATED_BUILTIN ${GENERATED_BUILTINS})
list(APPEND GENERATED_BUILTINS_CPPS ${BUILTINS_INCLUDE_DIR}/${RUNTIME_GENERATED_${GENERATED_BUILTIN}_${GEN_TYPE_LOWER}_${PLATFORM_IT}})
endforeach()
endmacro()
macro(macro_for_each_gen)
apply_macro_for_each_platform()
foreach(PLATFORM_TYPE "CORE" "LP")
get_family_name_with_type(${GEN_TYPE} ${PLATFORM_TYPE})
foreach(GENERATED_BUILTIN ${GENERATED_BUILTINS})
list(APPEND GENERATED_BUILTINS_CPPS ${BUILTINS_INCLUDE_DIR}/${RUNTIME_GENERATED_${GENERATED_BUILTIN}_${family_name_with_type}})
endforeach()
endforeach()
source_group("generated files\\${GEN_TYPE_LOWER}" FILES ${GENERATED_BUILTINS_CPPS})
endmacro()

View File

@ -39,16 +39,17 @@ set(BUILTINS_INCLUDE_DIR ${TargetDir} PARENT_SCOPE)
set(BUILTIN_CPP "")
# Define function for compiling built-ins (with cloc)
function(compile_builtin gen_name builtin)
set(OUTPUTDIR "${BUILTINS_OUTDIR_WITH_ARCH}/${gen_name}")
function(compile_builtin gen_type platform_type builtin)
string(TOLOWER ${gen_type} gen_type_lower)
get_family_name_with_type(${gen_type} ${platform_type})
set(OUTPUTDIR "${BUILTINS_OUTDIR_WITH_ARCH}/${gen_type_lower}")
# get filename
get_filename_component(FILENAME ${builtin} NAME)
# get name of the file w/o extension
get_filename_component(BASENAME ${builtin} NAME_WE)
set(OUTPUTPATH_BASE "${OUTPUTDIR}/${BASENAME}_${gen_name}")
set(OUTPUTPATH_BASE "${OUTPUTDIR}/${BASENAME}_${family_name_with_type}")
set(OUTPUT_FILES
${OUTPUTPATH_BASE}.bc
${OUTPUTPATH_BASE}.bin
@ -59,48 +60,38 @@ function(compile_builtin gen_name builtin)
# function returns builtin cpp filename
unset(BUILTIN_CPP)
# set variable outside function
set(BUILTIN_CPP built_ins/${NEO_ARCH}/${gen_name}/${BASENAME}_${gen_name}.cpp PARENT_SCOPE)
if(MSVC)
add_custom_command(
OUTPUT ${OUTPUT_FILES}
COMMAND cloc -q -file ${FILENAME} -device ${gen_name} ${BUILTIN_OPTIONS} -${NEO_BITS} -out_dir ${OUTPUTDIR} -cpp_file -options "-cl-kernel-arg-info ${BUILTIN_DEBUG_OPTION}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${builtin} cloc copy_compiler_files
)
set(BUILTIN_CPP built_ins/${NEO_ARCH}/${gen_type_lower}/${BASENAME}_${family_name_with_type}.cpp PARENT_SCOPE)
if(WIN32)
set(cloc_cmd_prefix cloc)
else()
add_custom_command(
OUTPUT ${OUTPUT_FILES}
COMMAND LD_LIBRARY_PATH=$<TARGET_FILE_DIR:cloc> $<TARGET_FILE:cloc> -q -file ${FILENAME} -device ${gen_name} ${BUILTIN_OPTIONS} -${NEO_BITS} -out_dir ${OUTPUTDIR} -cpp_file -options "-cl-kernel-arg-info ${BUILTIN_DEBUG_OPTION}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${builtin} cloc copy_compiler_files
)
set(cloc_cmd_prefix LD_LIBRARY_PATH=$<TARGET_FILE_DIR:cloc> $<TARGET_FILE:cloc>)
endif()
add_custom_command(
OUTPUT ${OUTPUT_FILES}
COMMAND ${cloc_cmd_prefix} -q -file ${FILENAME} -device ${DEFAULT_SUPPORTED_${gen_type}_${platform_type}_PLATFORM} ${BUILTIN_OPTIONS} -${NEO_BITS} -out_dir ${OUTPUTDIR} -cpp_file -options "-cl-kernel-arg-info ${BUILTIN_DEBUG_OPTION}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${builtin} cloc copy_compiler_files
)
endfunction()
macro(compile_builtins GEN_TYPE PLATFORM_IT)
string(TOLOWER ${PLATFORM_IT} PLATFORM_LOWER)
string(CONCAT GEN "_" ${GEN_TYPE} "_" ${PLATFORM_IT})
set (BUILTINS_COMMANDS)
foreach(GENERATED_BUILTIN ${GENERATED_BUILTINS})
compile_builtin(${PLATFORM_LOWER} ${GENERATED_BUILTIN}.igdrcl_built_in)
list(APPEND BUILTINS_COMMANDS ${TargetDir}/${BUILTIN_CPP})
set (RUNTIME_GENERATED_${GENERATED_BUILTIN}${GEN} ${BUILTIN_CPP} PARENT_SCOPE)
endforeach()
set(target_name builtins_${PLATFORM_LOWER})
add_custom_target(${target_name} DEPENDS ${BUILTINS_COMMANDS})
add_dependencies(builtins ${target_name})
set_target_properties(${target_name} PROPERTIES FOLDER "built_ins/${PLATFORM_LOWER}")
endmacro()
macro(macro_for_each_platform)
compile_builtins(${GEN_TYPE_LOWER} ${PLATFORM_IT})
endmacro()
macro(macro_for_each_gen)
apply_macro_for_each_platform()
foreach(PLATFORM_TYPE "CORE" "LP")
if(${GEN_TYPE}_HAS_${PLATFORM_TYPE})
get_family_name_with_type(${GEN_TYPE} ${PLATFORM_TYPE})
string(TOLOWER ${PLATFORM_TYPE} PLATFORM_TYPE_LOWER)
unset(BUILTINS_COMMANDS)
foreach(GENERATED_BUILTIN ${GENERATED_BUILTINS})
compile_builtin(${GEN_TYPE} ${PLATFORM_TYPE} ${GENERATED_BUILTIN}.igdrcl_built_in)
list(APPEND BUILTINS_COMMANDS ${TargetDir}/${BUILTIN_CPP})
set(RUNTIME_GENERATED_${GENERATED_BUILTIN}_${family_name_with_type} ${BUILTIN_CPP} PARENT_SCOPE)
endforeach()
set(target_name builtins_${family_name_with_type})
add_custom_target(${target_name} DEPENDS ${BUILTINS_COMMANDS})
add_dependencies(builtins ${target_name})
set_target_properties(${target_name} PROPERTIES FOLDER "built_ins/${family_name_with_type}")
endif()
endforeach()
endmacro()
apply_macro_for_each_gen("SUPPORTED")

View File

@ -213,6 +213,12 @@ const char *Device::getProductAbbrev() const {
return hardwarePrefix[hwInfo.pPlatform->eProductFamily];
}
const std::string Device::getFamilyNameWithType() const {
std::string platformName = familyName[hwInfo.pPlatform->eRenderCoreFamily];
platformName.append(getPlatformType(hwInfo));
return platformName;
}
double Device::getProfilingTimerResolution() {
return osTime->getDynamicDeviceTimerResolution(hwInfo);
}

View File

@ -97,6 +97,7 @@ class Device : public BaseObject<_cl_device_id> {
volatile uint32_t *getTagAddress() const;
const char *getProductAbbrev() const;
const std::string getFamilyNameWithType() const;
// This helper template is meant to simplify getDeviceInfo
template <cl_device_info Param>

View File

@ -73,7 +73,8 @@ const RuntimeCapabilityTable BDW::capabilityTable{
{true, 50000, true, 5000, true, 200000}, // KmdNotifyProperties
false, // ftr64KBpages
EngineType::ENGINE_RCS, // defaultEngineType
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
MemoryConstants::pageSize, //requiredPreemptionSurfaceSize
true // isBigCore
};
const HardwareInfo BDW_1x2x6::hwInfo = {

View File

@ -69,7 +69,8 @@ const RuntimeCapabilityTable BXT::capabilityTable{
{false, 0, false, 0, false, 0}, // KmdNotifyProperties
false, // ftr64KBpages
EngineType::ENGINE_RCS, // defaultEngineType
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
MemoryConstants::pageSize, //requiredPreemptionSurfaceSize
false // isBigCore
};
const HardwareInfo BXT_1x2x6::hwInfo = {

View File

@ -64,7 +64,8 @@ const RuntimeCapabilityTable CFL::capabilityTable{
{false, 0, false, 0, false, 0}, // KmdNotifyProperties
true, // ftr64KBpages
EngineType::ENGINE_RCS, // defaultEngineType
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
MemoryConstants::pageSize, //requiredPreemptionSurfaceSize
true // isBigCore
};
const HardwareInfo CFL_1x2x6::hwInfo = {

View File

@ -64,7 +64,8 @@ const RuntimeCapabilityTable GLK::capabilityTable{
{true, 30000, false, 0, false, 0}, // KmdNotifyProperties
false, // ftr64KBpages
EngineType::ENGINE_RCS, // defaultEngineType
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
MemoryConstants::pageSize, //requiredPreemptionSurfaceSize
false // isBigCore
};
const HardwareInfo GLK_1x3x6::hwInfo = {

View File

@ -64,7 +64,8 @@ const RuntimeCapabilityTable KBL::capabilityTable{
{false, 0, false, 0, false, 0}, // KmdNotifyProperties
true, // ftr64KBpages
EngineType::ENGINE_RCS, // defaultEngineType
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
MemoryConstants::pageSize, //requiredPreemptionSurfaceSize
true // isBigCore
};
const HardwareInfo KBL_1x2x6::hwInfo = {

View File

@ -72,7 +72,8 @@ const RuntimeCapabilityTable SKL::capabilityTable{
{false, 0, false, 0, false, 0}, // KmdNotifyProperties
true, // ftr64KBpages
EngineType::ENGINE_RCS, // defaultEngineType
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
MemoryConstants::pageSize, //requiredPreemptionSurfaceSize
true // isBigCore
};
const HardwareInfo SKL_1x2x6::hwInfo = {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Intel Corporation
* Copyright (c) 2017 - 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"),
@ -53,4 +53,11 @@ const HardwareInfo unknownHardware = {
&emptyWaTable,
&unknownSysInfo,
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, PreemptionMode::Disabled, {false, false}, nullptr}};
const char *getPlatformType(const HardwareInfo &hwInfo) {
if (hwInfo.capabilityTable.isBigCore) {
return "core";
}
return "lp";
}
} // namespace OCLRT

View File

@ -72,6 +72,7 @@ struct RuntimeCapabilityTable {
EngineType defaultEngineType;
size_t requiredPreemptionSurfaceSize;
bool isBigCore;
};
struct HardwareCapabilities {
@ -113,4 +114,6 @@ struct EnableGfxFamilyHw {
}
};
const char *getPlatformType(const HardwareInfo &hwInfo);
} // namespace OCLRT

View File

@ -19,63 +19,61 @@
# OTHER DEALINGS IN THE SOFTWARE.
add_custom_target(scheduler)
set (SCHEDULER_OUTDIR_WITH_ARCH "${TargetDir}/scheduler/${NEO_ARCH}")
set(SCHEDULER_OUTDIR_WITH_ARCH "${TargetDir}/scheduler/${NEO_ARCH}")
set_target_properties(scheduler PROPERTIES FOLDER "scheduler")
set (SCHEDULER_KERNEL scheduler.cl)
set (SCHEDULER_INCLUDE_OPTIONS "-I$<JOIN:${IGDRCL__IGC_INCLUDE_DIR}, -I>")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" )
set(SCHEDULER_DEBUG_OPTION "-D DEBUG")
set(SCHEDULER_DEBUG_OPTION "-D DEBUG")
else()
set(SCHEDULER_DEBUG_OPTION "")
set(SCHEDULER_DEBUG_OPTION "")
endif()
set(SCHEDULER_INCLUDE_DIR ${TargetDir})
function(compile_kernel target gen_name gen_type kernel)
set(OUTPUTDIR "${SCHEDULER_OUTDIR_WITH_ARCH}/${gen_name}")
set(SCHEDULER_INCLUDE_OPTIONS "${SCHEDULER_INCLUDE_OPTIONS} -I ../${gen_type}")
function(compile_kernel target gen_type platform_type kernel)
get_family_name_with_type(${gen_type} ${platform_type})
string(TOLOWER ${gen_type} gen_type_lower)
# get filename
set(OUTPUTDIR "${SCHEDULER_OUTDIR_WITH_ARCH}/${gen_type_lower}")
set(SCHEDULER_INCLUDE_OPTIONS "${SCHEDULER_INCLUDE_OPTIONS} -I ../${gen_type_lower}")
get_filename_component(BASENAME ${kernel} NAME_WE)
set(OUTPUTPATH "${OUTPUTDIR}/${BASENAME}_${gen_name}.bin")
set(OUTPUTPATH "${OUTPUTDIR}/${BASENAME}_${family_name_with_type}.bin")
set(SCHEDULER_CPP "${OUTPUTDIR}/${BASENAME}_${gen_name}.cpp")
if(MSVC)
add_custom_command(
OUTPUT ${OUTPUTPATH}
COMMAND cloc -q -file ${kernel} -device ${gen_name} -cl-intel-greater-than-4GB-buffer-required -${NEO_BITS} -out_dir ${OUTPUTDIR} -cpp_file -options "-cl-kernel-arg-info ${SCHEDULER_INCLUDE_OPTIONS} ${SCHEDULER_DEBUG_OPTION} -cl-std=CL2.0"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${kernel} cloc copy_compiler_files
)
set(SCHEDULER_CPP "${OUTPUTDIR}/${BASENAME}_${family_name_with_type}.cpp")
if(WIN32)
set(cloc_cmd_prefix cloc)
else()
add_custom_command(
OUTPUT ${OUTPUTPATH} ${SCHEDULER_CPP}
COMMAND LD_LIBRARY_PATH=$<TARGET_FILE_DIR:cloc> $<TARGET_FILE:cloc> -q -file ${kernel} -device ${gen_name} -cl-intel-greater-than-4GB-buffer-required -${NEO_BITS} -out_dir ${OUTPUTDIR} -cpp_file -options "-cl-kernel-arg-info ${SCHEDULER_INCLUDE_OPTIONS} ${SCHEDULER_DEBUG_OPTION} -cl-std=CL2.0"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${kernel} cloc copy_compiler_files
)
set(cloc_cmd_prefix LD_LIBRARY_PATH=$<TARGET_FILE_DIR:cloc> $<TARGET_FILE:cloc>)
endif()
add_custom_command(
OUTPUT ${OUTPUTPATH} ${SCHEDULER_CPP}
COMMAND ${cloc_cmd_prefix} -q -file ${kernel} -device ${DEFAULT_SUPPORTED_${gen_type}_${platform_type}_PLATFORM} -cl-intel-greater-than-4GB-buffer-required -${NEO_BITS} -out_dir ${OUTPUTDIR} -cpp_file -options "-cl-kernel-arg-info ${SCHEDULER_INCLUDE_OPTIONS} ${SCHEDULER_DEBUG_OPTION} -cl-std=CL2.0"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${kernel} cloc copy_compiler_files
)
set(SCHEDULER_CPP ${SCHEDULER_CPP} PARENT_SCOPE)
add_custom_target(${target} DEPENDS ${OUTPUTPATH})
set_target_properties(${target} PROPERTIES FOLDER "scheduler/${gen_name}")
set_target_properties(${target} PROPERTIES FOLDER "scheduler/${gen_type_lower}")
endfunction()
macro(macro_for_each_platform)
PLATFORM_HAS_2_0(${GEN_TYPE} ${PLATFORM_IT} PLATFORM_SUPPORTS_2_0)
if(COMPILE_BUILT_INS AND ${PLATFORM_SUPPORTS_2_0})
string(TOLOWER ${PLATFORM_IT} PLATFORM_IT_LOWER)
compile_kernel(scheduler_${PLATFORM_IT_LOWER} ${PLATFORM_IT_LOWER} ${GEN_TYPE_LOWER} ${SCHEDULER_KERNEL})
add_dependencies(scheduler scheduler_${PLATFORM_IT_LOWER})
list(APPEND GENERATED_SCHEDULER_CPPS ${SCHEDULER_CPP})
endif()
endmacro()
macro(macro_for_each_gen)
apply_macro_for_each_platform()
foreach(PLATFORM_TYPE "CORE" "LP")
if(${GEN_TYPE}_HAS_${PLATFORM_TYPE})
get_family_name_with_type(${GEN_TYPE} ${PLATFORM_TYPE})
set(PLATFORM_2_0_LOWER ${DEFAULT_SUPPORTED_2_0_${GEN_TYPE}_${PLATFORM_TYPE}_PLATFORM})
if(COMPILE_BUILT_INS AND PLATFORM_2_0_LOWER)
compile_kernel(scheduler_${family_name_with_type} ${GEN_TYPE} ${PLATFORM_TYPE} ${SCHEDULER_KERNEL})
add_dependencies(scheduler scheduler_${family_name_with_type})
list(APPEND GENERATED_SCHEDULER_CPPS ${SCHEDULER_CPP})
endif()
endif()
endforeach()
source_group("generated files\\${GEN_TYPE_LOWER}" FILES ${GENERATED_SCHEDULER_CPPS})
endmacro()