Merge branch 'origin/pghafari/opencl' into lmoriche/amd-master-next
Этот коммит содержится в:
+19
-105
@@ -1,112 +1,24 @@
|
||||
cmake_minimum_required(VERSION 3.4.3)
|
||||
|
||||
if (POLICY CMP0048)
|
||||
cmake_policy(SET CMP0048 NEW)
|
||||
set(PROJ_VERSION VERSION 1.5.0)
|
||||
cmake_policy(SET CMP0048 NEW)
|
||||
set(PROJ_VERSION VERSION 1.5.0)
|
||||
endif()
|
||||
|
||||
# FIXME: Remove following line after enabling COMGR by default
|
||||
set(USE_COMGR_LIBRARY "no" CACHE STRING "Do not enable COMGR by default")
|
||||
project(opencl)
|
||||
|
||||
# Build ROCm-OpenCL with ccache if the package is present.
|
||||
set(ROCM_OPENCL_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build")
|
||||
if(ROCM_OPENCL_CCACHE_BUILD)
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
if(CCACHE_PROGRAM)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM})
|
||||
else()
|
||||
message(FATAL_ERROR "Unable to find the program ccache. Set ROCM_OPENCL_CCACHE_BUILD to OFF")
|
||||
endif()
|
||||
#example command:
|
||||
#cmake -DVDI_DIR=/home/pghafari/git-vdi/opencl -DUSE_COMGR_LIBRARY=yes -DCMAKE_PREFIX_PATH="/home/pghafari/rocmgitvdi/support/lib/comgr;/home/pghafari/rocmgitvdi/support/lib/comgr/build;" -DLLVM_INCLUDES=/home/pghafari/rocmgit/llvm-project/llvm/include -DLIBVDI_STATIC_DIR=/home/pghafari/git-vdi/opencl/build -DCMAKE_MODULE_PATH=/home/pghafari/rocmgit/opencl/cmake/modules ..
|
||||
|
||||
# FIXME: Remove following if block after enabling COMGR by default
|
||||
if (${USE_COMGR_LIBRARY} STREQUAL "no")
|
||||
set(LLVM_CCACHE_BUILD ON CACHE BOOL "")
|
||||
set(ROCM_DEVICE_LIBS_CCACHE_BUILD ON CACHE BOOL "")
|
||||
set(ROCM_OPENCL_DRIVER_CCACHE_BUILD ON CACHE BOOL "")
|
||||
endif() # if (${USE_COMGR_LIBRARY} STREQUAL "no")
|
||||
endif()
|
||||
set(OPENCL_ICD_LOADER_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/khronos/headers/opencl2.2" CACHE PATH "")
|
||||
set(BUILD_SHARED_LIBS "Build shared libs" ON)
|
||||
|
||||
project(rocm-opencl)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
||||
set(OPENCL_ICD_LOADER_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2" CACHE PATH "")
|
||||
|
||||
find_package(ROCT REQUIRED)
|
||||
find_package(ROCR REQUIRED)
|
||||
|
||||
# FIXME: Remove following if block after enabling COMGR by default
|
||||
if (${USE_COMGR_LIBRARY} STREQUAL "no")
|
||||
set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
|
||||
set(LLVM_BUILD_TOOLS OFF CACHE BOOL "")
|
||||
set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
|
||||
set(LLVM_TARGETS_TO_BUILD "AMDGPU" CACHE STRING "")
|
||||
set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
|
||||
set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
|
||||
|
||||
# override default option value in library and driver
|
||||
set(GENERIC_IS_ZERO ON CACHE BOOL ON FORCE)
|
||||
|
||||
add_subdirectory(compiler/llvm EXCLUDE_FROM_ALL)
|
||||
|
||||
find_package(LLVM REQUIRED CONFIG PATHS ${CMAKE_BINARY_DIR}/compiler/llvm NO_DEFAULT_PATH)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
|
||||
include(AddLLVM)
|
||||
|
||||
add_definitions(${LLVM_DEFINITIONS})
|
||||
# TODO: add find_package for Clang and lld, and also use LLVM/Clang variables got from their config
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/include)
|
||||
include_directories(${CMAKE_BINARY_DIR}/compiler/llvm/tools/clang/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/llvm/tools/lld/include)
|
||||
|
||||
# TODO: move AMDGPU.h header to include folder
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/llvm/lib/Target/AMDGPU)
|
||||
include_directories(${CMAKE_BINARY_DIR}/compiler/llvm/lib/Target/AMDGPU)
|
||||
|
||||
set(BUILD_HC_LIB OFF CACHE BOOL "")
|
||||
set(ROCM_DEVICELIB_INCLUDE_TESTS OFF CACHE BOOL "")
|
||||
set(AMDGCN_TARGETS_LIB_LIST "AMDGCN_LIB_TARGETS")
|
||||
set(AMDGCN_TARGETS_LIB_DEPS "AMDGCN_DEP_TARGETS")
|
||||
set(AMDGPU_TARGET_TRIPLE "amdgcn-amd-amdhsa")
|
||||
add_subdirectory(library/amdgcn EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(compiler/driver EXCLUDE_FROM_ALL)
|
||||
|
||||
install(PROGRAMS $<TARGET_FILE:clang> $<TARGET_FILE:lld>
|
||||
DESTINATION bin/x86_64
|
||||
COMPONENT DEV)
|
||||
|
||||
foreach(AMDGCN_LIB_TARGET ${AMDGCN_LIB_TARGETS})
|
||||
get_target_property(lib_file_name ${AMDGCN_LIB_TARGET} ARCHIVE_OUTPUT_NAME)
|
||||
get_target_property(lib_file_path ${AMDGCN_LIB_TARGET} ARCHIVE_OUTPUT_DIRECTORY)
|
||||
install(FILES ${lib_file_path}/${lib_file_name}.amdgcn.bc
|
||||
DESTINATION lib/x86_64/bitcode
|
||||
COMPONENT DEV)
|
||||
endforeach()
|
||||
endif() # if (${USE_COMGR_LIBRARY} STREQUAL "no")
|
||||
|
||||
if(${USE_COMGR_LIBRARY} MATCHES "yes")
|
||||
set(COMGR_DYN_DLL "yes")
|
||||
add_definitions(-DCOMGR_DYN_DLL)
|
||||
add_definitions(-DUSE_COMGR_LIBRARY)
|
||||
if( ${BUILD_HIP} MATCHES "yes")
|
||||
add_subdirectory(api/hip)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(api/opencl/amdocl)
|
||||
add_subdirectory(compiler/lib/loaders/elf/utils/libelf)
|
||||
add_subdirectory(runtime)
|
||||
add_subdirectory(khronos/icd)
|
||||
add_subdirectory(amdocl)
|
||||
add_subdirectory(tools/clinfo)
|
||||
|
||||
set(BUILD_SHARED_LIBS "Build shared libs" ON)
|
||||
add_subdirectory(api/opencl/khronos/icd)
|
||||
|
||||
###--- Packaging ------------------------------------------------------------###
|
||||
|
||||
find_package(ROCM QUIET CONFIG PATHS /opt/rocm)
|
||||
include(ROCMSetupVersion)
|
||||
rocm_setup_version( VERSION "2.0.0" )
|
||||
|
||||
# MAIN package
|
||||
install(PROGRAMS $<TARGET_FILE:clinfo>
|
||||
DESTINATION bin/x86_64
|
||||
@@ -122,7 +34,7 @@ install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
|
||||
COMPONENT MAIN)
|
||||
|
||||
# DEV package
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/khronos/headers/opencl2.2/CL"
|
||||
DESTINATION include
|
||||
COMPONENT DEV
|
||||
USE_SOURCE_PERMISSIONS
|
||||
@@ -141,28 +53,30 @@ set(CPACK_PACKAGE_CONTACT "Advanced Micro Devices Inc.")
|
||||
set(CPACK_PACKAGE_VENDOR "AMD")
|
||||
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/rocm/opencl")
|
||||
|
||||
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "1")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "2")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "0")
|
||||
|
||||
# Debian CPACK variables
|
||||
set(CPACK_DEB_COMPONENT_INSTALL ON)
|
||||
|
||||
set(CPACK_DEBIAN_MAIN_FILE_NAME "rocm-opencl-${PROJECT_VERSION}-Linux.deb")
|
||||
set(CPACK_DEBIAN_MAIN_FILE_NAME "rocm-opencl-1.2.0.deb")
|
||||
set(CPACK_DEBIAN_MAIN_PACKAGE_NAME "rocm-opencl")
|
||||
set(CPACK_DEBIAN_MAIN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/DEB/postinst;${CMAKE_CURRENT_SOURCE_DIR}/DEB/prerm")
|
||||
|
||||
set(CPACK_DEBIAN_FILE_NAME "rocm-opencl-dev-${PROJECT_VERSION}-Linux.deb")
|
||||
set(CPACK_DEBIAN_PACKAGE_NAME "rocm-opencl-dev")
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "rocm-opencl")
|
||||
set(CPACK_DEBIAN_DEV_FILE_NAME "rocm-opencl-dev-1.2.0.deb")
|
||||
set(CPACK_DEBIAN_DEV_PACKAGE_NAME "rocm-opencl-dev")
|
||||
set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "rocm-opencl")
|
||||
|
||||
# RPM CPACK variables
|
||||
set(CPACK_RPM_COMPONENT_INSTALL ON)
|
||||
|
||||
set(CPACK_RPM_MAIN_FILE_NAME "rocm-opencl-${PROJECT_VERSION}-Linux.rpm")
|
||||
set(CPACK_RPM_MAIN_FILE_NAME "rocm-opencl-1.2.0.rpm")
|
||||
set(CPACK_RPM_MAIN_PACKAGE_NAME "rocm-opencl")
|
||||
set(CPACK_RPM_MAIN_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_post")
|
||||
set(CPACK_RPM_MAIN_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_postun")
|
||||
|
||||
set(CPACK_RPM_DEV_FILE_NAME "rocm-opencl-devel-${PROJECT_VERSION}-Linux.rpm")
|
||||
set(CPACK_RPM_DEV_FILE_NAME "rocm-opencl-devel-1.2.0.rpm")
|
||||
set(CPACK_RPM_DEV_PACKAGE_NAME "rocm-opencl-devel")
|
||||
set(CPACK_RPM_DEV_PACKAGE_DEPENDS "rocm-opencl")
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
|
||||
|
||||
# Some linker flags, -Wl,--unresolved-symbols=report-all being one of them, requires -shared-libasan if using -fsanitize=address.
|
||||
# If -Wl,--unresolved-symbols=report-all is removed from CMAKE_SHARED_LINKER_FLAGS, then update this snippet
|
||||
@@ -6,10 +7,15 @@ if(CMAKE_CXX_FLAGS MATCHES "fsanitize=address")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -shared-libasan")
|
||||
endif()
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic -Wl,--unresolved-symbols=report-all -Wl,--version-script=${CMAKE_SOURCE_DIR}/api/opencl/amdocl/amdocl.map")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic -Wl,--unresolved-symbols=report-all -Wl,--version-script=${CMAKE_SOURCE_DIR}/amdocl/amdocl.map")
|
||||
|
||||
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
||||
|
||||
find_package(ROCT REQUIRED)
|
||||
find_package(ROCR REQUIRED)
|
||||
|
||||
add_definitions(-DLINUX -D__x86_64__ -D__AMD64__ -DUNIX_OS -DqLittleEndian -DOPENCL_MAJOR=2 -DOPENCL_MINOR=0 -DWITH_AQL -DWITH_ONLINE_COMPILER -DATI_OS_LINUX -DATI_ARCH_X86 -DLITTLEENDIAN_CPU -DATI_BITS_64 -DATI_COMP_GCC -DWITH_HSA_DEVICE -DWITH_TARGET_AMDGCN -DOPENCL_EXPORTS -DCL_USE_DEPRECATED_OPENCL_1_0_APIS -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_USE_DEPRECATED_OPENCL_2_0_APIS -DVEGA10_ONLY=false -DWITH_LIGHTNING_COMPILER)
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
|
||||
@@ -17,29 +23,31 @@ if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
|
||||
endif()
|
||||
|
||||
include_directories(${ROCR_INCLUDES})
|
||||
if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "")
|
||||
include_directories(${LLVM_INCLUDES})
|
||||
endif() # if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "")
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/runtime)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/api/opencl)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/api/opencl/khronos)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/api/opencl/khronos/headers)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2)
|
||||
if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "")
|
||||
include_directories(${LLVM_INCLUDES})
|
||||
endif() # if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "")
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR})
|
||||
include_directories(${CMAKE_SOURCE_DIR}/khronos)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/khronos/headers)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/khronos/headers/opencl2.2)
|
||||
if(${USE_COMGR_LIBRARY} MATCHES "yes")
|
||||
add_definitions(-DUSE_COMGR_LIBRARY -DCOMGR_DYN_DLL)
|
||||
find_package(amd_comgr REQUIRED CONFIG)
|
||||
include_directories("$<TARGET_PROPERTY:amd_comgr,INTERFACE_INCLUDE_DIRECTORIES>")
|
||||
else()
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/driver/src)
|
||||
# include_directories(${CMAKE_SOURCE_DIR}/compiler/driver/src)
|
||||
endif()
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/lib)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/backends/common)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/loaders)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/loaders/elf/utils/libelf)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/loaders/elf/utils/common)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/tools)
|
||||
include_directories(${VDI_DIR})
|
||||
include_directories(${VDI_DIR}/include)
|
||||
include_directories(${VDI_DIR}/compiler/lib)
|
||||
include_directories(${VDI_DIR}/compiler/lib/include)
|
||||
include_directories(${VDI_DIR}/compiler/lib/backends/common)
|
||||
#include_directories(${VDI_DIR}/compiler/lib/loaders)
|
||||
include_directories(${VDI_DIR}/elf/utils/libelf)
|
||||
include_directories(${VDI_DIR}/elf/utils/common)
|
||||
#include_directories(${VDI_DIR}/compiler/tools)
|
||||
|
||||
if(UNIX)
|
||||
set(ADDITIONAL_LIBRARIES glibc_functions.cpp)
|
||||
@@ -47,7 +55,7 @@ else()
|
||||
set(ADDITIONAL_LIBRARIES "")
|
||||
endif()
|
||||
|
||||
add_library(amdocl64 SHARED
|
||||
add_library(amdocl64_obj OBJECT
|
||||
cl_memobj.cpp
|
||||
cl_program.cpp
|
||||
cl_sdi_amd.cpp
|
||||
@@ -73,12 +81,23 @@ add_library(amdocl64 SHARED
|
||||
cl_context.cpp
|
||||
cl_profile_amd.cpp
|
||||
cl_p2p_amd.cpp
|
||||
$<TARGET_OBJECTS:oclruntime>
|
||||
$<TARGET_OBJECTS:oclrocm>
|
||||
# $<TARGET_OBJECTS:oclruntime>
|
||||
#$<TARGET_OBJECTS:oclrocm>
|
||||
${ADDITIONAL_LIBRARIES}
|
||||
)
|
||||
if(${USE_COMGR_LIBRARY} MATCHES "yes")
|
||||
target_link_libraries(amdocl64 oclelf pthread dl ${ROCT_LIBRARIES} ${ROCR_LIBRARIES})
|
||||
else()
|
||||
target_link_libraries(amdocl64 opencl_driver oclelf pthread dl ${ROCT_LIBRARIES} ${ROCR_LIBRARIES})
|
||||
endif()
|
||||
|
||||
add_library(amdocl64 SHARED
|
||||
$<TARGET_OBJECTS:amdocl64_obj>
|
||||
)
|
||||
add_library(amdocl64_static STATIC
|
||||
$<TARGET_OBJECTS:amdocl64_obj>
|
||||
)
|
||||
|
||||
add_library(amdvdi_static STATIC IMPORTED)
|
||||
set_target_properties(amdvdi_static PROPERTIES IMPORTED_LOCATION "${LIBVDI_STATIC_DIR}/libamdvdi_static.a")
|
||||
|
||||
#add_library(oclelf STATIC IMPORTED)
|
||||
#set_target_properties(oclelf PROPERTIES IMPORTED_LOCATION "${LIBOCLELF_STATIC_PATH}/liboclelf.a")
|
||||
target_link_libraries(amdocl64_static amdvdi_static pthread dl ${ROCT_LIBRARIES} ${ROCR_LIBRARIES})
|
||||
|
||||
target_link_libraries(amdocl64 amdvdi_static pthread dl ${ROCT_LIBRARIES} ${ROCR_LIBRARIES})
|
||||
@@ -172,5 +172,3 @@ aclDumpBinary
|
||||
#if (OPENCL_MAJOR > 2) || (OPENCL_MAJOR == 2 && OPENCL_MINOR >= 1)
|
||||
clCreateProgramWithIL
|
||||
#endif
|
||||
#if !defined(OPENCL_MAINLINE)
|
||||
#endif
|
||||
@@ -111,7 +111,7 @@ RUNTIME_ENTRY(cl_int, clGetPlatformInfo,
|
||||
value = "Advanced Micro Devices, Inc.";
|
||||
break;
|
||||
case CL_PLATFORM_EXTENSIONS:
|
||||
value = "cl_khr_icd " NOT_MAINLINE("cl_amd_object_metadata ")
|
||||
value = "cl_khr_icd "
|
||||
#ifdef _WIN32
|
||||
"cl_khr_d3d10_sharing "
|
||||
"cl_khr_d3d11_sharing "
|
||||
@@ -0,0 +1,16 @@
|
||||
# Try to find ROCR (Radeon Open Compute Runtime)
|
||||
#
|
||||
# Once found, this will define:
|
||||
# - ROCR_FOUND - ROCR status (found or not found)
|
||||
# - ROCR_INCLUDES - Required ROCR include directories
|
||||
# - ROCR_LIBRARIES - Required ROCR libraries
|
||||
find_path(FIND_ROCR_INCLUDES hsa.h HINTS /opt/rocm/include /opt/rocm/hsa/include PATH_SUFFIXES hsa)
|
||||
find_library(FIND_ROCR_LIBRARIES hsa-runtime64 HINTS /opt/rocm/lib /opt/rocm/hsa/lib)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(ROCR DEFAULT_MSG
|
||||
FIND_ROCR_INCLUDES FIND_ROCR_LIBRARIES)
|
||||
mark_as_advanced(FIND_ROCR_INCLUDES FIND_ROCR_LIBRARIES)
|
||||
|
||||
set(ROCR_INCLUDES ${FIND_ROCR_INCLUDES})
|
||||
set(ROCR_LIBRARIES ${FIND_ROCR_LIBRARIES})
|
||||
@@ -0,0 +1,16 @@
|
||||
# Try to find ROCT (Radeon Open Compute Thunk)
|
||||
#
|
||||
# Once found, this will define:
|
||||
# - ROCT_FOUND - ROCT status (found or not found)
|
||||
# - ROCT_INCLUDES - Required ROCT include directories
|
||||
# - ROCT_LIBRARIES - Required ROCT libraries
|
||||
find_path(FIND_ROCT_INCLUDES hsakmt.h HINTS /opt/rocm/include)
|
||||
find_library(FIND_ROCT_LIBRARIES hsakmt HINTS /opt/rocm/lib)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(ROCT DEFAULT_MSG
|
||||
FIND_ROCT_INCLUDES FIND_ROCT_LIBRARIES)
|
||||
mark_as_advanced(FIND_ROCT_INCLUDES FIND_ROCT_LIBRARIES)
|
||||
|
||||
set(ROCT_INCLUDES ${FIND_ROCT_INCLUDES})
|
||||
set(ROCT_LIBRARIES ${FIND_ROCT_LIBRARIES})
|
||||
@@ -0,0 +1,39 @@
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c
|
||||
"#include <stdio.h>\n"
|
||||
"int main(int argc, char **argv){\n"
|
||||
" FILE *ifp, *ofp;\n"
|
||||
" int c, i, l;\n"
|
||||
" if (argc != 4) return 1;\n"
|
||||
" ifp = fopen(argv[1], \"rb\");\n"
|
||||
" if (!ifp) return 1;\n"
|
||||
" i = fseek(ifp, 0, SEEK_END);\n"
|
||||
" if (i < 0) return 1;\n"
|
||||
" l = ftell(ifp);\n"
|
||||
" if (l < 0) return 1;\n"
|
||||
" i = fseek(ifp, 0, SEEK_SET);\n"
|
||||
" if (i < 0) return 1;\n"
|
||||
" ofp = fopen(argv[2], \"wb+\");\n"
|
||||
" if (!ofp) return 1;\n"
|
||||
" fprintf(ofp, \"#define %s_size %d\\n\\n\"\n"
|
||||
" \"#if defined __GNUC__\\n\"\n"
|
||||
" \"__attribute__((aligned (4096)))\\n\"\n"
|
||||
" \"#elif defined _MSC_VER\\n\"\n"
|
||||
" \"__declspec(align(4096))\\n\"\n"
|
||||
" \"#endif\\n\"\n"
|
||||
" \"static const unsigned char %s[%s_size+1] = {\",\n"
|
||||
" argv[3], l,\n"
|
||||
" argv[3], argv[3]);\n"
|
||||
" i = 0;\n"
|
||||
" while ((c = getc(ifp)) != EOF) {\n"
|
||||
" if (0 == (i&7)) fprintf(ofp, \"\\n \");\n"
|
||||
" fprintf(ofp, \" 0x%02x,\", c);\n"
|
||||
" ++i;\n"
|
||||
" }\n"
|
||||
" fprintf(ofp, \" 0x00\\n};\\n\\n\");\n"
|
||||
" fclose(ifp);\n"
|
||||
" fclose(ofp);\n"
|
||||
" return 0;\n"
|
||||
"}\n"
|
||||
)
|
||||
|
||||
add_executable(bc2h ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c)
|
||||
@@ -1,204 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software source and associated documentation files (the "Materials"),
|
||||
* to deal in the Materials without restriction, including without limitation
|
||||
* the rights to use, copy, modify, compile, merge, publish, distribute,
|
||||
* sublicense, and/or sell copies of the Materials, and to permit persons to
|
||||
* whom the Materials are furnished to do so, subject the following terms and
|
||||
* conditions:
|
||||
*
|
||||
* All modifications to the Materials used to create a binary that is
|
||||
* distributed to third parties shall be provided to Khronos with an
|
||||
* unrestricted license to use for the purposes of implementing bug fixes and
|
||||
* enhancements to the Materials;
|
||||
*
|
||||
* If the binary is used as part of an OpenCL(TM) implementation, whether binary
|
||||
* is distributed together with or separately to that implementation, then
|
||||
* recipient must become an OpenCL Adopter and follow the published OpenCL
|
||||
* conformance process for that implementation, details at:
|
||||
* http://www.khronos.org/conformance/;
|
||||
*
|
||||
* The above copyright notice, the OpenCL trademark license, and this permission
|
||||
* notice shall be included in all copies or substantial portions of the
|
||||
* Materials.
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN
|
||||
* THE MATERIALS.
|
||||
*
|
||||
* OpenCL is a trademark of Apple Inc. used under license by Khronos.
|
||||
*/
|
||||
|
||||
#include "icd.h"
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <pthread.h>
|
||||
|
||||
static pthread_once_t initialized = PTHREAD_ONCE_INIT;
|
||||
|
||||
/*
|
||||
*
|
||||
* Vendor enumeration functions
|
||||
*
|
||||
*/
|
||||
|
||||
// go through the list of vendors in the two configuration files
|
||||
void khrIcdOsVendorsEnumerate(void)
|
||||
{
|
||||
DIR *dir = NULL;
|
||||
struct dirent *dirEntry = NULL;
|
||||
char *vendorPath;
|
||||
|
||||
vendorPath = getenv("OPENCL_VENDOR_PATH");
|
||||
if (vendorPath == NULL)
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
vendorPath = "/system/vendor/Khronos/OpenCL/vendors/";
|
||||
#else
|
||||
vendorPath = "/etc/OpenCL/vendors/";
|
||||
#endif // ANDROID
|
||||
}
|
||||
|
||||
// open the directory
|
||||
dir = opendir(vendorPath);
|
||||
if (NULL == dir)
|
||||
{
|
||||
KHR_ICD_TRACE("Failed to open path %s\n", vendorPath);
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
// attempt to load all files in the directory
|
||||
for (dirEntry = readdir(dir); dirEntry; dirEntry = readdir(dir) )
|
||||
{
|
||||
switch(dirEntry->d_type)
|
||||
{
|
||||
case DT_UNKNOWN:
|
||||
case DT_REG:
|
||||
case DT_LNK:
|
||||
{
|
||||
const char* extension = ".icd";
|
||||
FILE *fin = NULL;
|
||||
char* fileName = NULL;
|
||||
char* buffer = NULL;
|
||||
long bufferSize = 0;
|
||||
|
||||
// make sure the file name ends in .icd
|
||||
if (strlen(extension) > strlen(dirEntry->d_name) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (strcmp(dirEntry->d_name + strlen(dirEntry->d_name) - strlen(extension), extension) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// allocate space for the full path of the vendor library name
|
||||
fileName = malloc(strlen(dirEntry->d_name) + 1 + strlen(vendorPath) + 1);
|
||||
if (!fileName)
|
||||
{
|
||||
KHR_ICD_TRACE("Failed allocate space for ICD file path\n");
|
||||
break;
|
||||
}
|
||||
sprintf(fileName, "%s/%s", vendorPath, dirEntry->d_name);
|
||||
|
||||
// open the file and read its contents
|
||||
fin = fopen(fileName, "r");
|
||||
if (!fin)
|
||||
{
|
||||
free(fileName);
|
||||
break;
|
||||
}
|
||||
fseek(fin, 0, SEEK_END);
|
||||
bufferSize = ftell(fin);
|
||||
|
||||
buffer = malloc(bufferSize+1);
|
||||
if (!buffer)
|
||||
{
|
||||
free(fileName);
|
||||
fclose(fin);
|
||||
break;
|
||||
}
|
||||
memset(buffer, 0, bufferSize+1);
|
||||
fseek(fin, 0, SEEK_SET);
|
||||
if (bufferSize != (long)fread(buffer, 1, bufferSize, fin) )
|
||||
{
|
||||
free(fileName);
|
||||
free(buffer);
|
||||
fclose(fin);
|
||||
break;
|
||||
}
|
||||
// ignore a newline at the end of the file
|
||||
if (buffer[bufferSize-1] == '\n') buffer[bufferSize-1] = '\0';
|
||||
|
||||
// load the string read from the file
|
||||
khrIcdVendorAdd(buffer);
|
||||
|
||||
free(fileName);
|
||||
free(buffer);
|
||||
fclose(fin);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
|
||||
// free resources and exit
|
||||
if (dir)
|
||||
{
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
KHRicdVendor *vendorIterator;
|
||||
for (vendorIterator = khrIcdVendors; vendorIterator; vendorIterator = vendorIterator->next)
|
||||
{
|
||||
if (vendorIterator->libName != NULL)
|
||||
{
|
||||
free(vendorIterator->libName);
|
||||
vendorIterator->libName = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// go through the list of vendors only once
|
||||
void khrIcdOsVendorsEnumerateOnce(void)
|
||||
{
|
||||
pthread_once(&initialized, khrIcdOsVendorsEnumerate);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Dynamic library loading functions
|
||||
*
|
||||
*/
|
||||
|
||||
// dynamically load a library. returns NULL on failure
|
||||
void *khrIcdOsLibraryLoad(const char *libraryName)
|
||||
{
|
||||
return dlopen (libraryName, RTLD_NOW);
|
||||
}
|
||||
|
||||
// get a function pointer from a loaded library. returns NULL on failure.
|
||||
void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName)
|
||||
{
|
||||
return dlsym(library, functionName);
|
||||
}
|
||||
|
||||
// unload a library
|
||||
void khrIcdOsLibraryUnload(void *library)
|
||||
{
|
||||
dlclose(library);
|
||||
}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software source and associated documentation files (the "Materials"),
|
||||
* to deal in the Materials without restriction, including without limitation
|
||||
* the rights to use, copy, modify, compile, merge, publish, distribute,
|
||||
* sublicense, and/or sell copies of the Materials, and to permit persons to
|
||||
* whom the Materials are furnished to do so, subject the following terms and
|
||||
* conditions:
|
||||
*
|
||||
* All modifications to the Materials used to create a binary that is
|
||||
* distributed to third parties shall be provided to Khronos with an
|
||||
* unrestricted license to use for the purposes of implementing bug fixes and
|
||||
* enhancements to the Materials;
|
||||
*
|
||||
* If the binary is used as part of an OpenCL(TM) implementation, whether binary
|
||||
* is distributed together with or separately to that implementation, then
|
||||
* recipient must become an OpenCL Adopter and follow the published OpenCL
|
||||
* conformance process for that implementation, details at:
|
||||
* http://www.khronos.org/conformance/;
|
||||
*
|
||||
* The above copyright notice, the OpenCL trademark license, and this permission
|
||||
* notice shall be included in all copies or substantial portions of the
|
||||
* Materials.
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN
|
||||
* THE MATERIALS.
|
||||
*
|
||||
* OpenCL is a trademark of Apple Inc. used under license by Khronos.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef RC_INVOKED
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,2,1,0
|
||||
PRODUCTVERSION 2,2,1,0
|
||||
FILETYPE VFT_DLL
|
||||
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "FileDescription" ,"OpenCL Client DLL"
|
||||
VALUE "ProductName" ,"Khronos OpenCL ICD"
|
||||
VALUE "LegalCopyright" ,"Copyright \251 The Khronos Group Inc 2016"
|
||||
VALUE "FileVersion" ,"2.2.1.0"
|
||||
VALUE "CompanyName" ,"Khronos Group"
|
||||
VALUE "InternalName" ,"OpenCL"
|
||||
VALUE "OriginalFilename","OpenCL.dll"
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
// extend this line for localized versions
|
||||
VALUE "Translation", 0x0409, 0x04E4
|
||||
END
|
||||
END
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software source and associated documentation files (the "Materials"),
|
||||
* to deal in the Materials without restriction, including without limitation
|
||||
* the rights to use, copy, modify, compile, merge, publish, distribute,
|
||||
* sublicense, and/or sell copies of the Materials, and to permit persons to
|
||||
* whom the Materials are furnished to do so, subject the following terms and
|
||||
* conditions:
|
||||
*
|
||||
* All modifications to the Materials used to create a binary that is
|
||||
* distributed to third parties shall be provided to Khronos with an
|
||||
* unrestricted license to use for the purposes of implementing bug fixes and
|
||||
* enhancements to the Materials;
|
||||
*
|
||||
* If the binary is used as part of an OpenCL(TM) implementation, whether binary
|
||||
* is distributed together with or separately to that implementation, then
|
||||
* recipient must become an OpenCL Adopter and follow the published OpenCL
|
||||
* conformance process for that implementation, details at:
|
||||
* http://www.khronos.org/conformance/;
|
||||
*
|
||||
* The above copyright notice, the OpenCL trademark license, and this permission
|
||||
* notice shall be included in all copies or substantial portions of the
|
||||
* Materials.
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN
|
||||
* THE MATERIALS.
|
||||
*
|
||||
* OpenCL is a trademark of Apple Inc. used under license by Khronos.
|
||||
*/
|
||||
|
||||
#include "icd.h"
|
||||
#include "icd_windows_hkr.h"
|
||||
#include "icd_windows_dxgk.h"
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <winreg.h>
|
||||
|
||||
static INIT_ONCE initialized = INIT_ONCE_STATIC_INIT;
|
||||
|
||||
/*
|
||||
*
|
||||
* Vendor enumeration functions
|
||||
*
|
||||
*/
|
||||
|
||||
// go through the list of vendors in the registry and call khrIcdVendorAdd
|
||||
// for each vendor encountered
|
||||
BOOL CALLBACK khrIcdOsVendorsEnumerate(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContext)
|
||||
{
|
||||
LONG result;
|
||||
const char* platformsName = "SOFTWARE\\Khronos\\OpenCL\\Vendors";
|
||||
HKEY platformsKey = NULL;
|
||||
DWORD dwIndex;
|
||||
|
||||
if (!khrIcdOsVendorsEnumerateDXGK())
|
||||
{
|
||||
KHR_ICD_TRACE("Failed to load via DXGK interface on RS4, continuing\n");
|
||||
if (!khrIcdOsVendorsEnumerateHKR())
|
||||
{
|
||||
KHR_ICD_TRACE("Failed to enumerate HKR entries, continuing\n");
|
||||
}
|
||||
}
|
||||
|
||||
KHR_ICD_TRACE("Opening key HKLM\\%s...\n", platformsName);
|
||||
result = RegOpenKeyExA(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
platformsName,
|
||||
0,
|
||||
KEY_READ,
|
||||
&platformsKey);
|
||||
if (ERROR_SUCCESS != result)
|
||||
{
|
||||
KHR_ICD_TRACE("Failed to open platforms key %s, continuing\n", platformsName);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// for each value
|
||||
for (dwIndex = 0;; ++dwIndex)
|
||||
{
|
||||
char cszLibraryName[1024] = {0};
|
||||
DWORD dwLibraryNameSize = sizeof(cszLibraryName);
|
||||
DWORD dwLibraryNameType = 0;
|
||||
DWORD dwValue = 0;
|
||||
DWORD dwValueSize = sizeof(dwValue);
|
||||
|
||||
// read the value name
|
||||
KHR_ICD_TRACE("Reading value %d...\n", dwIndex);
|
||||
result = RegEnumValueA(
|
||||
platformsKey,
|
||||
dwIndex,
|
||||
cszLibraryName,
|
||||
&dwLibraryNameSize,
|
||||
NULL,
|
||||
&dwLibraryNameType,
|
||||
(LPBYTE)&dwValue,
|
||||
&dwValueSize);
|
||||
// if RegEnumKeyEx fails, we are done with the enumeration
|
||||
if (ERROR_SUCCESS != result)
|
||||
{
|
||||
KHR_ICD_TRACE("Failed to read value %d, done reading key.\n", dwIndex);
|
||||
break;
|
||||
}
|
||||
KHR_ICD_TRACE("Value %s found...\n", cszLibraryName);
|
||||
|
||||
// Require that the value be a DWORD and equal zero
|
||||
if (REG_DWORD != dwLibraryNameType)
|
||||
{
|
||||
KHR_ICD_TRACE("Value not a DWORD, skipping\n");
|
||||
continue;
|
||||
}
|
||||
if (dwValue)
|
||||
{
|
||||
KHR_ICD_TRACE("Value not zero, skipping\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
// add the library
|
||||
khrIcdVendorAdd(cszLibraryName);
|
||||
}
|
||||
|
||||
result = RegCloseKey(platformsKey);
|
||||
if (ERROR_SUCCESS != result)
|
||||
{
|
||||
KHR_ICD_TRACE("Failed to close platforms key %s, ignoring\n", platformsName);
|
||||
}
|
||||
|
||||
KHRicdVendor *vendorIterator;
|
||||
for (vendorIterator = khrIcdVendors; vendorIterator; vendorIterator = vendorIterator->next)
|
||||
{
|
||||
if (vendorIterator->libName != NULL)
|
||||
{
|
||||
free(vendorIterator->libName);
|
||||
vendorIterator->libName = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// go through the list of vendors only once
|
||||
void khrIcdOsVendorsEnumerateOnce()
|
||||
{
|
||||
InitOnceExecuteOnce(&initialized, khrIcdOsVendorsEnumerate, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Dynamic library loading functions
|
||||
*
|
||||
*/
|
||||
|
||||
// dynamically load a library. returns NULL on failure
|
||||
void *khrIcdOsLibraryLoad(const char *libraryName)
|
||||
{
|
||||
return (void *)LoadLibraryA(libraryName);
|
||||
}
|
||||
|
||||
// get a function pointer from a loaded library. returns NULL on failure.
|
||||
void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName)
|
||||
{
|
||||
if (!library || !functionName)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return GetProcAddress( (HMODULE)library, functionName);
|
||||
}
|
||||
|
||||
// unload a library.
|
||||
void khrIcdOsLibraryUnload(void *library)
|
||||
{
|
||||
FreeLibrary( (HMODULE)library);
|
||||
}
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software source and associated documentation files (the "Materials"),
|
||||
* to deal in the Materials without restriction, including without limitation
|
||||
* the rights to use, copy, modify, compile, merge, publish, distribute,
|
||||
* sublicense, and/or sell copies of the Materials, and to permit persons to
|
||||
* whom the Materials are furnished to do so, subject the following terms and
|
||||
* conditions:
|
||||
*
|
||||
* All modifications to the Materials used to create a binary that is
|
||||
* distributed to third parties shall be provided to Khronos with an
|
||||
* unrestricted license to use for the purposes of implementing bug fixes and
|
||||
* enhancements to the Materials;
|
||||
*
|
||||
* If the binary is used as part of an OpenCL(TM) implementation, whether binary
|
||||
* is distributed together with or separately to that implementation, then
|
||||
* recipient must become an OpenCL Adopter and follow the published OpenCL
|
||||
* conformance process for that implementation, details at:
|
||||
* http://www.khronos.org/conformance/;
|
||||
*
|
||||
* The above copyright notice, the OpenCL trademark license, and this permission
|
||||
* notice shall be included in all copies or substantial portions of the
|
||||
* Materials.
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN
|
||||
* THE MATERIALS.
|
||||
*
|
||||
* OpenCL is a trademark of Apple Inc. used under license by Khronos.
|
||||
*/
|
||||
|
||||
#include "icd.h"
|
||||
#include <windows.h>
|
||||
#include "icd_windows_dxgk.h"
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef NTSTATUS
|
||||
typedef LONG NTSTATUS;
|
||||
#define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
|
||||
#define STATUS_BUFFER_TOO_SMALL ((NTSTATUS)0xC0000023)
|
||||
#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
|
||||
#endif
|
||||
|
||||
#include "d3dkmthk.h"
|
||||
|
||||
bool khrIcdOsVendorsEnumerateDXGK(void)
|
||||
{
|
||||
#if defined(DXGKDDI_INTERFACE_VERSION_WDDM2_4) && (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WDDM2_4)
|
||||
{
|
||||
D3DKMT_ADAPTERINFO* pAdapterInfo;
|
||||
D3DKMT_ENUMADAPTERS2 EnumAdapters;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
// Get handle to GDI Runtime
|
||||
HMODULE h = LoadLibrary("gdi32.dll");
|
||||
|
||||
char cszLibraryName[1024] = { 0 };
|
||||
EnumAdapters.NumAdapters = 0;
|
||||
EnumAdapters.pAdapters = NULL;
|
||||
PFND3DKMT_ENUMADAPTERS2 pEnumAdapters2 = (PFND3DKMT_ENUMADAPTERS2)GetProcAddress((HMODULE)h, "D3DKMTEnumAdapters2");
|
||||
if (!pEnumAdapters2)
|
||||
{
|
||||
FreeLibrary(h);
|
||||
return FALSE;
|
||||
}
|
||||
Status = pEnumAdapters2(&EnumAdapters);
|
||||
if (!NT_SUCCESS(Status) && (Status != STATUS_BUFFER_TOO_SMALL))
|
||||
{
|
||||
FreeLibrary(h);
|
||||
return FALSE;
|
||||
}
|
||||
pAdapterInfo = (D3DKMT_ADAPTERINFO*)malloc(sizeof(D3DKMT_ADAPTERINFO)*(EnumAdapters.NumAdapters));
|
||||
EnumAdapters.pAdapters = pAdapterInfo;
|
||||
Status = pEnumAdapters2(&EnumAdapters);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
FreeLibrary(h);
|
||||
if (pAdapterInfo) free(pAdapterInfo);
|
||||
return FALSE;
|
||||
}
|
||||
for (UINT AdapterIndex = 0; AdapterIndex < EnumAdapters.NumAdapters; AdapterIndex++)
|
||||
{
|
||||
D3DDDI_QUERYREGISTRY_INFO QueryArgs = {0};
|
||||
D3DDDI_QUERYREGISTRY_INFO* pQueryArgs = &QueryArgs;
|
||||
D3DDDI_QUERYREGISTRY_INFO* pQueryBuffer = NULL;
|
||||
QueryArgs.QueryType = D3DDDI_QUERYREGISTRY_ADAPTERKEY;
|
||||
QueryArgs.QueryFlags.TranslatePath = TRUE;
|
||||
QueryArgs.ValueType = REG_SZ;
|
||||
#ifdef _WIN64
|
||||
wcscpy_s(QueryArgs.ValueName, ARRAYSIZE(L"OpenCLDriverName"), L"OpenCLDriverName");
|
||||
#else
|
||||
wcscpy_s(QueryArgs.ValueName, ARRAYSIZE(L"OpenCLDriverNameWow"), L"OpenCLDriverNameWow");
|
||||
#endif
|
||||
D3DKMT_QUERYADAPTERINFO QueryAdapterInfo = {0};
|
||||
QueryAdapterInfo.hAdapter = pAdapterInfo[AdapterIndex].hAdapter;
|
||||
QueryAdapterInfo.Type = KMTQAITYPE_QUERYREGISTRY;
|
||||
QueryAdapterInfo.pPrivateDriverData = &QueryArgs;
|
||||
QueryAdapterInfo.PrivateDriverDataSize = sizeof(QueryArgs);
|
||||
Status = D3DKMTQueryAdapterInfo(&QueryAdapterInfo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
FreeLibrary(h);
|
||||
if (pAdapterInfo) free(pAdapterInfo);
|
||||
return FALSE;
|
||||
}
|
||||
if (NT_SUCCESS(Status) && pQueryArgs->Status == D3DDDI_QUERYREGISTRY_STATUS_BUFFER_OVERFLOW)
|
||||
{
|
||||
unsigned int QueryBufferSize = sizeof(D3DDDI_QUERYREGISTRY_INFO) + QueryArgs.OutputValueSize;
|
||||
pQueryBuffer = (D3DDDI_QUERYREGISTRY_INFO*)malloc(QueryBufferSize);
|
||||
memcpy(pQueryBuffer, &QueryArgs, sizeof(D3DDDI_QUERYREGISTRY_INFO));
|
||||
QueryAdapterInfo.pPrivateDriverData = pQueryBuffer;
|
||||
QueryAdapterInfo.PrivateDriverDataSize = QueryBufferSize;
|
||||
Status = D3DKMTQueryAdapterInfo(&QueryAdapterInfo);
|
||||
pQueryArgs = pQueryBuffer;
|
||||
}
|
||||
if (NT_SUCCESS(Status) && pQueryArgs->Status == D3DDDI_QUERYREGISTRY_STATUS_SUCCESS)
|
||||
{
|
||||
wchar_t* pWchar = pQueryArgs->OutputString;
|
||||
unsigned int i = 0;
|
||||
memset(cszLibraryName, 0, sizeof(cszLibraryName));
|
||||
{
|
||||
while ((*pWchar != L'\0') && (i<1023))
|
||||
{
|
||||
cszLibraryName[i] = (char)*pWchar;
|
||||
i++;
|
||||
pWchar++;
|
||||
}
|
||||
if (i < 1023) khrIcdVendorAdd(cszLibraryName);
|
||||
}
|
||||
}
|
||||
if (pQueryBuffer) free(pQueryBuffer);
|
||||
}
|
||||
if (pAdapterInfo) free(pAdapterInfo);
|
||||
FreeLibrary(h);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software source and associated documentation files (the "Materials"),
|
||||
* to deal in the Materials without restriction, including without limitation
|
||||
* the rights to use, copy, modify, compile, merge, publish, distribute,
|
||||
* sublicense, and/or sell copies of the Materials, and to permit persons to
|
||||
* whom the Materials are furnished to do so, subject the following terms and
|
||||
* conditions:
|
||||
*
|
||||
* All modifications to the Materials used to create a binary that is
|
||||
* distributed to third parties shall be provided to Khronos with an
|
||||
* unrestricted license to use for the purposes of implementing bug fixes and
|
||||
* enhancements to the Materials;
|
||||
*
|
||||
* If the binary is used as part of an OpenCL(TM) implementation, whether binary
|
||||
* is distributed together with or separately to that implementation, then
|
||||
* recipient must become an OpenCL Adopter and follow the published OpenCL
|
||||
* conformance process for that implementation, details at:
|
||||
* http://www.khronos.org/conformance/;
|
||||
*
|
||||
* The above copyright notice, the OpenCL trademark license, and this permission
|
||||
* notice shall be included in all copies or substantial portions of the
|
||||
* Materials.
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN
|
||||
* THE MATERIALS.
|
||||
*
|
||||
* OpenCL is a trademark of Apple Inc. used under license by Khronos.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool khrIcdOsVendorsEnumerateDXGK(void);
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software source and associated documentation files (the "Materials"),
|
||||
* to deal in the Materials without restriction, including without limitation
|
||||
* the rights to use, copy, modify, compile, merge, publish, distribute,
|
||||
* sublicense, and/or sell copies of the Materials, and to permit persons to
|
||||
* whom the Materials are furnished to do so, subject the following terms and
|
||||
* conditions:
|
||||
*
|
||||
* All modifications to the Materials used to create a binary that is
|
||||
* distributed to third parties shall be provided to Khronos with an
|
||||
* unrestricted license to use for the purposes of implementing bug fixes and
|
||||
* enhancements to the Materials;
|
||||
*
|
||||
* If the binary is used as part of an OpenCL(TM) implementation, whether binary
|
||||
* is distributed together with or separately to that implementation, then
|
||||
* recipient must become an OpenCL Adopter and follow the published OpenCL
|
||||
* conformance process for that implementation, details at:
|
||||
* http://www.khronos.org/conformance/;
|
||||
*
|
||||
* The above copyright notice, the OpenCL trademark license, and this permission
|
||||
* notice shall be included in all copies or substantial portions of the
|
||||
* Materials.
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN
|
||||
* THE MATERIALS.
|
||||
*
|
||||
* OpenCL is a trademark of Apple Inc. used under license by Khronos.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool khrIcdOsVendorsEnumerateHKR(void);
|
||||
поставляемый
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Ссылка в новой задаче
Block a user