Initial support for oneAPI Level Zero
Change-Id: I221df8427b1844237a4d9d900c58512706b0be0f
This commit is contained in:
parent
612f47ced3
commit
27f4bce42f
|
@ -56,6 +56,8 @@ IncludeCategories:
|
|||
Priority: 2
|
||||
- Regex: '^"test\.h"$'
|
||||
Priority: 2
|
||||
- Regex: '^.(level_zero)/'
|
||||
Priority: 3
|
||||
- Regex: '(d3d9types|d3d10_1)\.h'
|
||||
Priority: 4
|
||||
- Regex: '(gfxEscape|windows)\.h'
|
||||
|
|
|
@ -0,0 +1,534 @@
|
|||
#
|
||||
# Copyright (C) 2019-2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
option(BUILD_WITH_L0 "Build level zero by default" ON)
|
||||
if(BUILD_WITH_L0 AND "${NEO_BITS}" STREQUAL "64")
|
||||
|
||||
set(TARGET_NAME_L0 ze_intel_gpu)
|
||||
|
||||
# Level Zero third party detection
|
||||
if(DEFINED LEVEL_ZERO_ROOT)
|
||||
get_filename_component(LEVEL_ZERO_ROOT "${LEVEL_ZERO_ROOT}" ABSOLUTE)
|
||||
else()
|
||||
get_filename_component(LEVEL_ZERO_ROOT_tmp "${NEO_SOURCE_DIR}/../level_zero" ABSOLUTE)
|
||||
# Level Zero Headers if read from the git repo are in include/core & include/tools.
|
||||
# To support the installation path of level_zero headers which is include/level_zero/*
|
||||
# the header files are combined into the path include/level_zero/* in the commands below.
|
||||
if(IS_DIRECTORY "${LEVEL_ZERO_ROOT_tmp}")
|
||||
set(CUSTOM_L0_INCLUDE_PATH "${LEVEL_ZERO_ROOT_tmp}/include/level_zero/")
|
||||
file(GLOB LEVEL_ZERO_SOURCE_HEADERS
|
||||
"${LEVEL_ZERO_ROOT_tmp}/include/core/*"
|
||||
"${LEVEL_ZERO_ROOT_tmp}/include/tools/*"
|
||||
)
|
||||
file(MAKE_DIRECTORY ${CUSTOM_L0_INCLUDE_PATH})
|
||||
file(COPY ${LEVEL_ZERO_SOURCE_HEADERS} DESTINATION ${CUSTOM_L0_INCLUDE_PATH})
|
||||
set(LEVEL_ZERO_ROOT "${LEVEL_ZERO_ROOT_tmp}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
project(intel-level-zero-gpu VERSION 0.4.1)
|
||||
include(cmake/source_tree.cmake)
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${BRANCH_TYPE}/platforms.cmake AND NOT SKIP_L0_UNIT_TESTS)
|
||||
include(cmake/${BRANCH_TYPE}/platforms.cmake)
|
||||
endif()
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
find_package(LevelZero)
|
||||
if(NOT LevelZero_FOUND)
|
||||
message(STATUS "Level zero headers not found")
|
||||
return()
|
||||
endif()
|
||||
|
||||
execute_process (
|
||||
COMMAND git rev-parse --short=4 origin/integration
|
||||
OUTPUT_VARIABLE L0_GIT_HEAD_COMMIT_SHA
|
||||
)
|
||||
|
||||
string(STRIP "${L0_GIT_HEAD_COMMIT_SHA}" L0_GIT_HEAD_COMMIT_SHA)
|
||||
|
||||
add_definitions( -DL0_PROJECT_VERSION_MAJOR="${PROJECT_VERSION_MAJOR}" )
|
||||
add_definitions( -DL0_PROJECT_VERSION_MINOR="${PROJECT_VERSION_MINOR}" )
|
||||
|
||||
add_definitions( -DZE_ENABLE_OCL_INTEROP=1)
|
||||
|
||||
# Generate VERSION and VERSION_SUFFIX (if building in tree) files to
|
||||
# facilitate artifact publishing.
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/VERSION" "${PROJECT_VERSION}")
|
||||
find_program(GIT_EXE NAMES "git")
|
||||
if(GIT_EXE AND EXISTS "${NEO_SOURCE_DIR}/.git")
|
||||
if(MSVC)
|
||||
execute_process(
|
||||
COMMAND CMD /c git rev-list --count HEAD
|
||||
OUTPUT_VARIABLE VERSION_SUFFIX
|
||||
)
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND git rev-list --count HEAD
|
||||
OUTPUT_VARIABLE VERSION_SUFFIX
|
||||
)
|
||||
endif()
|
||||
# ensure no trailing newlines are written to the file
|
||||
string(STRIP "${VERSION_SUFFIX}" VERSION_SUFFIX)
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/VERSION_SUFFIX" "${VERSION_SUFFIX}")
|
||||
endif()
|
||||
|
||||
#Define a path for custom commands to work around MSVC
|
||||
set(CUSTOM_COMMAND_BINARY_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
if(MSVC)
|
||||
#MSVC implicitly adds $<CONFIG> to the output path
|
||||
if(NOT "${CMAKE_GENERATOR}" STREQUAL "Ninja")
|
||||
set(CUSTOM_COMMAND_BINARY_DIR ${CUSTOM_COMMAND_BINARY_DIR}/$<CONFIG>)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
# Load GNUInstallDirs to determine install targets for Linux packages
|
||||
include(GNUInstallDirs)
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -fPIC")
|
||||
endif()
|
||||
|
||||
set(L0_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
if(NOT DEFINED COMPUTE_RUNTIME_DIR)
|
||||
get_filename_component(COMPUTE_RUNTIME_DIR ${CMAKE_CURRENT_SOURCE_DIR}/.. ABSOLUTE)
|
||||
endif()
|
||||
# Option to disable tests
|
||||
option(${PROJECT_NAME}_BUILD_TESTS "Build unit tests." ON)
|
||||
|
||||
if(SKIP_UNIT_TESTS)
|
||||
set(SKIP_L0_UNIT_TESTS TRUE)
|
||||
endif()
|
||||
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${BRANCH_TYPE}/l0_tests.cmake)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${BRANCH_TYPE}/l0_tests.cmake)
|
||||
endif()
|
||||
|
||||
# Copy third_party_binaries to output BIN folder
|
||||
add_custom_target(copy_third_party_files)
|
||||
set_target_properties(copy_third_party_files PROPERTIES FOLDER ${TARGET_NAME_L0})
|
||||
|
||||
if(DEFINED NEO__IGC_TARGETS)
|
||||
if(WIN32)
|
||||
add_dependencies(copy_third_party_files copy_compiler_files)
|
||||
else()
|
||||
add_dependencies(copy_third_party_files ${NEO__IGC_TARGETS})
|
||||
foreach(TARGET_tmp ${NEO__IGC_TARGETS})
|
||||
if(UNIX)
|
||||
add_custom_command(
|
||||
TARGET copy_third_party_files
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CUSTOM_COMMAND_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_SONAME_FILE:${TARGET_tmp}> "${CUSTOM_COMMAND_BINARY_DIR}/"
|
||||
)
|
||||
endif()
|
||||
add_custom_command(
|
||||
TARGET copy_third_party_files
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CUSTOM_COMMAND_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${TARGET_tmp}> "${CUSTOM_COMMAND_BINARY_DIR}/"
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
else()
|
||||
if(DEFINED IGC_DIR) # Only copy igc libs if available
|
||||
message(STATUS "L0::Igc Dir: ${IGC_DIR}")
|
||||
add_custom_command(
|
||||
TARGET copy_third_party_files
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CUSTOM_COMMAND_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${IGC_DIR}/lib" "${CUSTOM_COMMAND_BINARY_DIR}/"
|
||||
DEPENDS "${IGC_DIR}/lib"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET ${GMM_TARGET_NAME})
|
||||
message(STATUS "L0::Gmm Target: ${GMM_TARGET_NAME}")
|
||||
add_dependencies(copy_third_party_files ${GMM_TARGET_NAME})
|
||||
if(UNIX)
|
||||
add_custom_command(
|
||||
TARGET copy_third_party_files
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CUSTOM_COMMAND_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_SONAME_FILE:${GMM_TARGET_NAME}>" "${CUSTOM_COMMAND_BINARY_DIR}/"
|
||||
)
|
||||
endif()
|
||||
add_custom_command(
|
||||
TARGET copy_third_party_files
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CUSTOM_COMMAND_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:${GMM_TARGET_NAME}>" "${CUSTOM_COMMAND_BINARY_DIR}/"
|
||||
)
|
||||
else()
|
||||
if(DEFINED GMM_DIR) # Only copy gmm libs if available
|
||||
message(STATUS "L0::Gmm Dir: ${GMM_DIR}")
|
||||
add_custom_command(
|
||||
TARGET copy_third_party_files
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CUSTOM_COMMAND_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${GMM_DIR}/lib" "${CUSTOM_COMMAND_BINARY_DIR}/"
|
||||
DEPENDS "${GMM_DIR}/lib"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Get build type
|
||||
string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE)
|
||||
|
||||
if("${BUILD_TYPE}" STREQUAL "debug")
|
||||
add_definitions(-DZE_DEBUG)
|
||||
endif()
|
||||
|
||||
include_directories(${COMPUTE_RUNTIME_DIR}/third_party/opencl_headers)
|
||||
include_directories(${LevelZero_INCLUDE_DIRS})
|
||||
include_directories(${NEO_SOURCE_DIR}/level_zero/api/experimental${BRANCH_DIR_SUFFIX})
|
||||
include_directories(${NEO_SOURCE_DIR}/shared/source/compiler_interface/compiler_options${BRANCH_DIR_SUFFIX})
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/core/source/hw_helpers${BRANCH_DIR_SUFFIX})
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/core/source/cmdlist_extended${BRANCH_DIR_SUFFIX})
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/core/source/cmdqueue_extended${BRANCH_DIR_SUFFIX})
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
include_directories(ddi${BRANCH_DIR_SUFFIX})
|
||||
include_directories(tools/source)
|
||||
include_directories(experimental${BRANCH_DIR_SUFFIX}/source)
|
||||
|
||||
# Create our shared library/DLL
|
||||
add_library(${TARGET_NAME_L0}
|
||||
SHARED
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${NEO_CORE_DIRECTORY}/dll/options_dll.cpp
|
||||
${NEO_CORE_DIRECTORY}/gmm_helper/resource_info.cpp
|
||||
${NEO_CORE_DIRECTORY}/utilities/cpuintrinsics.cpp
|
||||
${NEO_CORE_DIRECTORY}/utilities/debug_settings_reader_creator.cpp
|
||||
${NEO_CORE_DIRECTORY}/gmm_helper/page_table_mngr.cpp
|
||||
${NEO_CORE_DIRECTORY}/gmm_helper/resource_info.cpp
|
||||
${NEO_CORE_DIRECTORY}/helpers/abort.cpp
|
||||
${NEO_CORE_DIRECTORY}/helpers/debug_helpers.cpp
|
||||
)
|
||||
|
||||
target_sources(${TARGET_NAME_L0}
|
||||
PRIVATE
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/aub/aub_stream_interface.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/create_command_stream.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/create_deferred_deleter.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/create_tbx_sockets.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/get_devices.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/source_level_debugger.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/helpers/built_ins_helper.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/instrumentation/instrumentation.cpp
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
target_sources(${TARGET_NAME_L0}
|
||||
PRIVATE
|
||||
${NEO_CORE_DIRECTORY}/gmm_helper/windows/gmm_memory_base.cpp
|
||||
${NEO_CORE_DIRECTORY}/gmm_helper/windows/gmm_memory.cpp
|
||||
${NEO_CORE_DIRECTORY}/os_interface/windows/sys_calls.cpp
|
||||
${NEO_CORE_DIRECTORY}/os_interface/windows/os_interface.cpp
|
||||
${NEO_CORE_DIRECTORY}/os_interface/windows/wddm/wddm_calls.cpp
|
||||
${NEO_CORE_DIRECTORY}/os_interface/windows/wddm/wddm_create.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/windows/environment_variables.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/windows/options_windows.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/windows/os_interface.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/windows/create_wddm_memory_manager.cpp
|
||||
)
|
||||
target_link_libraries(${TARGET_NAME_L0}
|
||||
dxgi
|
||||
ws2_32
|
||||
)
|
||||
else()
|
||||
target_sources(${TARGET_NAME_L0}
|
||||
PRIVATE
|
||||
${NEO_CORE_DIRECTORY}/os_interface/linux/sys_calls_linux.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/allocator_helper.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/create_drm_memory_manager.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/devices${BRANCH_DIR_SUFFIX}/devices.inl
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/devices/devices_base.inl
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/options_linux.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/os_interface.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(DEFINED AUB_STREAM_DIR)
|
||||
target_sources(${TARGET_NAME_L0}
|
||||
PRIVATE
|
||||
$<TARGET_OBJECTS:aub_stream_all_hw>
|
||||
)
|
||||
endif()
|
||||
target_sources(${TARGET_NAME_L0}
|
||||
PRIVATE
|
||||
$<TARGET_OBJECTS:${BUILTINS_BINARIES_LIB_NAME}>
|
||||
)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/source/inc)
|
||||
|
||||
target_compile_definitions(${TARGET_NAME_L0}
|
||||
PUBLIC
|
||||
ZE_MAKEDLL
|
||||
)
|
||||
|
||||
get_property(COMPUTE_RUNTIME_DEFINITIONS
|
||||
TARGET ${NEO_RELEASE_LIB_NAME}
|
||||
PROPERTY COMPILE_DEFINITIONS
|
||||
)
|
||||
|
||||
target_compile_definitions(${TARGET_NAME_L0}
|
||||
PRIVATE
|
||||
${COMPUTE_RUNTIME_DEFINITIONS}
|
||||
)
|
||||
|
||||
append_sources_from_properties(L0_SRCS_DLL NEO_CORE_SRCS_LINK)
|
||||
target_sources(${TARGET_NAME_L0} PRIVATE ${L0_SRCS_DLL})
|
||||
|
||||
if(UNIX)
|
||||
target_sources(${TARGET_NAME_L0}
|
||||
PRIVATE
|
||||
${NEO_CORE_DIRECTORY}/os_interface/linux/gmm_interface_linux.cpp
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/drm_neo_create.cpp
|
||||
)
|
||||
set(OS_SPECIFIC_LIBS dl pthread rt)
|
||||
target_include_directories(${TARGET_NAME_L0} PUBLIC
|
||||
${L0_ROOT_DIR}/core/source/os_interface/linux
|
||||
${I915_INCLUDES_DIR}
|
||||
)
|
||||
target_include_directories(${TARGET_NAME_L0} PRIVATE
|
||||
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/devices${BRANCH_DIR_SUFFIX}
|
||||
)
|
||||
else()
|
||||
set(OS_SPECIFIC_LIBS "")
|
||||
target_include_directories(${TARGET_NAME_L0} PUBLIC
|
||||
${L0_ROOT_DIR}/core/source/os_interface/windows
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(L0_BITNESS_SUFIX 32)
|
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(L0_BITNESS_SUFIX 64)
|
||||
endif()
|
||||
|
||||
set_target_properties(${TARGET_NAME_L0} PROPERTIES
|
||||
DEBUG_OUTPUT_NAME "${TARGET_NAME_L0}${L0_BITNESS_SUFIX}"
|
||||
RELEASE_OUTPUT_NAME "${TARGET_NAME_L0}${L0_BITNESS_SUFIX}"
|
||||
RELEASEINTERNAL_OUTPUT_NAME "${TARGET_NAME_L0}${L0_BITNESS_SUFIX}"
|
||||
OUTPUT_NAME "${TARGET_NAME_L0}${L0_BITNESS_SUFIX}"
|
||||
)
|
||||
add_dependencies(${TARGET_NAME_L0} ${GMM_TARGET_NAME})
|
||||
target_sources(${TARGET_NAME_L0} PRIVATE
|
||||
${NEO_CORE_DIRECTORY}/os_interface/windows/gmm_interface_win.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${TARGET_NAME_L0}
|
||||
${NEO_RELEASE_LIB_NAME}
|
||||
${NEO_CORE_RELEASE_LIB_NAME}
|
||||
${NEO_RELEASE_LIB_NAME}
|
||||
${NEO_CORE_RELEASE_LIB_NAME}
|
||||
${OS_SPECIFIC_LIBS}
|
||||
)
|
||||
if(UNIX)
|
||||
target_link_libraries(${TARGET_NAME_L0} ${GMM_LINK_NAME})
|
||||
endif()
|
||||
|
||||
add_subdirectory_unique(api)
|
||||
add_subdirectory_unique(source)
|
||||
add_subdirectory_unique(core/source)
|
||||
add_subdirectory_unique(experimental${BRANCH_DIR_SUFFIX}/source)
|
||||
add_subdirectory_unique(tools/source)
|
||||
|
||||
create_source_tree(${TARGET_NAME_L0} ${L0_ROOT_DIR}/..)
|
||||
|
||||
if(HAVE_INSTRUMENTATION)
|
||||
target_link_libraries(${TARGET_NAME_L0}
|
||||
${INSTRUMENTATION_LIB_NAME})
|
||||
target_include_directories(${TARGET_NAME_L0} BEFORE PRIVATE
|
||||
${INSTRUMENTATION_INCLUDE_PATH}
|
||||
)
|
||||
endif()
|
||||
|
||||
set_property(TARGET ${TARGET_NAME_L0} APPEND_STRING PROPERTY COMPILE_FLAGS ${ASAN_FLAGS})
|
||||
set_target_properties(${TARGET_NAME_L0} PROPERTIES FOLDER ${TARGET_NAME_L0})
|
||||
|
||||
set_target_properties(${TARGET_NAME_L0} PROPERTIES
|
||||
FOLDER ${TARGET_NAME_L0}
|
||||
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
|
||||
SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
install(TARGETS ${TARGET_NAME_L0}
|
||||
LIBRARY
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
COMPONENT ${PROJECT_NAME}
|
||||
NAMELINK_SKIP
|
||||
)
|
||||
else()
|
||||
install(TARGETS ${TARGET_NAME_L0} RUNTIME
|
||||
DESTINATION Release/lh64
|
||||
CONFIGURATIONS Release
|
||||
)
|
||||
install(TARGETS ${TARGET_NAME_L0} RUNTIME
|
||||
DESTINATION Release-Internal/lh64
|
||||
CONFIGURATIONS ReleaseInternal
|
||||
)
|
||||
install(TARGETS ${TARGET_NAME_L0} RUNTIME
|
||||
DESTINATION Debug/lh64
|
||||
CONFIGURATIONS Debug
|
||||
)
|
||||
endif()
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
if(UNIX AND (NOT NEO_BUILD_PACKAGE))
|
||||
message(STATUS "Building LevelZero package")
|
||||
if(DEFINED L0_CPACK_GENERATOR)
|
||||
set(CPACK_GENERATOR ${L0_CPACK_GENERATOR})
|
||||
else()
|
||||
# If generators list was not define build native package for current distro
|
||||
if(EXISTS "/etc/debian_version")
|
||||
set(CPACK_GENERATOR "DEB")
|
||||
|
||||
set(file_path "/etc/lsb-release")
|
||||
if(EXISTS "${file_path}")
|
||||
file(STRINGS "${file_path}" data_list REGEX "^(DISTRIB_ID|DISTRIB_CODENAME)=")
|
||||
|
||||
# Look for lines like "DISTRIB_ID="..." and DISTRIB_CODENAME="..."
|
||||
foreach(_var ${data_list})
|
||||
if("${_var}" MATCHES "^(DISTRIB_ID)=(.*)$")
|
||||
set(DEB_DISTRIB_ID "${CMAKE_MATCH_2}")
|
||||
elseif("${_var}" MATCHES "^(DISTRIB_CODENAME)=(.*)$")
|
||||
set(DEB_DISTRIB_CODENAME "${CMAKE_MATCH_2}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
elseif(EXISTS "/etc/redhat-release")
|
||||
set(CPACK_GENERATOR "RPM")
|
||||
else()
|
||||
set(CPACK_GENERATOR "TXZ")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CPACK_PACKAGE_CONTACT "Intel Corporation")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
|
||||
if(NOT DEFINED L0_VERSION_BUILD)
|
||||
set(L0_VERSION_BUILD 0)
|
||||
endif()
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Level Zero driver written for Intel GPU devices.")
|
||||
|
||||
set(CPACK_DEB_COMPONENT_INSTALL ON)
|
||||
set(CPACK_RPM_COMPONENT_INSTALL ON)
|
||||
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
|
||||
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
|
||||
set(CPACK_DEBIAN_PACKAGE_RELEASE ${L0_VERSION_BUILD})
|
||||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
||||
|
||||
set(CPACK_RPM_COMPRESSION_TYPE "xz")
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
|
||||
set(CPACK_RPM_PACKAGE_AUTOREQ OFF)
|
||||
set(CPACK_RPM_PACKAGE_GROUP "System Environment/Libraries")
|
||||
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
|
||||
set(CPACK_RPM_PACKAGE_RELEASE ${L0_VERSION_BUILD})
|
||||
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
|
||||
|
||||
set_property(GLOBAL APPEND PROPERTY L0_COMPONENTS_LIST ${PROJECT_NAME})
|
||||
|
||||
set(L0_PACKAGE_VERSION_DEB "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
set(L0_PACKAGE_VERSION_RPM "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
|
||||
if(NEO__GMM_FOUND)
|
||||
list(APPEND _external_package_dependencies_deb "intel-gmmlib(=${NEO__GMM_VERSION})")
|
||||
list(APPEND _external_package_dependencies_rpm "intel-gmmlib = ${NEO__GMM_VERSION}")
|
||||
else()
|
||||
list(APPEND _external_package_dependencies_deb "intel-gmmlib")
|
||||
list(APPEND _external_package_dependencies_rpm "intel-gmmlib")
|
||||
endif()
|
||||
|
||||
if(NEO__IGC_FOUND)
|
||||
list(APPEND _external_package_dependencies_deb "intel-igc-opencl(>=${NEO__IGC_VERSION})")
|
||||
list(APPEND _external_package_dependencies_rpm "intel-igc-opencl >= ${NEO__IGC_VERSION}")
|
||||
else()
|
||||
list(APPEND _external_package_dependencies_deb "intel-igc-opencl")
|
||||
list(APPEND _external_package_dependencies_rpm "intel-igc-opencl")
|
||||
endif()
|
||||
|
||||
list(APPEND _external_package_dependencies_deb "level-zero")
|
||||
list(APPEND _external_package_dependencies_rpm "level-zero")
|
||||
|
||||
# Consecutive build number
|
||||
if(NOT DEFINED NEO_VERSION_BUILD)
|
||||
set(PACKAGE_VERSION_BUILD ${BUILD_VERSION})
|
||||
else()
|
||||
set(PACKAGE_VERSION_BUILD ${NEO_VERSION_BUILD})
|
||||
endif()
|
||||
|
||||
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
|
||||
|
||||
include("os_release_info.cmake")
|
||||
get_os_release_info(os_name os_version os_codename)
|
||||
#Pick only first character of os_name
|
||||
string(SUBSTRING "${os_name}" 0 1 os_name)
|
||||
|
||||
find_program(GIT_EXE NAMES "git")
|
||||
if(GIT_EXE AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
if(MSVC)
|
||||
execute_process(
|
||||
COMMAND CMD /c git rev-list v${L0_PACKAGE_VERSION_DEB}..HEAD --count
|
||||
OUTPUT_VARIABLE VERSION_SUFFIX
|
||||
)
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND git rev-list v${L0_PACKAGE_VERSION_DEB}..HEAD --count
|
||||
OUTPUT_VARIABLE VERSION_SUFFIX
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
string(STRIP "${VERSION_SUFFIX}" VERSION_SUFFIX)
|
||||
|
||||
if(NOT DEFINED ${PACKAGE_VERSION_BUILD})
|
||||
set(PACKAGE_RELEASE_VERSION ${VERSION_SUFFIX})
|
||||
else()
|
||||
set(PACKAGE_RELEASE_VERSION ${PACKAGE_VERSION_BUILD})
|
||||
endif()
|
||||
|
||||
string(REPLACE ";" ", " CPACK_DEBIAN_INTEL-LEVEL-ZERO-GPU_PACKAGE_DEPENDS "${_external_package_dependencies_deb}")
|
||||
string(REPLACE ";" ", " CPACK_RPM_INTEL-LEVEL-ZERO-GPU_PACKAGE_REQUIRES "${_external_package_dependencies_rpm}")
|
||||
set(CPACK_DEBIAN_INTEL-LEVEL-ZERO-GPU_PACKAGE_DEPENDS ${CPACK_DEBIAN_INTEL-LEVEL-ZERO-GPU_PACKAGE_DEPENDS} PARENT_SCOPE)
|
||||
set(CPACK_RPM_INTEL-LEVEL-ZERO-GPU_PACKAGE_REQUIRES ${CPACK_RPM_INTEL-LEVEL-ZERO-GPU_PACKAGE_REQUIRES} PARENT_SCOPE)
|
||||
|
||||
set(CPACK_DEBIAN_INTEL-LEVEL-ZERO-GPU_PACKAGE_NAME ${PROJECT_NAME})
|
||||
if("${BUILD_TYPE}" STREQUAL "debug")
|
||||
set(CPACK_DEBIAN_INTEL-LEVEL-ZERO-GPU_FILE_NAME "${PROJECT_NAME}_${L0_PACKAGE_VERSION_DEB}-${PACKAGE_RELEASE_VERSION}+${os_name}${os_version}-dbg_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
|
||||
else()
|
||||
set(CPACK_DEBIAN_INTEL-LEVEL-ZERO-GPU_FILE_NAME "${PROJECT_NAME}_${L0_PACKAGE_VERSION_DEB}-${PACKAGE_RELEASE_VERSION}+${os_name}${os_version}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
|
||||
endif()
|
||||
|
||||
set(CPACK_RPM_INTEL-LEVEL-ZERO-GPU_PACKAGE_NAME ${PROJECT_NAME})
|
||||
set(CPACK_RPM_INTEL-LEVEL-ZERO-GPU_FILE_NAME "${PROJECT_NAME}-${L0_PACKAGE_VERSION_RPM}%{?dist}.${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm")
|
||||
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${BRANCH_TYPE}/cpack.cmake)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${BRANCH_TYPE}/cpack.cmake)
|
||||
endif()
|
||||
|
||||
set(CPACK_SOURCE_GENERATOR "TGZ")
|
||||
set(CPACK_SOURCE_IGNORE_FILES
|
||||
/.git/
|
||||
/.gitignore
|
||||
/build/
|
||||
/manifests/
|
||||
)
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}_${L0_PACKAGE_VERSION_DEB}-${PACKAGE_RELEASE_VERSION}_${BUILD_TYPE}")
|
||||
|
||||
get_property(CPACK_COMPONENTS_ALL GLOBAL PROPERTY L0_COMPONENTS_LIST)
|
||||
set(CPACK_PROPERTIES_FILE "${NEO_SOURCE_DIR}/package_config.cmake")
|
||||
set(CPACK_LD_LIBRARY_PATH "${NEO__GMM_LIBRARY_PATH}")
|
||||
|
||||
include(CPack)
|
||||
endif()
|
||||
endif()
|
|
@ -0,0 +1,16 @@
|
|||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(experimental${BRANCH_DIR_SUFFIX}/)
|
||||
add_subdirectory(tools)
|
||||
|
||||
set(L0_API "")
|
||||
append_sources_from_properties(L0_API
|
||||
L0_SRCS_API
|
||||
L0_EXPERIMENTAL_API
|
||||
L0_TOOLS_API)
|
||||
set_property(GLOBAL PROPERTY L0_API ${L0_API})
|
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_SRCS_API
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_barrier.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_cl_interop.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_cmdlist.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_cmdqueue.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_copy.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_core_loader.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_device.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_driver.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_event.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_fence.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_image.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_memory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_module.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_residency.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_sampler.cpp
|
||||
)
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_API ${L0_SRCS_API})
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/cmdlist.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendBarrier(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendBarrier(hSignalEvent, numWaitEvents, phWaitEvents);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendMemoryRangesBarrier(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
uint32_t numRanges,
|
||||
const size_t *pRangeSizes,
|
||||
const void **pRanges,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pRangeSizes)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pRanges)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendMemoryRangesBarrier(numRanges, pRangeSizes, pRanges, hSignalEvent, numWaitEvents, phWaitEvents);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceSystemBarrier(
|
||||
ze_device_handle_t hDevice) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->systemBarrier();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceRegisterCLMemory(
|
||||
ze_device_handle_t hDevice,
|
||||
cl_context context,
|
||||
cl_mem mem,
|
||||
void **ptr) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == ptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->registerCLMemory(context, mem, ptr);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceRegisterCLProgram(
|
||||
ze_device_handle_t hDevice,
|
||||
cl_context context,
|
||||
cl_program program,
|
||||
ze_module_handle_t *phModule) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phModule)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->registerCLProgram(context, program, phModule);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceRegisterCLCommandQueue(
|
||||
ze_device_handle_t hDevice,
|
||||
cl_context context,
|
||||
cl_command_queue commandQueue,
|
||||
ze_command_queue_handle_t *phCommandQueue) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phCommandQueue)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->registerCLCommandQueue(context, commandQueue, phCommandQueue);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/cmdlist.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListCreate(
|
||||
ze_device_handle_t hDevice,
|
||||
const ze_command_list_desc_t *desc,
|
||||
ze_command_list_handle_t *phCommandList) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == desc)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (ZE_COMMAND_LIST_DESC_VERSION_CURRENT < desc->version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->createCommandList(desc, phCommandList);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListCreateImmediate(
|
||||
ze_device_handle_t hDevice,
|
||||
const ze_command_queue_desc_t *altdesc,
|
||||
ze_command_list_handle_t *phCommandList) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == altdesc)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (ZE_COMMAND_QUEUE_DESC_VERSION_CURRENT < altdesc->version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->createCommandListImmediate(altdesc, phCommandList);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListDestroy(
|
||||
ze_command_list_handle_t hCommandList) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->destroy();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListClose(
|
||||
ze_command_list_handle_t hCommandList) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->close();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListReset(
|
||||
ze_command_list_handle_t hCommandList) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->reset();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/cmdqueue.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandQueueCreate(
|
||||
ze_device_handle_t hDevice,
|
||||
const ze_command_queue_desc_t *desc,
|
||||
ze_command_queue_handle_t *phCommandQueue) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == desc)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phCommandQueue)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (ZE_COMMAND_QUEUE_DESC_VERSION_CURRENT < desc->version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->createCommandQueue(desc, phCommandQueue);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandQueueDestroy(
|
||||
ze_command_queue_handle_t hCommandQueue) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandQueue)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandQueue::fromHandle(hCommandQueue)->destroy();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandQueueExecuteCommandLists(
|
||||
ze_command_queue_handle_t hCommandQueue,
|
||||
uint32_t numCommandLists,
|
||||
ze_command_list_handle_t *phCommandLists,
|
||||
ze_fence_handle_t hFence) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandQueue)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phCommandLists)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandQueue::fromHandle(hCommandQueue)->executeCommandLists(numCommandLists, phCommandLists, hFence, true);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandQueueSynchronize(
|
||||
ze_command_queue_handle_t hCommandQueue,
|
||||
uint32_t timeout) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandQueue)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandQueue::fromHandle(hCommandQueue)->synchronize(timeout);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,253 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/cmdlist.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendMemoryCopy(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
void *dstptr,
|
||||
const void *srcptr,
|
||||
size_t size,
|
||||
ze_event_handle_t hEvent) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == dstptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == srcptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendMemoryCopy(dstptr, srcptr, size, hEvent, 0, nullptr);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendMemoryFill(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
void *ptr,
|
||||
const void *pattern,
|
||||
size_t patternSize,
|
||||
size_t size,
|
||||
ze_event_handle_t hEvent) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == ptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendMemoryFill(ptr, pattern, patternSize, size, hEvent);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendMemoryCopyRegion(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
void *dstptr,
|
||||
const ze_copy_region_t *dstRegion,
|
||||
uint32_t dstPitch,
|
||||
uint32_t dstSlicePitch,
|
||||
const void *srcptr,
|
||||
const ze_copy_region_t *srcRegion,
|
||||
uint32_t srcPitch,
|
||||
uint32_t srcSlicePitch,
|
||||
ze_event_handle_t hEvent) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == dstptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == dstRegion)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == srcptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == srcRegion)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendMemoryCopyRegion(dstptr, dstRegion, dstPitch, dstSlicePitch, srcptr, srcRegion, srcPitch, srcSlicePitch, hEvent);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendImageCopy(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
ze_image_handle_t hDstImage,
|
||||
ze_image_handle_t hSrcImage,
|
||||
ze_event_handle_t hEvent) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hDstImage)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hSrcImage)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendImageCopy(hDstImage, hSrcImage, hEvent, 0, nullptr);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendImageCopyRegion(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
ze_image_handle_t hDstImage,
|
||||
ze_image_handle_t hSrcImage,
|
||||
const ze_image_region_t *pDstRegion,
|
||||
const ze_image_region_t *pSrcRegion,
|
||||
ze_event_handle_t hEvent) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hDstImage)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hSrcImage)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendImageCopyRegion(hDstImage, hSrcImage, pDstRegion, pSrcRegion, hEvent, 0, nullptr);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendImageCopyToMemory(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
void *dstptr,
|
||||
ze_image_handle_t hSrcImage,
|
||||
const ze_image_region_t *pSrcRegion,
|
||||
ze_event_handle_t hEvent) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == dstptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hSrcImage)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendImageCopyToMemory(dstptr, hSrcImage, pSrcRegion, hEvent, 0, nullptr);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendImageCopyFromMemory(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
ze_image_handle_t hDstImage,
|
||||
const void *srcptr,
|
||||
const ze_image_region_t *pDstRegion,
|
||||
ze_event_handle_t hEvent) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hDstImage)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == srcptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendImageCopyFromMemory(hDstImage, srcptr, pDstRegion, hEvent, 0, nullptr);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendMemoryPrefetch(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
const void *ptr,
|
||||
size_t size) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == ptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendMemoryPrefetch(ptr, size);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendMemAdvise(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
ze_device_handle_t hDevice,
|
||||
const void *ptr,
|
||||
size_t size,
|
||||
ze_memory_advice_t advice) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == ptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendMemAdvise(hDevice, ptr, size, advice);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,713 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/source/inc/ze_intel_gpu.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
#include <level_zero/ze_ddi.h>
|
||||
#include <level_zero/zet_api.h>
|
||||
#include <level_zero/zet_ddi.h>
|
||||
|
||||
#include "ze_ddi_tables.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
ze_gpu_driver_dditable_t driver_ddiTable;
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeGetDriverProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
ze_driver_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
driver_ddiTable.driverLibrary = LOAD_INTEL_GPU_LIBRARY();
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
driver_ddiTable.enableTracing = getenv_tobool("ZE_ENABLE_API_TRACING");
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGet = (ze_pfnDriverGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGet");
|
||||
pDdiTable->pfnGetApiVersion = (ze_pfnDriverGetApiVersion_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGetApiVersion");
|
||||
pDdiTable->pfnGetProperties = (ze_pfnDriverGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGetProperties");
|
||||
pDdiTable->pfnGetIPCProperties = (ze_pfnDriverGetIPCProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGetIPCProperties");
|
||||
pDdiTable->pfnGetExtensionFunctionAddress = (ze_pfnDriverGetExtensionFunctionAddress_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGetExtensionFunctionAddress");
|
||||
pDdiTable->pfnAllocSharedMem = (ze_pfnDriverAllocSharedMem_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverAllocSharedMem");
|
||||
pDdiTable->pfnAllocDeviceMem = (ze_pfnDriverAllocDeviceMem_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverAllocDeviceMem");
|
||||
pDdiTable->pfnAllocHostMem = (ze_pfnDriverAllocHostMem_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverAllocHostMem");
|
||||
pDdiTable->pfnFreeMem = (ze_pfnDriverFreeMem_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverFreeMem");
|
||||
pDdiTable->pfnGetMemAllocProperties = (ze_pfnDriverGetMemAllocProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGetMemAllocProperties");
|
||||
pDdiTable->pfnGetMemAddressRange = (ze_pfnDriverGetMemAddressRange_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGetMemAddressRange");
|
||||
pDdiTable->pfnGetMemIpcHandle = (ze_pfnDriverGetMemIpcHandle_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGetMemIpcHandle");
|
||||
pDdiTable->pfnOpenMemIpcHandle = (ze_pfnDriverOpenMemIpcHandle_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverOpenMemIpcHandle");
|
||||
pDdiTable->pfnCloseMemIpcHandle = (ze_pfnDriverCloseMemIpcHandle_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverCloseMemIpcHandle");
|
||||
driver_ddiTable.core_ddiTable.Driver = *pDdiTable;
|
||||
if (driver_ddiTable.enableTracing) {
|
||||
pDdiTable->pfnGet = (ze_pfnDriverGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGet_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGet)
|
||||
pDdiTable->pfnGet = driver_ddiTable.core_ddiTable.Driver.pfnGet;
|
||||
pDdiTable->pfnGetApiVersion = (ze_pfnDriverGetApiVersion_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGetApiVersion_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetApiVersion)
|
||||
pDdiTable->pfnGetApiVersion = driver_ddiTable.core_ddiTable.Driver.pfnGetApiVersion;
|
||||
pDdiTable->pfnGetProperties = (ze_pfnDriverGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGetProperties_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetProperties)
|
||||
pDdiTable->pfnGetProperties = driver_ddiTable.core_ddiTable.Driver.pfnGetProperties;
|
||||
pDdiTable->pfnGetIPCProperties = (ze_pfnDriverGetIPCProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGetIPCProperties_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetIPCProperties)
|
||||
pDdiTable->pfnGetIPCProperties = driver_ddiTable.core_ddiTable.Driver.pfnGetIPCProperties;
|
||||
pDdiTable->pfnGetExtensionFunctionAddress = (ze_pfnDriverGetExtensionFunctionAddress_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGetExtensionFunctionAddress_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetExtensionFunctionAddress)
|
||||
pDdiTable->pfnGetExtensionFunctionAddress = driver_ddiTable.core_ddiTable.Driver.pfnGetExtensionFunctionAddress;
|
||||
pDdiTable->pfnAllocSharedMem = (ze_pfnDriverAllocSharedMem_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverAllocSharedMem_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAllocSharedMem)
|
||||
pDdiTable->pfnAllocSharedMem = driver_ddiTable.core_ddiTable.Driver.pfnAllocSharedMem;
|
||||
pDdiTable->pfnAllocDeviceMem = (ze_pfnDriverAllocDeviceMem_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverAllocDeviceMem_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAllocDeviceMem)
|
||||
pDdiTable->pfnAllocDeviceMem = driver_ddiTable.core_ddiTable.Driver.pfnAllocDeviceMem;
|
||||
pDdiTable->pfnAllocHostMem = (ze_pfnDriverAllocHostMem_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverAllocHostMem_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAllocHostMem)
|
||||
pDdiTable->pfnAllocHostMem = driver_ddiTable.core_ddiTable.Driver.pfnAllocHostMem;
|
||||
pDdiTable->pfnFreeMem = (ze_pfnDriverFreeMem_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverFreeMem_Tracing");
|
||||
if (nullptr == pDdiTable->pfnFreeMem)
|
||||
pDdiTable->pfnFreeMem = driver_ddiTable.core_ddiTable.Driver.pfnFreeMem;
|
||||
pDdiTable->pfnGetMemAllocProperties = (ze_pfnDriverGetMemAllocProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGetMemAllocProperties_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetMemAllocProperties)
|
||||
pDdiTable->pfnGetMemAllocProperties = driver_ddiTable.core_ddiTable.Driver.pfnGetMemAllocProperties;
|
||||
pDdiTable->pfnGetMemAddressRange = (ze_pfnDriverGetMemAddressRange_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGetMemAddressRange_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetMemAddressRange)
|
||||
pDdiTable->pfnGetMemAddressRange = driver_ddiTable.core_ddiTable.Driver.pfnGetMemAddressRange;
|
||||
pDdiTable->pfnGetMemIpcHandle = (ze_pfnDriverGetMemIpcHandle_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverGetMemIpcHandle_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetMemIpcHandle)
|
||||
pDdiTable->pfnGetMemIpcHandle = driver_ddiTable.core_ddiTable.Driver.pfnGetMemIpcHandle;
|
||||
pDdiTable->pfnOpenMemIpcHandle = (ze_pfnDriverOpenMemIpcHandle_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverOpenMemIpcHandle_Tracing");
|
||||
if (nullptr == pDdiTable->pfnOpenMemIpcHandle)
|
||||
pDdiTable->pfnOpenMemIpcHandle = driver_ddiTable.core_ddiTable.Driver.pfnOpenMemIpcHandle;
|
||||
pDdiTable->pfnCloseMemIpcHandle = (ze_pfnDriverCloseMemIpcHandle_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDriverCloseMemIpcHandle_Tracing");
|
||||
if (nullptr == pDdiTable->pfnCloseMemIpcHandle)
|
||||
pDdiTable->pfnCloseMemIpcHandle = driver_ddiTable.core_ddiTable.Driver.pfnCloseMemIpcHandle;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeGetGlobalProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
ze_global_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
driver_ddiTable.driverLibrary = LOAD_INTEL_GPU_LIBRARY();
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
driver_ddiTable.enableTracing = getenv_tobool("ZE_ENABLE_API_TRACING");
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnInit = (ze_pfnInit_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeInit");
|
||||
driver_ddiTable.core_ddiTable.Global = *pDdiTable;
|
||||
if (driver_ddiTable.enableTracing) {
|
||||
pDdiTable->pfnInit = (ze_pfnInit_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeInit_Tracing");
|
||||
if (nullptr == pDdiTable->pfnInit)
|
||||
pDdiTable->pfnInit = driver_ddiTable.core_ddiTable.Global.pfnInit;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeGetDeviceProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
ze_device_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
driver_ddiTable.driverLibrary = LOAD_INTEL_GPU_LIBRARY();
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
driver_ddiTable.enableTracing = getenv_tobool("ZE_ENABLE_API_TRACING");
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGet = (ze_pfnDeviceGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGet");
|
||||
pDdiTable->pfnGetSubDevices = (ze_pfnDeviceGetSubDevices_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetSubDevices");
|
||||
pDdiTable->pfnGetProperties = (ze_pfnDeviceGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetProperties");
|
||||
pDdiTable->pfnSystemBarrier = (ze_pfnDeviceSystemBarrier_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceSystemBarrier");
|
||||
pDdiTable->pfnRegisterCLMemory = (ze_pfnDeviceRegisterCLMemory_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceRegisterCLMemory");
|
||||
pDdiTable->pfnRegisterCLProgram = (ze_pfnDeviceRegisterCLProgram_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceRegisterCLProgram");
|
||||
pDdiTable->pfnRegisterCLCommandQueue = (ze_pfnDeviceRegisterCLCommandQueue_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceRegisterCLCommandQueue");
|
||||
pDdiTable->pfnGetComputeProperties = (ze_pfnDeviceGetComputeProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetComputeProperties");
|
||||
pDdiTable->pfnGetKernelProperties = (ze_pfnDeviceGetKernelProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetKernelProperties");
|
||||
pDdiTable->pfnGetMemoryProperties = (ze_pfnDeviceGetMemoryProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetMemoryProperties");
|
||||
pDdiTable->pfnGetMemoryAccessProperties = (ze_pfnDeviceGetMemoryAccessProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetMemoryAccessProperties");
|
||||
pDdiTable->pfnGetCacheProperties = (ze_pfnDeviceGetCacheProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetCacheProperties");
|
||||
pDdiTable->pfnGetImageProperties = (ze_pfnDeviceGetImageProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetImageProperties");
|
||||
pDdiTable->pfnGetP2PProperties = (ze_pfnDeviceGetP2PProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetP2PProperties");
|
||||
pDdiTable->pfnCanAccessPeer = (ze_pfnDeviceCanAccessPeer_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceCanAccessPeer");
|
||||
pDdiTable->pfnSetLastLevelCacheConfig = (ze_pfnDeviceSetLastLevelCacheConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceSetLastLevelCacheConfig");
|
||||
pDdiTable->pfnMakeMemoryResident = (ze_pfnDeviceMakeMemoryResident_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceMakeMemoryResident");
|
||||
pDdiTable->pfnEvictMemory = (ze_pfnDeviceEvictMemory_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceEvictMemory");
|
||||
pDdiTable->pfnMakeImageResident = (ze_pfnDeviceMakeImageResident_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceMakeImageResident");
|
||||
pDdiTable->pfnEvictImage = (ze_pfnDeviceEvictImage_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceEvictImage");
|
||||
driver_ddiTable.core_ddiTable.Device = *pDdiTable;
|
||||
if (driver_ddiTable.enableTracing) {
|
||||
pDdiTable->pfnGet = (ze_pfnDeviceGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGet_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGet)
|
||||
pDdiTable->pfnGet = driver_ddiTable.core_ddiTable.Device.pfnGet;
|
||||
pDdiTable->pfnGetSubDevices = (ze_pfnDeviceGetSubDevices_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetSubDevices_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetSubDevices)
|
||||
pDdiTable->pfnGetSubDevices = driver_ddiTable.core_ddiTable.Device.pfnGetSubDevices;
|
||||
pDdiTable->pfnGetProperties = (ze_pfnDeviceGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetProperties_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetProperties)
|
||||
pDdiTable->pfnGetProperties = driver_ddiTable.core_ddiTable.Device.pfnGetProperties;
|
||||
pDdiTable->pfnSystemBarrier = (ze_pfnDeviceSystemBarrier_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceSystemBarrier_Tracing");
|
||||
if (nullptr == pDdiTable->pfnSystemBarrier)
|
||||
pDdiTable->pfnSystemBarrier = driver_ddiTable.core_ddiTable.Device.pfnSystemBarrier;
|
||||
pDdiTable->pfnRegisterCLMemory = (ze_pfnDeviceRegisterCLMemory_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceRegisterCLMemory_Tracing");
|
||||
if (nullptr == pDdiTable->pfnRegisterCLMemory)
|
||||
pDdiTable->pfnRegisterCLMemory = driver_ddiTable.core_ddiTable.Device.pfnRegisterCLMemory;
|
||||
pDdiTable->pfnRegisterCLProgram = (ze_pfnDeviceRegisterCLProgram_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceRegisterCLProgram_Tracing");
|
||||
if (nullptr == pDdiTable->pfnRegisterCLProgram)
|
||||
pDdiTable->pfnRegisterCLProgram = driver_ddiTable.core_ddiTable.Device.pfnRegisterCLProgram;
|
||||
pDdiTable->pfnRegisterCLCommandQueue = (ze_pfnDeviceRegisterCLCommandQueue_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceRegisterCLCommandQueue_Tracing");
|
||||
if (nullptr == pDdiTable->pfnRegisterCLCommandQueue)
|
||||
pDdiTable->pfnRegisterCLCommandQueue = driver_ddiTable.core_ddiTable.Device.pfnRegisterCLCommandQueue;
|
||||
pDdiTable->pfnGetComputeProperties = (ze_pfnDeviceGetComputeProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetComputeProperties_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetComputeProperties)
|
||||
pDdiTable->pfnGetComputeProperties = driver_ddiTable.core_ddiTable.Device.pfnGetComputeProperties;
|
||||
pDdiTable->pfnGetKernelProperties = (ze_pfnDeviceGetKernelProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetKernelProperties_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetKernelProperties)
|
||||
pDdiTable->pfnGetKernelProperties = driver_ddiTable.core_ddiTable.Device.pfnGetKernelProperties;
|
||||
pDdiTable->pfnGetMemoryProperties = (ze_pfnDeviceGetMemoryProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetMemoryProperties_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetMemoryProperties)
|
||||
pDdiTable->pfnGetMemoryProperties = driver_ddiTable.core_ddiTable.Device.pfnGetMemoryProperties;
|
||||
pDdiTable->pfnGetMemoryAccessProperties = (ze_pfnDeviceGetMemoryAccessProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetMemoryAccessProperties_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetMemoryAccessProperties)
|
||||
pDdiTable->pfnGetMemoryAccessProperties = driver_ddiTable.core_ddiTable.Device.pfnGetMemoryAccessProperties;
|
||||
pDdiTable->pfnGetCacheProperties = (ze_pfnDeviceGetCacheProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetCacheProperties_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetCacheProperties)
|
||||
pDdiTable->pfnGetCacheProperties = driver_ddiTable.core_ddiTable.Device.pfnGetCacheProperties;
|
||||
pDdiTable->pfnGetImageProperties = (ze_pfnDeviceGetImageProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetImageProperties_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetImageProperties)
|
||||
pDdiTable->pfnGetImageProperties = driver_ddiTable.core_ddiTable.Device.pfnGetImageProperties;
|
||||
pDdiTable->pfnGetP2PProperties = (ze_pfnDeviceGetP2PProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceGetP2PProperties_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetP2PProperties)
|
||||
pDdiTable->pfnGetP2PProperties = driver_ddiTable.core_ddiTable.Device.pfnGetP2PProperties;
|
||||
pDdiTable->pfnCanAccessPeer = (ze_pfnDeviceCanAccessPeer_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceCanAccessPeer_Tracing");
|
||||
if (nullptr == pDdiTable->pfnCanAccessPeer)
|
||||
pDdiTable->pfnCanAccessPeer = driver_ddiTable.core_ddiTable.Device.pfnCanAccessPeer;
|
||||
pDdiTable->pfnSetLastLevelCacheConfig = (ze_pfnDeviceSetLastLevelCacheConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceSetLastLevelCacheConfig_Tracing");
|
||||
if (nullptr == pDdiTable->pfnSetLastLevelCacheConfig)
|
||||
pDdiTable->pfnSetLastLevelCacheConfig = driver_ddiTable.core_ddiTable.Device.pfnSetLastLevelCacheConfig;
|
||||
pDdiTable->pfnMakeMemoryResident = (ze_pfnDeviceMakeMemoryResident_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceMakeMemoryResident_Tracing");
|
||||
if (nullptr == pDdiTable->pfnMakeMemoryResident)
|
||||
pDdiTable->pfnMakeMemoryResident = driver_ddiTable.core_ddiTable.Device.pfnMakeMemoryResident;
|
||||
pDdiTable->pfnEvictMemory = (ze_pfnDeviceEvictMemory_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceEvictMemory_Tracing");
|
||||
if (nullptr == pDdiTable->pfnEvictMemory)
|
||||
pDdiTable->pfnEvictMemory = driver_ddiTable.core_ddiTable.Device.pfnEvictMemory;
|
||||
pDdiTable->pfnMakeImageResident = (ze_pfnDeviceMakeImageResident_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceMakeImageResident_Tracing");
|
||||
if (nullptr == pDdiTable->pfnMakeImageResident)
|
||||
pDdiTable->pfnMakeImageResident = driver_ddiTable.core_ddiTable.Device.pfnMakeImageResident;
|
||||
pDdiTable->pfnEvictImage = (ze_pfnDeviceEvictImage_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeDeviceEvictImage_Tracing");
|
||||
if (nullptr == pDdiTable->pfnEvictImage)
|
||||
pDdiTable->pfnEvictImage = driver_ddiTable.core_ddiTable.Device.pfnEvictImage;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeGetCommandQueueProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
ze_command_queue_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
driver_ddiTable.driverLibrary = LOAD_INTEL_GPU_LIBRARY();
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
driver_ddiTable.enableTracing = getenv_tobool("ZE_ENABLE_API_TRACING");
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnCreate = (ze_pfnCommandQueueCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandQueueCreate");
|
||||
pDdiTable->pfnDestroy = (ze_pfnCommandQueueDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandQueueDestroy");
|
||||
pDdiTable->pfnExecuteCommandLists = (ze_pfnCommandQueueExecuteCommandLists_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandQueueExecuteCommandLists");
|
||||
pDdiTable->pfnSynchronize = (ze_pfnCommandQueueSynchronize_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandQueueSynchronize");
|
||||
driver_ddiTable.core_ddiTable.CommandQueue = *pDdiTable;
|
||||
if (driver_ddiTable.enableTracing) {
|
||||
pDdiTable->pfnCreate = (ze_pfnCommandQueueCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandQueueCreate_Tracing");
|
||||
if (nullptr == pDdiTable->pfnCreate)
|
||||
pDdiTable->pfnCreate = driver_ddiTable.core_ddiTable.CommandQueue.pfnCreate;
|
||||
pDdiTable->pfnDestroy = (ze_pfnCommandQueueDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandQueueDestroy_Tracing");
|
||||
if (nullptr == pDdiTable->pfnDestroy)
|
||||
pDdiTable->pfnDestroy = driver_ddiTable.core_ddiTable.CommandQueue.pfnDestroy;
|
||||
pDdiTable->pfnExecuteCommandLists = (ze_pfnCommandQueueExecuteCommandLists_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandQueueExecuteCommandLists_Tracing");
|
||||
if (nullptr == pDdiTable->pfnExecuteCommandLists)
|
||||
pDdiTable->pfnExecuteCommandLists = driver_ddiTable.core_ddiTable.CommandQueue.pfnExecuteCommandLists;
|
||||
pDdiTable->pfnSynchronize = (ze_pfnCommandQueueSynchronize_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandQueueSynchronize_Tracing");
|
||||
if (nullptr == pDdiTable->pfnSynchronize)
|
||||
pDdiTable->pfnSynchronize = driver_ddiTable.core_ddiTable.CommandQueue.pfnSynchronize;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeGetCommandListProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
ze_command_list_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
driver_ddiTable.driverLibrary = LOAD_INTEL_GPU_LIBRARY();
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
driver_ddiTable.enableTracing = getenv_tobool("ZE_ENABLE_API_TRACING");
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnAppendBarrier = (ze_pfnCommandListAppendBarrier_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendBarrier");
|
||||
pDdiTable->pfnAppendMemoryRangesBarrier = (ze_pfnCommandListAppendMemoryRangesBarrier_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendMemoryRangesBarrier");
|
||||
pDdiTable->pfnCreate = (ze_pfnCommandListCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListCreate");
|
||||
pDdiTable->pfnCreateImmediate = (ze_pfnCommandListCreateImmediate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListCreateImmediate");
|
||||
pDdiTable->pfnDestroy = (ze_pfnCommandListDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListDestroy");
|
||||
pDdiTable->pfnClose = (ze_pfnCommandListClose_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListClose");
|
||||
pDdiTable->pfnReset = (ze_pfnCommandListReset_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListReset");
|
||||
pDdiTable->pfnAppendMemoryCopy = (ze_pfnCommandListAppendMemoryCopy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendMemoryCopy");
|
||||
pDdiTable->pfnAppendMemoryCopyRegion = (ze_pfnCommandListAppendMemoryCopyRegion_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendMemoryCopyRegion");
|
||||
pDdiTable->pfnAppendMemoryFill = (ze_pfnCommandListAppendMemoryFill_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendMemoryFill");
|
||||
pDdiTable->pfnAppendImageCopy = (ze_pfnCommandListAppendImageCopy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendImageCopy");
|
||||
pDdiTable->pfnAppendImageCopyRegion = (ze_pfnCommandListAppendImageCopyRegion_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendImageCopyRegion");
|
||||
pDdiTable->pfnAppendImageCopyToMemory = (ze_pfnCommandListAppendImageCopyToMemory_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendImageCopyToMemory");
|
||||
pDdiTable->pfnAppendImageCopyFromMemory = (ze_pfnCommandListAppendImageCopyFromMemory_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendImageCopyFromMemory");
|
||||
pDdiTable->pfnAppendMemoryPrefetch = (ze_pfnCommandListAppendMemoryPrefetch_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendMemoryPrefetch");
|
||||
pDdiTable->pfnAppendMemAdvise = (ze_pfnCommandListAppendMemAdvise_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendMemAdvise");
|
||||
pDdiTable->pfnAppendSignalEvent = (ze_pfnCommandListAppendSignalEvent_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendSignalEvent");
|
||||
pDdiTable->pfnAppendWaitOnEvents = (ze_pfnCommandListAppendWaitOnEvents_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendWaitOnEvents");
|
||||
pDdiTable->pfnAppendEventReset = (ze_pfnCommandListAppendEventReset_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendEventReset");
|
||||
pDdiTable->pfnAppendLaunchKernel = (ze_pfnCommandListAppendLaunchKernel_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendLaunchKernel");
|
||||
pDdiTable->pfnAppendLaunchCooperativeKernel = (ze_pfnCommandListAppendLaunchCooperativeKernel_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendLaunchCooperativeKernel");
|
||||
pDdiTable->pfnAppendLaunchKernelIndirect = (ze_pfnCommandListAppendLaunchKernelIndirect_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendLaunchKernelIndirect");
|
||||
pDdiTable->pfnAppendLaunchMultipleKernelsIndirect = (ze_pfnCommandListAppendLaunchMultipleKernelsIndirect_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendLaunchMultipleKernelsIndirect");
|
||||
driver_ddiTable.core_ddiTable.CommandList = *pDdiTable;
|
||||
if (driver_ddiTable.enableTracing) {
|
||||
pDdiTable->pfnAppendBarrier = (ze_pfnCommandListAppendBarrier_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendBarrier_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendBarrier)
|
||||
pDdiTable->pfnAppendBarrier = driver_ddiTable.core_ddiTable.CommandList.pfnAppendBarrier;
|
||||
pDdiTable->pfnAppendMemoryRangesBarrier = (ze_pfnCommandListAppendMemoryRangesBarrier_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendMemoryRangesBarrier_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendMemoryRangesBarrier)
|
||||
pDdiTable->pfnAppendMemoryRangesBarrier = driver_ddiTable.core_ddiTable.CommandList.pfnAppendMemoryRangesBarrier;
|
||||
pDdiTable->pfnCreate = (ze_pfnCommandListCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListCreate_Tracing");
|
||||
if (nullptr == pDdiTable->pfnCreate)
|
||||
pDdiTable->pfnCreate = driver_ddiTable.core_ddiTable.CommandList.pfnCreate;
|
||||
pDdiTable->pfnCreateImmediate = (ze_pfnCommandListCreateImmediate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListCreateImmediate_Tracing");
|
||||
if (nullptr == pDdiTable->pfnDestroy)
|
||||
pDdiTable->pfnDestroy = driver_ddiTable.core_ddiTable.CommandList.pfnDestroy;
|
||||
pDdiTable->pfnDestroy = (ze_pfnCommandListDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListDestroy_Tracing");
|
||||
if (nullptr == pDdiTable->pfnDestroy)
|
||||
pDdiTable->pfnDestroy = driver_ddiTable.core_ddiTable.CommandList.pfnDestroy;
|
||||
pDdiTable->pfnClose = (ze_pfnCommandListClose_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListClose_Tracing");
|
||||
if (nullptr == pDdiTable->pfnClose)
|
||||
pDdiTable->pfnClose = driver_ddiTable.core_ddiTable.CommandList.pfnClose;
|
||||
pDdiTable->pfnReset = (ze_pfnCommandListReset_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListReset_Tracing");
|
||||
if (nullptr == pDdiTable->pfnReset)
|
||||
pDdiTable->pfnReset = driver_ddiTable.core_ddiTable.CommandList.pfnReset;
|
||||
pDdiTable->pfnAppendMemoryCopy = (ze_pfnCommandListAppendMemoryCopy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendMemoryCopy_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendMemoryCopy)
|
||||
pDdiTable->pfnAppendMemoryCopy = driver_ddiTable.core_ddiTable.CommandList.pfnAppendMemoryCopy;
|
||||
pDdiTable->pfnAppendMemoryCopyRegion = (ze_pfnCommandListAppendMemoryCopyRegion_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendMemoryCopyRegion_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendMemoryCopyRegion)
|
||||
pDdiTable->pfnAppendMemoryCopyRegion = driver_ddiTable.core_ddiTable.CommandList.pfnAppendMemoryCopyRegion;
|
||||
pDdiTable->pfnAppendMemoryFill = (ze_pfnCommandListAppendMemoryFill_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendMemoryFill_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendMemoryFill)
|
||||
pDdiTable->pfnAppendMemoryFill = driver_ddiTable.core_ddiTable.CommandList.pfnAppendMemoryFill;
|
||||
pDdiTable->pfnAppendImageCopy = (ze_pfnCommandListAppendImageCopy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendImageCopy_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendImageCopy)
|
||||
pDdiTable->pfnAppendImageCopy = driver_ddiTable.core_ddiTable.CommandList.pfnAppendImageCopy;
|
||||
pDdiTable->pfnAppendImageCopyRegion = (ze_pfnCommandListAppendImageCopyRegion_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendImageCopyRegion_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendImageCopyRegion)
|
||||
pDdiTable->pfnAppendImageCopyRegion = driver_ddiTable.core_ddiTable.CommandList.pfnAppendImageCopyRegion;
|
||||
pDdiTable->pfnAppendImageCopyToMemory = (ze_pfnCommandListAppendImageCopyToMemory_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendImageCopyToMemory_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendImageCopyToMemory)
|
||||
pDdiTable->pfnAppendImageCopyToMemory = driver_ddiTable.core_ddiTable.CommandList.pfnAppendImageCopyToMemory;
|
||||
pDdiTable->pfnAppendImageCopyFromMemory = (ze_pfnCommandListAppendImageCopyFromMemory_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendImageCopyFromMemory_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendImageCopyFromMemory)
|
||||
pDdiTable->pfnAppendImageCopyFromMemory = driver_ddiTable.core_ddiTable.CommandList.pfnAppendImageCopyFromMemory;
|
||||
pDdiTable->pfnAppendMemoryPrefetch = (ze_pfnCommandListAppendMemoryPrefetch_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendMemoryPrefetch_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendMemoryPrefetch)
|
||||
pDdiTable->pfnAppendMemoryPrefetch = driver_ddiTable.core_ddiTable.CommandList.pfnAppendMemoryPrefetch;
|
||||
pDdiTable->pfnAppendMemAdvise = (ze_pfnCommandListAppendMemAdvise_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendMemAdvise_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendMemAdvise)
|
||||
pDdiTable->pfnAppendMemAdvise = driver_ddiTable.core_ddiTable.CommandList.pfnAppendMemAdvise;
|
||||
pDdiTable->pfnAppendSignalEvent = (ze_pfnCommandListAppendSignalEvent_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendSignalEvent_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendSignalEvent)
|
||||
pDdiTable->pfnAppendSignalEvent = driver_ddiTable.core_ddiTable.CommandList.pfnAppendSignalEvent;
|
||||
pDdiTable->pfnAppendWaitOnEvents = (ze_pfnCommandListAppendWaitOnEvents_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendWaitOnEvents_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendWaitOnEvents)
|
||||
pDdiTable->pfnAppendWaitOnEvents = driver_ddiTable.core_ddiTable.CommandList.pfnAppendWaitOnEvents;
|
||||
pDdiTable->pfnAppendEventReset = (ze_pfnCommandListAppendEventReset_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendEventReset_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendEventReset)
|
||||
pDdiTable->pfnAppendEventReset = driver_ddiTable.core_ddiTable.CommandList.pfnAppendEventReset;
|
||||
pDdiTable->pfnAppendLaunchKernel = (ze_pfnCommandListAppendLaunchKernel_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendLaunchKernel_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendLaunchKernel)
|
||||
pDdiTable->pfnAppendLaunchKernel = driver_ddiTable.core_ddiTable.CommandList.pfnAppendLaunchKernel;
|
||||
pDdiTable->pfnAppendLaunchCooperativeKernel = (ze_pfnCommandListAppendLaunchCooperativeKernel_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendLaunchCooperativeKernel_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendLaunchCooperativeKernel)
|
||||
pDdiTable->pfnAppendLaunchCooperativeKernel = driver_ddiTable.core_ddiTable.CommandList.pfnAppendLaunchCooperativeKernel;
|
||||
pDdiTable->pfnAppendLaunchKernelIndirect = (ze_pfnCommandListAppendLaunchKernelIndirect_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendLaunchKernelIndirect_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendLaunchKernelIndirect)
|
||||
pDdiTable->pfnAppendLaunchKernelIndirect = driver_ddiTable.core_ddiTable.CommandList.pfnAppendLaunchKernelIndirect;
|
||||
pDdiTable->pfnAppendLaunchMultipleKernelsIndirect = (ze_pfnCommandListAppendLaunchMultipleKernelsIndirect_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeCommandListAppendLaunchMultipleKernelsIndirect_Tracing");
|
||||
if (nullptr == pDdiTable->pfnAppendLaunchMultipleKernelsIndirect)
|
||||
pDdiTable->pfnAppendLaunchMultipleKernelsIndirect = driver_ddiTable.core_ddiTable.CommandList.pfnAppendLaunchMultipleKernelsIndirect;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeGetFenceProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
ze_fence_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
driver_ddiTable.driverLibrary = LOAD_INTEL_GPU_LIBRARY();
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
driver_ddiTable.enableTracing = getenv_tobool("ZE_ENABLE_API_TRACING");
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnCreate = (ze_pfnFenceCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeFenceCreate");
|
||||
pDdiTable->pfnDestroy = (ze_pfnFenceDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeFenceDestroy");
|
||||
pDdiTable->pfnHostSynchronize = (ze_pfnFenceHostSynchronize_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeFenceHostSynchronize");
|
||||
pDdiTable->pfnQueryStatus = (ze_pfnFenceQueryStatus_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeFenceQueryStatus");
|
||||
pDdiTable->pfnReset = (ze_pfnFenceReset_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeFenceReset");
|
||||
driver_ddiTable.core_ddiTable.Fence = *pDdiTable;
|
||||
if (driver_ddiTable.enableTracing) {
|
||||
pDdiTable->pfnCreate = (ze_pfnFenceCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeFenceCreate_Tracing");
|
||||
if (nullptr == pDdiTable->pfnCreate)
|
||||
pDdiTable->pfnCreate = driver_ddiTable.core_ddiTable.Fence.pfnCreate;
|
||||
pDdiTable->pfnDestroy = (ze_pfnFenceDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeFenceDestroy_Tracing");
|
||||
if (nullptr == pDdiTable->pfnDestroy)
|
||||
pDdiTable->pfnDestroy = driver_ddiTable.core_ddiTable.Fence.pfnDestroy;
|
||||
pDdiTable->pfnHostSynchronize = (ze_pfnFenceHostSynchronize_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeFenceHostSynchronize_Tracing");
|
||||
if (nullptr == pDdiTable->pfnHostSynchronize)
|
||||
pDdiTable->pfnHostSynchronize = driver_ddiTable.core_ddiTable.Fence.pfnHostSynchronize;
|
||||
pDdiTable->pfnQueryStatus = (ze_pfnFenceQueryStatus_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeFenceQueryStatus_Tracing");
|
||||
if (nullptr == pDdiTable->pfnQueryStatus)
|
||||
pDdiTable->pfnQueryStatus = driver_ddiTable.core_ddiTable.Fence.pfnQueryStatus;
|
||||
pDdiTable->pfnReset = (ze_pfnFenceReset_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeFenceReset_Tracing");
|
||||
if (nullptr == pDdiTable->pfnReset)
|
||||
pDdiTable->pfnReset = driver_ddiTable.core_ddiTable.Fence.pfnReset;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeGetEventPoolProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
ze_event_pool_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
driver_ddiTable.driverLibrary = LOAD_INTEL_GPU_LIBRARY();
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
driver_ddiTable.enableTracing = getenv_tobool("ZE_ENABLE_API_TRACING");
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnCreate = (ze_pfnEventPoolCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventPoolCreate");
|
||||
pDdiTable->pfnDestroy = (ze_pfnEventPoolDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventPoolDestroy");
|
||||
pDdiTable->pfnGetIpcHandle = (ze_pfnEventPoolGetIpcHandle_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventPoolGetIpcHandle");
|
||||
pDdiTable->pfnOpenIpcHandle = (ze_pfnEventPoolOpenIpcHandle_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventPoolOpenIpcHandle");
|
||||
pDdiTable->pfnCloseIpcHandle = (ze_pfnEventPoolCloseIpcHandle_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventPoolCloseIpcHandle");
|
||||
driver_ddiTable.core_ddiTable.EventPool = *pDdiTable;
|
||||
if (driver_ddiTable.enableTracing) {
|
||||
pDdiTable->pfnCreate = (ze_pfnEventPoolCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventPoolCreate_Tracing");
|
||||
if (nullptr == pDdiTable->pfnCreate)
|
||||
pDdiTable->pfnCreate = driver_ddiTable.core_ddiTable.EventPool.pfnCreate;
|
||||
pDdiTable->pfnDestroy = (ze_pfnEventPoolDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventPoolDestroy_Tracing");
|
||||
if (nullptr == pDdiTable->pfnDestroy)
|
||||
pDdiTable->pfnDestroy = driver_ddiTable.core_ddiTable.EventPool.pfnDestroy;
|
||||
pDdiTable->pfnGetIpcHandle = (ze_pfnEventPoolGetIpcHandle_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventPoolGetIpcHandle_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetIpcHandle)
|
||||
pDdiTable->pfnGetIpcHandle = driver_ddiTable.core_ddiTable.EventPool.pfnGetIpcHandle;
|
||||
pDdiTable->pfnOpenIpcHandle = (ze_pfnEventPoolOpenIpcHandle_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventPoolOpenIpcHandle_Tracing");
|
||||
if (nullptr == pDdiTable->pfnOpenIpcHandle)
|
||||
pDdiTable->pfnOpenIpcHandle = driver_ddiTable.core_ddiTable.EventPool.pfnOpenIpcHandle;
|
||||
pDdiTable->pfnCloseIpcHandle = (ze_pfnEventPoolCloseIpcHandle_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventPoolCloseIpcHandle_Tracing");
|
||||
if (nullptr == pDdiTable->pfnCloseIpcHandle)
|
||||
pDdiTable->pfnCloseIpcHandle = driver_ddiTable.core_ddiTable.EventPool.pfnCloseIpcHandle;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeGetEventProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
ze_event_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
driver_ddiTable.driverLibrary = LOAD_INTEL_GPU_LIBRARY();
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
driver_ddiTable.enableTracing = getenv_tobool("ZE_ENABLE_API_TRACING");
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnCreate = (ze_pfnEventCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventCreate");
|
||||
pDdiTable->pfnDestroy = (ze_pfnEventDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventDestroy");
|
||||
pDdiTable->pfnHostSignal = (ze_pfnEventHostSignal_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventHostSignal");
|
||||
pDdiTable->pfnHostSynchronize = (ze_pfnEventHostSynchronize_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventHostSynchronize");
|
||||
pDdiTable->pfnQueryStatus = (ze_pfnEventQueryStatus_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventQueryStatus");
|
||||
pDdiTable->pfnHostReset = (ze_pfnEventHostReset_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventHostReset");
|
||||
pDdiTable->pfnGetTimestamp = (ze_pfnEventGetTimestamp_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventGetTimestamp");
|
||||
driver_ddiTable.core_ddiTable.Event = *pDdiTable;
|
||||
if (driver_ddiTable.enableTracing) {
|
||||
pDdiTable->pfnCreate = (ze_pfnEventCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventCreate_Tracing");
|
||||
if (nullptr == pDdiTable->pfnCreate)
|
||||
pDdiTable->pfnCreate = driver_ddiTable.core_ddiTable.Event.pfnCreate;
|
||||
pDdiTable->pfnDestroy = (ze_pfnEventDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventDestroy_Tracing");
|
||||
if (nullptr == pDdiTable->pfnDestroy)
|
||||
pDdiTable->pfnDestroy = driver_ddiTable.core_ddiTable.Event.pfnDestroy;
|
||||
pDdiTable->pfnHostSignal = (ze_pfnEventHostSignal_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventHostSignal_Tracing");
|
||||
if (nullptr == pDdiTable->pfnHostSignal)
|
||||
pDdiTable->pfnHostSignal = driver_ddiTable.core_ddiTable.Event.pfnHostSignal;
|
||||
pDdiTable->pfnHostSynchronize = (ze_pfnEventHostSynchronize_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventHostSynchronize_Tracing");
|
||||
if (nullptr == pDdiTable->pfnHostSynchronize)
|
||||
pDdiTable->pfnHostSynchronize = driver_ddiTable.core_ddiTable.Event.pfnHostSynchronize;
|
||||
pDdiTable->pfnQueryStatus = (ze_pfnEventQueryStatus_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventQueryStatus_Tracing");
|
||||
if (nullptr == pDdiTable->pfnQueryStatus)
|
||||
pDdiTable->pfnQueryStatus = driver_ddiTable.core_ddiTable.Event.pfnQueryStatus;
|
||||
pDdiTable->pfnHostReset = (ze_pfnEventHostReset_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventHostReset_Tracing");
|
||||
if (nullptr == pDdiTable->pfnHostReset)
|
||||
pDdiTable->pfnHostReset = driver_ddiTable.core_ddiTable.Event.pfnHostReset;
|
||||
pDdiTable->pfnGetTimestamp = (ze_pfnEventGetTimestamp_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeEventGetTimestamp_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetTimestamp)
|
||||
pDdiTable->pfnGetTimestamp = driver_ddiTable.core_ddiTable.Event.pfnGetTimestamp;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeGetImageProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
ze_image_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
driver_ddiTable.driverLibrary = LOAD_INTEL_GPU_LIBRARY();
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
driver_ddiTable.enableTracing = getenv_tobool("ZE_ENABLE_API_TRACING");
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetProperties = (ze_pfnImageGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeImageGetProperties");
|
||||
pDdiTable->pfnCreate = (ze_pfnImageCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeImageCreate");
|
||||
pDdiTable->pfnDestroy = (ze_pfnImageDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeImageDestroy");
|
||||
driver_ddiTable.core_ddiTable.Image = *pDdiTable;
|
||||
if (driver_ddiTable.enableTracing) {
|
||||
pDdiTable->pfnGetProperties = (ze_pfnImageGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeImageGetProperties_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetProperties)
|
||||
pDdiTable->pfnGetProperties = driver_ddiTable.core_ddiTable.Image.pfnGetProperties;
|
||||
pDdiTable->pfnCreate = (ze_pfnImageCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeImageCreate_Tracing");
|
||||
if (nullptr == pDdiTable->pfnCreate)
|
||||
pDdiTable->pfnCreate = driver_ddiTable.core_ddiTable.Image.pfnCreate;
|
||||
pDdiTable->pfnDestroy = (ze_pfnImageDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeImageDestroy_Tracing");
|
||||
if (nullptr == pDdiTable->pfnDestroy)
|
||||
pDdiTable->pfnDestroy = driver_ddiTable.core_ddiTable.Image.pfnDestroy;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeGetModuleProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
ze_module_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
driver_ddiTable.driverLibrary = LOAD_INTEL_GPU_LIBRARY();
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
driver_ddiTable.enableTracing = getenv_tobool("ZE_ENABLE_API_TRACING");
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnCreate = (ze_pfnModuleCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleCreate");
|
||||
pDdiTable->pfnDestroy = (ze_pfnModuleDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleDestroy");
|
||||
pDdiTable->pfnGetNativeBinary = (ze_pfnModuleGetNativeBinary_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleGetNativeBinary");
|
||||
pDdiTable->pfnGetGlobalPointer = (ze_pfnModuleGetGlobalPointer_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleGetGlobalPointer");
|
||||
pDdiTable->pfnGetFunctionPointer = (ze_pfnModuleGetFunctionPointer_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleGetFunctionPointer");
|
||||
pDdiTable->pfnGetKernelNames = (ze_pfnModuleGetKernelNames_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleGetKernelNames");
|
||||
driver_ddiTable.core_ddiTable.Module = *pDdiTable;
|
||||
if (driver_ddiTable.enableTracing) {
|
||||
pDdiTable->pfnCreate = (ze_pfnModuleCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleCreate_Tracing");
|
||||
if (nullptr == pDdiTable->pfnCreate)
|
||||
pDdiTable->pfnCreate = driver_ddiTable.core_ddiTable.Module.pfnCreate;
|
||||
pDdiTable->pfnDestroy = (ze_pfnModuleDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleDestroy_Tracing");
|
||||
if (nullptr == pDdiTable->pfnDestroy)
|
||||
pDdiTable->pfnDestroy = driver_ddiTable.core_ddiTable.Module.pfnDestroy;
|
||||
pDdiTable->pfnGetNativeBinary = (ze_pfnModuleGetNativeBinary_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleGetNativeBinary_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetNativeBinary)
|
||||
pDdiTable->pfnGetNativeBinary = driver_ddiTable.core_ddiTable.Module.pfnGetNativeBinary;
|
||||
pDdiTable->pfnGetGlobalPointer = (ze_pfnModuleGetGlobalPointer_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleGetGlobalPointer_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetGlobalPointer)
|
||||
pDdiTable->pfnGetGlobalPointer = driver_ddiTable.core_ddiTable.Module.pfnGetGlobalPointer;
|
||||
pDdiTable->pfnGetFunctionPointer = (ze_pfnModuleGetFunctionPointer_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleGetFunctionPointer_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetFunctionPointer)
|
||||
pDdiTable->pfnGetFunctionPointer = driver_ddiTable.core_ddiTable.Module.pfnGetFunctionPointer;
|
||||
pDdiTable->pfnGetKernelNames = (ze_pfnModuleGetKernelNames_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleGetKernelNames_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetKernelNames)
|
||||
pDdiTable->pfnGetKernelNames = driver_ddiTable.core_ddiTable.Module.pfnGetKernelNames;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeGetModuleBuildLogProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
ze_module_build_log_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
driver_ddiTable.driverLibrary = LOAD_INTEL_GPU_LIBRARY();
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
driver_ddiTable.enableTracing = getenv_tobool("ZE_ENABLE_API_TRACING");
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnDestroy = (ze_pfnModuleBuildLogDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleBuildLogDestroy");
|
||||
pDdiTable->pfnGetString = (ze_pfnModuleBuildLogGetString_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleBuildLogGetString");
|
||||
driver_ddiTable.core_ddiTable.ModuleBuildLog = *pDdiTable;
|
||||
if (driver_ddiTable.enableTracing) {
|
||||
pDdiTable->pfnDestroy = (ze_pfnModuleBuildLogDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleBuildLogDestroy_Tracing");
|
||||
if (nullptr == pDdiTable->pfnDestroy)
|
||||
pDdiTable->pfnDestroy = driver_ddiTable.core_ddiTable.ModuleBuildLog.pfnDestroy;
|
||||
pDdiTable->pfnGetString = (ze_pfnModuleBuildLogGetString_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeModuleBuildLogGetString_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetString)
|
||||
pDdiTable->pfnGetString = driver_ddiTable.core_ddiTable.ModuleBuildLog.pfnGetString;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeGetKernelProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
ze_kernel_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
driver_ddiTable.driverLibrary = LOAD_INTEL_GPU_LIBRARY();
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
driver_ddiTable.enableTracing = getenv_tobool("ZE_ENABLE_API_TRACING");
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnSetIntermediateCacheConfig = (ze_pfnKernelSetIntermediateCacheConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelSetIntermediateCacheConfig");
|
||||
pDdiTable->pfnCreate = (ze_pfnKernelCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelCreate");
|
||||
pDdiTable->pfnDestroy = (ze_pfnKernelDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelDestroy");
|
||||
pDdiTable->pfnSetGroupSize = (ze_pfnKernelSetGroupSize_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelSetGroupSize");
|
||||
pDdiTable->pfnSuggestGroupSize = (ze_pfnKernelSuggestGroupSize_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelSuggestGroupSize");
|
||||
pDdiTable->pfnSuggestMaxCooperativeGroupCount = (ze_pfnKernelSuggestMaxCooperativeGroupCount_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelSuggestMaxCooperativeGroupCount");
|
||||
pDdiTable->pfnSetArgumentValue = (ze_pfnKernelSetArgumentValue_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelSetArgumentValue");
|
||||
pDdiTable->pfnSetAttribute = (ze_pfnKernelSetAttribute_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelSetAttribute");
|
||||
pDdiTable->pfnGetAttribute = (ze_pfnKernelGetAttribute_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelGetAttribute");
|
||||
pDdiTable->pfnGetProperties = (ze_pfnKernelGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelGetProperties");
|
||||
driver_ddiTable.core_ddiTable.Kernel = *pDdiTable;
|
||||
if (driver_ddiTable.enableTracing) {
|
||||
pDdiTable->pfnSetIntermediateCacheConfig = (ze_pfnKernelSetIntermediateCacheConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelSetIntermediateCacheConfig_Tracing");
|
||||
if (nullptr == pDdiTable->pfnSetIntermediateCacheConfig)
|
||||
pDdiTable->pfnSetIntermediateCacheConfig = driver_ddiTable.core_ddiTable.Kernel.pfnSetIntermediateCacheConfig;
|
||||
pDdiTable->pfnCreate = (ze_pfnKernelCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelCreate_Tracing");
|
||||
if (nullptr == pDdiTable->pfnCreate)
|
||||
pDdiTable->pfnCreate = driver_ddiTable.core_ddiTable.Kernel.pfnCreate;
|
||||
pDdiTable->pfnDestroy = (ze_pfnKernelDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelDestroy_Tracing");
|
||||
if (nullptr == pDdiTable->pfnDestroy)
|
||||
pDdiTable->pfnDestroy = driver_ddiTable.core_ddiTable.Kernel.pfnDestroy;
|
||||
pDdiTable->pfnSetGroupSize = (ze_pfnKernelSetGroupSize_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelSetGroupSize_Tracing");
|
||||
if (nullptr == pDdiTable->pfnSetGroupSize)
|
||||
pDdiTable->pfnSetGroupSize = driver_ddiTable.core_ddiTable.Kernel.pfnSetGroupSize;
|
||||
pDdiTable->pfnSuggestGroupSize = (ze_pfnKernelSuggestGroupSize_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelSuggestGroupSize_Tracing");
|
||||
if (nullptr == pDdiTable->pfnSuggestGroupSize)
|
||||
pDdiTable->pfnSuggestGroupSize = driver_ddiTable.core_ddiTable.Kernel.pfnSuggestGroupSize;
|
||||
pDdiTable->pfnSuggestMaxCooperativeGroupCount = (ze_pfnKernelSuggestMaxCooperativeGroupCount_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelSuggestMaxCooperativeGroupCount_Tracing");
|
||||
if (nullptr == pDdiTable->pfnSuggestMaxCooperativeGroupCount)
|
||||
pDdiTable->pfnSuggestMaxCooperativeGroupCount = driver_ddiTable.core_ddiTable.Kernel.pfnSuggestMaxCooperativeGroupCount;
|
||||
pDdiTable->pfnSetArgumentValue = (ze_pfnKernelSetArgumentValue_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelSetArgumentValue_Tracing");
|
||||
if (nullptr == pDdiTable->pfnSetArgumentValue)
|
||||
pDdiTable->pfnSetArgumentValue = driver_ddiTable.core_ddiTable.Kernel.pfnSetArgumentValue;
|
||||
pDdiTable->pfnSetAttribute = (ze_pfnKernelSetAttribute_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelSetAttribute_Tracing");
|
||||
if (nullptr == pDdiTable->pfnSetAttribute)
|
||||
pDdiTable->pfnSetAttribute = driver_ddiTable.core_ddiTable.Kernel.pfnSetAttribute;
|
||||
pDdiTable->pfnGetAttribute = (ze_pfnKernelGetAttribute_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelGetAttribute_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetAttribute)
|
||||
pDdiTable->pfnGetAttribute = driver_ddiTable.core_ddiTable.Kernel.pfnGetAttribute;
|
||||
pDdiTable->pfnGetProperties = (ze_pfnKernelGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeKernelGetProperties_Tracing");
|
||||
if (nullptr == pDdiTable->pfnGetProperties)
|
||||
pDdiTable->pfnGetProperties = driver_ddiTable.core_ddiTable.Kernel.pfnGetProperties;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeGetSamplerProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
ze_sampler_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
driver_ddiTable.driverLibrary = LOAD_INTEL_GPU_LIBRARY();
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
driver_ddiTable.enableTracing = getenv_tobool("ZE_ENABLE_API_TRACING");
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnCreate = (ze_pfnSamplerCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeSamplerCreate");
|
||||
pDdiTable->pfnDestroy = (ze_pfnSamplerDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeSamplerDestroy");
|
||||
driver_ddiTable.core_ddiTable.Sampler = *pDdiTable;
|
||||
if (driver_ddiTable.enableTracing) {
|
||||
pDdiTable->pfnCreate = (ze_pfnSamplerCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeSamplerCreate_Tracing");
|
||||
if (nullptr == pDdiTable->pfnCreate)
|
||||
pDdiTable->pfnCreate = driver_ddiTable.core_ddiTable.Sampler.pfnCreate;
|
||||
pDdiTable->pfnDestroy = (ze_pfnSamplerDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zeSamplerDestroy_Tracing");
|
||||
if (nullptr == pDdiTable->pfnDestroy)
|
||||
pDdiTable->pfnDestroy = driver_ddiTable.core_ddiTable.Sampler.pfnDestroy;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,277 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include "level_zero/core/source/driver.h"
|
||||
#include "level_zero/core/source/driver_handle.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
#include <level_zero/ze_ddi.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceGet(
|
||||
ze_driver_handle_t hDriver,
|
||||
uint32_t *pCount,
|
||||
ze_device_handle_t *phDevices) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pCount)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::DriverHandle::fromHandle(hDriver)->getDevice(pCount, phDevices);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceGetSubDevices(
|
||||
ze_device_handle_t hDevice,
|
||||
uint32_t *pCount,
|
||||
ze_device_handle_t *phSubdevices) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pCount)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->getSubDevices(pCount, phSubdevices);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceGetProperties(
|
||||
ze_device_handle_t hDevice,
|
||||
ze_device_properties_t *pDeviceProperties) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pDeviceProperties)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->getProperties(pDeviceProperties);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceGetComputeProperties(
|
||||
ze_device_handle_t hDevice,
|
||||
ze_device_compute_properties_t *pComputeProperties) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pComputeProperties)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->getComputeProperties(pComputeProperties);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceGetKernelProperties(
|
||||
ze_device_handle_t hDevice,
|
||||
ze_device_kernel_properties_t *pKernelProperties) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pKernelProperties)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->getKernelProperties(pKernelProperties);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceGetMemoryProperties(
|
||||
ze_device_handle_t hDevice,
|
||||
uint32_t *pCount,
|
||||
ze_device_memory_properties_t *pMemProperties) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pCount)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->getMemoryProperties(pCount, pMemProperties);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceGetMemoryAccessProperties(
|
||||
ze_device_handle_t hDevice,
|
||||
ze_device_memory_access_properties_t *pMemAccessProperties) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pMemAccessProperties)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->getMemoryAccessProperties(pMemAccessProperties);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceGetCacheProperties(
|
||||
ze_device_handle_t hDevice,
|
||||
ze_device_cache_properties_t *pCacheProperties) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pCacheProperties)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->getCacheProperties(pCacheProperties);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceGetImageProperties(
|
||||
ze_device_handle_t hDevice,
|
||||
ze_device_image_properties_t *pImageProperties) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pImageProperties)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->getDeviceImageProperties(pImageProperties);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceGetP2PProperties(
|
||||
ze_device_handle_t hDevice,
|
||||
ze_device_handle_t hPeerDevice,
|
||||
ze_device_p2p_properties_t *pP2PProperties) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hPeerDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pP2PProperties)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->getP2PProperties(hPeerDevice, pP2PProperties);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceCanAccessPeer(
|
||||
ze_device_handle_t hDevice,
|
||||
ze_device_handle_t hPeerDevice,
|
||||
ze_bool_t *value) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hPeerDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == value)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->canAccessPeer(hPeerDevice, value);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceSetLastLevelCacheConfig(
|
||||
ze_device_handle_t hDevice,
|
||||
ze_cache_config_t cacheConfig) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->setLastLevelCacheConfig(cacheConfig);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/driver.h"
|
||||
#include "level_zero/core/source/driver_handle.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeInit(
|
||||
ze_init_flag_t flags) {
|
||||
try {
|
||||
{
|
||||
}
|
||||
return L0::init(flags);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDriverGet(
|
||||
uint32_t *pCount,
|
||||
ze_driver_handle_t *phDrivers) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == pCount)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::driverHandleGet(pCount, phDrivers);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDriverGetProperties(
|
||||
ze_driver_handle_t hDriver,
|
||||
ze_driver_properties_t *pProperties) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pProperties)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::DriverHandle::fromHandle(hDriver)->getProperties(pProperties);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDriverGetApiVersion(
|
||||
ze_driver_handle_t hDriver,
|
||||
ze_api_version_t *version) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == version)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::DriverHandle::fromHandle(hDriver)->getApiVersion(version);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDriverGetIPCProperties(
|
||||
ze_driver_handle_t hDriver,
|
||||
ze_driver_ipc_properties_t *pIPCProperties) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pIPCProperties)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::DriverHandle::fromHandle(hDriver)->getIPCProperties(pIPCProperties);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDriverGetExtensionFunctionAddress(
|
||||
ze_driver_handle_t hDriver,
|
||||
const char *pFuncName,
|
||||
void **pfunc) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pFuncName)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pfunc)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::DriverHandle::fromHandle(hDriver)->getExtensionFunctionAddress(pFuncName, pfunc);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,325 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/event.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeEventPoolCreate(
|
||||
ze_driver_handle_t hDriver,
|
||||
const ze_event_pool_desc_t *desc,
|
||||
uint32_t numDevices,
|
||||
ze_device_handle_t *phDevices,
|
||||
ze_event_pool_handle_t *phEventPool) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == desc)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phEventPool)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (ZE_EVENT_POOL_DESC_VERSION_CURRENT < desc->version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return L0::DriverHandle::fromHandle(hDriver)->createEventPool(desc, numDevices, phDevices, phEventPool);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeEventPoolDestroy(
|
||||
ze_event_pool_handle_t hEventPool) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hEventPool)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::EventPool::fromHandle(hEventPool)->destroy();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeEventCreate(
|
||||
ze_event_pool_handle_t hEventPool,
|
||||
const ze_event_desc_t *desc,
|
||||
ze_event_handle_t *phEvent) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hEventPool)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == desc)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phEvent)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (ZE_EVENT_DESC_VERSION_CURRENT < desc->version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return L0::eventCreate(hEventPool, desc, phEvent);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeEventDestroy(
|
||||
ze_event_handle_t hEvent) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hEvent)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::eventDestroy(hEvent);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeEventPoolGetIpcHandle(
|
||||
ze_event_pool_handle_t hEventPool,
|
||||
ze_ipc_event_pool_handle_t *phIpc) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hEventPool)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phIpc)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::EventPool::fromHandle(hEventPool)->getIpcHandle(phIpc);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeEventPoolOpenIpcHandle(
|
||||
ze_driver_handle_t hDriver,
|
||||
ze_ipc_event_pool_handle_t hIpc,
|
||||
ze_event_pool_handle_t *phEventPool) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phEventPool)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::eventPoolOpenIpcHandle(hDriver, hIpc, phEventPool);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeEventPoolCloseIpcHandle(
|
||||
ze_event_pool_handle_t hEventPool) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hEventPool)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::EventPool::fromHandle(hEventPool)->closeIpcHandle();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendSignalEvent(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
ze_event_handle_t hEvent) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hEvent)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendSignalEvent(hEvent);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendWaitOnEvents(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
uint32_t numEvents,
|
||||
ze_event_handle_t *phEvents) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phEvents)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendWaitOnEvents(numEvents, phEvents);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeEventHostSignal(
|
||||
ze_event_handle_t hEvent) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hEvent)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Event::fromHandle(hEvent)->hostSignal();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeEventHostSynchronize(
|
||||
ze_event_handle_t hEvent,
|
||||
uint32_t timeout) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hEvent)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Event::fromHandle(hEvent)->hostSynchronize(timeout);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeEventQueryStatus(
|
||||
ze_event_handle_t hEvent) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hEvent)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Event::fromHandle(hEvent)->queryStatus();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendEventReset(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
ze_event_handle_t hEvent) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hEvent)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendEventReset(hEvent);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeEventHostReset(
|
||||
ze_event_handle_t hEvent) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hEvent)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Event::fromHandle(hEvent)->reset();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeEventGetTimestamp(
|
||||
ze_event_handle_t hEvent,
|
||||
ze_event_timestamp_type_t timestampType,
|
||||
void *dstptr) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hEvent)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == dstptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Event::fromHandle(hEvent)->getTimestamp(timestampType, dstptr);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/fence.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeFenceCreate(
|
||||
ze_command_queue_handle_t hCommandQueue,
|
||||
const ze_fence_desc_t *desc,
|
||||
ze_fence_handle_t *phFence) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandQueue)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == desc)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phFence)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (ZE_FENCE_DESC_VERSION_CURRENT < desc->version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return L0::fenceCreate(hCommandQueue, desc, phFence);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeFenceDestroy(
|
||||
ze_fence_handle_t hFence) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hFence)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::fenceDestroy(hFence);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeFenceHostSynchronize(
|
||||
ze_fence_handle_t hFence,
|
||||
uint32_t timeout) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hFence)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Fence::fromHandle(hFence)->hostSynchronize(timeout);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeFenceQueryStatus(
|
||||
ze_fence_handle_t hFence) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hFence)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Fence::fromHandle(hFence)->queryStatus();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeFenceReset(
|
||||
ze_fence_handle_t hFence) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hFence)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Fence::fromHandle(hFence)->reset();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/image.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeImageGetProperties(
|
||||
ze_device_handle_t hDevice,
|
||||
const ze_image_desc_t *desc,
|
||||
ze_image_properties_t *pImageProperties) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == desc)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pImageProperties)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (ZE_IMAGE_DESC_VERSION_CURRENT < desc->version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->imageGetProperties(desc, pImageProperties);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeImageCreate(
|
||||
ze_device_handle_t hDevice,
|
||||
const ze_image_desc_t *desc,
|
||||
ze_image_handle_t *phImage) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == desc)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phImage)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (ZE_IMAGE_DESC_VERSION_CURRENT < desc->version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->createImage(desc, phImage);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeImageDestroy(
|
||||
ze_image_handle_t hImage) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hImage)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Image::fromHandle(hImage)->destroy();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,234 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/driver_handle.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDriverAllocSharedMem(
|
||||
ze_driver_handle_t hDriver,
|
||||
const ze_device_mem_alloc_desc_t *deviceDesc,
|
||||
const ze_host_mem_alloc_desc_t *hostDesc,
|
||||
size_t size,
|
||||
size_t alignment,
|
||||
ze_device_handle_t hDevice,
|
||||
void **pptr) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::DriverHandle::fromHandle(hDriver)->allocSharedMem(hDevice, deviceDesc->flags, hostDesc->flags, size, alignment, pptr);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDriverAllocDeviceMem(
|
||||
ze_driver_handle_t hDriver,
|
||||
const ze_device_mem_alloc_desc_t *deviceDesc,
|
||||
size_t size,
|
||||
size_t alignment,
|
||||
ze_device_handle_t hDevice,
|
||||
void **pptr) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::DriverHandle::fromHandle(hDriver)->allocDeviceMem(hDevice, deviceDesc->flags, size, alignment, pptr);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDriverAllocHostMem(
|
||||
ze_driver_handle_t hDriver,
|
||||
const ze_host_mem_alloc_desc_t *hostDesc,
|
||||
size_t size,
|
||||
size_t alignment,
|
||||
void **pptr) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::DriverHandle::fromHandle(hDriver)->allocHostMem(hostDesc->flags, size, alignment, pptr);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDriverFreeMem(
|
||||
ze_driver_handle_t hDriver,
|
||||
void *ptr) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == ptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::DriverHandle::fromHandle(hDriver)->freeMem(ptr);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDriverGetMemAllocProperties(
|
||||
ze_driver_handle_t hDriver,
|
||||
const void *ptr,
|
||||
ze_memory_allocation_properties_t *pMemAllocProperties,
|
||||
ze_device_handle_t *phDevice) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pMemAllocProperties)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == ptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::DriverHandle::fromHandle(hDriver)->getMemAllocProperties(ptr, pMemAllocProperties, phDevice);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDriverGetMemAddressRange(
|
||||
ze_driver_handle_t hDriver,
|
||||
const void *ptr,
|
||||
void **pBase,
|
||||
size_t *pSize) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == ptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::DriverHandle::fromHandle(hDriver)->getMemAddressRange(ptr, pBase, pSize);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDriverGetMemIpcHandle(
|
||||
ze_driver_handle_t hDriver,
|
||||
const void *ptr,
|
||||
ze_ipc_mem_handle_t *pIpcHandle) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pIpcHandle)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == ptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::DriverHandle::fromHandle(hDriver)->getIpcMemHandle(ptr, pIpcHandle);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDriverOpenMemIpcHandle(
|
||||
ze_driver_handle_t hDriver,
|
||||
ze_device_handle_t hDevice,
|
||||
ze_ipc_mem_handle_t handle,
|
||||
ze_ipc_memory_flag_t flags,
|
||||
void **pptr) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::DriverHandle::fromHandle(hDriver)->openIpcMemHandle(hDevice, handle, flags, pptr);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDriverCloseMemIpcHandle(
|
||||
ze_driver_handle_t hDriver,
|
||||
const void *ptr) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDriver)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == ptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::DriverHandle::fromHandle(hDriver)->closeIpcMemHandle(ptr);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,521 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/module.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeModuleCreate(
|
||||
ze_device_handle_t hDevice,
|
||||
const ze_module_desc_t *desc,
|
||||
ze_module_handle_t *phModule,
|
||||
ze_module_build_log_handle_t *phBuildLog) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == desc)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phModule)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (ZE_MODULE_DESC_VERSION_CURRENT < desc->version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->createModule(desc, phModule, phBuildLog);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeModuleDestroy(
|
||||
ze_module_handle_t hModule) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hModule)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Module::fromHandle(hModule)->destroy();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeModuleBuildLogDestroy(
|
||||
ze_module_build_log_handle_t hModuleBuildLog) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hModuleBuildLog)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::moduleBuildLogDestroy(hModuleBuildLog);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeModuleBuildLogGetString(
|
||||
ze_module_build_log_handle_t hModuleBuildLog,
|
||||
size_t *pSize,
|
||||
char *pBuildLog) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hModuleBuildLog)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pSize)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::ModuleBuildLog::fromHandle(hModuleBuildLog)->getString(pSize, pBuildLog);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeModuleGetNativeBinary(
|
||||
ze_module_handle_t hModule,
|
||||
size_t *pSize,
|
||||
uint8_t *pModuleNativeBinary) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hModule)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pSize)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Module::fromHandle(hModule)->getNativeBinary(pSize, pModuleNativeBinary);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeModuleGetGlobalPointer(
|
||||
ze_module_handle_t hModule,
|
||||
const char *pGlobalName,
|
||||
void **pptr) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hModule)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pGlobalName)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Module::fromHandle(hModule)->getGlobalPointer(pGlobalName, pptr);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeModuleGetKernelNames(
|
||||
ze_module_handle_t hModule,
|
||||
uint32_t *pCount,
|
||||
const char **pNames) {
|
||||
if (nullptr == hModule) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
if (nullptr == pCount) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Module::fromHandle(hModule)->getKernelNames(pCount, pNames);
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeKernelCreate(
|
||||
ze_module_handle_t hModule,
|
||||
const ze_kernel_desc_t *desc,
|
||||
ze_kernel_handle_t *phFunction) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hModule)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == desc)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phFunction)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (ZE_KERNEL_DESC_VERSION_CURRENT < desc->version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return L0::Module::fromHandle(hModule)->createKernel(desc, phFunction);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeKernelDestroy(
|
||||
ze_kernel_handle_t hKernel) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hKernel)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Kernel::fromHandle(hKernel)->destroy();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeModuleGetFunctionPointer(
|
||||
ze_module_handle_t hModule,
|
||||
const char *pKernelName,
|
||||
void **pfnFunction) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hModule)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pKernelName)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pfnFunction)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Module::fromHandle(hModule)->getFunctionPointer(pKernelName, pfnFunction);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeKernelSetGroupSize(
|
||||
ze_kernel_handle_t hFunction,
|
||||
uint32_t groupSizeX,
|
||||
uint32_t groupSizeY,
|
||||
uint32_t groupSizeZ) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hFunction)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Kernel::fromHandle(hFunction)->setGroupSize(groupSizeX, groupSizeY, groupSizeZ);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeKernelSuggestGroupSize(
|
||||
ze_kernel_handle_t hFunction,
|
||||
uint32_t globalSizeX,
|
||||
uint32_t globalSizeY,
|
||||
uint32_t globalSizeZ,
|
||||
uint32_t *groupSizeX,
|
||||
uint32_t *groupSizeY,
|
||||
uint32_t *groupSizeZ) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hFunction)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == groupSizeX)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == groupSizeY)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == groupSizeZ)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Kernel::fromHandle(hFunction)->suggestGroupSize(globalSizeX, globalSizeY, globalSizeZ, groupSizeX, groupSizeY, groupSizeZ);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeKernelSuggestMaxCooperativeGroupCount(
|
||||
ze_kernel_handle_t hKernel,
|
||||
uint32_t *totalGroupCount) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hKernel)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == totalGroupCount)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
(*totalGroupCount) = L0::Kernel::fromHandle(hKernel)->suggestMaxCooperativeGroupCount();
|
||||
return ZE_RESULT_SUCCESS;
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeFunctionSuggestMaxCooperativeGroupCount(
|
||||
ze_kernel_handle_t hFunction,
|
||||
uint32_t *groupCountX,
|
||||
uint32_t *groupCountY,
|
||||
uint32_t *groupCountZ);
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeKernelSetArgumentValue(
|
||||
ze_kernel_handle_t hFunction,
|
||||
uint32_t argIndex,
|
||||
size_t argSize,
|
||||
const void *pArgValue) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hFunction)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Kernel::fromHandle(hFunction)->setArgumentValue(argIndex, argSize, pArgValue);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeKernelSetAttribute(
|
||||
ze_kernel_handle_t hKernel,
|
||||
ze_kernel_attribute_t attr,
|
||||
uint32_t size,
|
||||
const void *pValue) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hKernel)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Kernel::fromHandle(hKernel)->setAttribute(attr, size, pValue);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeKernelGetAttribute(
|
||||
ze_kernel_handle_t hKernel,
|
||||
ze_kernel_attribute_t attr,
|
||||
uint32_t *pSize,
|
||||
void *pValue) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hKernel)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Kernel::fromHandle(hKernel)->getAttribute(attr, pSize, pValue);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeKernelSetIntermediateCacheConfig(
|
||||
ze_kernel_handle_t hKernel,
|
||||
ze_cache_config_t cacheConfig) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hKernel)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Kernel::fromHandle(hKernel)->setIntermediateCacheConfig(cacheConfig);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeKernelGetProperties(
|
||||
ze_kernel_handle_t hKernel,
|
||||
ze_kernel_properties_t *pKernelProperties) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hKernel)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pKernelProperties)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Kernel::fromHandle(hKernel)->getProperties(pKernelProperties);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendLaunchKernel(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
ze_kernel_handle_t hFunction,
|
||||
const ze_group_count_t *pLaunchFuncArgs,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hFunction)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pLaunchFuncArgs)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendLaunchFunction(hFunction, pLaunchFuncArgs, hSignalEvent, numWaitEvents, phWaitEvents);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendLaunchCooperativeKernel(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
ze_kernel_handle_t hKernel,
|
||||
const ze_group_count_t *pLaunchFuncArgs,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hKernel)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pLaunchFuncArgs)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendLaunchCooperativeKernel(hKernel, pLaunchFuncArgs, hSignalEvent, numWaitEvents, phWaitEvents);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendLaunchKernelIndirect(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
ze_kernel_handle_t hFunction,
|
||||
const ze_group_count_t *pLaunchArgumentsBuffer,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hFunction)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendLaunchFunctionIndirect(hFunction, pLaunchArgumentsBuffer, hSignalEvent, numWaitEvents, phWaitEvents);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeCommandListAppendLaunchMultipleKernelsIndirect(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
uint32_t numFunctions,
|
||||
ze_kernel_handle_t *phFunctions,
|
||||
const uint32_t *pCountBuffer,
|
||||
const ze_group_count_t *pLaunchArgumentsBuffer,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phFunctions)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pCountBuffer)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pLaunchArgumentsBuffer)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendLaunchMultipleFunctionsIndirect(numFunctions, phFunctions, pCountBuffer, pLaunchArgumentsBuffer, hSignalEvent, numWaitEvents, phWaitEvents);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceMakeMemoryResident(
|
||||
ze_device_handle_t hDevice,
|
||||
void *ptr,
|
||||
size_t size) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == ptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->makeMemoryResident(ptr, size);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceEvictMemory(
|
||||
ze_device_handle_t hDevice,
|
||||
void *ptr,
|
||||
size_t size) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == ptr)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->evictMemory(ptr, size);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceMakeImageResident(
|
||||
ze_device_handle_t hDevice,
|
||||
ze_image_handle_t hImage) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hImage)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->makeImageResident(hImage);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeDeviceEvictImage(
|
||||
ze_device_handle_t hDevice,
|
||||
ze_image_handle_t hImage) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hImage)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->evictImage(hImage);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/sampler.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeSamplerCreate(
|
||||
ze_device_handle_t hDevice,
|
||||
const ze_sampler_desc_t *desc,
|
||||
ze_sampler_handle_t *phSampler) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == desc)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phSampler)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (ZE_SAMPLER_DESC_VERSION_CURRENT < desc->version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->createSampler(desc, phSampler);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zeSamplerDestroy(
|
||||
ze_sampler_handle_t hSampler) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hSampler)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Sampler::fromHandle(hSampler)->destroy();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_EXPERIMENTAL_API
|
||||
)
|
||||
|
||||
set_property(GLOBAL PROPERTY L0_EXPERIMENTAL_API ${L0_EXPERIMENTAL_API})
|
|
@ -0,0 +1,15 @@
|
|||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_TOOLS_API
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ze_tools_loader.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zet_metric.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zet_sysman.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zet_tracing.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zet_driver.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zet_module.cpp
|
||||
)
|
||||
set_property(GLOBAL PROPERTY L0_TOOLS_API ${L0_TOOLS_API})
|
|
@ -0,0 +1,555 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/source/inc/ze_intel_gpu.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
#include <level_zero/ze_ddi.h>
|
||||
#include <level_zero/zet_api.h>
|
||||
#include <level_zero/zet_ddi.h>
|
||||
|
||||
#include "ze_ddi_tables.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
extern ze_gpu_driver_dditable_t driver_ddiTable;
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetGlobalProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_global_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnInit = (zet_pfnInit_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetInit");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetDeviceProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_device_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnActivateMetricGroups = (zet_pfnDeviceActivateMetricGroups_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetDeviceActivateMetricGroups");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetCommandListProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_command_list_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnAppendMetricTracerMarker = (zet_pfnCommandListAppendMetricTracerMarker_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetCommandListAppendMetricTracerMarker");
|
||||
pDdiTable->pfnAppendMetricQueryBegin = (zet_pfnCommandListAppendMetricQueryBegin_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetCommandListAppendMetricQueryBegin");
|
||||
pDdiTable->pfnAppendMetricQueryEnd = (zet_pfnCommandListAppendMetricQueryEnd_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetCommandListAppendMetricQueryEnd");
|
||||
pDdiTable->pfnAppendMetricMemoryBarrier = (zet_pfnCommandListAppendMetricMemoryBarrier_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetCommandListAppendMetricMemoryBarrier");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetModuleProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_module_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetDebugInfo = (zet_pfnModuleGetDebugInfo_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetModuleGetDebugInfo");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetKernelProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_kernel_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetProfileInfo = (zet_pfnKernelGetProfileInfo_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetKernelGetProfileInfo");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetMetricGroupProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_metric_group_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGet = (zet_pfnMetricGroupGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetMetricGroupGet");
|
||||
pDdiTable->pfnGetProperties = (zet_pfnMetricGroupGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetMetricGroupGetProperties");
|
||||
pDdiTable->pfnCalculateMetricValues = (zet_pfnMetricGroupCalculateMetricValues_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetMetricGroupCalculateMetricValues");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetMetricProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_metric_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGet = (zet_pfnMetricGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetMetricGet");
|
||||
pDdiTable->pfnGetProperties = (zet_pfnMetricGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetMetricGetProperties");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetMetricTracerProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_metric_tracer_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnOpen = (zet_pfnMetricTracerOpen_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetMetricTracerOpen");
|
||||
pDdiTable->pfnClose = (zet_pfnMetricTracerClose_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetMetricTracerClose");
|
||||
pDdiTable->pfnReadData = (zet_pfnMetricTracerReadData_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetMetricTracerReadData");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetMetricQueryPoolProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_metric_query_pool_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnCreate = (zet_pfnMetricQueryPoolCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetMetricQueryPoolCreate");
|
||||
pDdiTable->pfnDestroy = (zet_pfnMetricQueryPoolDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetMetricQueryPoolDestroy");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetMetricQueryProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_metric_query_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnCreate = (zet_pfnMetricQueryCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetMetricQueryCreate");
|
||||
pDdiTable->pfnDestroy = (zet_pfnMetricQueryDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetMetricQueryDestroy");
|
||||
pDdiTable->pfnReset = (zet_pfnMetricQueryReset_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetMetricQueryReset");
|
||||
pDdiTable->pfnGetData = (zet_pfnMetricQueryGetData_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetMetricQueryGetData");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetTracerProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_tracer_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnCreate = (zet_pfnTracerCreate_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetTracerCreate");
|
||||
pDdiTable->pfnDestroy = (zet_pfnTracerDestroy_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetTracerDestroy");
|
||||
pDdiTable->pfnSetPrologues = (zet_pfnTracerSetPrologues_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetTracerSetPrologues");
|
||||
pDdiTable->pfnSetEpilogues = (zet_pfnTracerSetEpilogues_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetTracerSetEpilogues");
|
||||
pDdiTable->pfnSetEnabled = (zet_pfnTracerSetEnabled_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetTracerSetEnabled");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetSysmanProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_sysman_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGet = (zet_pfnSysmanGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanGet");
|
||||
pDdiTable->pfnDeviceGetProperties = (zet_pfnSysmanDeviceGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanDeviceGetProperties");
|
||||
pDdiTable->pfnSchedulerGetSupportedModes = (zet_pfnSysmanSchedulerGetSupportedModes_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanSchedulerGetSupportedModes");
|
||||
pDdiTable->pfnSchedulerGetCurrentMode = (zet_pfnSysmanSchedulerGetCurrentMode_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanSchedulerGetCurrentMode");
|
||||
pDdiTable->pfnSchedulerGetTimeoutModeProperties = (zet_pfnSysmanSchedulerGetTimeoutModeProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanSchedulerGetTimeoutModeProperties");
|
||||
pDdiTable->pfnSchedulerGetTimesliceModeProperties = (zet_pfnSysmanSchedulerGetTimesliceModeProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanSchedulerGetTimesliceModeProperties");
|
||||
pDdiTable->pfnSchedulerSetTimeoutMode = (zet_pfnSysmanSchedulerSetTimeoutMode_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanSchedulerSetTimeoutMode");
|
||||
pDdiTable->pfnSchedulerSetTimesliceMode = (zet_pfnSysmanSchedulerSetTimesliceMode_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanSchedulerSetTimesliceMode");
|
||||
pDdiTable->pfnSchedulerSetExclusiveMode = (zet_pfnSysmanSchedulerSetExclusiveMode_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanSchedulerSetExclusiveMode");
|
||||
pDdiTable->pfnSchedulerSetComputeUnitDebugMode = (zet_pfnSysmanSchedulerSetComputeUnitDebugMode_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanSchedulerSetComputeUnitDebugMode");
|
||||
pDdiTable->pfnPerformanceProfileGetSupported = (zet_pfnSysmanPerformanceProfileGetSupported_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPerformanceProfileGetSupported");
|
||||
pDdiTable->pfnPerformanceProfileGet = (zet_pfnSysmanPerformanceProfileGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPerformanceProfileGet");
|
||||
pDdiTable->pfnPerformanceProfileSet = (zet_pfnSysmanPerformanceProfileSet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPerformanceProfileSet");
|
||||
pDdiTable->pfnProcessesGetState = (zet_pfnSysmanProcessesGetState_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanProcessesGetState");
|
||||
pDdiTable->pfnDeviceReset = (zet_pfnSysmanDeviceReset_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanDeviceReset");
|
||||
pDdiTable->pfnDeviceGetRepairStatus = (zet_pfnSysmanDeviceGetRepairStatus_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanDeviceGetRepairStatus");
|
||||
pDdiTable->pfnPciGetProperties = (zet_pfnSysmanPciGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPciGetProperties");
|
||||
pDdiTable->pfnPciGetState = (zet_pfnSysmanPciGetState_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPciGetState");
|
||||
pDdiTable->pfnPciGetBars = (zet_pfnSysmanPciGetBars_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPciGetBars");
|
||||
pDdiTable->pfnPciGetStats = (zet_pfnSysmanPciGetStats_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPciGetStats");
|
||||
pDdiTable->pfnPowerGet = (zet_pfnSysmanPowerGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPowerGet");
|
||||
pDdiTable->pfnFrequencyGet = (zet_pfnSysmanFrequencyGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFrequencyGet");
|
||||
pDdiTable->pfnEngineGet = (zet_pfnSysmanEngineGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanEngineGet");
|
||||
pDdiTable->pfnStandbyGet = (zet_pfnSysmanStandbyGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanStandbyGet");
|
||||
pDdiTable->pfnFirmwareGet = (zet_pfnSysmanFirmwareGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFirmwareGet");
|
||||
pDdiTable->pfnMemoryGet = (zet_pfnSysmanMemoryGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanMemoryGet");
|
||||
pDdiTable->pfnFabricPortGet = (zet_pfnSysmanFabricPortGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFabricPortGet");
|
||||
pDdiTable->pfnTemperatureGet = (zet_pfnSysmanTemperatureGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanTemperatureGet");
|
||||
pDdiTable->pfnPsuGet = (zet_pfnSysmanPsuGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPsuGet");
|
||||
pDdiTable->pfnFanGet = (zet_pfnSysmanFanGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFanGet");
|
||||
pDdiTable->pfnLedGet = (zet_pfnSysmanLedGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanLedGet");
|
||||
pDdiTable->pfnRasGet = (zet_pfnSysmanRasGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanRasGet");
|
||||
pDdiTable->pfnEventGet = (zet_pfnSysmanEventGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanEventGet");
|
||||
pDdiTable->pfnDiagnosticsGet = (zet_pfnSysmanDiagnosticsGet_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanDiagnosticsGet");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetSysmanPowerProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_sysman_power_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetProperties = (zet_pfnSysmanPowerGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPowerGetProperties");
|
||||
pDdiTable->pfnGetEnergyCounter = (zet_pfnSysmanPowerGetEnergyCounter_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPowerGetEnergyCounter");
|
||||
pDdiTable->pfnGetLimits = (zet_pfnSysmanPowerGetLimits_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPowerGetLimits");
|
||||
pDdiTable->pfnSetLimits = (zet_pfnSysmanPowerSetLimits_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPowerSetLimits");
|
||||
pDdiTable->pfnGetEnergyThreshold = (zet_pfnSysmanPowerGetEnergyThreshold_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPowerGetEnergyThreshold");
|
||||
pDdiTable->pfnSetEnergyThreshold = (zet_pfnSysmanPowerSetEnergyThreshold_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPowerSetEnergyThreshold");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetSysmanFrequencyProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_sysman_frequency_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetProperties = (zet_pfnSysmanFrequencyGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFrequencyGetProperties");
|
||||
pDdiTable->pfnGetAvailableClocks = (zet_pfnSysmanFrequencyGetAvailableClocks_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFrequencyGetAvailableClocks");
|
||||
pDdiTable->pfnGetRange = (zet_pfnSysmanFrequencyGetRange_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFrequencyGetRange");
|
||||
pDdiTable->pfnSetRange = (zet_pfnSysmanFrequencySetRange_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFrequencySetRange");
|
||||
pDdiTable->pfnGetState = (zet_pfnSysmanFrequencyGetState_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFrequencyGetState");
|
||||
pDdiTable->pfnGetThrottleTime = (zet_pfnSysmanFrequencyGetThrottleTime_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFrequencyGetThrottleTime");
|
||||
pDdiTable->pfnOcGetCapabilities = (zet_pfnSysmanFrequencyOcGetCapabilities_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFrequencyOcGetCapabilities");
|
||||
pDdiTable->pfnOcGetConfig = (zet_pfnSysmanFrequencyOcGetConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFrequencyOcGetConfig");
|
||||
pDdiTable->pfnOcSetConfig = (zet_pfnSysmanFrequencyOcSetConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFrequencyOcSetConfig");
|
||||
pDdiTable->pfnOcGetIccMax = (zet_pfnSysmanFrequencyOcGetIccMax_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFrequencyOcGetIccMax");
|
||||
pDdiTable->pfnOcSetIccMax = (zet_pfnSysmanFrequencyOcSetIccMax_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFrequencyOcSetIccMax");
|
||||
pDdiTable->pfnOcGetTjMax = (zet_pfnSysmanFrequencyOcGetTjMax_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFrequencyOcGetTjMax");
|
||||
pDdiTable->pfnOcSetTjMax = (zet_pfnSysmanFrequencyOcSetTjMax_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFrequencyOcSetTjMax");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetSysmanEngineProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_sysman_engine_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetProperties = (zet_pfnSysmanEngineGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanEngineGetProperties");
|
||||
pDdiTable->pfnGetActivity = (zet_pfnSysmanEngineGetActivity_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanEngineGetActivity");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetSysmanStandbyProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_sysman_standby_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetProperties = (zet_pfnSysmanStandbyGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanStandbyGetProperties");
|
||||
pDdiTable->pfnGetMode = (zet_pfnSysmanStandbyGetMode_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanStandbyGetMode");
|
||||
pDdiTable->pfnSetMode = (zet_pfnSysmanStandbySetMode_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanStandbySetMode");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetSysmanFirmwareProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_sysman_firmware_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetProperties = (zet_pfnSysmanFirmwareGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFirmwareGetProperties");
|
||||
pDdiTable->pfnGetChecksum = (zet_pfnSysmanFirmwareGetChecksum_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFirmwareGetChecksum");
|
||||
pDdiTable->pfnFlash = (zet_pfnSysmanFirmwareFlash_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFirmwareFlash");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetSysmanMemoryProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_sysman_memory_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetProperties = (zet_pfnSysmanMemoryGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanMemoryGetProperties");
|
||||
pDdiTable->pfnGetState = (zet_pfnSysmanMemoryGetState_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanMemoryGetState");
|
||||
pDdiTable->pfnGetBandwidth = (zet_pfnSysmanMemoryGetBandwidth_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanMemoryGetBandwidth");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetSysmanFabricPortProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_sysman_fabric_port_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetProperties = (zet_pfnSysmanFabricPortGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFabricPortGetProperties");
|
||||
pDdiTable->pfnGetLinkType = (zet_pfnSysmanFabricPortGetLinkType_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFabricPortGetLinkType");
|
||||
pDdiTable->pfnGetConfig = (zet_pfnSysmanFabricPortGetConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFabricPortGetConfig");
|
||||
pDdiTable->pfnSetConfig = (zet_pfnSysmanFabricPortSetConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFabricPortSetConfig");
|
||||
pDdiTable->pfnGetState = (zet_pfnSysmanFabricPortGetState_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFabricPortGetState");
|
||||
pDdiTable->pfnGetThroughput = (zet_pfnSysmanFabricPortGetThroughput_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFabricPortGetThroughput");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetSysmanTemperatureProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_sysman_temperature_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetProperties = (zet_pfnSysmanTemperatureGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanTemperatureGetProperties");
|
||||
pDdiTable->pfnGetConfig = (zet_pfnSysmanTemperatureGetConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanTemperatureGetConfig");
|
||||
pDdiTable->pfnSetConfig = (zet_pfnSysmanTemperatureSetConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanTemperatureSetConfig");
|
||||
pDdiTable->pfnGetState = (zet_pfnSysmanTemperatureGetState_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanTemperatureGetState");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetSysmanPsuProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_sysman_psu_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetProperties = (zet_pfnSysmanPsuGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPsuGetProperties");
|
||||
pDdiTable->pfnGetState = (zet_pfnSysmanPsuGetState_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanPsuGetState");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetSysmanFanProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_sysman_fan_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetProperties = (zet_pfnSysmanFanGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFanGetProperties");
|
||||
pDdiTable->pfnGetConfig = (zet_pfnSysmanFanGetConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFanGetConfig");
|
||||
pDdiTable->pfnSetConfig = (zet_pfnSysmanFanSetConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFanSetConfig");
|
||||
pDdiTable->pfnGetState = (zet_pfnSysmanFanGetState_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanFanGetState");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetSysmanLedProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_sysman_led_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetProperties = (zet_pfnSysmanLedGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanLedGetProperties");
|
||||
pDdiTable->pfnGetState = (zet_pfnSysmanLedGetState_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanLedGetState");
|
||||
pDdiTable->pfnSetState = (zet_pfnSysmanLedSetState_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanLedSetState");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetSysmanRasProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_sysman_ras_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetProperties = (zet_pfnSysmanRasGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanRasGetProperties");
|
||||
pDdiTable->pfnGetConfig = (zet_pfnSysmanRasGetConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanRasGetConfig");
|
||||
pDdiTable->pfnSetConfig = (zet_pfnSysmanRasSetConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanRasSetConfig");
|
||||
pDdiTable->pfnGetState = (zet_pfnSysmanRasGetState_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanRasGetState");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetSysmanDiagnosticsProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_sysman_diagnostics_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetProperties = (zet_pfnSysmanDiagnosticsGetProperties_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanDiagnosticsGetProperties");
|
||||
pDdiTable->pfnGetTests = (zet_pfnSysmanDiagnosticsGetTests_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanDiagnosticsGetTests");
|
||||
pDdiTable->pfnRunTests = (zet_pfnSysmanDiagnosticsRunTests_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanDiagnosticsRunTests");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetSysmanEventProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_sysman_event_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnGetConfig = (zet_pfnSysmanEventGetConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanEventGetConfig");
|
||||
pDdiTable->pfnSetConfig = (zet_pfnSysmanEventSetConfig_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanEventSetConfig");
|
||||
pDdiTable->pfnGetState = (zet_pfnSysmanEventGetState_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanEventGetState");
|
||||
pDdiTable->pfnListen = (zet_pfnSysmanEventListen_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetSysmanEventListen");
|
||||
return result;
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetGetDebugProcAddrTable(
|
||||
ze_api_version_t version,
|
||||
zet_debug_dditable_t *pDdiTable) {
|
||||
if (nullptr == pDdiTable)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (driver_ddiTable.version < version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (nullptr == driver_ddiTable.driverLibrary) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
pDdiTable->pfnAttach = (zet_pfnDebugAttach_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetDebugAttach");
|
||||
pDdiTable->pfnDetach = (zet_pfnDebugDetach_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetDebugDetach");
|
||||
pDdiTable->pfnGetNumThreads = (zet_pfnDebugGetNumThreads_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetDebugGetNumThreads");
|
||||
pDdiTable->pfnReadEvent = (zet_pfnDebugReadEvent_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetDebugReadEvent");
|
||||
pDdiTable->pfnInterrupt = (zet_pfnDebugInterrupt_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetDebugInterrupt");
|
||||
pDdiTable->pfnResume = (zet_pfnDebugResume_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetDebugResume");
|
||||
pDdiTable->pfnReadMemory = (zet_pfnDebugReadMemory_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetDebugReadMemory");
|
||||
pDdiTable->pfnWriteMemory = (zet_pfnDebugWriteMemory_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetDebugWriteMemory");
|
||||
pDdiTable->pfnReadState = (zet_pfnDebugReadState_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetDebugReadState");
|
||||
pDdiTable->pfnWriteState = (zet_pfnDebugWriteState_t)GET_FUNCTION_PTR(driver_ddiTable.driverLibrary, "zetDebugWriteState");
|
||||
return result;
|
||||
}
|
||||
};
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/source/tools_init.h"
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetInit(
|
||||
ze_init_flag_t flags) {
|
||||
try {
|
||||
{
|
||||
}
|
||||
return L0::ToolsInit::get()->initTools(flags);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,428 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/cmdlist.h"
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include "level_zero/tools/source/metrics/metric.h"
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetMetricGroupGet(
|
||||
zet_device_handle_t hDevice,
|
||||
uint32_t *pCount,
|
||||
zet_metric_group_handle_t *phMetricGroups) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pCount)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::metricGroupGet(hDevice, pCount, phMetricGroups);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetMetricGroupGetProperties(
|
||||
zet_metric_group_handle_t hMetricGroup,
|
||||
zet_metric_group_properties_t *pProperties) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hMetricGroup)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pProperties)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::MetricGroup::fromHandle(hMetricGroup)->getProperties(pProperties);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetMetricGet(
|
||||
zet_metric_group_handle_t hMetricGroup,
|
||||
uint32_t *pCount,
|
||||
zet_metric_handle_t *phMetrics) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hMetricGroup)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pCount)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::metricGet(hMetricGroup, pCount, phMetrics);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetMetricGetProperties(
|
||||
zet_metric_handle_t hMetric,
|
||||
zet_metric_properties_t *pProperties) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hMetric)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pProperties)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Metric::fromHandle(hMetric)->getProperties(pProperties);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetMetricGroupCalculateMetricValues(
|
||||
zet_metric_group_handle_t hMetricGroup,
|
||||
size_t rawDataSize,
|
||||
const uint8_t *pRawData,
|
||||
uint32_t *pMetricValueCount,
|
||||
zet_typed_value_t *pMetricValues) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hMetricGroup)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pRawData)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pMetricValueCount)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::MetricGroup::fromHandle(hMetricGroup)->calculateMetricValues(rawDataSize, pRawData, pMetricValueCount, pMetricValues);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetDeviceActivateMetricGroups(
|
||||
zet_device_handle_t hDevice,
|
||||
uint32_t count,
|
||||
zet_metric_group_handle_t *phMetricGroups) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::Device::fromHandle(hDevice)->activateMetricGroups(count, phMetricGroups);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetMetricTracerOpen(
|
||||
zet_device_handle_t hDevice,
|
||||
zet_metric_group_handle_t hMetricGroup,
|
||||
zet_metric_tracer_desc_t *pDesc,
|
||||
ze_event_handle_t hNotificationEvent,
|
||||
zet_metric_tracer_handle_t *phMetricTracer) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hMetricGroup)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pDesc)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phMetricTracer)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (ZET_METRIC_TRACER_DESC_VERSION_CURRENT < pDesc->version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return L0::metricTracerOpen(hDevice, hMetricGroup, pDesc, hNotificationEvent, phMetricTracer);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetCommandListAppendMetricTracerMarker(
|
||||
ze_command_list_handle_t hCommandList,
|
||||
zet_metric_tracer_handle_t hMetricTracer,
|
||||
uint32_t value) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hMetricTracer)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendMetricTracerMarker(hMetricTracer, value);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetMetricTracerClose(
|
||||
zet_metric_tracer_handle_t hMetricTracer) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hMetricTracer)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::MetricTracer::fromHandle(hMetricTracer)->close();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetMetricTracerReadData(
|
||||
zet_metric_tracer_handle_t hMetricTracer,
|
||||
uint32_t maxReportCount,
|
||||
size_t *pRawDataSize,
|
||||
uint8_t *pRawData) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hMetricTracer)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pRawDataSize)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::MetricTracer::fromHandle(hMetricTracer)->readData(maxReportCount, pRawDataSize, pRawData);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetMetricQueryPoolCreate(
|
||||
zet_device_handle_t hDevice,
|
||||
zet_metric_group_handle_t hMetricGroup,
|
||||
const zet_metric_query_pool_desc_t *desc,
|
||||
zet_metric_query_pool_handle_t *phMetricQueryPool) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hDevice)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == desc)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phMetricQueryPool)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (ZET_METRIC_QUERY_POOL_DESC_VERSION_CURRENT < desc->version)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return L0::metricQueryPoolCreate(hDevice, hMetricGroup, desc, phMetricQueryPool);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetMetricQueryPoolDestroy(
|
||||
zet_metric_query_pool_handle_t hMetricQueryPool) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hMetricQueryPool)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::metricQueryPoolDestroy(hMetricQueryPool);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetMetricQueryCreate(
|
||||
zet_metric_query_pool_handle_t hMetricQueryPool,
|
||||
uint32_t index,
|
||||
zet_metric_query_handle_t *phMetricQuery) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hMetricQueryPool)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == phMetricQuery)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::MetricQueryPool::fromHandle(hMetricQueryPool)->createMetricQuery(index, phMetricQuery);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetMetricQueryDestroy(
|
||||
zet_metric_query_handle_t hMetricQuery) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hMetricQuery)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::MetricQuery::fromHandle(hMetricQuery)->destroy();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetMetricQueryReset(
|
||||
zet_metric_query_handle_t hMetricQuery) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hMetricQuery)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::MetricQuery::fromHandle(hMetricQuery)->reset();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetCommandListAppendMetricQueryBegin(
|
||||
zet_command_list_handle_t hCommandList,
|
||||
zet_metric_query_handle_t hMetricQuery) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hMetricQuery)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendMetricQueryBegin(hMetricQuery);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetCommandListAppendMetricQueryEnd(
|
||||
zet_command_list_handle_t hCommandList,
|
||||
zet_metric_query_handle_t hMetricQuery,
|
||||
ze_event_handle_t hCompletionEvent) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == hMetricQuery)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendMetricQueryEnd(hMetricQuery, hCompletionEvent);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetCommandListAppendMetricMemoryBarrier(
|
||||
zet_command_list_handle_t hCommandList) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hCommandList)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::CommandList::fromHandle(hCommandList)->appendMetricMemoryBarrier();
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetMetricQueryGetData(
|
||||
zet_metric_query_handle_t hMetricQuery,
|
||||
size_t *pRawDataSize,
|
||||
uint8_t *pRawData) {
|
||||
try {
|
||||
{
|
||||
if (nullptr == hMetricQuery)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pRawDataSize)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
return L0::MetricQuery::fromHandle(hMetricQuery)->getData(pRawDataSize, pRawData);
|
||||
} catch (ze_result_t &result) {
|
||||
return result;
|
||||
} catch (std::bad_alloc &) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} catch (std::exception &) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/module.h"
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
#include <exception>
|
||||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetModuleGetDebugInfo(
|
||||
zet_module_handle_t hModule,
|
||||
zet_module_debug_info_format_t format,
|
||||
size_t *pSize,
|
||||
uint8_t *pDebugInfo) {
|
||||
{
|
||||
if (nullptr == hModule)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (nullptr == pSize)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
if (format != ZET_MODULE_DEBUG_INFO_FORMAT_ELF_DWARF)
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return L0::Module::fromHandle(hModule)->getDebugInfo(pSize, pDebugInfo);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/source/tracing/tracing.h"
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetTracerCreate(
|
||||
zet_driver_handle_t hDriver,
|
||||
const zet_tracer_desc_t *desc,
|
||||
zet_tracer_handle_t *phTracer) {
|
||||
{
|
||||
if (ZET_TRACER_DESC_VERSION_CURRENT > desc->version) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
return L0::createAPITracer(hDriver, desc, phTracer);
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetTracerDestroy(
|
||||
zet_tracer_handle_t hTracer) {
|
||||
{
|
||||
if (nullptr == hTracer) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
}
|
||||
return L0::APITracer::fromHandle(hTracer)->destroyTracer(hTracer);
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetTracerSetPrologues(
|
||||
zet_tracer_handle_t hTracer,
|
||||
zet_core_callbacks_t *pCoreCbs) {
|
||||
{
|
||||
if (nullptr == hTracer) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
if (nullptr == pCoreCbs) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
}
|
||||
return L0::APITracer::fromHandle(hTracer)->setPrologues(pCoreCbs);
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetTracerSetEpilogues(
|
||||
zet_tracer_handle_t hTracer,
|
||||
zet_core_callbacks_t *pCoreCbs) {
|
||||
{
|
||||
if (nullptr == hTracer) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
if (nullptr == pCoreCbs) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
}
|
||||
return L0::APITracer::fromHandle(hTracer)->setEpilogues(pCoreCbs);
|
||||
}
|
||||
|
||||
__zedllexport ze_result_t __zecall
|
||||
zetTracerSetEnabled(
|
||||
zet_tracer_handle_t hTracer,
|
||||
ze_bool_t enable) {
|
||||
ze_result_t result;
|
||||
{
|
||||
if (nullptr == hTracer) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
}
|
||||
result = L0::APITracer::fromHandle(hTracer)->enableTracer(enable);
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_path(LevelZero_INCLUDE_DIR
|
||||
NAMES level_zero/ze_api.h
|
||||
PATHS
|
||||
${LEVEL_ZERO_ROOT}
|
||||
PATH_SUFFIXES "include"
|
||||
)
|
||||
|
||||
find_package_handle_standard_args(LevelZero
|
||||
REQUIRED_VARS
|
||||
LevelZero_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if(LevelZero_FOUND)
|
||||
list(APPEND LevelZero_INCLUDE_DIRS ${LevelZero_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
if(LevelZero_FOUND AND NOT TARGET LevelZero::LevelZero)
|
||||
add_library(LevelZero::LevelZero INTERFACE IMPORTED)
|
||||
set_target_properties(LevelZero::LevelZero
|
||||
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LevelZero_INCLUDE_DIRS}"
|
||||
)
|
||||
endif()
|
||||
|
||||
MESSAGE(STATUS "LevelZero_INCLUDE_DIRS: " ${LevelZero_INCLUDE_DIRS})
|
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# Copyright (C) 2019-2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
function(create_source_tree target directory)
|
||||
if(WIN32)
|
||||
get_filename_component(directory ${directory} ABSOLUTE)
|
||||
get_target_property(source_list ${target} SOURCES)
|
||||
source_group(TREE ${directory} FILES ${source_list})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
macro(add_subdirectoriesL0 curdir dirmask)
|
||||
file(GLOB children RELATIVE ${curdir} ${curdir}/${dirmask})
|
||||
set(dirlist "")
|
||||
|
||||
foreach(child ${children})
|
||||
if(IS_DIRECTORY ${curdir}/${child})
|
||||
list(APPEND dirlist ${child})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(subdir ${dirlist})
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/CMakeLists.txt)
|
||||
add_subdirectory(${subdir})
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
|
@ -0,0 +1,109 @@
|
|||
#
|
||||
# Copyright (C) 2019-2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_RUNTIME_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/additional_kernel_properties.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/builtin_functions_lib.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/builtin_functions_lib_impl.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/builtin_functions_lib_impl.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdlist.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdlist.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_hw.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_hw.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_hw_base.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdqueue.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdqueue.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdqueue_hw.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_hw_immediate.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_hw_immediate.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdqueue_hw.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdqueue_hw_base.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdqueue_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cpu_page_fault_memory_manager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_manager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debugger.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/driver_handle.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/driver_handle_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/driver_handle_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/driver.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/driver.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/driver_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/event.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/event.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fence.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fence.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_hw.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image_hw.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image_hw.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_operations_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/module.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/module_build_log.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/module_build_log.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/module_extra_options.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/module_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/module_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/printf_handler.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/printf_handler.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sampler.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sampler_hw.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sampler_hw.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sampler_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sampler_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_helpers${BRANCH_DIR_SUFFIX}/hw_helpers.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_extended${BRANCH_DIR_SUFFIX}/cmdlist_extended.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdqueue_extended${BRANCH_DIR_SUFFIX}/cmdqueue_extended.inl
|
||||
)
|
||||
|
||||
target_include_directories(${TARGET_NAME_L0}
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
append_sources_from_properties(L0_RUNTIME_SOURCES
|
||||
L0_API
|
||||
L0_SRCS_DLL
|
||||
L0_SOURCES_LINUX
|
||||
L0_SOURCES_WINDOWS
|
||||
L0_SRCS_COMPILER_INTERFACE
|
||||
L0_SRCS_DEBUGGER
|
||||
L0_SRCS_OCLOC_SHARED
|
||||
)
|
||||
|
||||
target_sources(${TARGET_NAME_L0}
|
||||
PRIVATE
|
||||
${L0_RUNTIME_SOURCES}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
set_source_files_properties(${L0_RUNTIME_SOURCES} PROPERTIES COMPILE_FLAGS -Wall)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED L0_DRIVER_VERSION)
|
||||
set(L0_DRIVER_VERSION 1)
|
||||
endif()
|
||||
|
||||
configure_file(driver_version.h.in ${CMAKE_BINARY_DIR}/driver_version_l0.h) # Put Driver version into define
|
||||
|
||||
# Make our source files visible to parent
|
||||
set_property(GLOBAL PROPERTY L0_RUNTIME_SOURCES ${L0_RUNTIME_SOURCES})
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/device_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
void DeviceImp::processAdditionalKernelProperties(NEO::HwHelper &hwHelper, ze_device_kernel_properties_t *pKernelProperties) {
|
||||
}
|
||||
} // namespace L0
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace NEO {
|
||||
class BuiltIns;
|
||||
} // namespace NEO
|
||||
|
||||
namespace L0 {
|
||||
struct Device;
|
||||
struct Kernel;
|
||||
|
||||
enum class Builtin : uint32_t {
|
||||
CopyBufferBytes = 0u,
|
||||
CopyBufferToBufferSide,
|
||||
CopyBufferToBufferMiddle,
|
||||
CopyImageRegion,
|
||||
FillBufferImmediate,
|
||||
FillBufferSSHOffset,
|
||||
CopyBufferRectBytes2d,
|
||||
CopyBufferRectBytes3d,
|
||||
CopyBufferToImage3dBytes,
|
||||
CopyBufferToImage3d2Bytes,
|
||||
CopyBufferToImage3d4Bytes,
|
||||
CopyBufferToImage3d8Bytes,
|
||||
CopyBufferToImage3d16Bytes,
|
||||
CopyImage3dToBufferBytes,
|
||||
CopyImage3dToBuffer2Bytes,
|
||||
CopyImage3dToBuffer4Bytes,
|
||||
CopyImage3dToBuffer8Bytes,
|
||||
CopyImage3dToBuffer16Bytes,
|
||||
COUNT
|
||||
};
|
||||
|
||||
struct BuiltinFunctionsLib {
|
||||
virtual ~BuiltinFunctionsLib() = default;
|
||||
static std::unique_ptr<BuiltinFunctionsLib> create(Device *device,
|
||||
NEO::BuiltIns *builtins);
|
||||
|
||||
virtual Kernel *getFunction(Builtin func) = 0;
|
||||
virtual void initFunctions() = 0;
|
||||
virtual Kernel *getPageFaultFunction() = 0;
|
||||
virtual void initPageFaultFunction() = 0;
|
||||
|
||||
protected:
|
||||
BuiltinFunctionsLib() = default;
|
||||
};
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/builtin_functions_lib_impl.h"
|
||||
|
||||
#include "shared/source/built_ins/built_ins.h"
|
||||
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include "level_zero/core/source/module.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
std::unique_ptr<BuiltinFunctionsLib> BuiltinFunctionsLib::create(Device *device,
|
||||
NEO::BuiltIns *builtins) {
|
||||
return std::unique_ptr<BuiltinFunctionsLib>(new BuiltinFunctionsLibImpl(device, builtins));
|
||||
}
|
||||
|
||||
struct BuiltinFunctionsLibImpl::BuiltinData {
|
||||
~BuiltinData() {
|
||||
func.reset();
|
||||
module.reset();
|
||||
}
|
||||
|
||||
std::unique_ptr<Module> module;
|
||||
std::unique_ptr<Kernel> func;
|
||||
};
|
||||
|
||||
void BuiltinFunctionsLibImpl::initFunctions() {
|
||||
for (uint32_t builtId = 0; builtId < static_cast<uint32_t>(Builtin::COUNT); builtId++) {
|
||||
const char *builtinName = nullptr;
|
||||
NEO::EBuiltInOps::Type builtin;
|
||||
|
||||
switch (static_cast<Builtin>(builtId)) {
|
||||
case Builtin::CopyBufferBytes:
|
||||
builtinName = "copyBufferToBufferBytesSingle";
|
||||
builtin = NEO::EBuiltInOps::CopyBufferToBuffer;
|
||||
break;
|
||||
case Builtin::CopyBufferToBufferSide:
|
||||
builtinName = "CopyBufferToBufferSideRegion";
|
||||
builtin = NEO::EBuiltInOps::CopyBufferToBuffer;
|
||||
break;
|
||||
case Builtin::CopyBufferToBufferMiddle:
|
||||
builtinName = "CopyBufferToBufferMiddleRegion";
|
||||
builtin = NEO::EBuiltInOps::CopyBufferToBuffer;
|
||||
break;
|
||||
case Builtin::CopyImageRegion:
|
||||
builtinName = "CopyImageToImage3d";
|
||||
builtin = NEO::EBuiltInOps::CopyImageToImage3d;
|
||||
break;
|
||||
case Builtin::FillBufferImmediate:
|
||||
builtinName = "FillBufferImmediate";
|
||||
builtin = NEO::EBuiltInOps::FillBuffer;
|
||||
break;
|
||||
case Builtin::FillBufferSSHOffset:
|
||||
builtinName = "FillBufferSSHOffset";
|
||||
builtin = NEO::EBuiltInOps::FillBuffer;
|
||||
break;
|
||||
case Builtin::CopyBufferRectBytes2d:
|
||||
builtinName = "CopyBufferRectBytes2d";
|
||||
builtin = NEO::EBuiltInOps::CopyBufferRect;
|
||||
break;
|
||||
case Builtin::CopyBufferRectBytes3d:
|
||||
builtinName = "CopyBufferRectBytes3d";
|
||||
builtin = NEO::EBuiltInOps::CopyBufferRect;
|
||||
break;
|
||||
case Builtin::CopyBufferToImage3dBytes:
|
||||
builtinName = "CopyBufferToImage3dBytes";
|
||||
builtin = NEO::EBuiltInOps::CopyBufferToImage3d;
|
||||
break;
|
||||
case Builtin::CopyBufferToImage3d2Bytes:
|
||||
builtinName = "CopyBufferToImage3d2Bytes";
|
||||
builtin = NEO::EBuiltInOps::CopyBufferToImage3d;
|
||||
break;
|
||||
case Builtin::CopyBufferToImage3d4Bytes:
|
||||
builtinName = "CopyBufferToImage3d4Bytes";
|
||||
builtin = NEO::EBuiltInOps::CopyBufferToImage3d;
|
||||
break;
|
||||
case Builtin::CopyBufferToImage3d8Bytes:
|
||||
builtinName = "CopyBufferToImage3d8Bytes";
|
||||
builtin = NEO::EBuiltInOps::CopyBufferToImage3d;
|
||||
break;
|
||||
case Builtin::CopyBufferToImage3d16Bytes:
|
||||
builtinName = "CopyBufferToImage3d16Bytes";
|
||||
builtin = NEO::EBuiltInOps::CopyBufferToImage3d;
|
||||
break;
|
||||
case Builtin::CopyImage3dToBufferBytes:
|
||||
builtinName = "CopyImage3dToBufferBytes";
|
||||
builtin = NEO::EBuiltInOps::CopyImage3dToBuffer;
|
||||
break;
|
||||
case Builtin::CopyImage3dToBuffer2Bytes:
|
||||
builtinName = "CopyImage3dToBuffer2Bytes";
|
||||
builtin = NEO::EBuiltInOps::CopyImage3dToBuffer;
|
||||
break;
|
||||
case Builtin::CopyImage3dToBuffer4Bytes:
|
||||
builtinName = "CopyImage3dToBuffer4Bytes";
|
||||
builtin = NEO::EBuiltInOps::CopyImage3dToBuffer;
|
||||
break;
|
||||
case Builtin::CopyImage3dToBuffer8Bytes:
|
||||
builtinName = "CopyImage3dToBuffer8Bytes";
|
||||
builtin = NEO::EBuiltInOps::CopyImage3dToBuffer;
|
||||
break;
|
||||
case Builtin::CopyImage3dToBuffer16Bytes:
|
||||
builtinName = "CopyImage3dToBuffer16Bytes";
|
||||
builtin = NEO::EBuiltInOps::CopyImage3dToBuffer;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
};
|
||||
|
||||
builtins[builtId] = loadBuiltIn(builtin, builtinName);
|
||||
}
|
||||
}
|
||||
|
||||
Kernel *BuiltinFunctionsLibImpl::getFunction(Builtin func) {
|
||||
auto builtId = static_cast<uint32_t>(func);
|
||||
return builtins[builtId]->func.get();
|
||||
}
|
||||
|
||||
void BuiltinFunctionsLibImpl::initPageFaultFunction() {
|
||||
pageFaultBuiltin = loadBuiltIn(NEO::EBuiltInOps::CopyBufferToBuffer, "CopyBufferToBufferSideRegion");
|
||||
}
|
||||
|
||||
Kernel *BuiltinFunctionsLibImpl::getPageFaultFunction() {
|
||||
return pageFaultBuiltin->func.get();
|
||||
}
|
||||
|
||||
std::unique_ptr<BuiltinFunctionsLibImpl::BuiltinData> BuiltinFunctionsLibImpl::loadBuiltIn(NEO::EBuiltInOps::Type builtin, const char *builtInName) {
|
||||
auto builtInCode = builtInsLib->getBuiltinsLib().getBuiltinCode(builtin, NEO::BuiltinCode::ECodeType::Binary, *device->getNEODevice());
|
||||
|
||||
ze_result_t res;
|
||||
std::unique_ptr<Module> module;
|
||||
ze_module_handle_t moduleHandle;
|
||||
ze_module_desc_t moduleDesc = {ZE_MODULE_DESC_VERSION_CURRENT};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<uint8_t *>(&builtInCode.resource[0]);
|
||||
moduleDesc.inputSize = builtInCode.resource.size();
|
||||
res = device->createModule(&moduleDesc, &moduleHandle, nullptr);
|
||||
UNRECOVERABLE_IF(res != ZE_RESULT_SUCCESS);
|
||||
|
||||
module.reset(Module::fromHandle(moduleHandle));
|
||||
|
||||
std::unique_ptr<Kernel> function;
|
||||
ze_kernel_handle_t functionHandle;
|
||||
ze_kernel_desc_t functionDesc = {ZE_KERNEL_DESC_VERSION_CURRENT};
|
||||
functionDesc.pKernelName = builtInName;
|
||||
res = module->createKernel(&functionDesc, &functionHandle);
|
||||
DEBUG_BREAK_IF(res != ZE_RESULT_SUCCESS);
|
||||
UNUSED_VARIABLE(res);
|
||||
function.reset(Kernel::fromHandle(functionHandle));
|
||||
return std::unique_ptr<BuiltinData>(new BuiltinData{std::move(module), std::move(function)});
|
||||
}
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/core/source/builtin_functions_lib.h"
|
||||
|
||||
namespace NEO {
|
||||
namespace EBuiltInOps {
|
||||
using Type = uint32_t;
|
||||
}
|
||||
class BuiltIns;
|
||||
} // namespace NEO
|
||||
|
||||
namespace L0 {
|
||||
struct BuiltinFunctionsLibImpl : BuiltinFunctionsLib {
|
||||
struct BuiltinData;
|
||||
BuiltinFunctionsLibImpl(Device *device, NEO::BuiltIns *builtInsLib)
|
||||
: device(device), builtInsLib(builtInsLib) {
|
||||
}
|
||||
~BuiltinFunctionsLibImpl() override {
|
||||
builtins->reset();
|
||||
pageFaultBuiltin.release();
|
||||
}
|
||||
|
||||
Kernel *getFunction(Builtin func) override;
|
||||
Kernel *getPageFaultFunction() override;
|
||||
void initFunctions() override;
|
||||
void initPageFaultFunction() override;
|
||||
std::unique_ptr<BuiltinFunctionsLibImpl::BuiltinData> loadBuiltIn(NEO::EBuiltInOps::Type builtin, const char *builtInName);
|
||||
|
||||
protected:
|
||||
std::unique_ptr<BuiltinData> builtins[static_cast<uint32_t>(Builtin::COUNT)];
|
||||
std::unique_ptr<BuiltinData> pageFaultBuiltin;
|
||||
|
||||
Device *device;
|
||||
NEO::BuiltIns *builtInsLib;
|
||||
};
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/cmdlist.h"
|
||||
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
|
||||
#include "opencl/source/device/device_info.h"
|
||||
|
||||
namespace L0 {
|
||||
CommandList::~CommandList() {
|
||||
if (cmdQImmediate) {
|
||||
cmdQImmediate->destroy();
|
||||
}
|
||||
removeDeallocationContainerData();
|
||||
removeHostPtrAllocations();
|
||||
printfFunctionContainer.clear();
|
||||
}
|
||||
void CommandList::storePrintfFunction(Kernel *function) {
|
||||
auto it = std::find(this->printfFunctionContainer.begin(), this->printfFunctionContainer.end(),
|
||||
function);
|
||||
|
||||
if (it == this->printfFunctionContainer.end()) {
|
||||
this->printfFunctionContainer.push_back(function);
|
||||
}
|
||||
}
|
||||
|
||||
void CommandList::removeHostPtrAllocations() {
|
||||
auto memoryManager = device ? device->getDriverHandle()->getMemoryManager() : nullptr;
|
||||
for (auto &allocation : hostPtrMap) {
|
||||
UNRECOVERABLE_IF(memoryManager == nullptr);
|
||||
memoryManager->freeGraphicsMemory(allocation.second);
|
||||
}
|
||||
hostPtrMap.clear();
|
||||
}
|
||||
|
||||
void CommandList::removeDeallocationContainerData() {
|
||||
auto memoryManager = device ? device->getDriverHandle()->getMemoryManager() : nullptr;
|
||||
|
||||
auto container = commandContainer.getDeallocationContainer();
|
||||
for (auto deallocation : container) {
|
||||
DEBUG_BREAK_IF(deallocation == nullptr);
|
||||
UNRECOVERABLE_IF(memoryManager == nullptr);
|
||||
NEO::SvmAllocationData *allocData = device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(reinterpret_cast<void *>(deallocation->getGpuAddress()));
|
||||
if (allocData) {
|
||||
device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->remove(*allocData);
|
||||
}
|
||||
if (!((deallocation->getAllocationType() == NEO::GraphicsAllocation::AllocationType::INTERNAL_HEAP) ||
|
||||
(deallocation->getAllocationType() == NEO::GraphicsAllocation::AllocationType::LINEAR_STREAM))) {
|
||||
memoryManager->freeGraphicsMemory(deallocation);
|
||||
eraseDeallocationContainerEntry(deallocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommandList::eraseDeallocationContainerEntry(NEO::GraphicsAllocation *allocation) {
|
||||
std::vector<NEO::GraphicsAllocation *>::iterator allocErase;
|
||||
auto container = &commandContainer.getDeallocationContainer();
|
||||
|
||||
allocErase = std::find(container->begin(), container->end(), allocation);
|
||||
if (allocErase != container->end()) {
|
||||
container->erase(allocErase);
|
||||
}
|
||||
}
|
||||
|
||||
void CommandList::eraseResidencyContainerEntry(NEO::GraphicsAllocation *allocation) {
|
||||
std::vector<NEO::GraphicsAllocation *>::iterator allocErase;
|
||||
auto container = &commandContainer.getResidencyContainer();
|
||||
|
||||
allocErase = std::find(container->begin(), container->end(), allocation);
|
||||
if (allocErase != container->end()) {
|
||||
container->erase(allocErase);
|
||||
}
|
||||
}
|
||||
|
||||
NEO::PreemptionMode CommandList::obtainFunctionPreemptionMode(Kernel *function) {
|
||||
auto functionAttributes = function->getImmutableData()->getDescriptor().kernelAttributes;
|
||||
|
||||
NEO::PreemptionFlags flags = {};
|
||||
flags.flags.disabledMidThreadPreemptionKernel = functionAttributes.flags.requiresDisabledMidThreadPreemption;
|
||||
flags.flags.usesFencesForReadWriteImages = functionAttributes.flags.usesFencesForReadWriteImages;
|
||||
flags.flags.deviceSupportsVmePreemption = device->getDeviceInfo().vmeAvcSupportsPreemption;
|
||||
flags.flags.disablePerCtxtPreemptionGranularityControl = device->getHwInfo().workaroundTable.waDisablePerCtxtPreemptionGranularityControl;
|
||||
flags.flags.disableLSQCROPERFforOCL = device->getHwInfo().workaroundTable.waDisableLSQCROPERFforOCL;
|
||||
|
||||
return NEO::PreemptionHelper::taskPreemptionMode(device->getDevicePreemptionMode(), flags);
|
||||
}
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,192 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/command_container/cmdcontainer.h"
|
||||
#include "shared/source/command_stream/preemption_mode.h"
|
||||
|
||||
#include "level_zero/core/source/cmdqueue.h"
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include "level_zero/core/source/kernel.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
struct _ze_command_list_handle_t {};
|
||||
|
||||
namespace L0 {
|
||||
struct EventPool;
|
||||
struct Event;
|
||||
struct Kernel;
|
||||
|
||||
struct CommandList : _ze_command_list_handle_t {
|
||||
static constexpr uint32_t maxNumInterfaceDescriptorsPerMediaInterfaceDescriptorLoad = 62u;
|
||||
static constexpr uint32_t defaultNumIddsPerBlock = maxNumInterfaceDescriptorsPerMediaInterfaceDescriptorLoad;
|
||||
static constexpr uint32_t commandListimmediateIddsPerBlock = 1u;
|
||||
|
||||
CommandList() {}
|
||||
CommandList(uint32_t numIddsPerBlock) : commandContainer(numIddsPerBlock) {}
|
||||
|
||||
template <typename Type>
|
||||
struct Allocator {
|
||||
static CommandList *allocate(uint32_t numIddsPerBlock) { return new Type(numIddsPerBlock); }
|
||||
};
|
||||
|
||||
virtual ze_result_t close() = 0;
|
||||
virtual ze_result_t destroy() = 0;
|
||||
virtual ze_result_t appendEventReset(ze_event_handle_t hEvent) = 0;
|
||||
virtual ze_result_t appendBarrier(ze_event_handle_t hSignalEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) = 0;
|
||||
virtual ze_result_t appendMemoryRangesBarrier(uint32_t numRanges, const size_t *pRangeSizes,
|
||||
const void **pRanges,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) = 0;
|
||||
virtual ze_result_t appendImageCopyFromMemory(ze_image_handle_t hDstImage, const void *srcptr,
|
||||
const ze_image_region_t *pDstRegion,
|
||||
ze_event_handle_t hEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) = 0;
|
||||
virtual ze_result_t appendImageCopyToMemory(void *dstptr, ze_image_handle_t hSrcImage,
|
||||
const ze_image_region_t *pSrcRegion,
|
||||
ze_event_handle_t hEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) = 0;
|
||||
virtual ze_result_t appendImageCopyRegion(ze_image_handle_t hDstImage, ze_image_handle_t hSrcImage,
|
||||
const ze_image_region_t *pDstRegion, const ze_image_region_t *pSrcRegion,
|
||||
ze_event_handle_t hSignalEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) = 0;
|
||||
virtual ze_result_t appendImageCopy(ze_image_handle_t hDstImage, ze_image_handle_t hSrcImage,
|
||||
ze_event_handle_t hEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) = 0;
|
||||
virtual ze_result_t appendLaunchFunction(ze_kernel_handle_t hFunction, const ze_group_count_t *pThreadGroupDimensions,
|
||||
ze_event_handle_t hEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) = 0;
|
||||
virtual ze_result_t appendLaunchCooperativeKernel(ze_kernel_handle_t hKernel,
|
||||
const ze_group_count_t *pLaunchFuncArgs,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) = 0;
|
||||
virtual ze_result_t appendLaunchFunctionIndirect(ze_kernel_handle_t hFunction,
|
||||
const ze_group_count_t *pDispatchArgumentsBuffer,
|
||||
ze_event_handle_t hEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) = 0;
|
||||
virtual ze_result_t appendLaunchMultipleFunctionsIndirect(uint32_t numFunctions, const ze_kernel_handle_t *phFunctions,
|
||||
const uint32_t *pNumLaunchArguments,
|
||||
const ze_group_count_t *pLaunchArgumentsBuffer, ze_event_handle_t hEvent,
|
||||
uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) = 0;
|
||||
virtual ze_result_t appendMemAdvise(ze_device_handle_t hDevice, const void *ptr, size_t size,
|
||||
ze_memory_advice_t advice) = 0;
|
||||
virtual ze_result_t appendMemoryCopy(void *dstptr, const void *srcptr, size_t size,
|
||||
ze_event_handle_t hSignalEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) = 0;
|
||||
virtual ze_result_t appendPageFaultCopy(NEO::GraphicsAllocation *dstptr, NEO::GraphicsAllocation *srcptr, size_t size, bool flushHost) = 0;
|
||||
virtual ze_result_t appendMemoryCopyRegion(void *dstPtr,
|
||||
const ze_copy_region_t *dstRegion,
|
||||
uint32_t dstPitch,
|
||||
uint32_t dstSlicePitch,
|
||||
const void *srcPtr,
|
||||
const ze_copy_region_t *srcRegion,
|
||||
uint32_t srcPitch,
|
||||
uint32_t srcSlicePitch,
|
||||
ze_event_handle_t hSignalEvent) = 0;
|
||||
virtual ze_result_t appendMemoryFill(void *ptr, const void *pattern,
|
||||
size_t patternSize, size_t size, ze_event_handle_t hEvent) = 0;
|
||||
virtual ze_result_t appendMemoryPrefetch(const void *ptr, size_t count) = 0;
|
||||
virtual ze_result_t appendSignalEvent(ze_event_handle_t hEvent) = 0;
|
||||
virtual ze_result_t appendWaitOnEvents(uint32_t numEvents, ze_event_handle_t *phEvent) = 0;
|
||||
virtual ze_result_t reserveSpace(size_t size, void **ptr) = 0;
|
||||
virtual ze_result_t reset() = 0;
|
||||
|
||||
virtual ze_result_t appendMetricMemoryBarrier() = 0;
|
||||
virtual ze_result_t appendMetricTracerMarker(zet_metric_tracer_handle_t hMetricTracer,
|
||||
uint32_t value) = 0;
|
||||
virtual ze_result_t appendMetricQueryBegin(zet_metric_query_handle_t hMetricQuery) = 0;
|
||||
virtual ze_result_t appendMetricQueryEnd(zet_metric_query_handle_t hMetricQuery,
|
||||
ze_event_handle_t hCompletionEvent) = 0;
|
||||
|
||||
virtual ze_result_t appendMILoadRegImm(uint32_t reg, uint32_t value) = 0;
|
||||
virtual ze_result_t appendMILoadRegReg(uint32_t reg1, uint32_t reg2) = 0;
|
||||
virtual ze_result_t appendMILoadRegMem(uint32_t reg1, uint64_t address) = 0;
|
||||
virtual ze_result_t appendMIStoreRegMem(uint32_t reg1, uint64_t address) = 0;
|
||||
virtual ze_result_t appendMIMath(void *aluArray, size_t aluCount) = 0;
|
||||
virtual ze_result_t appendMIBBStart(uint64_t address, size_t predication, bool secondLevel) = 0;
|
||||
virtual ze_result_t appendMIBBEnd() = 0;
|
||||
virtual ze_result_t appendMINoop() = 0;
|
||||
|
||||
static CommandList *create(uint32_t productFamily, Device *device);
|
||||
static CommandList *createImmediate(uint32_t productFamily, Device *device,
|
||||
const ze_command_queue_desc_t *desc,
|
||||
bool internalUsage);
|
||||
|
||||
static CommandList *fromHandle(ze_command_list_handle_t handle) {
|
||||
return static_cast<CommandList *>(handle);
|
||||
}
|
||||
|
||||
inline ze_command_list_handle_t toHandle() { return this; }
|
||||
|
||||
uint32_t getCommandListPerThreadScratchSize() const {
|
||||
return commandListPerThreadScratchSize;
|
||||
}
|
||||
|
||||
NEO::PreemptionMode getCommandListPreemptionMode() const {
|
||||
return commandListPreemptionMode;
|
||||
}
|
||||
|
||||
NEO::PreemptionMode obtainFunctionPreemptionMode(Kernel *function);
|
||||
|
||||
std::vector<Kernel *> &getPrintfFunctionContainer() {
|
||||
return this->printfFunctionContainer;
|
||||
}
|
||||
|
||||
void storePrintfFunction(Kernel *function);
|
||||
void removeDeallocationContainerData();
|
||||
void removeHostPtrAllocations();
|
||||
void eraseDeallocationContainerEntry(NEO::GraphicsAllocation *allocation);
|
||||
void eraseResidencyContainerEntry(NEO::GraphicsAllocation *allocation);
|
||||
|
||||
enum CommandListType : uint32_t {
|
||||
TYPE_REGULAR = 0u,
|
||||
TYPE_IMMEDIATE = 1u
|
||||
};
|
||||
|
||||
CommandQueue *cmdQImmediate = nullptr;
|
||||
uint32_t cmdListType = CommandListType::TYPE_REGULAR;
|
||||
const ze_command_queue_desc_t *cmdQImmediateDesc = nullptr;
|
||||
|
||||
Device *device = nullptr;
|
||||
std::vector<Kernel *> printfFunctionContainer;
|
||||
|
||||
virtual ze_result_t executeCommandListImmediate(bool performMigration) = 0;
|
||||
virtual bool initialize(Device *device) = 0;
|
||||
virtual ~CommandList();
|
||||
NEO::CommandContainer commandContainer;
|
||||
|
||||
protected:
|
||||
std::map<const void *, NEO::GraphicsAllocation *> hostPtrMap;
|
||||
uint32_t commandListPerThreadScratchSize = 0u;
|
||||
NEO::PreemptionMode commandListPreemptionMode = NEO::PreemptionMode::Initial;
|
||||
};
|
||||
|
||||
using CommandListAllocatorFn = CommandList *(*)(uint32_t);
|
||||
extern CommandListAllocatorFn commandListFactory[];
|
||||
extern CommandListAllocatorFn commandListFactoryImmediate[];
|
||||
|
||||
template <uint32_t productFamily, typename CommandListType>
|
||||
struct CommandListPopulateFactory {
|
||||
CommandListPopulateFactory() {
|
||||
commandListFactory[productFamily] = CommandList::Allocator<CommandListType>::allocate;
|
||||
}
|
||||
};
|
||||
|
||||
template <uint32_t productFamily, typename CommandListType>
|
||||
struct CommandListImmediatePopulateFactory {
|
||||
CommandListImmediatePopulateFactory() {
|
||||
commandListFactoryImmediate[productFamily] = CommandList::Allocator<CommandListType>::allocate;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/command_stream/linear_stream.h"
|
||||
|
||||
#include "level_zero/core/source/cmdlist_hw.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMILoadRegImm(uint32_t reg, uint32_t value) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMILoadRegReg(uint32_t reg1, uint32_t reg2) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMILoadRegMem(uint32_t reg1, uint64_t address) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMIStoreRegMem(uint32_t reg1, uint64_t address) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMIMath(void *aluArray, size_t aluCount) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMIBBStart(uint64_t address,
|
||||
size_t predication,
|
||||
bool secondLevel) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMIBBEnd() {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMINoop() {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/core/source/builtin_functions_lib.h"
|
||||
#include "level_zero/core/source/cmdlist_imp.h"
|
||||
|
||||
#include "igfxfmid.h"
|
||||
|
||||
namespace NEO {
|
||||
enum class ImageType;
|
||||
}
|
||||
|
||||
namespace L0 {
|
||||
struct AlignedAllocationData {
|
||||
uintptr_t alignedAllocationPtr = 0u;
|
||||
size_t offset = 0u;
|
||||
NEO::GraphicsAllocation *alloc = nullptr;
|
||||
bool needsFlush = false;
|
||||
};
|
||||
|
||||
struct EventPool;
|
||||
struct Event;
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
struct CommandListCoreFamily : CommandListImp {
|
||||
using BaseClass = CommandListImp;
|
||||
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
|
||||
using INTERFACE_DESCRIPTOR_DATA = typename GfxFamily::INTERFACE_DESCRIPTOR_DATA;
|
||||
|
||||
using CommandListImp::CommandListImp;
|
||||
CommandListCoreFamily() {}
|
||||
CommandListCoreFamily(uint32_t numIddsPerBlock) : CommandListImp(numIddsPerBlock) {}
|
||||
|
||||
bool initialize(Device *device) override;
|
||||
virtual void programL3(bool isSLMused);
|
||||
|
||||
ze_result_t close() override;
|
||||
ze_result_t appendEventReset(ze_event_handle_t hEvent) override;
|
||||
ze_result_t appendBarrier(ze_event_handle_t hSignalEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
ze_result_t appendMemoryRangesBarrier(uint32_t numRanges,
|
||||
const size_t *pRangeSizes,
|
||||
const void **pRanges,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
ze_result_t appendImageCopyFromMemory(ze_image_handle_t hDstImage, const void *srcptr,
|
||||
const ze_image_region_t *pDstRegion,
|
||||
ze_event_handle_t hEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
ze_result_t appendImageCopyToMemory(void *dstptr, ze_image_handle_t hSrcImage,
|
||||
const ze_image_region_t *pSrcRegion, ze_event_handle_t hEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
ze_result_t appendImageCopyRegion(ze_image_handle_t hDstImage, ze_image_handle_t hSrcImage,
|
||||
const ze_image_region_t *pDstRegion, const ze_image_region_t *pSrcRegion,
|
||||
ze_event_handle_t hSignalEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
ze_result_t appendImageCopy(ze_image_handle_t hDstImage, ze_image_handle_t hSrcImage,
|
||||
ze_event_handle_t hEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
ze_result_t appendLaunchFunction(ze_kernel_handle_t hFunction,
|
||||
const ze_group_count_t *pThreadGroupDimensions,
|
||||
ze_event_handle_t hEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
ze_result_t appendLaunchCooperativeKernel(ze_kernel_handle_t hKernel,
|
||||
const ze_group_count_t *pLaunchFuncArgs,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
ze_result_t appendLaunchFunctionIndirect(ze_kernel_handle_t hFunction,
|
||||
const ze_group_count_t *pDispatchArgumentsBuffer,
|
||||
ze_event_handle_t hEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
ze_result_t appendLaunchMultipleFunctionsIndirect(uint32_t numFunctions,
|
||||
const ze_kernel_handle_t *phFunctions,
|
||||
const uint32_t *pNumLaunchArguments,
|
||||
const ze_group_count_t *pLaunchArgumentsBuffer,
|
||||
ze_event_handle_t hEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
ze_result_t appendMemAdvise(ze_device_handle_t hDevice,
|
||||
const void *ptr, size_t size,
|
||||
ze_memory_advice_t advice) override;
|
||||
ze_result_t appendMemoryCopy(void *dstptr, const void *srcptr, size_t size,
|
||||
ze_event_handle_t hSignalEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
ze_result_t appendPageFaultCopy(NEO::GraphicsAllocation *dstptr,
|
||||
NEO::GraphicsAllocation *srcptr,
|
||||
size_t size,
|
||||
bool flushHost) override;
|
||||
ze_result_t appendMemoryCopyRegion(void *dstPtr,
|
||||
const ze_copy_region_t *dstRegion,
|
||||
uint32_t dstPitch,
|
||||
uint32_t dstSlicePitch,
|
||||
const void *srcPtr,
|
||||
const ze_copy_region_t *srcRegion,
|
||||
uint32_t srcPitch,
|
||||
uint32_t srcSlicePitch,
|
||||
ze_event_handle_t hSignalEvent) override;
|
||||
ze_result_t appendMemoryPrefetch(const void *ptr, size_t count) override;
|
||||
ze_result_t appendMemoryFill(void *ptr, const void *pattern,
|
||||
size_t patternSize, size_t size,
|
||||
ze_event_handle_t hEvent) override;
|
||||
|
||||
ze_result_t appendMILoadRegImm(uint32_t reg, uint32_t value) override;
|
||||
ze_result_t appendMILoadRegReg(uint32_t reg1, uint32_t reg2) override;
|
||||
ze_result_t appendMILoadRegMem(uint32_t reg1, uint64_t address) override;
|
||||
ze_result_t appendMIStoreRegMem(uint32_t reg1, uint64_t address) override;
|
||||
ze_result_t appendMIMath(void *aluArray, size_t aluCount) override;
|
||||
ze_result_t appendMIBBStart(uint64_t address, size_t predication, bool secondLevel) override;
|
||||
ze_result_t appendMIBBEnd() override;
|
||||
ze_result_t appendMINoop() override;
|
||||
|
||||
ze_result_t appendSignalEvent(ze_event_handle_t hEvent) override;
|
||||
ze_result_t appendWaitOnEvents(uint32_t numEvents, ze_event_handle_t *phEvent) override;
|
||||
ze_result_t reserveSpace(size_t size, void **ptr) override;
|
||||
ze_result_t reset() override;
|
||||
ze_result_t executeCommandListImmediate(bool performMigration) override;
|
||||
|
||||
protected:
|
||||
ze_result_t appendMemoryCopyKernelWithGA(void *dstPtr, NEO::GraphicsAllocation *dstPtrAlloc,
|
||||
uint64_t dstOffset, void *srcPtr,
|
||||
NEO::GraphicsAllocation *srcPtrAlloc,
|
||||
uint64_t srcOffset, uint32_t size,
|
||||
uint32_t elementSize, Builtin builtin);
|
||||
|
||||
ze_result_t appendMemoryCopyKernel2d(const void *dstptr, const void *srcptr,
|
||||
Builtin builtin, const ze_copy_region_t *dstRegion,
|
||||
uint32_t dstPitch, size_t dstOffset,
|
||||
const ze_copy_region_t *srcRegion, uint32_t srcPitch,
|
||||
size_t srcOffset, ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents);
|
||||
|
||||
ze_result_t appendMemoryCopyKernel3d(const void *dstptr, const void *srcptr,
|
||||
Builtin builtin, const ze_copy_region_t *dstRegion,
|
||||
uint32_t dstPitch, uint32_t dstSlicePitch, size_t dstOffset,
|
||||
const ze_copy_region_t *srcRegion, uint32_t srcPitch,
|
||||
uint32_t srcSlicePitch, size_t srcOffset,
|
||||
ze_event_handle_t hSignalEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents);
|
||||
static constexpr uint32_t alignIndirectStatePointer = MemoryConstants::cacheLineSize * sizeof(uint8_t);
|
||||
|
||||
static constexpr uint32_t regGlobalTimestamp = 0x2358;
|
||||
|
||||
ze_result_t appendLaunchFunctionWithParams(ze_kernel_handle_t hFunction,
|
||||
const ze_group_count_t *pThreadGroupDimensions,
|
||||
ze_event_handle_t hEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents, bool isIndirect, bool isPredicate);
|
||||
|
||||
ze_result_t prepareIndirectParams(const ze_group_count_t *pThreadGroupDimensions);
|
||||
|
||||
void applyMemoryRangesBarrier(uint32_t numRanges, const size_t *pRangeSizes,
|
||||
const void **pRanges);
|
||||
|
||||
ze_result_t setGroupSizeIndirect(uint32_t offsets[3], void *crossThreadAddress, uint32_t lws[3]);
|
||||
void appendEventForProfiling(ze_event_handle_t hEvent, bool beforeWalker);
|
||||
void appendSignalEventPostWalker(ze_event_handle_t hEvent);
|
||||
|
||||
uint64_t getInputBufferSize(NEO::ImageType imageType, uint64_t bytesPerPixel, const ze_image_region_t *region);
|
||||
AlignedAllocationData getAlignedAllocation(Device *device, const void *buffer, uint64_t bufferSize);
|
||||
ze_result_t addEventsToCmdList(ze_event_handle_t hEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents);
|
||||
};
|
||||
|
||||
template <PRODUCT_FAMILY gfxProductFamily>
|
||||
struct CommandListProductFamily;
|
||||
|
||||
} // namespace L0
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/source/command_stream/linear_stream.h"
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/helpers/simd_helper.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/unified_memory/unified_memory.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace L0 {
|
||||
struct DeviceImp;
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchFunctionWithParams(ze_kernel_handle_t hFunction,
|
||||
const ze_group_count_t *pThreadGroupDimensions,
|
||||
ze_event_handle_t hEvent, uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents, bool isIndirect, bool isPredicate) {
|
||||
const auto function = Kernel::fromHandle(hFunction);
|
||||
UNRECOVERABLE_IF(function == nullptr);
|
||||
const auto functionImmutableData = function->getImmutableData();
|
||||
commandListPerThreadScratchSize = std::max(commandListPerThreadScratchSize, function->getPerThreadScratchSize());
|
||||
|
||||
auto functionPreemptionMode = obtainFunctionPreemptionMode(function);
|
||||
commandListPreemptionMode = std::min(commandListPreemptionMode, functionPreemptionMode);
|
||||
|
||||
if (!isIndirect) {
|
||||
function->setGroupCount(pThreadGroupDimensions->groupCountX,
|
||||
pThreadGroupDimensions->groupCountY,
|
||||
pThreadGroupDimensions->groupCountZ);
|
||||
}
|
||||
|
||||
if (isIndirect && pThreadGroupDimensions) {
|
||||
prepareIndirectParams(pThreadGroupDimensions);
|
||||
}
|
||||
|
||||
auto csr = device->getNEODevice()->getDefaultEngine().commandStreamReceiver;
|
||||
|
||||
UnifiedMemoryControls unifiedMemoryControls = function->getUnifiedMemoryControls();
|
||||
if (unifiedMemoryControls.indirectDeviceAllocationsAllowed ||
|
||||
unifiedMemoryControls.indirectHostAllocationsAllowed ||
|
||||
unifiedMemoryControls.indirectSharedAllocationsAllowed) {
|
||||
device->getDriverHandle()->getSvmAllocsManager()->makeInternalAllocationsResident(*csr, unifiedMemoryControls.generateMask());
|
||||
}
|
||||
|
||||
NEO::EncodeDispatchKernel<GfxFamily>::encode(commandContainer,
|
||||
reinterpret_cast<const void *>(pThreadGroupDimensions), isIndirect, isPredicate, function,
|
||||
0, device->getNEODevice(), commandListPreemptionMode);
|
||||
|
||||
if (hEvent) {
|
||||
appendSignalEventPostWalker(hEvent);
|
||||
}
|
||||
|
||||
commandContainer.addToResidencyContainer(functionImmutableData->getIsaGraphicsAllocation());
|
||||
auto &residencyContainer = function->getResidencyContainer();
|
||||
for (auto resource : residencyContainer) {
|
||||
commandContainer.addToResidencyContainer(resource);
|
||||
}
|
||||
|
||||
if (functionImmutableData->getDescriptor().kernelAttributes.flags.usesPrintf) {
|
||||
storePrintfFunction(function);
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
void CommandListCoreFamily<gfxCoreFamily>::appendEventForProfiling(ze_event_handle_t hEvent, bool beforeWalker) {
|
||||
if (!hEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto event = Event::fromHandle(hEvent);
|
||||
|
||||
if (!event->isTimestampEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t timeStampAddress = 0;
|
||||
|
||||
using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL;
|
||||
using POST_SYNC_OPERATION = typename PIPE_CONTROL::POST_SYNC_OPERATION;
|
||||
|
||||
commandContainer.addToResidencyContainer(&event->getAllocation());
|
||||
if (beforeWalker) {
|
||||
timeStampAddress = event->getGpuAddress() + event->getOffsetOfProfilingEvent(ZE_EVENT_TIMESTAMP_GLOBAL_START);
|
||||
NEO::EncodeStoreMMIO<GfxFamily>::encode(commandContainer, regGlobalTimestamp, timeStampAddress);
|
||||
|
||||
timeStampAddress = event->getGpuAddress() + event->getOffsetOfProfilingEvent(ZE_EVENT_TIMESTAMP_CONTEXT_START);
|
||||
NEO::EncodeStoreMMIO<GfxFamily>::encode(commandContainer, GP_THREAD_TIME_REG_ADDRESS_OFFSET_LOW, timeStampAddress);
|
||||
} else {
|
||||
|
||||
// Local Context End SRM
|
||||
timeStampAddress = event->getGpuAddress() + event->getOffsetOfProfilingEvent(ZE_EVENT_TIMESTAMP_CONTEXT_END);
|
||||
NEO::EncodeStoreMMIO<GfxFamily>::encode(commandContainer, GP_THREAD_TIME_REG_ADDRESS_OFFSET_LOW, timeStampAddress);
|
||||
|
||||
// Global End PC
|
||||
timeStampAddress = event->getGpuAddress() + event->getOffsetOfProfilingEvent(ZE_EVENT_TIMESTAMP_GLOBAL_END);
|
||||
bool dcFlushEnable = (event->signalScope == ZE_EVENT_SCOPE_FLAG_NONE) ? false : true;
|
||||
|
||||
NEO::MemorySynchronizationCommands<GfxFamily>::obtainPipeControlAndProgramPostSyncOperation(
|
||||
*(commandContainer.getCommandStream()), POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_TIMESTAMP,
|
||||
timeStampAddress,
|
||||
0llu,
|
||||
dcFlushEnable,
|
||||
device->getHwInfo());
|
||||
}
|
||||
}
|
||||
} // namespace L0
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/core/source/cmdlist_hw.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
struct EventPool;
|
||||
struct Event;
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
struct CommandListCoreFamilyImmediate : public CommandListCoreFamily<gfxCoreFamily> {
|
||||
using BaseClass = CommandListCoreFamily<gfxCoreFamily>;
|
||||
using BaseClass::executeCommandListImmediate;
|
||||
|
||||
using BaseClass::BaseClass;
|
||||
CommandListCoreFamilyImmediate() {}
|
||||
CommandListCoreFamilyImmediate(uint32_t numIddsPerBlock) : CommandListCoreFamily<gfxCoreFamily>(numIddsPerBlock) {}
|
||||
|
||||
ze_result_t appendLaunchFunction(
|
||||
ze_kernel_handle_t hFunction, const ze_group_count_t *pThreadGroupDimensions,
|
||||
ze_event_handle_t hEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) override;
|
||||
|
||||
ze_result_t appendLaunchFunctionIndirect(
|
||||
ze_kernel_handle_t hFunction, const ze_group_count_t *pDispatchArgumentsBuffer,
|
||||
ze_event_handle_t hEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) override;
|
||||
|
||||
ze_result_t appendBarrier(ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
|
||||
ze_result_t appendMemoryCopy(void *dstptr,
|
||||
const void *srcptr,
|
||||
size_t size,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
|
||||
ze_result_t appendMemoryCopyRegion(void *dstPtr,
|
||||
const ze_copy_region_t *dstRegion,
|
||||
uint32_t dstPitch,
|
||||
uint32_t dstSlicePitch,
|
||||
const void *srcPtr,
|
||||
const ze_copy_region_t *srcRegion,
|
||||
uint32_t srcPitch,
|
||||
uint32_t srcSlicePitch,
|
||||
ze_event_handle_t hSignalEvent) override;
|
||||
|
||||
ze_result_t appendMemoryFill(void *ptr, const void *pattern,
|
||||
size_t patternSize, size_t size,
|
||||
ze_event_handle_t hEvent) override;
|
||||
|
||||
ze_result_t appendSignalEvent(ze_event_handle_t hEvent) override;
|
||||
|
||||
ze_result_t appendEventReset(ze_event_handle_t hEvent) override;
|
||||
|
||||
ze_result_t appendPageFaultCopy(NEO::GraphicsAllocation *dstptr, NEO::GraphicsAllocation *srcptr, size_t size, bool flushHost) override;
|
||||
|
||||
ze_result_t appendWaitOnEvents(uint32_t numEvents, ze_event_handle_t *phEvent) override;
|
||||
|
||||
ze_result_t appendImageCopyFromMemory(ze_image_handle_t hDstImage,
|
||||
const void *srcPtr,
|
||||
const ze_image_region_t *pDstRegion,
|
||||
ze_event_handle_t hEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
|
||||
ze_result_t appendImageCopyToMemory(void *dstPtr,
|
||||
ze_image_handle_t hSrcImage,
|
||||
const ze_image_region_t *pSrcRegion,
|
||||
ze_event_handle_t hEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) override;
|
||||
};
|
||||
|
||||
template <PRODUCT_FAMILY gfxProductFamily>
|
||||
struct CommandListImmediateProductFamily;
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/core/source/cmdlist_hw_immediate.h"
|
||||
|
||||
namespace L0 {
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendLaunchFunction(
|
||||
ze_kernel_handle_t hFunction, const ze_group_count_t *pThreadGroupDimensions,
|
||||
ze_event_handle_t hEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) {
|
||||
|
||||
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendLaunchFunction(hFunction, pThreadGroupDimensions, hEvent, numWaitEvents, phWaitEvents);
|
||||
if (ret == ZE_RESULT_SUCCESS) {
|
||||
executeCommandListImmediate(true);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendLaunchFunctionIndirect(
|
||||
ze_kernel_handle_t hFunction, const ze_group_count_t *pDispatchArgumentsBuffer,
|
||||
ze_event_handle_t hEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) {
|
||||
|
||||
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendLaunchFunctionIndirect(hFunction, pDispatchArgumentsBuffer, hEvent, numWaitEvents, phWaitEvents);
|
||||
if (ret == ZE_RESULT_SUCCESS) {
|
||||
executeCommandListImmediate(true);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendBarrier(ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) {
|
||||
|
||||
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendBarrier(hSignalEvent, numWaitEvents, phWaitEvents);
|
||||
if (ret == ZE_RESULT_SUCCESS) {
|
||||
executeCommandListImmediate(true);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendMemoryCopy(void *dstptr,
|
||||
const void *srcptr,
|
||||
size_t size,
|
||||
ze_event_handle_t hSignalEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) {
|
||||
|
||||
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendMemoryCopy(dstptr, srcptr, size, hSignalEvent, numWaitEvents, phWaitEvents);
|
||||
if (ret == ZE_RESULT_SUCCESS) {
|
||||
executeCommandListImmediate(true);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendMemoryCopyRegion(void *dstPtr,
|
||||
const ze_copy_region_t *dstRegion,
|
||||
uint32_t dstPitch,
|
||||
uint32_t dstSlicePitch,
|
||||
const void *srcPtr,
|
||||
const ze_copy_region_t *srcRegion,
|
||||
uint32_t srcPitch,
|
||||
uint32_t srcSlicePitch,
|
||||
ze_event_handle_t hSignalEvent) {
|
||||
|
||||
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendMemoryCopyRegion(dstPtr, dstRegion, dstPitch, dstSlicePitch, srcPtr, srcRegion, srcPitch, srcSlicePitch, hSignalEvent);
|
||||
if (ret == ZE_RESULT_SUCCESS) {
|
||||
executeCommandListImmediate(true);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendMemoryFill(void *ptr, const void *pattern,
|
||||
size_t patternSize, size_t size,
|
||||
ze_event_handle_t hEvent) {
|
||||
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendMemoryFill(ptr, pattern, patternSize, size, hEvent);
|
||||
if (ret == ZE_RESULT_SUCCESS) {
|
||||
executeCommandListImmediate(true);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendSignalEvent(ze_event_handle_t hEvent) {
|
||||
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendSignalEvent(hEvent);
|
||||
if (ret == ZE_RESULT_SUCCESS) {
|
||||
executeCommandListImmediate(true);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendEventReset(ze_event_handle_t hEvent) {
|
||||
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendEventReset(hEvent);
|
||||
if (ret == ZE_RESULT_SUCCESS) {
|
||||
executeCommandListImmediate(true);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendPageFaultCopy(NEO::GraphicsAllocation *dstptr, NEO::GraphicsAllocation *srcptr, size_t size, bool flushHost) {
|
||||
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendPageFaultCopy(dstptr, srcptr, size, flushHost);
|
||||
if (ret == ZE_RESULT_SUCCESS) {
|
||||
executeCommandListImmediate(false);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendWaitOnEvents(uint32_t numEvents, ze_event_handle_t *phEvent) {
|
||||
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendWaitOnEvents(numEvents, phEvent);
|
||||
if (ret == ZE_RESULT_SUCCESS) {
|
||||
executeCommandListImmediate(true);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendImageCopyFromMemory(ze_image_handle_t hDstImage,
|
||||
const void *srcPtr,
|
||||
const ze_image_region_t *pDstRegion,
|
||||
ze_event_handle_t hEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) {
|
||||
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendImageCopyFromMemory(hDstImage, srcPtr, pDstRegion, hEvent, numWaitEvents, phWaitEvents);
|
||||
if (ret == ZE_RESULT_SUCCESS) {
|
||||
executeCommandListImmediate(true);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendImageCopyToMemory(void *dstPtr,
|
||||
ze_image_handle_t hSrcImage,
|
||||
const ze_image_region_t *pSrcRegion,
|
||||
ze_event_handle_t hEvent,
|
||||
uint32_t numWaitEvents,
|
||||
ze_event_handle_t *phWaitEvents) {
|
||||
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendImageCopyToMemory(dstPtr, hSrcImage, pSrcRegion, hEvent, numWaitEvents, phWaitEvents);
|
||||
if (ret == ZE_RESULT_SUCCESS) {
|
||||
executeCommandListImmediate(true);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // namespace L0
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/cmdlist_imp.h"
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/command_stream/linear_stream.h"
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/indirect_heap/indirect_heap.h"
|
||||
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include "level_zero/core/source/device_imp.h"
|
||||
#include "level_zero/tools/source/metrics/metric.h"
|
||||
|
||||
#include "igfxfmid.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
CommandListAllocatorFn commandListFactory[IGFX_MAX_PRODUCT] = {};
|
||||
CommandListAllocatorFn commandListFactoryImmediate[IGFX_MAX_PRODUCT] = {};
|
||||
|
||||
ze_result_t CommandListImp::destroy() {
|
||||
delete this;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t CommandListImp::appendMetricMemoryBarrier() {
|
||||
return MetricQuery::appendMemoryBarrier(*this);
|
||||
}
|
||||
|
||||
ze_result_t CommandListImp::appendMetricTracerMarker(zet_metric_tracer_handle_t hMetricTracer,
|
||||
uint32_t value) {
|
||||
return MetricQuery::appendTracerMarker(*this, hMetricTracer, value);
|
||||
}
|
||||
|
||||
ze_result_t CommandListImp::appendMetricQueryBegin(zet_metric_query_handle_t hMetricQuery) {
|
||||
return MetricQuery::fromHandle(hMetricQuery)->appendBegin(*this);
|
||||
}
|
||||
|
||||
ze_result_t CommandListImp::appendMetricQueryEnd(zet_metric_query_handle_t hMetricQuery,
|
||||
ze_event_handle_t hCompletionEvent) {
|
||||
return MetricQuery::fromHandle(hMetricQuery)->appendEnd(*this, hCompletionEvent);
|
||||
}
|
||||
|
||||
CommandList *CommandList::create(uint32_t productFamily, Device *device) {
|
||||
CommandListAllocatorFn allocator = nullptr;
|
||||
if (productFamily < IGFX_MAX_PRODUCT) {
|
||||
allocator = commandListFactory[productFamily];
|
||||
}
|
||||
|
||||
CommandListImp *commandList = nullptr;
|
||||
if (allocator) {
|
||||
commandList = static_cast<CommandListImp *>((*allocator)(CommandList::defaultNumIddsPerBlock));
|
||||
|
||||
commandList->initialize(device);
|
||||
}
|
||||
return commandList;
|
||||
}
|
||||
|
||||
CommandList *CommandList::createImmediate(uint32_t productFamily, Device *device,
|
||||
const ze_command_queue_desc_t *desc,
|
||||
bool internalUsage) {
|
||||
|
||||
auto deviceImp = static_cast<DeviceImp *>(device);
|
||||
NEO::CommandStreamReceiver *csr = nullptr;
|
||||
if (internalUsage) {
|
||||
csr = deviceImp->neoDevice->getInternalEngine().commandStreamReceiver;
|
||||
} else {
|
||||
csr = deviceImp->neoDevice->getDefaultEngine().commandStreamReceiver;
|
||||
}
|
||||
|
||||
auto commandQueue = CommandQueue::create(productFamily, device, csr, desc);
|
||||
if (!commandQueue) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CommandListAllocatorFn allocator = nullptr;
|
||||
if (productFamily < IGFX_MAX_PRODUCT) {
|
||||
allocator = commandListFactoryImmediate[productFamily];
|
||||
}
|
||||
|
||||
CommandListImp *commandList = nullptr;
|
||||
if (allocator) {
|
||||
commandList = static_cast<CommandListImp *>((*allocator)(CommandList::commandListimmediateIddsPerBlock));
|
||||
|
||||
commandList->initialize(device);
|
||||
}
|
||||
|
||||
if (!commandList) {
|
||||
commandQueue->destroy();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
commandList->cmdQImmediate = commandQueue;
|
||||
commandList->cmdListType = CommandListType::TYPE_IMMEDIATE;
|
||||
commandList->cmdQImmediateDesc = desc;
|
||||
commandList->commandListPreemptionMode = device->getDevicePreemptionMode();
|
||||
|
||||
return commandList;
|
||||
}
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/core/source/cmdlist.h"
|
||||
#include "level_zero/core/source/device.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
struct CommandListImp : CommandList {
|
||||
CommandListImp() {}
|
||||
CommandListImp(uint32_t numIddsPerBlock) : CommandList(numIddsPerBlock) {}
|
||||
ze_result_t destroy() override;
|
||||
|
||||
ze_result_t appendMetricMemoryBarrier() override;
|
||||
ze_result_t appendMetricTracerMarker(zet_metric_tracer_handle_t hMetricTracer,
|
||||
uint32_t value) override;
|
||||
ze_result_t appendMetricQueryBegin(zet_metric_query_handle_t hMetricQuery) override;
|
||||
ze_result_t appendMetricQueryEnd(zet_metric_query_handle_t hMetricQuery,
|
||||
ze_event_handle_t hCompletionEvent) override;
|
||||
|
||||
protected:
|
||||
~CommandListImp() override = default;
|
||||
};
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/command_stream/csr_definitions.h"
|
||||
#include "shared/source/command_stream/linear_stream.h"
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
|
||||
#include "level_zero/core/source/cmdlist_hw.h"
|
||||
#include "level_zero/core/source/cmdqueue_imp.h"
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include "level_zero/core/source/device_imp.h"
|
||||
|
||||
#include "hw_helpers.h"
|
||||
#include "igfxfmid.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
CommandQueueAllocatorFn commandQueueFactory[IGFX_MAX_PRODUCT] = {};
|
||||
|
||||
ze_result_t CommandQueueImp::destroy() {
|
||||
delete this;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
void CommandQueueImp::initialize() {
|
||||
buffers.initialize(device, totalCmdBufferSize);
|
||||
NEO::GraphicsAllocation *bufferAllocation = buffers.getCurrentBufferAllocation();
|
||||
commandStream = new NEO::LinearStream(bufferAllocation->getUnderlyingBuffer(),
|
||||
defaultQueueCmdBufferSize);
|
||||
UNRECOVERABLE_IF(commandStream == nullptr);
|
||||
commandStream->replaceGraphicsAllocation(bufferAllocation);
|
||||
}
|
||||
|
||||
void CommandQueueImp::reserveLinearStreamSize(size_t size) {
|
||||
UNRECOVERABLE_IF(commandStream == nullptr);
|
||||
if (commandStream->getAvailableSpace() < size) {
|
||||
buffers.switchBuffers(csr);
|
||||
NEO::GraphicsAllocation *nextBufferAllocation = buffers.getCurrentBufferAllocation();
|
||||
commandStream->replaceBuffer(nextBufferAllocation->getUnderlyingBuffer(),
|
||||
defaultQueueCmdBufferSize);
|
||||
commandStream->replaceGraphicsAllocation(nextBufferAllocation);
|
||||
}
|
||||
}
|
||||
|
||||
void CommandQueueImp::submitBatchBuffer(size_t offset, NEO::ResidencyContainer &residencyContainer, void *endingCmdPtr) {
|
||||
UNRECOVERABLE_IF(csr == nullptr);
|
||||
|
||||
NEO::BatchBuffer batchBuffer(commandStream->getGraphicsAllocation(), offset, 0u, nullptr, false, false,
|
||||
NEO::QueueThrottle::HIGH, NEO::QueueSliceCount::defaultSliceCount,
|
||||
commandStream->getUsed(), commandStream, endingCmdPtr);
|
||||
|
||||
csr->submitBatchBuffer(batchBuffer, residencyContainer);
|
||||
buffers.setCurrentFlushStamp(csr->obtainCurrentFlushStamp());
|
||||
}
|
||||
|
||||
ze_result_t CommandQueueImp::synchronize(uint32_t timeout) {
|
||||
return synchronizeByPollingForTaskCount(timeout);
|
||||
}
|
||||
|
||||
ze_result_t CommandQueueImp::synchronizeByPollingForTaskCount(uint32_t timeout) {
|
||||
UNRECOVERABLE_IF(csr == nullptr);
|
||||
|
||||
auto taskCountToWait = this->taskCount;
|
||||
|
||||
waitForTaskCountWithKmdNotifyFallbackHelper(csr, this->taskCount, 0, false, false);
|
||||
|
||||
bool enableTimeout = (timeout != std::numeric_limits<uint32_t>::max());
|
||||
csr->waitForCompletionWithTimeout(enableTimeout, timeout, this->taskCount);
|
||||
|
||||
if (*csr->getTagAddress() < taskCountToWait) {
|
||||
return ZE_RESULT_NOT_READY;
|
||||
}
|
||||
|
||||
printFunctionsPrintfOutput();
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
void CommandQueueImp::printFunctionsPrintfOutput() {
|
||||
size_t size = this->printfFunctionContainer.size();
|
||||
if (size) {
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
this->printfFunctionContainer[i]->printPrintfOutput();
|
||||
}
|
||||
this->printfFunctionContainer.clear();
|
||||
}
|
||||
}
|
||||
|
||||
CommandQueue *CommandQueue::create(uint32_t productFamily, Device *device, NEO::CommandStreamReceiver *csr, const ze_command_queue_desc_t *desc) {
|
||||
CommandQueueAllocatorFn allocator = nullptr;
|
||||
if (productFamily < IGFX_MAX_PRODUCT) {
|
||||
allocator = commandQueueFactory[productFamily];
|
||||
}
|
||||
|
||||
CommandQueueImp *commandQueue = nullptr;
|
||||
if (allocator) {
|
||||
commandQueue = static_cast<CommandQueueImp *>((*allocator)(device, csr, desc));
|
||||
|
||||
commandQueue->initialize();
|
||||
}
|
||||
return commandQueue;
|
||||
}
|
||||
|
||||
ze_result_t fenceCreate(ze_command_queue_handle_t hCommandQueue, const ze_fence_desc_t *desc,
|
||||
ze_fence_handle_t *phFence) {
|
||||
auto commandQueue = static_cast<CommandQueueImp *>(CommandQueue::fromHandle(hCommandQueue));
|
||||
return commandQueue->createFence(desc, phFence);
|
||||
}
|
||||
|
||||
ze_command_queue_mode_t CommandQueueImp::getSynchronousMode() {
|
||||
return desc.mode;
|
||||
}
|
||||
|
||||
void CommandQueueImp::CommandBufferManager::initialize(Device *device, size_t sizeRequested) {
|
||||
size_t alignedSize = alignUp<size_t>(sizeRequested, MemoryConstants::pageSize64k);
|
||||
NEO::AllocationProperties properties{device->getRootDeviceIndex(), true, alignedSize,
|
||||
NEO::GraphicsAllocation::AllocationType::COMMAND_BUFFER,
|
||||
device->isMultiDeviceCapable(),
|
||||
false,
|
||||
NEO::SubDevice::unspecifiedSubDeviceIndex};
|
||||
|
||||
buffers[BUFFER_ALLOCATION::FIRST] = device->getDriverHandle()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
|
||||
UNRECOVERABLE_IF(nullptr == buffers[BUFFER_ALLOCATION::FIRST]);
|
||||
memset(buffers[BUFFER_ALLOCATION::FIRST]->getUnderlyingBuffer(), 0, buffers[BUFFER_ALLOCATION::FIRST]->getUnderlyingBufferSize());
|
||||
|
||||
buffers[BUFFER_ALLOCATION::SECOND] = device->getDriverHandle()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
|
||||
UNRECOVERABLE_IF(nullptr == buffers[BUFFER_ALLOCATION::SECOND]);
|
||||
memset(buffers[BUFFER_ALLOCATION::SECOND]->getUnderlyingBuffer(), 0, buffers[BUFFER_ALLOCATION::SECOND]->getUnderlyingBufferSize());
|
||||
flushId[BUFFER_ALLOCATION::FIRST] = 0u;
|
||||
flushId[BUFFER_ALLOCATION::SECOND] = 0u;
|
||||
}
|
||||
|
||||
void CommandQueueImp::CommandBufferManager::destroy(NEO::MemoryManager *memoryManager) {
|
||||
memoryManager->freeGraphicsMemory(buffers[BUFFER_ALLOCATION::FIRST]);
|
||||
memoryManager->freeGraphicsMemory(buffers[BUFFER_ALLOCATION::SECOND]);
|
||||
}
|
||||
|
||||
void CommandQueueImp::CommandBufferManager::switchBuffers(NEO::CommandStreamReceiver *csr) {
|
||||
if (bufferUse == BUFFER_ALLOCATION::FIRST) {
|
||||
bufferUse = BUFFER_ALLOCATION::SECOND;
|
||||
} else {
|
||||
bufferUse = BUFFER_ALLOCATION::FIRST;
|
||||
}
|
||||
|
||||
NEO::FlushStamp completionId = flushId[bufferUse];
|
||||
if (completionId != 0u) {
|
||||
UNRECOVERABLE_IF(csr == nullptr);
|
||||
csr->waitForFlushStamp(completionId);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include <level_zero/ze_common.h>
|
||||
#include <level_zero/ze_fence.h>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
struct _ze_command_queue_handle_t {};
|
||||
|
||||
namespace NEO {
|
||||
class CommandStreamReceiver;
|
||||
}
|
||||
|
||||
namespace L0 {
|
||||
|
||||
struct CommandQueue : _ze_command_queue_handle_t {
|
||||
template <typename Type>
|
||||
struct Allocator {
|
||||
static CommandQueue *allocate(Device *device, NEO::CommandStreamReceiver *csr, const ze_command_queue_desc_t *desc) {
|
||||
return new Type(device, csr, desc);
|
||||
}
|
||||
};
|
||||
|
||||
virtual ~CommandQueue() = default;
|
||||
|
||||
virtual ze_result_t createFence(const ze_fence_desc_t *desc, ze_fence_handle_t *phFence) = 0;
|
||||
virtual ze_result_t destroy() = 0;
|
||||
virtual ze_result_t executeCommandLists(uint32_t numCommandLists,
|
||||
ze_command_list_handle_t *phCommandLists,
|
||||
ze_fence_handle_t hFence, bool performMigration) = 0;
|
||||
virtual ze_result_t executeCommands(uint32_t numCommands,
|
||||
void *phCommands,
|
||||
ze_fence_handle_t hFence) = 0;
|
||||
virtual ze_result_t synchronize(uint32_t timeout) = 0;
|
||||
|
||||
static CommandQueue *create(uint32_t productFamily, Device *device, NEO::CommandStreamReceiver *csr, const ze_command_queue_desc_t *desc);
|
||||
|
||||
static CommandQueue *fromHandle(ze_command_queue_handle_t handle) {
|
||||
return static_cast<CommandQueue *>(handle);
|
||||
}
|
||||
|
||||
inline ze_command_queue_handle_t toHandle() { return this; }
|
||||
|
||||
inline void setCommandQueuePreemptionMode(NEO::PreemptionMode newPreemptionMode) {
|
||||
commandQueuePreemptionMode = newPreemptionMode;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::atomic<uint32_t> commandQueuePerThreadScratchSize;
|
||||
NEO::PreemptionMode commandQueuePreemptionMode = NEO::PreemptionMode::Initial;
|
||||
};
|
||||
|
||||
using CommandQueueAllocatorFn = CommandQueue *(*)(Device *device, NEO::CommandStreamReceiver *csr, const ze_command_queue_desc_t *desc);
|
||||
extern CommandQueueAllocatorFn commandQueueFactory[];
|
||||
|
||||
template <uint32_t productFamily, typename CommandQueueType>
|
||||
struct CommandQueuePopulateFactory {
|
||||
CommandQueuePopulateFactory() {
|
||||
commandQueueFactory[productFamily] = CommandQueue::Allocator<CommandQueueType>::allocate;
|
||||
}
|
||||
};
|
||||
|
||||
ze_result_t fenceCreate(ze_command_queue_handle_t hCommandQueue, const ze_fence_desc_t *desc,
|
||||
ze_fence_handle_t *phFence);
|
||||
|
||||
ze_result_t fenceDestroy(ze_fence_handle_t hFence);
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/core/source/cmdqueue_hw.h"
|
||||
|
||||
namespace L0 {
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommands(uint32_t numCommandGraphs,
|
||||
void *phCommands,
|
||||
ze_fence_handle_t hFence) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
} // namespace L0
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/command_stream/scratch_space_controller.h"
|
||||
#include "shared/source/command_stream/submissions_aggregator.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
#include "shared/source/memory_manager/memory_constants.h"
|
||||
#include "shared/source/memory_manager/residency_container.h"
|
||||
|
||||
#include "level_zero/core/source/cmdqueue_imp.h"
|
||||
|
||||
#include "igfxfmid.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
struct CommandQueueHw : public CommandQueueImp {
|
||||
using CommandQueueImp::CommandQueueImp;
|
||||
|
||||
ze_result_t createFence(const ze_fence_desc_t *desc, ze_fence_handle_t *phFence) override;
|
||||
ze_result_t destroy() override;
|
||||
ze_result_t executeCommandLists(uint32_t numCommandLists,
|
||||
ze_command_list_handle_t *phCommandLists,
|
||||
ze_fence_handle_t hFence, bool performMigration) override;
|
||||
ze_result_t executeCommands(uint32_t numCommands,
|
||||
void *phCommands,
|
||||
ze_fence_handle_t hFence) override;
|
||||
|
||||
void dispatchTaskCountWrite(NEO::LinearStream &commandStream, bool flushDataCache) override;
|
||||
|
||||
void programGeneralStateBaseAddress(uint64_t gsba, NEO::LinearStream &commandStream);
|
||||
size_t estimateStateBaseAddressCmdSize();
|
||||
void programFrontEnd(uint64_t scratchAddress, NEO::LinearStream &commandStream);
|
||||
|
||||
size_t estimateFrontEndCmdSize();
|
||||
size_t estimatePipelineSelect();
|
||||
void programPipelineSelect(NEO::LinearStream &commandStream);
|
||||
|
||||
void handleScratchSpace(NEO::ResidencyContainer &residency,
|
||||
NEO::ScratchSpaceController *scratchController,
|
||||
bool &gsbaState, bool &frontEndState);
|
||||
};
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,316 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/built_ins/built_ins.h"
|
||||
#include "shared/source/built_ins/sip.h"
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/source/command_stream/linear_stream.h"
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/helpers/interlocked_max.h"
|
||||
#include "shared/source/helpers/preamble.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
#include "shared/source/page_fault_manager/cpu_page_fault_manager.h"
|
||||
|
||||
#include "level_zero/core/source/cmdlist.h"
|
||||
#include "level_zero/core/source/cmdlist_hw.h"
|
||||
#include "level_zero/core/source/cmdqueue_hw.h"
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include "level_zero/core/source/fence.h"
|
||||
#include "level_zero/tools/source/metrics/metric.h"
|
||||
|
||||
#include <limits>
|
||||
#include <thread>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandQueueHw<gfxCoreFamily>::createFence(const ze_fence_desc_t *desc,
|
||||
ze_fence_handle_t *phFence) {
|
||||
*phFence = Fence::create(this, desc);
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandQueueHw<gfxCoreFamily>::destroy() {
|
||||
delete commandStream;
|
||||
buffers.destroy(this->getDevice()->getDriverHandle()->getMemoryManager());
|
||||
delete this;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
|
||||
uint32_t numCommandLists, ze_command_list_handle_t *phCommandLists, ze_fence_handle_t hFence, bool performMigration) {
|
||||
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
|
||||
using MI_BATCH_BUFFER_START = typename GfxFamily::MI_BATCH_BUFFER_START;
|
||||
using MI_BATCH_BUFFER_END = typename GfxFamily::MI_BATCH_BUFFER_END;
|
||||
|
||||
using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL;
|
||||
using POST_SYNC_OPERATION = typename PIPE_CONTROL::POST_SYNC_OPERATION;
|
||||
|
||||
size_t spaceForResidency = 0;
|
||||
size_t preemptionSize = 0u;
|
||||
constexpr size_t residencyContainerSpaceForPreemption = 2;
|
||||
constexpr size_t residencyContainerSpaceForFence = 1;
|
||||
constexpr size_t residencyContainerSpaceForTagWrite = 1;
|
||||
|
||||
NEO::Device *neoDevice = device->getNEODevice();
|
||||
NEO::PreemptionMode statePreemption = commandQueuePreemptionMode;
|
||||
auto devicePreemption = device->getDevicePreemptionMode();
|
||||
if (commandQueuePreemptionMode == NEO::PreemptionMode::Initial) {
|
||||
preemptionSize += NEO::PreemptionHelper::getRequiredCmdStreamSize<GfxFamily>(commandQueuePreemptionMode,
|
||||
devicePreemption) +
|
||||
NEO::PreemptionHelper::getRequiredPreambleSize<GfxFamily>(*neoDevice) +
|
||||
NEO::PreemptionHelper::getRequiredStateSipCmdSize<GfxFamily>(*neoDevice);
|
||||
statePreemption = devicePreemption;
|
||||
}
|
||||
if (devicePreemption == NEO::PreemptionMode::MidThread) {
|
||||
spaceForResidency += residencyContainerSpaceForPreemption;
|
||||
}
|
||||
|
||||
bool directSubmissionEnabled = csr->isDirectSubmissionEnabled();
|
||||
|
||||
NEO::ResidencyContainer residencyContainer;
|
||||
L0::Fence *fence = nullptr;
|
||||
|
||||
device->activateMetricGroups();
|
||||
|
||||
size_t totalCmdBuffers = 0;
|
||||
for (auto i = 0u; i < numCommandLists; i++) {
|
||||
auto commandList = CommandList::fromHandle(phCommandLists[i]);
|
||||
|
||||
totalCmdBuffers += commandList->commandContainer.getCmdBufferAllocations().size();
|
||||
spaceForResidency += commandList->commandContainer.getResidencyContainer().size();
|
||||
auto commandListPreemption = commandList->getCommandListPreemptionMode();
|
||||
if (statePreemption != commandListPreemption) {
|
||||
preemptionSize += sizeof(PIPE_CONTROL);
|
||||
preemptionSize += NEO::PreemptionHelper::getRequiredCmdStreamSize<GfxFamily>(commandListPreemption, statePreemption);
|
||||
statePreemption = commandListPreemption;
|
||||
}
|
||||
|
||||
interlockedMax(commandQueuePerThreadScratchSize, commandList->getCommandListPerThreadScratchSize());
|
||||
}
|
||||
|
||||
size_t linearStreamSizeEstimate = totalCmdBuffers * sizeof(MI_BATCH_BUFFER_START);
|
||||
|
||||
if (directSubmissionEnabled) {
|
||||
linearStreamSizeEstimate += sizeof(MI_BATCH_BUFFER_START);
|
||||
} else {
|
||||
linearStreamSizeEstimate += sizeof(MI_BATCH_BUFFER_END);
|
||||
}
|
||||
|
||||
if (hFence) {
|
||||
fence = Fence::fromHandle(hFence);
|
||||
spaceForResidency += residencyContainerSpaceForFence;
|
||||
linearStreamSizeEstimate += NEO::MemorySynchronizationCommands<GfxFamily>::getSizeForPipeControlWithPostSyncOperation(device->getHwInfo());
|
||||
}
|
||||
|
||||
spaceForResidency += residencyContainerSpaceForTagWrite;
|
||||
|
||||
residencyContainer.reserve(spaceForResidency);
|
||||
|
||||
auto scratchSpaceController = csr->getScratchSpaceController();
|
||||
bool gsbaStateDirty = false;
|
||||
bool frontEndStateDirty = false;
|
||||
handleScratchSpace(residencyContainer,
|
||||
scratchSpaceController,
|
||||
gsbaStateDirty, frontEndStateDirty);
|
||||
|
||||
gsbaStateDirty |= !gsbaInit;
|
||||
frontEndStateDirty |= !frontEndInit;
|
||||
|
||||
if (!gpgpuEnabled) {
|
||||
linearStreamSizeEstimate += estimatePipelineSelect();
|
||||
}
|
||||
|
||||
if (frontEndStateDirty) {
|
||||
linearStreamSizeEstimate += estimateFrontEndCmdSize();
|
||||
}
|
||||
|
||||
if (gsbaStateDirty) {
|
||||
linearStreamSizeEstimate += estimateStateBaseAddressCmdSize();
|
||||
}
|
||||
|
||||
linearStreamSizeEstimate += NEO::MemorySynchronizationCommands<GfxFamily>::getSizeForPipeControlWithPostSyncOperation(device->getHwInfo());
|
||||
|
||||
linearStreamSizeEstimate += preemptionSize;
|
||||
|
||||
size_t alignedSize = alignUp<size_t>(linearStreamSizeEstimate, minCmdBufferPtrAlign);
|
||||
size_t padding = alignedSize - linearStreamSizeEstimate;
|
||||
reserveLinearStreamSize(alignedSize);
|
||||
NEO::LinearStream child(commandStream->getSpace(alignedSize), alignedSize);
|
||||
|
||||
if (!gpgpuEnabled) {
|
||||
programPipelineSelect(child);
|
||||
}
|
||||
if (frontEndStateDirty) {
|
||||
programFrontEnd(scratchSpaceController->getScratchPatchAddress(), child);
|
||||
}
|
||||
if (gsbaStateDirty) {
|
||||
programGeneralStateBaseAddress(scratchSpaceController->calculateNewGSH(), child);
|
||||
}
|
||||
|
||||
if (commandQueuePreemptionMode == NEO::PreemptionMode::Initial) {
|
||||
NEO::PreemptionHelper::programCsrBaseAddress<GfxFamily>(child, *neoDevice, csr->getPreemptionAllocation());
|
||||
NEO::PreemptionHelper::programStateSip<GfxFamily>(child, *neoDevice);
|
||||
NEO::PreemptionHelper::programCmdStream<GfxFamily>(child,
|
||||
devicePreemption,
|
||||
commandQueuePreemptionMode,
|
||||
csr->getPreemptionAllocation());
|
||||
commandQueuePreemptionMode = devicePreemption;
|
||||
statePreemption = commandQueuePreemptionMode;
|
||||
}
|
||||
|
||||
if (devicePreemption == NEO::PreemptionMode::MidThread) {
|
||||
residencyContainer.push_back(csr->getPreemptionAllocation());
|
||||
auto sipIsa = neoDevice->getBuiltIns()->getSipKernel(NEO::SipKernelType::Csr, *neoDevice).getSipAllocation();
|
||||
residencyContainer.push_back(sipIsa);
|
||||
}
|
||||
|
||||
for (auto i = 0u; i < numCommandLists; ++i) {
|
||||
auto commandList = CommandList::fromHandle(phCommandLists[i]);
|
||||
auto cmdBufferAllocations = commandList->commandContainer.getCmdBufferAllocations();
|
||||
auto cmdBufferCount = cmdBufferAllocations.size();
|
||||
|
||||
auto commandListPreemption = commandList->getCommandListPreemptionMode();
|
||||
if (statePreemption != commandListPreemption) {
|
||||
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControl(child, false);
|
||||
NEO::PreemptionHelper::programCmdStream<GfxFamily>(child,
|
||||
commandListPreemption,
|
||||
statePreemption,
|
||||
csr->getPreemptionAllocation());
|
||||
statePreemption = commandListPreemption;
|
||||
}
|
||||
|
||||
for (size_t iter = 0; iter < cmdBufferCount; iter++) {
|
||||
auto allocation = cmdBufferAllocations[iter];
|
||||
NEO::EncodeBatchBufferStartOrEnd<GfxFamily>::programBatchBufferStart(&child, allocation->getGpuAddress(), true);
|
||||
}
|
||||
|
||||
printfFunctionContainer.insert(printfFunctionContainer.end(),
|
||||
commandList->getPrintfFunctionContainer().begin(),
|
||||
commandList->getPrintfFunctionContainer().end());
|
||||
|
||||
NEO::PageFaultManager *pageFaultManager = nullptr;
|
||||
if (performMigration) {
|
||||
pageFaultManager = device->getDriverHandle()->getMemoryManager()->getPageFaultManager();
|
||||
if (pageFaultManager == nullptr) {
|
||||
performMigration = false;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto alloc : commandList->commandContainer.getResidencyContainer()) {
|
||||
if (residencyContainer.end() ==
|
||||
std::find(residencyContainer.begin(), residencyContainer.end(), alloc)) {
|
||||
residencyContainer.push_back(alloc);
|
||||
|
||||
if (performMigration) {
|
||||
if (alloc &&
|
||||
(alloc->getAllocationType() == NEO::GraphicsAllocation::AllocationType::SVM_GPU ||
|
||||
alloc->getAllocationType() == NEO::GraphicsAllocation::AllocationType::SVM_CPU)) {
|
||||
pageFaultManager->moveAllocationToGpuDomain(reinterpret_cast<void *>(alloc->getGpuAddress()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
commandQueuePreemptionMode = statePreemption;
|
||||
|
||||
if (hFence) {
|
||||
residencyContainer.push_back(&fence->getAllocation());
|
||||
NEO::MemorySynchronizationCommands<GfxFamily>::obtainPipeControlAndProgramPostSyncOperation(
|
||||
child, POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA,
|
||||
fence->getGpuAddress(), Fence::STATE_SIGNALED, true, device->getHwInfo());
|
||||
}
|
||||
|
||||
dispatchTaskCountWrite(child, true);
|
||||
residencyContainer.push_back(csr->getTagAllocation());
|
||||
void *endingCmd = nullptr;
|
||||
if (directSubmissionEnabled) {
|
||||
endingCmd = child.getSpace(0);
|
||||
NEO::EncodeBatchBufferStartOrEnd<GfxFamily>::programBatchBufferStart(&child, 0ull, false);
|
||||
} else {
|
||||
MI_BATCH_BUFFER_END cmd = GfxFamily::cmdInitBatchBufferEnd;
|
||||
auto buffer = child.getSpaceForCmd<MI_BATCH_BUFFER_END>();
|
||||
*(MI_BATCH_BUFFER_END *)buffer = cmd;
|
||||
}
|
||||
|
||||
if (padding) {
|
||||
void *paddingPtr = child.getSpace(padding);
|
||||
memset(paddingPtr, 0, padding);
|
||||
}
|
||||
|
||||
submitBatchBuffer(ptrDiff(child.getCpuBase(), commandStream->getCpuBase()), residencyContainer, endingCmd);
|
||||
|
||||
this->taskCount = csr->peekTaskCount();
|
||||
|
||||
csr->makeSurfacePackNonResident(residencyContainer);
|
||||
|
||||
if (getSynchronousMode() == ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS) {
|
||||
this->synchronize(std::numeric_limits<uint32_t>::max());
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
void CommandQueueHw<gfxCoreFamily>::programFrontEnd(uint64_t scratchAddress, NEO::LinearStream &commandStream) {
|
||||
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
|
||||
UNRECOVERABLE_IF(csr == nullptr);
|
||||
NEO::PreambleHelper<GfxFamily>::programVFEState(&commandStream,
|
||||
device->getHwInfo(),
|
||||
commandQueuePerThreadScratchSize,
|
||||
scratchAddress,
|
||||
device->getMaxNumHwThreads(),
|
||||
csr->getOsContext().getEngineType());
|
||||
frontEndInit = true;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
size_t CommandQueueHw<gfxCoreFamily>::estimateFrontEndCmdSize() {
|
||||
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
|
||||
return NEO::PreambleHelper<GfxFamily>::getVFECommandsSize();
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
size_t CommandQueueHw<gfxCoreFamily>::estimatePipelineSelect() {
|
||||
|
||||
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
|
||||
return NEO::PreambleHelper<GfxFamily>::getCmdSizeForPipelineSelect(device->getHwInfo());
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
void CommandQueueHw<gfxCoreFamily>::programPipelineSelect(NEO::LinearStream &commandStream) {
|
||||
NEO::PipelineSelectArgs args = {0, 0};
|
||||
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
|
||||
NEO::PreambleHelper<GfxFamily>::programPipelineSelect(&commandStream, args, device->getHwInfo());
|
||||
gpgpuEnabled = true;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
void CommandQueueHw<gfxCoreFamily>::dispatchTaskCountWrite(NEO::LinearStream &commandStream, bool flushDataCache) {
|
||||
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
|
||||
using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL;
|
||||
using POST_SYNC_OPERATION = typename PIPE_CONTROL::POST_SYNC_OPERATION;
|
||||
|
||||
UNRECOVERABLE_IF(csr == nullptr);
|
||||
|
||||
auto taskCountToWrite = csr->peekTaskCount() + 1;
|
||||
auto gpuAddress = static_cast<uint64_t>(csr->getTagAllocation()->getGpuAddress());
|
||||
|
||||
NEO::MemorySynchronizationCommands<GfxFamily>::obtainPipeControlAndProgramPostSyncOperation(
|
||||
commandStream, POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA,
|
||||
gpuAddress, taskCountToWrite, true, device->getHwInfo());
|
||||
}
|
||||
} // namespace L0
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/command_stream/csr_definitions.h"
|
||||
#include "shared/source/command_stream/linear_stream.h"
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/helpers/interlocked_max.h"
|
||||
#include "shared/source/helpers/preamble.h"
|
||||
#include "shared/source/helpers/state_base_address.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
|
||||
#include "level_zero/core/source/cmdlist.h"
|
||||
#include "level_zero/core/source/cmdqueue_hw.h"
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include "level_zero/core/source/fence.h"
|
||||
#include "level_zero/tools/source/metrics/metric.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
void CommandQueueHw<gfxCoreFamily>::programGeneralStateBaseAddress(uint64_t gsba, NEO::LinearStream &commandStream) {
|
||||
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
|
||||
using STATE_BASE_ADDRESS = typename GfxFamily::STATE_BASE_ADDRESS;
|
||||
using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL;
|
||||
|
||||
PIPE_CONTROL *pcCmd = commandStream.getSpaceForCmd<PIPE_CONTROL>();
|
||||
*pcCmd = GfxFamily::cmdInitPipeControl;
|
||||
|
||||
pcCmd->setTextureCacheInvalidationEnable(true);
|
||||
pcCmd->setDcFlushEnable(true);
|
||||
pcCmd->setCommandStreamerStallEnable(true);
|
||||
|
||||
auto gmmHelper = device->getNEODevice()->getGmmHelper();
|
||||
|
||||
NEO::StateBaseAddressHelper<GfxFamily>::programStateBaseAddress(commandStream,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
gsba,
|
||||
true,
|
||||
(device->getMOCS(true, false) >> 1),
|
||||
device->getDriverHandle()->getMemoryManager()->getInternalHeapBaseAddress(0),
|
||||
true,
|
||||
gmmHelper,
|
||||
false);
|
||||
|
||||
gsbaInit = true;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
size_t CommandQueueHw<gfxCoreFamily>::estimateStateBaseAddressCmdSize() {
|
||||
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
|
||||
using STATE_BASE_ADDRESS = typename GfxFamily::STATE_BASE_ADDRESS;
|
||||
using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL;
|
||||
|
||||
constexpr size_t size = sizeof(STATE_BASE_ADDRESS) + sizeof(PIPE_CONTROL);
|
||||
return size;
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
void CommandQueueHw<gfxCoreFamily>::handleScratchSpace(NEO::ResidencyContainer &residency,
|
||||
NEO::ScratchSpaceController *scratchController,
|
||||
bool &gsbaState, bool &frontEndState) {
|
||||
|
||||
if (commandQueuePerThreadScratchSize > 0) {
|
||||
scratchController->setRequiredScratchSpace(nullptr, commandQueuePerThreadScratchSize, 0u, csr->peekTaskCount(),
|
||||
csr->getOsContext(), gsbaState, frontEndState);
|
||||
auto scratchAllocation = scratchController->getScratchSpaceAllocation();
|
||||
residency.push_back(scratchAllocation);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/command_stream/csr_definitions.h"
|
||||
#include "shared/source/command_stream/submissions_aggregator.h"
|
||||
#include "shared/source/memory_manager/memory_constants.h"
|
||||
|
||||
#include "level_zero/core/source/cmdqueue.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
class LinearStream;
|
||||
class GraphicsAllocation;
|
||||
class MemoryManager;
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
namespace L0 {
|
||||
struct CommandList;
|
||||
struct Kernel;
|
||||
struct CommandQueueImp : public CommandQueue {
|
||||
class CommandBufferManager {
|
||||
public:
|
||||
enum BUFFER_ALLOCATION : uint32_t {
|
||||
FIRST = 0,
|
||||
SECOND,
|
||||
COUNT
|
||||
};
|
||||
|
||||
void initialize(Device *device, size_t sizeRequested);
|
||||
void destroy(NEO::MemoryManager *memoryManager);
|
||||
void switchBuffers(NEO::CommandStreamReceiver *csr);
|
||||
|
||||
NEO::GraphicsAllocation *getCurrentBufferAllocation() {
|
||||
return buffers[bufferUse];
|
||||
}
|
||||
|
||||
void setCurrentFlushStamp(NEO::FlushStamp flushStamp) {
|
||||
flushId[bufferUse] = flushStamp;
|
||||
}
|
||||
|
||||
private:
|
||||
NEO::GraphicsAllocation *buffers[BUFFER_ALLOCATION::COUNT];
|
||||
NEO::FlushStamp flushId[BUFFER_ALLOCATION::COUNT];
|
||||
BUFFER_ALLOCATION bufferUse = BUFFER_ALLOCATION::FIRST;
|
||||
};
|
||||
static constexpr size_t defaultQueueCmdBufferSize = 128 * MemoryConstants::kiloByte;
|
||||
static constexpr size_t minCmdBufferPtrAlign = 8;
|
||||
static constexpr size_t totalCmdBufferSize =
|
||||
defaultQueueCmdBufferSize +
|
||||
MemoryConstants::cacheLineSize +
|
||||
NEO::CSRequirements::csOverfetchSize;
|
||||
|
||||
CommandQueueImp(Device *device, NEO::CommandStreamReceiver *csr, const ze_command_queue_desc_t *desc)
|
||||
: device(device), csr(csr), desc(*desc), commandStream(nullptr) {
|
||||
std::atomic_init(&commandQueuePerThreadScratchSize, 0u);
|
||||
}
|
||||
|
||||
ze_result_t destroy() override;
|
||||
|
||||
ze_result_t synchronize(uint32_t timeout) override;
|
||||
|
||||
void initialize();
|
||||
|
||||
Device *getDevice() { return device; }
|
||||
|
||||
uint32_t getTaskCount() { return taskCount; }
|
||||
|
||||
NEO::CommandStreamReceiver *getCsr() { return csr; }
|
||||
|
||||
void reserveLinearStreamSize(size_t size);
|
||||
ze_command_queue_mode_t getSynchronousMode();
|
||||
virtual void dispatchTaskCountWrite(NEO::LinearStream &commandStream, bool flushDataCache) = 0;
|
||||
|
||||
protected:
|
||||
void submitBatchBuffer(size_t offset, NEO::ResidencyContainer &residencyContainer, void *endingCmdPtr);
|
||||
|
||||
ze_result_t synchronizeByPollingForTaskCount(uint32_t timeout);
|
||||
|
||||
void printFunctionsPrintfOutput();
|
||||
|
||||
Device *device;
|
||||
NEO::CommandStreamReceiver *csr;
|
||||
const ze_command_queue_desc_t desc;
|
||||
NEO::LinearStream *commandStream;
|
||||
uint32_t taskCount = 0;
|
||||
std::vector<Kernel *> printfFunctionContainer;
|
||||
bool gsbaInit = false;
|
||||
bool frontEndInit = false;
|
||||
bool gpgpuEnabled = false;
|
||||
CommandBufferManager buffers;
|
||||
};
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,15 @@
|
|||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_SRCS_COMPILER_INTERFACE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/default_cache_config.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/default_l0_cache_config.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/default_l0_cache_config.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/l0_reg_path.h
|
||||
)
|
||||
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_COMPILER_INTERFACE ${L0_SRCS_COMPILER_INTERFACE})
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/compiler_interface/default_cache_config.h"
|
||||
|
||||
#include "level_zero/core/source/compiler_interface/default_l0_cache_config.h"
|
||||
|
||||
namespace NEO {
|
||||
CompilerCacheConfig getDefaultCompilerCacheConfig() {
|
||||
return L0::getDefaultL0CompilerCacheConfig();
|
||||
}
|
||||
|
||||
} // namespace NEO
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#define L0_CACHE_LOCATION "l0_c_cache"
|
||||
|
||||
#include "level_zero/core/source/compiler_interface/default_l0_cache_config.h"
|
||||
|
||||
#include "shared/source/utilities/debug_settings_reader.h"
|
||||
|
||||
#include "level_zero/core/source/compiler_interface/l0_reg_path.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
NEO::CompilerCacheConfig getDefaultL0CompilerCacheConfig() {
|
||||
NEO::CompilerCacheConfig ret;
|
||||
|
||||
std::string keyName = registryPath;
|
||||
keyName += "l0_c_cache_dir";
|
||||
std::unique_ptr<NEO::SettingsReader> settingsReader(NEO::SettingsReader::createOsReader(false, keyName));
|
||||
ret.cacheDir = settingsReader->getSetting(settingsReader->appSpecificLocation(keyName), static_cast<std::string>(L0_CACHE_LOCATION));
|
||||
|
||||
ret.cacheFileExtension = ".l0_c_cache";
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace L0
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/compiler_interface/compiler_cache.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
NEO::CompilerCacheConfig getDefaultL0CompilerCacheConfig();
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
namespace L0 {
|
||||
extern const char *registryPath;
|
||||
} // namespace L0
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/page_fault_manager/cpu_page_fault_manager.h"
|
||||
|
||||
#include "level_zero/core/source/cmdlist.h"
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include "level_zero/core/source/device_imp.h"
|
||||
#include "level_zero/core/source/driver_handle_imp.h"
|
||||
|
||||
namespace NEO {
|
||||
void PageFaultManager::transferToCpu(void *ptr, size_t size, void *device) {
|
||||
L0::DeviceImp *deviceImp = static_cast<L0::DeviceImp *>(device);
|
||||
|
||||
NEO::SvmAllocationData *allocData = deviceImp->getDriverHandle()->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||
UNRECOVERABLE_IF(allocData == nullptr);
|
||||
|
||||
auto ret =
|
||||
deviceImp->pageFaultCommandList->appendPageFaultCopy(allocData->cpuAllocation,
|
||||
allocData->gpuAllocation,
|
||||
allocData->size, true);
|
||||
UNRECOVERABLE_IF(ret);
|
||||
}
|
||||
void PageFaultManager::transferToGpu(void *ptr, void *device) {
|
||||
L0::DeviceImp *deviceImp = static_cast<L0::DeviceImp *>(device);
|
||||
|
||||
NEO::SvmAllocationData *allocData = deviceImp->getDriverHandle()->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||
UNRECOVERABLE_IF(allocData == nullptr);
|
||||
|
||||
auto ret =
|
||||
deviceImp->pageFaultCommandList->appendPageFaultCopy(allocData->gpuAllocation,
|
||||
allocData->cpuAllocation,
|
||||
allocData->size, false);
|
||||
UNRECOVERABLE_IF(ret);
|
||||
}
|
||||
} // namespace NEO
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
|
||||
#include "level_zero/core/source/compiler_interface/l0_reg_path.h"
|
||||
|
||||
namespace NEO {
|
||||
DebugSettingsManager<globalDebugFunctionalityLevel> DebugManager(L0::registryPath);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/debugger/debugger.h"
|
||||
|
||||
#include "level_zero/core/source/debugger/debugger_l0.h"
|
||||
|
||||
std::unique_ptr<NEO::Debugger> NEO::Debugger::create(HardwareInfo *hwInfo) {
|
||||
return std::make_unique<L0::DebuggerL0>();
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_SRCS_DEBUGGER
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debugger_l0.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debugger_l0.h
|
||||
)
|
||||
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_DEBUGGER ${L0_SRCS_DEBUGGER})
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/debugger/debugger_l0.h"
|
||||
|
||||
namespace L0 {
|
||||
bool DebuggerL0::isDebuggerActive() {
|
||||
return false;
|
||||
}
|
||||
} // namespace L0
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/debugger/debugger.h"
|
||||
|
||||
namespace L0 {
|
||||
class DebuggerL0 : public NEO::Debugger {
|
||||
public:
|
||||
bool isDebuggerActive() override;
|
||||
~DebuggerL0() override = default;
|
||||
};
|
||||
} // namespace L0
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/command_stream/preemption_mode.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
|
||||
#include "level_zero/core/source/driver.h"
|
||||
#include "level_zero/core/source/driver_handle.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
struct _ze_device_handle_t {};
|
||||
struct DeviceInfo;
|
||||
namespace NEO {
|
||||
class Device;
|
||||
class MemoryManager;
|
||||
} // namespace NEO
|
||||
|
||||
namespace L0 {
|
||||
struct DriverHandle;
|
||||
struct BuiltinFunctionsLib;
|
||||
struct ExecutionEnvironment;
|
||||
struct MetricContext;
|
||||
|
||||
struct Device : _ze_device_handle_t {
|
||||
virtual uint32_t getRootDeviceIndex() = 0;
|
||||
virtual ze_result_t canAccessPeer(ze_device_handle_t hPeerDevice, ze_bool_t *value) = 0;
|
||||
virtual ze_result_t copyCommandList(ze_command_list_handle_t hCommandList,
|
||||
ze_command_list_handle_t *phCommandList) = 0;
|
||||
|
||||
virtual ze_result_t createCommandList(const ze_command_list_desc_t *desc,
|
||||
ze_command_list_handle_t *commandList) = 0;
|
||||
|
||||
virtual ze_result_t createCommandListImmediate(const ze_command_queue_desc_t *desc,
|
||||
ze_command_list_handle_t *commandList) = 0;
|
||||
|
||||
virtual ze_result_t createCommandQueue(const ze_command_queue_desc_t *desc,
|
||||
ze_command_queue_handle_t *commandQueue) = 0;
|
||||
|
||||
virtual ze_result_t createEventPool(const ze_event_pool_desc_t *desc,
|
||||
ze_event_pool_handle_t *phEventPool) = 0;
|
||||
virtual ze_result_t createImage(const ze_image_desc_t *desc, ze_image_handle_t *phImage) = 0;
|
||||
|
||||
virtual ze_result_t createModule(const ze_module_desc_t *desc, ze_module_handle_t *module,
|
||||
ze_module_build_log_handle_t *buildLog) = 0;
|
||||
virtual ze_result_t createSampler(const ze_sampler_desc_t *pDesc,
|
||||
ze_sampler_handle_t *phSampler) = 0;
|
||||
virtual ze_result_t evictImage(ze_image_handle_t hImage) = 0;
|
||||
virtual ze_result_t evictMemory(void *ptr, size_t size) = 0;
|
||||
virtual ze_result_t
|
||||
getComputeProperties(ze_device_compute_properties_t *pComputeProperties) = 0;
|
||||
virtual ze_result_t getP2PProperties(ze_device_handle_t hPeerDevice,
|
||||
ze_device_p2p_properties_t *pP2PProperties) = 0;
|
||||
virtual ze_result_t getKernelProperties(ze_device_kernel_properties_t *pKernelProperties) = 0;
|
||||
virtual ze_result_t getMemoryProperties(uint32_t *pCount, ze_device_memory_properties_t *pMemProperties) = 0;
|
||||
virtual ze_result_t getMemoryAccessProperties(ze_device_memory_access_properties_t *pMemAccessProperties) = 0;
|
||||
virtual ze_result_t getProperties(ze_device_properties_t *pDeviceProperties) = 0;
|
||||
virtual ze_result_t getSubDevices(uint32_t *pCount, ze_device_handle_t *phSubdevices) = 0;
|
||||
virtual ze_result_t makeImageResident(ze_image_handle_t hImage) = 0;
|
||||
virtual ze_result_t makeMemoryResident(void *ptr, size_t size) = 0;
|
||||
virtual ze_result_t setIntermediateCacheConfig(ze_cache_config_t cacheConfig) = 0;
|
||||
virtual ze_result_t setLastLevelCacheConfig(ze_cache_config_t cacheConfig) = 0;
|
||||
virtual ze_result_t getCacheProperties(ze_device_cache_properties_t *pCacheProperties) = 0;
|
||||
virtual ze_result_t imageGetProperties(const ze_image_desc_t *desc, ze_image_properties_t *pImageProperties) = 0;
|
||||
virtual ze_result_t getDeviceImageProperties(ze_device_image_properties_t *pDeviceImageProperties) = 0;
|
||||
|
||||
virtual ze_result_t systemBarrier() = 0;
|
||||
|
||||
virtual ze_result_t registerCLMemory(cl_context context, cl_mem mem, void **ptr) = 0;
|
||||
virtual ze_result_t registerCLProgram(cl_context context, cl_program program,
|
||||
ze_module_handle_t *phModule) = 0;
|
||||
virtual ze_result_t registerCLCommandQueue(cl_context context, cl_command_queue commandQueue,
|
||||
ze_command_queue_handle_t *phCommandQueue) = 0;
|
||||
virtual ~Device() = default;
|
||||
|
||||
virtual void *getExecEnvironment() = 0;
|
||||
virtual BuiltinFunctionsLib *getBuiltinFunctionsLib() = 0;
|
||||
virtual uint32_t getMOCS(bool l3enabled, bool l1enabled) = 0;
|
||||
virtual uint32_t getMaxNumHwThreads() const = 0;
|
||||
|
||||
virtual NEO::HwHelper &getHwHelper() = 0;
|
||||
virtual bool isMultiDeviceCapable() const = 0;
|
||||
virtual const NEO::HardwareInfo &getHwInfo() const = 0;
|
||||
virtual NEO::OSInterface &getOsInterface() = 0;
|
||||
virtual uint32_t getPlatformInfo() const = 0;
|
||||
virtual MetricContext &getMetricContext() = 0;
|
||||
|
||||
virtual ze_result_t activateMetricGroups(uint32_t count,
|
||||
zet_metric_group_handle_t *phMetricGroups) = 0;
|
||||
virtual void activateMetricGroups() = 0;
|
||||
|
||||
virtual DriverHandle *getDriverHandle() = 0;
|
||||
virtual void setDriverHandle(DriverHandle *driverHandle) = 0;
|
||||
|
||||
static Device *fromHandle(ze_device_handle_t handle) { return static_cast<Device *>(handle); }
|
||||
|
||||
inline ze_device_handle_t toHandle() { return this; }
|
||||
|
||||
static Device *create(DriverHandle *driverHandle, NEO::Device *neoDevice);
|
||||
|
||||
virtual NEO::PreemptionMode getDevicePreemptionMode() const = 0;
|
||||
virtual const DeviceInfo &getDeviceInfo() const = 0;
|
||||
virtual NEO::Device *getNEODevice() = 0;
|
||||
};
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,603 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/device_imp.h"
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/device/sub_device.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/gmm_helper/gmm_helper.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/kernel/grf_config.h"
|
||||
#include "shared/source/memory_manager/memory_constants.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/memory_manager/memory_operations_handler.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/source/os_interface/os_time.h"
|
||||
|
||||
#include "opencl/source/device/device_info.h"
|
||||
#include "opencl/source/device/device_info_map.h"
|
||||
#include "opencl/source/mem_obj/mem_obj.h"
|
||||
#include "opencl/source/program/program.h"
|
||||
|
||||
#include "level_zero/core/source/builtin_functions_lib.h"
|
||||
#include "level_zero/core/source/cmdlist.h"
|
||||
#include "level_zero/core/source/cmdqueue.h"
|
||||
#include "level_zero/core/source/driver_handle_imp.h"
|
||||
#include "level_zero/core/source/event.h"
|
||||
#include "level_zero/core/source/image.h"
|
||||
#include "level_zero/core/source/memory_operations_helper.h"
|
||||
#include "level_zero/core/source/module.h"
|
||||
#include "level_zero/core/source/printf_handler.h"
|
||||
#include "level_zero/core/source/sampler.h"
|
||||
#include "level_zero/tools/source/metrics/metric.h"
|
||||
|
||||
#include "hw_helpers.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
uint32_t DeviceImp::getRootDeviceIndex() {
|
||||
return neoDevice->getRootDeviceIndex();
|
||||
}
|
||||
|
||||
DriverHandle *DeviceImp::getDriverHandle() {
|
||||
return this->driverHandle;
|
||||
}
|
||||
|
||||
void DeviceImp::setDriverHandle(DriverHandle *driverHandle) {
|
||||
this->driverHandle = driverHandle;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::canAccessPeer(ze_device_handle_t hPeerDevice, ze_bool_t *value) {
|
||||
*value = false;
|
||||
if (NEO::DebugManager.flags.CreateMultipleRootDevices.get() > 0) {
|
||||
*value = true;
|
||||
}
|
||||
if (NEO::DebugManager.flags.CreateMultipleSubDevices.get() > 0) {
|
||||
*value = true;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::copyCommandList(ze_command_list_handle_t hCommandList,
|
||||
ze_command_list_handle_t *phCommandList) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::createCommandList(const ze_command_list_desc_t *desc,
|
||||
ze_command_list_handle_t *commandList) {
|
||||
auto productFamily = neoDevice->getHardwareInfo().platform.eProductFamily;
|
||||
*commandList = CommandList::create(productFamily, this);
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::createCommandListImmediate(const ze_command_queue_desc_t *desc,
|
||||
ze_command_list_handle_t *phCommandList) {
|
||||
auto productFamily = neoDevice->getHardwareInfo().platform.eProductFamily;
|
||||
*phCommandList = CommandList::createImmediate(productFamily, this, desc, false);
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::createCommandQueue(const ze_command_queue_desc_t *desc,
|
||||
ze_command_queue_handle_t *commandQueue) {
|
||||
auto productFamily = neoDevice->getHardwareInfo().platform.eProductFamily;
|
||||
|
||||
auto csr = neoDevice->getDefaultEngine().commandStreamReceiver;
|
||||
|
||||
*commandQueue = CommandQueue::create(productFamily, this, csr, desc);
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::createEventPool(const ze_event_pool_desc_t *desc,
|
||||
ze_event_pool_handle_t *eventPool) {
|
||||
*eventPool = EventPool::create(this, desc);
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::createImage(const ze_image_desc_t *desc, ze_image_handle_t *phImage) {
|
||||
if (desc->format.layout >= ze_image_format_layout_t::ZE_IMAGE_FORMAT_LAYOUT_Y8) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
auto productFamily = neoDevice->getHardwareInfo().platform.eProductFamily;
|
||||
*phImage = Image::create(productFamily, this, desc);
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::createSampler(const ze_sampler_desc_t *desc,
|
||||
ze_sampler_handle_t *sampler) {
|
||||
auto productFamily = neoDevice->getHardwareInfo().platform.eProductFamily;
|
||||
*sampler = Sampler::create(productFamily, this, desc);
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::createModule(const ze_module_desc_t *desc, ze_module_handle_t *module,
|
||||
ze_module_build_log_handle_t *buildLog) {
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
if (buildLog) {
|
||||
moduleBuildLog = ModuleBuildLog::create();
|
||||
*buildLog = moduleBuildLog->toHandle();
|
||||
}
|
||||
auto modulePtr = Module::create(this, desc, neoDevice, moduleBuildLog);
|
||||
if (modulePtr == nullptr) {
|
||||
return ZE_RESULT_ERROR_MODULE_BUILD_FAILURE;
|
||||
}
|
||||
|
||||
*module = modulePtr;
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::evictImage(ze_image_handle_t hImage) {
|
||||
auto alloc = Image::fromHandle(hImage)->getAllocation();
|
||||
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
||||
auto success = memoryOperationsIface->evict(*alloc);
|
||||
return changeMemoryOperationStatusToL0ResultType(success);
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::evictMemory(void *ptr, size_t size) {
|
||||
auto alloc = getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(ptr);
|
||||
if (alloc == nullptr) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
||||
auto success = memoryOperationsIface->evict(*alloc->gpuAllocation);
|
||||
return changeMemoryOperationStatusToL0ResultType(success);
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::getComputeProperties(ze_device_compute_properties_t *pComputeProperties) {
|
||||
const auto &deviceInfo = this->neoDevice->getDeviceInfo();
|
||||
|
||||
pComputeProperties->maxTotalGroupSize = static_cast<uint32_t>(deviceInfo.maxWorkGroupSize);
|
||||
|
||||
pComputeProperties->maxGroupSizeX = static_cast<uint32_t>(deviceInfo.maxWorkItemSizes[0]);
|
||||
pComputeProperties->maxGroupSizeY = static_cast<uint32_t>(deviceInfo.maxWorkItemSizes[1]);
|
||||
pComputeProperties->maxGroupSizeZ = static_cast<uint32_t>(deviceInfo.maxWorkItemSizes[2]);
|
||||
|
||||
pComputeProperties->maxGroupCountX = 0xffffffff;
|
||||
pComputeProperties->maxGroupCountY = 0xffffffff;
|
||||
pComputeProperties->maxGroupCountZ = 0xffffffff;
|
||||
|
||||
pComputeProperties->maxSharedLocalMemory = static_cast<uint32_t>(deviceInfo.localMemSize);
|
||||
|
||||
pComputeProperties->numSubGroupSizes = static_cast<uint32_t>(deviceInfo.maxSubGroups.size());
|
||||
|
||||
for (uint32_t i = 0; i < pComputeProperties->numSubGroupSizes; ++i) {
|
||||
pComputeProperties->subGroupSizes[i] = static_cast<uint32_t>(deviceInfo.maxSubGroups[i]);
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::getP2PProperties(ze_device_handle_t hPeerDevice,
|
||||
ze_device_p2p_properties_t *pP2PProperties) {
|
||||
pP2PProperties->accessSupported = true;
|
||||
pP2PProperties->atomicsSupported = false;
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::getMemoryProperties(uint32_t *pCount, ze_device_memory_properties_t *pMemProperties) {
|
||||
if (*pCount == 0) {
|
||||
*pCount = 1;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
if (*pCount > 1) {
|
||||
*pCount = 1;
|
||||
}
|
||||
|
||||
if (nullptr == pMemProperties) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
const auto &deviceInfo = this->neoDevice->getDeviceInfo();
|
||||
|
||||
pMemProperties->maxClockRate = deviceInfo.maxClockFrequency;
|
||||
pMemProperties->maxBusWidth = deviceInfo.addressBits;
|
||||
pMemProperties->totalSize = deviceInfo.globalMemSize;
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::getMemoryAccessProperties(ze_device_memory_access_properties_t *pMemAccessProperties) {
|
||||
pMemAccessProperties->hostAllocCapabilities =
|
||||
static_cast<ze_memory_access_capabilities_t>(ZE_MEMORY_ACCESS | ZE_MEMORY_ATOMIC_ACCESS);
|
||||
pMemAccessProperties->deviceAllocCapabilities =
|
||||
static_cast<ze_memory_access_capabilities_t>(ZE_MEMORY_ACCESS | ZE_MEMORY_ATOMIC_ACCESS);
|
||||
pMemAccessProperties->sharedSingleDeviceAllocCapabilities =
|
||||
static_cast<ze_memory_access_capabilities_t>(ZE_MEMORY_ACCESS | ZE_MEMORY_ATOMIC_ACCESS);
|
||||
pMemAccessProperties->sharedCrossDeviceAllocCapabilities =
|
||||
ze_memory_access_capabilities_t{};
|
||||
pMemAccessProperties->sharedSystemAllocCapabilities =
|
||||
ze_memory_access_capabilities_t{};
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static constexpr ze_fp_capabilities_t defaultFpFlags = static_cast<ze_fp_capabilities_t>(ZE_FP_CAPS_ROUND_TO_NEAREST |
|
||||
ZE_FP_CAPS_ROUND_TO_ZERO |
|
||||
ZE_FP_CAPS_ROUND_TO_INF |
|
||||
ZE_FP_CAPS_INF_NAN |
|
||||
ZE_FP_CAPS_DENORM |
|
||||
ZE_FP_CAPS_FMA);
|
||||
|
||||
ze_result_t DeviceImp::getKernelProperties(ze_device_kernel_properties_t *pKernelProperties) {
|
||||
const auto &hardwareInfo = this->neoDevice->getHardwareInfo();
|
||||
const auto &deviceInfo = this->neoDevice->getDeviceInfo();
|
||||
auto &hwHelper = NEO::HwHelper::get(hardwareInfo.platform.eRenderCoreFamily);
|
||||
|
||||
std::string ilVersion = deviceInfo.ilVersion;
|
||||
size_t majorVersionPos = ilVersion.find('_');
|
||||
size_t minorVersionPos = ilVersion.find('.');
|
||||
|
||||
if (majorVersionPos != std::string::npos && minorVersionPos != std::string::npos) {
|
||||
uint32_t majorSpirvVersion = static_cast<uint32_t>(std::stoul(ilVersion.substr(majorVersionPos + 1, minorVersionPos)));
|
||||
uint32_t minorSpirvVersion = static_cast<uint32_t>(std::stoul(ilVersion.substr(minorVersionPos + 1)));
|
||||
pKernelProperties->spirvVersionSupported = ZE_MAKE_VERSION(majorSpirvVersion, minorSpirvVersion);
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
pKernelProperties->fp16Supported = true;
|
||||
pKernelProperties->int64AtomicsSupported = hardwareInfo.capabilityTable.ftrSupportsInteger64BitAtomics;
|
||||
pKernelProperties->fp64Supported = hardwareInfo.capabilityTable.ftrSupportsFP64;
|
||||
pKernelProperties->halfFpCapabilities = defaultFpFlags;
|
||||
pKernelProperties->singleFpCapabilities = hardwareInfo.capabilityTable.ftrSupports64BitMath ? ZE_FP_CAPS_ROUNDED_DIVIDE_SQRT : ZE_FP_CAPS_NONE;
|
||||
pKernelProperties->doubleFpCapabilities = hardwareInfo.capabilityTable.ftrSupportsFP64 ? defaultFpFlags : ZE_FP_CAPS_NONE;
|
||||
|
||||
pKernelProperties->nativeKernelSupported.id[0] = 0;
|
||||
|
||||
processAdditionalKernelProperties(hwHelper, pKernelProperties);
|
||||
|
||||
pKernelProperties->maxArgumentsSize = static_cast<uint32_t>(DeviceInfoTable::Map<CL_DEVICE_MAX_PARAMETER_SIZE>::getValue(this->neoDevice->getDeviceInfo()));
|
||||
|
||||
pKernelProperties->printfBufferSize = static_cast<uint32_t>(DeviceInfoTable::Map<CL_DEVICE_PRINTF_BUFFER_SIZE>::getValue(this->neoDevice->getDeviceInfo()));
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::getProperties(ze_device_properties_t *pDeviceProperties) {
|
||||
const auto &deviceInfo = this->neoDevice->getDeviceInfo();
|
||||
const auto &hardwareInfo = this->neoDevice->getHardwareInfo();
|
||||
auto &hwHelper = NEO::HwHelper::get(hardwareInfo.platform.eRenderCoreFamily);
|
||||
|
||||
pDeviceProperties->type = ZE_DEVICE_TYPE_GPU;
|
||||
|
||||
pDeviceProperties->vendorId = deviceInfo.vendorId;
|
||||
|
||||
pDeviceProperties->deviceId = hardwareInfo.platform.usDeviceID;
|
||||
|
||||
uint32_t rootDeviceIndex = this->neoDevice->getRootDeviceIndex();
|
||||
|
||||
memcpy_s(pDeviceProperties->uuid.id, sizeof(uint32_t), &pDeviceProperties->vendorId, sizeof(pDeviceProperties->vendorId));
|
||||
memcpy_s(pDeviceProperties->uuid.id + sizeof(uint32_t), sizeof(uint32_t), &pDeviceProperties->deviceId, sizeof(pDeviceProperties->deviceId));
|
||||
memcpy_s(pDeviceProperties->uuid.id + (2 * sizeof(uint32_t)), sizeof(uint32_t), &rootDeviceIndex, sizeof(rootDeviceIndex));
|
||||
|
||||
pDeviceProperties->isSubdevice = isSubdevice;
|
||||
|
||||
pDeviceProperties->subdeviceId = isSubdevice ? static_cast<NEO::SubDevice *>(neoDevice)->getSubDeviceIndex() : 0;
|
||||
|
||||
pDeviceProperties->coreClockRate = deviceInfo.maxClockFrequency;
|
||||
|
||||
pDeviceProperties->unifiedMemorySupported = true;
|
||||
|
||||
pDeviceProperties->eccMemorySupported = static_cast<ze_bool_t>(DeviceInfoTable::Map<CL_DEVICE_ERROR_CORRECTION_SUPPORT>::getValue(this->neoDevice->getDeviceInfo()));
|
||||
|
||||
pDeviceProperties->onDemandPageFaultsSupported = true;
|
||||
|
||||
pDeviceProperties->maxCommandQueues = deviceInfo.maxOnDeviceQueues;
|
||||
|
||||
pDeviceProperties->numAsyncComputeEngines = static_cast<uint32_t>(hwHelper.getGpgpuEngineInstances(hardwareInfo).size());
|
||||
|
||||
pDeviceProperties->numAsyncCopyEngines = 1;
|
||||
|
||||
pDeviceProperties->maxCommandQueuePriority = 0;
|
||||
|
||||
pDeviceProperties->numThreadsPerEU = deviceInfo.numThreadsPerEU;
|
||||
|
||||
pDeviceProperties->physicalEUSimdWidth = hwHelper.getMinimalSIMDSize();
|
||||
|
||||
pDeviceProperties->numEUsPerSubslice = hardwareInfo.gtSystemInfo.MaxEuPerSubSlice;
|
||||
|
||||
pDeviceProperties->numSubslicesPerSlice = hardwareInfo.gtSystemInfo.SubSliceCount / hardwareInfo.gtSystemInfo.SliceCount;
|
||||
|
||||
pDeviceProperties->numSlices = hardwareInfo.gtSystemInfo.SliceCount * this->numSubDevices;
|
||||
|
||||
pDeviceProperties->timerResolution = static_cast<uint64_t>(DeviceInfoTable::Map<CL_DEVICE_PROFILING_TIMER_RESOLUTION>::getValue(this->neoDevice->getDeviceInfo()));
|
||||
|
||||
std::string name = "Intel(R) ";
|
||||
name += NEO::familyName[hardwareInfo.platform.eRenderCoreFamily];
|
||||
name += '\0';
|
||||
memcpy_s(pDeviceProperties->name, name.length(), name.c_str(), name.length());
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::getSubDevices(uint32_t *pCount, ze_device_handle_t *phSubdevices) {
|
||||
if (*pCount == 0) {
|
||||
*pCount = this->numSubDevices;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
if (phSubdevices == nullptr) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (*pCount > this->numSubDevices) {
|
||||
*pCount = this->numSubDevices;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < *pCount; i++) {
|
||||
phSubdevices[i] = this->subDevices[i];
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::makeImageResident(ze_image_handle_t hImage) {
|
||||
auto alloc = Image::fromHandle(hImage)->getAllocation();
|
||||
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
||||
auto success = memoryOperationsIface->makeResident(ArrayRef<NEO::GraphicsAllocation *>(&alloc, 1));
|
||||
return changeMemoryOperationStatusToL0ResultType(success);
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::makeMemoryResident(void *ptr, size_t size) {
|
||||
auto alloc = getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(ptr);
|
||||
if (alloc == nullptr) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
||||
auto success = memoryOperationsIface->makeResident(ArrayRef<NEO::GraphicsAllocation *>(&alloc->gpuAllocation, 1));
|
||||
return changeMemoryOperationStatusToL0ResultType(success);
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::setIntermediateCacheConfig(ze_cache_config_t cacheConfig) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::setLastLevelCacheConfig(ze_cache_config_t cacheConfig) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::getCacheProperties(ze_device_cache_properties_t *pCacheProperties) {
|
||||
const auto &hardwareInfo = this->getHwInfo();
|
||||
auto &hwHelper = NEO::HwHelper::get(hardwareInfo.platform.eRenderCoreFamily);
|
||||
|
||||
pCacheProperties->intermediateCacheControlSupported = false;
|
||||
|
||||
pCacheProperties->intermediateCacheSize = getIntermediateCacheSize(hardwareInfo);
|
||||
|
||||
pCacheProperties->intermediateCachelineSize = 0;
|
||||
|
||||
pCacheProperties->lastLevelCacheSizeControlSupported = hwHelper.isL3Configurable(hardwareInfo);
|
||||
|
||||
pCacheProperties->lastLevelCacheSize = static_cast<size_t>(hardwareInfo.gtSystemInfo.L3CacheSizeInKb * KB);
|
||||
|
||||
pCacheProperties->lastLevelCachelineSize = static_cast<uint32_t>(DeviceInfoTable::Map<CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE>::getValue(this->neoDevice->getDeviceInfo()));
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::imageGetProperties(const ze_image_desc_t *desc,
|
||||
ze_image_properties_t *pImageProperties) {
|
||||
const auto &deviceInfo = this->neoDevice->getDeviceInfo();
|
||||
|
||||
if (deviceInfo.imageSupport) {
|
||||
pImageProperties->samplerFilterFlags = ZE_IMAGE_SAMPLER_FILTER_FLAGS_LINEAR;
|
||||
} else {
|
||||
pImageProperties->samplerFilterFlags = ZE_IMAGE_SAMPLER_FILTER_FLAGS_NONE;
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::getDeviceImageProperties(ze_device_image_properties_t *pDeviceImageProperties) {
|
||||
const auto &deviceInfo = this->neoDevice->getDeviceInfo();
|
||||
|
||||
pDeviceImageProperties->supported = deviceInfo.imageSupport;
|
||||
pDeviceImageProperties->maxImageDims1D = static_cast<uint32_t>(deviceInfo.image2DMaxWidth);
|
||||
pDeviceImageProperties->maxImageDims2D = static_cast<uint32_t>(deviceInfo.image2DMaxHeight);
|
||||
pDeviceImageProperties->maxImageDims3D = static_cast<uint32_t>(deviceInfo.image3DMaxDepth);
|
||||
pDeviceImageProperties->maxImageBufferSize = static_cast<uint64_t>(DeviceInfoTable::Map<CL_DEVICE_IMAGE_MAX_BUFFER_SIZE>::getValue(this->neoDevice->getDeviceInfo()));
|
||||
pDeviceImageProperties->maxImageArraySlices = static_cast<uint32_t>(deviceInfo.imageMaxArraySize);
|
||||
pDeviceImageProperties->maxSamplers = static_cast<uint32_t>(DeviceInfoTable::Map<CL_DEVICE_MAX_SAMPLERS>::getValue(this->neoDevice->getDeviceInfo()));
|
||||
pDeviceImageProperties->maxReadImageArgs = static_cast<uint32_t>(DeviceInfoTable::Map<CL_DEVICE_MAX_READ_IMAGE_ARGS>::getValue(this->neoDevice->getDeviceInfo()));
|
||||
pDeviceImageProperties->maxWriteImageArgs = static_cast<uint32_t>(DeviceInfoTable::Map<CL_DEVICE_MAX_WRITE_IMAGE_ARGS>::getValue(this->neoDevice->getDeviceInfo()));
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::systemBarrier() { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; }
|
||||
|
||||
ze_result_t DeviceImp::activateMetricGroups(uint32_t count,
|
||||
zet_metric_group_handle_t *phMetricGroups) {
|
||||
return metricContext->activateMetricGroupsDeferred(count, phMetricGroups);
|
||||
}
|
||||
|
||||
void *DeviceImp::getExecEnvironment() { return execEnvironment; }
|
||||
|
||||
BuiltinFunctionsLib *DeviceImp::getBuiltinFunctionsLib() { return builtins.get(); }
|
||||
|
||||
uint32_t DeviceImp::getMOCS(bool l3enabled, bool l1enabled) {
|
||||
return getHwHelper().getMocsIndex(*getNEODevice()->getGmmHelper(), l3enabled, l1enabled) << 1;
|
||||
}
|
||||
|
||||
NEO::HwHelper &DeviceImp::getHwHelper() {
|
||||
const auto &hardwareInfo = neoDevice->getHardwareInfo();
|
||||
return NEO::HwHelper::get(hardwareInfo.platform.eRenderCoreFamily);
|
||||
}
|
||||
|
||||
NEO::OSInterface &DeviceImp::getOsInterface() { return *neoDevice->getOSTime()->getOSInterface(); }
|
||||
|
||||
uint32_t DeviceImp::getPlatformInfo() const {
|
||||
const auto &hardwareInfo = neoDevice->getHardwareInfo();
|
||||
return hardwareInfo.platform.eRenderCoreFamily;
|
||||
}
|
||||
|
||||
MetricContext &DeviceImp::getMetricContext() { return *metricContext; }
|
||||
|
||||
void DeviceImp::activateMetricGroups() {
|
||||
if (metricContext != nullptr) {
|
||||
metricContext->activateMetricGroups();
|
||||
}
|
||||
}
|
||||
uint32_t DeviceImp::getMaxNumHwThreads() const { return maxNumHwThreads; }
|
||||
|
||||
ze_result_t DeviceImp::registerCLMemory(cl_context context, cl_mem mem, void **ptr) {
|
||||
NEO::MemObj *memObj = static_cast<NEO::MemObj *>(mem);
|
||||
NEO::GraphicsAllocation *graphicsAllocation = memObj->getGraphicsAllocation();
|
||||
DEBUG_BREAK_IF(graphicsAllocation == nullptr);
|
||||
|
||||
auto allocation = getDriverHandle()->allocateManagedMemoryFromHostPtr(
|
||||
this, graphicsAllocation->getUnderlyingBuffer(),
|
||||
graphicsAllocation->getUnderlyingBufferSize(), nullptr);
|
||||
|
||||
*ptr = allocation->getUnderlyingBuffer();
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::registerCLProgram(cl_context context, cl_program program,
|
||||
ze_module_handle_t *phModule) {
|
||||
NEO::Program *neoProgram = static_cast<NEO::Program *>(program);
|
||||
|
||||
if (neoProgram->getIsSpirV()) {
|
||||
size_t deviceBinarySize = 0;
|
||||
if (0 != neoProgram->getInfo(CL_PROGRAM_BINARY_SIZES, sizeof(deviceBinarySize), &deviceBinarySize, nullptr)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> deviceBinary;
|
||||
deviceBinary.resize(deviceBinarySize);
|
||||
auto deviceBinaryPtr = deviceBinary.data();
|
||||
if (0 != neoProgram->getInfo(CL_PROGRAM_BINARIES, sizeof(void *), &deviceBinaryPtr, nullptr)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
ze_module_desc_t module_desc;
|
||||
module_desc.version = ZE_MODULE_DESC_VERSION_CURRENT;
|
||||
module_desc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
module_desc.inputSize = deviceBinarySize;
|
||||
module_desc.pInputModule = deviceBinary.data();
|
||||
module_desc.pBuildFlags = nullptr;
|
||||
|
||||
return createModule(&module_desc, phModule, nullptr);
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::registerCLCommandQueue(cl_context context, cl_command_queue commandQueue,
|
||||
ze_command_queue_handle_t *phCommandQueue) {
|
||||
ze_command_queue_desc_t desc;
|
||||
desc.version = ZE_COMMAND_QUEUE_DESC_VERSION_CURRENT;
|
||||
desc.flags = ZE_COMMAND_QUEUE_FLAG_NONE;
|
||||
desc.mode = ZE_COMMAND_QUEUE_MODE_DEFAULT;
|
||||
desc.priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL;
|
||||
|
||||
auto productFamily = neoDevice->getHardwareInfo().platform.eProductFamily;
|
||||
auto csr = neoDevice->getDefaultEngine().commandStreamReceiver;
|
||||
*phCommandQueue = CommandQueue::create(productFamily, this, csr, &desc);
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
const NEO::HardwareInfo &DeviceImp::getHwInfo() const { return neoDevice->getHardwareInfo(); }
|
||||
|
||||
bool DeviceImp::isMultiDeviceCapable() const {
|
||||
return neoDevice->getNumAvailableDevices() > 1u;
|
||||
}
|
||||
|
||||
Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice) {
|
||||
auto device = new DeviceImp;
|
||||
UNRECOVERABLE_IF(device == nullptr);
|
||||
|
||||
device->setDriverHandle(driverHandle);
|
||||
|
||||
device->neoDevice = neoDevice;
|
||||
neoDevice->incRefInternal();
|
||||
|
||||
device->execEnvironment = (void *)neoDevice->getExecutionEnvironment();
|
||||
device->metricContext = MetricContext::create(*device);
|
||||
device->builtins = BuiltinFunctionsLib::create(
|
||||
device, neoDevice->getBuiltIns());
|
||||
device->maxNumHwThreads = NEO::HwHelper::getMaxThreadsForVfe(neoDevice->getHardwareInfo());
|
||||
|
||||
if (device->neoDevice->getNumAvailableDevices() == 1) {
|
||||
device->numSubDevices = 0;
|
||||
} else {
|
||||
device->numSubDevices = device->neoDevice->getNumAvailableDevices();
|
||||
for (uint32_t i = 0; i < device->numSubDevices; i++) {
|
||||
ze_device_handle_t subDevice = Device::create(driverHandle,
|
||||
device->neoDevice->getDeviceById(i));
|
||||
if (subDevice == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
reinterpret_cast<DeviceImp *>(subDevice)->isSubdevice = true;
|
||||
device->subDevices.push_back(static_cast<Device *>(subDevice));
|
||||
}
|
||||
}
|
||||
|
||||
if (neoDevice->getCompilerInterface()) {
|
||||
device->getBuiltinFunctionsLib()->initFunctions();
|
||||
device->getBuiltinFunctionsLib()->initPageFaultFunction();
|
||||
}
|
||||
|
||||
auto supportDualStorageSharedMemory = device->getDriverHandle()->getMemoryManager()->isLocalMemorySupported(device->neoDevice->getRootDeviceIndex());
|
||||
if (NEO::DebugManager.flags.AllocateSharedAllocationsWithCpuAndGpuStorage.get() != -1) {
|
||||
supportDualStorageSharedMemory = NEO::DebugManager.flags.AllocateSharedAllocationsWithCpuAndGpuStorage.get();
|
||||
}
|
||||
|
||||
if (supportDualStorageSharedMemory) {
|
||||
ze_command_queue_desc_t cmdQueueDesc;
|
||||
cmdQueueDesc.version = ZE_COMMAND_QUEUE_DESC_VERSION_CURRENT;
|
||||
cmdQueueDesc.ordinal = 0;
|
||||
cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS;
|
||||
device->pageFaultCommandList =
|
||||
CommandList::createImmediate(
|
||||
device->neoDevice->getHardwareInfo().platform.eProductFamily, device, &cmdQueueDesc, true);
|
||||
}
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
DeviceImp::~DeviceImp() {
|
||||
for (uint32_t i = 0; i < this->numSubDevices; i++) {
|
||||
delete this->subDevices[i];
|
||||
}
|
||||
if (this->pageFaultCommandList) {
|
||||
this->pageFaultCommandList->destroy();
|
||||
this->pageFaultCommandList = nullptr;
|
||||
}
|
||||
metricContext.reset();
|
||||
builtins.reset();
|
||||
if (neoDevice) {
|
||||
neoDevice->decRefInternal();
|
||||
}
|
||||
}
|
||||
|
||||
NEO::PreemptionMode DeviceImp::getDevicePreemptionMode() const {
|
||||
return neoDevice->getPreemptionMode();
|
||||
}
|
||||
|
||||
const DeviceInfo &DeviceImp::getDeviceInfo() const {
|
||||
return neoDevice->getDeviceInfo();
|
||||
}
|
||||
|
||||
NEO::Device *DeviceImp::getNEODevice() {
|
||||
return neoDevice;
|
||||
}
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/core/source/builtin_functions_lib.h"
|
||||
#include "level_zero/core/source/cmdlist.h"
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include "level_zero/core/source/driver_handle.h"
|
||||
#include "level_zero/tools/source/metrics/metric.h"
|
||||
#include "level_zero/tools/source/tracing/tracing.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
struct DeviceImp : public Device {
|
||||
uint32_t getRootDeviceIndex() override;
|
||||
ze_result_t canAccessPeer(ze_device_handle_t hPeerDevice, ze_bool_t *value) override;
|
||||
ze_result_t copyCommandList(ze_command_list_handle_t hCommandList,
|
||||
ze_command_list_handle_t *phCommandList) override;
|
||||
ze_result_t createCommandList(const ze_command_list_desc_t *desc,
|
||||
ze_command_list_handle_t *commandList) override;
|
||||
ze_result_t createCommandListImmediate(const ze_command_queue_desc_t *desc,
|
||||
ze_command_list_handle_t *phCommandList) override;
|
||||
ze_result_t createCommandQueue(const ze_command_queue_desc_t *desc,
|
||||
ze_command_queue_handle_t *commandQueue) override;
|
||||
ze_result_t createEventPool(const ze_event_pool_desc_t *desc,
|
||||
ze_event_pool_handle_t *eventPool) override;
|
||||
ze_result_t createImage(const ze_image_desc_t *desc, ze_image_handle_t *phImage) override;
|
||||
ze_result_t createModule(const ze_module_desc_t *desc, ze_module_handle_t *module,
|
||||
ze_module_build_log_handle_t *buildLog) override;
|
||||
ze_result_t createSampler(const ze_sampler_desc_t *pDesc,
|
||||
ze_sampler_handle_t *phSampler) override;
|
||||
ze_result_t evictImage(ze_image_handle_t hImage) override;
|
||||
ze_result_t evictMemory(void *ptr, size_t size) override;
|
||||
ze_result_t getComputeProperties(ze_device_compute_properties_t *pComputeProperties) override;
|
||||
ze_result_t getP2PProperties(ze_device_handle_t hPeerDevice,
|
||||
ze_device_p2p_properties_t *pP2PProperties) override;
|
||||
ze_result_t getKernelProperties(ze_device_kernel_properties_t *pKernelProperties) override;
|
||||
ze_result_t getMemoryProperties(uint32_t *pCount, ze_device_memory_properties_t *pMemProperties) override;
|
||||
ze_result_t getMemoryAccessProperties(ze_device_memory_access_properties_t *pMemAccessProperties) override;
|
||||
ze_result_t getProperties(ze_device_properties_t *pDeviceProperties) override;
|
||||
ze_result_t getSubDevices(uint32_t *pCount, ze_device_handle_t *phSubdevices) override;
|
||||
ze_result_t makeImageResident(ze_image_handle_t hImage) override;
|
||||
ze_result_t makeMemoryResident(void *ptr, size_t size) override;
|
||||
ze_result_t setIntermediateCacheConfig(ze_cache_config_t cacheConfig) override;
|
||||
ze_result_t setLastLevelCacheConfig(ze_cache_config_t cacheConfig) override;
|
||||
ze_result_t getCacheProperties(ze_device_cache_properties_t *pCacheProperties) override;
|
||||
ze_result_t imageGetProperties(const ze_image_desc_t *desc, ze_image_properties_t *pImageProperties) override;
|
||||
ze_result_t getDeviceImageProperties(ze_device_image_properties_t *pDeviceImageProperties) override;
|
||||
ze_result_t systemBarrier() override;
|
||||
void *getExecEnvironment() override;
|
||||
BuiltinFunctionsLib *getBuiltinFunctionsLib() override;
|
||||
uint32_t getMOCS(bool l3enabled, bool l1enabled) override;
|
||||
NEO::HwHelper &getHwHelper() override;
|
||||
bool isMultiDeviceCapable() const override;
|
||||
const NEO::HardwareInfo &getHwInfo() const override;
|
||||
NEO::OSInterface &getOsInterface() override;
|
||||
uint32_t getPlatformInfo() const override;
|
||||
MetricContext &getMetricContext() override;
|
||||
uint32_t getMaxNumHwThreads() const override;
|
||||
ze_result_t registerCLMemory(cl_context context, cl_mem mem, void **ptr) override;
|
||||
ze_result_t registerCLProgram(cl_context context, cl_program program,
|
||||
ze_module_handle_t *phModule) override;
|
||||
ze_result_t registerCLCommandQueue(cl_context context, cl_command_queue commandQueue,
|
||||
ze_command_queue_handle_t *phCommandQueue) override;
|
||||
ze_result_t activateMetricGroups(uint32_t count,
|
||||
zet_metric_group_handle_t *phMetricGroups) override;
|
||||
|
||||
DriverHandle *getDriverHandle() override;
|
||||
void setDriverHandle(DriverHandle *driverHandle) override;
|
||||
NEO::PreemptionMode getDevicePreemptionMode() const override;
|
||||
const DeviceInfo &getDeviceInfo() const override;
|
||||
NEO::Device *getNEODevice() override;
|
||||
void activateMetricGroups() override;
|
||||
void processAdditionalKernelProperties(NEO::HwHelper &hwHelper, ze_device_kernel_properties_t *pKernelProperties);
|
||||
|
||||
~DeviceImp() override;
|
||||
|
||||
NEO::Device *neoDevice = nullptr;
|
||||
bool isSubdevice = false;
|
||||
void *execEnvironment = nullptr;
|
||||
std::unique_ptr<BuiltinFunctionsLib> builtins = nullptr;
|
||||
std::unique_ptr<MetricContext> metricContext = nullptr;
|
||||
uint32_t maxNumHwThreads = 0;
|
||||
uint32_t numSubDevices = 0;
|
||||
std::vector<Device *> subDevices;
|
||||
DriverHandle *driverHandle = nullptr;
|
||||
CommandList *pageFaultCommandList = nullptr;
|
||||
};
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,11 @@
|
|||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_SRCS_DLL
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/disallow_deferred_deleter.cpp
|
||||
)
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_DLL ${L0_SRCS_DLL})
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/deferred_deleter_helper.h"
|
||||
|
||||
bool NEO::isDeferredDeleterEnabled() {
|
||||
return false;
|
||||
} // namespace NEO
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/driver.h"
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/os_interface/device_factory.h"
|
||||
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include "level_zero/core/source/driver_handle.h"
|
||||
#include "level_zero/core/source/driver_imp.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
ze_driver_handle_t GlobalDrivers[1];
|
||||
uint32_t driverCount = 1;
|
||||
|
||||
void DriverImp::initialize(bool *result) {
|
||||
*result = false;
|
||||
|
||||
auto executionEnvironment = new NEO::ExecutionEnvironment();
|
||||
UNRECOVERABLE_IF(nullptr == executionEnvironment);
|
||||
|
||||
executionEnvironment->incRefInternal();
|
||||
auto devices = NEO::DeviceFactory::createDevices(*executionEnvironment);
|
||||
executionEnvironment->decRefInternal();
|
||||
if (!devices.empty()) {
|
||||
GlobalDrivers[0] = DriverHandle::create(std::move(devices));
|
||||
if (GlobalDrivers[0]) {
|
||||
*result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool DriverImp::initStatus(false);
|
||||
|
||||
ze_result_t DriverImp::driverInit(ze_init_flag_t flag) {
|
||||
std::call_once(initDriverOnce, [this]() {
|
||||
bool result;
|
||||
this->initialize(&result);
|
||||
initStatus = result;
|
||||
});
|
||||
return ((initStatus) ? ZE_RESULT_SUCCESS : ZE_RESULT_ERROR_UNINITIALIZED);
|
||||
}
|
||||
|
||||
ze_result_t driverHandleGet(uint32_t *pCount, ze_driver_handle_t *phDriverHandles) {
|
||||
if (*pCount == 0) {
|
||||
*pCount = driverCount;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
if (*pCount > driverCount) {
|
||||
*pCount = driverCount;
|
||||
}
|
||||
|
||||
if (phDriverHandles == nullptr) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < *pCount; i++) {
|
||||
phDriverHandles[i] = GlobalDrivers[i];
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static DriverImp driverImp;
|
||||
Driver *Driver::driver = &driverImp;
|
||||
|
||||
ze_result_t init(ze_init_flag_t flag) { return Driver::get()->driverInit(flag); }
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
namespace L0 {
|
||||
struct Driver {
|
||||
virtual ze_result_t driverInit(_ze_init_flag_t) = 0;
|
||||
virtual void initialize(bool *result) = 0;
|
||||
static Driver *get() { return driver; }
|
||||
|
||||
protected:
|
||||
static Driver *driver;
|
||||
};
|
||||
|
||||
ze_result_t init(_ze_init_flag_t);
|
||||
ze_result_t driverHandleGet(uint32_t *pCount, ze_driver_handle_t *phDrivers);
|
||||
|
||||
extern uint32_t driverCount;
|
||||
extern ze_driver_handle_t GlobalDrivers[1];
|
||||
} // namespace L0
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/memory_manager/unified_memory_manager.h"
|
||||
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
struct _ze_driver_handle_t {};
|
||||
|
||||
namespace L0 {
|
||||
struct Device;
|
||||
|
||||
struct DriverHandle : _ze_driver_handle_t {
|
||||
virtual ze_result_t getDevice(uint32_t *pCount, ze_device_handle_t *phDevices) = 0;
|
||||
virtual ze_result_t getProperties(ze_driver_properties_t *properties) = 0;
|
||||
virtual ze_result_t getApiVersion(ze_api_version_t *version) = 0;
|
||||
virtual ze_result_t getIPCProperties(ze_driver_ipc_properties_t *pIPCProperties) = 0;
|
||||
virtual ze_result_t getExtensionFunctionAddress(const char *pFuncName, void **pfunc) = 0;
|
||||
virtual ze_result_t getMemAllocProperties(const void *ptr,
|
||||
ze_memory_allocation_properties_t *pMemAllocProperties,
|
||||
ze_device_handle_t *phDevice) = 0;
|
||||
|
||||
virtual ze_result_t allocHostMem(ze_host_mem_alloc_flag_t flags, size_t size, size_t alignment, void **ptr) = 0;
|
||||
|
||||
virtual ze_result_t allocDeviceMem(ze_device_handle_t hDevice, ze_device_mem_alloc_flag_t flags, size_t size,
|
||||
size_t alignment, void **ptr) = 0;
|
||||
|
||||
virtual ze_result_t allocSharedMem(ze_device_handle_t hDevice, ze_device_mem_alloc_flag_t deviceFlags,
|
||||
ze_host_mem_alloc_flag_t hostFlags, size_t size, size_t alignment,
|
||||
void **ptr) = 0;
|
||||
virtual ze_result_t freeMem(const void *ptr) = 0;
|
||||
virtual NEO::MemoryManager *getMemoryManager() = 0;
|
||||
virtual void setMemoryManager(NEO::MemoryManager *memoryManager) = 0;
|
||||
virtual ze_result_t getMemAddressRange(const void *ptr, void **pBase, size_t *pSize) = 0;
|
||||
virtual ze_result_t closeIpcMemHandle(const void *ptr) = 0;
|
||||
virtual ze_result_t getIpcMemHandle(const void *ptr, ze_ipc_mem_handle_t *pIpcHandle) = 0;
|
||||
virtual ze_result_t openIpcMemHandle(ze_device_handle_t hDevice, ze_ipc_mem_handle_t handle,
|
||||
ze_ipc_memory_flag_t flags, void **ptr) = 0;
|
||||
virtual ze_result_t createEventPool(const ze_event_pool_desc_t *desc,
|
||||
uint32_t numDevices,
|
||||
ze_device_handle_t *phDevices,
|
||||
ze_event_pool_handle_t *phEventPool) = 0;
|
||||
virtual ze_result_t checkMemoryAccessFromDevice(Device *device, const void *ptr) = 0;
|
||||
virtual NEO::GraphicsAllocation *allocateManagedMemoryFromHostPtr(Device *device, void *buffer,
|
||||
size_t size, struct CommandList *commandList) = 0;
|
||||
virtual NEO::GraphicsAllocation *allocateMemoryFromHostPtr(Device *device, const void *buffer, size_t size) = 0;
|
||||
virtual bool findAllocationDataForRange(const void *buffer,
|
||||
size_t size,
|
||||
NEO::SvmAllocationData **allocData) = 0;
|
||||
virtual std::vector<NEO::SvmAllocationData *> findAllocationsWithinRange(const void *buffer,
|
||||
size_t size,
|
||||
bool *allocationRangeCovered) = 0;
|
||||
|
||||
virtual NEO::SVMAllocsManager *getSvmAllocsManager() = 0;
|
||||
static DriverHandle *fromHandle(ze_driver_handle_t handle) { return static_cast<DriverHandle *>(handle); }
|
||||
inline ze_driver_handle_t toHandle() { return this; }
|
||||
|
||||
virtual ~DriverHandle() = default;
|
||||
|
||||
DriverHandle &operator=(const DriverHandle &) = delete;
|
||||
DriverHandle &operator=(DriverHandle &&) = delete;
|
||||
|
||||
static DriverHandle *create(std::vector<std::unique_ptr<NEO::Device>> devices);
|
||||
};
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,293 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/driver_handle_imp.h"
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
#include "level_zero/core/source/device_imp.h"
|
||||
|
||||
#include "driver_version_l0.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
NEO::MemoryManager *DriverHandleImp::getMemoryManager() {
|
||||
return this->memoryManager;
|
||||
}
|
||||
|
||||
void DriverHandleImp::setMemoryManager(NEO::MemoryManager *memoryManager) {
|
||||
this->memoryManager = memoryManager;
|
||||
}
|
||||
|
||||
NEO::SVMAllocsManager *DriverHandleImp::getSvmAllocsManager() {
|
||||
return this->svmAllocsManager;
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::getApiVersion(ze_api_version_t *version) {
|
||||
*version = ZE_API_VERSION_1_0;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::getProperties(ze_driver_properties_t *properties) {
|
||||
uint32_t versionMajor = (uint32_t)strtoul(L0_PROJECT_VERSION_MAJOR, NULL, 16);
|
||||
uint32_t versionMinor = (uint32_t)strtoul(L0_PROJECT_VERSION_MINOR, NULL, 16);
|
||||
|
||||
properties->driverVersion = ZE_MAKE_VERSION(versionMajor, versionMinor);
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::getIPCProperties(ze_driver_ipc_properties_t *pIPCProperties) {
|
||||
pIPCProperties->eventsSupported = false;
|
||||
pIPCProperties->memsSupported = true;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
inline ze_memory_type_t parseUSMType(InternalMemoryType memoryType) {
|
||||
switch (memoryType) {
|
||||
case InternalMemoryType::SHARED_UNIFIED_MEMORY:
|
||||
return ZE_MEMORY_TYPE_SHARED;
|
||||
case InternalMemoryType::DEVICE_UNIFIED_MEMORY:
|
||||
return ZE_MEMORY_TYPE_DEVICE;
|
||||
case InternalMemoryType::HOST_UNIFIED_MEMORY:
|
||||
return ZE_MEMORY_TYPE_HOST;
|
||||
default:
|
||||
return ZE_MEMORY_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
return ZE_MEMORY_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::getExtensionFunctionAddress(const char *pFuncName, void **pfunc) {
|
||||
*pfunc = this->osLibrary->getProcAddress(std::string(pFuncName));
|
||||
if (*pfunc == nullptr) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::getMemAllocProperties(const void *ptr,
|
||||
ze_memory_allocation_properties_t *pMemAllocProperties,
|
||||
ze_device_handle_t *phDevice) {
|
||||
auto alloc = svmAllocsManager->getSVMAllocs()->get(ptr);
|
||||
if (alloc) {
|
||||
pMemAllocProperties->type = parseUSMType(alloc->memoryType);
|
||||
pMemAllocProperties->id = alloc->gpuAllocation->getGpuAddress();
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
DriverHandleImp::~DriverHandleImp() {
|
||||
for (auto &device : this->devices) {
|
||||
delete device;
|
||||
}
|
||||
if (this->svmAllocsManager) {
|
||||
delete this->svmAllocsManager;
|
||||
this->svmAllocsManager = nullptr;
|
||||
}
|
||||
delete this->osLibrary;
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>> devices) {
|
||||
this->memoryManager = devices[0]->getMemoryManager();
|
||||
if (this->memoryManager == nullptr) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
|
||||
this->svmAllocsManager = new NEO::SVMAllocsManager(memoryManager);
|
||||
if (this->svmAllocsManager == nullptr) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
this->numDevices = static_cast<uint32_t>(devices.size());
|
||||
|
||||
for (auto &neoDevice : devices) {
|
||||
auto device = Device::create(this, neoDevice.release());
|
||||
this->devices.push_back(device);
|
||||
}
|
||||
|
||||
this->osLibrary = NEO::OsLibrary::load("");
|
||||
if (this->osLibrary->isLoaded() == false) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
DriverHandle *DriverHandle::create(std::vector<std::unique_ptr<NEO::Device>> devices) {
|
||||
DriverHandleImp *driverHandle = new DriverHandleImp;
|
||||
UNRECOVERABLE_IF(nullptr == driverHandle);
|
||||
|
||||
ze_result_t res = driverHandle->initialize(std::move(devices));
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
delete driverHandle;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
driverHandle->memoryManager->setForceNonSvmForExternalHostPtr(true);
|
||||
return driverHandle;
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::getDevice(uint32_t *pCount, ze_device_handle_t *phDevices) {
|
||||
if (*pCount == 0) {
|
||||
*pCount = this->numDevices;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
if (phDevices == nullptr) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < *pCount; i++) {
|
||||
phDevices[i] = this->devices[i];
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
bool DriverHandleImp::findAllocationDataForRange(const void *buffer,
|
||||
size_t size,
|
||||
NEO::SvmAllocationData **allocData) {
|
||||
// Make sure the host buffer does not overlap any existing allocation
|
||||
const char *baseAddress = reinterpret_cast<const char *>(buffer);
|
||||
NEO::SvmAllocationData *beginAllocData = svmAllocsManager->getSVMAllocs()->get(baseAddress);
|
||||
NEO::SvmAllocationData *endAllocData = svmAllocsManager->getSVMAllocs()->get(baseAddress + size - 1);
|
||||
|
||||
if (allocData) {
|
||||
if (beginAllocData) {
|
||||
*allocData = beginAllocData;
|
||||
} else {
|
||||
*allocData = endAllocData;
|
||||
}
|
||||
}
|
||||
|
||||
// Return true if the whole range requested is covered by the same allocation
|
||||
if (beginAllocData && endAllocData &&
|
||||
(beginAllocData->gpuAllocation == endAllocData->gpuAllocation)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<NEO::SvmAllocationData *> DriverHandleImp::findAllocationsWithinRange(const void *buffer,
|
||||
size_t size,
|
||||
bool *allocationRangeCovered) {
|
||||
std::vector<NEO::SvmAllocationData *> allocDataArray;
|
||||
const char *baseAddress = reinterpret_cast<const char *>(buffer);
|
||||
// Check if the host buffer overlaps any existing allocation
|
||||
NEO::SvmAllocationData *beginAllocData = svmAllocsManager->getSVMAllocs()->get(baseAddress);
|
||||
NEO::SvmAllocationData *endAllocData = svmAllocsManager->getSVMAllocs()->get(baseAddress + size - 1);
|
||||
|
||||
// Add the allocation that matches the beginning address
|
||||
if (beginAllocData) {
|
||||
allocDataArray.push_back(beginAllocData);
|
||||
}
|
||||
// Add the allocation that matches the end address range if there was no beginning allocation
|
||||
// or the beginning allocation does not match the ending allocation
|
||||
if (endAllocData) {
|
||||
if ((beginAllocData && (beginAllocData->gpuAllocation != endAllocData->gpuAllocation)) ||
|
||||
!beginAllocData) {
|
||||
allocDataArray.push_back(endAllocData);
|
||||
}
|
||||
}
|
||||
|
||||
// Return true if the whole range requested is covered by the same allocation
|
||||
if (beginAllocData && endAllocData &&
|
||||
(beginAllocData->gpuAllocation == endAllocData->gpuAllocation)) {
|
||||
*allocationRangeCovered = true;
|
||||
} else {
|
||||
*allocationRangeCovered = false;
|
||||
}
|
||||
return allocDataArray;
|
||||
}
|
||||
|
||||
NEO::GraphicsAllocation *DriverHandleImp::allocateManagedMemoryFromHostPtr(Device *device, void *buffer,
|
||||
size_t size, struct CommandList *commandList) {
|
||||
char *baseAddress = reinterpret_cast<char *>(buffer);
|
||||
NEO::GraphicsAllocation *allocation = nullptr;
|
||||
bool allocFound = false;
|
||||
std::vector<NEO::SvmAllocationData *> allocDataArray = findAllocationsWithinRange(buffer, size, &allocFound);
|
||||
if (allocFound) {
|
||||
return allocDataArray[0]->gpuAllocation;
|
||||
}
|
||||
|
||||
if (!allocDataArray.empty()) {
|
||||
UNRECOVERABLE_IF(commandList == nullptr);
|
||||
for (auto allocData : allocDataArray) {
|
||||
allocation = allocData->gpuAllocation;
|
||||
char *allocAddress = reinterpret_cast<char *>(allocation->getGpuAddress());
|
||||
size_t allocSize = allocData->size;
|
||||
|
||||
device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->remove(*allocData);
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
commandList->eraseDeallocationContainerEntry(allocation);
|
||||
commandList->eraseResidencyContainerEntry(allocation);
|
||||
|
||||
if (allocAddress < baseAddress) {
|
||||
buffer = reinterpret_cast<void *>(allocAddress);
|
||||
baseAddress += size;
|
||||
size = ptrDiff(baseAddress, allocAddress);
|
||||
baseAddress = reinterpret_cast<char *>(buffer);
|
||||
} else {
|
||||
allocAddress += allocSize;
|
||||
baseAddress += size;
|
||||
if (allocAddress > baseAddress) {
|
||||
baseAddress = reinterpret_cast<char *>(buffer);
|
||||
size = ptrDiff(allocAddress, baseAddress);
|
||||
} else {
|
||||
baseAddress = reinterpret_cast<char *>(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
allocation = memoryManager->allocateGraphicsMemoryWithProperties(
|
||||
{0u, false, size, NEO::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, false},
|
||||
buffer);
|
||||
|
||||
if (allocation == nullptr) {
|
||||
return allocation;
|
||||
}
|
||||
|
||||
NEO::SvmAllocationData allocData;
|
||||
allocData.gpuAllocation = allocation;
|
||||
allocData.cpuAllocation = nullptr;
|
||||
allocData.size = size;
|
||||
allocData.memoryType = InternalMemoryType::NOT_SPECIFIED;
|
||||
allocData.device = nullptr;
|
||||
svmAllocsManager->getSVMAllocs()->insert(allocData);
|
||||
|
||||
return allocation;
|
||||
}
|
||||
|
||||
NEO::GraphicsAllocation *DriverHandleImp::allocateMemoryFromHostPtr(Device *device, const void *buffer, size_t size) {
|
||||
NEO::AllocationProperties properties = {0u, false, size, NEO::GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, false};
|
||||
properties.flags.flushL3RequiredForRead = properties.flags.flushL3RequiredForWrite = true;
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties,
|
||||
buffer);
|
||||
|
||||
UNRECOVERABLE_IF(allocation == nullptr);
|
||||
|
||||
return allocation;
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::createEventPool(const ze_event_pool_desc_t *desc,
|
||||
uint32_t numDevices,
|
||||
ze_device_handle_t *phDevices,
|
||||
ze_event_pool_handle_t *phEventPool) {
|
||||
auto device = Device::fromHandle(phDevices[0]);
|
||||
return device->createEventPool(desc, phEventPool);
|
||||
}
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
#include "level_zero/core/source/driver_handle.h"
|
||||
#include "level_zero/tools/source/tracing/tracing.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
struct DriverHandleImp : public DriverHandle {
|
||||
~DriverHandleImp() override;
|
||||
ze_result_t getDevice(uint32_t *pCount, ze_device_handle_t *phDevices) override;
|
||||
ze_result_t getProperties(ze_driver_properties_t *properties) override;
|
||||
ze_result_t getApiVersion(ze_api_version_t *version) override;
|
||||
ze_result_t getIPCProperties(ze_driver_ipc_properties_t *pIPCProperties) override;
|
||||
ze_result_t getExtensionFunctionAddress(const char *pFuncName, void **pfunc) override;
|
||||
ze_result_t getMemAllocProperties(const void *ptr,
|
||||
ze_memory_allocation_properties_t *pMemAllocProperties,
|
||||
ze_device_handle_t *phDevice) override;
|
||||
|
||||
ze_result_t allocHostMem(ze_host_mem_alloc_flag_t flags, size_t size, size_t alignment, void **ptr) override;
|
||||
|
||||
ze_result_t allocDeviceMem(ze_device_handle_t hDevice, ze_device_mem_alloc_flag_t flags, size_t size,
|
||||
size_t alignment, void **ptr) override;
|
||||
|
||||
ze_result_t allocSharedMem(ze_device_handle_t hDevice, ze_device_mem_alloc_flag_t deviceFlags,
|
||||
ze_host_mem_alloc_flag_t hostFlags, size_t size, size_t alignment,
|
||||
void **ptr) override;
|
||||
|
||||
ze_result_t getMemAddressRange(const void *ptr, void **pBase, size_t *pSize) override;
|
||||
ze_result_t freeMem(const void *ptr) override;
|
||||
NEO::MemoryManager *getMemoryManager() override;
|
||||
void setMemoryManager(NEO::MemoryManager *memoryManager) override;
|
||||
ze_result_t closeIpcMemHandle(const void *ptr) override;
|
||||
ze_result_t getIpcMemHandle(const void *ptr, ze_ipc_mem_handle_t *pIpcHandle) override;
|
||||
ze_result_t openIpcMemHandle(ze_device_handle_t hDevice, ze_ipc_mem_handle_t handle,
|
||||
ze_ipc_memory_flag_t flags, void **ptr) override;
|
||||
ze_result_t createEventPool(const ze_event_pool_desc_t *desc,
|
||||
uint32_t numDevices,
|
||||
ze_device_handle_t *phDevices,
|
||||
ze_event_pool_handle_t *phEventPool) override;
|
||||
ze_result_t checkMemoryAccessFromDevice(Device *device, const void *ptr) override;
|
||||
NEO::SVMAllocsManager *getSvmAllocsManager() override;
|
||||
ze_result_t initialize(std::vector<std::unique_ptr<NEO::Device>> devices);
|
||||
NEO::GraphicsAllocation *allocateManagedMemoryFromHostPtr(Device *device, void *buffer,
|
||||
size_t size, struct CommandList *commandList) override;
|
||||
NEO::GraphicsAllocation *allocateMemoryFromHostPtr(Device *device, const void *buffer, size_t size) override;
|
||||
bool findAllocationDataForRange(const void *buffer,
|
||||
size_t size,
|
||||
NEO::SvmAllocationData **allocData) override;
|
||||
std::vector<NEO::SvmAllocationData *> findAllocationsWithinRange(const void *buffer,
|
||||
size_t size,
|
||||
bool *allocationRangeCovered) override;
|
||||
|
||||
uint32_t numDevices = 0;
|
||||
std::vector<Device *> devices;
|
||||
NEO::MemoryManager *memoryManager = nullptr;
|
||||
NEO::SVMAllocsManager *svmAllocsManager = nullptr;
|
||||
NEO::OsLibrary *osLibrary = nullptr;
|
||||
};
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/core/source/driver.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class DriverImp : public Driver {
|
||||
public:
|
||||
ze_result_t driverInit(_ze_init_flag_t) override;
|
||||
|
||||
void initialize(bool *result) override;
|
||||
|
||||
protected:
|
||||
std::once_flag initDriverOnce;
|
||||
static bool initStatus;
|
||||
};
|
||||
} // namespace L0
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef L0_DRIVER_VERSION_H
|
||||
#define L0_DRIVER_VERSION_H
|
||||
|
||||
#define L0_DRIVER_VERSION @L0_DRIVER_VERSION@
|
||||
|
||||
#endif /* L0_DRIVER_VERSION_H */
|
||||
|
|
@ -0,0 +1,394 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/event.h"
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver_hw.h"
|
||||
#include "shared/source/command_stream/csr_definitions.h"
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/memory_manager/memory_operations_handler.h"
|
||||
#include "shared/source/utilities/cpuintrinsics.h"
|
||||
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include "level_zero/core/source/device_imp.h"
|
||||
#include "level_zero/tools/source/metrics/metric.h"
|
||||
|
||||
#include <queue>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
struct EventImp : public Event {
|
||||
EventImp(EventPool *eventPool, int index, Device *device)
|
||||
: device(device), eventPool(eventPool) {}
|
||||
|
||||
~EventImp() override {}
|
||||
|
||||
ze_result_t hostSignal() override;
|
||||
|
||||
ze_result_t hostSynchronize(uint32_t timeout) override;
|
||||
|
||||
ze_result_t queryStatus() override {
|
||||
uint64_t *hostAddr = static_cast<uint64_t *>(hostAddress);
|
||||
auto alloc = &(this->eventPool->getAllocation());
|
||||
auto csr = static_cast<DeviceImp *>(this->device)->neoDevice->getDefaultEngine().commandStreamReceiver;
|
||||
|
||||
if (metricTracer != nullptr) {
|
||||
*hostAddr = metricTracer->getNotificationState();
|
||||
}
|
||||
|
||||
csr->downloadAllocation(*alloc);
|
||||
|
||||
if (isTimestampEvent) {
|
||||
auto baseAddr = reinterpret_cast<uint64_t>(hostAddress);
|
||||
|
||||
auto timeStampAddress = baseAddr + getOffsetOfProfilingEvent(ZE_EVENT_TIMESTAMP_CONTEXT_END);
|
||||
hostAddr = reinterpret_cast<uint64_t *>(timeStampAddress);
|
||||
}
|
||||
|
||||
return *hostAddr == Event::STATE_CLEARED ? ZE_RESULT_NOT_READY : ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t reset() override;
|
||||
|
||||
ze_result_t getTimestamp(ze_event_timestamp_type_t timestampType, void *dstptr) override;
|
||||
|
||||
Device *device;
|
||||
EventPool *eventPool;
|
||||
|
||||
protected:
|
||||
ze_result_t hostEventSetValue(uint32_t eventValue);
|
||||
ze_result_t hostEventSetValueTimestamps(uint32_t eventVal);
|
||||
void makeAllocationResident();
|
||||
};
|
||||
|
||||
struct EventPoolImp : public EventPool {
|
||||
EventPoolImp(Device *device, uint32_t count, ze_event_pool_flag_t flags) : device(device), count(count) {
|
||||
pool = std::vector<int>(this->count);
|
||||
eventPoolUsedCount = 0;
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
pool[i] = EventPool::EVENT_STATE_INITIAL;
|
||||
}
|
||||
|
||||
auto timestampMultiplier = 1;
|
||||
if (flags == ZE_EVENT_POOL_FLAG_TIMESTAMP) {
|
||||
isEventPoolUsedForTimestamp = true;
|
||||
timestampMultiplier = numEventTimestampTypes;
|
||||
}
|
||||
|
||||
NEO::AllocationProperties properties(
|
||||
device->getRootDeviceIndex(), count * eventSize * timestampMultiplier, NEO::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
|
||||
properties.alignment = eventAlignment;
|
||||
eventPoolAllocation = device->getDriverHandle()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
|
||||
UNRECOVERABLE_IF(eventPoolAllocation == nullptr);
|
||||
}
|
||||
|
||||
~EventPoolImp() override {
|
||||
device->getDriverHandle()->getMemoryManager()->freeGraphicsMemory(eventPoolAllocation);
|
||||
eventPoolAllocation = nullptr;
|
||||
|
||||
eventTracker.clear();
|
||||
}
|
||||
|
||||
ze_result_t destroy() override;
|
||||
|
||||
size_t getPoolSize() override { return this->pool.size(); }
|
||||
uint32_t getPoolUsedCount() override { return eventPoolUsedCount; }
|
||||
|
||||
ze_result_t getIpcHandle(ze_ipc_event_pool_handle_t *pIpcHandle) override;
|
||||
|
||||
ze_result_t closeIpcHandle() override;
|
||||
|
||||
ze_result_t createEvent(const ze_event_desc_t *desc, ze_event_handle_t *phEvent) override {
|
||||
*phEvent = Event::create(this, desc, this->getDevice());
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t reserveEventFromPool(int index, Event *event) override;
|
||||
|
||||
ze_result_t releaseEventToPool(Event *event) override;
|
||||
|
||||
uint32_t getEventSize() override { return eventSize; }
|
||||
|
||||
uint32_t getNumEventTimestampTypes() override { return numEventTimestampTypes; }
|
||||
|
||||
ze_result_t destroyPool() {
|
||||
if (eventPoolUsedCount != 0) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
pool.clear();
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
Device *getDevice() override { return device; }
|
||||
|
||||
Device *device;
|
||||
uint32_t count;
|
||||
uint32_t eventPoolUsedCount;
|
||||
std::vector<int> pool;
|
||||
std::unordered_map<Event *, int> eventTracker;
|
||||
|
||||
std::queue<int> lastEventPoolOffsetUsed;
|
||||
|
||||
protected:
|
||||
const uint32_t eventSize = 64u;
|
||||
const uint32_t eventAlignment = 64u;
|
||||
|
||||
const uint32_t numEventTimestampTypes = 4u;
|
||||
};
|
||||
|
||||
Event *Event::create(EventPool *eventPool, const ze_event_desc_t *desc, Device *device) {
|
||||
auto event = new EventImp(eventPool, desc->index, device);
|
||||
UNRECOVERABLE_IF(event == nullptr);
|
||||
eventPool->reserveEventFromPool(desc->index, static_cast<Event *>(event));
|
||||
|
||||
if (eventPool->isEventPoolUsedForTimestamp) {
|
||||
event->isTimestampEvent = true;
|
||||
}
|
||||
|
||||
event->signalScope = desc->signal;
|
||||
event->waitScope = desc->wait;
|
||||
|
||||
event->reset();
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
NEO::GraphicsAllocation &Event::getAllocation() {
|
||||
auto eventImp = static_cast<EventImp *>(this);
|
||||
|
||||
return eventImp->eventPool->getAllocation();
|
||||
}
|
||||
|
||||
uint64_t Event::getOffsetOfProfilingEvent(uint32_t profileEventType) {
|
||||
auto eventImp = static_cast<EventImp *>(this);
|
||||
auto eventSize = eventImp->eventPool->getEventSize();
|
||||
return (profileEventType * eventSize);
|
||||
}
|
||||
|
||||
ze_result_t Event::destroy() {
|
||||
auto eventImp = static_cast<EventImp *>(this);
|
||||
if (eventImp->eventPool->releaseEventToPool(this)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
delete this;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
void EventImp::makeAllocationResident() {
|
||||
auto deviceImp = static_cast<DeviceImp *>(this->device);
|
||||
NEO::MemoryOperationsHandler *memoryOperationsIface = deviceImp->neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
||||
auto alloc = &(this->eventPool->getAllocation());
|
||||
|
||||
if (memoryOperationsIface) {
|
||||
memoryOperationsIface->makeResident(ArrayRef<NEO::GraphicsAllocation *>(&alloc, 1));
|
||||
}
|
||||
}
|
||||
|
||||
ze_result_t EventImp::hostEventSetValueTimestamps(uint32_t eventVal) {
|
||||
for (uint32_t i = 0; i < this->eventPool->getNumEventTimestampTypes(); i++) {
|
||||
auto baseAddr = reinterpret_cast<uint64_t>(hostAddress);
|
||||
auto timeStampAddress = baseAddr + getOffsetOfProfilingEvent(i);
|
||||
auto tsptr = reinterpret_cast<uint64_t *>(timeStampAddress);
|
||||
|
||||
*(tsptr) = eventVal;
|
||||
|
||||
if (this->signalScope != ZE_EVENT_SCOPE_FLAG_NONE) {
|
||||
NEO::CpuIntrinsics::clFlush(tsptr);
|
||||
}
|
||||
}
|
||||
|
||||
makeAllocationResident();
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t EventImp::hostEventSetValue(uint32_t eventVal) {
|
||||
if (isTimestampEvent) {
|
||||
hostEventSetValueTimestamps(eventVal);
|
||||
}
|
||||
|
||||
auto hostAddr = static_cast<uint64_t *>(hostAddress);
|
||||
UNRECOVERABLE_IF(hostAddr == nullptr);
|
||||
*(hostAddr) = eventVal;
|
||||
|
||||
makeAllocationResident();
|
||||
|
||||
if (this->signalScope != ZE_EVENT_SCOPE_FLAG_NONE) {
|
||||
NEO::CpuIntrinsics::clFlush(hostAddr);
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t EventImp::hostSignal() {
|
||||
return hostEventSetValue(Event::STATE_SIGNALED);
|
||||
}
|
||||
|
||||
ze_result_t EventImp::hostSynchronize(uint32_t timeout) {
|
||||
std::chrono::high_resolution_clock::time_point time1, time2;
|
||||
int64_t timeDiff = 0;
|
||||
ze_result_t ret = ZE_RESULT_NOT_READY;
|
||||
auto csr = static_cast<DeviceImp *>(this->device)->neoDevice->getDefaultEngine().commandStreamReceiver;
|
||||
|
||||
if (csr->getType() == NEO::CommandStreamReceiverType::CSR_AUB) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
if (timeout == 0) {
|
||||
return queryStatus();
|
||||
}
|
||||
|
||||
time1 = std::chrono::high_resolution_clock::now();
|
||||
while (true) {
|
||||
ret = queryStatus();
|
||||
if (ret == ZE_RESULT_SUCCESS) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
std::this_thread::yield();
|
||||
NEO::CpuIntrinsics::pause();
|
||||
|
||||
if (timeout == std::numeric_limits<uint32_t>::max()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
time2 = std::chrono::high_resolution_clock::now();
|
||||
timeDiff = std::chrono::duration_cast<std::chrono::nanoseconds>(time2 - time1).count();
|
||||
|
||||
if (timeDiff >= timeout) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ze_result_t EventImp::reset() {
|
||||
return hostEventSetValue(Event::STATE_INITIAL);
|
||||
}
|
||||
|
||||
ze_result_t EventImp::getTimestamp(ze_event_timestamp_type_t timestampType, void *dstptr) {
|
||||
auto baseAddr = reinterpret_cast<uint64_t>(hostAddress);
|
||||
|
||||
if (!this->isTimestampEvent)
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
|
||||
auto timeStampAddress = baseAddr + getOffsetOfProfilingEvent(timestampType);
|
||||
auto tsptr = reinterpret_cast<uint64_t *>(timeStampAddress);
|
||||
|
||||
memcpy_s(dstptr, sizeof(uint64_t), static_cast<void *>(tsptr), sizeof(uint64_t));
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
EventPool *EventPool::create(Device *device, const ze_event_pool_desc_t *desc) {
|
||||
auto eventPool = new EventPoolImp(device, desc->count, desc->flags);
|
||||
UNRECOVERABLE_IF(eventPool == nullptr);
|
||||
|
||||
return eventPool;
|
||||
}
|
||||
|
||||
ze_result_t EventPoolImp::reserveEventFromPool(int index, Event *event) {
|
||||
if (pool[index] == EventPool::EVENT_STATE_CREATED) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
pool[index] = EventPool::EVENT_STATE_CREATED;
|
||||
eventTracker.insert(std::pair<Event *, int>(event, index));
|
||||
|
||||
if (lastEventPoolOffsetUsed.empty()) {
|
||||
event->offsetUsed = index;
|
||||
} else {
|
||||
event->offsetUsed = lastEventPoolOffsetUsed.front();
|
||||
lastEventPoolOffsetUsed.pop();
|
||||
}
|
||||
|
||||
auto timestampMultiplier = 1;
|
||||
if (static_cast<struct EventPool *>(this)->isEventPoolUsedForTimestamp) {
|
||||
timestampMultiplier = numEventTimestampTypes;
|
||||
}
|
||||
|
||||
uint64_t baseHostAddr = reinterpret_cast<uint64_t>(eventPoolAllocation->getUnderlyingBuffer());
|
||||
event->hostAddress = reinterpret_cast<void *>(baseHostAddr + (event->offsetUsed * eventSize * timestampMultiplier));
|
||||
event->gpuAddress = eventPoolAllocation->getGpuAddress() + (event->offsetUsed * eventSize * timestampMultiplier);
|
||||
|
||||
eventPoolUsedCount++;
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t EventPoolImp::releaseEventToPool(Event *event) {
|
||||
UNRECOVERABLE_IF(event == nullptr);
|
||||
if (eventTracker.find(event) == eventTracker.end()) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
int index = eventTracker[event];
|
||||
pool[index] = EventPool::EVENT_STATE_DESTROYED;
|
||||
eventTracker.erase(event);
|
||||
|
||||
event->hostAddress = nullptr;
|
||||
event->gpuAddress = 0;
|
||||
|
||||
lastEventPoolOffsetUsed.push(event->offsetUsed);
|
||||
event->offsetUsed = -1;
|
||||
|
||||
eventPoolUsedCount--;
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t EventPoolImp::getIpcHandle(ze_ipc_event_pool_handle_t *pIpcHandle) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t EventPoolImp::closeIpcHandle() { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; }
|
||||
|
||||
ze_result_t EventPoolImp::destroy() {
|
||||
if (this->destroyPool()) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
delete this;
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t eventPoolOpenIpcHandle(ze_driver_handle_t hDriver, ze_ipc_event_pool_handle_t hIpc,
|
||||
ze_event_pool_handle_t *phEventPool) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t eventCreate(ze_event_pool_handle_t hEventPool, const ze_event_desc_t *desc,
|
||||
ze_event_handle_t *phEvent) {
|
||||
EventPool *eventPool = EventPool::fromHandle(hEventPool);
|
||||
UNRECOVERABLE_IF(eventPool == nullptr);
|
||||
|
||||
if (desc->index > (eventPool->getPoolSize() - 1)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if ((eventPool->getPoolUsedCount() + 1) > eventPool->getPoolSize()) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return eventPool->createEvent(desc, phEvent);
|
||||
}
|
||||
|
||||
ze_result_t eventDestroy(ze_event_handle_t hEvent) { return Event::fromHandle(hEvent)->destroy(); }
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/core/source/cmdlist.h"
|
||||
#include "level_zero/core/source/device.h"
|
||||
#include "level_zero/core/source/driver_handle.h"
|
||||
#include <level_zero/ze_event.h>
|
||||
|
||||
struct _ze_event_handle_t {};
|
||||
|
||||
struct _ze_event_pool_handle_t {};
|
||||
|
||||
namespace L0 {
|
||||
typedef uint64_t FlushStamp;
|
||||
struct EventPool;
|
||||
struct MetricTracer;
|
||||
|
||||
struct Event : _ze_event_handle_t {
|
||||
virtual ~Event() = default;
|
||||
virtual ze_result_t destroy();
|
||||
virtual ze_result_t hostSignal() = 0;
|
||||
virtual ze_result_t hostSynchronize(uint32_t timeout) = 0;
|
||||
virtual ze_result_t queryStatus() = 0;
|
||||
virtual ze_result_t reset() = 0;
|
||||
virtual ze_result_t getTimestamp(ze_event_timestamp_type_t timestampType, void *dstptr) = 0;
|
||||
|
||||
enum State : uint32_t {
|
||||
STATE_SIGNALED = 0u,
|
||||
STATE_CLEARED = static_cast<uint32_t>(-1),
|
||||
STATE_INITIAL = STATE_CLEARED
|
||||
};
|
||||
|
||||
static Event *create(EventPool *eventPool, const ze_event_desc_t *desc, Device *device);
|
||||
|
||||
static Event *fromHandle(ze_event_handle_t handle) { return static_cast<Event *>(handle); }
|
||||
|
||||
inline ze_event_handle_t toHandle() { return this; }
|
||||
|
||||
NEO::GraphicsAllocation &getAllocation();
|
||||
|
||||
uint64_t getGpuAddress() { return gpuAddress; }
|
||||
uint64_t getOffsetOfProfilingEvent(uint32_t profileEventType);
|
||||
|
||||
void *hostAddress = nullptr;
|
||||
uint64_t gpuAddress;
|
||||
int offsetUsed = -1;
|
||||
|
||||
ze_event_scope_flag_t signalScope; // Saving scope for use later
|
||||
ze_event_scope_flag_t waitScope;
|
||||
|
||||
bool isTimestampEvent = false;
|
||||
|
||||
// Metric tracer instance associated with the event.
|
||||
MetricTracer *metricTracer = nullptr;
|
||||
|
||||
protected:
|
||||
NEO::GraphicsAllocation *allocation = nullptr;
|
||||
};
|
||||
|
||||
struct EventPool : _ze_event_pool_handle_t {
|
||||
static EventPool *create(Device *device, const ze_event_pool_desc_t *desc);
|
||||
|
||||
virtual ~EventPool() = default;
|
||||
virtual ze_result_t destroy() = 0;
|
||||
virtual size_t getPoolSize() = 0;
|
||||
virtual uint32_t getPoolUsedCount() = 0;
|
||||
virtual ze_result_t getIpcHandle(ze_ipc_event_pool_handle_t *pIpcHandle) = 0;
|
||||
virtual ze_result_t closeIpcHandle() = 0;
|
||||
virtual ze_result_t createEvent(const ze_event_desc_t *desc, ze_event_handle_t *phEvent) = 0;
|
||||
virtual ze_result_t reserveEventFromPool(int index, Event *event) = 0;
|
||||
virtual ze_result_t releaseEventToPool(Event *event) = 0;
|
||||
virtual Device *getDevice() = 0;
|
||||
|
||||
enum EventCreationState : int {
|
||||
EVENT_STATE_INITIAL = 0,
|
||||
EVENT_STATE_DESTROYED = EVENT_STATE_INITIAL,
|
||||
EVENT_STATE_CREATED = 1
|
||||
};
|
||||
|
||||
static EventPool *fromHandle(ze_event_pool_handle_t handle) {
|
||||
return static_cast<EventPool *>(handle);
|
||||
}
|
||||
|
||||
inline ze_event_pool_handle_t toHandle() { return this; }
|
||||
|
||||
NEO::GraphicsAllocation &getAllocation() { return *eventPoolAllocation; }
|
||||
|
||||
virtual uint32_t getEventSize() = 0;
|
||||
virtual uint32_t getNumEventTimestampTypes() = 0;
|
||||
|
||||
bool isEventPoolUsedForTimestamp = false;
|
||||
|
||||
protected:
|
||||
NEO::GraphicsAllocation *eventPoolAllocation = nullptr;
|
||||
};
|
||||
|
||||
ze_result_t eventPoolOpenIpcHandle(ze_driver_handle_t hDriver, ze_ipc_event_pool_handle_t hIpc,
|
||||
ze_event_pool_handle_t *phEventPool);
|
||||
|
||||
ze_result_t eventCreate(ze_event_pool_handle_t hEventPool, const ze_event_desc_t *desc,
|
||||
ze_event_handle_t *phEvent);
|
||||
|
||||
ze_result_t eventDestroy(ze_event_handle_t hEvent);
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/fence.h"
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/utilities/cpuintrinsics.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
struct FenceImp : public Fence {
|
||||
FenceImp(CommandQueueImp *cmdQueueImp) : cmdQueue(cmdQueueImp) {}
|
||||
|
||||
~FenceImp() override {
|
||||
cmdQueue->getDevice()->getDriverHandle()->getMemoryManager()->freeGraphicsMemory(allocation);
|
||||
allocation = nullptr;
|
||||
}
|
||||
|
||||
ze_result_t destroy() override {
|
||||
delete this;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t hostSynchronize(uint32_t timeout) override;
|
||||
|
||||
ze_result_t queryStatus() override {
|
||||
auto csr = cmdQueue->getCsr();
|
||||
if (csr) {
|
||||
csr->downloadAllocation(*allocation);
|
||||
}
|
||||
|
||||
auto hostAddr = static_cast<uint64_t *>(allocation->getUnderlyingBuffer());
|
||||
return *hostAddr == Fence::STATE_CLEARED ? ZE_RESULT_NOT_READY : ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t reset() override;
|
||||
|
||||
static Fence *fromHandle(ze_fence_handle_t handle) { return static_cast<Fence *>(handle); }
|
||||
|
||||
inline ze_fence_handle_t toHandle() { return this; }
|
||||
|
||||
bool initialize();
|
||||
|
||||
protected:
|
||||
CommandQueueImp *cmdQueue;
|
||||
};
|
||||
|
||||
Fence *Fence::create(CommandQueueImp *cmdQueue, const ze_fence_desc_t *desc) {
|
||||
auto fence = new FenceImp(cmdQueue);
|
||||
UNRECOVERABLE_IF(fence == nullptr);
|
||||
|
||||
fence->initialize();
|
||||
|
||||
return fence;
|
||||
}
|
||||
|
||||
bool FenceImp::initialize() {
|
||||
NEO::AllocationProperties properties(
|
||||
cmdQueue->getDevice()->getRootDeviceIndex(), 64u, NEO::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
|
||||
properties.alignment = 64u;
|
||||
allocation = cmdQueue->getDevice()->getDriverHandle()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
UNRECOVERABLE_IF(allocation == nullptr);
|
||||
|
||||
reset();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ze_result_t FenceImp::reset() {
|
||||
auto hostAddress = static_cast<uint64_t *>(allocation->getUnderlyingBuffer());
|
||||
*(hostAddress) = Fence::STATE_CLEARED;
|
||||
|
||||
NEO::CpuIntrinsics::clFlush(hostAddress);
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t FenceImp::hostSynchronize(uint32_t timeout) {
|
||||
std::chrono::high_resolution_clock::time_point time1, time2;
|
||||
int64_t timeDiff = 0;
|
||||
ze_result_t ret = ZE_RESULT_NOT_READY;
|
||||
|
||||
if (cmdQueue->getCsr()->getType() == NEO::CommandStreamReceiverType::CSR_AUB) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
if (timeout == 0) {
|
||||
return queryStatus();
|
||||
}
|
||||
|
||||
time1 = std::chrono::high_resolution_clock::now();
|
||||
while (timeDiff < timeout) {
|
||||
ret = queryStatus();
|
||||
if (ret == ZE_RESULT_SUCCESS) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
std::this_thread::yield();
|
||||
NEO::CpuIntrinsics::pause();
|
||||
|
||||
if (timeout == std::numeric_limits<uint32_t>::max()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
time2 = std::chrono::high_resolution_clock::now();
|
||||
timeDiff = std::chrono::duration_cast<std::chrono::nanoseconds>(time2 - time1).count();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ze_result_t fenceDestroy(ze_fence_handle_t phFence) {
|
||||
return Fence::fromHandle(phFence)->destroy();
|
||||
}
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/command_stream/csr_definitions.h"
|
||||
|
||||
#include "level_zero/core/source/cmdqueue.h"
|
||||
#include "level_zero/core/source/cmdqueue_imp.h"
|
||||
#include <level_zero/ze_fence.h>
|
||||
|
||||
#include <limits>
|
||||
|
||||
struct _ze_fence_handle_t {};
|
||||
|
||||
namespace L0 {
|
||||
|
||||
struct Fence : _ze_fence_handle_t {
|
||||
static Fence *create(CommandQueueImp *cmdQueue, const ze_fence_desc_t *desc);
|
||||
virtual ~Fence() = default;
|
||||
virtual ze_result_t destroy() = 0;
|
||||
virtual ze_result_t hostSynchronize(uint32_t timeout) = 0;
|
||||
virtual ze_result_t queryStatus() = 0;
|
||||
virtual ze_result_t reset() = 0;
|
||||
|
||||
static Fence *fromHandle(ze_fence_handle_t handle) { return static_cast<Fence *>(handle); }
|
||||
|
||||
inline ze_fence_handle_t toHandle() { return this; }
|
||||
|
||||
enum State : uint32_t {
|
||||
STATE_SIGNALED = 0u,
|
||||
STATE_CLEARED = std::numeric_limits<uint32_t>::max(),
|
||||
STATE_INITIAL = STATE_CLEARED
|
||||
};
|
||||
|
||||
enum EnqueueState : uint32_t { ENQUEUE_NOT_READY = 0u,
|
||||
ENQUEUE_READY };
|
||||
|
||||
NEO::GraphicsAllocation &getAllocation() { return *allocation; }
|
||||
|
||||
uint64_t getGpuAddress() {
|
||||
UNRECOVERABLE_IF(allocation == nullptr);
|
||||
return allocation->getGpuAddress();
|
||||
}
|
||||
|
||||
protected:
|
||||
NEO::GraphicsAllocation *allocation = nullptr;
|
||||
};
|
||||
|
||||
ze_result_t fenceDestroy(ze_fence_handle_t *phFence);
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,17 @@
|
|||
#
|
||||
# Copyright (C) 2019-2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(SUPPORT_GEN11)
|
||||
set(HW_SOURCES_GEN11
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_gen11.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enable_family_full_l0_gen11.cpp
|
||||
)
|
||||
add_subdirectories()
|
||||
|
||||
target_sources(${TARGET_NAME_L0} PRIVATE ${HW_SOURCES_GEN11})
|
||||
set_property(GLOBAL PROPERTY L0_HW_SOURCES_GEN11 ${HW_SOURCES_GEN11})
|
||||
endif()
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
namespace L0 {
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
void CommandListCoreFamily<gfxCoreFamily>::applyMemoryRangesBarrier(uint32_t numRanges,
|
||||
const size_t *pRangeSizes,
|
||||
const void **pRanges) {
|
||||
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControl(*commandContainer.getCommandStream(),
|
||||
true);
|
||||
}
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver_hw.h"
|
||||
|
||||
#include "opencl/source/command_stream/aub_command_stream_receiver_hw.h"
|
||||
#include "opencl/source/command_stream/tbx_command_stream_receiver_hw.h"
|
||||
#include "opencl/source/mem_obj/buffer.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
typedef ICLFamily Family;
|
||||
|
||||
struct EnableL0Gen11 {
|
||||
EnableL0Gen11() {
|
||||
populateFactoryTable<AUBCommandStreamReceiverHw<Family>>();
|
||||
populateFactoryTable<TbxCommandStreamReceiverHw<Family>>();
|
||||
populateFactoryTable<CommandStreamReceiverHw<Family>>();
|
||||
populateFactoryTable<BufferHw<Family>>();
|
||||
}
|
||||
};
|
||||
|
||||
static EnableL0Gen11 enable;
|
||||
} // namespace NEO
|
|
@ -0,0 +1,18 @@
|
|||
#
|
||||
# Copyright (C) 2019-2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(SUPPORT_ICLLP)
|
||||
set(HW_SOURCES_GEN11
|
||||
${HW_SOURCES_GEN11}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_icllp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdqueue_icllp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_icllp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image_icllp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sampler_icllp.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endif()
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/gen11/hw_cmds.h"
|
||||
#include "shared/source/gen11/hw_info.h"
|
||||
|
||||
#include "level_zero/core/source/cmdlist_hw.inl"
|
||||
#include "level_zero/core/source/cmdlist_hw_base.inl"
|
||||
#include "level_zero/core/source/cmdlist_hw_immediate.inl"
|
||||
#include "level_zero/core/source/gen11/cmdlist_gen11.inl"
|
||||
|
||||
#include "cmdlist_extended.inl"
|
||||
#include "igfxfmid.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
template struct CommandListCoreFamily<IGFX_GEN11_CORE>;
|
||||
template struct CommandListCoreFamilyImmediate<IGFX_GEN11_CORE>;
|
||||
|
||||
template <>
|
||||
struct CommandListProductFamily<IGFX_ICELAKE_LP> : public CommandListCoreFamily<IGFX_GEN11_CORE> {
|
||||
using CommandListCoreFamily::CommandListCoreFamily;
|
||||
};
|
||||
|
||||
static CommandListPopulateFactory<IGFX_ICELAKE_LP, CommandListProductFamily<IGFX_ICELAKE_LP>>
|
||||
populateICLLP;
|
||||
|
||||
template <>
|
||||
struct CommandListImmediateProductFamily<IGFX_ICELAKE_LP> : public CommandListCoreFamilyImmediate<IGFX_GEN11_CORE> {
|
||||
using CommandListCoreFamilyImmediate::CommandListCoreFamilyImmediate;
|
||||
};
|
||||
|
||||
static CommandListImmediatePopulateFactory<IGFX_ICELAKE_LP, CommandListImmediateProductFamily<IGFX_ICELAKE_LP>>
|
||||
populateICLLPImmediate;
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/gen11/hw_cmds.h"
|
||||
#include "shared/source/gen11/hw_info.h"
|
||||
|
||||
#include "level_zero/core/source/cmdqueue_hw.inl"
|
||||
#include "level_zero/core/source/cmdqueue_hw_base.inl"
|
||||
|
||||
#include "cmdqueue_extended.inl"
|
||||
#include "igfxfmid.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
static CommandQueuePopulateFactory<IGFX_ICELAKE_LP, CommandQueueHw<IGFX_GEN11_CORE>> populateICLLP;
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/gen11/hw_cmds.h"
|
||||
#include "shared/source/gen11/hw_info.h"
|
||||
|
||||
#include "level_zero/core/source/image_hw.inl"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
template <>
|
||||
struct ImageProductFamily<IGFX_ICELAKE_LP> : public ImageCoreFamily<IGFX_GEN11_CORE> {
|
||||
using ImageCoreFamily::ImageCoreFamily;
|
||||
|
||||
bool initialize(Device *device, const ze_image_desc_t *desc) override {
|
||||
return ImageCoreFamily<IGFX_GEN11_CORE>::initialize(device, desc);
|
||||
};
|
||||
};
|
||||
|
||||
static ImagePopulateFactory<IGFX_ICELAKE_LP, ImageProductFamily<IGFX_ICELAKE_LP>> populateICLLP;
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/kernel_hw.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
static KernelPopulateFactory<IGFX_ICELAKE_LP, KernelHw<IGFX_GEN11_CORE>> populateICLLP;
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/gen11/hw_cmds.h"
|
||||
#include "shared/source/gen11/hw_info.h"
|
||||
|
||||
#include "level_zero/core/source/sampler_hw.inl"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
template <>
|
||||
struct SamplerProductFamily<IGFX_ICELAKE_LP> : public SamplerCoreFamily<IGFX_GEN11_CORE> {
|
||||
using SamplerCoreFamily::SamplerCoreFamily;
|
||||
};
|
||||
|
||||
static SamplerPopulateFactory<IGFX_ICELAKE_LP, SamplerProductFamily<IGFX_ICELAKE_LP>> populateICLLP;
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,19 @@
|
|||
#
|
||||
# Copyright (C) 2019-2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(SUPPORT_GEN12LP)
|
||||
set(HW_SOURCES_GEN12LP
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_gen12lp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/cache_flush_gen12lp.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enable_family_full_l0_gen12lp.cpp
|
||||
)
|
||||
add_subdirectories()
|
||||
target_include_directories(${TARGET_NAME_L0} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/)
|
||||
|
||||
target_sources(${TARGET_NAME_L0} PRIVATE ${HW_SOURCES_GEN12LP})
|
||||
set_property(GLOBAL APPEND PROPERTY L0_HW_SOURCES_GEN12LP ${HW_SOURCES_GEN12LP})
|
||||
endif()
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/core/source/cmdlist_hw.h"
|
||||
#include "level_zero/core/source/cmdlist_hw_immediate.h"
|
||||
|
||||
#include "cache_flush_gen12lp.inl"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
template <PRODUCT_FAMILY productFamily>
|
||||
struct CommandListProductFamily : public CommandListCoreFamily<IGFX_GEN12LP_CORE> {
|
||||
using CommandListCoreFamily::CommandListCoreFamily;
|
||||
};
|
||||
|
||||
template <PRODUCT_FAMILY gfxProductFamily>
|
||||
struct CommandListImmediateProductFamily : public CommandListCoreFamilyImmediate<IGFX_GEN12LP_CORE> {
|
||||
using CommandListCoreFamilyImmediate::CommandListCoreFamilyImmediate;
|
||||
};
|
||||
} // namespace L0
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/cmdlist_hw.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
void CommandListCoreFamily<gfxCoreFamily>::applyMemoryRangesBarrier(uint32_t numRanges,
|
||||
const size_t *pRangeSizes,
|
||||
const void **pRanges) {
|
||||
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControl(*commandContainer.getCommandStream(),
|
||||
true);
|
||||
}
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver_hw.h"
|
||||
|
||||
#include "opencl/source/command_stream/aub_command_stream_receiver_hw.h"
|
||||
#include "opencl/source/command_stream/tbx_command_stream_receiver_hw.h"
|
||||
#include "opencl/source/mem_obj/buffer.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
typedef TGLLPFamily Family;
|
||||
|
||||
struct EnableL0Gen12LP {
|
||||
EnableL0Gen12LP() {
|
||||
populateFactoryTable<AUBCommandStreamReceiverHw<Family>>();
|
||||
populateFactoryTable<TbxCommandStreamReceiverHw<Family>>();
|
||||
populateFactoryTable<CommandStreamReceiverHw<Family>>();
|
||||
populateFactoryTable<BufferHw<Family>>();
|
||||
}
|
||||
};
|
||||
|
||||
static EnableL0Gen12LP enable;
|
||||
} // namespace NEO
|
|
@ -0,0 +1,18 @@
|
|||
#
|
||||
# Copyright (C) 2019-2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(SUPPORT_TGLLP)
|
||||
set(HW_SOURCES_GEN12LP
|
||||
${HW_SOURCES_GEN12LP}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_tgllp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdqueue_tgllp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel_tgllp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image_tgllp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sampler_tgllp.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endif()
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/gen12lp/hw_cmds.h"
|
||||
#include "shared/source/gen12lp/hw_info.h"
|
||||
|
||||
#include "level_zero/core/source/cmdlist_hw.inl"
|
||||
#include "level_zero/core/source/cmdlist_hw_base.inl"
|
||||
#include "level_zero/core/source/cmdlist_hw_immediate.inl"
|
||||
#include "level_zero/core/source/gen12lp/cmdlist_gen12lp.h"
|
||||
|
||||
#include "cmdlist_extended.inl"
|
||||
#include "igfxfmid.h"
|
||||
|
||||
namespace L0 {
|
||||
template struct CommandListCoreFamily<IGFX_GEN12LP_CORE>;
|
||||
|
||||
static CommandListPopulateFactory<IGFX_TIGERLAKE_LP, CommandListProductFamily<IGFX_TIGERLAKE_LP>>
|
||||
populateTGLLP;
|
||||
|
||||
static CommandListImmediatePopulateFactory<IGFX_TIGERLAKE_LP, CommandListImmediateProductFamily<IGFX_TIGERLAKE_LP>>
|
||||
populateTGLLPImmediate;
|
||||
} // namespace L0
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/gen12lp/hw_cmds.h"
|
||||
#include "shared/source/gen12lp/hw_info.h"
|
||||
|
||||
#include "level_zero/core/source/cmdqueue_hw.inl"
|
||||
#include "level_zero/core/source/cmdqueue_hw_base.inl"
|
||||
|
||||
#include "cmdqueue_extended.inl"
|
||||
#include "igfxfmid.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
static CommandQueuePopulateFactory<IGFX_TIGERLAKE_LP, CommandQueueHw<IGFX_GEN12LP_CORE>>
|
||||
populateTGLLP;
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/gen12lp/hw_cmds.h"
|
||||
#include "shared/source/gen12lp/hw_info.h"
|
||||
|
||||
#include "level_zero/core/source/image_hw.inl"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
template <>
|
||||
struct ImageProductFamily<IGFX_TIGERLAKE_LP> : public ImageCoreFamily<IGFX_GEN12LP_CORE> {
|
||||
using ImageCoreFamily::ImageCoreFamily;
|
||||
|
||||
bool initialize(Device *device, const ze_image_desc_t *desc) override {
|
||||
return ImageCoreFamily<IGFX_GEN12LP_CORE>::initialize(device, desc);
|
||||
};
|
||||
};
|
||||
|
||||
static ImagePopulateFactory<IGFX_TIGERLAKE_LP, ImageProductFamily<IGFX_TIGERLAKE_LP>> populateTGLLP;
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/kernel_hw.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
static KernelPopulateFactory<IGFX_TIGERLAKE_LP, KernelHw<IGFX_GEN12LP_CORE>> populateTGLLP;
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/gen12lp/hw_cmds.h"
|
||||
#include "shared/source/gen12lp/hw_info.h"
|
||||
|
||||
#include "level_zero/core/source/sampler_hw.inl"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
template <>
|
||||
struct SamplerProductFamily<IGFX_TIGERLAKE_LP> : public SamplerCoreFamily<IGFX_GEN12LP_CORE> {
|
||||
using SamplerCoreFamily::SamplerCoreFamily;
|
||||
};
|
||||
|
||||
static SamplerPopulateFactory<IGFX_TIGERLAKE_LP, SamplerProductFamily<IGFX_TIGERLAKE_LP>> populateTGLLP;
|
||||
|
||||
} // namespace L0
|
|
@ -0,0 +1,15 @@
|
|||
#
|
||||
# Copyright (C) 2019-2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(SUPPORT_GEN8)
|
||||
set(HW_SOURCES_GEN8
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enable_family_full_l0_gen8.cpp
|
||||
)
|
||||
|
||||
target_sources(${TARGET_NAME_L0} PRIVATE ${HW_SOURCES_GEN8})
|
||||
set_property(GLOBAL PROPERTY L0_HW_SOURCES_GEN8 ${HW_SOURCES_GEN8})
|
||||
endif()
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver_hw.h"
|
||||
|
||||
#include "opencl/source/command_stream/aub_command_stream_receiver_hw.h"
|
||||
#include "opencl/source/command_stream/tbx_command_stream_receiver_hw.h"
|
||||
#include "opencl/source/mem_obj/buffer.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
typedef BDWFamily Family;
|
||||
|
||||
struct EnableL0Gen8 {
|
||||
EnableL0Gen8() {
|
||||
populateFactoryTable<AUBCommandStreamReceiverHw<Family>>();
|
||||
populateFactoryTable<TbxCommandStreamReceiverHw<Family>>();
|
||||
populateFactoryTable<CommandStreamReceiverHw<Family>>();
|
||||
populateFactoryTable<BufferHw<Family>>();
|
||||
}
|
||||
};
|
||||
|
||||
static EnableL0Gen8 enable;
|
||||
} // namespace NEO
|
|
@ -0,0 +1,18 @@
|
|||
#
|
||||
# Copyright (C) 2019-2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(SUPPORT_GEN9)
|
||||
set(HW_SOURCES_GEN9
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_gen9.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enable_family_full_l0_gen9.cpp
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
target_sources(${TARGET_NAME_L0} PRIVATE ${HW_SOURCES_GEN9})
|
||||
set_property(GLOBAL PROPERTY L0_HW_SOURCES_GEN9 ${HW_SOURCES_GEN9})
|
||||
endif()
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue