Merge branch 'origin/pghafari/vdi-prototype' into lmoriche/amd-master
Change-Id: Id3b833d405596735becb3346f3b08c6da57033fe
[ROCm/clr commit: 20c7173849]
Esse commit está contido em:
1 pai
ecb6dc185d
commit
011f3e945b
356 files changed
+3337
-14228
No files matched your search
@@ -1,170 +1,199 @@
|
||||
cmake_minimum_required(VERSION 3.4.3)
|
||||
project(vdi)
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
#example command:
|
||||
#cmake -DUSE_COMGR_LIBRARY=yes -DOPENCL_DIR=/home/pghafari/git-ocl -DCMAKE_PREFIX_PATH="/home/pghafari/rocmgitvdi/support/lib/comgr;/home/pghafari/rocmgitvdi/support/lib/comgr/build;home/pghafari/rocmgitvdi/hsa-runtime/opensrc/hsa-runtime/build;/home/pghafari/rocmgitvdi/hsa-runtime/opensrc" -DLLVM_INCLUDES=/home/pghafari/rocmgit/llvm-project/llvm/include ..
|
||||
|
||||
if (POLICY CMP0048)
|
||||
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")
|
||||
|
||||
# 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()
|
||||
|
||||
# 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()
|
||||
|
||||
project(rocm-opencl)
|
||||
#cmake -DLLVM_INCLUDES=/home/ixt-rack-79/payam/include -DOPENCL_DIR=/home/ixt-rack-79/payam/ocl4/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 "")
|
||||
set(USE_COMGR_LIBRARY "yes")
|
||||
add_definitions(-DUSE_COMGR_LIBRARY -DCOMGR_DYN_DLL)
|
||||
add_definitions(-DBSD_LIBELF)
|
||||
|
||||
find_package(amd_comgr REQUIRED CONFIG
|
||||
PATHS
|
||||
/opt/rocm/
|
||||
PATH_SUFFIXES
|
||||
cmake/amd_comgr
|
||||
lib/cmake/amd_comgr
|
||||
)
|
||||
MESSAGE(STATUS "Code Object Manager found at ${amd_comgr_DIR}.")
|
||||
|
||||
find_path(COMGR_INCLUDE
|
||||
NAMES amd_comgr.h
|
||||
PATH_SUFFIXES include
|
||||
PATHS /opt/rocm
|
||||
)
|
||||
|
||||
find_library( OpenCL REQUIRED CONFIG
|
||||
PATHS
|
||||
/opt/rocm
|
||||
)
|
||||
|
||||
find_path(OPENCL_INCLUDE_DIR
|
||||
NAMES OpenCL/cl.h CL/cl.h
|
||||
PATH_SUFFIXES include opencl/include inc include/x86_64 include/x64
|
||||
PATHS /opt/rocm
|
||||
DOC "OpenCL include header OpenCL/cl.h or CL/cl.h"
|
||||
)
|
||||
|
||||
MESSAGE(STATUS "Opencl fund at ${OPENCL_INCLUDE_DIR}.")
|
||||
set(OPENCL_ICD_LOADER_HEADERS_DIR "${OPENCL_INCLUDE_DIR}")
|
||||
|
||||
#/khronos/headers/opencl2.2" CACHE PATH "")
|
||||
find_package(ROCT REQUIRED)
|
||||
find_package(ROCR REQUIRED)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads 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 "")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
|
||||
|
||||
# override default option value in library and driver
|
||||
set(GENERIC_IS_ZERO ON CACHE BOOL ON FORCE)
|
||||
add_definitions(-DLINUX -D__x86_64__ -D__AMD64__ -DUNIX_OS -DqLittleEndian -DOPENCL_MAJOR=2 -DOPENCL_MINOR=1 -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)
|
||||
add_definitions(-DOPENCL_C_MAJOR=2 -DOPENCL_C_MINOR=0)
|
||||
|
||||
add_subdirectory(compiler/llvm EXCLUDE_FROM_ALL)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic -Wl,--unresolved-symbols=report-all")
|
||||
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
|
||||
|
||||
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()
|
||||
if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
|
||||
add_definitions(-DDEBUG)
|
||||
endif()
|
||||
|
||||
add_subdirectory(api/opencl/amdocl)
|
||||
add_subdirectory(compiler/lib/loaders/elf/utils/libelf)
|
||||
add_subdirectory(runtime)
|
||||
add_subdirectory(tools/clinfo)
|
||||
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 "")
|
||||
|
||||
set(BUILD_SHARED_LIBS "Build shared libs" ON)
|
||||
add_subdirectory(api/opencl/khronos/icd)
|
||||
include_directories(${CMAKE_SOURCE_DIR})
|
||||
include_directories(${CMAKE_SOURCE_DIR}/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/device/rocm)
|
||||
include_directories(${OPENCL_DIR})
|
||||
include_directories(${OPENCL_DIR}/amdocl)
|
||||
include_directories(${OPENCL_DIR}/khronos)
|
||||
include_directories(${OPENCL_DIR}/khronos/headers)
|
||||
include_directories(${OPENCL_DIR}/khronos/headers/opencl2.2)
|
||||
include_directories(${OPENCL_INCLUDE_DIR})
|
||||
include_directories(${COMGR_INCLUDE})
|
||||
#message (${OPENCL_DIR}/opencl/khronos/headers/opencl2.2)
|
||||
|
||||
###--- Packaging ------------------------------------------------------------###
|
||||
|
||||
find_package(ROCM QUIET CONFIG PATHS /opt/rocm)
|
||||
include(ROCMSetupVersion)
|
||||
rocm_setup_version( VERSION "2.0.0" )
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/lib)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/backends/common)
|
||||
|
||||
# MAIN package
|
||||
install(PROGRAMS $<TARGET_FILE:clinfo>
|
||||
DESTINATION bin/x86_64
|
||||
COMPONENT MAIN)
|
||||
install(PROGRAMS $<TARGET_FILE:amdocl64>
|
||||
DESTINATION lib/x86_64
|
||||
COMPONENT MAIN)
|
||||
install(PROGRAMS $<TARGET_FILE:OpenCL>
|
||||
DESTINATION lib/x86_64
|
||||
COMPONENT MAIN)
|
||||
install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
|
||||
DESTINATION lib/x86_64
|
||||
COMPONENT MAIN)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/elf/utils/common)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/elf/utils/libelf)
|
||||
|
||||
# DEV package
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
|
||||
DESTINATION include
|
||||
COMPONENT DEV
|
||||
USE_SOURCE_PERMISSIONS
|
||||
PATTERN cl_d3d10.h EXCLUDE
|
||||
PATTERN cl_d3d11.h EXCLUDE
|
||||
PATTERN cl_dx9_media_sharing.h EXCLUDE
|
||||
PATTERN cl_egl.h EXCLUDE)
|
||||
install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
|
||||
DESTINATION lib/x86_64
|
||||
COMPONENT DEV)
|
||||
add_subdirectory(device/rocm)
|
||||
|
||||
# Generic CPACK variables
|
||||
set(CPACK_GENERATOR "DEB;RPM" CACHE STRING "Default packaging generators")
|
||||
|
||||
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})
|
||||
|
||||
# Debian CPACK variables
|
||||
set(CPACK_DEB_COMPONENT_INSTALL ON)
|
||||
#find_package(amd_comgr REQUIRED CONFIG)
|
||||
include_directories("$<TARGET_PROPERTY:amd_comgr,INTERFACE_INCLUDE_DIRECTORIES>")
|
||||
set(COMGR_CPP device/comgrctx.cpp)
|
||||
|
||||
set(CPACK_DEBIAN_MAIN_FILE_NAME "rocm-opencl-${PROJECT_VERSION}-Linux.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")
|
||||
add_subdirectory( elf/utils/libelf "${CMAKE_CURRENT_BINARY_DIR}/libelf" )
|
||||
add_library(oclruntime OBJECT
|
||||
thread/thread.cpp
|
||||
thread/monitor.cpp
|
||||
thread/semaphore.cpp
|
||||
utils/flags.cpp
|
||||
utils/debug.cpp
|
||||
device/appprofile.cpp
|
||||
device/device.cpp
|
||||
device/hwdebug.cpp
|
||||
device/blitcl.cpp
|
||||
device/blit.cpp
|
||||
device/devkernel.cpp
|
||||
device/devwavelimiter.cpp
|
||||
device/devprogram.cpp
|
||||
platform/activity.cpp
|
||||
platform/kernel.cpp
|
||||
platform/context.cpp
|
||||
platform/command.cpp
|
||||
platform/ndrange.cpp
|
||||
platform/runtime.cpp
|
||||
platform/object.cpp
|
||||
platform/memory.cpp
|
||||
platform/program.cpp
|
||||
platform/commandqueue.cpp
|
||||
platform/agent.cpp
|
||||
os/os_win32.cpp
|
||||
os/alloc.cpp
|
||||
os/os.cpp
|
||||
os/os_posix.cpp
|
||||
compiler/lib/utils/options.cpp
|
||||
elf/elf.cpp
|
||||
elf/elf_utils.cpp
|
||||
#${CMAKE_SOURCE_DIR}/compiler/tools/caching/cache.cpp
|
||||
${COMGR_CPP}
|
||||
)
|
||||
|
||||
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_target_properties(oclruntime PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
# RPM CPACK variables
|
||||
set(CPACK_RPM_COMPONENT_INSTALL ON)
|
||||
add_library(amdvdi_static STATIC
|
||||
$<TARGET_OBJECTS:oclruntime>
|
||||
$<TARGET_OBJECTS:oclrocm>
|
||||
$<TARGET_OBJECTS:oclelf_obj>
|
||||
)
|
||||
set_target_properties(amdvdi_static PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
#add_library(oclelf STATIC IMPORTED)
|
||||
#set_target_properties(oclelf PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/libelf/liboclelf.a")
|
||||
#target_link_libraries(oclruntime_static PRIVATE oclelf)
|
||||
target_link_libraries(amdvdi_static PUBLIC Threads::Threads)
|
||||
target_link_libraries(amdvdi_static PUBLIC dl ${ROCT_LIBRARIES} ${ROCR_LIBRARIES} )
|
||||
|
||||
set(CPACK_RPM_MAIN_FILE_NAME "rocm-opencl-${PROJECT_VERSION}-Linux.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")
|
||||
if (UNIX)
|
||||
set(VDI_DEFAULT_INSTALL_PREFIX "/opt/rocm/vdi")
|
||||
endif()
|
||||
#comment out as it's not available in cmake 3.5
|
||||
#if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
if(NOT CMAKE_INSTALL_PREFIX)
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "Installation path for vdi" FORCE)
|
||||
#elseif(CMAKE_BUILD_TYPE MATCHES Release)
|
||||
else()
|
||||
set(CMAKE_INSTALL_PREFIX ${VDI_DEFAULT_INSTALL_PREFIX} CACHE PATH "Installation path for vdi" FORCE)
|
||||
# message(FATAL_ERROR "Invalid CMAKE_BUILD_TYPE specified. Valid values are Debug and Release")
|
||||
endif()
|
||||
#endif()
|
||||
endif()
|
||||
message("cmake install path ${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
set(CPACK_RPM_DEV_FILE_NAME "rocm-opencl-devel-${PROJECT_VERSION}-Linux.rpm")
|
||||
set(CPACK_RPM_DEV_PACKAGE_NAME "rocm-opencl-devel")
|
||||
set(CPACK_RPM_DEV_PACKAGE_DEPENDS "rocm-opencl")
|
||||
install( TARGETS amdvdi_static ARCHIVE DESTINATION lib LIBRARY DESTINATION lib COMPONENT applications)
|
||||
FILE(GLOB headerfiles "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")
|
||||
INSTALL (
|
||||
FILES ${headerfiles}
|
||||
DESTINATION include)
|
||||
INSTALL (
|
||||
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/compiler"
|
||||
DESTINATION include
|
||||
FILES_MATCHING PATTERN "*.h*")
|
||||
INSTALL (
|
||||
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/utils"
|
||||
DESTINATION include
|
||||
FILES_MATCHING PATTERN "*.h*")
|
||||
INSTALL (
|
||||
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/platform"
|
||||
DESTINATION include
|
||||
FILES_MATCHING PATTERN "*.h*")
|
||||
INSTALL (
|
||||
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/thread"
|
||||
DESTINATION include
|
||||
FILES_MATCHING PATTERN "*.h*")
|
||||
INSTALL (
|
||||
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/os"
|
||||
DESTINATION include
|
||||
FILES_MATCHING PATTERN "*.h*")
|
||||
INSTALL (
|
||||
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/device"
|
||||
DESTINATION include
|
||||
FILES_MATCHING PATTERN "*.h*")
|
||||
#set(AMDGCN_DEP_LIST)
|
||||
#if(AMDGCN_TARGETS_LIB_DEPS)
|
||||
#set(${AMDGCN_TARGETS_LIB_DEPS} ${AMDGCN_DEP_LIST} PARENT_SCOPE)
|
||||
#endif()
|
||||
|
||||
set(CPACK_COMPONENTS_ALL MAIN DEV)
|
||||
include(CPack)
|
||||
#foreach(AMDGCN_DEP_TARGET ${AMDGCN_DEP_TARGETS})
|
||||
#add_dependencies(oclruntime ${AMDGCN_DEP_TARGET})
|
||||
#endforeach()
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,52 +0,0 @@
|
||||
EXPORTS
|
||||
aclLoader_OnLoad
|
||||
aclLoader_OnUnload
|
||||
aclCompilerInit
|
||||
aclCompilerFini
|
||||
aclCompilerVersion
|
||||
aclVersionSize
|
||||
aclGetErrorString
|
||||
aclGetArchInfo
|
||||
aclGetDeviceInfo
|
||||
aclGetTargetInfo
|
||||
aclGetArchitecture
|
||||
aclGetFamily
|
||||
aclGetChip
|
||||
aclBinaryInit
|
||||
aclBinaryFini
|
||||
aclReadFromFile
|
||||
aclReadFromMem
|
||||
aclWriteToFile
|
||||
aclWriteToMem
|
||||
aclCreateFromBinary
|
||||
aclBinaryVersion
|
||||
aclInsertSection
|
||||
aclRemoveSection
|
||||
aclExtractSection
|
||||
aclInsertSymbol
|
||||
aclRemoveSymbol
|
||||
aclExtractSymbol
|
||||
aclDbgAddArgument
|
||||
aclDbgRemoveArgument
|
||||
aclQueryInfo
|
||||
aclCompile
|
||||
aclLink
|
||||
aclGetCompilerLog
|
||||
aclRetrieveType
|
||||
aclSetType
|
||||
aclConvertType
|
||||
aclDisassemble
|
||||
aclGetDeviceBinary
|
||||
aclInsertKernelStatistics
|
||||
aclDumpBinary
|
||||
aclJITObjectImageCreate
|
||||
aclJITObjectImageCopy
|
||||
aclJITObjectImageDestroy
|
||||
aclJITObjectImageFinalize
|
||||
aclJITObjectImageSize
|
||||
aclJITObjectImageData
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
aclJITObjectImageDisassembleKernel
|
||||
#endif
|
||||
aclJITObjectImageIterateSymbols
|
||||
aclJITObjectImageGetGlobalsSize
|
||||
@@ -1,58 +0,0 @@
|
||||
ACL_API_0.8 {
|
||||
global:
|
||||
aclCompilerInit;
|
||||
aclCompilerFini;
|
||||
aclCompilerVersion;
|
||||
aclVersionSize;
|
||||
aclGetErrorString;
|
||||
aclGetArchInfo;
|
||||
aclGetFamilyInfo;
|
||||
aclGetDeviceInfo;
|
||||
aclGetAsicInfo;
|
||||
aclGetTargetInfo;
|
||||
aclGetArchitecture;
|
||||
aclGetFamily;
|
||||
aclGetChip;
|
||||
aclGetAsic;
|
||||
aclBinaryInit;
|
||||
aclBinaryFini;
|
||||
aclReadFromFile;
|
||||
aclReadFromMem;
|
||||
aclWriteToFile;
|
||||
aclWriteToMem;
|
||||
aclCreateFromBinary;
|
||||
aclBinaryVersion;
|
||||
aclInsertSection;
|
||||
aclRemoveSection;
|
||||
aclExtractSection;
|
||||
aclInsertSymbol;
|
||||
aclRemoveSymbol;
|
||||
aclExtractSymbol;
|
||||
aclQueryInfo;
|
||||
aclDbgAddArgument;
|
||||
aclDbgRemoveArgument;
|
||||
aclCompile;
|
||||
aclLink;
|
||||
aclGetCompilerLog;
|
||||
aclRetrieveType;
|
||||
aclSetType;
|
||||
aclConvertType;
|
||||
aclDisassemble;
|
||||
aclInsertKernelStatistics;
|
||||
aclGetDeviceBinary;
|
||||
aclLoader_OnLoad;
|
||||
aclLoader_OnUnload;
|
||||
aclJITObjectImageCreate;
|
||||
aclJITObjectImageCopy;
|
||||
aclJITObjectImageDestroy;
|
||||
aclJITObjectImageFinalize;
|
||||
aclJITObjectImageSize;
|
||||
aclJITObjectImageData;
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
aclJITObjectImageDisassembleKernel;
|
||||
#endif
|
||||
aclJITObjectImageIterateSymbols;
|
||||
aclJITObjectImageGetGlobalsSize;
|
||||
local:
|
||||
*;
|
||||
};
|
||||
@@ -1,75 +0,0 @@
|
||||
#define STR(__macro__) #__macro__
|
||||
#define XSTR(__macro__) STR(__macro__)
|
||||
|
||||
#if defined(_DEBUG)
|
||||
#define DEBUG_ONLY(x) x
|
||||
#else
|
||||
#define DEBUG_ONLY(x)
|
||||
#endif
|
||||
|
||||
#define VERSION_PREFIX_MAJOR 1
|
||||
#define VERSION_PREFIX_MINOR 1
|
||||
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winresrc.h"
|
||||
#include "utils/versions.hpp"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION AMD_COMPILER_MAJOR_VERSION,AMD_COMPILER_MINOR_VERSION,AMD_COMPILER_BUILD_NUMBER,AMD_COMPILER_REVISION_NUMBER
|
||||
PRODUCTVERSION AMD_COMPILER_MAJOR_VERSION,AMD_COMPILER_MINOR_VERSION,AMD_COMPILER_BUILD_NUMBER,AMD_COMPILER_REVISION_NUMBER
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", " \0"
|
||||
VALUE "CompanyName", "Advanced Micro Devices Inc.\0"
|
||||
VALUE "FileDescription", AMD_COMPILER_NAME " OpenCL " XSTR(VERSION_PREFIX_MAJOR) "." XSTR(VERSION_PREFIX_MINOR) " Compiler\0"
|
||||
VALUE "FileVersion", XSTR(AMD_COMPILER_MAJOR_VERSION) ", " XSTR(AMD_COMPILER_MINOR_VERSION) ", " XSTR(AMD_COMPILER_BUILD_NUMBER) ", " XSTR(AMD_COMPILER_REVISION_NUMBER) ", " XSTR(AMD_SC_COMPILER_REVISION_NUMBER)
|
||||
VALUE "InternalName", "AOC"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2011 Advanced Micro Devices Inc.\0"
|
||||
VALUE "OriginalFilename", "amdoclcl.dll"
|
||||
VALUE "ProductName", "AMD Compiler Library " XSTR(VERSION_PREFIX_MAJOR) "." XSTR(VERSION_PREFIX_MINOR) " " AMD_COMPILER_INFO "\0"
|
||||
VALUE "ProductVersion", XSTR(AMD_COMPILER_MAJOR_VERSION) ", " XSTR(AMD_COMPILER_MINOR_VERSION) ", " XSTR(AMD_COMPILER_BUILD_NUMBER) ", " XSTR(AMD_COMPILER_REVISION_NUMBER) ", " XSTR(AMD_SC_COMPILER_REVISION_NUMBER)
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1,345 +0,0 @@
|
||||
//===- Disassembler.cpp - Disassembler for hex strings --------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This class implements the disassembler of strings of bytes written in
|
||||
// hexadecimal, from standard input or from a file.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
#include "Disassembler.h"
|
||||
#include "lib/MC/MCDisassembler/EDDisassembler.h"
|
||||
#include "lib/MC/MCDisassembler/EDInst.h"
|
||||
#include "lib/MC/MCDisassembler/EDOperand.h"
|
||||
#include "lib/MC/MCDisassembler/EDToken.h"
|
||||
#include "llvm/MC/MCDisassembler.h"
|
||||
#include "llvm/MC/MCInst.h"
|
||||
#include "llvm/MC/MCStreamer.h"
|
||||
#include "llvm/MC/MCSubtargetInfo.h"
|
||||
#include "llvm/ADT/OwningPtr.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Support/MemoryObject.h"
|
||||
#include "llvm/Support/SourceMgr.h"
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
typedef std::vector<std::pair<unsigned char, const char*> > ByteArrayTy;
|
||||
|
||||
namespace {
|
||||
class VectorMemoryObject : public MemoryObject {
|
||||
private:
|
||||
const ByteArrayTy &Bytes;
|
||||
public:
|
||||
VectorMemoryObject(const ByteArrayTy &bytes) : Bytes(bytes) {}
|
||||
|
||||
uint64_t getBase() const { return 0; }
|
||||
uint64_t getExtent() const { return Bytes.size(); }
|
||||
|
||||
int readByte(uint64_t Addr, uint8_t *Byte) const {
|
||||
if (Addr >= getExtent())
|
||||
return -1;
|
||||
*Byte = Bytes[Addr].first;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static bool PrintInsts(const MCDisassembler &DisAsm,
|
||||
const ByteArrayTy &Bytes,
|
||||
SourceMgr &SM, raw_ostream &Out,
|
||||
MCStreamer &Streamer) {
|
||||
// Wrap the vector in a MemoryObject.
|
||||
VectorMemoryObject memoryObject(Bytes);
|
||||
|
||||
// Disassemble it to strings.
|
||||
uint64_t Size;
|
||||
uint64_t Index;
|
||||
|
||||
for (Index = 0; Index < Bytes.size(); Index += Size) {
|
||||
MCInst Inst;
|
||||
|
||||
MCDisassembler::DecodeStatus S;
|
||||
S = DisAsm.getInstruction(Inst, Size, memoryObject, Index,
|
||||
/*REMOVE*/ nulls(), nulls());
|
||||
switch (S) {
|
||||
case MCDisassembler::Fail:
|
||||
SM.PrintMessage(SMLoc::getFromPointer(Bytes[Index].second),
|
||||
SourceMgr::DK_Warning,
|
||||
"invalid instruction encoding");
|
||||
if (Size == 0)
|
||||
Size = 1; // skip illegible bytes
|
||||
break;
|
||||
|
||||
case MCDisassembler::SoftFail:
|
||||
SM.PrintMessage(SMLoc::getFromPointer(Bytes[Index].second),
|
||||
SourceMgr::DK_Warning,
|
||||
"potentially undefined instruction encoding");
|
||||
// Fall through
|
||||
|
||||
case MCDisassembler::Success:
|
||||
Streamer.EmitInstruction(Inst);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ByteArrayFromString(ByteArrayTy &ByteArray,
|
||||
StringRef &Str,
|
||||
SourceMgr &SM) {
|
||||
while (!Str.empty()) {
|
||||
// Strip horizontal whitespace.
|
||||
if (size_t Pos = Str.find_first_not_of(" \t\r")) {
|
||||
Str = Str.substr(Pos);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If this is the end of a line or start of a comment, remove the rest of
|
||||
// the line.
|
||||
if (Str[0] == '\n' || Str[0] == '#') {
|
||||
// Strip to the end of line if we already processed any bytes on this
|
||||
// line. This strips the comment and/or the \n.
|
||||
if (Str[0] == '\n') {
|
||||
Str = Str.substr(1);
|
||||
} else {
|
||||
Str = Str.substr(Str.find_first_of('\n'));
|
||||
if (!Str.empty())
|
||||
Str = Str.substr(1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the current token.
|
||||
size_t Next = Str.find_first_of(" \t\n\r#");
|
||||
StringRef Value = Str.substr(0, Next);
|
||||
|
||||
// Convert to a byte and add to the byte vector.
|
||||
unsigned ByteVal = 0;
|
||||
if (Value.getAsInteger(0, ByteVal) || ByteVal > 255) {
|
||||
// If we have an error, print it and skip to the end of line.
|
||||
SM.PrintMessage(SMLoc::getFromPointer(Value.data()), SourceMgr::DK_Error,
|
||||
"invalid input token");
|
||||
Str = Str.substr(Str.find('\n'));
|
||||
ByteArray.clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
ByteArray.push_back(std::make_pair((unsigned char)ByteVal, Value.data()));
|
||||
Str = Str.substr(Next);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int Disassembler::disassemble(const Target &T,
|
||||
const std::string &Triple,
|
||||
MCSubtargetInfo &STI,
|
||||
MCStreamer &Streamer,
|
||||
MemoryBuffer &Buffer,
|
||||
SourceMgr &SM,
|
||||
raw_ostream &Out) {
|
||||
OwningPtr<const MCDisassembler> DisAsm(T.createMCDisassembler(STI));
|
||||
if (!DisAsm) {
|
||||
errs() << "error: no disassembler for target " << Triple << "\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set up initial section manually here
|
||||
Streamer.InitSections();
|
||||
|
||||
bool ErrorOccurred = false;
|
||||
|
||||
// Convert the input to a vector for disassembly.
|
||||
ByteArrayTy ByteArray;
|
||||
StringRef Str = Buffer.getBuffer();
|
||||
|
||||
ErrorOccurred |= ByteArrayFromString(ByteArray, Str, SM);
|
||||
|
||||
if (!ByteArray.empty())
|
||||
ErrorOccurred |= PrintInsts(*DisAsm, ByteArray, SM, Out, Streamer);
|
||||
|
||||
return ErrorOccurred;
|
||||
}
|
||||
|
||||
static int byteArrayReader(uint8_t *B, uint64_t A, void *Arg) {
|
||||
ByteArrayTy &ByteArray = *((ByteArrayTy*)Arg);
|
||||
|
||||
if (A >= ByteArray.size())
|
||||
return -1;
|
||||
|
||||
*B = ByteArray[A].first;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int verboseEvaluator(uint64_t *V, unsigned R, void *Arg) {
|
||||
EDDisassembler &disassembler = *(EDDisassembler *)((void **)Arg)[0];
|
||||
raw_ostream &Out = *(raw_ostream *)((void **)Arg)[1];
|
||||
|
||||
if (const char *regName = disassembler.nameWithRegisterID(R))
|
||||
Out << "[" << regName << "/" << R << "]";
|
||||
|
||||
if (disassembler.registerIsStackPointer(R))
|
||||
Out << "(sp)";
|
||||
if (disassembler.registerIsProgramCounter(R))
|
||||
Out << "(pc)";
|
||||
|
||||
*V = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Disassembler::disassembleEnhanced(const std::string &TS,
|
||||
MemoryBuffer &Buffer,
|
||||
SourceMgr &SM,
|
||||
raw_ostream &Out) {
|
||||
ByteArrayTy ByteArray;
|
||||
StringRef Str = Buffer.getBuffer();
|
||||
|
||||
if (ByteArrayFromString(ByteArray, Str, SM)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Triple T(TS);
|
||||
EDDisassembler::AssemblySyntax AS;
|
||||
|
||||
switch (T.getArch()) {
|
||||
default:
|
||||
errs() << "error: no default assembly syntax for " << TS.c_str() << "\n";
|
||||
return -1;
|
||||
case Triple::arm:
|
||||
case Triple::thumb:
|
||||
AS = EDDisassembler::kEDAssemblySyntaxARMUAL;
|
||||
break;
|
||||
case Triple::x86:
|
||||
case Triple::x86_64:
|
||||
AS = EDDisassembler::kEDAssemblySyntaxX86ATT;
|
||||
break;
|
||||
}
|
||||
|
||||
OwningPtr<EDDisassembler>
|
||||
disassembler(EDDisassembler::getDisassembler(TS.c_str(), AS));
|
||||
|
||||
if (disassembler == 0) {
|
||||
errs() << "error: couldn't get disassembler for " << TS << '\n';
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (ByteArray.size()) {
|
||||
OwningPtr<EDInst>
|
||||
inst(disassembler->createInst(byteArrayReader, 0, &ByteArray));
|
||||
|
||||
if (inst == 0) {
|
||||
errs() << "error: Didn't get an instruction\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
ByteArray.erase (ByteArray.begin(), ByteArray.begin() + inst->byteSize());
|
||||
|
||||
unsigned numTokens = inst->numTokens();
|
||||
if ((int)numTokens < 0) {
|
||||
errs() << "error: couldn't count the instruction's tokens\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (unsigned tokenIndex = 0; tokenIndex != numTokens; ++tokenIndex) {
|
||||
EDToken *token;
|
||||
|
||||
if (inst->getToken(token, tokenIndex)) {
|
||||
errs() << "error: Couldn't get token\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char *buf;
|
||||
if (token->getString(buf)) {
|
||||
errs() << "error: Couldn't get string for token\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
Out << '[';
|
||||
int operandIndex = token->operandID();
|
||||
|
||||
if (operandIndex >= 0)
|
||||
Out << operandIndex << "-";
|
||||
|
||||
switch (token->type()) {
|
||||
case EDToken::kTokenWhitespace: Out << "w"; break;
|
||||
case EDToken::kTokenPunctuation: Out << "p"; break;
|
||||
case EDToken::kTokenOpcode: Out << "o"; break;
|
||||
case EDToken::kTokenLiteral: Out << "l"; break;
|
||||
case EDToken::kTokenRegister: Out << "r"; break;
|
||||
}
|
||||
|
||||
Out << ":" << buf;
|
||||
|
||||
if (token->type() == EDToken::kTokenLiteral) {
|
||||
Out << "=";
|
||||
if (token->literalSign())
|
||||
Out << "-";
|
||||
uint64_t absoluteValue;
|
||||
if (token->literalAbsoluteValue(absoluteValue)) {
|
||||
errs() << "error: Couldn't get the value of a literal token\n";
|
||||
return -1;
|
||||
}
|
||||
Out << absoluteValue;
|
||||
} else if (token->type() == EDToken::kTokenRegister) {
|
||||
Out << "=";
|
||||
unsigned regID;
|
||||
if (token->registerID(regID)) {
|
||||
errs() << "error: Couldn't get the ID of a register token\n";
|
||||
return -1;
|
||||
}
|
||||
Out << "r" << regID;
|
||||
}
|
||||
|
||||
Out << "]";
|
||||
}
|
||||
|
||||
Out << " ";
|
||||
|
||||
if (inst->isBranch())
|
||||
Out << "<br> ";
|
||||
if (inst->isMove())
|
||||
Out << "<mov> ";
|
||||
|
||||
unsigned numOperands = inst->numOperands();
|
||||
|
||||
if ((int)numOperands < 0) {
|
||||
errs() << "error: Couldn't count operands\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (unsigned operandIndex = 0; operandIndex != numOperands;
|
||||
++operandIndex) {
|
||||
Out << operandIndex << ":";
|
||||
|
||||
EDOperand *operand;
|
||||
if (inst->getOperand(operand, operandIndex)) {
|
||||
errs() << "error: couldn't get operand\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint64_t evaluatedResult;
|
||||
void *Arg[] = { disassembler.get(), &Out };
|
||||
if (operand->evaluate(evaluatedResult, verboseEvaluator, Arg)) {
|
||||
errs() << "error: Couldn't evaluate an operand\n";
|
||||
return -1;
|
||||
}
|
||||
Out << "=" << evaluatedResult << " ";
|
||||
}
|
||||
|
||||
Out << '\n';
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif // LEGACY_COMPLIB
|
||||
@@ -1,47 +0,0 @@
|
||||
//===- Disassembler.h - Text File Disassembler ----------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This class implements the disassembler of strings of bytes written in
|
||||
// hexadecimal, from standard input or from a file.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef DISASSEMBLER_H
|
||||
#define DISASSEMBLER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class MemoryBuffer;
|
||||
class Target;
|
||||
class raw_ostream;
|
||||
class SourceMgr;
|
||||
class MCSubtargetInfo;
|
||||
class MCStreamer;
|
||||
|
||||
class Disassembler {
|
||||
public:
|
||||
static int disassemble(const Target &T,
|
||||
const std::string &Triple,
|
||||
MCSubtargetInfo &STI,
|
||||
MCStreamer &Streamer,
|
||||
MemoryBuffer &Buffer,
|
||||
SourceMgr &SM,
|
||||
raw_ostream &Out);
|
||||
|
||||
static int disassembleEnhanced(const std::string &tripleString,
|
||||
MemoryBuffer &buffer,
|
||||
SourceMgr &SM,
|
||||
raw_ostream &Out);
|
||||
};
|
||||
|
||||
} // namespace llvm
|
||||
|
||||
#endif
|
||||
@@ -1,72 +0,0 @@
|
||||
==============================================================================
|
||||
LLVM Release License
|
||||
==============================================================================
|
||||
University of Illinois/NCSA
|
||||
Open Source License
|
||||
|
||||
Copyright (c) 2003-2017 University of Illinois at Urbana-Champaign.
|
||||
All rights reserved.
|
||||
|
||||
Developed by:
|
||||
|
||||
LLVM Team
|
||||
|
||||
University of Illinois at Urbana-Champaign
|
||||
|
||||
http://llvm.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal with
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimers.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimers in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of the LLVM Team, University of Illinois at
|
||||
Urbana-Champaign, nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this Software without specific
|
||||
prior written permission.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
|
||||
SOFTWARE.
|
||||
|
||||
==============================================================================
|
||||
Copyrights and Licenses for Third Party Software Distributed with LLVM:
|
||||
==============================================================================
|
||||
The LLVM software contains code written by third parties. Such software will
|
||||
have its own individual LICENSE.TXT file in the directory in which it appears.
|
||||
This file will describe the copyrights, license, and restrictions which apply
|
||||
to that code.
|
||||
|
||||
The disclaimer of warranty in the University of Illinois Open Source License
|
||||
applies to all code in the LLVM Distribution, and nothing in any of the
|
||||
other licenses gives permission to use the names of the LLVM Team or the
|
||||
University of Illinois to endorse or promote products derived from this
|
||||
Software.
|
||||
|
||||
The following pieces of software have additional or alternate copyrights,
|
||||
licenses, and/or restrictions:
|
||||
|
||||
Program Directory
|
||||
------- ---------
|
||||
Google Test llvm/utils/unittest/googletest
|
||||
OpenBSD regex llvm/lib/Support/{reg*, COPYRIGHT.regex}
|
||||
pyyaml tests llvm/test/YAMLParser/{*.data, LICENSE.TXT}
|
||||
ARM contributions llvm/lib/Target/ARM/LICENSE.TXT
|
||||
md5 contributions llvm/lib/Support/MD5.cpp llvm/include/llvm/Support/MD5.h
|
||||
|
||||
Open source files:
|
||||
Disassembler.cpp
|
||||
Disassembler.h
|
||||
@@ -1,33 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _BE_BACKEND_HPP_
|
||||
#define _BE_BACKEND_HPP_
|
||||
#include "compiler_stage.hpp"
|
||||
|
||||
namespace amdcl
|
||||
{
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::Backend
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class Backend : public CompilerStage {
|
||||
Backend(Backend&); // DO NOT IMPLEMENT.
|
||||
Backend(); // DO NOT IMPLEMENT.
|
||||
public:
|
||||
Backend(aclCompiler *cl, aclBinary *elf, aclLogFunction log)
|
||||
: CompilerStage(cl, elf, log) {}
|
||||
|
||||
virtual ~Backend() {}
|
||||
|
||||
/*! Function that takes in a string that is a source file
|
||||
* and generates the backend binary that is then
|
||||
* inserted into the elf file at the correct location.
|
||||
*/
|
||||
virtual int jit(const std::string &source) = 0;
|
||||
}; // class Backend
|
||||
/*@}*/
|
||||
}; // amdcl namespace
|
||||
#endif // _BE_BACKEND_HPP
|
||||
@@ -1,652 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#include "top.hpp"
|
||||
|
||||
#include "codegen.hpp"
|
||||
#include "utils/libUtils.h"
|
||||
#include "os/os.hpp"
|
||||
#include "utils/target_mappings.h"
|
||||
#ifdef _MSC_VER
|
||||
/* for disabling warning in llvm/ADT/Statistic.h */
|
||||
#pragma warning(disable:4146)
|
||||
#endif
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default:4146)
|
||||
#endif
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
#include "llvm/DataLayout.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/ExecutionEngine/ObjectImage.h"
|
||||
#else
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/Object/ObjectFile.h"
|
||||
#endif
|
||||
#include "llvm/Support/CodeGen.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/FormattedStream.h"
|
||||
#include "llvm/Support/Host.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetOptions.h"
|
||||
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||
#include "llvm/ExecutionEngine/JITEventListener.h"
|
||||
#include "llvm/ExecutionEngine/MCJIT.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
|
||||
using namespace amdcl;
|
||||
using namespace llvm;
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// JIT Memory manager
|
||||
//!--------------------------------------------------------------------------!//
|
||||
OCLMCJITMemoryManager::~OCLMCJITMemoryManager() {
|
||||
for (llvm::SmallVectorImpl<Allocation>::iterator
|
||||
I = AllocatedCodeMem.begin(), E = AllocatedCodeMem.end();
|
||||
I != E; ++I)
|
||||
llvm::sys::Memory::releaseMappedMemory(I->first);
|
||||
for (llvm::SmallVectorImpl<Allocation>::iterator
|
||||
I = AllocatedDataMem.begin(), E = AllocatedDataMem.end();
|
||||
I != E; ++I)
|
||||
llvm::sys::Memory::releaseMappedMemory(I->first);
|
||||
}
|
||||
|
||||
void
|
||||
OCLMCJITMemoryManager::deallocateSection(uint8_t* BasePtr) {
|
||||
for (llvm::SmallVectorImpl<Allocation>::iterator
|
||||
I = AllocatedCodeMem.begin(), E = AllocatedCodeMem.end();
|
||||
I != E; ++I)
|
||||
if (I->first.base() == BasePtr) {
|
||||
llvm::sys::Memory::releaseMappedMemory(I->first);
|
||||
AllocatedCodeMem.erase(I);
|
||||
return;
|
||||
}
|
||||
for (llvm::SmallVectorImpl<Allocation>::iterator
|
||||
I = AllocatedDataMem.begin(), E = AllocatedDataMem.end();
|
||||
I != E; ++I)
|
||||
if (I->first.base() == BasePtr) {
|
||||
llvm::sys::Memory::releaseMappedMemory(I->first);
|
||||
AllocatedDataMem.erase(I);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void OCLMCJITMemoryManager::reserveMemory(uint64_t Size) {
|
||||
llvm::sys::MemoryBlock Block = allocateSection(Size);
|
||||
AllocatedCodeMem.push_back(Allocation(Block, 64));
|
||||
allocPtr = (uint8_t*)Block.base();
|
||||
allocMaxPtr = allocPtr + Block.size();
|
||||
}
|
||||
|
||||
uint8_t *OCLMCJITMemoryManager::
|
||||
allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID
|
||||
#if !defined(LEGACY_COMPLIB)
|
||||
, llvm::StringRef SectionName
|
||||
#endif
|
||||
) {
|
||||
// The recording memory manager is just a local copy of the remote target.
|
||||
// The alignment requirement is just stored here for later use. Regular
|
||||
// heap storage is sufficient here, but we're using mapped memory to work
|
||||
// around a bug in MCJIT.
|
||||
uint8_t* address = reservedAlloc(Size, Alignment);
|
||||
if(address != NULL) {
|
||||
return address;
|
||||
} else {
|
||||
llvm::sys::MemoryBlock Block = allocateSection(Size);
|
||||
AllocatedCodeMem.push_back(Allocation(Block, Alignment));
|
||||
return (uint8_t*)Block.base();
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t *OCLMCJITMemoryManager::
|
||||
allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID,
|
||||
#if !defined(LEGACY_COMPLIB)
|
||||
llvm::StringRef SectionName,
|
||||
#endif
|
||||
bool isReadOnly) {
|
||||
// The recording memory manager is just a local copy of the remote target.
|
||||
// The alignment requirement is just stored here for later use. Regular
|
||||
// heap storage is sufficient here, but we're using mapped memory to work
|
||||
// around a bug in MCJIT.
|
||||
uint8_t* address = reservedAlloc(Size, Alignment);
|
||||
if(address != NULL) {
|
||||
return address;
|
||||
} else {
|
||||
llvm::sys::MemoryBlock Block = allocateSection(Size);
|
||||
AllocatedDataMem.push_back(Allocation(Block, Alignment));
|
||||
return (uint8_t*)Block.base();
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t * OCLMCJITMemoryManager::reservedAlloc(uintptr_t Size, unsigned Alignment) {
|
||||
if(allocPtr != NULL) {
|
||||
uint8_t *allocPtrAligned =
|
||||
(uint8_t*)(((uintptr_t)allocPtr +
|
||||
((uintptr_t)Alignment-1)) & ~((uintptr_t)Alignment-1));
|
||||
uint8_t *allocPtrNext = allocPtrAligned + Size;
|
||||
if(allocPtrNext < allocMaxPtr) {
|
||||
allocPtr = allocPtrNext;
|
||||
return allocPtrAligned;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
llvm::sys::MemoryBlock OCLMCJITMemoryManager::allocateSection(uintptr_t Size) {
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
llvm::error_code ec;
|
||||
#else
|
||||
std::error_code ec;
|
||||
#endif
|
||||
llvm::sys::MemoryBlock MB =
|
||||
llvm::sys::Memory::allocateMappedMemory(Size,
|
||||
&Near,
|
||||
llvm::sys::Memory::MF_READ |
|
||||
llvm::sys::Memory::MF_WRITE |
|
||||
llvm::sys::Memory::MF_EXEC,
|
||||
ec);
|
||||
assert(!ec && MB.base());
|
||||
|
||||
// FIXME: This is part of a work around to keep sections near one another
|
||||
// when MCJIT performs relocations after code emission but before
|
||||
// the generated code is moved to the remote target.
|
||||
// Save this address as the basis for our next request
|
||||
Near = MB;
|
||||
return MB;
|
||||
}
|
||||
|
||||
#if !defined(LEGACY_COMPLIB)
|
||||
void OCLMCJITMemoryManager::reserveAllocationSpace(uintptr_t CodeSize,
|
||||
uint32_t CodeAlign,
|
||||
uintptr_t RODataSize,
|
||||
uint32_t RODataAlign,
|
||||
uintptr_t RWDataSize,
|
||||
uint32_t RWDataAlign) {
|
||||
uint64_t GOTTableReserveSize = 4096;
|
||||
uint64_t Size = (uint64_t)CodeSize + (uint64_t)RODataSize +
|
||||
(uint64_t)RWDataSize + GOTTableReserveSize;
|
||||
if ((uint64_t)allocPtr + (uint64_t)Size > (uint64_t)allocMaxPtr)
|
||||
reserveMemory(Size);
|
||||
}
|
||||
#endif // !LEGACY_COMPLIB
|
||||
|
||||
void OCLMCJITMemoryManager::setMemoryWritable() {
|
||||
assert(!"Unexpected");
|
||||
}
|
||||
|
||||
void OCLMCJITMemoryManager::setMemoryExecutable() {
|
||||
assert(!"Unexpected");
|
||||
}
|
||||
|
||||
void OCLMCJITMemoryManager::setPoisonMemory(bool poison) {
|
||||
assert(!"Unexpected");
|
||||
}
|
||||
|
||||
void OCLMCJITMemoryManager::AllocateGOT() {
|
||||
assert(!"Unexpected");
|
||||
}
|
||||
|
||||
uint8_t *OCLMCJITMemoryManager::getGOTBase() const {
|
||||
assert(!"Unexpected");
|
||||
return 0;
|
||||
}
|
||||
uint8_t *OCLMCJITMemoryManager::startFunctionBody(const llvm::Function *F,
|
||||
uintptr_t &ActualSize) {
|
||||
assert(!"Unexpected");
|
||||
return 0;
|
||||
}
|
||||
uint8_t *OCLMCJITMemoryManager::allocateStub(const llvm::GlobalValue* F,
|
||||
unsigned StubSize,
|
||||
unsigned Alignment) {
|
||||
assert(!"Unexpected");
|
||||
return 0;
|
||||
}
|
||||
void OCLMCJITMemoryManager::endFunctionBody(const llvm::Function *F,
|
||||
uint8_t *FunctionStart,
|
||||
uint8_t *FunctionEnd) {
|
||||
assert(!"Unexpected");
|
||||
}
|
||||
uint8_t *OCLMCJITMemoryManager::allocateSpace(intptr_t Size,
|
||||
unsigned Alignment) {
|
||||
assert(!"Unexpected");
|
||||
return 0;
|
||||
}
|
||||
uint8_t *OCLMCJITMemoryManager::allocateGlobal(uintptr_t Size,
|
||||
unsigned Alignment) {
|
||||
assert(!"Unexpected");
|
||||
return 0;
|
||||
}
|
||||
void OCLMCJITMemoryManager::deallocateFunctionBody(void *Body) {
|
||||
assert(!"Unexpected");
|
||||
}
|
||||
uint8_t* OCLMCJITMemoryManager::startExceptionTable(const llvm::Function* F,
|
||||
uintptr_t &ActualSize) {
|
||||
assert(!"Unexpected");
|
||||
return 0;
|
||||
}
|
||||
void OCLMCJITMemoryManager::endExceptionTable(const llvm::Function *F,
|
||||
uint8_t *TableStart,
|
||||
uint8_t *TableEnd,
|
||||
uint8_t* FrameRegister) {
|
||||
assert(!"Unexpected");
|
||||
}
|
||||
void OCLMCJITMemoryManager::deallocateExceptionTable(void *ET) {
|
||||
assert(!"Unexpected");
|
||||
}
|
||||
|
||||
static int jit_noop() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *OCLMCJITMemoryManager::getPointerToNamedFunction(const std::string &Name,
|
||||
bool AbortOnFailure) {
|
||||
// We should not invoke parent's ctors/dtors from generated main()!
|
||||
// On Mingw and Cygwin, the symbol __main is resolved to
|
||||
// callee's(eg. tools/lli) one, to invoke wrong duplicated ctors
|
||||
// (and register wrong callee's dtors with atexit(3)).
|
||||
// We expect ExecutionEngine::runStaticConstructorsDestructors()
|
||||
// is called before ExecutionEngine::runFunctionAsMain() is called.
|
||||
if (Name == "__main") return (void*)(intptr_t)&jit_noop;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// JIT Event Listener
|
||||
//!--------------------------------------------------------------------------!//
|
||||
class OclJITEventListener : public llvm::JITEventListener
|
||||
{
|
||||
private:
|
||||
std::string* output_;
|
||||
|
||||
public:
|
||||
OclJITEventListener(std::string &output) {
|
||||
output_ = &output;
|
||||
}
|
||||
|
||||
virtual void NotifyObjectEmitted
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
(const llvm::ObjectImage &Obj)
|
||||
#else
|
||||
(const llvm::object::ObjectFile &Obj, const llvm::RuntimeDyld::LoadedObjectInfo &L)
|
||||
#endif
|
||||
override {
|
||||
encodeObjectImage(Obj.getData(), *output_);
|
||||
}
|
||||
|
||||
// Encoding and decoding are used to eliminate 0x00 ('\0') from the
|
||||
// string so it is safe to use it as a null terminated c string.
|
||||
// Translate:
|
||||
// 0x00 -> 0xaa 0x55
|
||||
// 0xaa -> 0xaa 0xaa
|
||||
static void encodeObjectImage(std::string objectImage, std::string &encodedObjectImage) {
|
||||
size_t length = objectImage.length();
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
unsigned char c = objectImage[i];
|
||||
switch (c) {
|
||||
case 0x00U:
|
||||
encodedObjectImage.push_back(0xaaU);
|
||||
encodedObjectImage.push_back(0x55U);
|
||||
break;
|
||||
case 0xaaU:
|
||||
encodedObjectImage.push_back(0xaaU);
|
||||
encodedObjectImage.push_back(0xaaU);
|
||||
break;
|
||||
default:
|
||||
encodedObjectImage.push_back(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Translate:
|
||||
// 0xaa 0x55 -> 0x00
|
||||
// 0xaa 0xaa -> 0xaa
|
||||
static void decodeObjectImage(std::string encodedObjectImage, std::string &decodedObjectImage) {
|
||||
size_t length = encodedObjectImage.length();
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
unsigned char c = encodedObjectImage[i];
|
||||
switch (c) {
|
||||
case 0xaaU:
|
||||
{
|
||||
i = i + 1; // Increment to advance two characters
|
||||
unsigned char cnext = encodedObjectImage[i];
|
||||
if (cnext == 0xaaU) {
|
||||
decodedObjectImage.push_back(0xaaU);
|
||||
} else if (cnext == 0x55U) {
|
||||
decodedObjectImage.push_back(0x00U);
|
||||
} else {
|
||||
assert(!"Bad encoding encountered");
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
decodedObjectImage.push_back(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void decodeObjectImage(std::string encodedObjectImage, std::string &decodedObjectImage) {
|
||||
OclJITEventListener::decodeObjectImage(encodedObjectImage, decodedObjectImage);
|
||||
}
|
||||
|
||||
// Returns empty string if code generation was successful,
|
||||
// otherwise the return string contains the error the MCJIT encountered.
|
||||
std::string
|
||||
jitCodeGen(llvm::Module* Composite,
|
||||
llvm::TargetMachine* TargetMachine,
|
||||
llvm::CodeGenOpt::Level OLvl,
|
||||
std::string& output) {
|
||||
std::string ErrStr;
|
||||
OclJITEventListener Listener(output);
|
||||
llvm::InitializeNativeTargetAsmParser();
|
||||
llvm::InitializeNativeTargetAsmPrinter();
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
OCLMCJITMemoryManager* MemMgr = new OCLMCJITMemoryManager();
|
||||
llvm::EngineBuilder builder(Composite);
|
||||
#else
|
||||
std::unique_ptr<RTDyldMemoryManager> MemMgr(new OCLMCJITMemoryManager());
|
||||
// FIXME: this llvm::Module* actually seems to be got from unique_ptr::get()
|
||||
// somewhere, but acl functions use Module* instead of std::unique_ptr<llvm::Module>
|
||||
// llvm::EngineBuilder does std::move on this pointer further so Module* can be
|
||||
// deleted twice... llvm::EngineBuilder builder(Composite);
|
||||
std::unique_ptr<llvm::Module> MPtr(Composite);
|
||||
llvm::EngineBuilder builder(std::move(MPtr));
|
||||
#endif
|
||||
builder.setOptLevel(OLvl);
|
||||
builder.setErrorStr(&ErrStr);
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
builder.setJITMemoryManager(MemMgr);
|
||||
builder.setUseMCJIT(true);
|
||||
#else
|
||||
builder.setMCJITMemoryManager(std::move(MemMgr));
|
||||
#endif
|
||||
// builder.setRelocationModel(llvm::Reloc::PIC_)
|
||||
// builder.setCodeModel(llvm::CodeModel::Large)
|
||||
#ifndef ANDROID
|
||||
std::unique_ptr<llvm::ExecutionEngine>
|
||||
TheExecutionEngine(builder.create(TargetMachine));
|
||||
|
||||
TheExecutionEngine->RegisterJITEventListener(&Listener);
|
||||
TheExecutionEngine->finalizeObject();
|
||||
TheExecutionEngine->removeModule(Composite);
|
||||
#endif
|
||||
return ErrStr;
|
||||
}
|
||||
|
||||
int
|
||||
llvmCodeGen(
|
||||
Module* Composite,
|
||||
amd::option::Options *OptionsObj,
|
||||
std::string& output,
|
||||
aclBinary* binary)
|
||||
{
|
||||
const FamilyMapping &familyMap = familySet[binary->target.arch_id];
|
||||
const bool optimize = (OptionsObj ? (OptionsObj->oVariables->OptLevel > amd::option::OPT_O0) : true);
|
||||
const TargetMapping* targetMap = familyMap.target;
|
||||
unsigned famID = binary->target.chip_id;
|
||||
if (!targetMap || !targetMap[famID].supported) {
|
||||
LogError("Device is not supported by code generator!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Load the module to be compiled...
|
||||
Module &mod = *Composite;
|
||||
|
||||
// FIXME: The triple given in this map is wrong and isn't really
|
||||
// useful. Only need the architecture.
|
||||
const std::string TargetTriple = std::string(familyMap.triple);
|
||||
Triple TheTriple(TargetTriple);
|
||||
if (TheTriple.getTriple().empty()) {
|
||||
TheTriple.setTriple(sys::getDefaultTargetTriple());
|
||||
}
|
||||
|
||||
Triple::ArchType arch = TheTriple.getArch();
|
||||
|
||||
bool isGPU = (arch == Triple::amdil || arch == Triple::amdil64 ||
|
||||
arch == Triple::hsail || arch == Triple::hsail64);
|
||||
|
||||
if (isGPU) {
|
||||
TheTriple.setOS(Triple::UnknownOS);
|
||||
} else { // CPUs
|
||||
// FIXME: This should come from somewhere else.
|
||||
#ifdef __linux__
|
||||
TheTriple.setOS(Triple::Linux);
|
||||
#else
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
TheTriple.setOS(Triple::MinGW32);
|
||||
#else
|
||||
TheTriple.setOS(Triple::Win32);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
TheTriple.setEnvironment(Triple::AMDOpenCL);
|
||||
// FIXME: need to make AMDOpenCL be the same as ELF
|
||||
if (OptionsObj->oVariables->UseJIT)
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
TheTriple.setEnvironment(Triple::ELF);
|
||||
#else
|
||||
TheTriple.setObjectFormat(Triple::ELF);
|
||||
#endif
|
||||
mod.setTargetTriple(TheTriple.getTriple());
|
||||
|
||||
// Allocate target machine. First, check whether the user has explicitly
|
||||
// specified an architecture to compile for. If so we have to look it up by
|
||||
// name, because it might be a backend that has no mapping to a target triple.
|
||||
const Target *TheTarget = 0;
|
||||
assert(binary->target.arch_id != aclError && "Cannot have the error device!");
|
||||
|
||||
std::string MArch = familyMap.architecture;
|
||||
|
||||
#ifdef WITH_TARGET_HSAIL
|
||||
if (MArch == "hsail" && OptionsObj->oVariables->GPU64BitIsa) {
|
||||
MArch = std::string("hsail64");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
for (TargetRegistry::iterator it = TargetRegistry::begin(),
|
||||
ie = TargetRegistry::end(); it != ie; ++it) {
|
||||
#else
|
||||
for (TargetRegistry::iterator it = TargetRegistry::targets().begin(),
|
||||
ie = TargetRegistry::targets().end(); it != ie; ++it) {
|
||||
#endif
|
||||
if (MArch == it->getName()) {
|
||||
TheTarget = &*it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!TheTarget) {
|
||||
errs() << ": ERROR: invalid target '" << MArch << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
CodeGenOpt::Level OLvl = CodeGenOpt::None;
|
||||
switch (OptionsObj->oVariables->OptLevel) {
|
||||
case amd::option::OPT_O0: // -O0
|
||||
OLvl = CodeGenOpt::None;
|
||||
break;
|
||||
case amd::option::OPT_O1: // -O1
|
||||
OLvl = CodeGenOpt::Less;
|
||||
break;
|
||||
default:
|
||||
assert(!"Error with optimization level");
|
||||
case amd::option::OPT_O2: // -O2
|
||||
case amd::option::OPT_O5: // -O5
|
||||
case amd::option::OPT_OG: // -Og
|
||||
case amd::option::OPT_OS: // -Os
|
||||
OLvl = CodeGenOpt::Default;
|
||||
break;
|
||||
case amd::option::OPT_O3: // -O3
|
||||
case amd::option::OPT_O4: // -O4
|
||||
OLvl = CodeGenOpt::Aggressive;
|
||||
break;
|
||||
};
|
||||
|
||||
// Adjust the triple to match (if known), otherwise stick with the
|
||||
// module/host triple.
|
||||
Triple::ArchType Type = Triple::getArchTypeForLLVMName(MArch);
|
||||
if (Type != Triple::UnknownArch)
|
||||
TheTriple.setArch(Type);
|
||||
|
||||
// Package up features to be passed to target/subtarget
|
||||
std::string FeatureStr = getFeatureString(binary->target, OptionsObj);
|
||||
|
||||
llvm::TargetOptions targetOptions;
|
||||
targetOptions.StackAlignmentOverride =
|
||||
OptionsObj->oVariables->CPUStackAlignment;
|
||||
// jgolds
|
||||
//targetOptions.EnableEBB = (optimize && OptionsObj->oVariables->CGEBB);
|
||||
//targetOptions.EnableBFO = OptionsObj->oVariables->CGBFO;
|
||||
//targetOptions.NoExcessFPPrecision = !OptionsObj->oVariables->EnableFMA;
|
||||
|
||||
// Don't allow unsafe optimizations for CPU because the library
|
||||
// contains code that is not safe. See bug 9567.
|
||||
if (isGPU)
|
||||
targetOptions.UnsafeFPMath = OptionsObj->oVariables->UnsafeMathOpt;
|
||||
targetOptions.LessPreciseFPMADOption = OptionsObj->oVariables->MadEnable ||
|
||||
OptionsObj->oVariables->EnableMAD;
|
||||
targetOptions.NoInfsFPMath = OptionsObj->oVariables->FiniteMathOnly;
|
||||
// Need to add a support for OptionsObj->oVariables->NoSignedZeros,
|
||||
targetOptions.NoNaNsFPMath = OptionsObj->oVariables->FiniteMathOnly;
|
||||
|
||||
std::auto_ptr<TargetMachine>
|
||||
target(TheTarget->createTargetMachine(TheTriple.getTriple(),
|
||||
aclutGetCodegenName(binary->target), FeatureStr, targetOptions,
|
||||
WINDOWS_SWITCH(Reloc::DynamicNoPIC, Reloc::PIC_),
|
||||
CodeModel::Default, OLvl));
|
||||
assert(target.get() && "Could not allocate target machine!");
|
||||
|
||||
// MCJIT(Jan)
|
||||
if(!isGPU && OptionsObj->oVariables->UseJIT) {
|
||||
TargetMachine* jittarget(TheTarget->createTargetMachine(TheTriple.getTriple(),
|
||||
aclutGetCodegenName(binary->target), FeatureStr, targetOptions,
|
||||
WINDOWS_SWITCH(Reloc::DynamicNoPIC, Reloc::PIC_),
|
||||
CodeModel::Default, OLvl));
|
||||
|
||||
std::string ErrStr = jitCodeGen(Composite, jittarget, OLvl, output);
|
||||
|
||||
if (!ErrStr.empty()) {
|
||||
LogError("MCJIT failed to generate code");
|
||||
LogError(ErrStr.c_str());
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TargetMachine &Target = *target;
|
||||
|
||||
// Figure out where we are going to send the output...
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
raw_string_ostream *RSOut = new raw_string_ostream(output);
|
||||
formatted_raw_ostream *Out = new formatted_raw_ostream(*RSOut, formatted_raw_ostream::DELETE_STREAM);
|
||||
#else
|
||||
auto RSOut = llvm::make_unique<raw_string_ostream>(output);
|
||||
if (!RSOut) {
|
||||
LogError("llvmCodeGen couldn't create an output stream");
|
||||
return 1;
|
||||
}
|
||||
auto Out = llvm::make_unique<buffer_ostream>(*RSOut);
|
||||
#endif
|
||||
if (!Out) {
|
||||
LogError("llvmCodeGen couldn't create an output stream");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Build up all of the passes that we want to do to the module or function or
|
||||
// Basic Block.
|
||||
legacy::PassManager Passes;
|
||||
|
||||
// Add the target data from the target machine, if it exists, or the module.
|
||||
mod.setDataLayout(Target.createDataLayout());
|
||||
// Override default to generate verbose assembly, if the device is not the GPU.
|
||||
// The GPU sets this in AMDILTargetMachine.cpp.
|
||||
if (familyMap.target == (const TargetMapping*)&X86TargetMapping ||
|
||||
familyMap.target == (const TargetMapping*)&X64TargetMapping
|
||||
) {
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
Target.setAsmVerbosityDefault(true);
|
||||
#else
|
||||
Target.Options.MCOptions.AsmVerbose = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef WITH_TARGET_HSAIL
|
||||
if (isHSAILTarget(binary->target)) {
|
||||
if (Target.addPassesToEmitFile(Passes, *Out, TargetMachine::CGFT_ObjectFile, true)) {
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
delete Out;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
if (Target.addPassesToEmitFile(Passes, *Out, TargetMachine::CGFT_AssemblyFile, false))
|
||||
#else
|
||||
if (Target.addPassesToEmitFile(Passes, *Out, TargetMachine::CGFT_AssemblyFile, true))
|
||||
#endif
|
||||
{
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
delete Out;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Passes.run(mod);
|
||||
llvm::PrintStatistics();
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
delete Out;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
CLCodeGen::codegen(llvm::Module *input)
|
||||
{
|
||||
uint64_t time_cg = 0ULL;
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
time_cg = amd::Os::timeNanos();
|
||||
}
|
||||
llvmbinary_ = input;
|
||||
amdcl::CompilerStage *cs = reinterpret_cast<amdcl::CompilerStage*>(this);
|
||||
if (!isHSAILTarget(cs->Elf()->target)) {
|
||||
setWholeProgram(true);
|
||||
}
|
||||
setUniformWorkGroupSize(Options()->oVariables->UniformWorkGroupSize);
|
||||
|
||||
int ret = llvmCodeGen(LLVMBinary(), Options(), Source(), Elf());
|
||||
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
time_cg = amd::Os::timeNanos() - time_cg;
|
||||
std::stringstream tmp_ss;
|
||||
tmp_ss << " LLVM CodeGen time: "
|
||||
<< time_cg/1000ULL
|
||||
<< "us\n";
|
||||
appendLogToCL(CL(), tmp_ss.str());
|
||||
}
|
||||
if (!Source().empty() && Options()->isDumpFlagSet(amd::option::DUMP_CGIL)) {
|
||||
std::string ilFileName = Options()->getDumpFileName(".il");
|
||||
std::fstream f;
|
||||
f.open(ilFileName.c_str(), (std::fstream::out | std::fstream::binary));
|
||||
f.write(Source().data(), Source().length());
|
||||
f.close();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _BE_CODEGEN_HPP_
|
||||
#define _BE_CODEGEN_HPP_
|
||||
#include "compiler_stage.hpp"
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
#include "llvm/ExecutionEngine/JITMemoryManager.h"
|
||||
#else
|
||||
#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
|
||||
#endif
|
||||
|
||||
namespace amdcl
|
||||
{
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::CodeGen
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class CodeGen : public LLVMCompilerStage {
|
||||
CodeGen(CodeGen&); // DO NOT IMPLEMENT.
|
||||
CodeGen(); // DO NOT IMPLEMENT.
|
||||
public:
|
||||
CodeGen(aclCompiler *cl, aclBinary *elf, aclLogFunction log)
|
||||
: LLVMCompilerStage(cl, elf, log) {}
|
||||
|
||||
virtual ~CodeGen() {}
|
||||
|
||||
/*! Function that takes in an LLVM module as input
|
||||
* and generates code for it based on the target
|
||||
* device.
|
||||
* Returns 0 on success and non-zero on failure.
|
||||
*/
|
||||
virtual int codegen(llvm::Module *input) = 0;
|
||||
|
||||
}; // class CodeGen
|
||||
/*@}*/
|
||||
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::CLCodeGen
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class CLCodeGen : public CodeGen {
|
||||
CLCodeGen(CLCodeGen&); // DO NOT IMPLEMENT.
|
||||
CLCodeGen(); // DO NOT IMPLEMENT.
|
||||
public:
|
||||
CLCodeGen(aclCompiler *cl, aclBinary *elf, aclLogFunction log)
|
||||
: CodeGen(cl, elf, log) {}
|
||||
|
||||
virtual ~CLCodeGen() {}
|
||||
|
||||
/*! Function that takes in an LLVM module as input
|
||||
* and generates code for it based on the target
|
||||
* device.
|
||||
* Returns 0 on success and non-zero on failure.
|
||||
*/
|
||||
virtual int codegen(llvm::Module *input);
|
||||
|
||||
}; // class CLCodeGen
|
||||
/*@}*/
|
||||
|
||||
#if 0
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::AMDILCodeGen
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class AMDILCodeGen : public CodeGen {
|
||||
AMDILCodeGen(AMDILCodeGen&); // DO NOT IMPLEMENT.
|
||||
AMDILCodeGen(); // DO NOT IMPLEMENT.
|
||||
public:
|
||||
AMDILCodeGen(aclCompiler *cl, aclBinary *elf, llvm::LLVMContext *ctx)
|
||||
: CLCodeGen(cl, elf, ctx) {}
|
||||
|
||||
virtual ~AMDILCodeGen() {}
|
||||
|
||||
/*! Function that takes in an LLVM module as input
|
||||
* and generates code for it based on the target
|
||||
* device.
|
||||
* Returns 0 on success and non-zero on failure.
|
||||
*/
|
||||
int codegen(llvm::Module *input) = 0;
|
||||
|
||||
}; // class AMDILCodeGen
|
||||
/*@}*/
|
||||
#endif
|
||||
} // amdcl namespace
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// JIT Memory manager
|
||||
//!--------------------------------------------------------------------------!//
|
||||
class OCLMCJITMemoryManager : public
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
llvm::JITMemoryManager
|
||||
#else
|
||||
llvm::RTDyldMemoryManager
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
typedef std::pair<llvm::sys::MemoryBlock, unsigned> Allocation;
|
||||
|
||||
private:
|
||||
llvm::SmallVector<Allocation, 16> AllocatedDataMem;
|
||||
llvm::SmallVector<Allocation, 16> AllocatedCodeMem;
|
||||
|
||||
// FIXME: This is part of a work around to keep sections near one another
|
||||
// when MCJIT performs relocations after code emission but before
|
||||
// the generated code is moved to the remote target.
|
||||
llvm::sys::MemoryBlock Near;
|
||||
uint8_t * reservedAlloc(uintptr_t Size, unsigned Alignment);
|
||||
llvm::sys::MemoryBlock allocateSection(uintptr_t Size);
|
||||
|
||||
uint8_t *allocPtr;
|
||||
uint8_t *allocMaxPtr;
|
||||
|
||||
public:
|
||||
OCLMCJITMemoryManager() : allocPtr(NULL), allocMaxPtr(NULL) {}
|
||||
virtual ~OCLMCJITMemoryManager();
|
||||
|
||||
typedef llvm::SmallVectorImpl<Allocation>::const_iterator const_data_iterator;
|
||||
typedef llvm::SmallVectorImpl<Allocation>::const_iterator const_code_iterator;
|
||||
|
||||
const_data_iterator data_begin() const { return AllocatedDataMem.begin(); }
|
||||
const_data_iterator data_end() const { return AllocatedDataMem.end(); }
|
||||
const_code_iterator code_begin() const { return AllocatedCodeMem.begin(); }
|
||||
const_code_iterator code_end() const { return AllocatedCodeMem.end(); }
|
||||
|
||||
virtual void reserveMemory(uint64_t size);
|
||||
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
|
||||
unsigned SectionID);
|
||||
|
||||
uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
|
||||
unsigned SectionID, bool isReadOnly);
|
||||
|
||||
bool applyPermissions(std::string *ErrMsg) { return false; }
|
||||
|
||||
#else
|
||||
virtual bool needsToReserveAllocationSpace() override { return true; }
|
||||
|
||||
virtual void reserveAllocationSpace(uintptr_t CodeSize, uint32_t CodeAlign,
|
||||
uintptr_t RODataSize,
|
||||
uint32_t RODataAlign,
|
||||
uintptr_t RWDataSize,
|
||||
uint32_t RWDataAlign) override;
|
||||
|
||||
uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
|
||||
unsigned SectionID, llvm::StringRef SectionName) override;
|
||||
|
||||
uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
|
||||
unsigned SectionID, llvm::StringRef SectionName,
|
||||
bool isReadOnly) override;
|
||||
|
||||
bool finalizeMemory(std::string *ErrMsg = nullptr) override { return false; }
|
||||
#endif
|
||||
|
||||
void *getPointerToNamedFunction(const std::string &Name,
|
||||
bool AbortOnFailure = true);
|
||||
|
||||
// The following obsolete JITMemoryManager calls are stubbed out for
|
||||
// this model.
|
||||
void setMemoryWritable();
|
||||
void setMemoryExecutable();
|
||||
void setPoisonMemory(bool poison);
|
||||
void AllocateGOT();
|
||||
uint8_t *getGOTBase() const;
|
||||
uint8_t *startFunctionBody(const llvm::Function *F, uintptr_t &ActualSize);
|
||||
uint8_t *allocateStub(const llvm::GlobalValue* F, unsigned StubSize,
|
||||
unsigned Alignment);
|
||||
void endFunctionBody(const llvm::Function *F, uint8_t *FunctionStart,
|
||||
uint8_t *FunctionEnd);
|
||||
uint8_t *allocateSpace(intptr_t Size, unsigned Alignment);
|
||||
uint8_t *allocateGlobal(uintptr_t Size, unsigned Alignment);
|
||||
void deallocateFunctionBody(void *Body);
|
||||
uint8_t* startExceptionTable(const llvm::Function* F, uintptr_t &ActualSize);
|
||||
void endExceptionTable(const llvm::Function *F, uint8_t *TableStart,
|
||||
uint8_t *TableEnd, uint8_t* FrameRegister);
|
||||
void deallocateExceptionTable(void *ET);
|
||||
void deallocateSection(uint8_t* BasePtr);
|
||||
};
|
||||
|
||||
// The jitCodeGen function creates a string where the '\0' characters
|
||||
// have been encoded. decodeObjectImage puts the '\0' characters back.
|
||||
void decodeObjectImage(std::string encodedObjectImage, std::string &decodedObjectImage);
|
||||
|
||||
#endif // _BE_CODEGEN_HPP_
|
||||
@@ -1,119 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#include "compiler_stage.hpp"
|
||||
#include "utils/libUtils.h"
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
#include "llvm/Assembly/Parser.h"
|
||||
#include "llvm/LLVMContext.h"
|
||||
#else
|
||||
#include "llvm/AsmParser/Parser.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#endif
|
||||
|
||||
using namespace amdcl;
|
||||
|
||||
CompilerStage::CompilerStage(aclCompiler* cl, aclBinary* elf,
|
||||
aclLogFunction callback)
|
||||
: cl_(cl), elf_(elf), binary_(NULL),
|
||||
source_(""), log_(""), callback_(callback)
|
||||
{
|
||||
opts_ = (amd::option::Options*)Elf()->options;
|
||||
}
|
||||
|
||||
CompilerStage::~CompilerStage()
|
||||
{ }
|
||||
|
||||
LLVMCompilerStage::LLVMCompilerStage(aclCompiler *cl, aclBinary *elf,
|
||||
aclLogFunction callback)
|
||||
: CompilerStage(cl, elf, callback),
|
||||
llvmbinary_(NULL),
|
||||
context_(NULL)
|
||||
{
|
||||
if (!Options()->oVariables->DisableAllWarnings) {
|
||||
hookup_.LLVMBuildLog = &log_;
|
||||
}
|
||||
// Expose some options to LLVM.
|
||||
llvm::AMDOptions *amdopts = &hookup_.amdoptions;
|
||||
amdopts->OptLiveness = Options()->oVariables->OptLiveness;
|
||||
if (isHSAILTarget(Elf()->target)) {
|
||||
if ((amdopts->NumAvailGPRs == ~0u) || (Options()->NumAvailGPRs != -1))
|
||||
amdopts->NumAvailGPRs = Options()->NumAvailGPRs;
|
||||
} else {
|
||||
amdopts->OptPrintLiveness = Options()->oVariables->OptPrintLiveness;
|
||||
amdopts->OptMem2reg = Options()->oVariables->OptMem2reg;
|
||||
amdopts->UseJIT = Options()->oVariables->UseJIT;
|
||||
amdopts->APThreshold = Options()->oVariables->APThreshold;
|
||||
amdopts->AAForBarrier = Options()->oVariables->AAForBarrier;
|
||||
amdopts->UnrollScratchThreshold = 500;
|
||||
amdopts->AmdilUseDefaultResId = Options()->oVariables->DefaultResourceId;
|
||||
}
|
||||
amdopts->OptSimplifyLibCall = Options()->oVariables->OptSimplifyLibCall;
|
||||
amdopts->EnableFDiv2FMul = Options()->oVariables->EnableFDiv2FMul;
|
||||
amdopts->SRThreshold = Options()->oVariables->SRThreshold;
|
||||
amdopts->OptMemCombineMaxVecGen = Options()->oVariables->OptMemCombineMaxVecGen;
|
||||
amdopts->OptLICM = Options()->oVariables->OptLICM;
|
||||
|
||||
// math-related options
|
||||
amdopts->UnsafeMathOpt = Options()->oVariables->UnsafeMathOpt;
|
||||
amdopts->NoSignedZeros = Options()->oVariables->NoSignedZeros;
|
||||
amdopts->FiniteMathOnly = Options()->oVariables->FiniteMathOnly;
|
||||
amdopts->FastRelaxedMath = Options()->oVariables->FastRelaxedMath;
|
||||
|
||||
amdopts->LUThreshold = Options()->oVariables->LUThreshold;
|
||||
amdopts->LUCount = Options()->oVariables->LUCount;
|
||||
amdopts->LUAllowPartial = Options()->oVariables->LUAllowPartial;
|
||||
amdopts->GPUArch = (uint32_t)getLibraryType(&elf->target);
|
||||
}
|
||||
|
||||
void
|
||||
LLVMCompilerStage::setContext(aclContext *ctx)
|
||||
{
|
||||
context_ = reinterpret_cast<llvm::LLVMContext*>(ctx);
|
||||
if (ctx) {
|
||||
Context().setAMDLLVMContextHook(&hookup_);
|
||||
}
|
||||
}
|
||||
|
||||
LLVMCompilerStage::~LLVMCompilerStage()
|
||||
{
|
||||
if (context_) {
|
||||
Context().setAMDLLVMContextHook(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
llvm::Module*
|
||||
LLVMCompilerStage::loadBitcode(std::string& llvmBinary)
|
||||
{
|
||||
if (!llvm::isBitcode(reinterpret_cast<const unsigned char*>(llvmBinary.data()),
|
||||
reinterpret_cast<const unsigned char*>(llvmBinary.data()
|
||||
+ llvmBinary.length()))) {
|
||||
llvm::SMDiagnostic diags;
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
return ParseAssemblyString(llvmBinary.c_str(), llvmbinary_, diags, Context());
|
||||
#else
|
||||
llvmbinary_ = llvm::parseAssemblyString(llvmBinary.c_str(), diags, Context()).release();
|
||||
return llvmbinary_;
|
||||
#endif
|
||||
}
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
// Use getMemBuffer() ?
|
||||
if (llvm::MemoryBuffer *Buffer =
|
||||
llvm::MemoryBuffer::getMemBufferCopy(
|
||||
llvm::StringRef(llvmBinary), "input.bc")) {
|
||||
std::string ErrorMessage;
|
||||
llvm::Module* M =
|
||||
llvm::ParseBitcodeFile(Buffer, Context(), &ErrorMessage);
|
||||
delete Buffer;
|
||||
return M;
|
||||
}
|
||||
#else
|
||||
if (std::unique_ptr<llvm::MemoryBuffer> Buffer =
|
||||
llvm::MemoryBuffer::getMemBufferCopy(
|
||||
llvm::StringRef(llvmBinary), "input.bc")) {
|
||||
auto ModuleOrErr = llvm::parseBitcodeFile(Buffer->getMemBufferRef(), Context());
|
||||
if( !ModuleOrErr.getError() ) return ModuleOrErr.get().release();
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _BE_COMPILER_STAGE_HPP_
|
||||
#define _BE_COMPILER_STAGE_HPP_
|
||||
|
||||
#if defined DEBUG
|
||||
#undef DEBUG
|
||||
#endif
|
||||
|
||||
#include "llvm/AMDLLVMContextHook.h"
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
#include "llvm/PassManager.h"
|
||||
#else
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#endif
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Support/SourceMgr.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
|
||||
#include "aclTypes.h"
|
||||
#include "utils/options.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
namespace llvm
|
||||
{
|
||||
class LLVMContext;
|
||||
class Module;
|
||||
}
|
||||
|
||||
namespace amdcl
|
||||
{
|
||||
/*! \addtogroup CompilerLibrary
|
||||
*
|
||||
* \copydoc amdcl::CompilerStage
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class CompilerStage {
|
||||
private:
|
||||
CompilerStage(); // DO NOT IMPLEMENT.
|
||||
CompilerStage(CompilerStage&); // DO NOT IMPLEMENT.
|
||||
public:
|
||||
CompilerStage(aclCompiler* cl, aclBinary* elf, aclLogFunction callback);
|
||||
|
||||
virtual ~CompilerStage();
|
||||
|
||||
/*! Returns the Compiler */
|
||||
aclCompiler* CL() const { return cl_; }
|
||||
|
||||
/*! Returns the elf binary */
|
||||
aclBinary* Elf() const { return elf_; }
|
||||
|
||||
/*! Returns the callback */
|
||||
aclLogFunction Callback() const { return callback_; }
|
||||
|
||||
/*! Returns the options */
|
||||
amd::option::Options* Options() const {
|
||||
assert(opts_ && "Options should not be null");
|
||||
return opts_;
|
||||
}
|
||||
|
||||
|
||||
/*! Returns the source file */
|
||||
std::string& Source() { return source_; }
|
||||
|
||||
/*! Returns the build log */
|
||||
std::string& BuildLog() { return log_; }
|
||||
|
||||
protected:
|
||||
aclCompiler *cl_;
|
||||
aclBinary *elf_;
|
||||
void *binary_;
|
||||
amd::option::Options* opts_;
|
||||
std::string source_;
|
||||
std::string log_;
|
||||
aclLogFunction callback_;
|
||||
}; // class CompilerStage
|
||||
|
||||
class LLVMCompilerStage : public CompilerStage {
|
||||
public:
|
||||
LLVMCompilerStage(aclCompiler *cl, aclBinary *elf,
|
||||
aclLogFunction callback);
|
||||
virtual ~LLVMCompilerStage();
|
||||
void setContext(aclContext *ctx);
|
||||
|
||||
/*! Returns the local context */
|
||||
llvm::LLVMContext& Context() { return (*context_); }
|
||||
|
||||
/*! Loads bitcode in either text or binary format and return
|
||||
* and LLVM module. */
|
||||
virtual llvm::Module* loadBitcode(std::string& llvmBinary);
|
||||
|
||||
void setGPU(bool isForGPU) { hookup_.amdoptions.IsGPU = isForGPU; }
|
||||
void setWholeProgram(bool Val) { hookup_.amdoptions.WholeProgram = Val; }
|
||||
void setNoSignedZeros(bool Val) { hookup_.amdoptions.NoSignedZeros = Val; }
|
||||
void setFastRelaxedMath(bool Val) { hookup_.amdoptions.FastRelaxedMath = Val; }
|
||||
void setOptSimplifyLibCall(bool Val) { hookup_.amdoptions.OptSimplifyLibCall = Val; }
|
||||
void setUnsafeMathOpt(bool Val) { hookup_.amdoptions.UnsafeMathOpt = Val; }
|
||||
void setFiniteMathOnly(bool Val) { hookup_.amdoptions.FiniteMathOnly = Val; }
|
||||
void setIsPreLinkOpt(bool Val) { hookup_.amdoptions.IsPreLinkOpt = Val; }
|
||||
void setFP32RoundDivideSqrt(bool Val) { hookup_.amdoptions.FP32RoundDivideSqrt = Val; }
|
||||
void setUseNative(const char * Val) { if(Val) hookup_.amdoptions.OptUseNative = Val; }
|
||||
void setDenormsAreZero(bool Val) { hookup_.amdoptions.DenormsAreZero = Val; }
|
||||
void setUniformWorkGroupSize(bool Val) { hookup_.amdoptions.UniformWorkGroupSize = Val; }
|
||||
void setHaveFastFMA32(bool Val) { hookup_.amdoptions.HaveFastFMA32 = Val; }
|
||||
void setISAVersion(int Val) { hookup_.amdoptions.ISAVersion = Val; }
|
||||
|
||||
/*! Returns the llvm binary */
|
||||
llvm::Module* LLVMBinary() const { return llvmbinary_; }
|
||||
aclModule* Module() const { return reinterpret_cast<aclModule*>(llvmbinary_);}
|
||||
protected:
|
||||
llvm::Module *llvmbinary_;
|
||||
llvm::LLVMContext *context_;
|
||||
llvm::AMDLLVMContextHook hookup_;
|
||||
}; // class CompilerStage
|
||||
/*@}*/
|
||||
}
|
||||
#endif // _BE_COMPILER_STAGE_HPP_
|
||||
@@ -1,251 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#include "top.hpp"
|
||||
#include "frontend.hpp"
|
||||
#include "bif/bifbase.hpp"
|
||||
#include "utils/target_mappings.h"
|
||||
#include "utils/options.hpp"
|
||||
#include "os/os.hpp"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
bool Is64bitMachine() {return sizeof(void*) == 8;}
|
||||
|
||||
void
|
||||
amdcl::OCLFrontend::appendCLVersionFlag(std::stringstream &ss,
|
||||
const amd::option::Options *opts)
|
||||
{
|
||||
llvm::StringRef clStd(opts->oVariables->CLStd);
|
||||
|
||||
if (clStd == "CL1.0") {
|
||||
ss << "--opencl=1.0 ";
|
||||
} else if (clStd == "CL1.1") {
|
||||
ss << "--opencl=1.1 ";
|
||||
} else if (clStd == "CL1.2") {
|
||||
ss << "--opencl=1.2 ";
|
||||
} else {
|
||||
if (clStd != "CL2.0") {
|
||||
appendLogToCL(CL(), "Warning: invalid value for -cl-std, defaulting to CL1.2");
|
||||
ss << "--opencl=1.2 ";
|
||||
return;
|
||||
}
|
||||
|
||||
ss << "--opencl=2.0 ";
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// @brief Function that converts elf + src combo into the correct
|
||||
/// sequence of commands to call the CLC frontend.
|
||||
///
|
||||
/// FIXME: This needs to be modified so writing to a file is
|
||||
/// not necessary!
|
||||
std::string
|
||||
amdcl::OCLFrontend::getFrontendCommand(aclBinary *elf,
|
||||
const std::string &src,
|
||||
std::string &logFile,
|
||||
std::string &clFile,
|
||||
bool preprocessOnly)
|
||||
{
|
||||
std::stringstream systemPath;
|
||||
std::fstream f;
|
||||
amd::option::Options* Opts = (amd::option::Options*)elf->options;
|
||||
|
||||
f.open(clFile.c_str(), (std::fstream::out | std::fstream::binary));
|
||||
f.write(src.data(), src.length());
|
||||
f.close();
|
||||
|
||||
bool enableSpir = false;
|
||||
#ifdef DEBUG
|
||||
enableSpir = getenv("AMD_OCL_ENABLE_SPIR");
|
||||
#endif
|
||||
|
||||
if (enableSpir)
|
||||
systemPath << "clc --spir --emit=spirbc ";
|
||||
else
|
||||
systemPath << "clc --emit=llvmbc ";
|
||||
|
||||
appendCLVersionFlag(systemPath, Opts);
|
||||
|
||||
if (enableSpir)
|
||||
systemPath << "--amd-options-begin " << Opts->origOptionStr << " --amd-options-end ";
|
||||
|
||||
if (checkFlag(aclutGetCaps(elf), capImageSupport)) {
|
||||
systemPath << "-D__IMAGE_SUPPORT__=1 ";
|
||||
}
|
||||
|
||||
if (checkFlag(aclutGetCaps(elf), capFMA)) {
|
||||
systemPath << "-DFP_FAST_FMAF=1 ";
|
||||
systemPath << "-DFP_FAST_FMA=1 ";
|
||||
}
|
||||
|
||||
// F_IMAGES
|
||||
if (Options()->oVariables->ImageSupport) {
|
||||
systemPath << "-D__IMAGE_SUPPORT__=1 ";
|
||||
}
|
||||
|
||||
if (Options()->oVariables->FastFMA) {
|
||||
systemPath << "-DFP_FAST_FMA=1 ";
|
||||
}
|
||||
|
||||
if (Options()->oVariables->FastFMAF) {
|
||||
systemPath << "-DFP_FAST_FMAF=1 ";
|
||||
}
|
||||
|
||||
systemPath << "-D__AMD__=1 ";
|
||||
uint32_t chipName = elf->target.chip_id;
|
||||
assert(chipName < familySet[elf->target.arch_id].children_size && "Cannot index past end of array!");
|
||||
switch(elf->target.arch_id) {
|
||||
default:
|
||||
assert(!"Unknown target device ID!");
|
||||
case aclX64:
|
||||
systemPath << "--march=x86-64 -D__X86_64__=1 -D__" << X64TargetMapping[chipName].chip_name << "__=1 ";
|
||||
break;
|
||||
case aclX86:
|
||||
systemPath << "--march=x86 -D__X86__=1 -D__" << X86TargetMapping[chipName].chip_name << "__=1 ";
|
||||
break;
|
||||
case aclAMDIL:
|
||||
systemPath << "-D__AMDIL__ -D__" << AMDILTargetMapping[chipName].chip_name << "__=1 ";
|
||||
break;
|
||||
case aclAMDIL64:
|
||||
systemPath << "--march=gpu-64 -D__AMDIL_64__ -D__" << AMDIL64TargetMapping[chipName].chip_name << "__=1 ";
|
||||
break;
|
||||
case aclHSAIL:
|
||||
systemPath << "--march=hsail -D__HSAIL__ -D__" << HSAILTargetMapping[chipName].chip_name << "__=1 ";
|
||||
break;
|
||||
case aclHSAIL64:
|
||||
systemPath << "--march=hsail64 -D__HSAIL__ -D__" << HSAIL64TargetMapping[chipName].chip_name << "__=1 ";
|
||||
break;
|
||||
};
|
||||
// AMDIL and non CPU HSAIL targets get the GPU define, everything
|
||||
// else gets CPU define.
|
||||
if (!isCpuTarget(elf->target)) {
|
||||
systemPath << "-D__GPU__=1 ";
|
||||
} else {
|
||||
systemPath << "-D__CPU__=1 ";
|
||||
}
|
||||
|
||||
if (elf->target.arch_id == aclAMDIL
|
||||
&& AMDILTargetMapping[chipName].family_enum == FAMILY_RV7XX) {
|
||||
systemPath << "-Dcl_amd_vec3=1 -Dcl_amd_printf=1 --opencl=1.0";
|
||||
}
|
||||
|
||||
if (Opts) {
|
||||
systemPath << Opts->clcOptions;
|
||||
}
|
||||
|
||||
#ifdef WITH_TARGET_HSAIL
|
||||
if ((Is64bitMachine() && isHSAILTarget(elf->target)) ||
|
||||
(Opts->oVariables->GPU64BitIsa && (elf->target.arch_id == aclHSAIL)))
|
||||
systemPath << " --march=hsail64 ";
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
const char* env = getenv("AMD_EDG_OPTIONS");
|
||||
if (env)
|
||||
systemPath << env << " ";
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
if (!getenv("AMD_OCL_SHOW_COMPILER_OUTPUT"))
|
||||
#endif
|
||||
systemPath << " --error_output \"" << logFile << "\" ";
|
||||
if(preprocessOnly) {
|
||||
std::string clppFileName = Opts->getDumpFileName(".i");
|
||||
systemPath << " -E -o \"" << clppFileName << "\"";
|
||||
}
|
||||
systemPath << " \"" << clFile << "\" ";
|
||||
|
||||
LogPrintfDebug("Invoking CL to LLVM binary compilation:\n %s",
|
||||
systemPath.str().c_str());
|
||||
|
||||
#ifdef DEBUG
|
||||
if(getenv("AMD_OCL_SHOW_CMD_LINE"))
|
||||
std::cout << "command line: " << systemPath.str() << std::endl;
|
||||
#endif
|
||||
|
||||
if (Opts && Opts->isDumpFlagSet(amd::option::DUMP_CL) && !preprocessOnly) {
|
||||
dumpSource(src, Opts);
|
||||
}
|
||||
std::string clcCmd = systemPath.str();
|
||||
return clcCmd;
|
||||
}
|
||||
// CLC_IN_PROCESS_CHANGE
|
||||
extern int openclFrontEnd(const char* cmdline, std::string*, std::string* typeInfo = NULL);
|
||||
|
||||
static std::string
|
||||
loadFileToStr(std::string file)
|
||||
{
|
||||
std::string str = "";
|
||||
std::ifstream log(file.c_str(), std::ios::in|std::ios::ate);
|
||||
if (log.is_open()) {
|
||||
size_t size = (size_t)log.tellg();
|
||||
log.seekg(0, std::ios::beg);
|
||||
std::vector<char> buffer(size+1);
|
||||
log.read(&buffer[0],size);
|
||||
log.close();
|
||||
//for safety
|
||||
buffer[size] = '\0';
|
||||
str += &buffer[0];
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
int
|
||||
amdcl::OCLFrontend::compileCommand(const std::string& singleSrc)
|
||||
{
|
||||
std::string tempFileName = amd::Os::getTempFileName();
|
||||
std::string logFile = tempFileName + ".log";
|
||||
std::string clFile = tempFileName + ".cl";
|
||||
std::string frontendCmd = getFrontendCommand(Elf(), singleSrc, logFile,
|
||||
clFile, false);
|
||||
std::string logStr;
|
||||
uint64_t start_time = 0, stop_time = 0;
|
||||
amd::option::Options* Opts = (amd::option::Options*)Elf()->options;
|
||||
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
start_time = amd::Os::timeNanos();
|
||||
}
|
||||
if (!checkFlag(aclutGetCaps(Elf()), capSaveSOURCE)) {
|
||||
CL()->clAPI.remSec(CL(), Elf(), aclSOURCE);
|
||||
}
|
||||
int ret = openclFrontEnd(frontendCmd.c_str(), &Source(), NULL);
|
||||
|
||||
// We dump the preprocessed code by invoking clc a second time after the
|
||||
// original call, just in case somthing really bad happens in the original
|
||||
// call.
|
||||
if (Opts && Opts->isDumpFlagSet(amd::option::DUMP_I)) {
|
||||
std::string pplogFile = tempFileName + "preprocess.log";
|
||||
std::string ppFrontendCmd =
|
||||
getFrontendCommand(Elf(), singleSrc, pplogFile, clFile, true);
|
||||
(void) openclFrontEnd(ppFrontendCmd.c_str(), &Source(), NULL);
|
||||
amd::Os::unlink(pplogFile.c_str());
|
||||
}
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
stop_time = amd::Os::timeNanos();
|
||||
std::stringstream tmp_ss;
|
||||
tmp_ss << " OpenCL FE time: " << (stop_time - start_time)/1000ULL
|
||||
<< "us\n";
|
||||
appendLogToCL(CL(), tmp_ss.str());
|
||||
}
|
||||
llvmbinary_ = loadBitcode(Source());
|
||||
if (!llvmbinary_) {
|
||||
ret |= 1;
|
||||
}
|
||||
if (!ret) {
|
||||
CL()->clAPI.insSec(CL(), Elf(), Source().data(), Source().size(), aclLLVMIR);
|
||||
}
|
||||
log_ += loadFileToStr(logFile);
|
||||
amd::Os::unlink(logFile.c_str());
|
||||
if (isCpuTarget(Elf()->target) && Options()->oVariables->EnableDebug) {
|
||||
Options()->sourceFileName_.assign(clFile);
|
||||
} else {
|
||||
amd::Os::unlink(clFile.c_str());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _BE_FRONTEND_HPP_
|
||||
#define _BE_FRONTEND_HPP_
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include "aclTypes.h"
|
||||
#include "compiler_stage.hpp"
|
||||
#include "utils/libUtils.h"
|
||||
|
||||
namespace amdcl
|
||||
{
|
||||
/*! \addtogroup CompilerLibrary
|
||||
*
|
||||
* \copydoc amdcl::Frontend
|
||||
*
|
||||
* @{
|
||||
* \brief Interface parent class for the frontend child classes.
|
||||
* This class should never be instantiated directly.
|
||||
*/
|
||||
class Frontend : public LLVMCompilerStage {
|
||||
Frontend(Frontend&); // DO NOT IMPLEMENT.
|
||||
Frontend(); // DO NOT IMPLEMENT.
|
||||
public:
|
||||
Frontend(aclCompiler* cl, aclBinary* elf, aclLogFunction log)
|
||||
: LLVMCompilerStage(cl, elf, log) {}
|
||||
//! Virtual destructer that makes sure everything is cleaned up.
|
||||
virtual ~Frontend() {}
|
||||
|
||||
//! Function that converts from OpenCL singleSrc into
|
||||
// OpenCL formatted LLVM-IR stored as a std::string.
|
||||
// This function generates a command string for clc to execute.
|
||||
virtual int compileCommand(const std::string& singleSrc) = 0;
|
||||
|
||||
virtual std::string getClassName() = 0;
|
||||
|
||||
//! Dumps source CL text with compiler options in a file.
|
||||
void dumpSource(const std::string& src, amd::option::Options* opts) {
|
||||
std::ofstream f(opts->getDumpFileName(".cl").c_str(), std::ios::trunc);
|
||||
if(f.is_open()) {
|
||||
f << "/* Compiler options:\n" << opts->origOptionStr << "\n*/\n\n" << src;
|
||||
} else {
|
||||
appendLogToCL(CL(), "File for dumping source cl isn't opened");
|
||||
}
|
||||
}
|
||||
}; // class Frontend
|
||||
/*@}*/
|
||||
|
||||
/*! \addtogroup CompilerLibrary
|
||||
*
|
||||
* \copydoc amdcl::OCLFrontend
|
||||
*
|
||||
* @{
|
||||
* \brief Implementation of the Frontend interface to compile
|
||||
* from OpenCL C to LLVM-IR.
|
||||
*/
|
||||
class OCLFrontend : public Frontend {
|
||||
OCLFrontend(OCLFrontend&); // DO NOT IMPLEMENT.
|
||||
OCLFrontend(); // DO NOT IMPLEMENT.
|
||||
|
||||
void appendCLVersionFlag(
|
||||
std::stringstream &ss,
|
||||
const amd::option::Options *opts);
|
||||
|
||||
std::string getFrontendCommand(
|
||||
aclBinary *elf,
|
||||
const std::string &src,
|
||||
std::string &logFile,
|
||||
std::string &clFile,
|
||||
bool preprocessOnly);
|
||||
|
||||
public:
|
||||
OCLFrontend(aclCompiler* cl, aclBinary* elf, aclLogFunction log)
|
||||
: Frontend(cl, elf, log) {}
|
||||
|
||||
virtual ~OCLFrontend() {}
|
||||
|
||||
//! Function that converts from OpenCL singleSrc into
|
||||
// OpenCL formatted LLVM-IR stored as a std::string.
|
||||
// This function generates a command string for clc to execute.
|
||||
virtual int compileCommand(const std::string& singleSrc);
|
||||
|
||||
virtual std::string getClassName() {return "OCLFrontend";}
|
||||
}; // class OCLFrontend
|
||||
/*@}*/
|
||||
|
||||
|
||||
/*! \addtogroup CompilerLibrary
|
||||
*
|
||||
* \copydoc amdcl::Frontend
|
||||
*
|
||||
* @{
|
||||
* \brief This is the class which calls the clang front-end.
|
||||
* This class will be used if user asks for it (By default EDG will be
|
||||
* called).
|
||||
*/
|
||||
class ClangOCLFrontend : public Frontend {
|
||||
//! Options to be passed to the ClangOCLFE library.
|
||||
|
||||
public:
|
||||
ClangOCLFrontend(aclCompiler* cl, aclBinary* elf, aclLogFunction log);
|
||||
|
||||
//! Virtual destructer that makes sure everything is cleaned up.
|
||||
virtual ~ClangOCLFrontend() {}
|
||||
|
||||
//! This function generates a command string for ClangOCLFE to execute.
|
||||
virtual int compileCommand(const std::string& singleSrc);
|
||||
|
||||
virtual std::string getClassName() {return "ClangOCLFrontend";}
|
||||
}; // class Frontend
|
||||
/*@}*/
|
||||
} // namespac amdcl
|
||||
#endif // _BE_FRONTEND_HPP_
|
||||
@@ -1,232 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#include "OpenCLFE.h"
|
||||
|
||||
#include "bif/bifbase.hpp"
|
||||
#include "frontend.hpp"
|
||||
#include "os/os.hpp"
|
||||
#include "top.hpp"
|
||||
#include "utils/options.hpp"
|
||||
#include "utils/target_mappings.h"
|
||||
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Support/SPIRV.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
amdcl::ClangOCLFrontend::ClangOCLFrontend(aclCompiler* cl, aclBinary* elf,
|
||||
aclLogFunction log)
|
||||
: Frontend(cl, elf, log){}
|
||||
|
||||
/// @brief This function generates the required command-line options to
|
||||
/// call the ClangOCLFE library.
|
||||
int amdcl::ClangOCLFrontend::compileCommand(const std::string& src) {
|
||||
|
||||
std::vector<const char*> argsToClang;
|
||||
std::string tempFileName = amd::Os::getTempFileName();
|
||||
std::string logFileName = tempFileName + ".log";
|
||||
std::string inpCLFileName = tempFileName + ".cl";
|
||||
std::string logFromClang;
|
||||
int ret = 0;
|
||||
|
||||
aclBinary *elf = Elf();
|
||||
amd::option::Options* amdOpts = (amd::option::Options*)elf->options;
|
||||
|
||||
// Following are the options passed to the ClangOCLFE library
|
||||
// and then to Clang itself.
|
||||
|
||||
// handle -O0
|
||||
if (amdOpts && amdOpts->origOptionStr.find("-O0") != std::string::npos) {
|
||||
amdOpts->clangOptions.push_back("-O0");
|
||||
}
|
||||
|
||||
// Passing the compiler FE options to clang.
|
||||
if (amdOpts) {
|
||||
for (std::vector<std::string>::const_iterator it = amdOpts->clangOptions.begin();
|
||||
it != amdOpts->clangOptions.end(); ++it) {
|
||||
if ("-g" == *it) {
|
||||
argsToClang.push_back("-dwarf-version=2");
|
||||
argsToClang.push_back("-debug-info-kind=standalone");
|
||||
} else {
|
||||
argsToClang.push_back((*it).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Options()->oVariables->ImageSupport) {
|
||||
argsToClang.push_back ("-D__IMAGE_SUPPORT__=1 ");
|
||||
}
|
||||
|
||||
if (Options()->oVariables->FastFMA) {
|
||||
argsToClang.push_back ("-DFP_FAST_FMA=1 ");
|
||||
}
|
||||
|
||||
if (Options()->oVariables->FastFMAF) {
|
||||
argsToClang.push_back ("-DFP_FAST_FMAF=1 ");
|
||||
}
|
||||
|
||||
argsToClang.push_back ("-D__AMD__=1 ");
|
||||
|
||||
if (Options()->oVariables->FEGenSPIRV) {
|
||||
argsToClang.push_back("-D__AMD_SPIRV__ ");
|
||||
}
|
||||
|
||||
// Other options are passed using OptionsInfo structure.
|
||||
clc2::OptionsInfo ClangOptions;
|
||||
|
||||
ClangOptions.InFilename = inpCLFileName;
|
||||
|
||||
// Generate target triple.
|
||||
// TODO: Refine the triple as necessary.
|
||||
uint32_t chipName = elf->target.chip_id;
|
||||
assert(chipName < familySet[elf->target.arch_id].children_size &&
|
||||
"Cannot index past end of array!");
|
||||
switch (elf->target.arch_id) {
|
||||
default:
|
||||
log_ += "\nerror: Unknown target device ID!\n";
|
||||
ret |= 1;
|
||||
return ret;
|
||||
break;
|
||||
case aclX86:
|
||||
case aclAMDIL:
|
||||
case aclHSAIL:
|
||||
// See bug: http://ocltc.amd.com/bugs/show_bug.cgi?id=9631
|
||||
if (sizeof(void*) != 4) {
|
||||
log_ += "\nerror: 32-bit kernels not supported on a 64-bit executable\n";
|
||||
ret |= 1;
|
||||
return ret;
|
||||
}
|
||||
ClangOptions.TargetArch = llvm::Triple::spir;
|
||||
break;
|
||||
case aclX64:
|
||||
case aclAMDIL64:
|
||||
case aclHSAIL64:
|
||||
// See bug: http://ocltc.amd.com/bugs/show_bug.cgi?id=9631
|
||||
if (sizeof(void*) != 8) {
|
||||
log_ += "\nerror: 64-bit kernels not supported on a 32-bit executable\n";
|
||||
ret |= 1;
|
||||
return ret;
|
||||
}
|
||||
ClangOptions.TargetArch = llvm::Triple::spir64;
|
||||
break;
|
||||
};
|
||||
|
||||
// Copy the source to a buffer. Note that the input
|
||||
// file itself is not passed to the ClangOCLFE library. It is a passed
|
||||
// as a string for compilation.
|
||||
|
||||
std::unique_ptr<llvm::MemoryBuffer> srcBufferPtr =
|
||||
llvm::MemoryBuffer::getMemBuffer(src, inpCLFileName.c_str(),
|
||||
true);
|
||||
ClangOptions.Src.swap(srcBufferPtr);
|
||||
assert(ClangOptions.Src.get() && "ClangOCLFE: Memory Buffer"
|
||||
" initialization error\n");
|
||||
|
||||
// Set Pre-processor output if user asks for it.
|
||||
if (amdOpts && amdOpts->isDumpFlagSet(amd::option::DUMP_I)) {
|
||||
ClangOptions.PreProcOut = amdOpts->getDumpFileName(".i");
|
||||
}
|
||||
|
||||
// Set the LLVMContext for the front-end compilation.
|
||||
// Clang needs to use a separate LLVMContext since the generated bitcode
|
||||
// needs to be loaded again. Using the same LLVMContext causes name collision
|
||||
// for named struct types in bitcode loader.
|
||||
llvm::LLVMContext ClangCtx;
|
||||
ClangOptions.CompilerContext = &ClangCtx;
|
||||
|
||||
if (amdOpts && amdOpts->isDumpFlagSet(amd::option::DUMP_CL)) {
|
||||
dumpSource(src, amdOpts);
|
||||
}
|
||||
|
||||
//Start the compilation
|
||||
uint64_t start_time = 0, stop_time = 0;
|
||||
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
start_time = amd::Os::timeNanos();
|
||||
}
|
||||
|
||||
if (!checkFlag(aclutGetCaps(Elf()), capSaveSOURCE)) {
|
||||
CL()->clAPI.remSec(CL(), Elf(), aclSOURCE);
|
||||
}
|
||||
|
||||
// Pass OpenCL version option to Clang
|
||||
llvm::StringRef OCLVer(amdOpts->oVariables->CLStd);
|
||||
if (OCLVer.equals("CL1.2")) {
|
||||
ClangOptions.OCLVer = clc2::OCL_12;
|
||||
} else if (OCLVer.equals("CL2.0")) {
|
||||
ClangOptions.OCLVer = clc2::OCL_20;
|
||||
} else {
|
||||
llvm_unreachable("Unknown OpenCL version");
|
||||
}
|
||||
|
||||
// Call the Clang Front-end to generate serialized llvm::Module
|
||||
// from the OpenCL source.
|
||||
#ifdef ANDROID
|
||||
// We will not exercise Clang for RenderScript.
|
||||
log_ += "\nerror: Clang front-end compilation unsupported on Android!\n";
|
||||
ret |= 1;
|
||||
return ret;
|
||||
#else
|
||||
if (!parseOCLSource(ClangOptions, argsToClang, &Source(), &logFromClang)) {
|
||||
log_ += logFromClang;
|
||||
log_ += "\nerror: Clang front-end compilation failed!\n";
|
||||
ret |= 1;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
stop_time = amd::Os::timeNanos();
|
||||
std::stringstream tmp_ss;
|
||||
tmp_ss << " OpenCL FE time: "
|
||||
<< (stop_time - start_time)/1000ULL
|
||||
<< "us\n";
|
||||
appendLogToCL(CL(), tmp_ss.str());
|
||||
}
|
||||
|
||||
llvmbinary_ = loadBitcode(Source());
|
||||
|
||||
if (!llvmbinary_) {
|
||||
ret |= 1;
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
CL()->clAPI.insSec(CL(), Elf(), Source().data(), Source().size(), aclLLVMIR);
|
||||
}
|
||||
|
||||
if (Options()->oVariables->FEGenSPIRV) {
|
||||
std::string s;
|
||||
llvm::raw_string_ostream ss(s);
|
||||
std::string err;
|
||||
|
||||
if (Options()->getLLVMArgc()) {
|
||||
llvm::cl::ParseCommandLineOptions(Options()->getLLVMArgc(),
|
||||
Options()->getLLVMArgv(), "LLVM/SPIRV converter");
|
||||
}
|
||||
if (WriteSPIRV(llvmbinary_, ss, err)) {
|
||||
std::string img = ss.str();
|
||||
CL()->clAPI.insSec(CL(), Elf(), img.data(), img.size(), aclSPIRV);
|
||||
}
|
||||
|
||||
if (!log_.empty())
|
||||
log_ += std::string(" ");
|
||||
log_ += err;
|
||||
}
|
||||
|
||||
log_ += logFromClang;
|
||||
if (isCpuTarget(Elf()->target)
|
||||
&& Options()->oVariables->EnableDebug) {
|
||||
Options()->sourceFileName_ = inpCLFileName;
|
||||
} else {
|
||||
amd::Os::unlink(inpCLFileName.c_str());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _IF_ACL_H_
|
||||
#define _IF_ACL_H_
|
||||
#include "aclTypes.h"
|
||||
#include "v0_8/if_acl.h"
|
||||
#endif // _IF_ACL_H_
|
||||
@@ -1,293 +0,0 @@
|
||||
|
||||
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "top.hpp"
|
||||
#include "aclTypes.h"
|
||||
#include "library.hpp"
|
||||
#include "utils/options.hpp"
|
||||
|
||||
namespace amd {
|
||||
|
||||
/*
|
||||
Integrated bitcode libraries
|
||||
*/
|
||||
|
||||
// GPU libraries
|
||||
#if defined(WITH_TARGET_AMDIL)
|
||||
#include "builtins-gpugen-comm.inc"
|
||||
#include "builtins-gpugen-diff.gpu.inc"
|
||||
#include "builtins-gpugen-diff.gpu-64.inc"
|
||||
#include "builtins-gpucommon-comm.inc"
|
||||
#include "builtins-gpucommon-diff.gpu.inc"
|
||||
#include "builtins-gpucommon-diff.gpu-64.inc"
|
||||
#include "builtins-SI-comm.inc"
|
||||
#include "builtins-SI-diff.gpu.inc"
|
||||
#include "builtins-SI-diff.gpu-64.inc"
|
||||
#include "builtins-CI-comm.inc"
|
||||
#include "builtins-CI-diff.gpu.inc"
|
||||
#include "builtins-CI-diff.gpu-64.inc"
|
||||
#endif // WITH_TARGET_AMDIL
|
||||
|
||||
// CPU libraries
|
||||
#if defined(WITH_TARGET_X86)
|
||||
#include "builtins-cpugen.x86.inc"
|
||||
#include "builtins-cpucommon.x86.inc"
|
||||
#include "builtins-avx.x86.inc"
|
||||
#include "builtins-fma4.x86.inc"
|
||||
#include "builtins-cpugen.x86-64.inc"
|
||||
#include "builtins-cpucommon.x86-64.inc"
|
||||
#include "builtins-avx.x86-64.inc"
|
||||
#include "builtins-fma4.x86-64.inc"
|
||||
#endif // WITH_TARGET_X86
|
||||
|
||||
#if defined(WITH_TARGET_ARM)
|
||||
#include "builtins-cpugen.arm.inc"
|
||||
#include "builtins-cpucommon.arm.inc"
|
||||
#endif // WITH_TARGET_ARM
|
||||
|
||||
#ifdef WITH_TARGET_HSAIL
|
||||
// HSAIL libraries
|
||||
#include "builtins-hsail.inc"
|
||||
#include "builtins-gcn.inc"
|
||||
#include "builtins-ocml.inc"
|
||||
#include "builtins-spirv.inc"
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
// getLibsDesc() : returns a list of libraries that need to be linked with the
|
||||
// application. The max number of libraries is defined by
|
||||
// enum MAX_NUM_LIBRARY_DESCS in class LibraryDescriptor.
|
||||
//
|
||||
// Return 0: successful
|
||||
// <n>: error happened
|
||||
int
|
||||
getLibDescs (
|
||||
LibrarySelector LibType, // input
|
||||
LibraryDescriptor* LibDesc, // output
|
||||
int& LibDescSize // output -- LibDesc[0:LibDescSize-1]
|
||||
)
|
||||
{
|
||||
switch (LibType) {
|
||||
#if defined(WITH_TARGET_AMDIL)
|
||||
case GPU_Library_Evergreen:
|
||||
// Library order is important!
|
||||
LibDesc[0].start = reinterpret_cast<const char*>
|
||||
(builtins_gpucommon_comm);
|
||||
LibDesc[0].size = builtins_gpucommon_comm_size;
|
||||
LibDesc[1].start = reinterpret_cast<const char*>
|
||||
(builtins_gpucommon_diff_gpu);
|
||||
LibDesc[1].size = builtins_gpucommon_diff_gpu_size;
|
||||
LibDesc[2].start = reinterpret_cast<const char*>
|
||||
(builtins_gpugen_comm);
|
||||
LibDesc[2].size = builtins_gpugen_comm_size;
|
||||
LibDesc[3].start = reinterpret_cast<const char*>
|
||||
(builtins_gpugen_diff_gpu);
|
||||
LibDesc[3].size = builtins_gpugen_diff_gpu_size;
|
||||
LibDescSize = 4;
|
||||
break;
|
||||
|
||||
case GPU_Library_SI:
|
||||
// Library order is important!
|
||||
LibDesc[0].start = reinterpret_cast<const char*>
|
||||
(builtins_SI_comm);
|
||||
LibDesc[0].size = builtins_SI_comm_size;
|
||||
LibDesc[1].start = reinterpret_cast<const char*>
|
||||
(builtins_SI_diff_gpu);
|
||||
LibDesc[1].size = builtins_SI_diff_gpu_size;
|
||||
LibDesc[2].start = reinterpret_cast<const char*>
|
||||
(builtins_gpucommon_comm);
|
||||
LibDesc[2].size = builtins_gpucommon_comm_size;
|
||||
LibDesc[3].start = reinterpret_cast<const char*>
|
||||
(builtins_gpucommon_diff_gpu);
|
||||
LibDesc[3].size = builtins_gpucommon_diff_gpu_size;
|
||||
LibDesc[4].start = reinterpret_cast<const char*>
|
||||
(builtins_gpugen_comm);
|
||||
LibDesc[4].size = builtins_gpugen_comm_size;
|
||||
LibDesc[5].start = reinterpret_cast<const char*>
|
||||
(builtins_gpugen_diff_gpu);
|
||||
LibDesc[5].size = builtins_gpugen_diff_gpu_size;
|
||||
LibDescSize = 6;
|
||||
break;
|
||||
|
||||
case GPU64_Library_SI:
|
||||
// Library order is important!
|
||||
LibDesc[0].start = reinterpret_cast<const char*>
|
||||
(builtins_SI_comm);
|
||||
LibDesc[0].size = builtins_SI_comm_size;
|
||||
LibDesc[1].start = reinterpret_cast<const char*>
|
||||
(builtins_SI_diff_gpu_64);
|
||||
LibDesc[1].size = builtins_SI_diff_gpu_64_size;
|
||||
LibDesc[2].start = reinterpret_cast<const char*>
|
||||
(builtins_gpucommon_comm);
|
||||
LibDesc[2].size = builtins_gpucommon_comm_size;
|
||||
LibDesc[3].start = reinterpret_cast<const char*>
|
||||
(builtins_gpucommon_diff_gpu_64);
|
||||
LibDesc[3].size = builtins_gpucommon_diff_gpu_64_size;
|
||||
LibDesc[4].start = reinterpret_cast<const char*>
|
||||
(builtins_gpugen_comm);
|
||||
LibDesc[4].size = builtins_gpugen_comm_size;
|
||||
LibDesc[5].start = reinterpret_cast<const char*>
|
||||
(builtins_gpugen_diff_gpu_64);
|
||||
LibDesc[5].size = builtins_gpugen_diff_gpu_64_size;
|
||||
LibDescSize = 6;
|
||||
break;
|
||||
|
||||
case GPU_Library_CI:
|
||||
// Library order is important!
|
||||
LibDesc[0].start = reinterpret_cast<const char*>
|
||||
(builtins_CI_comm);
|
||||
LibDesc[0].size = builtins_CI_comm_size;
|
||||
LibDesc[1].start = reinterpret_cast<const char*>
|
||||
(builtins_CI_diff_gpu);
|
||||
LibDesc[1].size = builtins_CI_diff_gpu_size;
|
||||
LibDesc[2].start = reinterpret_cast<const char*>
|
||||
(builtins_SI_comm);
|
||||
LibDesc[2].size = builtins_SI_comm_size;
|
||||
LibDesc[3].start = reinterpret_cast<const char*>
|
||||
(builtins_SI_diff_gpu);
|
||||
LibDesc[3].size = builtins_SI_diff_gpu_size;
|
||||
LibDesc[4].start = reinterpret_cast<const char*>
|
||||
(builtins_gpucommon_comm);
|
||||
LibDesc[4].size = builtins_gpucommon_comm_size;
|
||||
LibDesc[5].start = reinterpret_cast<const char*>
|
||||
(builtins_gpucommon_diff_gpu);
|
||||
LibDesc[5].size = builtins_gpucommon_diff_gpu_size;
|
||||
LibDesc[6].start = reinterpret_cast<const char*>
|
||||
(builtins_gpugen_comm);
|
||||
LibDesc[6].size = builtins_gpugen_comm_size;
|
||||
LibDesc[7].start = reinterpret_cast<const char*>
|
||||
(builtins_gpugen_diff_gpu);
|
||||
LibDesc[7].size = builtins_gpugen_diff_gpu_size;
|
||||
LibDescSize = 8;
|
||||
break;
|
||||
|
||||
case GPU64_Library_CI:
|
||||
// Library order is important!
|
||||
LibDesc[0].start = reinterpret_cast<const char*>
|
||||
(builtins_CI_comm);
|
||||
LibDesc[0].size = builtins_CI_comm_size;
|
||||
LibDesc[1].start = reinterpret_cast<const char*>
|
||||
(builtins_CI_diff_gpu_64);
|
||||
LibDesc[1].size = builtins_CI_diff_gpu_64_size;
|
||||
LibDesc[2].start = reinterpret_cast<const char*>
|
||||
(builtins_SI_comm);
|
||||
LibDesc[2].size = builtins_SI_comm_size;
|
||||
LibDesc[3].start = reinterpret_cast<const char*>
|
||||
(builtins_SI_diff_gpu_64);
|
||||
LibDesc[3].size = builtins_SI_diff_gpu_64_size;
|
||||
LibDesc[4].start = reinterpret_cast<const char*>
|
||||
(builtins_gpucommon_comm);
|
||||
LibDesc[4].size = builtins_gpucommon_comm_size;
|
||||
LibDesc[5].start = reinterpret_cast<const char*>
|
||||
(builtins_gpucommon_diff_gpu_64);
|
||||
LibDesc[5].size = builtins_gpucommon_diff_gpu_64_size;
|
||||
LibDesc[6].start = reinterpret_cast<const char*>
|
||||
(builtins_gpugen_comm);
|
||||
LibDesc[6].size = builtins_gpugen_comm_size;
|
||||
LibDesc[7].start = reinterpret_cast<const char*>
|
||||
(builtins_gpugen_diff_gpu_64);
|
||||
LibDesc[7].size = builtins_gpugen_diff_gpu_64_size;
|
||||
LibDescSize = 8;
|
||||
break;
|
||||
|
||||
#endif // WITH_TARGET_AMDIL
|
||||
|
||||
#if defined(WITH_TARGET_X86)
|
||||
case CPU64_Library_Generic:
|
||||
LibDesc[0].start = reinterpret_cast<const char*>(builtins_cpucommon_x86_64);
|
||||
LibDesc[0].size = builtins_cpucommon_x86_64_size;
|
||||
LibDesc[1].start = reinterpret_cast<const char*>(builtins_cpugen_x86_64);
|
||||
LibDesc[1].size = builtins_cpugen_x86_64_size;
|
||||
LibDescSize = 2;
|
||||
break;
|
||||
|
||||
case CPU64_Library_AVX:
|
||||
LibDesc[0].start = reinterpret_cast<const char*>(builtins_avx_x86_64);
|
||||
LibDesc[0].size = builtins_avx_x86_64_size;
|
||||
LibDesc[1].start = reinterpret_cast<const char*>(builtins_cpucommon_x86_64);
|
||||
LibDesc[1].size = builtins_cpucommon_x86_64_size;
|
||||
LibDesc[2].start = reinterpret_cast<const char*>(builtins_cpugen_x86_64);
|
||||
LibDesc[2].size = builtins_cpugen_x86_64_size;
|
||||
LibDescSize = 3;
|
||||
break;
|
||||
|
||||
case CPU64_Library_FMA4:
|
||||
LibDesc[0].start = reinterpret_cast<const char*>(builtins_fma4_x86_64);
|
||||
LibDesc[0].size = builtins_fma4_x86_64_size;
|
||||
LibDesc[1].start = reinterpret_cast<const char*>(builtins_avx_x86_64);
|
||||
LibDesc[1].size = builtins_avx_x86_64_size;
|
||||
LibDesc[2].start = reinterpret_cast<const char*>(builtins_cpucommon_x86_64);
|
||||
LibDesc[2].size = builtins_cpucommon_x86_64_size;
|
||||
LibDesc[3].start = reinterpret_cast<const char*>(builtins_cpugen_x86_64);
|
||||
LibDesc[3].size = builtins_cpugen_x86_64_size;
|
||||
LibDescSize = 4;
|
||||
break;
|
||||
|
||||
case CPU_Library_Generic:
|
||||
LibDesc[0].start = reinterpret_cast<const char*>(builtins_cpucommon_x86);
|
||||
LibDesc[0].size = builtins_cpucommon_x86_size;
|
||||
LibDesc[1].start = reinterpret_cast<const char*>(builtins_cpugen_x86);
|
||||
LibDesc[1].size = builtins_cpugen_x86_size;
|
||||
LibDescSize = 2;
|
||||
break;
|
||||
|
||||
case CPU_Library_AVX:
|
||||
LibDesc[0].start = reinterpret_cast<const char*>(builtins_avx_x86);
|
||||
LibDesc[0].size = builtins_avx_x86_size;
|
||||
LibDesc[1].start = reinterpret_cast<const char*>(builtins_cpucommon_x86);
|
||||
LibDesc[1].size = builtins_cpucommon_x86_size;
|
||||
LibDesc[2].start = reinterpret_cast<const char*>(builtins_cpugen_x86);
|
||||
LibDesc[2].size = builtins_cpugen_x86_size;
|
||||
LibDescSize = 3;
|
||||
break;
|
||||
|
||||
case CPU_Library_FMA4:
|
||||
LibDesc[0].start = reinterpret_cast<const char*>(builtins_fma4_x86);
|
||||
LibDesc[0].size = builtins_fma4_x86_size;
|
||||
LibDesc[1].start = reinterpret_cast<const char*>(builtins_avx_x86);
|
||||
LibDesc[1].size = builtins_avx_x86_size;
|
||||
LibDesc[2].start = reinterpret_cast<const char*>(builtins_cpucommon_x86);
|
||||
LibDesc[2].size = builtins_cpucommon_x86_size;
|
||||
LibDesc[3].start = reinterpret_cast<const char*>(builtins_cpugen_x86);
|
||||
LibDesc[3].size = builtins_cpugen_x86_size;
|
||||
LibDescSize = 4;
|
||||
break;
|
||||
#endif // WITH_TARGET_X86
|
||||
|
||||
#if defined(WITH_TARGET_ARM)
|
||||
case CPU_Library_Generic:
|
||||
LibDesc[0].start = reinterpret_cast<const char*>(builtins_cpucommon_arm);
|
||||
LibDesc[0].size = builtins_cpucommon_arm_size;
|
||||
LibDesc[1].start = reinterpret_cast<const char*>(builtins_cpugen_arm);
|
||||
LibDesc[1].size = builtins_cpugen_arm_size;
|
||||
LibDescSize = 2;
|
||||
break;
|
||||
#endif // WITH_TARGET_ARM
|
||||
|
||||
#if defined(WITH_TARGET_HSAIL)
|
||||
case GPU_Library_HSAIL:
|
||||
// Library order is important!
|
||||
LibDesc[0].start = reinterpret_cast<const char*>(builtins_gcn);
|
||||
LibDesc[0].size = builtins_gcn_size;
|
||||
LibDesc[1].start = reinterpret_cast<const char*>(builtins_hsail);
|
||||
LibDesc[1].size = builtins_hsail_size;
|
||||
LibDesc[2].start = reinterpret_cast<const char*>(builtins_ocml);
|
||||
LibDesc[2].size = builtins_ocml_size;
|
||||
LibDesc[3].start = reinterpret_cast<const char*>(builtins_spirv);
|
||||
LibDesc[3].size = builtins_spirv_size;
|
||||
LibDescSize = 4;
|
||||
break;
|
||||
#endif // WITH_TARGET_HSAIL
|
||||
|
||||
default:
|
||||
// Failed
|
||||
return 1; //
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace amd
|
||||
@@ -1,753 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// TODO: The entire linker implementation should be a pass in LLVM and
|
||||
// the code in the compiler library should only call this pass.
|
||||
|
||||
#include "top.hpp"
|
||||
#include "library.hpp"
|
||||
#include "linker.hpp"
|
||||
#include "os/os.hpp"
|
||||
#include "thread/monitor.hpp"
|
||||
#include "utils/libUtils.h"
|
||||
#include "utils/options.hpp"
|
||||
#include "utils/target_mappings.h"
|
||||
|
||||
#include "acl.h"
|
||||
#if !defined(LEGACY_COMPLIB)
|
||||
#define HAS_SPIRV
|
||||
#endif
|
||||
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Linker.h"
|
||||
#include "llvm/LLVMContext.h"
|
||||
#include "llvm/GlobalValue.h"
|
||||
#include "llvm/GlobalVariable.h"
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/Support/CallSite.h"
|
||||
#include "llvm/Support/system_error.h"
|
||||
#include "llvm/DataLayout.h"
|
||||
#include "llvm/ValueSymbolTable.h"
|
||||
#ifdef _DEBUG
|
||||
#include "llvm/Assembly/Writer.h"
|
||||
#endif
|
||||
#else
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/CallSite.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/GlobalValue.h"
|
||||
#include "llvm/IR/GlobalVariable.h"
|
||||
#include "llvm/IR/ValueSymbolTable.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/Linker/Linker.h"
|
||||
#endif
|
||||
|
||||
#ifndef LEGACY_COMPLIB
|
||||
#include "AMDFixupKernelModule.h"
|
||||
#include "AMDResolveLinker.h"
|
||||
#include "AMDPrelink.h"
|
||||
#else
|
||||
#include "llvm/AMDFixupKernelModule.h"
|
||||
#include "llvm/AMDResolveLinker.h"
|
||||
#include "llvm/AMDPrelink.h"
|
||||
#endif
|
||||
|
||||
#include "llvm/AMDUtils.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/Analysis/AMDLocalArrayUsage.h"
|
||||
#include "llvm/Analysis/LoopPass.h"
|
||||
#include "llvm/Analysis/Passes.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
|
||||
#include "llvm/CodeGen/LinkAllAsmWriterComponents.h"
|
||||
#include "llvm/CodeGen/LinkAllCodegenComponents.h"
|
||||
#include "llvm/Config/config.h"
|
||||
|
||||
#include "llvm/MC/SubtargetFeature.h"
|
||||
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include "llvm/Support/FileUtilities.h"
|
||||
#include "llvm/Support/FormattedStream.h"
|
||||
#include "llvm/Support/Host.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
#include "llvm/Support/PluginLoader.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Support/Signals.h"
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetOptions.h"
|
||||
|
||||
#include "llvm/Transforms/IPO.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/AMDLLVMContextHook.h"
|
||||
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
#include "llvm/AMDILFuncSupport.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAS_SPIRV
|
||||
#include "llvm/Support/SPIRV.h"
|
||||
#endif
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif // _WIN32
|
||||
|
||||
#define DEBUG_TYPE "ocl_linker"
|
||||
|
||||
namespace AMDSpir {
|
||||
extern void replaceTrivialFunc(llvm::Module& M);
|
||||
}
|
||||
namespace amd {
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
// LoadFile - Read the specified bitcode file in and return it. This routine
|
||||
// searches the link path for the specified file to try to find it...
|
||||
//
|
||||
inline llvm::Module*
|
||||
LoadFile(const std::string &Filename, LLVMContext& Context)
|
||||
{
|
||||
if (!sys::fs::exists(Filename)) {
|
||||
// dbgs() << "Bitcode file: '" << Filename.c_str() << "' does not exist.\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
llvm::Module* M;
|
||||
std::string ErrorMessage;
|
||||
OwningPtr<MemoryBuffer> Buffer;
|
||||
if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buffer)) {
|
||||
// Error
|
||||
M = NULL;
|
||||
}
|
||||
else {
|
||||
M = ParseBitcodeFile(Buffer.get(), Context, &ErrorMessage);
|
||||
}
|
||||
|
||||
return M;
|
||||
#else
|
||||
ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr = MemoryBuffer::getFileOrSTDIN(Filename);
|
||||
if (!FileOrErr) {
|
||||
auto ModuleOrErr = llvm::parseBitcodeFile(FileOrErr.get()->getMemBufferRef(), Context);
|
||||
if (!ModuleOrErr.getError()) return ModuleOrErr.get().release();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
inline llvm::Module*
|
||||
LoadLibrary(const std::string& libFile, LLVMContext& Context, MemoryBuffer** Buffer) {
|
||||
if (!sys::fs::exists(libFile)) {
|
||||
// dbgs() << "Bitcode file: '" << Filename.c_str() << "' does not exist.\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
llvm::Module* M = NULL;
|
||||
std::string ErrorMessage;
|
||||
|
||||
static Monitor mapLock;
|
||||
static std::map<std::string, void*> FileMap;
|
||||
MemoryBuffer* statBuffer;
|
||||
{
|
||||
ScopedLock sl(mapLock);
|
||||
statBuffer = (MemoryBuffer*) FileMap[libFile];
|
||||
if (statBuffer == NULL) {
|
||||
OwningPtr<MemoryBuffer> PtrBuffer;
|
||||
if (error_code ec = MemoryBuffer::getFileOrSTDIN(libFile, PtrBuffer)) {
|
||||
// Error
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
statBuffer = PtrBuffer.take();
|
||||
M = ParseBitcodeFile(statBuffer, Context, &ErrorMessage);
|
||||
FileMap[libFile] = statBuffer;
|
||||
}
|
||||
}
|
||||
*Buffer = MemoryBuffer::getMemBufferCopy(StringRef(statBuffer->getBufferStart(), statBuffer->getBufferSize()), "");
|
||||
if ( *Buffer ) {
|
||||
M = getLazyBitcodeModule(*Buffer, Context, &ErrorMessage);
|
||||
if (!M) {
|
||||
delete *Buffer;
|
||||
*Buffer = 0;
|
||||
}
|
||||
}
|
||||
return M;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Load bitcode libary from an array of const char. This assumes that
|
||||
// the array has a valid ending zero !
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
llvm::Module*
|
||||
LoadLibrary(const char* libBC, size_t libBCSize,
|
||||
LLVMContext& Context, MemoryBuffer** Buffer)
|
||||
{
|
||||
llvm::Module* M = 0;
|
||||
std::string ErrorMessage;
|
||||
|
||||
*Buffer = MemoryBuffer::getMemBuffer(StringRef(libBC, libBCSize), "");
|
||||
if ( *Buffer ) {
|
||||
M = getLazyBitcodeModule(*Buffer, Context, &ErrorMessage);
|
||||
if (!M) {
|
||||
delete *Buffer;
|
||||
*Buffer = 0;
|
||||
}
|
||||
}
|
||||
return M;
|
||||
}
|
||||
#else
|
||||
llvm::Module*
|
||||
LoadLibrary(const char* libBC, size_t libBCSize,
|
||||
LLVMContext& Context)
|
||||
{
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(StringRef(libBC, libBCSize), "");
|
||||
if ( Buffer ) {
|
||||
auto ModuleOrErr = llvm::getLazyBitcodeModule(std::move(Buffer), Context);
|
||||
if (!ModuleOrErr.getError()) return ModuleOrErr.get().release();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
static std::set<std::string> *getAmdRtFunctions()
|
||||
{
|
||||
std::set<std::string> *result = new std::set<std::string>();
|
||||
for (size_t i = 0; i < sizeof(amdRTFuns)/sizeof(amdRTFuns[0]); ++i)
|
||||
result->insert(amdRTFuns[i]);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace amd
|
||||
|
||||
|
||||
bool
|
||||
amdcl::OCLLinker::linkWithModule(llvm::Module* Dst, std::unique_ptr<llvm::Module> Src)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
if (Options()->oVariables->EnableDebugLinker) {
|
||||
llvm::DebugFlag = true;
|
||||
llvm::setCurrentDebugType(DEBUG_TYPE);
|
||||
}
|
||||
#endif
|
||||
std::string ErrorMessage;
|
||||
if (llvm::linkWithModule(Dst, std::move(Src), &ErrorMessage)) {
|
||||
DEBUG(llvm::dbgs() << "Error: " << ErrorMessage << "\n");
|
||||
BuildLog() += "\nInternal Error: linking libraries failed!\n";
|
||||
LogError("linkWithModule(): linking bc libraries failed!");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
amdcl::OCLLinker::linkLLVMModules(std::vector<std::unique_ptr<llvm::Module>> &libs)
|
||||
{
|
||||
// Load input modules first
|
||||
bool Failed = false;
|
||||
for (size_t i = 0; i < libs.size(); ++i) {
|
||||
std::string ErrorMsg;
|
||||
if (!libs[i]) {
|
||||
char ErrStr[128];
|
||||
sprintf(ErrStr,
|
||||
"Error: cannot load input %d bc for linking: %s\n",
|
||||
(int)i, ErrorMsg.c_str());
|
||||
BuildLog() += ErrStr;
|
||||
Failed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (Options()->isDumpFlagSet(amd::option::DUMP_BC_ORIGINAL)) {
|
||||
std::string MyErrorInfo;
|
||||
char buf[128];
|
||||
sprintf(buf, "_original%d.bc", (int)i);
|
||||
std::string fileName = Options()->getDumpFileName(buf);
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
llvm::raw_fd_ostream outs(fileName.c_str(), MyErrorInfo,
|
||||
llvm::raw_fd_ostream::F_Binary);
|
||||
if (MyErrorInfo.empty())
|
||||
llvm::WriteBitcodeToFile(libs[i], outs);
|
||||
else
|
||||
printf(MyErrorInfo.c_str());
|
||||
#else
|
||||
std::error_code EC;
|
||||
llvm::raw_fd_ostream outs(fileName.c_str(), EC, llvm::sys::fs::F_None);
|
||||
if (!EC)
|
||||
llvm::WriteBitcodeToFile(libs[i].get(), outs);
|
||||
else
|
||||
printf(EC.message().c_str());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (!Failed) {
|
||||
// Link input modules together
|
||||
for (size_t i = 0; i < libs.size(); ++i) {
|
||||
DEBUG(llvm::dbgs() << "LinkWithModule " << i << ":\n");
|
||||
if (amdcl::OCLLinker::linkWithModule(LLVMBinary(), std::move(libs[i]))) {
|
||||
Failed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Failed) {
|
||||
delete LLVMBinary();
|
||||
}
|
||||
libs.clear();
|
||||
return Failed;
|
||||
|
||||
}
|
||||
|
||||
void amdcl::OCLLinker::fixupOldTriple(llvm::Module *module)
|
||||
{
|
||||
llvm::Triple triple(module->getTargetTriple());
|
||||
|
||||
// Bug 9357: "amdopencl" used to be a hacky "OS" that was Linux or Windows
|
||||
// depending on the host. It only really matters for x86. If we are trying to
|
||||
// use an old binary module still using the old triple, replace it with a new
|
||||
// one.
|
||||
if (triple.getOSName() == "amdopencl") {
|
||||
if (triple.getArch() == llvm::Triple::amdil ||
|
||||
triple.getArch() == llvm::Triple::amdil64) {
|
||||
triple.setOS(llvm::Triple::UnknownOS);
|
||||
} else {
|
||||
llvm::Triple hostTriple(llvm::sys::getDefaultTargetTriple());
|
||||
triple.setOS(hostTriple.getOS());
|
||||
}
|
||||
|
||||
triple.setEnvironment(llvm::Triple::AMDOpenCL);
|
||||
module->setTargetTriple(triple.str());
|
||||
}
|
||||
}
|
||||
|
||||
// On 64 bit device, aclBinary target is set to 64 bit by default. When 32 bit
|
||||
// LLVM or SPIR binary is loaded, aclBinary target needs to be modified to
|
||||
// match LLVM or SPIR bitness.
|
||||
// Returns false on error.
|
||||
static bool
|
||||
checkAndFixAclBinaryTarget(llvm::Module* module, aclBinary* elf,
|
||||
std::string& buildLog) {
|
||||
if (module->getTargetTriple().empty()) {
|
||||
LogWarning("Module has no target triple");
|
||||
return true;
|
||||
}
|
||||
|
||||
llvm::Triple triple(module->getTargetTriple());
|
||||
const char* newArch = NULL;
|
||||
if (elf->target.arch_id == aclAMDIL64 &&
|
||||
(triple.getArch() == llvm::Triple::amdil ||
|
||||
triple.getArch() == llvm::Triple::spir))
|
||||
newArch = "amdil";
|
||||
else if (elf->target.arch_id == aclX64 &&
|
||||
(triple.getArch() == llvm::Triple::x86 ||
|
||||
triple.getArch() == llvm::Triple::spir))
|
||||
newArch = "x86";
|
||||
else if (elf->target.arch_id == aclHSAIL64 &&
|
||||
(triple.getArch() == llvm::Triple::hsail ||
|
||||
triple.getArch() == llvm::Triple::spir))
|
||||
newArch = "hsail";
|
||||
if (newArch != NULL) {
|
||||
acl_error errorCode;
|
||||
elf->target = aclGetTargetInfo(newArch, aclGetChip(elf->target),
|
||||
&errorCode);
|
||||
if (errorCode != ACL_SUCCESS) {
|
||||
assert(0 && "Invalid arch id or chip id in elf target");
|
||||
buildLog += "Internal Error: failed to link modules correctlty.\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
reinterpret_cast<amd::option::Options*>(elf->options)->libraryType_ =
|
||||
getLibraryType(&elf->target);
|
||||
|
||||
// Check consistency between module triple and aclBinary target
|
||||
if (elf->target.arch_id == aclAMDIL64 &&
|
||||
(triple.getArch() == llvm::Triple::amdil64 ||
|
||||
triple.getArch() == llvm::Triple::spir64))
|
||||
return true;
|
||||
if (elf->target.arch_id == aclAMDIL &&
|
||||
(triple.getArch() == llvm::Triple::amdil ||
|
||||
triple.getArch() == llvm::Triple::spir))
|
||||
return true;
|
||||
if (elf->target.arch_id == aclHSAIL64 &&
|
||||
(triple.getArch() == llvm::Triple::hsail64 ||
|
||||
triple.getArch() == llvm::Triple::spir64))
|
||||
return true;
|
||||
if (elf->target.arch_id == aclHSAIL &&
|
||||
(triple.getArch() == llvm::Triple::hsail ||
|
||||
triple.getArch() == llvm::Triple::spir))
|
||||
return true;
|
||||
if (elf->target.arch_id == aclX64 &&
|
||||
(triple.getArch() == llvm::Triple::x86_64 ||
|
||||
triple.getArch() == llvm::Triple::spir64))
|
||||
return true;
|
||||
if (elf->target.arch_id == aclX86 &&
|
||||
(triple.getArch() == llvm::Triple::x86 ||
|
||||
triple.getArch() == llvm::Triple::spir))
|
||||
return true;
|
||||
DEBUG_WITH_TYPE("linkTriple", llvm::dbgs() <<
|
||||
"[checkAndFixAclBinaryTarget] " <<
|
||||
" aclBinary target: " << elf->target.arch_id <<
|
||||
" chipId: " << elf->target.chip_id <<
|
||||
" module triple: " << module->getTargetTriple() <<
|
||||
'\n');
|
||||
|
||||
//ToDo: There is bug 9996 in compiler library about converting BIF30 to BIF21
|
||||
//which causes regressions in ocltst if the following check is enabled.
|
||||
//Fix the bugs then enable the following check
|
||||
#if 0
|
||||
assert(0 && "Inconsistent LLVM target and elf target");
|
||||
buildLog += "Internal Error: failed to link modules correctlty.\n";
|
||||
return false;
|
||||
#else
|
||||
LogWarning("Inconsistent LLVM target and elf target");
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAS_SPIRV
|
||||
bool
|
||||
translateSpirv(llvm::Module *&M, const std::string &DumpSpirv,
|
||||
const std::string &DumpLlvm, bool Timing, std::string &TimeStr){
|
||||
uint64_t ReadTime = 0;
|
||||
uint64_t WriteTime = 0;
|
||||
std::string S;
|
||||
llvm::raw_string_ostream RSS(S);
|
||||
std::string Err;
|
||||
|
||||
if (Timing)
|
||||
WriteTime = amd::Os::timeNanos();
|
||||
if (!llvm::WriteSPIRV(M, RSS, Err)) {
|
||||
llvm::errs() << "Fails to save LLVM as SPIR-V: " << Err << '\n';
|
||||
return false;
|
||||
}
|
||||
if (Timing)
|
||||
WriteTime = amd::Os::timeNanos() - WriteTime;
|
||||
|
||||
if (!DumpSpirv.empty()) {
|
||||
std::ofstream OFS(DumpSpirv, std::ios::binary);
|
||||
OFS << RSS.str();
|
||||
OFS.close();
|
||||
}
|
||||
|
||||
RSS.flush();
|
||||
std::stringstream SS(S);
|
||||
|
||||
auto &Ctx = M->getContext();
|
||||
delete M;
|
||||
M = nullptr;
|
||||
if (Timing)
|
||||
ReadTime = amd::Os::timeNanos();
|
||||
if (!llvm::ReadSPIRV(Ctx, SS, M, Err)) {
|
||||
llvm::errs() << "Fails to load SPIR-V as LLVM Module: " << Err << '\n';
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Timing) {
|
||||
ReadTime = amd::Os::timeNanos() - ReadTime;
|
||||
std::stringstream tmp_ss;
|
||||
tmp_ss << " LLVM/SPIRV translation time: "
|
||||
<< WriteTime/1000ULL << " us\n"
|
||||
<< " SPIRV/LLVM translation time: "
|
||||
<< ReadTime/1000ULL << " us\n";
|
||||
TimeStr = tmp_ss.str();
|
||||
}
|
||||
|
||||
if (!DumpLlvm.empty()) {
|
||||
std::error_code EC;
|
||||
llvm::raw_fd_ostream outs(DumpLlvm.c_str(), EC, llvm::sys::fs::F_None);
|
||||
if (!EC)
|
||||
WriteBitcodeToFile(M, outs);
|
||||
else {
|
||||
llvm::errs() << EC.message();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
amdcl::OCLLinker::link(llvm::Module* input, std::vector<std::unique_ptr<llvm::Module>> &libs)
|
||||
{
|
||||
bool IsGPUTarget = isGpuTarget(Elf()->target);
|
||||
uint64_t start_time = 0ULL, time_link = 0ULL, time_prelinkopt = 0ULL;
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
start_time = amd::Os::timeNanos();
|
||||
}
|
||||
|
||||
fixupOldTriple(input);
|
||||
|
||||
if (!checkAndFixAclBinaryTarget(input, Elf(), BuildLog()))
|
||||
return 1;
|
||||
|
||||
int ret = 0;
|
||||
if (Options()->oVariables->UseJIT) {
|
||||
delete hookup_.amdrtFunctions;
|
||||
hookup_.amdrtFunctions = amd::getAmdRtFunctions();
|
||||
} else {
|
||||
hookup_.amdrtFunctions = NULL;
|
||||
}
|
||||
if (Options()->isOptionSeen(amd::option::OID_LUThreshold) || !IsGPUTarget) {
|
||||
setUnrollScratchThreshold(Options()->oVariables->LUThreshold);
|
||||
} else {
|
||||
setUnrollScratchThreshold(500);
|
||||
}
|
||||
|
||||
llvmbinary_ = input;
|
||||
|
||||
if ( !LLVMBinary() ) {
|
||||
BuildLog() += "Internal Error: cannot load bc application for linking\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (linkLLVMModules(libs)) {
|
||||
BuildLog() += "Internal Error: failed to link modules correctlty.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Don't link in built-in libraries if we are only creating the library.
|
||||
if (Options()->oVariables->clCreateLibrary) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (Options()->isDumpFlagSet(amd::option::DUMP_BC_ORIGINAL)) {
|
||||
std::string fileName = Options()->getDumpFileName("_original.bc");
|
||||
std::error_code EC;
|
||||
llvm::raw_fd_ostream outs(fileName.c_str(), EC, llvm::sys::fs::F_None);
|
||||
if (!EC)
|
||||
WriteBitcodeToFile(LLVMBinary(), outs);
|
||||
else
|
||||
printf(EC.message().c_str());
|
||||
}
|
||||
|
||||
#ifdef HAS_SPIRV
|
||||
if (Options()->oVariables->RoundTripSPIRV && isAMDSPIRModule(*llvmbinary_)) {
|
||||
std::string DumpSpirv;
|
||||
std::string DumpLlvm;
|
||||
if (Options()->isDumpFlagSet(amd::option::DUMP_BC_ORIGINAL)) {
|
||||
DumpSpirv = Options()->getDumpFileName(".spv");
|
||||
DumpLlvm = Options()->getDumpFileName("_fromspv.bc");
|
||||
}
|
||||
std::string TimeStr;
|
||||
translateSpirv(llvmbinary_, DumpSpirv, DumpLlvm,
|
||||
Options()->oVariables->EnableBuildTiming, TimeStr);
|
||||
if (!TimeStr.empty())
|
||||
appendLogToCL(CL(), TimeStr);
|
||||
}
|
||||
#endif
|
||||
|
||||
llvm::StringRef chip(aclGetChip(Elf()->target));
|
||||
setGPU(IsGPUTarget);
|
||||
setFiniteMathOnly(Options()->oVariables->FiniteMathOnly);
|
||||
setNoSignedZeros(Options()->oVariables->NoSignedZeros);
|
||||
setFastRelaxedMath(Options()->oVariables->FastRelaxedMath);
|
||||
setWholeProgram(true);
|
||||
setOptSimplifyLibCall(Options()->oVariables->OptSimplifyLibCall);
|
||||
setUnsafeMathOpt(Options()->oVariables->UnsafeMathOpt);
|
||||
setIsPreLinkOpt(Options()->oVariables->OptLevel != amd::option::OPT_O0);
|
||||
setFP32RoundDivideSqrt(Options()->oVariables->FP32RoundDivideSqrt);
|
||||
setUseNative(Options()->oVariables->OptUseNative);
|
||||
setDenormsAreZero(Options()->oVariables->DenormsAreZero);
|
||||
setUniformWorkGroupSize(Options()->oVariables->UniformWorkGroupSize);
|
||||
setHaveFastFMA32(chip == "Cypress"
|
||||
|| chip == "Cayman"
|
||||
|| chip == "Tahiti"
|
||||
|| chip == "Hawaii"
|
||||
|| chip == "Carrizo"
|
||||
|| chip == "gfx900"
|
||||
|| chip == "gfx901"
|
||||
|| chip == "gfx902"
|
||||
|| chip == "gfx903"
|
||||
|| chip == "gfx904"
|
||||
|| chip == "gfx905"
|
||||
|| chip == "gfx906"
|
||||
|| chip == "gfx907"
|
||||
|| chip == "gfx908"
|
||||
|| chip == "gfx1000"
|
||||
|| chip == "gfx1010"
|
||||
|| chip == "gfx1011"
|
||||
|| chip == "gfx1012");
|
||||
setISAVersion(getIsaType(aclutGetTargetInfo(Elf())));
|
||||
LLVMBinary()->getContext().setAMDLLVMContextHook(&hookup_);
|
||||
|
||||
amd::LibraryDescriptor LibDescs[
|
||||
amd::LibraryDescriptor::MAX_NUM_LIBRARY_DESCS];
|
||||
int sz;
|
||||
std::string LibTargetTriple;
|
||||
std::string LibDataLayout;
|
||||
if (amd::getLibDescs(Options()->libraryType_, LibDescs, sz) != 0) {
|
||||
// FIXME: If we error here, we don't clean up, so we crash in debug build
|
||||
// on compilerfini().
|
||||
BuildLog() += "Internal Error: finding libraries failed!\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
AMDSpir::replaceTrivialFunc(*LLVMBinary());
|
||||
|
||||
for (int i=0; i < sz; i++) {
|
||||
std::unique_ptr<llvm::Module> Library(
|
||||
amd::LoadLibrary(LibDescs[i].start, LibDescs[i].size, Context()));
|
||||
|
||||
DEBUG(llvm::dbgs() << "Loaded library " << i << "\n");
|
||||
if ( !Library.get() ) {
|
||||
BuildLog() += "Internal Error: cannot load library!\n";
|
||||
delete LLVMBinary();
|
||||
return 1;
|
||||
#ifndef NDEBUG
|
||||
} else {
|
||||
if ( llvm::verifyModule( *Library.get() ) ) {
|
||||
BuildLog() += "Internal Error: library verification failed!\n";
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
DEBUG_WITH_TYPE("linkTriple", llvm::dbgs() << "Library[" << i << "] " <<
|
||||
Library->getTargetTriple() << ' ' << LibDataLayout << '\n');
|
||||
|
||||
if (LibTargetTriple.empty()) {
|
||||
// The first member in the list of libraries is assumed to be
|
||||
// representative of the target device.
|
||||
LibTargetTriple = Library->getTargetTriple();
|
||||
LibDataLayout = Library->getDataLayoutStr();
|
||||
DEBUG_WITH_TYPE("linkTriple", llvm::dbgs() << "Library[" << i << "] " <<
|
||||
LibTargetTriple << ' ' << LibDataLayout << '\n');
|
||||
assert(!LibTargetTriple.empty() && !LibDataLayout.empty() &&
|
||||
"First library should have triple and datalayout");
|
||||
|
||||
if (!llvm::fixupKernelModule(LLVMBinary(), LibTargetTriple, LibDataLayout))
|
||||
return 1;
|
||||
|
||||
// Before doing anything else, quickly optimize Module
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
time_prelinkopt = amd::Os::timeNanos();
|
||||
}
|
||||
|
||||
std::string clp_errmsg;
|
||||
std::unique_ptr<llvm::Module> OnFlyLib(AMDPrelink(LLVMBinary(), clp_errmsg));
|
||||
|
||||
if (!clp_errmsg.empty()) {
|
||||
delete LLVMBinary();
|
||||
BuildLog() += clp_errmsg;
|
||||
BuildLog() += "Internal Error: on-fly library generation failed\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (OnFlyLib) {
|
||||
// OnFlyLib must be the first!
|
||||
std::string ErrorMsg;
|
||||
if (resolveLink(LLVMBinary(), std::move(OnFlyLib), &ErrorMsg)) {
|
||||
BuildLog() += ErrorMsg;
|
||||
BuildLog() += "\nInternal Error: linking libraries failed!\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
time_prelinkopt = amd::Os::timeNanos() - time_prelinkopt;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Check consistency of target and data layout
|
||||
if (!Library->getTargetTriple().empty()) {
|
||||
assert (Library->getTargetTriple() == LibTargetTriple &&
|
||||
"Library target triple should match");
|
||||
assert (Library->getDataLayoutStr() == LibDataLayout &&
|
||||
"Library data layout should match");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Now, do linking by extracting from the builtins library only those
|
||||
// functions that are used in the kernel(s).
|
||||
uint64_t tm = Options()->oVariables->EnableBuildTiming ? amd::Os::timeNanos() : 0ULL;
|
||||
|
||||
// Link libraries to get every functions that are referenced.
|
||||
std::string ErrorMsg;
|
||||
if (resolveLink(LLVMBinary(), std::move(Library), &ErrorMsg)) {
|
||||
BuildLog() += ErrorMsg;
|
||||
BuildLog() += "\nInternal Error: linking libraries failed!\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
time_link += amd::Os::timeNanos() - tm;
|
||||
}
|
||||
}
|
||||
|
||||
fixupModulePostLink(LLVMBinary());
|
||||
CreateOptControlFunctions(LLVMBinary());
|
||||
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
time_link = amd::Os::timeNanos() - time_link;
|
||||
std::stringstream tmp_ss;
|
||||
tmp_ss << " LLVM time (link+opt): "
|
||||
<< (amd::Os::timeNanos() - start_time)/1000ULL
|
||||
<< " us\n"
|
||||
<< " prelinkopt: " << time_prelinkopt/1000ULL << " us\n"
|
||||
<< " link: " << time_link/1000ULL << " us\n";
|
||||
appendLogToCL(CL(), tmp_ss.str());
|
||||
}
|
||||
|
||||
if (Options()->isDumpFlagSet(amd::option::DUMP_BC_LINKED)) {
|
||||
std::string MyErrorInfo;
|
||||
std::string fileName = Options()->getDumpFileName("_linked.bc");
|
||||
std::error_code EC;
|
||||
llvm::raw_fd_ostream outs(fileName.c_str(), EC, llvm::sys::fs::F_None);
|
||||
// FIXME: Need to add this to the elf binary!
|
||||
if (!EC)
|
||||
WriteBitcodeToFile(LLVMBinary(), outs);
|
||||
else
|
||||
printf(EC.message().c_str());
|
||||
}
|
||||
|
||||
// Check if kernels containing local arrays are called by other kernels.
|
||||
std::string localArrayUsageError;
|
||||
if (!llvm::AMDCheckLocalArrayUsage(*LLVMBinary(), &localArrayUsageError)) {
|
||||
BuildLog() += "Error: " + localArrayUsageError + '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
// check undefined function
|
||||
#ifndef NDEBUG
|
||||
{
|
||||
auto M = LLVMBinary();
|
||||
for (auto I = M->begin(), E = M->end(); I != E; ++I) {
|
||||
if (!I->isDeclaration() || I->use_empty() || (I->hasName() &&
|
||||
(I->getName().startswith("__") ||
|
||||
I->getName().startswith("llvm."))))
|
||||
continue;
|
||||
llvm::errs() << "Warning: Undefined function: " << *I << '\n';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _BE_LINKER_HPP_
|
||||
#define _BE_LINKER_HPP_
|
||||
#include "compiler_stage.hpp"
|
||||
#include "aclTypes.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
|
||||
namespace llvm {
|
||||
class Module;
|
||||
class Value;
|
||||
}; // namespace llvm
|
||||
|
||||
namespace amdcl
|
||||
{
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::Linker
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class Linker : public LLVMCompilerStage{
|
||||
Linker(Linker&); // DO NOT IMPLEMENT.
|
||||
Linker(); // DO NOT IMPLEMENT.
|
||||
|
||||
public:
|
||||
Linker(aclCompiler *cl, aclBinary* elf, aclLogFunction log)
|
||||
: LLVMCompilerStage(cl, elf, log) {}
|
||||
|
||||
virtual ~Linker() {}
|
||||
|
||||
|
||||
|
||||
/*! Function that takes as in a llvm::Module that contains LLVM-IR
|
||||
* binary and links in a vector of libraries.
|
||||
* Returns 0 on success, non-zero on failure.
|
||||
*/
|
||||
virtual int link(llvm::Module* input, std::vector<std::unique_ptr<llvm::Module>> &libs) = 0;
|
||||
|
||||
}; // class Linker
|
||||
/*@}*/
|
||||
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::OCLLinker
|
||||
*
|
||||
* @{
|
||||
* \brief Linker that is unique to OpenCL.
|
||||
*/
|
||||
class OCLLinker : public Linker {
|
||||
public:
|
||||
OCLLinker(aclCompiler* cl, aclBinary* bin, aclLogFunction log)
|
||||
: Linker(cl, bin, log) {}
|
||||
|
||||
virtual ~OCLLinker() {
|
||||
for (unsigned j = 0, i = (unsigned)mathLibs_.size(); j < i; ++j) {
|
||||
if (mathLibs_[j]) {
|
||||
delete mathLibs_[j];
|
||||
}
|
||||
}
|
||||
};
|
||||
void setPreLinkOpt(bool Val) { hookup_.amdoptions.IsPreLinkOpt = Val; }
|
||||
void setUnrollScratchThreshold(uint32_t ust) { hookup_.amdoptions.UnrollScratchThreshold = ust; }
|
||||
|
||||
bool getWholeProgram() { return hookup_.amdoptions.WholeProgram; }
|
||||
uint32_t getUnrollScratchThreshold() { return hookup_.amdoptions.UnrollScratchThreshold; }
|
||||
|
||||
|
||||
/*! Function that takes as input a std::string which
|
||||
* contains LLVM-IR binary and links in a vector of libraries.
|
||||
* This version also links in the OpenCL math libraries along with
|
||||
* the list of libraries that are passed in.
|
||||
*/
|
||||
int link(llvm::Module* input, std::vector<std::unique_ptr<llvm::Module>> &libs);
|
||||
protected:
|
||||
bool linkLLVMModules(std::vector<std::unique_ptr<llvm::Module>> &libs);
|
||||
bool linkWithModule(llvm::Module* Dst, std::unique_ptr<llvm::Module> Src);
|
||||
|
||||
|
||||
private:
|
||||
static void fixupOldTriple(llvm::Module* module);
|
||||
/*! Vector of modules that stores the math libraries.
|
||||
*/
|
||||
std::vector<llvm::Module*> mathLibs_;
|
||||
}; // class OCLLinker
|
||||
/*@}*/
|
||||
|
||||
}; // namespace amdcl
|
||||
#endif // _BE_LINKER_HPP_
|
||||
@@ -1,284 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#include "top.hpp"
|
||||
#include "opt_level.hpp"
|
||||
#include "library.hpp"
|
||||
#include "acl.h"
|
||||
#include "utils/options.hpp"
|
||||
#include "utils/target_mappings.h"
|
||||
#include "utils/libUtils.h"
|
||||
#include "llvm/Analysis/Passes.h"
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
#include "llvm/DataLayout.h"
|
||||
#include "llvm/Module.h"
|
||||
#else
|
||||
#include "llvm/Analysis/TargetTransformInfo.h"
|
||||
#endif
|
||||
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
|
||||
#include "llvm/LinkAllPasses.h"
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
#include "llvm/Transforms/IPO/AMDOptOptions.h"
|
||||
#include "compiler_stage.hpp"
|
||||
using namespace amdcl;
|
||||
using namespace llvm;
|
||||
|
||||
void
|
||||
OptLevel::setup(aclBinary *elf, bool isGPU, uint32_t OptLevel)
|
||||
{
|
||||
// Add an appropriate DataLayout instance for this module.
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
Passes().add(new DataLayout(module_));
|
||||
fpasses_ = new FunctionPassManager(module_);
|
||||
fpasses_->add(new DataLayout(module_));
|
||||
#else
|
||||
fpasses_ = new legacy::FunctionPassManager(module_);
|
||||
#endif
|
||||
|
||||
const aclTargetInfo* trg = aclutGetTargetInfo(elf);
|
||||
if (trg) {
|
||||
llvm::Triple TheTriple(getTriple(trg->arch_id));
|
||||
if (TheTriple.getArch()) {
|
||||
std::string Error;
|
||||
llvm::StringRef MArch(aclGetArchitecture(*trg));
|
||||
const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple,
|
||||
Error);
|
||||
if (TheTarget) {
|
||||
llvm::TargetOptions targetOptions;
|
||||
targetOptions.StackAlignmentOverride = Options()->oVariables->CPUStackAlignment;
|
||||
#ifdef WITH_TARGET_HSAIL
|
||||
if (Options()->libraryType_ == amd::GPU_Library_HSAIL)
|
||||
targetOptions.UnsafeFPMath = Options()->oVariables->UnsafeMathOpt;
|
||||
#endif
|
||||
targetOptions.LessPreciseFPMADOption = Options()->oVariables->MadEnable ||
|
||||
Options()->oVariables->EnableMAD;
|
||||
targetOptions.NoInfsFPMath = targetOptions.NoNaNsFPMath
|
||||
= Options()->oVariables->FiniteMathOnly;
|
||||
for (auto &F : *module_) {
|
||||
auto Attrs = F.getAttributes();
|
||||
Attrs = Attrs.addAttribute(F.getContext(), AttributeSet::FunctionIndex,
|
||||
"no-frame-pointer-elim", "false");
|
||||
F.setAttributes(Attrs);
|
||||
}
|
||||
|
||||
llvm::CodeGenOpt::Level OLvl = CodeGenOpt::None;
|
||||
switch (Options()->oVariables->OptLevel) {
|
||||
case amd::option::OPT_O0: // -O0
|
||||
OLvl = CodeGenOpt::None;
|
||||
break;
|
||||
case amd::option::OPT_O1: // -O1
|
||||
OLvl = CodeGenOpt::Less;
|
||||
break;
|
||||
case amd::option::OPT_O2: // -O2
|
||||
case amd::option::OPT_O5: // -O5
|
||||
case amd::option::OPT_OG: // -Og
|
||||
case amd::option::OPT_OS: // -Os
|
||||
OLvl = CodeGenOpt::Default;
|
||||
break;
|
||||
case amd::option::OPT_O3: // -O3
|
||||
case amd::option::OPT_O4: // -O4
|
||||
OLvl = CodeGenOpt::Aggressive;
|
||||
break;
|
||||
default:
|
||||
assert(!"Error with optimization level");
|
||||
};
|
||||
|
||||
TM = TheTarget->createTargetMachine(TheTriple.getTriple(),
|
||||
aclutGetCodegenName(elf->target),
|
||||
getFeatureString(elf->target, Options()),
|
||||
targetOptions,
|
||||
WINDOWS_SWITCH(Reloc::DynamicNoPIC, Reloc::PIC_),
|
||||
CodeModel::Default, OLvl);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (TM) {
|
||||
passes_.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
|
||||
fpasses_->add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
|
||||
}
|
||||
|
||||
PassManagerBuilder Builder;
|
||||
Builder.OptLevel = OptLevel;
|
||||
|
||||
if (Options()->libraryType_ == amd::GPU_Library_HSAIL) {
|
||||
if (OptLevel == 0) return;
|
||||
}
|
||||
|
||||
if (!Options()->oVariables->Inline) {
|
||||
// No inlining pass
|
||||
} else if (isGPU) {
|
||||
#ifdef WITH_TARGET_HSAIL
|
||||
if (Options()->libraryType_ == amd::GPU_Library_HSAIL) {
|
||||
if (HLC_HSAIL_Enable_Calls) {
|
||||
HLC_Disable_Amd_Inline_All = true;
|
||||
} else {
|
||||
HLC_Disable_Amd_Inline_All = false;
|
||||
}
|
||||
// Always create Inliner regardless of OptLevel
|
||||
if (HLC_Force_Always_Inliner_Pass) {
|
||||
Builder.Inliner = createAlwaysInlinerPass();
|
||||
} else {
|
||||
Builder.Inliner = createAMDFunctionInliningPass(HLC_HSAIL_Inline_Threshold);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
HLC_Disable_Amd_Inline_All = false;
|
||||
// Always create Inliner regardless of OptLevel
|
||||
Builder.Inliner = createAMDFunctionInliningPass(500);
|
||||
}
|
||||
} else if (OptLevel > 1) {
|
||||
unsigned Threshold = 225;
|
||||
if (OptLevel > 2)
|
||||
Threshold = 275;
|
||||
#ifdef WITH_TARGET_HSAIL
|
||||
if (Options()->libraryType_ == amd::GPU_Library_HSAIL) {
|
||||
// Don't do inlining (including createAlwaysInlinerPass()) if OptimizationLevel
|
||||
// is zero becaue we are generating code for -g
|
||||
if (OptLevel > 0) {
|
||||
Builder.Inliner = createAMDFunctionInliningPass(Threshold);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
Builder.Inliner = createAMDFunctionInliningPass(Threshold);
|
||||
}
|
||||
}
|
||||
Builder.SizeLevel = 0;
|
||||
Builder.DisableUnitAtATime = false;
|
||||
Builder.DisableUnrollLoops = OptLevel == 0;
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
if (Options()->libraryType_ != amd::GPU_Library_HSAIL)
|
||||
Builder.DisableSimplifyLibCalls = true;
|
||||
#endif
|
||||
Builder.AMDpopulateFunctionPassManager(*fpasses_, &module_->getContext());
|
||||
Builder.AMDpopulateModulePassManager(passes_, &module_->getContext(), module_);
|
||||
}
|
||||
|
||||
void
|
||||
OptLevel::run(aclBinary *elf)
|
||||
{
|
||||
if (Options()->oVariables->OptPrintLiveness) {
|
||||
Passes().add(createAMDLivenessPrinterPass());
|
||||
}
|
||||
fpasses_->doInitialization();
|
||||
for (Module::iterator I = module_->begin(), E = module_->end(); I != E; ++I)
|
||||
fpasses_->run(*I);
|
||||
fpasses_->doFinalization();
|
||||
// Now that we have all of the passes ready, run them.
|
||||
passes_.run(*module_);
|
||||
|
||||
delete fpasses_;
|
||||
}
|
||||
|
||||
int
|
||||
O0OptLevel::optimize(aclBinary *elf, Module *input, bool isGPU)
|
||||
{
|
||||
// With -O0, we don't do anything
|
||||
module_ = input;
|
||||
#ifdef WITH_TARGET_HSAIL
|
||||
if (Options()->libraryType_ == amd::GPU_Library_HSAIL) {
|
||||
// Mark all non-kernel functions as having internal linkage
|
||||
Passes().add(createAMDSymbolLinkagePass(true, NULL));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
setup(elf, false, 0);
|
||||
run(elf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
GPUO0OptLevel::optimize(aclBinary *elf, Module *input, bool isGPU)
|
||||
{
|
||||
module_ = input;
|
||||
assert(isGPU && "Only a GPU can use GPUO0OptLevel!\n");
|
||||
setup(elf, true, 0);
|
||||
#ifdef WITH_TARGET_HSAIL
|
||||
if (Options()->libraryType_ == amd::GPU_Library_HSAIL) {
|
||||
// On the GPU, even with -O0, we must do some optimizations. One
|
||||
// goal is to ensure that all functions are inlined. This requires
|
||||
// three steps in that order:
|
||||
//
|
||||
// 1. Mark all non-kernel functions as having internal linkage.
|
||||
// 2. Invoke the GlobalOptimizer to resolve function aliases.
|
||||
// 3. Force inlining using our custom inliner pass.
|
||||
if (Options()->oVariables->EnableDebug) {
|
||||
HLC_HSAIL_Enable_Calls = false;
|
||||
HLC_Disable_Amd_Inline_All = false;
|
||||
}
|
||||
else if (HLC_HSAIL_Enable_Calls) {
|
||||
HLC_Disable_Amd_Inline_All = true;
|
||||
}
|
||||
else {
|
||||
HLC_Disable_Amd_Inline_All = false;
|
||||
}
|
||||
Passes().add(createAMDSymbolLinkagePass(true, NULL));
|
||||
Passes().add(createGlobalOptimizerPass());
|
||||
if (!HLC_Disable_Amd_Inline_All &&
|
||||
!DisableInline &&
|
||||
!HLC_Force_Always_Inliner_Pass) {
|
||||
Passes().add(createAMDInlineAllPass(true));
|
||||
} else {
|
||||
Passes().add(createAlwaysInlinerPass());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
run(elf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
O1OptLevel::optimize(aclBinary *elf, Module *input, bool isGPU)
|
||||
{
|
||||
module_ = input;
|
||||
setup(elf, isGPU, 1);
|
||||
run(elf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
O2OptLevel::optimize(aclBinary *elf, Module *input, bool isGPU)
|
||||
{
|
||||
module_ = input;
|
||||
setup(elf, isGPU, 2);
|
||||
run(elf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
O3OptLevel::optimize(aclBinary *elf, Module *input, bool isGPU)
|
||||
{
|
||||
module_ = input;
|
||||
setup(elf, isGPU, 3);
|
||||
run(elf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
O4OptLevel::optimize(aclBinary *elf, Module *input, bool isGPU)
|
||||
{
|
||||
module_ = input;
|
||||
setup(elf, isGPU, 4);
|
||||
run(elf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
OsOptLevel::optimize(aclBinary *elf, Module *input, bool isGPU)
|
||||
{
|
||||
module_ = input;
|
||||
setup(elf, isGPU, 5);
|
||||
run(elf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
OgOptLevel::optimize(aclBinary *elf, Module *input, bool isGPU)
|
||||
{
|
||||
module_ = input;
|
||||
setup(elf, isGPU, 2);
|
||||
run(elf);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _BE_OPT_LEVEL_HPP_
|
||||
#define _BE_OPT_LEVEL_HPP_
|
||||
#include "top.hpp"
|
||||
#include "utils/options.hpp"
|
||||
#include "aclTypes.h"
|
||||
|
||||
#if defined DEBUG
|
||||
#undef DEBUG
|
||||
#endif
|
||||
|
||||
#include "llvm/Analysis/Passes.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
|
||||
namespace llvm {
|
||||
class Module;
|
||||
|
||||
}; // llvm namespace
|
||||
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
#define LLVM_LEGACY_NAMESPACE llvm
|
||||
#else
|
||||
#define LLVM_LEGACY_NAMESPACE llvm::legacy
|
||||
#endif
|
||||
|
||||
namespace amdcl
|
||||
{
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::OptLevel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class OptLevel {
|
||||
OptLevel(OptLevel&); // DO NOT IMPLEMENT.
|
||||
OptLevel(); // DO NOT IMPLEMENT.
|
||||
|
||||
public:
|
||||
OptLevel(amd::option::Options *OptionsObj)
|
||||
: opts_(OptionsObj), TM(nullptr) {}
|
||||
|
||||
virtual ~OptLevel() { delete TM; }
|
||||
|
||||
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU) = 0;
|
||||
protected:
|
||||
void setup(aclBinary *elf, bool isGPU, uint32_t OptLevel);
|
||||
void run(aclBinary *elf);
|
||||
LLVM_LEGACY_NAMESPACE::PassManager& Passes() { return passes_; }
|
||||
LLVM_LEGACY_NAMESPACE::FunctionPassManager& FPasses() { return (*fpasses_); }
|
||||
amd::option::Options* Options() { return opts_; }
|
||||
llvm::Module* module_;
|
||||
private:
|
||||
LLVM_LEGACY_NAMESPACE::FunctionPassManager *fpasses_;
|
||||
LLVM_LEGACY_NAMESPACE::PassManager passes_;
|
||||
amd::option::Options *opts_;
|
||||
llvm::TargetMachine* TM;
|
||||
}; // class OptLevel
|
||||
/*@}*/
|
||||
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::O0OptLevel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class O0OptLevel : public OptLevel {
|
||||
O0OptLevel(O0OptLevel&); // DO NOT IMPLEMENT.
|
||||
O0OptLevel(); // DO NOT IMPLEMENT.
|
||||
|
||||
public:
|
||||
O0OptLevel(amd::option::Options *opts)
|
||||
: OptLevel(opts) {}
|
||||
|
||||
virtual ~O0OptLevel() {}
|
||||
|
||||
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
||||
}; // class O0OptLevel
|
||||
/*@}*/
|
||||
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::GPUO0OptLevel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class GPUO0OptLevel : public O0OptLevel {
|
||||
GPUO0OptLevel(GPUO0OptLevel&); // DO NOT IMPLEMENT.
|
||||
GPUO0OptLevel(); // DO NOT IMPLEMENT.
|
||||
|
||||
public:
|
||||
GPUO0OptLevel(amd::option::Options *opts)
|
||||
: O0OptLevel(opts) {}
|
||||
|
||||
virtual ~GPUO0OptLevel() {}
|
||||
|
||||
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
||||
}; // class O0OptLevel
|
||||
/*@}*/
|
||||
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::O1OptLevel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class O1OptLevel : public OptLevel {
|
||||
O1OptLevel(O1OptLevel&); // DO NOT IMPLEMENT.
|
||||
O1OptLevel(); // DO NOT IMPLEMENT.
|
||||
|
||||
public:
|
||||
O1OptLevel(amd::option::Options *opts)
|
||||
: OptLevel(opts) {}
|
||||
|
||||
virtual ~O1OptLevel() {}
|
||||
|
||||
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
||||
}; // class O1OptLevel
|
||||
/*@}*/
|
||||
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::O2OptLevel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class O2OptLevel : public OptLevel {
|
||||
O2OptLevel(O2OptLevel&); // DO NOT IMPLEMENT.
|
||||
O2OptLevel(); // DO NOT IMPLEMENT.
|
||||
|
||||
public:
|
||||
O2OptLevel(amd::option::Options *opts)
|
||||
: OptLevel(opts) {}
|
||||
|
||||
virtual ~O2OptLevel() {}
|
||||
|
||||
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
||||
}; // class O2OptLevel
|
||||
/*@}*/
|
||||
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::O3OptLevel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class O3OptLevel : public OptLevel {
|
||||
O3OptLevel(O3OptLevel&); // DO NOT IMPLEMENT.
|
||||
O3OptLevel(); // DO NOT IMPLEMENT.
|
||||
|
||||
public:
|
||||
O3OptLevel(amd::option::Options *opts)
|
||||
: OptLevel(opts) {}
|
||||
|
||||
virtual ~O3OptLevel() {}
|
||||
|
||||
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
||||
}; // class O3OptLevel
|
||||
/*@}*/
|
||||
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::O4OptLevel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class O4OptLevel : public OptLevel {
|
||||
O4OptLevel(O4OptLevel&); // DO NOT IMPLEMENT.
|
||||
O4OptLevel(); // DO NOT IMPLEMENT.
|
||||
|
||||
public:
|
||||
O4OptLevel(amd::option::Options *opts)
|
||||
: OptLevel(opts) {}
|
||||
|
||||
virtual ~O4OptLevel() {}
|
||||
|
||||
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
||||
}; // class O4OptLevel
|
||||
/*@}*/
|
||||
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::OsOptLevel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class OsOptLevel : public OptLevel {
|
||||
OsOptLevel(OsOptLevel&); // DO NOT IMPLEMENT.
|
||||
OsOptLevel(); // DO NOT IMPLEMENT.
|
||||
|
||||
public:
|
||||
OsOptLevel(amd::option::Options *opts)
|
||||
: OptLevel(opts) {}
|
||||
|
||||
virtual ~OsOptLevel() {}
|
||||
|
||||
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
||||
}; // class OsOptLevel
|
||||
/*@}*/
|
||||
|
||||
class OgOptLevel : public OptLevel {
|
||||
OgOptLevel(OgOptLevel&); // DO NOT IMPLEMENT.
|
||||
OgOptLevel(); // DO NOT IMPLEMENT.
|
||||
|
||||
public:
|
||||
OgOptLevel(amd::option::Options *opts)
|
||||
: OptLevel(opts) {}
|
||||
|
||||
virtual ~OgOptLevel() {}
|
||||
|
||||
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
||||
}; // class OgOptLevel
|
||||
/*@}*/
|
||||
|
||||
}; // amdcl namespace
|
||||
#endif // _BE_OPT_LEVEL_HPP_
|
||||
@@ -1,188 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#include "top.hpp"
|
||||
#include "optimizer.hpp"
|
||||
#include "opt_level.hpp"
|
||||
#include "os/os.hpp"
|
||||
#include "utils/bif_section_labels.hpp"
|
||||
#include "utils/libUtils.h"
|
||||
#include "utils/options.hpp"
|
||||
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
#include "llvm/DataLayout.h"
|
||||
#else
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include "AMDPasses.h"
|
||||
#endif
|
||||
#include "llvm/Analysis/Passes.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/LinkAllPasses.h"
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
using namespace amdcl;
|
||||
using namespace llvm;
|
||||
|
||||
static OptLevel* getOptLevel(amd::option::Options* Options, bool isGPU) {
|
||||
switch(Options->oVariables->OptLevel) {
|
||||
case amd::option::OPT_O0:
|
||||
return (isGPU) ? new GPUO0OptLevel(Options) : new O0OptLevel(Options);
|
||||
case amd::option::OPT_O1:
|
||||
return new O1OptLevel(Options);
|
||||
default:
|
||||
assert(!"Found an invalid optimization level!");
|
||||
case amd::option::OPT_O2:
|
||||
return new O2OptLevel(Options);
|
||||
case amd::option::OPT_OG:
|
||||
return new OgOptLevel(Options);
|
||||
case amd::option::OPT_O3:
|
||||
return new O3OptLevel(Options);
|
||||
case amd::option::OPT_O4:
|
||||
return new O4OptLevel(Options);
|
||||
case amd::option::OPT_O5:
|
||||
case amd::option::OPT_OS:
|
||||
return new OsOptLevel(Options);
|
||||
}
|
||||
assert(!"Unreachable!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
CPUOptimizer::preOptimizer(llvm::Module* M)
|
||||
{
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
llvm::PassManager Passes;
|
||||
Passes.add(new llvm::DataLayout(M));
|
||||
#else
|
||||
llvm::legacy::PassManager Passes;
|
||||
#endif
|
||||
|
||||
Passes.add(createAMDExportKernelNaturePass());
|
||||
|
||||
Passes.run(*M);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
CPUOptimizer::optimize(llvm::Module *input)
|
||||
{
|
||||
if (!input) {
|
||||
return 1;
|
||||
}
|
||||
int ret = 0;
|
||||
uint64_t start_time = 0ULL, time_opt = 0ULL;
|
||||
llvmbinary_ = input;
|
||||
setWholeProgram(true);
|
||||
|
||||
setGPU(false);
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
start_time = amd::Os::timeNanos();
|
||||
}
|
||||
ret = preOptimizer(LLVMBinary());
|
||||
setUniformWorkGroupSize(Options()->oVariables->UniformWorkGroupSize);
|
||||
OptLevel* cpuOpt = getOptLevel(Options(), false);
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
time_opt = amd::Os::timeNanos();
|
||||
}
|
||||
ret = cpuOpt->optimize(Elf(), LLVMBinary(), false);
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
time_opt = amd::Os::timeNanos() - time_opt;
|
||||
std::stringstream tmp_ss;
|
||||
tmp_ss << " LLVM Opt time: "
|
||||
<< time_opt/1000ULL
|
||||
<< "us\n";
|
||||
appendLogToCL(CL(), tmp_ss.str());
|
||||
}
|
||||
delete cpuOpt;
|
||||
|
||||
if ( ret ) {
|
||||
BuildLog() += "Internal Error: optimizer failed!\n";
|
||||
return 1;
|
||||
}
|
||||
if (Options()->isDumpFlagSet(amd::option::DUMP_BC_OPTIMIZED)) {
|
||||
std::string fileName = Options()->getDumpFileName("_optimized.bc");
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
std::string MyErrorInfo;
|
||||
raw_fd_ostream outs (fileName.c_str(), MyErrorInfo, raw_fd_ostream::F_Binary);
|
||||
// FIXME: Need to add this to the elf binary!
|
||||
if (MyErrorInfo.empty())
|
||||
WriteBitcodeToFile(LLVMBinary(), outs);
|
||||
else
|
||||
printf(MyErrorInfo.c_str());
|
||||
#else
|
||||
std::error_code EC;
|
||||
llvm::raw_fd_ostream outs(fileName.c_str(), EC, llvm::sys::fs::F_None);
|
||||
// FIXME: Need to add this to the elf binary!
|
||||
if (!EC)
|
||||
WriteBitcodeToFile(LLVMBinary(), outs);
|
||||
else
|
||||
printf(EC.message().c_str());
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
GPUOptimizer::optimize(llvm::Module *input)
|
||||
{
|
||||
if (!input) {
|
||||
return 1;
|
||||
}
|
||||
int ret = 0;
|
||||
uint64_t start_time = 0ULL, time_opt = 0ULL;
|
||||
llvmbinary_ = input;
|
||||
|
||||
setGPU(true);
|
||||
setWholeProgram(true);
|
||||
#ifdef WITH_TARGET_HSAIL
|
||||
if (isHSAILTarget(Elf()->target)) {
|
||||
if (Options()->NumAvailGPRs == -1)
|
||||
Options()->NumAvailGPRs = 128; // Default HSAIL number of GPRs
|
||||
if (hookup_.amdoptions.NumAvailGPRs == ~0u)
|
||||
hookup_.amdoptions.NumAvailGPRs = Options()->NumAvailGPRs;
|
||||
}
|
||||
#endif
|
||||
setUniformWorkGroupSize(Options()->oVariables->UniformWorkGroupSize);
|
||||
OptLevel* gpuOpt = getOptLevel(Options(), true);
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
time_opt = amd::Os::timeNanos();
|
||||
}
|
||||
ret = gpuOpt->optimize(Elf(), LLVMBinary(), true);
|
||||
if (Options()->oVariables->EnableBuildTiming) {
|
||||
time_opt = amd::Os::timeNanos() - time_opt;
|
||||
std::stringstream tmp_ss;
|
||||
tmp_ss << " LLVM Opt time: "
|
||||
<< time_opt/1000ULL
|
||||
<< "us\n";
|
||||
appendLogToCL(CL(), tmp_ss.str());
|
||||
}
|
||||
delete gpuOpt;
|
||||
|
||||
if ( ret ) {
|
||||
BuildLog() += "Internal Error: optimizer failed!\n";
|
||||
return 1;
|
||||
}
|
||||
if (Options()->isDumpFlagSet(amd::option::DUMP_BC_OPTIMIZED)) {
|
||||
std::string fileName = Options()->getDumpFileName("_optimized.bc");
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
std::string MyErrorInfo;
|
||||
raw_fd_ostream outs (fileName.c_str(), MyErrorInfo, raw_fd_ostream::F_Binary);
|
||||
// FIXME: Need to add this to the elf binary!
|
||||
if (MyErrorInfo.empty())
|
||||
WriteBitcodeToFile(LLVMBinary(), outs);
|
||||
else
|
||||
printf(MyErrorInfo.c_str());
|
||||
#else
|
||||
std::error_code EC;
|
||||
llvm::raw_fd_ostream outs(fileName.c_str(), EC, llvm::sys::fs::F_None);
|
||||
// FIXME: Need to add this to the elf binary!
|
||||
if (!EC)
|
||||
WriteBitcodeToFile(LLVMBinary(), outs);
|
||||
else
|
||||
printf(EC.message().c_str());
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _BE_OPTIMIZER_HPP_
|
||||
#define _BE_OPTIMIZER_HPP_
|
||||
#include "aclTypes.h"
|
||||
#include "compiler_stage.hpp"
|
||||
|
||||
namespace llvm
|
||||
{
|
||||
class Module;
|
||||
}
|
||||
|
||||
namespace amdcl
|
||||
{
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::Optimizer
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class Optimizer : public LLVMCompilerStage {
|
||||
Optimizer(Optimizer&); // DO NOT IMPLEMENT.
|
||||
Optimizer(); // DO NOT IMPLEMENT.
|
||||
public:
|
||||
Optimizer(aclCompiler *cl, aclBinary* elf, aclLogFunction log)
|
||||
: LLVMCompilerStage(cl, elf, log) {
|
||||
// Expose some options to LLVM
|
||||
llvm::AMDOptions *amdopts = &hookup_.amdoptions;
|
||||
if (opts_) {
|
||||
amdopts->OptLiveness = opts_->oVariables->OptLiveness;
|
||||
amdopts->NumAvailGPRs = opts_->NumAvailGPRs;
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~Optimizer() {}
|
||||
|
||||
/*! Function that takes in the LLVM module as input
|
||||
* and optimizes it.
|
||||
* Returns 0 on success and non-zero on failure.
|
||||
*/
|
||||
virtual int optimize(llvm::Module *input) = 0;
|
||||
|
||||
}; // class Optimizer
|
||||
/*@}*/
|
||||
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::CLOptimizer
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class CLOptimizer : public Optimizer {
|
||||
public:
|
||||
CLOptimizer(aclCompiler *cl, aclBinary *elf, aclLogFunction log)
|
||||
: Optimizer(cl, elf, log) {}
|
||||
virtual ~CLOptimizer() {}
|
||||
|
||||
/*! Function that takes in the LLVM module as input
|
||||
* and optimizes it.
|
||||
* Returns 0 on success and non-zero on failure.
|
||||
*/
|
||||
virtual int optimize(llvm::Module *input) = 0;
|
||||
}; // class CLOptimizer
|
||||
/*@}*/
|
||||
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::GPUOptimizer
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class GPUOptimizer : public CLOptimizer {
|
||||
public:
|
||||
GPUOptimizer(aclCompiler *cl, aclBinary *elf, aclLogFunction log)
|
||||
: CLOptimizer(cl, elf, log) {}
|
||||
virtual ~GPUOptimizer() {}
|
||||
|
||||
/*! Function that takes in the LLVM module as input
|
||||
* and optimizes it.
|
||||
* Returns 0 on success and non-zero on failure.
|
||||
*/
|
||||
virtual int optimize(llvm::Module *input);
|
||||
}; // class GPUOptimizer
|
||||
/*@}*/
|
||||
|
||||
/*! \addtogroup Compiler Library
|
||||
*
|
||||
* \copydoc amdcl::CPUOptimizer
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
class CPUOptimizer : public CLOptimizer {
|
||||
public:
|
||||
CPUOptimizer(aclCompiler *cl, aclBinary *elf, aclLogFunction log)
|
||||
: CLOptimizer(cl, elf, log) {}
|
||||
virtual ~CPUOptimizer() {}
|
||||
|
||||
/*! Function that takes in the LLVM module as input
|
||||
* and optimizes it.
|
||||
* Returns 0 on success and non-zero on failure.
|
||||
*/
|
||||
virtual int optimize(llvm::Module *input);
|
||||
protected:
|
||||
int preOptimizer(llvm::Module *m);
|
||||
}; // class CPUOptimizer
|
||||
/*@}*/
|
||||
|
||||
}; // amdcl namespace
|
||||
#endif // _BE_OPTIMIZER_HPP_
|
||||
@@ -1,165 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#include "top.hpp"
|
||||
#include "spir.hpp"
|
||||
#include "aclTypes.h"
|
||||
#include "bif/bifbase.hpp"
|
||||
#include "utils/libUtils.h"
|
||||
#include "utils/options.hpp"
|
||||
#include "utils/target_mappings.h"
|
||||
#include "os/os.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
#include "llvm/DataLayout.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/Assembly/PrintModulePass.h"
|
||||
#else
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#endif
|
||||
#include "llvm/Pass.h"
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
#include "llvm/PassManager.h"
|
||||
#else
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#endif
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/Analysis/SPIRVerifier.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Bitcode/BitstreamWriter.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
#define LLVMReturnStatusAction ReturnStatusAction
|
||||
#endif
|
||||
|
||||
using namespace llvm;
|
||||
using namespace amdcl;
|
||||
|
||||
Module*
|
||||
amdcl::SPIR::loadSPIR(std::string &spirBinary)
|
||||
{
|
||||
// Need to use the namespace here since a parent function is called Module().
|
||||
llvm::Module *bc = NULL;
|
||||
std::string errors;
|
||||
source_ = spirBinary;
|
||||
SPIRState State = {"", "", 1, 0, 1, 2};
|
||||
bc = amdcl::LLVMCompilerStage::loadBitcode(source_);
|
||||
if (!bc)
|
||||
{
|
||||
errors = "loadBitcode failed";
|
||||
log_ += errors;
|
||||
return NULL;
|
||||
}
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
verifyModule(*bc, ReturnStatusAction, &errors);
|
||||
#else
|
||||
raw_string_ostream errorsOS(errors);
|
||||
verifyModule(*bc, &errorsOS);
|
||||
#endif
|
||||
if (!errors.empty()) {
|
||||
log_ += errors;
|
||||
errors.clear();
|
||||
}
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
FunctionPassManager FPM(bc);
|
||||
#else
|
||||
legacy::FunctionPassManager FPM(bc);
|
||||
#endif
|
||||
if (Options()->oVariables->verifyHWSpir) {
|
||||
if (!isHSAILTarget(Elf()->target)) {
|
||||
verifySPIRModule(*bc, LLVMReturnStatusAction, State, false, &errors);
|
||||
}
|
||||
if (!errors.empty()) {
|
||||
log_ += errors;
|
||||
errors.clear();
|
||||
delete bc;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (Options()->oVariables->verifyLWSpir) {
|
||||
if (!isHSAILTarget(Elf()->target)) {
|
||||
verifySPIRModule(*bc, LLVMReturnStatusAction, State, true, &errors);
|
||||
}
|
||||
if (!errors.empty()) {
|
||||
log_ += errors;
|
||||
errors.clear();
|
||||
delete bc;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return bc;
|
||||
}
|
||||
Module*
|
||||
amdcl::SPIR::loadBitcode(std::string &binary)
|
||||
{
|
||||
llvm::Module *bc = loadSPIR(binary);
|
||||
if (!bc) return NULL;
|
||||
|
||||
// FIXME: It is not clear why SPIRLoader is invoked so early here.
|
||||
// The current view is to keep SPIRLoader as a pure pre-link pass to
|
||||
// be called only by the linker.
|
||||
StringRef LayoutStr = is64BitTarget(Elf()->target) ?
|
||||
DATA_LAYOUT_64BIT : DATA_LAYOUT_32BIT;
|
||||
bc->setDataLayout(LayoutStr);
|
||||
bc->setTargetTriple(familySet[Elf()->target.arch_id].triple);
|
||||
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
llvm::PassManager SPIRPasses;
|
||||
SPIRPasses.add(new llvm::DataLayout(bc));
|
||||
#else
|
||||
llvm::legacy::PassManager SPIRPasses;
|
||||
#endif
|
||||
SPIRPasses.add(createSPIRLoader(/*demangleBuiltin=*/ true));
|
||||
SPIRPasses.run(*bc);
|
||||
return bc;
|
||||
}
|
||||
|
||||
const void*
|
||||
SPIR::toBinary(const void *text, size_t text_size, size_t *binary_size)
|
||||
{
|
||||
std::string text_buf(reinterpret_cast<const char*>(text), text_size);
|
||||
// Need to use the namespace here since a parent function is called Module().
|
||||
llvm::Module *mod = loadSPIR(text_buf);
|
||||
SmallString<256> char_buf;
|
||||
raw_svector_ostream outstream(char_buf);
|
||||
WriteBitcodeToFile(mod, outstream);
|
||||
std::string str_buf(char_buf.begin(), char_buf.end());
|
||||
(*binary_size) = char_buf.size();
|
||||
void *ptr = aclutAlloc(CL())(*binary_size);
|
||||
std::copy(char_buf.begin(), char_buf.end(), reinterpret_cast<char*>(ptr));
|
||||
return ptr;
|
||||
}
|
||||
|
||||
const void*
|
||||
SPIR::toText(const void *binary, size_t binary_size, size_t *text_size)
|
||||
{
|
||||
std::string text_buf(reinterpret_cast<const char*>(binary), binary_size);
|
||||
// Need to use the namespace here since a parent function is called Module().
|
||||
llvm::Module *mod = loadSPIR(text_buf);
|
||||
std::string errors;
|
||||
if (!mod)
|
||||
{
|
||||
errors = "loadSPIR failed";
|
||||
log_ += errors;
|
||||
return NULL;
|
||||
}
|
||||
std::string bin_buf;
|
||||
raw_string_ostream buf(bin_buf);
|
||||
mod->print(buf, NULL);
|
||||
(*text_size) = bin_buf.size();
|
||||
void *ptr = aclutAlloc(CL())(*text_size);
|
||||
std::copy(bin_buf.begin(), bin_buf.end(), reinterpret_cast<char*>(ptr));
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _BE_SPIR_HPP_
|
||||
#define _BE_SPIR_HPP_
|
||||
#include <string>
|
||||
#include "aclTypes.h"
|
||||
#include "compiler_stage.hpp"
|
||||
namespace amdcl
|
||||
{
|
||||
/*@}*/
|
||||
|
||||
/*! \addtogroup CompilerLibrary
|
||||
*
|
||||
* \copydoc amdcl::SPIR
|
||||
*
|
||||
* @{
|
||||
* \brief Implementation of the Frontend interface to compile
|
||||
* from OpenCL C to LLVM-IR.
|
||||
*/
|
||||
class SPIR : public LLVMCompilerStage {
|
||||
SPIR(SPIR&); // DO NOT IMPLEMENT.
|
||||
SPIR(); // DO NOT IMPLEMENT.
|
||||
|
||||
public:
|
||||
SPIR(aclCompiler* cl, aclBinary* elf, aclLogFunction log)
|
||||
: LLVMCompilerStage(cl, elf, log) {}
|
||||
|
||||
virtual ~SPIR() {}
|
||||
virtual llvm::Module* loadBitcode(std::string &spirBinary) override;
|
||||
virtual llvm::Module* loadSPIR(std::string &spirBinary);
|
||||
const void*
|
||||
toBinary(const void *text, size_t text_size, size_t *binary_size);
|
||||
const void*
|
||||
toText(const void *binary, size_t binary_size, size_t *text_size);
|
||||
|
||||
}; // class SPIR
|
||||
/*@}*/
|
||||
} // namespac amdcl
|
||||
#endif // _BE_SPIR_HPP_
|
||||
@@ -1,24 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#include "sync.hpp"
|
||||
#include "llvm/Support/Mutex.h"
|
||||
#include "llvm/Support/Threading.h"
|
||||
|
||||
|
||||
static llvm::sys::MutexImpl mtx;
|
||||
|
||||
namespace amdcl
|
||||
{
|
||||
|
||||
void acquire_global_lock() {
|
||||
if (llvm::llvm_is_multithreaded())
|
||||
mtx.acquire();
|
||||
}
|
||||
|
||||
void release_global_lock() {
|
||||
if (llvm::llvm_is_multithreaded())
|
||||
mtx.release();
|
||||
}
|
||||
|
||||
} // namespace amdcl
|
||||
@@ -1,13 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _BE_SYNC_HPP_
|
||||
#define _BE_SYNC_HPP_
|
||||
|
||||
namespace amdcl
|
||||
{
|
||||
void acquire_global_lock();
|
||||
|
||||
void release_global_lock();
|
||||
} // namespace amdcl
|
||||
#endif // _BE_SYNC_HPP_
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,172 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _IF_ACL_0_8_H_
|
||||
#define _IF_ACL_0_8_H_
|
||||
#include "aclTypes.h"
|
||||
aclLoaderData* ACL_API_ENTRY
|
||||
if_aclCompilerInit(aclCompiler *cl, aclBinary *bin, aclLogFunction log, acl_error *error);
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclCompilerFini(aclLoaderData *ald);
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclCompile(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *options,
|
||||
aclType from,
|
||||
aclType to,
|
||||
aclLogFunction compile_callback) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclLink(aclCompiler *cl,
|
||||
aclBinary *src_bin,
|
||||
unsigned int num_libs,
|
||||
aclBinary **libs,
|
||||
aclType link_mode,
|
||||
const char *options,
|
||||
aclLogFunction link_callback) ACL_API_0_8;
|
||||
|
||||
const char* ACL_API_ENTRY
|
||||
if_aclGetCompilerLog(aclCompiler *cl) ACL_API_0_8;
|
||||
|
||||
const void* ACL_API_ENTRY
|
||||
if_aclRetrieveType(aclCompiler *cl,
|
||||
const aclBinary *bin,
|
||||
const char *name,
|
||||
size_t *data_size,
|
||||
aclType type,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclSetType(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *name,
|
||||
aclType type,
|
||||
const void *data,
|
||||
size_t size) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclConvertType(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *name,
|
||||
aclType type) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclDisassemble(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *kernel,
|
||||
aclLogFunction disasm_callback) ACL_API_0_8;
|
||||
|
||||
const void* ACL_API_ENTRY
|
||||
if_aclGetDeviceBinary(aclCompiler *cl,
|
||||
const aclBinary *bin,
|
||||
const char *kernel,
|
||||
size_t *size,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclInsertSection(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
const void *data,
|
||||
size_t data_size,
|
||||
aclSections id) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclInsertSymbol(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
const void *data,
|
||||
size_t data_size,
|
||||
aclSections id,
|
||||
const char *symbol) ACL_API_0_8;
|
||||
|
||||
const void* ACL_API_ENTRY
|
||||
if_aclExtractSection(aclCompiler *cl,
|
||||
const aclBinary *binary,
|
||||
size_t *size,
|
||||
aclSections id,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
const void* ACL_API_ENTRY
|
||||
if_aclExtractSymbol(aclCompiler *cl,
|
||||
const aclBinary *binary,
|
||||
size_t *size,
|
||||
aclSections id,
|
||||
const char *symbol,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclRemoveSection(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
aclSections id) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclRemoveSymbol(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
aclSections id,
|
||||
const char *symbol) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclQueryInfo(aclCompiler *cl,
|
||||
const aclBinary *binary,
|
||||
aclQueryType query,
|
||||
const char *kernel,
|
||||
void *data_ptr,
|
||||
size_t *ptr_size) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclDbgAddArgument(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *kernel,
|
||||
const char *name,
|
||||
bool byVal) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclDbgRemoveArgument(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char* kernel,
|
||||
const char* name) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclSetupLoaderObject(aclCompiler *cl) ACL_API_0_8;
|
||||
|
||||
void* ACL_API_ENTRY
|
||||
if_aclJITObjectImageCreate(const void* buffer,
|
||||
size_t length,
|
||||
aclBinary* bin,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
void* ACL_API_ENTRY
|
||||
if_aclJITObjectImageCopy(const void* buffer,
|
||||
size_t length,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclJITObjectImageDestroy(aclJITObjectImage buffer) ACL_API_0_8;
|
||||
|
||||
size_t ACL_API_ENTRY
|
||||
if_aclJITObjectImageSize(aclJITObjectImage image,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
const char* ACL_API_ENTRY
|
||||
if_aclJITObjectImageData(aclJITObjectImage image,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclJITObjectImageFinalize(aclJITObjectImage image) ACL_API_0_8;
|
||||
|
||||
size_t ACL_API_ENTRY
|
||||
if_aclJITObjectImageGetGlobalsSize(aclJITObjectImage image,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
if_aclJITObjectImageIterateSymbols(aclJITObjectImage image,
|
||||
JITSymbolCallback jit_callback, void* data) ACL_API_0_8;
|
||||
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
char* ACL_API_ENTRY
|
||||
if_aclJITObjectImageDisassembleKernel(constAclJITObjectImage image,
|
||||
const char* kernel,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
#endif
|
||||
|
||||
#endif // _IF_ACL_0_8_H_
|
||||
@@ -1,87 +0,0 @@
|
||||
OPENCL_DEPTH ?= $(COMPLIB_DEPTH)/../..
|
||||
|
||||
include $(OPENCL_DEPTH)/opencldefs
|
||||
|
||||
# Set the #defines for sc/Interface like that used to build sc.
|
||||
# For a non-default configuration (for instance adding GFX9),
|
||||
# make GFX9_BUILD=1 wNow.dbg
|
||||
# or change
|
||||
# ../../opencldefs
|
||||
# to make sure that the settings for sc and sc's uses match.
|
||||
include $(OPENCL_DEPTH)/compiler/sc/Interface/scinterfacedefs
|
||||
GCPPFLAGS += $(SC_LIB_DEFS)
|
||||
|
||||
ELFTOOLCHAIN_DIR = $(COMPLIB_DEPTH)/loaders/elf/utils
|
||||
|
||||
ifdef GONE_TO_BUILD_DIR
|
||||
ifneq ($(BUILD_LEGACY_COMPLIB),yes)
|
||||
override BUILD_LLVM_AMDIL_TARGET = no
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_LLVM_HSAIL_TARGET),yes)
|
||||
GCPPFLAGS += $(DEFSWITCH) WITH_TARGET_HSAIL
|
||||
endif
|
||||
|
||||
GCPPFLAGS += $(ASIC_REG_INCS)
|
||||
GCPPFLAGS += $(INCSWITCH) "$(COMPLIB_DEPTH)"
|
||||
GCPPFLAGS += $(INCSWITCH) "$(OPENCL_DEPTH)/runtime"
|
||||
GCPPFLAGS += $(INCSWITCH) "$(OPENCL_DEPTH)/runtime/utils"
|
||||
GCPPFLAGS += $(INCSWITCH) "$(COMPLIB_DEPTH)/utils"
|
||||
GCPPFLAGS += $(INCSWITCH) "$(OPENCL_DEPTH)/api/opencl/khronos/headers/opencl2.0"
|
||||
|
||||
# Do we build the 0.9 version?
|
||||
ifeq ($(BUILD_VERSION_0_9), 1)
|
||||
GCPPFLAGS += $(DEFSWITCH) WITH_VERSION_0_9
|
||||
CLVER_SUBDIR = v0_9
|
||||
else
|
||||
# Otherwise we build v0.8
|
||||
GCPPFLAGS += $(DEFSWITCH) WITH_VERSION_0_8
|
||||
CLVER_SUBDIR = v0_8
|
||||
endif
|
||||
|
||||
GCPPFLAGS += $(INCSWITCH) "$(COMPLIB_DEPTH)/utils/$(CLVER_SUBDIR)"
|
||||
GCPPFLAGS += $(INCSWITCH) "$(COMPLIB_DEPTH)/include/$(CLVER_SUBDIR)"
|
||||
GCPPFLAGS += $(DEFSWITCH) "BREAK_ON_LOG_WARNING=0"
|
||||
GCPPFLAGS += $(DEFSWITCH) "BREAK_ON_LOG_ERROR=0"
|
||||
GCPPFLAGS += $(DEFSWITCH) "LOG_LEVEL=2"
|
||||
|
||||
GCPPFLAGS += $(INCSWITCH) "$(OPENCL_DEPTH)/runtime/device/gpu/gslbe/src/rt"
|
||||
GCPPFLAGS += $(INCSWITCH) "$(UGL_DEPTH)/gl/gs/hwl/si/include/asic"
|
||||
|
||||
export BRIG_ENABLE=1
|
||||
|
||||
ifdef ATI_OS_WINDOWS
|
||||
GCPPFLAGS += $(INCSWITCH) "$(DK_ROOT)/$(DK_DX_SDK)/inc"
|
||||
|
||||
ifeq ($(BUILD_TYPE),dbg)
|
||||
GCXXOPTS += /Ob1
|
||||
endif
|
||||
|
||||
GCXXOPTS += -wd4985 -wd4355 -wd4800 -wd4291 -wd4624 -wd4141
|
||||
|
||||
GCPPFLAGS += $(DEFSWITCH) _SCL_SECURE_NO_WARNINGS
|
||||
|
||||
GCXXOPTS += /GR- # Disable Run-Time Type Information
|
||||
endif
|
||||
|
||||
ifdef ATI_OS_LINUX
|
||||
GCPPFLAGS += $(DEFSWITCH) __STDC_LIMIT_MACROS
|
||||
GCPPFLAGS += $(DEFSWITCH) __STDC_CONSTANT_MACROS
|
||||
|
||||
GCXXOPTS += -fno-rtti -Wno-sign-compare
|
||||
|
||||
ifneq ($(filter gcc/gcc-7.4%,$(DK_C)),)
|
||||
GCXXOPTS += -Wno-deprecated-declarations
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OPENCL_USE_ONE_SC),1)
|
||||
GCPPFLAGS += $(DEFSWITCH) OPENCL_USE_ONE_SC
|
||||
endif
|
||||
|
||||
ifneq (,$(wildcard $(COMPLIB_DEPTH)/loaders/elf/utils/blowfish/blowfish.h))
|
||||
GCPPFLAGS += $(DEFSWITCH) HAVE_BLOWFISH_H
|
||||
endif
|
||||
|
||||
include $(OPENCL_DEPTH)/compiler/scinterfacedefs.opencl
|
||||
@@ -1,4 +0,0 @@
|
||||
COMPLIB_DEPTH = $(OPENCL_DEPTH)/compiler/lib
|
||||
|
||||
#AMDOpenCLLLVMLinkerLIBS = $(COMPLIB_DEPTH)/linker/lib/$(FULL_BUILD_DIR)/AMDLLVMOpenCLLinker$(LIB_EXT)
|
||||
AMDOpenCLLLVMLinkerLIBS = $(OPENCL_DEPTH)/compiler/lib/linker/lib/$(FULL_BUILD_DIR)/AMDOpenCLLLVMLinker$(LIB_EXT)
|
||||
@@ -1,16 +0,0 @@
|
||||
COMPLIB_DEPTH ?= $(OPENCL_DEPTH)/compiler/lib
|
||||
ifdef GONE_TO_BUILD_DIR
|
||||
ifdef ATI_OS_LINUX
|
||||
*$(OBJ_EXT): $(COMPLIB_DEPTH)/complibdefs $(COMPLIB_DEPTH)/complibrules
|
||||
endif
|
||||
endif
|
||||
|
||||
%.v08:
|
||||
@$(MAKENOISE) "Setting BUILD_VERSION_0_8=1"
|
||||
@$(MAKE) BUILD_VERSION_0_8=1 $*
|
||||
|
||||
%.v09:
|
||||
@$(MAKENOISE) "Setting BUILD_VERSION_0_9=1"
|
||||
@$(MAKE) BUILD_VERSION_0_9=1 $*
|
||||
|
||||
include $(OPENCL_DEPTH)/openclrules
|
||||
@@ -1,10 +1,305 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// This is a compatibility header file. Either define the version
|
||||
// of the compiler library that is to be used or include the
|
||||
// header file for that version directly.
|
||||
#ifndef ACL_H_
|
||||
#define ACL_H_
|
||||
#include "v0_8/acl.h"
|
||||
#endif // ACL_H_
|
||||
#ifndef _ACL_0_8_H_
|
||||
#define _ACL_0_8_H_
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "aclTypes.h"
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with aclCompiler objects.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
aclCompiler* ACL_API_ENTRY
|
||||
aclCompilerInit(aclCompilerOptions *opts, acl_error *error_code) ACL_API_0_8;
|
||||
acl_error ACL_API_ENTRY
|
||||
aclCompilerFini(aclCompiler *cl) ACL_API_0_8;
|
||||
aclCLVersion ACL_API_ENTRY
|
||||
aclCompilerVersion(aclCompiler *cl, acl_error *error_code) ACL_API_0_8;
|
||||
uint32_t ACL_API_ENTRY
|
||||
aclVersionSize(aclCLVersion num, acl_error *error_code) ACL_API_0_8;
|
||||
const char* ACL_API_ENTRY
|
||||
aclGetErrorString(acl_error error_code) ACL_API_0_8;
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with target specific information.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
//! Returns in the names argument, if non-NULL, a pointer to each of the arch
|
||||
// names that the compiler supports. If names is NULL and arch_size is
|
||||
// non-NULL, returns the number of arch entries that are required.
|
||||
acl_error ACL_API_ENTRY
|
||||
aclGetArchInfo(const char** arch_names,
|
||||
size_t *arch_size) ACL_API_0_8;
|
||||
|
||||
//! Returns in the arch argument, if non-NULL, a pointer to each device
|
||||
// name that the compiler supports. If device_size is non-NULL,
|
||||
// returns the number of device entries that are used.
|
||||
acl_error ACL_API_ENTRY
|
||||
aclGetDeviceInfo(const char* arch,
|
||||
const char **names,
|
||||
size_t *device_size) ACL_API_0_8;
|
||||
|
||||
//! Function that returns a correctly filled out aclTargetInfo structure based
|
||||
// on the information passed into the kernel.
|
||||
aclTargetInfo ACL_API_ENTRY
|
||||
aclGetTargetInfo(const char *arch,
|
||||
const char *device,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
//! Function that returns a correctly filled out aclTargetInfo structure based
|
||||
// on the information passed into the kernel.
|
||||
aclTargetInfo ACL_API_ENTRY
|
||||
aclGetTargetInfoFromChipID(const char *arch,
|
||||
const uint32_t chip_id,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
//! Function that returns a string representation of the target architecture.
|
||||
const char* ACL_API_ENTRY
|
||||
aclGetArchitecture(const aclTargetInfo &target) ACL_API_0_8;
|
||||
|
||||
//! Function that returns a string representation of the target chip options.
|
||||
const uint64_t ACL_API_ENTRY
|
||||
aclGetChipOptions(const aclTargetInfo &target) ACL_API_0_8;
|
||||
|
||||
//! Function that returns a string representation of the target family.
|
||||
const char* ACL_API_ENTRY
|
||||
aclGetFamily(const aclTargetInfo &target) ACL_API_0_8;
|
||||
|
||||
//! Function that returns a string representation of the target chip.
|
||||
const char* ACL_API_ENTRY
|
||||
aclGetChip(const aclTargetInfo &target) ACL_API_0_8;
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with aclBinary objects.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
aclBinary* ACL_API_ENTRY
|
||||
aclBinaryInit(
|
||||
size_t struct_version,
|
||||
const aclTargetInfo *target,
|
||||
const aclBinaryOptions *options,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclBinaryFini(aclBinary *bin) ACL_API_0_8;
|
||||
|
||||
aclBinary* ACL_API_ENTRY
|
||||
aclReadFromFile(const char *str,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
aclBinary* ACL_API_ENTRY
|
||||
aclReadFromMem(const void *mem,
|
||||
size_t size, acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclWriteToFile(aclBinary *bin,
|
||||
const char *str) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclWriteToMem(aclBinary *bin,
|
||||
void **mem, size_t *size) ACL_API_0_8;
|
||||
|
||||
aclBinary* ACL_API_ENTRY
|
||||
aclCreateFromBinary(const aclBinary *binary,
|
||||
aclBIFVersion version) ACL_API_0_8;
|
||||
|
||||
aclBIFVersion ACL_API_ENTRY
|
||||
aclBinaryVersion(const aclBinary *binary) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclInsertSection(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
const void *data,
|
||||
size_t data_size,
|
||||
aclSections id) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclInsertSymbol(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
const void *data,
|
||||
size_t data_size,
|
||||
aclSections id,
|
||||
const char *symbol) ACL_API_0_8;
|
||||
|
||||
const void* ACL_API_ENTRY
|
||||
aclExtractSection(aclCompiler *cl,
|
||||
const aclBinary *binary,
|
||||
size_t *size,
|
||||
aclSections id,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
const void* ACL_API_ENTRY
|
||||
aclExtractSymbol(aclCompiler *cl,
|
||||
const aclBinary *binary,
|
||||
size_t *size,
|
||||
aclSections id,
|
||||
const char *symbol,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclRemoveSection(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
aclSections id) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclRemoveSymbol(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
aclSections id,
|
||||
const char *symbol) ACL_API_0_8;
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with debug/metdata.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
acl_error ACL_API_ENTRY
|
||||
aclQueryInfo(aclCompiler *cl,
|
||||
const aclBinary *binary,
|
||||
aclQueryType query,
|
||||
const char *kernel,
|
||||
void *data_ptr,
|
||||
size_t *ptr_size) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclDbgAddArgument(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
const char* kernel,
|
||||
const char* name,
|
||||
bool byVal)
|
||||
ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclDbgRemoveArgument(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
const char* kernel,
|
||||
const char* name)
|
||||
ACL_API_0_8;
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with various compilation phases.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
acl_error ACL_API_ENTRY
|
||||
aclCompile(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *options,
|
||||
aclType from,
|
||||
aclType to,
|
||||
aclLogFunction compile_callback) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclLink(aclCompiler *cl,
|
||||
aclBinary *src_bin,
|
||||
unsigned int num_libs,
|
||||
aclBinary **libs,
|
||||
aclType link_mode,
|
||||
const char *options,
|
||||
aclLogFunction link_callback) ACL_API_0_8;
|
||||
|
||||
const char* ACL_API_ENTRY
|
||||
aclGetCompilerLog(aclCompiler *cl) ACL_API_0_8;
|
||||
|
||||
const void* ACL_API_ENTRY
|
||||
aclRetrieveType(aclCompiler *cl,
|
||||
const aclBinary *bin,
|
||||
const char *name,
|
||||
size_t *data_size,
|
||||
aclType type,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclSetType(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *name,
|
||||
aclType type,
|
||||
const void *data,
|
||||
size_t size) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclConvertType(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *name,
|
||||
aclType type) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclDisassemble(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *kernel,
|
||||
aclLogFunction disasm_callback) ACL_API_0_8;
|
||||
|
||||
const void* ACL_API_ENTRY
|
||||
aclGetDeviceBinary(aclCompiler *cl,
|
||||
const aclBinary *bin,
|
||||
const char *kernel,
|
||||
size_t *size,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with binary image.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
bool ACL_API_ENTRY
|
||||
aclValidateBinaryImage(const void* binary,
|
||||
size_t length, unsigned) ACL_API_0_8;
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with aclJITObjectImage objects.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
aclJITObjectImage ACL_API_ENTRY
|
||||
aclJITObjectImageCreate(aclCompiler *cl, const void* buffer,
|
||||
size_t length, aclBinary* bin, acl_error* error_code);
|
||||
|
||||
aclJITObjectImage ACL_API_ENTRY
|
||||
aclJITObjectImageCopy(aclCompiler *cl, const void* buffer,
|
||||
size_t length, acl_error* error_code);
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclJITObjectImageDestroy(aclCompiler *cl, aclJITObjectImage buffer);
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclJITObjectImageFinalize(aclCompiler *cl, aclJITObjectImage image);
|
||||
|
||||
size_t ACL_API_ENTRY
|
||||
aclJITObjectImageSize(aclCompiler *cl, aclJITObjectImage image,
|
||||
acl_error* error_code);
|
||||
|
||||
const char* ACL_API_ENTRY
|
||||
aclJITObjectImageData(aclCompiler *cl, aclJITObjectImage image,
|
||||
acl_error* error_code);
|
||||
|
||||
size_t ACL_API_ENTRY
|
||||
aclJITObjectImageGetGlobalsSize(aclCompiler *cl, aclJITObjectImage image,
|
||||
acl_error* error_code);
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclJITObjectImageIterateSymbols(aclCompiler *cl, aclJITObjectImage image,
|
||||
aclJITSymbolCallback callback, void* data);
|
||||
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
char* ACL_API_ENTRY
|
||||
aclJITObjectImageDisassembleKernel(aclCompiler *cl, constAclJITObjectImage image,
|
||||
const char* kernel, acl_error* error_code);
|
||||
#endif
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Debug functionality
|
||||
//!--------------------------------------------------------------------------!//
|
||||
void aclDumpBinary(const aclBinary *bin);
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with kenel statistics.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
void aclGetKstatsSI(const void* shader,
|
||||
aclKernelStats &kstats);
|
||||
acl_error ACL_API_ENTRY
|
||||
aclInsertKernelStatistics(aclCompiler *cl,
|
||||
aclBinary *bin);
|
||||
//! Define hardware info constants for SI and above devices
|
||||
const static unsigned SI_sgprs_avail = 102;
|
||||
const static unsigned SI_vgprs_avail = 256;
|
||||
const static unsigned SI_ldssize_avail = 32*1024;
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with memory.
|
||||
// Free memory allocated by aclWriteToMem
|
||||
//!--------------------------------------------------------------------------!//
|
||||
acl_error ACL_API_ENTRY
|
||||
aclFreeMem(aclBinary *bin,
|
||||
void *mem);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // _ACL_0_8_H_
|
||||
@@ -1,10 +1,37 @@
|
||||
//
|
||||
// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// This is a compatibility header file. Either define the version
|
||||
// of the compiler library that is to be used or include the
|
||||
// header file for that version directly.
|
||||
#ifndef ACL_DEFS_H_
|
||||
#define ACL_DEFS_H_
|
||||
#include "v0_8/aclDefs.h"
|
||||
#endif // ACL_DEFS_H_
|
||||
#ifndef _ACL_DEFS_0_8_H_
|
||||
#define _ACL_DEFS_0_8_H_
|
||||
|
||||
#ifndef ACL_API_ENTRY
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#define ACL_API_ENTRY __stdcall
|
||||
#else
|
||||
#define ACL_API_ENTRY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ACL_API_0_8
|
||||
#define ACL_API_0_8
|
||||
#endif
|
||||
|
||||
#ifndef BIF_API_2_0
|
||||
#define BIF_API_2_0
|
||||
#endif
|
||||
|
||||
#ifndef BIF_API_2_1
|
||||
#define BIF_API_2_1
|
||||
#endif
|
||||
|
||||
#ifndef BIF_API_3_0
|
||||
#define BIF_API_3_0
|
||||
#endif
|
||||
|
||||
#ifndef MAX_HIDDEN_KERNARGS_NUM
|
||||
#define MAX_HIDDEN_KERNARGS_NUM 6
|
||||
#else
|
||||
#error "MAX_HIDDEN_KERNARGS_NUM is already defined"
|
||||
#endif
|
||||
|
||||
#endif // _ACL_DEFS_0_8_H_
|
||||
@@ -1,10 +1,347 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// This is a compatibility header file. Either define the version
|
||||
// of the compiler library that is to be used or include the
|
||||
// header file for that version directly.
|
||||
#ifndef ACL_ENUMS_H_
|
||||
#define ACL_ENUMS_H_
|
||||
#include "v0_8/aclEnums.h"
|
||||
#endif // ACL_ENUMS_H_
|
||||
#ifndef _ACL_ENUMS_0_8_H_
|
||||
#define _ACL_ENUMS_0_8_H_
|
||||
|
||||
typedef enum _acl_error_enum_0_8 {
|
||||
ACL_SUCCESS = 0,
|
||||
ACL_ERROR = 1,
|
||||
ACL_INVALID_ARG = 2,
|
||||
ACL_OUT_OF_MEM = 3,
|
||||
ACL_SYS_ERROR = 4,
|
||||
ACL_UNSUPPORTED = 5,
|
||||
ACL_ELF_ERROR = 6,
|
||||
ACL_INVALID_FILE = 7,
|
||||
ACL_INVALID_COMPILER= 8,
|
||||
ACL_INVALID_TARGET = 9,
|
||||
ACL_INVALID_BINARY = 10,
|
||||
ACL_INVALID_OPTION = 11,
|
||||
ACL_INVALID_TYPE = 12,
|
||||
ACL_INVALID_SECTION = 13,
|
||||
ACL_INVALID_SYMBOL = 14,
|
||||
ACL_INVALID_QUERY = 15,
|
||||
ACL_FRONTEND_FAILURE= 16,
|
||||
ACL_INVALID_BITCODE = 17,
|
||||
ACL_LINKER_ERROR = 18,
|
||||
ACL_OPTIMIZER_ERROR = 19,
|
||||
ACL_CODEGEN_ERROR = 20,
|
||||
ACL_ISAGEN_ERROR = 21,
|
||||
ACL_INVALID_SOURCE = 22,
|
||||
ACL_LIBRARY_ERROR = 23,
|
||||
ACL_INVALID_SPIR = 24,
|
||||
ACL_LWVERIFY_FAIL = 25,
|
||||
ACL_HWVERIFY_FAIL = 26,
|
||||
ACL_SPIRV_LOAD_FAIL = 27,
|
||||
ACL_SPIRV_SAVE_FAIL = 28,
|
||||
ACL_LAST_ERROR = 29
|
||||
} acl_error_0_8;
|
||||
|
||||
typedef enum _comp_device_caps_enum_0_8 {
|
||||
capError = 0,
|
||||
capFMA = 1,
|
||||
capImageSupport = 2,
|
||||
capSaveSOURCE = 3, // input source
|
||||
capSaveLLVMIR = 4, // output LLVMIR from frontend
|
||||
capSaveCG = 5, // output from LLVM-BE
|
||||
capSaveEXE = 6, // output executable
|
||||
capSaveAMDIL = 7, // Save per-kernel AMDIL
|
||||
capSaveHSAIL = 8, // Save per-kernel HSAIL
|
||||
capEncrypted = 9,
|
||||
capSaveDISASM = 10,
|
||||
capSaveAS = 11,
|
||||
capSaveSPIR = 12,
|
||||
capDumpLast = 13
|
||||
} compDeviceCaps_0_8;
|
||||
|
||||
typedef enum _comp_opt_settings_enum_0_8 {
|
||||
optO0 = 0, // No optimization setting.
|
||||
optO1 = 1,
|
||||
optO2 = 2,
|
||||
optO3 = 3,
|
||||
optO4 = 4,
|
||||
optOs = 5,
|
||||
optError = 6, // Invalid optimization set
|
||||
optLast = 7
|
||||
} compOptSettings_0_8;
|
||||
|
||||
#define FLAG_SHIFT_VALUE 5
|
||||
#define FLAG_MASK_VALUE ((1 << capDumpLast) - 1)
|
||||
#define FLAG_BITLOC(A) (1 << ((A) & FLAG_MASK_VALUE))
|
||||
#define FLAG_ARRAY_SIZE 4
|
||||
|
||||
//! An enumeration that defines the possible valid device types that
|
||||
// can be compiled for.
|
||||
typedef enum _acl_dev_type_enum_0_8 {
|
||||
aclError = 0, // aclDevType of 0 is an error.
|
||||
aclX86 = 1, // Targeting a 32bit X86 CPU device.
|
||||
aclAMDIL = 2, // Targeting an AMDIL GPU device.
|
||||
aclHSAIL = 3, // Targeting an HSAIL GPU device.
|
||||
aclX64 = 4, // Targeting a 64bit X86 CPU device.
|
||||
aclHSAIL64= 5, // Targeting a 64bit HSAIL GPU device.
|
||||
aclAMDIL64= 6, // Targeting a 64bit AMDIL GPU device
|
||||
aclLast = 7
|
||||
} aclDevType_0_8;
|
||||
|
||||
//! Enum that represents the versions of the compiler
|
||||
typedef enum _acl_cl_version_enum_0_8 {
|
||||
ACL_VERSION_ERROR = 0,
|
||||
ACL_VERSION_0_7 = 1,
|
||||
ACL_VERSION_0_8 = 2,
|
||||
ACL_VERSION_0_8_1 = 3,
|
||||
ACL_VERSION_0_9 = 4,
|
||||
ACL_VERSION_1_0 = 5,
|
||||
ACL_VERSION_LAST = 6
|
||||
} aclCLVersion_0_8;
|
||||
|
||||
//! Enum of the various aclTypes that are supported
|
||||
typedef enum _acl_type_enum_0_8 {
|
||||
ACL_TYPE_DEFAULT = 0,
|
||||
ACL_TYPE_OPENCL = 1,
|
||||
ACL_TYPE_LLVMIR_TEXT = 2,
|
||||
ACL_TYPE_LLVMIR_BINARY = 3,
|
||||
ACL_TYPE_SPIR_TEXT = 4,
|
||||
ACL_TYPE_SPIR_BINARY = 5,
|
||||
ACL_TYPE_AMDIL_TEXT = 6,
|
||||
ACL_TYPE_AMDIL_BINARY = 7,
|
||||
ACL_TYPE_HSAIL_TEXT = 8,
|
||||
ACL_TYPE_HSAIL_BINARY = 9,
|
||||
ACL_TYPE_X86_TEXT = 10,
|
||||
ACL_TYPE_X86_BINARY = 11,
|
||||
ACL_TYPE_CG = 12,
|
||||
ACL_TYPE_SOURCE = 13,
|
||||
ACL_TYPE_ISA = 14,
|
||||
ACL_TYPE_HEADER = 15,
|
||||
ACL_TYPE_RSLLVMIR_BINARY = 16,
|
||||
ACL_TYPE_SPIRV_BINARY = 17,
|
||||
ACL_TYPE_ASM_TEXT = 18,
|
||||
ACL_TYPE_LAST = 19
|
||||
} aclType_0_8;
|
||||
|
||||
//! Enum of the various loader types that are supported.
|
||||
typedef enum _acl_loader_type_enum_0_8 {
|
||||
ACL_LOADER_COMPLIB = 0,
|
||||
ACL_LOADER_FRONTEND = 1,
|
||||
ACL_LOADER_LINKER = 2,
|
||||
ACL_LOADER_OPTIMIZER= 3,
|
||||
ACL_LOADER_CODEGEN = 4,
|
||||
ACL_LOADER_BACKEND = 5,
|
||||
ACL_LOADER_SC = 6,
|
||||
ACL_LOADER_LAST = 7
|
||||
} aclLoaderType_0_8;
|
||||
|
||||
// Enumeration for the various acl versions
|
||||
typedef enum _bif_version_enum_0_8 {
|
||||
aclBIFVersionError = 0, // Error
|
||||
aclBIFVersion20 = 1, // Version 2.0 of the OpenCL BIF
|
||||
aclBIFVersion21 = 2, // Version 2.1 of the OpenCL BIF
|
||||
aclBIFVersion30 = 3, // Version 3.0 of the OpenCL BIF
|
||||
aclBIFVersion31 = 4, // Version 3.1 of the OpenCL BIF
|
||||
aclBIFVersionLatest = aclBIFVersion31, // Most recent version of the BIF
|
||||
aclBIFVersionCAL = 5,
|
||||
aclBIFVersionLast = 6
|
||||
} aclBIFVersion_0_8;
|
||||
|
||||
// Enumeration for the various platform types
|
||||
typedef enum _bif_platform_enum_0_8 {
|
||||
aclPlatformCAL = 0, // For BIF 2.0 backward compatibility
|
||||
aclPlatformCPU = 1, // For BIF 2.0 backward compatibility
|
||||
aclPlatformCompLib = 2,
|
||||
aclPlatformLast = 3
|
||||
} aclPlatform_0_8;
|
||||
|
||||
// Enumeration for the various bif sections
|
||||
typedef enum _bif_sections_enum_0_8 {
|
||||
aclLLVMIR = 0,
|
||||
aclSOURCE = 1,
|
||||
aclILTEXT = 2, // For BIF 2.0 backward compatibility
|
||||
aclASTEXT = 3, // For BIF 2.0 backward compatibility
|
||||
aclCAL = 4, // For BIF 2.0 backward compatibility
|
||||
aclDLL = 5, // For BIF 2.0 backward compatibility
|
||||
aclSTRTAB = 6,
|
||||
aclSYMTAB = 7,
|
||||
aclRODATA = 8,
|
||||
aclSHSTRTAB = 9,
|
||||
aclNOTES = 10,
|
||||
aclCOMMENT = 11,
|
||||
aclILDEBUG = 12, // For BIF 2.0 backward compatibility
|
||||
aclDEBUG_INFO = 13,
|
||||
aclDEBUG_ABBREV = 14,
|
||||
aclDEBUG_LINE = 15,
|
||||
aclDEBUG_PUBNAMES = 16,
|
||||
aclDEBUG_PUBTYPES = 17,
|
||||
aclDEBUG_LOC = 18,
|
||||
aclDEBUG_ARANGES = 19,
|
||||
aclDEBUG_RANGES = 20,
|
||||
aclDEBUG_MACINFO = 21,
|
||||
aclDEBUG_STR = 22,
|
||||
aclDEBUG_FRAME = 23,
|
||||
aclJITBINARY = 24, // For BIF 2.0 backward compatibility
|
||||
aclCODEGEN = 25,
|
||||
aclTEXT = 26,
|
||||
aclINTERNAL = 27,
|
||||
aclSPIR = 28,
|
||||
aclHEADER = 29,
|
||||
aclBRIG = 30,
|
||||
aclBRIGxxx1 = 31,
|
||||
aclBRIGxxx2 = 32,
|
||||
aclBRIGxxx3 = 33,
|
||||
aclHSADEBUG = 34,
|
||||
aclKSTATS = 35, // For storing kernel statistics
|
||||
aclSPIRV = 36,
|
||||
aclLAST = 37
|
||||
} aclSections_0_8;
|
||||
|
||||
//! An enumeration that defines what are valid queries for aclQueryInfo.
|
||||
typedef enum _rt_query_types_enum_0_8 {
|
||||
RT_ABI_VERSION = 0,
|
||||
RT_DEVICE_NAME = 1,
|
||||
RT_MEM_SIZES = 2,
|
||||
RT_GPU_FUNC_CAPS = 3,
|
||||
RT_GPU_FUNC_ID = 4,
|
||||
RT_GPU_DEFAULT_ID = 5,
|
||||
RT_WORK_GROUP_SIZE = 6,
|
||||
RT_WORK_REGION_SIZE = 7,
|
||||
RT_ARGUMENT_ARRAY = 8,
|
||||
RT_GPU_PRINTF_ARRAY = 9,
|
||||
RT_CPU_BARRIER_NAMES = 10,
|
||||
RT_DEVICE_ENQUEUE = 11,
|
||||
RT_KERNEL_INDEX = 12,
|
||||
RT_KERNEL_NAME = 13,
|
||||
RT_KERNEL_NAMES = 14,
|
||||
RT_CONTAINS_LLVMIR = 15,
|
||||
RT_CONTAINS_OPTIONS = 16,
|
||||
RT_CONTAINS_BRIG = 17,
|
||||
RT_CONTAINS_HSAIL = 18,
|
||||
RT_CONTAINS_ISA = 19,
|
||||
RT_CONTAINS_LOADER_MAP = 20,
|
||||
RT_CONTAINS_SPIR = 21,
|
||||
RT_NUM_KERNEL_HIDDEN_ARGS = 22,
|
||||
RT_CONTAINS_SPIRV = 23,
|
||||
RT_WAVES_PER_SIMD_HINT = 24,
|
||||
RT_WORK_GROUP_SIZE_HINT = 25,
|
||||
RT_VEC_TYPE_HINT = 26,
|
||||
RT_LAST_TYPE = 27
|
||||
} aclQueryType_0_8;
|
||||
|
||||
//! An enumeration for the various GPU capabilities
|
||||
typedef enum _rt_gpu_caps_enum_0_8 {
|
||||
RT_COMPILER_WRITE = 1 << 0,
|
||||
RT_DATA_SECTION = 1 << 1,
|
||||
RT_WGS = 1 << 2,
|
||||
RT_LIMIT_WGS = 1 << 3,
|
||||
RT_PACKED_REGS = 1 << 4,
|
||||
RT_64BIT_ABI = 1 << 5,
|
||||
RT_PRINTF = 1 << 6,
|
||||
RT_ARENA_UAV = 1 << 7,
|
||||
RT_LRP_MEM = 1 << 8, // Local/Region/Private Memory
|
||||
RT_INDEX_TEMPS = 1 << 9,
|
||||
RT_WRS = 1 << 10,
|
||||
RT_GWS = 1 << 11,
|
||||
RT_SWGWS = 1 << 12,
|
||||
RT_GPU_CAPS_MASK = 0xFFF
|
||||
} aclGPUCaps_0_8;
|
||||
|
||||
//! An enumeration for the various CPU capabilities.
|
||||
typedef enum _rt_cpu_caps_enum_0_8 {
|
||||
RT_KERNEL_BARRIER = 1 << 0,
|
||||
RT_PROGRAM_BARRIER = 1 << 1,
|
||||
RT_CPU_CAPS_MASK = 0x3
|
||||
} aclCPUCaps_0_8;
|
||||
|
||||
//! An enumeration that maps Resource type to index values
|
||||
typedef enum _rt_gpu_resource_enum_0_8 {
|
||||
RT_RES_UAV = 0, // UAV resources
|
||||
RT_RES_PRI = 1, // Private resources
|
||||
RT_RES_LDS = 2, // LDS resources
|
||||
RT_RES_GDS = 3, // GDS resources
|
||||
RT_RES_CON = 4, // Constant resources
|
||||
RT_RES_LAST = 5
|
||||
} aclGPUResource_0_8;
|
||||
|
||||
//! An enumeration that maps memory types to index values
|
||||
typedef enum _rt_gpu_mem_sizes_enum_0_8 {
|
||||
RT_MEM_HW_LOCAL = 0,
|
||||
RT_MEM_SW_LOCAL = 1,
|
||||
RT_MEM_HW_PRIVATE = 2,
|
||||
RT_MEM_SW_PRIVATE = 3,
|
||||
RT_MEM_HW_REGION = 4,
|
||||
RT_MEM_SW_REGION = 5,
|
||||
RT_MEM_LAST = 6
|
||||
} aclGPUMemSizes_0_8;
|
||||
|
||||
// Enumerations for the various argument types.
|
||||
typedef enum _acl_arg_type_enum_0_8 {
|
||||
ARG_TYPE_ERROR = 0,
|
||||
ARG_TYPE_SAMPLER = 1,
|
||||
ARG_TYPE_IMAGE = 2,
|
||||
ARG_TYPE_COUNTER = 3,
|
||||
ARG_TYPE_VALUE = 4,
|
||||
ARG_TYPE_POINTER = 5,
|
||||
ARG_TYPE_SEMAPHORE = 6,
|
||||
ARG_TYPE_QUEUE = 7, // enum for device enqueue
|
||||
ARG_TYPE_LAST = 8
|
||||
} aclArgType_0_8;
|
||||
|
||||
// Enumerations of the valid data types for pass by value and
|
||||
// pass by pointer kernel arguments.
|
||||
typedef enum _acl_data_type_enum_0_8 {
|
||||
DATATYPE_ERROR = 0,
|
||||
DATATYPE_i1 = 1,
|
||||
DATATYPE_i8 = 2,
|
||||
DATATYPE_i16 = 3,
|
||||
DATATYPE_i32 = 4,
|
||||
DATATYPE_i64 = 5,
|
||||
DATATYPE_u8 = 6,
|
||||
DATATYPE_u16 = 7,
|
||||
DATATYPE_u32 = 8,
|
||||
DATATYPE_u64 = 9,
|
||||
DATATYPE_f16 = 10,
|
||||
DATATYPE_f32 = 11,
|
||||
DATATYPE_f64 = 12,
|
||||
DATATYPE_f80 = 13,
|
||||
DATATYPE_f128 = 14,
|
||||
DATATYPE_struct = 15,
|
||||
DATATYPE_union = 16,
|
||||
DATATYPE_event = 17,
|
||||
DATATYPE_opaque = 18,
|
||||
DATATYPE_unknown = 19,
|
||||
DATATYPE_LAST = 20
|
||||
} aclArgDataType_0_8;
|
||||
|
||||
// Enumerations of the valid memory types for pass by pointer
|
||||
// kernel arguments
|
||||
typedef enum _acl_memory_type_enum_0_8 {
|
||||
PTR_MT_ERROR = 0, // Error
|
||||
PTR_MT_GLOBAL = 1, // global buffer
|
||||
PTR_MT_SCRATCH_EMU = 2, // SW emulated private memory
|
||||
PTR_MT_LDS_EMU = 3, // SW emulated local memory
|
||||
PTR_MT_UAV = 4, // uniformed access vector memory
|
||||
PTR_MT_CONSTANT_EMU = 5, // SW emulated constant memory
|
||||
PTR_MT_GDS_EMU = 6, // SW emulated region memory
|
||||
PTR_MT_LDS = 7, // HW local memory
|
||||
PTR_MT_SCRATCH = 8, // HW private memory
|
||||
PTR_MT_CONSTANT = 9, // HW constant memory
|
||||
PTR_MT_GDS = 10, // HW region memory
|
||||
PTR_MT_UAV_SCRATCH = 11, // SI and later HW private memory
|
||||
PTR_MT_UAV_CONSTANT = 12, // SI and later HW constant memory
|
||||
PTR_MT_LAST = 13
|
||||
} aclMemoryType_0_8;
|
||||
|
||||
// Enumeration that specifies the various access types for a pointer/image.
|
||||
typedef enum _acl_access_type_enum_0_8 {
|
||||
ACCESS_TYPE_ERROR = 0,
|
||||
ACCESS_TYPE_RO = 1,
|
||||
ACCESS_TYPE_WO = 2,
|
||||
ACCESS_TYPE_RW = 3,
|
||||
ACCESS_TYPE_LAST = 4
|
||||
} aclAccessType_0_8;
|
||||
|
||||
// Enumeration that specifies the binary types.
|
||||
typedef enum _acl_binary_image_type_enum_0_8 {
|
||||
BINARY_TYPE_ELF = 1,
|
||||
BINARY_TYPE_LLVM = 2,
|
||||
BINARY_TYPE_SPIRV = 4,
|
||||
} aclBinaryImageType_0_8;
|
||||
|
||||
#endif // _ACL_ENUMS_0_8_H_
|
||||
@@ -1,10 +1,230 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// This is a compatibility header file. Either define the version
|
||||
// of the compiler library that is to be used or include the
|
||||
// header file for that version directly.
|
||||
#ifndef ACL_FUNCTORS_H_
|
||||
#define ACL_FUNCTORS_H_
|
||||
#include "v0_8/aclFunctors.h"
|
||||
#endif // ACL_FUNCTORS_H_
|
||||
#ifndef _ACL_FUNCTORS_0_8_H_
|
||||
#define _ACL_FUNCTORS_0_8_H_
|
||||
|
||||
//! Callback for the log function function pointer that many
|
||||
// API calls take to have the calling application receive
|
||||
// information on what errors occur.
|
||||
typedef void (*aclLogFunction_0_8)(const char *msg, size_t size);
|
||||
|
||||
typedef bool (*aclJITSymbolCallback)(const char*, const void*, void*);
|
||||
typedef void* aclJITObjectImage;
|
||||
typedef const void* constAclJITObjectImage;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *InsertSec_0_8)(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
const void *data,
|
||||
size_t data_size,
|
||||
aclSections id) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *InsertSym_0_8)(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
const void *data,
|
||||
size_t data_size,
|
||||
aclSections id,
|
||||
const char *symbol) ACL_API_0_8;
|
||||
|
||||
typedef const void *
|
||||
(ACL_API_ENTRY *ExtractSec_0_8)(aclCompiler *cl,
|
||||
const aclBinary *binary,
|
||||
size_t *size,
|
||||
aclSections id,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
typedef const void *
|
||||
(ACL_API_ENTRY *ExtractSym_0_8)(aclCompiler *cl,
|
||||
const aclBinary *binary,
|
||||
size_t *size,
|
||||
aclSections id,
|
||||
const char *symbol,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *RemoveSec_0_8)(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
aclSections id) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *RemoveSym_0_8)(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
aclSections id,
|
||||
const char *symbol) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *QueryInfo_0_8)(aclCompiler *cl,
|
||||
const aclBinary *binary,
|
||||
aclQueryType query,
|
||||
const char *kernel,
|
||||
void *data_ptr,
|
||||
size_t *ptr_size) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *AddDbgArg_0_8)(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *kernel,
|
||||
const char *name,
|
||||
bool byVal) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *RemoveDbgArg_0_8)(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *kernel,
|
||||
const char *name) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *Compile_0_8)(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *options,
|
||||
aclType from,
|
||||
aclType to,
|
||||
aclLogFunction_0_8 compile_callback) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *Link_0_8)(aclCompiler *cl,
|
||||
aclBinary *src_bin,
|
||||
unsigned int num_libs,
|
||||
aclBinary **libs,
|
||||
aclType link_mode,
|
||||
const char *options,
|
||||
aclLogFunction_0_8 link_callback) ACL_API_0_8;
|
||||
|
||||
typedef const char *
|
||||
(ACL_API_ENTRY *CompLog_0_8)(aclCompiler *cl) ACL_API_0_8;
|
||||
|
||||
typedef const void *
|
||||
(ACL_API_ENTRY *RetrieveType_0_8)(aclCompiler *cl,
|
||||
const aclBinary *bin,
|
||||
const char *name,
|
||||
size_t *data_size,
|
||||
aclType type,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *SetType_0_8)(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *name,
|
||||
aclType type,
|
||||
const void *data,
|
||||
size_t size) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *ConvertType_0_8)(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *name,
|
||||
aclType type) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *Disassemble_0_8)(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *kernel,
|
||||
aclLogFunction_0_8 disasm_callback) ACL_API_0_8;
|
||||
|
||||
typedef const void *
|
||||
(ACL_API_ENTRY *GetDevBinary_0_8)(aclCompiler *cl,
|
||||
const aclBinary *bin,
|
||||
const char *kernel,
|
||||
size_t *size,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
typedef aclLoaderData *
|
||||
(ACL_API_ENTRY *LoaderInit_0_8)(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
aclLogFunction_0_8 callback,
|
||||
acl_error *error);
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *LoaderFini_0_8)(aclLoaderData *data);
|
||||
|
||||
typedef aclModule *
|
||||
(ACL_API_ENTRY *FEToIR_0_8)(aclLoaderData *ald,
|
||||
const char *source,
|
||||
size_t data_size,
|
||||
aclContext *ctx,
|
||||
acl_error *error) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *SourceToISA_0_8)(aclLoaderData *ald,
|
||||
const char *source,
|
||||
size_t data_size) ACL_API_0_8;
|
||||
|
||||
typedef aclModule *
|
||||
(ACL_API_ENTRY *IRPhase_0_8)(aclLoaderData *data,
|
||||
aclModule *ir,
|
||||
aclContext *ctx,
|
||||
acl_error *error) ACL_API_0_8;
|
||||
|
||||
typedef aclModule *
|
||||
(ACL_API_ENTRY *LinkPhase_0_8)(aclLoaderData *data,
|
||||
aclModule *ir,
|
||||
unsigned int num_libs,
|
||||
aclModule **libs,
|
||||
aclContext *ctx,
|
||||
acl_error *error) ACL_API_0_8;
|
||||
|
||||
typedef const void *
|
||||
(ACL_API_ENTRY *CGPhase_0_8)(aclLoaderData *data,
|
||||
aclModule *ir,
|
||||
aclContext *ctx,
|
||||
acl_error *error) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *DisasmISA_0_8)(aclLoaderData *data,
|
||||
const char *kernel,
|
||||
const void *isa_code,
|
||||
size_t isa_size) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *SetupLoaderObject_0_8)(aclCompiler *cl) ACL_API_0_8;
|
||||
|
||||
typedef aclJITObjectImage
|
||||
(ACL_API_ENTRY *JITObjectImageCreate_0_8)(const void* buffer,
|
||||
size_t length,
|
||||
aclBinary* bin,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
typedef aclJITObjectImage
|
||||
(ACL_API_ENTRY *JITObjectImageCopy_0_8)(const void* buffer,
|
||||
size_t length,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *JITObjectImageDestroy_0_8)(aclJITObjectImage image) ACL_API_0_8;
|
||||
|
||||
typedef size_t
|
||||
(ACL_API_ENTRY *JITObjectImageSize_0_8)(aclJITObjectImage image,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
typedef const char *
|
||||
(ACL_API_ENTRY *JITObjectImageData_0_8)(aclJITObjectImage image,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *JITObjectImageFinalize_0_8)(aclJITObjectImage image) ACL_API_0_8;
|
||||
|
||||
typedef size_t
|
||||
(ACL_API_ENTRY *JITObjectImageGetGlobalsSize_0_8)(aclJITObjectImage image,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
typedef bool (*JITSymbolCallback_0_8)(const char*, const void*, void*);
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *JITObjectImageIterateSymbols_0_8)(aclJITObjectImage image,
|
||||
JITSymbolCallback_0_8 jit_callback,
|
||||
void* data) ACL_API_0_8;
|
||||
|
||||
typedef char*
|
||||
(ACL_API_ENTRY *JITObjectImageDisassembleKernel_0_8)(constAclJITObjectImage image,
|
||||
const char* kernel,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
typedef void*
|
||||
(*AllocFunc_0_8)(size_t size) ACL_API_0_8;
|
||||
|
||||
typedef void
|
||||
(*FreeFunc_0_8)(void *ptr) ACL_API_0_8;
|
||||
|
||||
#endif // _ACL_FUNCTORS_0_8_H_
|
||||
@@ -1,10 +1,349 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// This is a compatibility header file. Either define the version
|
||||
// of the compiler library that is to be used or include the
|
||||
// header file for that version directly.
|
||||
#ifndef ACL_STRUCTS_H_
|
||||
#define ACL_STRUCTS_H_
|
||||
#include "v0_8/aclStructs.h"
|
||||
#endif // ACL_STRUCTS_H_
|
||||
#ifndef _ACL_STRUCTS_0_8_H_
|
||||
#define _ACL_STRUCTS_0_8_H_
|
||||
#define ACL_STRUCT_HEADER \
|
||||
size_t struct_size
|
||||
//! A structure that holds information on the various types of arguments
|
||||
// The format in memory of this structure is
|
||||
// -------------
|
||||
// | aclArgData |
|
||||
// -------------
|
||||
// |->argStr |
|
||||
// -------------
|
||||
// |->typeStr |
|
||||
// -------------
|
||||
typedef struct _acl_md_arg_type_0_8 {
|
||||
ACL_STRUCT_HEADER;
|
||||
size_t argNameSize;
|
||||
size_t typeStrSize;
|
||||
const char *argStr;
|
||||
const char *typeStr;
|
||||
union {
|
||||
struct { // Struct for sampler arguments
|
||||
unsigned ID;
|
||||
unsigned isKernelDefined;
|
||||
unsigned value;
|
||||
} sampler;
|
||||
struct { // Struct for image arguments
|
||||
unsigned resID;
|
||||
unsigned cbNum;
|
||||
unsigned cbOffset;
|
||||
aclAccessType type;
|
||||
bool is2D;
|
||||
bool is1D;
|
||||
bool isArray;
|
||||
bool isBuffer;
|
||||
} image;
|
||||
struct { // struct for atomic counter arguments
|
||||
unsigned is32bit;
|
||||
unsigned resID;
|
||||
unsigned cbNum;
|
||||
unsigned cbOffset;
|
||||
} counter;
|
||||
struct { // struct for semaphore arguments
|
||||
unsigned resID;
|
||||
unsigned cbNum;
|
||||
unsigned cbOffset;
|
||||
} sema;
|
||||
struct { // struct for pass by value arguments
|
||||
unsigned numElements;
|
||||
unsigned cbNum;
|
||||
unsigned cbOffset;
|
||||
aclArgDataType data;
|
||||
} value;
|
||||
struct { // struct for pass by pointer arguments
|
||||
unsigned numElements;
|
||||
unsigned cbNum;
|
||||
unsigned cbOffset;
|
||||
unsigned bufNum;
|
||||
unsigned align;
|
||||
aclArgDataType data;
|
||||
aclMemoryType memory;
|
||||
aclAccessType type;
|
||||
bool isVolatile;
|
||||
bool isRestrict;
|
||||
bool isPipe;
|
||||
} pointer;
|
||||
struct { // Struct for queue arguments
|
||||
unsigned numElements;
|
||||
unsigned cbNum;
|
||||
unsigned cbOffset;
|
||||
aclArgDataType data;
|
||||
aclMemoryType memory;
|
||||
} queue;
|
||||
} arg;
|
||||
aclArgType type;
|
||||
bool isConst;
|
||||
} aclArgData_0_8;
|
||||
|
||||
//! A structure that holds information for printf
|
||||
// The format in memory of this structure is
|
||||
// --------------
|
||||
// | aclPrintfFmt|
|
||||
// --------------
|
||||
// |->argSizes |
|
||||
// --------------
|
||||
// |->fmrStr |
|
||||
// --------------
|
||||
|
||||
typedef struct _acl_md_printf_fmt_0_8 {
|
||||
ACL_STRUCT_HEADER;
|
||||
unsigned ID;
|
||||
size_t numSizes;
|
||||
size_t fmtStrSize;
|
||||
uint32_t *argSizes;
|
||||
const char *fmtStr;
|
||||
} aclPrintfFmt_0_8;
|
||||
|
||||
//! A structure that holds the metadata in the RODATA section.
|
||||
typedef struct _acl_metadata_0_8 {
|
||||
ACL_STRUCT_HEADER; // This holds the size of the structure itself for versioning.
|
||||
size_t data_size; // This holds the size of all the memory allocated for this structure.
|
||||
uint32_t major, minor, revision; // RT_ABI_VERSION
|
||||
uint32_t gpuCaps; // RT_GPU_FUNC_CAPS
|
||||
uint32_t funcID; // RT_GPU_FUNC_ID
|
||||
uint32_t gpuRes[5]; // RT_GPU_DEFAULT_ID
|
||||
size_t wgs[3]; // RT_WORK_GROUP_SIZE
|
||||
uint32_t wrs[3]; // RT_WORK_REGION_SIZE
|
||||
size_t kernelNameSize;
|
||||
size_t deviceNameSize;
|
||||
size_t mem[6]; // RT_MEM_SIZES
|
||||
size_t numArgs;
|
||||
size_t numPrintf;
|
||||
|
||||
aclArgData_0_8 *args; // RT_ARGUMENT_ARRAY
|
||||
aclPrintfFmt_0_8 *printf; // RT_GPU_PRINTF_ARRAY
|
||||
const char *kernelName; // RT_KERNEL_NAME
|
||||
const char *deviceName; // RT_DEVICE_NAME
|
||||
bool enqueue_kernel; // RT_DEVICE_ENQUEUE
|
||||
uint32_t kernel_index; // RT_KERNEL_INDEX
|
||||
uint32_t numHiddenKernelArgs; // RT_NUM_KERNEL_HIDDEN_ARGS
|
||||
size_t wavesPerSimdHint; // RT_WAVES_PER_SIMD_HINT
|
||||
size_t wsh[3]; // RT_WORK_GROUP_SIZE_HINT
|
||||
size_t vecTypeHintSize;
|
||||
const char *vth; // RT_VEC_TYPE_HINT
|
||||
} aclMetadata_0_8;
|
||||
|
||||
//! An structure that holds information on the capabilities of the bif device.
|
||||
typedef struct _acl_device_caps_rec_0_8 {
|
||||
ACL_STRUCT_HEADER;
|
||||
uint32_t flags[4];
|
||||
uint32_t encryptCode;
|
||||
} aclDevCaps_0_8;
|
||||
|
||||
//! Structure that holds information on the target that the source is
|
||||
// being compiled for.
|
||||
typedef struct _acl_target_info_rec_0_8 {
|
||||
ACL_STRUCT_HEADER;
|
||||
aclDevType arch_id; // An identifier for the architecture.
|
||||
uint32_t chip_id; // A identifier for the chip.
|
||||
} aclTargetInfo_0_8;
|
||||
|
||||
// Structure for the version 0.8 of the structure.
|
||||
typedef struct _acl_binary_opts_rec_0_8 {
|
||||
ACL_STRUCT_HEADER;
|
||||
uint32_t elfclass;
|
||||
uint32_t bitness;
|
||||
const char *temp_file;
|
||||
uint32_t kernelArgAlign;
|
||||
} aclBinaryOptions_0_8;
|
||||
|
||||
// Structure for the version 0.8.1 of the structure.
|
||||
// This versions addes in alloc/dealloc functions.
|
||||
typedef struct _acl_binary_opts_rec_0_8_1 {
|
||||
ACL_STRUCT_HEADER;
|
||||
uint32_t elfclass;
|
||||
uint32_t bitness;
|
||||
const char *temp_file;
|
||||
uint32_t kernelArgAlign;
|
||||
AllocFunc_0_8 alloc;
|
||||
FreeFunc_0_8 dealloc;
|
||||
} aclBinaryOptions_0_8_1;
|
||||
|
||||
//! Structure that holds the OpenCL binary information.
|
||||
typedef struct _acl_bif_rec_0_8 {
|
||||
ACL_STRUCT_HEADER;
|
||||
aclTargetInfo_0_8 target; // Information about the target device.
|
||||
aclBIF* bin; // Pointer to the acl.
|
||||
aclOptions* options; // Pointer to acl options.
|
||||
aclBinaryOptions_0_8 binOpts; // Pointer to the binary options.
|
||||
aclDevCaps_0_8 caps; // Capabilities of the BIF.
|
||||
} aclBinary_0_8;
|
||||
|
||||
//! Version of the aclBinary that uses the 0_8_1 version of the aclBinaryOptions.
|
||||
typedef struct _acl_bif_rec_0_8_1 {
|
||||
ACL_STRUCT_HEADER;
|
||||
aclTargetInfo_0_8 target; // Information about the target device.
|
||||
aclBIF* bin; // Pointer to the acl.
|
||||
aclOptions* options; // Pointer to acl options.
|
||||
aclBinaryOptions_0_8_1 binOpts; // Pointer to the binary options.
|
||||
aclDevCaps_0_8 caps; // Capabilities of the BIF.
|
||||
} aclBinary_0_8_1;
|
||||
|
||||
#define ACL_LOADER_COMMON\
|
||||
ACL_STRUCT_HEADER; \
|
||||
bool isBuiltin; \
|
||||
const char *libName; \
|
||||
void *handle; \
|
||||
LoaderInit init; \
|
||||
LoaderFini fini;
|
||||
|
||||
// Struct that maps to the common structure between all loaders.
|
||||
typedef struct _acl_common_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
} aclCommonLoader_0_8;
|
||||
|
||||
typedef struct _acl_cl_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
Compile compile;
|
||||
Link link;
|
||||
CompLog getLog;
|
||||
RetrieveType_0_8 retrieveType;
|
||||
SetType_0_8 setType;
|
||||
ConvertType_0_8 convertType;
|
||||
Disassemble disassemble;
|
||||
GetDevBinary_0_8 devBinary;
|
||||
InsertSec insSec;
|
||||
ExtractSec extSec;
|
||||
RemoveSec remSec;
|
||||
InsertSym insSym;
|
||||
ExtractSym extSym;
|
||||
RemoveSym remSym;
|
||||
QueryInfo getInfo;
|
||||
AddDbgArg addDbg;
|
||||
RemoveDbgArg removeDbg;
|
||||
SetupLoaderObject setupLoaderObject;
|
||||
JITObjectImageCreate jitOICreate;
|
||||
JITObjectImageCopy jitOICopy;
|
||||
JITObjectImageDestroy jitOIDestroy;
|
||||
JITObjectImageSize jitOISize;
|
||||
JITObjectImageData jitOIData;
|
||||
JITObjectImageFinalize jitOIFinalize;
|
||||
JITObjectImageGetGlobalsSize jitOIGlobalSize;
|
||||
JITObjectImageIterateSymbols jitOIIterateSymbols;
|
||||
JITObjectImageDisassembleKernel jitOIDisassembleKernel;
|
||||
} aclCLLoader_0_8;
|
||||
|
||||
//! Structure that holds the required functions
|
||||
// that sc exports for the SCDLL infrastructure.
|
||||
typedef struct _acl_sc_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
uint32_t /*SC_UINT32*/ sc_interface_version;
|
||||
void /**SC_EXPORT_FUNCTIONS**/ *scef;
|
||||
// Any version specific fields go here.
|
||||
} aclSCLoader_0_8;
|
||||
|
||||
typedef struct _acl_fe_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
FEToIR toIR; // Used for Source to aclModule containing LLVMIR
|
||||
FEToIR toModule; // Used to convert raw SPIR/LLVM-IR to aclModule
|
||||
SourceToISA toISA; // Used for Source to ISA
|
||||
} aclFELoader_0_8;
|
||||
|
||||
typedef struct _acl_opt_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
IRPhase optimize; // Used for IR to IR transformation
|
||||
} aclOptLoader_0_8;
|
||||
|
||||
typedef struct _acl_link_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
LinkPhase link; // Used for Linking in IR modules
|
||||
IRPhase toLLVMIR; // Used for converting SPIR to LLVMIR
|
||||
IRPhase toSPIR; // Used for converting LLVMIR to SPIR
|
||||
} aclLinkLoader_0_8;
|
||||
|
||||
typedef struct _acl_cg_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
CGPhase codegen; // Used for converting from LLVMIR to target ASM.
|
||||
} aclCGLoader_0_8;
|
||||
|
||||
typedef struct _acl_be_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
SourceToISA finalize; // Used for converting from target source to target ISA.
|
||||
SourceToISA assemble; // Used for converting from target text to target binary.
|
||||
DisasmISA disassemble; // Used for converting from target binary to target ISA.
|
||||
} aclBELoader_0_8;
|
||||
|
||||
typedef struct _acl_compiler_opts_rec_0_8 {
|
||||
ACL_STRUCT_HEADER; // Size of the structure for version checking.
|
||||
const char *clLib;
|
||||
const char *feLib;
|
||||
const char *optLib;
|
||||
const char *linkLib;
|
||||
const char *cgLib;
|
||||
const char *beLib;
|
||||
const char *scLib;
|
||||
} aclCompilerOptions_0_8;
|
||||
|
||||
typedef struct _acl_compiler_opts_rec_0_8_1 {
|
||||
ACL_STRUCT_HEADER; // Size of the structure for version checking.
|
||||
const char* clLib;
|
||||
const char *feLib;
|
||||
const char *optLib;
|
||||
const char *linkLib;
|
||||
const char *cgLib;
|
||||
const char *beLib;
|
||||
const char *scLib; // Name or path to the shader compiler shared library
|
||||
AllocFunc alloc;
|
||||
FreeFunc dealloc;
|
||||
} aclCompilerOptions_0_8_1;
|
||||
|
||||
//! Structure that holds the OpenCL compiler and various loaders.
|
||||
typedef struct _acl_compiler_rec_0_8 {
|
||||
ACL_STRUCT_HEADER; // Size of structure for version checking.
|
||||
aclCLLoader clAPI; // Pointer to the compiler API.
|
||||
aclFELoader feAPI; // Pointer to the FE Loader API.
|
||||
aclOptLoader optAPI; // Pointer to the Opt Loader API.
|
||||
aclLinkLoader linkAPI; // Pointer to the Link Loader API.
|
||||
aclCGLoader cgAPI; // Pointer to the CG Loader API.
|
||||
aclBELoader beAPI; // Pointer to the BE Loader API.
|
||||
aclSCLoader scAPI; // Pointer to the SC Loader API.
|
||||
aclCompilerOptions *opts; // The options structure for the compiler.
|
||||
void *llvm_shutdown; // Pointer to the llvm shutdown object.
|
||||
char *buildLog; // Pointer to the current build log.
|
||||
unsigned logSize; // Size of the current build log.
|
||||
aclLoaderData *apiData; // pointer to data store for the compiler API loader.
|
||||
} aclCompilerHandle_0_8;
|
||||
|
||||
//! Structure that holds the OpenCL compiler and various loaders.
|
||||
typedef struct _acl_compiler_rec_0_8_1 {
|
||||
ACL_STRUCT_HEADER;
|
||||
aclCLLoader clAPI; // Pointer to the compiler API.
|
||||
aclFELoader feAPI; // Pointer to the FE Loader API.
|
||||
aclOptLoader optAPI; // Pointer to the Opt Loader API.
|
||||
aclLinkLoader linkAPI; // Pointer to the Link Loader API.
|
||||
aclCGLoader cgAPI; // Pointer to the CG Loader API.
|
||||
aclBELoader beAPI; // Pointer to the BE Loader API.
|
||||
aclSCLoader scAPI; // Pointer to the SC Loader API.
|
||||
AllocFunc alloc;
|
||||
FreeFunc dealloc;
|
||||
aclCompilerOptions *opts; // The options structure for the compiler.
|
||||
void *llvm_shutdown; // Pointer to the llvm shutdown object.
|
||||
char *buildLog; // Pointer to the current build log.
|
||||
unsigned logSize; // Size of the current build log.
|
||||
aclLoaderData *apiData; // pointer to data store for the compiler API loader.
|
||||
} aclCompilerHandle_0_8_1;
|
||||
|
||||
//! Structure to hold kernel statistics obtained from kernel
|
||||
typedef struct _acl_kernel_stats_0_8_1 {
|
||||
unsigned int scratchRegs;
|
||||
unsigned int scratchSize;
|
||||
unsigned int availablevgprs;
|
||||
unsigned int availablesgprs;
|
||||
unsigned int usedvgprs;
|
||||
unsigned int usedsgprs;
|
||||
unsigned int availableldssize;
|
||||
unsigned int usedldssize;
|
||||
unsigned int availablestacksize;
|
||||
unsigned int usedstacksize;
|
||||
unsigned int wavefrontsize;
|
||||
unsigned int wavefrontpersimd;
|
||||
unsigned int threadsperworkgroup;
|
||||
unsigned int reqdworkgroup_x;
|
||||
unsigned int reqdworkgroup_y;
|
||||
unsigned int reqdworkgroup_z;
|
||||
} aclKernelStats;
|
||||
|
||||
#endif // _ACL_STRUCTS_0_8_H_
|
||||
@@ -1,10 +1,100 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// This is a compatibility header file. Either define the version
|
||||
// of the compiler library that is to be used or include the
|
||||
// header file for that version directly.
|
||||
#ifndef ACL_TYPES_H_
|
||||
#define ACL_TYPES_H_
|
||||
#include "v0_8/aclTypes.h"
|
||||
#endif // ACL_TYPES_H_
|
||||
#ifndef _ACL_API_TYPES_0_8_H_
|
||||
#define _ACL_API_TYPES_0_8_H_
|
||||
#include "aclDefs.h"
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
// Typedefs that always point to the most recent versions of the objects.
|
||||
typedef struct _acl_md_arg_type_0_8 aclArgData;
|
||||
typedef struct _acl_md_printf_fmt_0_8 aclPrintfFmt;
|
||||
typedef struct _acl_metadata_0_8 aclMetadata;
|
||||
typedef struct _acl_device_caps_rec_0_8 aclDevCaps;
|
||||
typedef struct _acl_target_info_rec_0_8 aclTargetInfo;
|
||||
typedef struct _acl_bif_rec_0_8_1 aclBinary;
|
||||
typedef struct _acl_binary_opts_rec_0_8_1 aclBinaryOptions;
|
||||
typedef struct _acl_compiler_rec_0_8_1 aclCompiler;
|
||||
typedef struct _acl_compiler_opts_rec_0_8_1 aclCompilerOptions;
|
||||
typedef struct _acl_options_0_8* aclOptions; // Opaque pointer to amd::Options
|
||||
typedef struct _acl_binary_0_8* aclBIF; // Opaque pointer to bifbase
|
||||
typedef struct _acl_common_loader_rec_0_8 aclCommonLoader;
|
||||
typedef struct _acl_cl_loader_rec_0_8 aclCLLoader;
|
||||
typedef struct _acl_sc_loader_rec_0_8 aclSCLoader;
|
||||
typedef struct _acl_fe_loader_rec_0_8 aclFELoader;
|
||||
typedef struct _acl_link_loader_rec_0_8 aclLinkLoader;
|
||||
typedef struct _acl_opt_loader_rec_0_8 aclOptLoader;
|
||||
typedef struct _acl_cg_loader_rec_0_8 aclCGLoader;
|
||||
typedef struct _acl_be_loader_rec_0_8 aclBELoader;
|
||||
typedef struct _acl_llvm_module_0_8* aclModule; // Opaque pointer to llvm::Module
|
||||
typedef struct _acl_llvm_context_0_8* aclContext; // Opaque pointer to llvm::Context
|
||||
typedef struct _acl_loader_data_0_8* aclLoaderData; // Opaque pointer to loader data
|
||||
|
||||
#include "aclEnums.h"
|
||||
// Typedefs for enumerations
|
||||
typedef enum _acl_error_enum_0_8 acl_error;
|
||||
typedef enum _comp_device_caps_enum_0_8 compDeviceCaps;
|
||||
typedef enum _comp_opt_settings_enum_0_8 compOptSettings;
|
||||
typedef enum _acl_dev_type_enum_0_8 aclDevType;
|
||||
typedef enum _acl_cl_version_enum_0_8 aclCLVersion;
|
||||
typedef enum _acl_type_enum_0_8 aclType;
|
||||
typedef enum _rt_query_types_enum_0_8 aclQueryType;
|
||||
typedef enum _rt_gpu_caps_enum_0_8 aclGPUCaps;
|
||||
typedef enum _rt_gpu_resource_enum_0_8 aclGPUResource;
|
||||
typedef enum _rt_gpu_mem_sizes_enum_0_8 aclGPUMemSizes;
|
||||
typedef enum _acl_arg_type_enum_0_8 aclArgType;
|
||||
typedef enum _acl_data_type_enum_0_8 aclArgDataType;
|
||||
typedef enum _acl_memory_type_enum_0_8 aclMemoryType;
|
||||
typedef enum _acl_access_type_enum_0_8 aclAccessType;
|
||||
typedef enum _bif_version_enum_0_8 aclBIFVersion;
|
||||
typedef enum _bif_platform_enum_0_8 aclPlatform;
|
||||
typedef enum _bif_sections_enum_0_8 aclSections;
|
||||
typedef enum _acl_loader_type_enum_0_8 aclLoaderType;
|
||||
typedef enum _acl_binary_image_type_enum_0_8 aclBinaryImageType;
|
||||
|
||||
#include "aclFunctors.h"
|
||||
// Typedefs for function pointers
|
||||
typedef aclLogFunction_0_8 aclLogFunction;
|
||||
typedef InsertSec_0_8 InsertSec;
|
||||
typedef RemoveSec_0_8 RemoveSec;
|
||||
typedef ExtractSec_0_8 ExtractSec;
|
||||
typedef InsertSym_0_8 InsertSym;
|
||||
typedef RemoveSym_0_8 RemoveSym;
|
||||
typedef ExtractSym_0_8 ExtractSym;
|
||||
typedef QueryInfo_0_8 QueryInfo;
|
||||
typedef Compile_0_8 Compile;
|
||||
typedef Link_0_8 Link;
|
||||
typedef AddDbgArg_0_8 AddDbgArg;
|
||||
typedef RemoveDbgArg_0_8 RemoveDbgArg;
|
||||
typedef SetupLoaderObject_0_8 SetupLoaderObject;
|
||||
typedef CompLog_0_8 CompLog;
|
||||
typedef RetrieveType_0_8 RetrieveType;
|
||||
typedef SetType_0_8 SetType;
|
||||
typedef ConvertType_0_8 ConvertType;
|
||||
typedef Disassemble_0_8 Disassemble;
|
||||
typedef GetDevBinary_0_8 GetDevBinary;
|
||||
typedef LoaderInit_0_8 LoaderInit;
|
||||
typedef LoaderFini_0_8 LoaderFini;
|
||||
typedef FEToIR_0_8 FEToIR;
|
||||
typedef SourceToISA_0_8 SourceToISA;
|
||||
typedef IRPhase_0_8 IRPhase;
|
||||
typedef LinkPhase_0_8 LinkPhase;
|
||||
typedef CGPhase_0_8 CGPhase;
|
||||
typedef DisasmISA_0_8 DisasmISA;
|
||||
typedef AllocFunc_0_8 AllocFunc;
|
||||
typedef FreeFunc_0_8 FreeFunc;
|
||||
typedef JITObjectImageCreate_0_8 JITObjectImageCreate;
|
||||
typedef JITObjectImageCopy_0_8 JITObjectImageCopy;
|
||||
typedef JITObjectImageDestroy_0_8 JITObjectImageDestroy;
|
||||
typedef JITObjectImageSize_0_8 JITObjectImageSize;
|
||||
typedef JITObjectImageData_0_8 JITObjectImageData;
|
||||
typedef JITObjectImageFinalize_0_8 JITObjectImageFinalize;
|
||||
typedef JITObjectImageGetGlobalsSize_0_8 JITObjectImageGetGlobalsSize;
|
||||
typedef JITSymbolCallback_0_8 JITSymbolCallback;
|
||||
typedef JITObjectImageIterateSymbols_0_8 JITObjectImageIterateSymbols;
|
||||
typedef JITObjectImageDisassembleKernel_0_8 JITObjectImageDisassembleKernel;
|
||||
|
||||
#include "aclStructs.h"
|
||||
|
||||
#endif // _CL_API_TYPES_0_8_H_
|
||||
@@ -1,305 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _ACL_0_8_H_
|
||||
#define _ACL_0_8_H_
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "aclTypes.h"
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with aclCompiler objects.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
aclCompiler* ACL_API_ENTRY
|
||||
aclCompilerInit(aclCompilerOptions *opts, acl_error *error_code) ACL_API_0_8;
|
||||
acl_error ACL_API_ENTRY
|
||||
aclCompilerFini(aclCompiler *cl) ACL_API_0_8;
|
||||
aclCLVersion ACL_API_ENTRY
|
||||
aclCompilerVersion(aclCompiler *cl, acl_error *error_code) ACL_API_0_8;
|
||||
uint32_t ACL_API_ENTRY
|
||||
aclVersionSize(aclCLVersion num, acl_error *error_code) ACL_API_0_8;
|
||||
const char* ACL_API_ENTRY
|
||||
aclGetErrorString(acl_error error_code) ACL_API_0_8;
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with target specific information.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
//! Returns in the names argument, if non-NULL, a pointer to each of the arch
|
||||
// names that the compiler supports. If names is NULL and arch_size is
|
||||
// non-NULL, returns the number of arch entries that are required.
|
||||
acl_error ACL_API_ENTRY
|
||||
aclGetArchInfo(const char** arch_names,
|
||||
size_t *arch_size) ACL_API_0_8;
|
||||
|
||||
//! Returns in the arch argument, if non-NULL, a pointer to each device
|
||||
// name that the compiler supports. If device_size is non-NULL,
|
||||
// returns the number of device entries that are used.
|
||||
acl_error ACL_API_ENTRY
|
||||
aclGetDeviceInfo(const char* arch,
|
||||
const char **names,
|
||||
size_t *device_size) ACL_API_0_8;
|
||||
|
||||
//! Function that returns a correctly filled out aclTargetInfo structure based
|
||||
// on the information passed into the kernel.
|
||||
aclTargetInfo ACL_API_ENTRY
|
||||
aclGetTargetInfo(const char *arch,
|
||||
const char *device,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
//! Function that returns a correctly filled out aclTargetInfo structure based
|
||||
// on the information passed into the kernel.
|
||||
aclTargetInfo ACL_API_ENTRY
|
||||
aclGetTargetInfoFromChipID(const char *arch,
|
||||
const uint32_t chip_id,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
//! Function that returns a string representation of the target architecture.
|
||||
const char* ACL_API_ENTRY
|
||||
aclGetArchitecture(const aclTargetInfo &target) ACL_API_0_8;
|
||||
|
||||
//! Function that returns a string representation of the target chip options.
|
||||
const uint64_t ACL_API_ENTRY
|
||||
aclGetChipOptions(const aclTargetInfo &target) ACL_API_0_8;
|
||||
|
||||
//! Function that returns a string representation of the target family.
|
||||
const char* ACL_API_ENTRY
|
||||
aclGetFamily(const aclTargetInfo &target) ACL_API_0_8;
|
||||
|
||||
//! Function that returns a string representation of the target chip.
|
||||
const char* ACL_API_ENTRY
|
||||
aclGetChip(const aclTargetInfo &target) ACL_API_0_8;
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with aclBinary objects.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
aclBinary* ACL_API_ENTRY
|
||||
aclBinaryInit(
|
||||
size_t struct_version,
|
||||
const aclTargetInfo *target,
|
||||
const aclBinaryOptions *options,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclBinaryFini(aclBinary *bin) ACL_API_0_8;
|
||||
|
||||
aclBinary* ACL_API_ENTRY
|
||||
aclReadFromFile(const char *str,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
aclBinary* ACL_API_ENTRY
|
||||
aclReadFromMem(const void *mem,
|
||||
size_t size, acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclWriteToFile(aclBinary *bin,
|
||||
const char *str) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclWriteToMem(aclBinary *bin,
|
||||
void **mem, size_t *size) ACL_API_0_8;
|
||||
|
||||
aclBinary* ACL_API_ENTRY
|
||||
aclCreateFromBinary(const aclBinary *binary,
|
||||
aclBIFVersion version) ACL_API_0_8;
|
||||
|
||||
aclBIFVersion ACL_API_ENTRY
|
||||
aclBinaryVersion(const aclBinary *binary) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclInsertSection(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
const void *data,
|
||||
size_t data_size,
|
||||
aclSections id) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclInsertSymbol(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
const void *data,
|
||||
size_t data_size,
|
||||
aclSections id,
|
||||
const char *symbol) ACL_API_0_8;
|
||||
|
||||
const void* ACL_API_ENTRY
|
||||
aclExtractSection(aclCompiler *cl,
|
||||
const aclBinary *binary,
|
||||
size_t *size,
|
||||
aclSections id,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
const void* ACL_API_ENTRY
|
||||
aclExtractSymbol(aclCompiler *cl,
|
||||
const aclBinary *binary,
|
||||
size_t *size,
|
||||
aclSections id,
|
||||
const char *symbol,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclRemoveSection(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
aclSections id) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclRemoveSymbol(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
aclSections id,
|
||||
const char *symbol) ACL_API_0_8;
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with debug/metdata.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
acl_error ACL_API_ENTRY
|
||||
aclQueryInfo(aclCompiler *cl,
|
||||
const aclBinary *binary,
|
||||
aclQueryType query,
|
||||
const char *kernel,
|
||||
void *data_ptr,
|
||||
size_t *ptr_size) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclDbgAddArgument(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
const char* kernel,
|
||||
const char* name,
|
||||
bool byVal)
|
||||
ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclDbgRemoveArgument(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
const char* kernel,
|
||||
const char* name)
|
||||
ACL_API_0_8;
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with various compilation phases.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
acl_error ACL_API_ENTRY
|
||||
aclCompile(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *options,
|
||||
aclType from,
|
||||
aclType to,
|
||||
aclLogFunction compile_callback) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclLink(aclCompiler *cl,
|
||||
aclBinary *src_bin,
|
||||
unsigned int num_libs,
|
||||
aclBinary **libs,
|
||||
aclType link_mode,
|
||||
const char *options,
|
||||
aclLogFunction link_callback) ACL_API_0_8;
|
||||
|
||||
const char* ACL_API_ENTRY
|
||||
aclGetCompilerLog(aclCompiler *cl) ACL_API_0_8;
|
||||
|
||||
const void* ACL_API_ENTRY
|
||||
aclRetrieveType(aclCompiler *cl,
|
||||
const aclBinary *bin,
|
||||
const char *name,
|
||||
size_t *data_size,
|
||||
aclType type,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclSetType(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *name,
|
||||
aclType type,
|
||||
const void *data,
|
||||
size_t size) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclConvertType(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *name,
|
||||
aclType type) ACL_API_0_8;
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclDisassemble(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *kernel,
|
||||
aclLogFunction disasm_callback) ACL_API_0_8;
|
||||
|
||||
const void* ACL_API_ENTRY
|
||||
aclGetDeviceBinary(aclCompiler *cl,
|
||||
const aclBinary *bin,
|
||||
const char *kernel,
|
||||
size_t *size,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with binary image.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
bool ACL_API_ENTRY
|
||||
aclValidateBinaryImage(const void* binary,
|
||||
size_t length, unsigned) ACL_API_0_8;
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with aclJITObjectImage objects.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
aclJITObjectImage ACL_API_ENTRY
|
||||
aclJITObjectImageCreate(aclCompiler *cl, const void* buffer,
|
||||
size_t length, aclBinary* bin, acl_error* error_code);
|
||||
|
||||
aclJITObjectImage ACL_API_ENTRY
|
||||
aclJITObjectImageCopy(aclCompiler *cl, const void* buffer,
|
||||
size_t length, acl_error* error_code);
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclJITObjectImageDestroy(aclCompiler *cl, aclJITObjectImage buffer);
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclJITObjectImageFinalize(aclCompiler *cl, aclJITObjectImage image);
|
||||
|
||||
size_t ACL_API_ENTRY
|
||||
aclJITObjectImageSize(aclCompiler *cl, aclJITObjectImage image,
|
||||
acl_error* error_code);
|
||||
|
||||
const char* ACL_API_ENTRY
|
||||
aclJITObjectImageData(aclCompiler *cl, aclJITObjectImage image,
|
||||
acl_error* error_code);
|
||||
|
||||
size_t ACL_API_ENTRY
|
||||
aclJITObjectImageGetGlobalsSize(aclCompiler *cl, aclJITObjectImage image,
|
||||
acl_error* error_code);
|
||||
|
||||
acl_error ACL_API_ENTRY
|
||||
aclJITObjectImageIterateSymbols(aclCompiler *cl, aclJITObjectImage image,
|
||||
aclJITSymbolCallback callback, void* data);
|
||||
|
||||
#if defined(LEGACY_COMPLIB)
|
||||
char* ACL_API_ENTRY
|
||||
aclJITObjectImageDisassembleKernel(aclCompiler *cl, constAclJITObjectImage image,
|
||||
const char* kernel, acl_error* error_code);
|
||||
#endif
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Debug functionality
|
||||
//!--------------------------------------------------------------------------!//
|
||||
void aclDumpBinary(const aclBinary *bin);
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with kenel statistics.
|
||||
//!--------------------------------------------------------------------------!//
|
||||
void aclGetKstatsSI(const void* shader,
|
||||
aclKernelStats &kstats);
|
||||
acl_error ACL_API_ENTRY
|
||||
aclInsertKernelStatistics(aclCompiler *cl,
|
||||
aclBinary *bin);
|
||||
//! Define hardware info constants for SI and above devices
|
||||
const static unsigned SI_sgprs_avail = 102;
|
||||
const static unsigned SI_vgprs_avail = 256;
|
||||
const static unsigned SI_ldssize_avail = 32*1024;
|
||||
|
||||
//!--------------------------------------------------------------------------!//
|
||||
// Functions that deal with memory.
|
||||
// Free memory allocated by aclWriteToMem
|
||||
//!--------------------------------------------------------------------------!//
|
||||
acl_error ACL_API_ENTRY
|
||||
aclFreeMem(aclBinary *bin,
|
||||
void *mem);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // _ACL_0_8_H_
|
||||
@@ -1,37 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _ACL_DEFS_0_8_H_
|
||||
#define _ACL_DEFS_0_8_H_
|
||||
|
||||
#ifndef ACL_API_ENTRY
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#define ACL_API_ENTRY __stdcall
|
||||
#else
|
||||
#define ACL_API_ENTRY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ACL_API_0_8
|
||||
#define ACL_API_0_8
|
||||
#endif
|
||||
|
||||
#ifndef BIF_API_2_0
|
||||
#define BIF_API_2_0
|
||||
#endif
|
||||
|
||||
#ifndef BIF_API_2_1
|
||||
#define BIF_API_2_1
|
||||
#endif
|
||||
|
||||
#ifndef BIF_API_3_0
|
||||
#define BIF_API_3_0
|
||||
#endif
|
||||
|
||||
#ifndef MAX_HIDDEN_KERNARGS_NUM
|
||||
#define MAX_HIDDEN_KERNARGS_NUM 6
|
||||
#else
|
||||
#error "MAX_HIDDEN_KERNARGS_NUM is already defined"
|
||||
#endif
|
||||
|
||||
#endif // _ACL_DEFS_0_8_H_
|
||||
@@ -1,347 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _ACL_ENUMS_0_8_H_
|
||||
#define _ACL_ENUMS_0_8_H_
|
||||
|
||||
typedef enum _acl_error_enum_0_8 {
|
||||
ACL_SUCCESS = 0,
|
||||
ACL_ERROR = 1,
|
||||
ACL_INVALID_ARG = 2,
|
||||
ACL_OUT_OF_MEM = 3,
|
||||
ACL_SYS_ERROR = 4,
|
||||
ACL_UNSUPPORTED = 5,
|
||||
ACL_ELF_ERROR = 6,
|
||||
ACL_INVALID_FILE = 7,
|
||||
ACL_INVALID_COMPILER= 8,
|
||||
ACL_INVALID_TARGET = 9,
|
||||
ACL_INVALID_BINARY = 10,
|
||||
ACL_INVALID_OPTION = 11,
|
||||
ACL_INVALID_TYPE = 12,
|
||||
ACL_INVALID_SECTION = 13,
|
||||
ACL_INVALID_SYMBOL = 14,
|
||||
ACL_INVALID_QUERY = 15,
|
||||
ACL_FRONTEND_FAILURE= 16,
|
||||
ACL_INVALID_BITCODE = 17,
|
||||
ACL_LINKER_ERROR = 18,
|
||||
ACL_OPTIMIZER_ERROR = 19,
|
||||
ACL_CODEGEN_ERROR = 20,
|
||||
ACL_ISAGEN_ERROR = 21,
|
||||
ACL_INVALID_SOURCE = 22,
|
||||
ACL_LIBRARY_ERROR = 23,
|
||||
ACL_INVALID_SPIR = 24,
|
||||
ACL_LWVERIFY_FAIL = 25,
|
||||
ACL_HWVERIFY_FAIL = 26,
|
||||
ACL_SPIRV_LOAD_FAIL = 27,
|
||||
ACL_SPIRV_SAVE_FAIL = 28,
|
||||
ACL_LAST_ERROR = 29
|
||||
} acl_error_0_8;
|
||||
|
||||
typedef enum _comp_device_caps_enum_0_8 {
|
||||
capError = 0,
|
||||
capFMA = 1,
|
||||
capImageSupport = 2,
|
||||
capSaveSOURCE = 3, // input source
|
||||
capSaveLLVMIR = 4, // output LLVMIR from frontend
|
||||
capSaveCG = 5, // output from LLVM-BE
|
||||
capSaveEXE = 6, // output executable
|
||||
capSaveAMDIL = 7, // Save per-kernel AMDIL
|
||||
capSaveHSAIL = 8, // Save per-kernel HSAIL
|
||||
capEncrypted = 9,
|
||||
capSaveDISASM = 10,
|
||||
capSaveAS = 11,
|
||||
capSaveSPIR = 12,
|
||||
capDumpLast = 13
|
||||
} compDeviceCaps_0_8;
|
||||
|
||||
typedef enum _comp_opt_settings_enum_0_8 {
|
||||
optO0 = 0, // No optimization setting.
|
||||
optO1 = 1,
|
||||
optO2 = 2,
|
||||
optO3 = 3,
|
||||
optO4 = 4,
|
||||
optOs = 5,
|
||||
optError = 6, // Invalid optimization set
|
||||
optLast = 7
|
||||
} compOptSettings_0_8;
|
||||
|
||||
#define FLAG_SHIFT_VALUE 5
|
||||
#define FLAG_MASK_VALUE ((1 << capDumpLast) - 1)
|
||||
#define FLAG_BITLOC(A) (1 << ((A) & FLAG_MASK_VALUE))
|
||||
#define FLAG_ARRAY_SIZE 4
|
||||
|
||||
//! An enumeration that defines the possible valid device types that
|
||||
// can be compiled for.
|
||||
typedef enum _acl_dev_type_enum_0_8 {
|
||||
aclError = 0, // aclDevType of 0 is an error.
|
||||
aclX86 = 1, // Targeting a 32bit X86 CPU device.
|
||||
aclAMDIL = 2, // Targeting an AMDIL GPU device.
|
||||
aclHSAIL = 3, // Targeting an HSAIL GPU device.
|
||||
aclX64 = 4, // Targeting a 64bit X86 CPU device.
|
||||
aclHSAIL64= 5, // Targeting a 64bit HSAIL GPU device.
|
||||
aclAMDIL64= 6, // Targeting a 64bit AMDIL GPU device
|
||||
aclLast = 7
|
||||
} aclDevType_0_8;
|
||||
|
||||
//! Enum that represents the versions of the compiler
|
||||
typedef enum _acl_cl_version_enum_0_8 {
|
||||
ACL_VERSION_ERROR = 0,
|
||||
ACL_VERSION_0_7 = 1,
|
||||
ACL_VERSION_0_8 = 2,
|
||||
ACL_VERSION_0_8_1 = 3,
|
||||
ACL_VERSION_0_9 = 4,
|
||||
ACL_VERSION_1_0 = 5,
|
||||
ACL_VERSION_LAST = 6
|
||||
} aclCLVersion_0_8;
|
||||
|
||||
//! Enum of the various aclTypes that are supported
|
||||
typedef enum _acl_type_enum_0_8 {
|
||||
ACL_TYPE_DEFAULT = 0,
|
||||
ACL_TYPE_OPENCL = 1,
|
||||
ACL_TYPE_LLVMIR_TEXT = 2,
|
||||
ACL_TYPE_LLVMIR_BINARY = 3,
|
||||
ACL_TYPE_SPIR_TEXT = 4,
|
||||
ACL_TYPE_SPIR_BINARY = 5,
|
||||
ACL_TYPE_AMDIL_TEXT = 6,
|
||||
ACL_TYPE_AMDIL_BINARY = 7,
|
||||
ACL_TYPE_HSAIL_TEXT = 8,
|
||||
ACL_TYPE_HSAIL_BINARY = 9,
|
||||
ACL_TYPE_X86_TEXT = 10,
|
||||
ACL_TYPE_X86_BINARY = 11,
|
||||
ACL_TYPE_CG = 12,
|
||||
ACL_TYPE_SOURCE = 13,
|
||||
ACL_TYPE_ISA = 14,
|
||||
ACL_TYPE_HEADER = 15,
|
||||
ACL_TYPE_RSLLVMIR_BINARY = 16,
|
||||
ACL_TYPE_SPIRV_BINARY = 17,
|
||||
ACL_TYPE_ASM_TEXT = 18,
|
||||
ACL_TYPE_LAST = 19
|
||||
} aclType_0_8;
|
||||
|
||||
//! Enum of the various loader types that are supported.
|
||||
typedef enum _acl_loader_type_enum_0_8 {
|
||||
ACL_LOADER_COMPLIB = 0,
|
||||
ACL_LOADER_FRONTEND = 1,
|
||||
ACL_LOADER_LINKER = 2,
|
||||
ACL_LOADER_OPTIMIZER= 3,
|
||||
ACL_LOADER_CODEGEN = 4,
|
||||
ACL_LOADER_BACKEND = 5,
|
||||
ACL_LOADER_SC = 6,
|
||||
ACL_LOADER_LAST = 7
|
||||
} aclLoaderType_0_8;
|
||||
|
||||
// Enumeration for the various acl versions
|
||||
typedef enum _bif_version_enum_0_8 {
|
||||
aclBIFVersionError = 0, // Error
|
||||
aclBIFVersion20 = 1, // Version 2.0 of the OpenCL BIF
|
||||
aclBIFVersion21 = 2, // Version 2.1 of the OpenCL BIF
|
||||
aclBIFVersion30 = 3, // Version 3.0 of the OpenCL BIF
|
||||
aclBIFVersion31 = 4, // Version 3.1 of the OpenCL BIF
|
||||
aclBIFVersionLatest = aclBIFVersion31, // Most recent version of the BIF
|
||||
aclBIFVersionCAL = 5,
|
||||
aclBIFVersionLast = 6
|
||||
} aclBIFVersion_0_8;
|
||||
|
||||
// Enumeration for the various platform types
|
||||
typedef enum _bif_platform_enum_0_8 {
|
||||
aclPlatformCAL = 0, // For BIF 2.0 backward compatibility
|
||||
aclPlatformCPU = 1, // For BIF 2.0 backward compatibility
|
||||
aclPlatformCompLib = 2,
|
||||
aclPlatformLast = 3
|
||||
} aclPlatform_0_8;
|
||||
|
||||
// Enumeration for the various bif sections
|
||||
typedef enum _bif_sections_enum_0_8 {
|
||||
aclLLVMIR = 0,
|
||||
aclSOURCE = 1,
|
||||
aclILTEXT = 2, // For BIF 2.0 backward compatibility
|
||||
aclASTEXT = 3, // For BIF 2.0 backward compatibility
|
||||
aclCAL = 4, // For BIF 2.0 backward compatibility
|
||||
aclDLL = 5, // For BIF 2.0 backward compatibility
|
||||
aclSTRTAB = 6,
|
||||
aclSYMTAB = 7,
|
||||
aclRODATA = 8,
|
||||
aclSHSTRTAB = 9,
|
||||
aclNOTES = 10,
|
||||
aclCOMMENT = 11,
|
||||
aclILDEBUG = 12, // For BIF 2.0 backward compatibility
|
||||
aclDEBUG_INFO = 13,
|
||||
aclDEBUG_ABBREV = 14,
|
||||
aclDEBUG_LINE = 15,
|
||||
aclDEBUG_PUBNAMES = 16,
|
||||
aclDEBUG_PUBTYPES = 17,
|
||||
aclDEBUG_LOC = 18,
|
||||
aclDEBUG_ARANGES = 19,
|
||||
aclDEBUG_RANGES = 20,
|
||||
aclDEBUG_MACINFO = 21,
|
||||
aclDEBUG_STR = 22,
|
||||
aclDEBUG_FRAME = 23,
|
||||
aclJITBINARY = 24, // For BIF 2.0 backward compatibility
|
||||
aclCODEGEN = 25,
|
||||
aclTEXT = 26,
|
||||
aclINTERNAL = 27,
|
||||
aclSPIR = 28,
|
||||
aclHEADER = 29,
|
||||
aclBRIG = 30,
|
||||
aclBRIGxxx1 = 31,
|
||||
aclBRIGxxx2 = 32,
|
||||
aclBRIGxxx3 = 33,
|
||||
aclHSADEBUG = 34,
|
||||
aclKSTATS = 35, // For storing kernel statistics
|
||||
aclSPIRV = 36,
|
||||
aclLAST = 37
|
||||
} aclSections_0_8;
|
||||
|
||||
//! An enumeration that defines what are valid queries for aclQueryInfo.
|
||||
typedef enum _rt_query_types_enum_0_8 {
|
||||
RT_ABI_VERSION = 0,
|
||||
RT_DEVICE_NAME = 1,
|
||||
RT_MEM_SIZES = 2,
|
||||
RT_GPU_FUNC_CAPS = 3,
|
||||
RT_GPU_FUNC_ID = 4,
|
||||
RT_GPU_DEFAULT_ID = 5,
|
||||
RT_WORK_GROUP_SIZE = 6,
|
||||
RT_WORK_REGION_SIZE = 7,
|
||||
RT_ARGUMENT_ARRAY = 8,
|
||||
RT_GPU_PRINTF_ARRAY = 9,
|
||||
RT_CPU_BARRIER_NAMES = 10,
|
||||
RT_DEVICE_ENQUEUE = 11,
|
||||
RT_KERNEL_INDEX = 12,
|
||||
RT_KERNEL_NAME = 13,
|
||||
RT_KERNEL_NAMES = 14,
|
||||
RT_CONTAINS_LLVMIR = 15,
|
||||
RT_CONTAINS_OPTIONS = 16,
|
||||
RT_CONTAINS_BRIG = 17,
|
||||
RT_CONTAINS_HSAIL = 18,
|
||||
RT_CONTAINS_ISA = 19,
|
||||
RT_CONTAINS_LOADER_MAP = 20,
|
||||
RT_CONTAINS_SPIR = 21,
|
||||
RT_NUM_KERNEL_HIDDEN_ARGS = 22,
|
||||
RT_CONTAINS_SPIRV = 23,
|
||||
RT_WAVES_PER_SIMD_HINT = 24,
|
||||
RT_WORK_GROUP_SIZE_HINT = 25,
|
||||
RT_VEC_TYPE_HINT = 26,
|
||||
RT_LAST_TYPE = 27
|
||||
} aclQueryType_0_8;
|
||||
|
||||
//! An enumeration for the various GPU capabilities
|
||||
typedef enum _rt_gpu_caps_enum_0_8 {
|
||||
RT_COMPILER_WRITE = 1 << 0,
|
||||
RT_DATA_SECTION = 1 << 1,
|
||||
RT_WGS = 1 << 2,
|
||||
RT_LIMIT_WGS = 1 << 3,
|
||||
RT_PACKED_REGS = 1 << 4,
|
||||
RT_64BIT_ABI = 1 << 5,
|
||||
RT_PRINTF = 1 << 6,
|
||||
RT_ARENA_UAV = 1 << 7,
|
||||
RT_LRP_MEM = 1 << 8, // Local/Region/Private Memory
|
||||
RT_INDEX_TEMPS = 1 << 9,
|
||||
RT_WRS = 1 << 10,
|
||||
RT_GWS = 1 << 11,
|
||||
RT_SWGWS = 1 << 12,
|
||||
RT_GPU_CAPS_MASK = 0xFFF
|
||||
} aclGPUCaps_0_8;
|
||||
|
||||
//! An enumeration for the various CPU capabilities.
|
||||
typedef enum _rt_cpu_caps_enum_0_8 {
|
||||
RT_KERNEL_BARRIER = 1 << 0,
|
||||
RT_PROGRAM_BARRIER = 1 << 1,
|
||||
RT_CPU_CAPS_MASK = 0x3
|
||||
} aclCPUCaps_0_8;
|
||||
|
||||
//! An enumeration that maps Resource type to index values
|
||||
typedef enum _rt_gpu_resource_enum_0_8 {
|
||||
RT_RES_UAV = 0, // UAV resources
|
||||
RT_RES_PRI = 1, // Private resources
|
||||
RT_RES_LDS = 2, // LDS resources
|
||||
RT_RES_GDS = 3, // GDS resources
|
||||
RT_RES_CON = 4, // Constant resources
|
||||
RT_RES_LAST = 5
|
||||
} aclGPUResource_0_8;
|
||||
|
||||
//! An enumeration that maps memory types to index values
|
||||
typedef enum _rt_gpu_mem_sizes_enum_0_8 {
|
||||
RT_MEM_HW_LOCAL = 0,
|
||||
RT_MEM_SW_LOCAL = 1,
|
||||
RT_MEM_HW_PRIVATE = 2,
|
||||
RT_MEM_SW_PRIVATE = 3,
|
||||
RT_MEM_HW_REGION = 4,
|
||||
RT_MEM_SW_REGION = 5,
|
||||
RT_MEM_LAST = 6
|
||||
} aclGPUMemSizes_0_8;
|
||||
|
||||
// Enumerations for the various argument types.
|
||||
typedef enum _acl_arg_type_enum_0_8 {
|
||||
ARG_TYPE_ERROR = 0,
|
||||
ARG_TYPE_SAMPLER = 1,
|
||||
ARG_TYPE_IMAGE = 2,
|
||||
ARG_TYPE_COUNTER = 3,
|
||||
ARG_TYPE_VALUE = 4,
|
||||
ARG_TYPE_POINTER = 5,
|
||||
ARG_TYPE_SEMAPHORE = 6,
|
||||
ARG_TYPE_QUEUE = 7, // enum for device enqueue
|
||||
ARG_TYPE_LAST = 8
|
||||
} aclArgType_0_8;
|
||||
|
||||
// Enumerations of the valid data types for pass by value and
|
||||
// pass by pointer kernel arguments.
|
||||
typedef enum _acl_data_type_enum_0_8 {
|
||||
DATATYPE_ERROR = 0,
|
||||
DATATYPE_i1 = 1,
|
||||
DATATYPE_i8 = 2,
|
||||
DATATYPE_i16 = 3,
|
||||
DATATYPE_i32 = 4,
|
||||
DATATYPE_i64 = 5,
|
||||
DATATYPE_u8 = 6,
|
||||
DATATYPE_u16 = 7,
|
||||
DATATYPE_u32 = 8,
|
||||
DATATYPE_u64 = 9,
|
||||
DATATYPE_f16 = 10,
|
||||
DATATYPE_f32 = 11,
|
||||
DATATYPE_f64 = 12,
|
||||
DATATYPE_f80 = 13,
|
||||
DATATYPE_f128 = 14,
|
||||
DATATYPE_struct = 15,
|
||||
DATATYPE_union = 16,
|
||||
DATATYPE_event = 17,
|
||||
DATATYPE_opaque = 18,
|
||||
DATATYPE_unknown = 19,
|
||||
DATATYPE_LAST = 20
|
||||
} aclArgDataType_0_8;
|
||||
|
||||
// Enumerations of the valid memory types for pass by pointer
|
||||
// kernel arguments
|
||||
typedef enum _acl_memory_type_enum_0_8 {
|
||||
PTR_MT_ERROR = 0, // Error
|
||||
PTR_MT_GLOBAL = 1, // global buffer
|
||||
PTR_MT_SCRATCH_EMU = 2, // SW emulated private memory
|
||||
PTR_MT_LDS_EMU = 3, // SW emulated local memory
|
||||
PTR_MT_UAV = 4, // uniformed access vector memory
|
||||
PTR_MT_CONSTANT_EMU = 5, // SW emulated constant memory
|
||||
PTR_MT_GDS_EMU = 6, // SW emulated region memory
|
||||
PTR_MT_LDS = 7, // HW local memory
|
||||
PTR_MT_SCRATCH = 8, // HW private memory
|
||||
PTR_MT_CONSTANT = 9, // HW constant memory
|
||||
PTR_MT_GDS = 10, // HW region memory
|
||||
PTR_MT_UAV_SCRATCH = 11, // SI and later HW private memory
|
||||
PTR_MT_UAV_CONSTANT = 12, // SI and later HW constant memory
|
||||
PTR_MT_LAST = 13
|
||||
} aclMemoryType_0_8;
|
||||
|
||||
// Enumeration that specifies the various access types for a pointer/image.
|
||||
typedef enum _acl_access_type_enum_0_8 {
|
||||
ACCESS_TYPE_ERROR = 0,
|
||||
ACCESS_TYPE_RO = 1,
|
||||
ACCESS_TYPE_WO = 2,
|
||||
ACCESS_TYPE_RW = 3,
|
||||
ACCESS_TYPE_LAST = 4
|
||||
} aclAccessType_0_8;
|
||||
|
||||
// Enumeration that specifies the binary types.
|
||||
typedef enum _acl_binary_image_type_enum_0_8 {
|
||||
BINARY_TYPE_ELF = 1,
|
||||
BINARY_TYPE_LLVM = 2,
|
||||
BINARY_TYPE_SPIRV = 4,
|
||||
} aclBinaryImageType_0_8;
|
||||
|
||||
#endif // _ACL_ENUMS_0_8_H_
|
||||
@@ -1,230 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _ACL_FUNCTORS_0_8_H_
|
||||
#define _ACL_FUNCTORS_0_8_H_
|
||||
|
||||
//! Callback for the log function function pointer that many
|
||||
// API calls take to have the calling application receive
|
||||
// information on what errors occur.
|
||||
typedef void (*aclLogFunction_0_8)(const char *msg, size_t size);
|
||||
|
||||
typedef bool (*aclJITSymbolCallback)(const char*, const void*, void*);
|
||||
typedef void* aclJITObjectImage;
|
||||
typedef const void* constAclJITObjectImage;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *InsertSec_0_8)(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
const void *data,
|
||||
size_t data_size,
|
||||
aclSections id) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *InsertSym_0_8)(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
const void *data,
|
||||
size_t data_size,
|
||||
aclSections id,
|
||||
const char *symbol) ACL_API_0_8;
|
||||
|
||||
typedef const void *
|
||||
(ACL_API_ENTRY *ExtractSec_0_8)(aclCompiler *cl,
|
||||
const aclBinary *binary,
|
||||
size_t *size,
|
||||
aclSections id,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
typedef const void *
|
||||
(ACL_API_ENTRY *ExtractSym_0_8)(aclCompiler *cl,
|
||||
const aclBinary *binary,
|
||||
size_t *size,
|
||||
aclSections id,
|
||||
const char *symbol,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *RemoveSec_0_8)(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
aclSections id) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *RemoveSym_0_8)(aclCompiler *cl,
|
||||
aclBinary *binary,
|
||||
aclSections id,
|
||||
const char *symbol) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *QueryInfo_0_8)(aclCompiler *cl,
|
||||
const aclBinary *binary,
|
||||
aclQueryType query,
|
||||
const char *kernel,
|
||||
void *data_ptr,
|
||||
size_t *ptr_size) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *AddDbgArg_0_8)(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *kernel,
|
||||
const char *name,
|
||||
bool byVal) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *RemoveDbgArg_0_8)(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *kernel,
|
||||
const char *name) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *Compile_0_8)(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *options,
|
||||
aclType from,
|
||||
aclType to,
|
||||
aclLogFunction_0_8 compile_callback) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *Link_0_8)(aclCompiler *cl,
|
||||
aclBinary *src_bin,
|
||||
unsigned int num_libs,
|
||||
aclBinary **libs,
|
||||
aclType link_mode,
|
||||
const char *options,
|
||||
aclLogFunction_0_8 link_callback) ACL_API_0_8;
|
||||
|
||||
typedef const char *
|
||||
(ACL_API_ENTRY *CompLog_0_8)(aclCompiler *cl) ACL_API_0_8;
|
||||
|
||||
typedef const void *
|
||||
(ACL_API_ENTRY *RetrieveType_0_8)(aclCompiler *cl,
|
||||
const aclBinary *bin,
|
||||
const char *name,
|
||||
size_t *data_size,
|
||||
aclType type,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *SetType_0_8)(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *name,
|
||||
aclType type,
|
||||
const void *data,
|
||||
size_t size) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *ConvertType_0_8)(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *name,
|
||||
aclType type) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *Disassemble_0_8)(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
const char *kernel,
|
||||
aclLogFunction_0_8 disasm_callback) ACL_API_0_8;
|
||||
|
||||
typedef const void *
|
||||
(ACL_API_ENTRY *GetDevBinary_0_8)(aclCompiler *cl,
|
||||
const aclBinary *bin,
|
||||
const char *kernel,
|
||||
size_t *size,
|
||||
acl_error *error_code) ACL_API_0_8;
|
||||
|
||||
typedef aclLoaderData *
|
||||
(ACL_API_ENTRY *LoaderInit_0_8)(aclCompiler *cl,
|
||||
aclBinary *bin,
|
||||
aclLogFunction_0_8 callback,
|
||||
acl_error *error);
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *LoaderFini_0_8)(aclLoaderData *data);
|
||||
|
||||
typedef aclModule *
|
||||
(ACL_API_ENTRY *FEToIR_0_8)(aclLoaderData *ald,
|
||||
const char *source,
|
||||
size_t data_size,
|
||||
aclContext *ctx,
|
||||
acl_error *error) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *SourceToISA_0_8)(aclLoaderData *ald,
|
||||
const char *source,
|
||||
size_t data_size) ACL_API_0_8;
|
||||
|
||||
typedef aclModule *
|
||||
(ACL_API_ENTRY *IRPhase_0_8)(aclLoaderData *data,
|
||||
aclModule *ir,
|
||||
aclContext *ctx,
|
||||
acl_error *error) ACL_API_0_8;
|
||||
|
||||
typedef aclModule *
|
||||
(ACL_API_ENTRY *LinkPhase_0_8)(aclLoaderData *data,
|
||||
aclModule *ir,
|
||||
unsigned int num_libs,
|
||||
aclModule **libs,
|
||||
aclContext *ctx,
|
||||
acl_error *error) ACL_API_0_8;
|
||||
|
||||
typedef const void *
|
||||
(ACL_API_ENTRY *CGPhase_0_8)(aclLoaderData *data,
|
||||
aclModule *ir,
|
||||
aclContext *ctx,
|
||||
acl_error *error) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *DisasmISA_0_8)(aclLoaderData *data,
|
||||
const char *kernel,
|
||||
const void *isa_code,
|
||||
size_t isa_size) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *SetupLoaderObject_0_8)(aclCompiler *cl) ACL_API_0_8;
|
||||
|
||||
typedef aclJITObjectImage
|
||||
(ACL_API_ENTRY *JITObjectImageCreate_0_8)(const void* buffer,
|
||||
size_t length,
|
||||
aclBinary* bin,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
typedef aclJITObjectImage
|
||||
(ACL_API_ENTRY *JITObjectImageCopy_0_8)(const void* buffer,
|
||||
size_t length,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *JITObjectImageDestroy_0_8)(aclJITObjectImage image) ACL_API_0_8;
|
||||
|
||||
typedef size_t
|
||||
(ACL_API_ENTRY *JITObjectImageSize_0_8)(aclJITObjectImage image,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
typedef const char *
|
||||
(ACL_API_ENTRY *JITObjectImageData_0_8)(aclJITObjectImage image,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *JITObjectImageFinalize_0_8)(aclJITObjectImage image) ACL_API_0_8;
|
||||
|
||||
typedef size_t
|
||||
(ACL_API_ENTRY *JITObjectImageGetGlobalsSize_0_8)(aclJITObjectImage image,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
typedef bool (*JITSymbolCallback_0_8)(const char*, const void*, void*);
|
||||
|
||||
typedef acl_error
|
||||
(ACL_API_ENTRY *JITObjectImageIterateSymbols_0_8)(aclJITObjectImage image,
|
||||
JITSymbolCallback_0_8 jit_callback,
|
||||
void* data) ACL_API_0_8;
|
||||
|
||||
typedef char*
|
||||
(ACL_API_ENTRY *JITObjectImageDisassembleKernel_0_8)(constAclJITObjectImage image,
|
||||
const char* kernel,
|
||||
acl_error* error_code) ACL_API_0_8;
|
||||
|
||||
typedef void*
|
||||
(*AllocFunc_0_8)(size_t size) ACL_API_0_8;
|
||||
|
||||
typedef void
|
||||
(*FreeFunc_0_8)(void *ptr) ACL_API_0_8;
|
||||
|
||||
#endif // _ACL_FUNCTORS_0_8_H_
|
||||
@@ -1,349 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _ACL_STRUCTS_0_8_H_
|
||||
#define _ACL_STRUCTS_0_8_H_
|
||||
#define ACL_STRUCT_HEADER \
|
||||
size_t struct_size
|
||||
//! A structure that holds information on the various types of arguments
|
||||
// The format in memory of this structure is
|
||||
// -------------
|
||||
// | aclArgData |
|
||||
// -------------
|
||||
// |->argStr |
|
||||
// -------------
|
||||
// |->typeStr |
|
||||
// -------------
|
||||
typedef struct _acl_md_arg_type_0_8 {
|
||||
ACL_STRUCT_HEADER;
|
||||
size_t argNameSize;
|
||||
size_t typeStrSize;
|
||||
const char *argStr;
|
||||
const char *typeStr;
|
||||
union {
|
||||
struct { // Struct for sampler arguments
|
||||
unsigned ID;
|
||||
unsigned isKernelDefined;
|
||||
unsigned value;
|
||||
} sampler;
|
||||
struct { // Struct for image arguments
|
||||
unsigned resID;
|
||||
unsigned cbNum;
|
||||
unsigned cbOffset;
|
||||
aclAccessType type;
|
||||
bool is2D;
|
||||
bool is1D;
|
||||
bool isArray;
|
||||
bool isBuffer;
|
||||
} image;
|
||||
struct { // struct for atomic counter arguments
|
||||
unsigned is32bit;
|
||||
unsigned resID;
|
||||
unsigned cbNum;
|
||||
unsigned cbOffset;
|
||||
} counter;
|
||||
struct { // struct for semaphore arguments
|
||||
unsigned resID;
|
||||
unsigned cbNum;
|
||||
unsigned cbOffset;
|
||||
} sema;
|
||||
struct { // struct for pass by value arguments
|
||||
unsigned numElements;
|
||||
unsigned cbNum;
|
||||
unsigned cbOffset;
|
||||
aclArgDataType data;
|
||||
} value;
|
||||
struct { // struct for pass by pointer arguments
|
||||
unsigned numElements;
|
||||
unsigned cbNum;
|
||||
unsigned cbOffset;
|
||||
unsigned bufNum;
|
||||
unsigned align;
|
||||
aclArgDataType data;
|
||||
aclMemoryType memory;
|
||||
aclAccessType type;
|
||||
bool isVolatile;
|
||||
bool isRestrict;
|
||||
bool isPipe;
|
||||
} pointer;
|
||||
struct { // Struct for queue arguments
|
||||
unsigned numElements;
|
||||
unsigned cbNum;
|
||||
unsigned cbOffset;
|
||||
aclArgDataType data;
|
||||
aclMemoryType memory;
|
||||
} queue;
|
||||
} arg;
|
||||
aclArgType type;
|
||||
bool isConst;
|
||||
} aclArgData_0_8;
|
||||
|
||||
//! A structure that holds information for printf
|
||||
// The format in memory of this structure is
|
||||
// --------------
|
||||
// | aclPrintfFmt|
|
||||
// --------------
|
||||
// |->argSizes |
|
||||
// --------------
|
||||
// |->fmrStr |
|
||||
// --------------
|
||||
|
||||
typedef struct _acl_md_printf_fmt_0_8 {
|
||||
ACL_STRUCT_HEADER;
|
||||
unsigned ID;
|
||||
size_t numSizes;
|
||||
size_t fmtStrSize;
|
||||
uint32_t *argSizes;
|
||||
const char *fmtStr;
|
||||
} aclPrintfFmt_0_8;
|
||||
|
||||
//! A structure that holds the metadata in the RODATA section.
|
||||
typedef struct _acl_metadata_0_8 {
|
||||
ACL_STRUCT_HEADER; // This holds the size of the structure itself for versioning.
|
||||
size_t data_size; // This holds the size of all the memory allocated for this structure.
|
||||
uint32_t major, minor, revision; // RT_ABI_VERSION
|
||||
uint32_t gpuCaps; // RT_GPU_FUNC_CAPS
|
||||
uint32_t funcID; // RT_GPU_FUNC_ID
|
||||
uint32_t gpuRes[5]; // RT_GPU_DEFAULT_ID
|
||||
size_t wgs[3]; // RT_WORK_GROUP_SIZE
|
||||
uint32_t wrs[3]; // RT_WORK_REGION_SIZE
|
||||
size_t kernelNameSize;
|
||||
size_t deviceNameSize;
|
||||
size_t mem[6]; // RT_MEM_SIZES
|
||||
size_t numArgs;
|
||||
size_t numPrintf;
|
||||
|
||||
aclArgData_0_8 *args; // RT_ARGUMENT_ARRAY
|
||||
aclPrintfFmt_0_8 *printf; // RT_GPU_PRINTF_ARRAY
|
||||
const char *kernelName; // RT_KERNEL_NAME
|
||||
const char *deviceName; // RT_DEVICE_NAME
|
||||
bool enqueue_kernel; // RT_DEVICE_ENQUEUE
|
||||
uint32_t kernel_index; // RT_KERNEL_INDEX
|
||||
uint32_t numHiddenKernelArgs; // RT_NUM_KERNEL_HIDDEN_ARGS
|
||||
size_t wavesPerSimdHint; // RT_WAVES_PER_SIMD_HINT
|
||||
size_t wsh[3]; // RT_WORK_GROUP_SIZE_HINT
|
||||
size_t vecTypeHintSize;
|
||||
const char *vth; // RT_VEC_TYPE_HINT
|
||||
} aclMetadata_0_8;
|
||||
|
||||
//! An structure that holds information on the capabilities of the bif device.
|
||||
typedef struct _acl_device_caps_rec_0_8 {
|
||||
ACL_STRUCT_HEADER;
|
||||
uint32_t flags[4];
|
||||
uint32_t encryptCode;
|
||||
} aclDevCaps_0_8;
|
||||
|
||||
//! Structure that holds information on the target that the source is
|
||||
// being compiled for.
|
||||
typedef struct _acl_target_info_rec_0_8 {
|
||||
ACL_STRUCT_HEADER;
|
||||
aclDevType arch_id; // An identifier for the architecture.
|
||||
uint32_t chip_id; // A identifier for the chip.
|
||||
} aclTargetInfo_0_8;
|
||||
|
||||
// Structure for the version 0.8 of the structure.
|
||||
typedef struct _acl_binary_opts_rec_0_8 {
|
||||
ACL_STRUCT_HEADER;
|
||||
uint32_t elfclass;
|
||||
uint32_t bitness;
|
||||
const char *temp_file;
|
||||
uint32_t kernelArgAlign;
|
||||
} aclBinaryOptions_0_8;
|
||||
|
||||
// Structure for the version 0.8.1 of the structure.
|
||||
// This versions addes in alloc/dealloc functions.
|
||||
typedef struct _acl_binary_opts_rec_0_8_1 {
|
||||
ACL_STRUCT_HEADER;
|
||||
uint32_t elfclass;
|
||||
uint32_t bitness;
|
||||
const char *temp_file;
|
||||
uint32_t kernelArgAlign;
|
||||
AllocFunc_0_8 alloc;
|
||||
FreeFunc_0_8 dealloc;
|
||||
} aclBinaryOptions_0_8_1;
|
||||
|
||||
//! Structure that holds the OpenCL binary information.
|
||||
typedef struct _acl_bif_rec_0_8 {
|
||||
ACL_STRUCT_HEADER;
|
||||
aclTargetInfo_0_8 target; // Information about the target device.
|
||||
aclBIF* bin; // Pointer to the acl.
|
||||
aclOptions* options; // Pointer to acl options.
|
||||
aclBinaryOptions_0_8 binOpts; // Pointer to the binary options.
|
||||
aclDevCaps_0_8 caps; // Capabilities of the BIF.
|
||||
} aclBinary_0_8;
|
||||
|
||||
//! Version of the aclBinary that uses the 0_8_1 version of the aclBinaryOptions.
|
||||
typedef struct _acl_bif_rec_0_8_1 {
|
||||
ACL_STRUCT_HEADER;
|
||||
aclTargetInfo_0_8 target; // Information about the target device.
|
||||
aclBIF* bin; // Pointer to the acl.
|
||||
aclOptions* options; // Pointer to acl options.
|
||||
aclBinaryOptions_0_8_1 binOpts; // Pointer to the binary options.
|
||||
aclDevCaps_0_8 caps; // Capabilities of the BIF.
|
||||
} aclBinary_0_8_1;
|
||||
|
||||
#define ACL_LOADER_COMMON\
|
||||
ACL_STRUCT_HEADER; \
|
||||
bool isBuiltin; \
|
||||
const char *libName; \
|
||||
void *handle; \
|
||||
LoaderInit init; \
|
||||
LoaderFini fini;
|
||||
|
||||
// Struct that maps to the common structure between all loaders.
|
||||
typedef struct _acl_common_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
} aclCommonLoader_0_8;
|
||||
|
||||
typedef struct _acl_cl_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
Compile compile;
|
||||
Link link;
|
||||
CompLog getLog;
|
||||
RetrieveType_0_8 retrieveType;
|
||||
SetType_0_8 setType;
|
||||
ConvertType_0_8 convertType;
|
||||
Disassemble disassemble;
|
||||
GetDevBinary_0_8 devBinary;
|
||||
InsertSec insSec;
|
||||
ExtractSec extSec;
|
||||
RemoveSec remSec;
|
||||
InsertSym insSym;
|
||||
ExtractSym extSym;
|
||||
RemoveSym remSym;
|
||||
QueryInfo getInfo;
|
||||
AddDbgArg addDbg;
|
||||
RemoveDbgArg removeDbg;
|
||||
SetupLoaderObject setupLoaderObject;
|
||||
JITObjectImageCreate jitOICreate;
|
||||
JITObjectImageCopy jitOICopy;
|
||||
JITObjectImageDestroy jitOIDestroy;
|
||||
JITObjectImageSize jitOISize;
|
||||
JITObjectImageData jitOIData;
|
||||
JITObjectImageFinalize jitOIFinalize;
|
||||
JITObjectImageGetGlobalsSize jitOIGlobalSize;
|
||||
JITObjectImageIterateSymbols jitOIIterateSymbols;
|
||||
JITObjectImageDisassembleKernel jitOIDisassembleKernel;
|
||||
} aclCLLoader_0_8;
|
||||
|
||||
//! Structure that holds the required functions
|
||||
// that sc exports for the SCDLL infrastructure.
|
||||
typedef struct _acl_sc_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
uint32_t /*SC_UINT32*/ sc_interface_version;
|
||||
void /**SC_EXPORT_FUNCTIONS**/ *scef;
|
||||
// Any version specific fields go here.
|
||||
} aclSCLoader_0_8;
|
||||
|
||||
typedef struct _acl_fe_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
FEToIR toIR; // Used for Source to aclModule containing LLVMIR
|
||||
FEToIR toModule; // Used to convert raw SPIR/LLVM-IR to aclModule
|
||||
SourceToISA toISA; // Used for Source to ISA
|
||||
} aclFELoader_0_8;
|
||||
|
||||
typedef struct _acl_opt_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
IRPhase optimize; // Used for IR to IR transformation
|
||||
} aclOptLoader_0_8;
|
||||
|
||||
typedef struct _acl_link_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
LinkPhase link; // Used for Linking in IR modules
|
||||
IRPhase toLLVMIR; // Used for converting SPIR to LLVMIR
|
||||
IRPhase toSPIR; // Used for converting LLVMIR to SPIR
|
||||
} aclLinkLoader_0_8;
|
||||
|
||||
typedef struct _acl_cg_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
CGPhase codegen; // Used for converting from LLVMIR to target ASM.
|
||||
} aclCGLoader_0_8;
|
||||
|
||||
typedef struct _acl_be_loader_rec_0_8 {
|
||||
ACL_LOADER_COMMON;
|
||||
SourceToISA finalize; // Used for converting from target source to target ISA.
|
||||
SourceToISA assemble; // Used for converting from target text to target binary.
|
||||
DisasmISA disassemble; // Used for converting from target binary to target ISA.
|
||||
} aclBELoader_0_8;
|
||||
|
||||
typedef struct _acl_compiler_opts_rec_0_8 {
|
||||
ACL_STRUCT_HEADER; // Size of the structure for version checking.
|
||||
const char *clLib;
|
||||
const char *feLib;
|
||||
const char *optLib;
|
||||
const char *linkLib;
|
||||
const char *cgLib;
|
||||
const char *beLib;
|
||||
const char *scLib;
|
||||
} aclCompilerOptions_0_8;
|
||||
|
||||
typedef struct _acl_compiler_opts_rec_0_8_1 {
|
||||
ACL_STRUCT_HEADER; // Size of the structure for version checking.
|
||||
const char* clLib;
|
||||
const char *feLib;
|
||||
const char *optLib;
|
||||
const char *linkLib;
|
||||
const char *cgLib;
|
||||
const char *beLib;
|
||||
const char *scLib; // Name or path to the shader compiler shared library
|
||||
AllocFunc alloc;
|
||||
FreeFunc dealloc;
|
||||
} aclCompilerOptions_0_8_1;
|
||||
|
||||
//! Structure that holds the OpenCL compiler and various loaders.
|
||||
typedef struct _acl_compiler_rec_0_8 {
|
||||
ACL_STRUCT_HEADER; // Size of structure for version checking.
|
||||
aclCLLoader clAPI; // Pointer to the compiler API.
|
||||
aclFELoader feAPI; // Pointer to the FE Loader API.
|
||||
aclOptLoader optAPI; // Pointer to the Opt Loader API.
|
||||
aclLinkLoader linkAPI; // Pointer to the Link Loader API.
|
||||
aclCGLoader cgAPI; // Pointer to the CG Loader API.
|
||||
aclBELoader beAPI; // Pointer to the BE Loader API.
|
||||
aclSCLoader scAPI; // Pointer to the SC Loader API.
|
||||
aclCompilerOptions *opts; // The options structure for the compiler.
|
||||
void *llvm_shutdown; // Pointer to the llvm shutdown object.
|
||||
char *buildLog; // Pointer to the current build log.
|
||||
unsigned logSize; // Size of the current build log.
|
||||
aclLoaderData *apiData; // pointer to data store for the compiler API loader.
|
||||
} aclCompilerHandle_0_8;
|
||||
|
||||
//! Structure that holds the OpenCL compiler and various loaders.
|
||||
typedef struct _acl_compiler_rec_0_8_1 {
|
||||
ACL_STRUCT_HEADER;
|
||||
aclCLLoader clAPI; // Pointer to the compiler API.
|
||||
aclFELoader feAPI; // Pointer to the FE Loader API.
|
||||
aclOptLoader optAPI; // Pointer to the Opt Loader API.
|
||||
aclLinkLoader linkAPI; // Pointer to the Link Loader API.
|
||||
aclCGLoader cgAPI; // Pointer to the CG Loader API.
|
||||
aclBELoader beAPI; // Pointer to the BE Loader API.
|
||||
aclSCLoader scAPI; // Pointer to the SC Loader API.
|
||||
AllocFunc alloc;
|
||||
FreeFunc dealloc;
|
||||
aclCompilerOptions *opts; // The options structure for the compiler.
|
||||
void *llvm_shutdown; // Pointer to the llvm shutdown object.
|
||||
char *buildLog; // Pointer to the current build log.
|
||||
unsigned logSize; // Size of the current build log.
|
||||
aclLoaderData *apiData; // pointer to data store for the compiler API loader.
|
||||
} aclCompilerHandle_0_8_1;
|
||||
|
||||
//! Structure to hold kernel statistics obtained from kernel
|
||||
typedef struct _acl_kernel_stats_0_8_1 {
|
||||
unsigned int scratchRegs;
|
||||
unsigned int scratchSize;
|
||||
unsigned int availablevgprs;
|
||||
unsigned int availablesgprs;
|
||||
unsigned int usedvgprs;
|
||||
unsigned int usedsgprs;
|
||||
unsigned int availableldssize;
|
||||
unsigned int usedldssize;
|
||||
unsigned int availablestacksize;
|
||||
unsigned int usedstacksize;
|
||||
unsigned int wavefrontsize;
|
||||
unsigned int wavefrontpersimd;
|
||||
unsigned int threadsperworkgroup;
|
||||
unsigned int reqdworkgroup_x;
|
||||
unsigned int reqdworkgroup_y;
|
||||
unsigned int reqdworkgroup_z;
|
||||
} aclKernelStats;
|
||||
|
||||
#endif // _ACL_STRUCTS_0_8_H_
|
||||
@@ -1,100 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _ACL_API_TYPES_0_8_H_
|
||||
#define _ACL_API_TYPES_0_8_H_
|
||||
#include "aclDefs.h"
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
// Typedefs that always point to the most recent versions of the objects.
|
||||
typedef struct _acl_md_arg_type_0_8 aclArgData;
|
||||
typedef struct _acl_md_printf_fmt_0_8 aclPrintfFmt;
|
||||
typedef struct _acl_metadata_0_8 aclMetadata;
|
||||
typedef struct _acl_device_caps_rec_0_8 aclDevCaps;
|
||||
typedef struct _acl_target_info_rec_0_8 aclTargetInfo;
|
||||
typedef struct _acl_bif_rec_0_8_1 aclBinary;
|
||||
typedef struct _acl_binary_opts_rec_0_8_1 aclBinaryOptions;
|
||||
typedef struct _acl_compiler_rec_0_8_1 aclCompiler;
|
||||
typedef struct _acl_compiler_opts_rec_0_8_1 aclCompilerOptions;
|
||||
typedef struct _acl_options_0_8* aclOptions; // Opaque pointer to amd::Options
|
||||
typedef struct _acl_binary_0_8* aclBIF; // Opaque pointer to bifbase
|
||||
typedef struct _acl_common_loader_rec_0_8 aclCommonLoader;
|
||||
typedef struct _acl_cl_loader_rec_0_8 aclCLLoader;
|
||||
typedef struct _acl_sc_loader_rec_0_8 aclSCLoader;
|
||||
typedef struct _acl_fe_loader_rec_0_8 aclFELoader;
|
||||
typedef struct _acl_link_loader_rec_0_8 aclLinkLoader;
|
||||
typedef struct _acl_opt_loader_rec_0_8 aclOptLoader;
|
||||
typedef struct _acl_cg_loader_rec_0_8 aclCGLoader;
|
||||
typedef struct _acl_be_loader_rec_0_8 aclBELoader;
|
||||
typedef struct _acl_llvm_module_0_8* aclModule; // Opaque pointer to llvm::Module
|
||||
typedef struct _acl_llvm_context_0_8* aclContext; // Opaque pointer to llvm::Context
|
||||
typedef struct _acl_loader_data_0_8* aclLoaderData; // Opaque pointer to loader data
|
||||
|
||||
#include "aclEnums.h"
|
||||
// Typedefs for enumerations
|
||||
typedef enum _acl_error_enum_0_8 acl_error;
|
||||
typedef enum _comp_device_caps_enum_0_8 compDeviceCaps;
|
||||
typedef enum _comp_opt_settings_enum_0_8 compOptSettings;
|
||||
typedef enum _acl_dev_type_enum_0_8 aclDevType;
|
||||
typedef enum _acl_cl_version_enum_0_8 aclCLVersion;
|
||||
typedef enum _acl_type_enum_0_8 aclType;
|
||||
typedef enum _rt_query_types_enum_0_8 aclQueryType;
|
||||
typedef enum _rt_gpu_caps_enum_0_8 aclGPUCaps;
|
||||
typedef enum _rt_gpu_resource_enum_0_8 aclGPUResource;
|
||||
typedef enum _rt_gpu_mem_sizes_enum_0_8 aclGPUMemSizes;
|
||||
typedef enum _acl_arg_type_enum_0_8 aclArgType;
|
||||
typedef enum _acl_data_type_enum_0_8 aclArgDataType;
|
||||
typedef enum _acl_memory_type_enum_0_8 aclMemoryType;
|
||||
typedef enum _acl_access_type_enum_0_8 aclAccessType;
|
||||
typedef enum _bif_version_enum_0_8 aclBIFVersion;
|
||||
typedef enum _bif_platform_enum_0_8 aclPlatform;
|
||||
typedef enum _bif_sections_enum_0_8 aclSections;
|
||||
typedef enum _acl_loader_type_enum_0_8 aclLoaderType;
|
||||
typedef enum _acl_binary_image_type_enum_0_8 aclBinaryImageType;
|
||||
|
||||
#include "aclFunctors.h"
|
||||
// Typedefs for function pointers
|
||||
typedef aclLogFunction_0_8 aclLogFunction;
|
||||
typedef InsertSec_0_8 InsertSec;
|
||||
typedef RemoveSec_0_8 RemoveSec;
|
||||
typedef ExtractSec_0_8 ExtractSec;
|
||||
typedef InsertSym_0_8 InsertSym;
|
||||
typedef RemoveSym_0_8 RemoveSym;
|
||||
typedef ExtractSym_0_8 ExtractSym;
|
||||
typedef QueryInfo_0_8 QueryInfo;
|
||||
typedef Compile_0_8 Compile;
|
||||
typedef Link_0_8 Link;
|
||||
typedef AddDbgArg_0_8 AddDbgArg;
|
||||
typedef RemoveDbgArg_0_8 RemoveDbgArg;
|
||||
typedef SetupLoaderObject_0_8 SetupLoaderObject;
|
||||
typedef CompLog_0_8 CompLog;
|
||||
typedef RetrieveType_0_8 RetrieveType;
|
||||
typedef SetType_0_8 SetType;
|
||||
typedef ConvertType_0_8 ConvertType;
|
||||
typedef Disassemble_0_8 Disassemble;
|
||||
typedef GetDevBinary_0_8 GetDevBinary;
|
||||
typedef LoaderInit_0_8 LoaderInit;
|
||||
typedef LoaderFini_0_8 LoaderFini;
|
||||
typedef FEToIR_0_8 FEToIR;
|
||||
typedef SourceToISA_0_8 SourceToISA;
|
||||
typedef IRPhase_0_8 IRPhase;
|
||||
typedef LinkPhase_0_8 LinkPhase;
|
||||
typedef CGPhase_0_8 CGPhase;
|
||||
typedef DisasmISA_0_8 DisasmISA;
|
||||
typedef AllocFunc_0_8 AllocFunc;
|
||||
typedef FreeFunc_0_8 FreeFunc;
|
||||
typedef JITObjectImageCreate_0_8 JITObjectImageCreate;
|
||||
typedef JITObjectImageCopy_0_8 JITObjectImageCopy;
|
||||
typedef JITObjectImageDestroy_0_8 JITObjectImageDestroy;
|
||||
typedef JITObjectImageSize_0_8 JITObjectImageSize;
|
||||
typedef JITObjectImageData_0_8 JITObjectImageData;
|
||||
typedef JITObjectImageFinalize_0_8 JITObjectImageFinalize;
|
||||
typedef JITObjectImageGetGlobalsSize_0_8 JITObjectImageGetGlobalsSize;
|
||||
typedef JITSymbolCallback_0_8 JITSymbolCallback;
|
||||
typedef JITObjectImageIterateSymbols_0_8 JITObjectImageIterateSymbols;
|
||||
typedef JITObjectImageDisassembleKernel_0_8 JITObjectImageDisassembleKernel;
|
||||
|
||||
#include "aclStructs.h"
|
||||
|
||||
#endif // _CL_API_TYPES_0_8_H_
|
||||
@@ -1,18 +0,0 @@
|
||||
#include "spirvUtils.h"
|
||||
|
||||
const unsigned SPRVMagicNumber = 0x07230203;
|
||||
|
||||
bool isSPIRVMagic(const void* Image, size_t Length) {
|
||||
if (Image == nullptr || Length < sizeof(unsigned))
|
||||
return false;
|
||||
auto Magic = static_cast<const unsigned*>(Image);
|
||||
return *Magic == SPRVMagicNumber;
|
||||
}
|
||||
|
||||
// ToDo: replace this with SPIR-V validator when it is available.
|
||||
bool
|
||||
validateSPIRV(const void *Image, size_t Length) {
|
||||
return isSPIRVMagic(Image, Length);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#include "amdilUtils.hpp"
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
// Change all private uav length in a kernel
|
||||
void amdilUtils::changePrivateUAVLength(std::string& kernel, unsigned length) {
|
||||
std::regex pattern("dcl_typeless_uav_id\\(([[:digit:]]+)\\)_stride"
|
||||
"\\(([[:digit:]]+)\\)_length\\([[:digit:]]+\\)_access\\(private\\)");
|
||||
std::stringstream ss;
|
||||
ss << "dcl_typeless_uav_id($1)_stride($2)_length(" << length <<
|
||||
")_access(private)";
|
||||
kernel = std::regex_replace(kernel, pattern, ss.str());
|
||||
}
|
||||
|
||||
bool amdilUtils::isKernelMemoryBound(const std::string& kernel) {
|
||||
std::istringstream is(kernel);
|
||||
std::regex pattern("\\s*;\\s*membound\\s*:\\s*1\\s*");
|
||||
while (is) {
|
||||
std::string line;
|
||||
is >> line;
|
||||
if (std::regex_match(line, pattern))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
#ifndef AMDILUTILS_H_
|
||||
#define AMDILUTILS_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace amdilUtils {
|
||||
// Change all private uav length in a kernel
|
||||
void changePrivateUAVLength(std::string& kernel, unsigned length);
|
||||
|
||||
bool isKernelMemoryBound(const std::string& kernel);
|
||||
|
||||
}
|
||||
#endif /* AMDILUTILS_H_ */
|
||||
@@ -1,10 +1,421 @@
|
||||
//
|
||||
// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// This is a compatibility header file. Either define the version
|
||||
// of the compiler library to use or include the version specific
|
||||
// header file directly.
|
||||
#ifndef _CL_LIB_UTILS_H_
|
||||
#define _CL_LIB_UTILS_H_
|
||||
#include "v0_8/libUtils.h"
|
||||
#endif // _CL_LIB_UTILS_H_
|
||||
#ifndef _CL_LIB_UTILS_0_8_H_
|
||||
#define _CL_LIB_UTILS_0_8_H_
|
||||
#include "acl.h"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iterator>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include "library.hpp"
|
||||
#include "utils/bif_section_labels.hpp"
|
||||
#include "utils/options.hpp"
|
||||
using namespace bif;
|
||||
|
||||
// Utility function to set a flag in option structure
|
||||
// of the aclDevCaps.
|
||||
void
|
||||
setFlag(aclDevCaps *elf, compDeviceCaps option);
|
||||
|
||||
// Utility function to flip a flag in option structure
|
||||
// of the aclDevCaps.
|
||||
void
|
||||
flipFlag(aclDevCaps *elf, compDeviceCaps option);
|
||||
|
||||
// Utility function to clear a flag in option structure
|
||||
// of the aclDevCaps.
|
||||
void
|
||||
clearFlag(aclDevCaps *elf, compDeviceCaps option);
|
||||
|
||||
// Utility function to check that a flag in option structure
|
||||
// of the aclDevCaps is set.
|
||||
bool
|
||||
checkFlag(aclDevCaps *elf, compDeviceCaps option);
|
||||
|
||||
// Utility function to initialize and elf device capabilities
|
||||
void
|
||||
initElfDeviceCaps(aclBinary *elf);
|
||||
|
||||
// Append the string to the aclCompiler log string.
|
||||
void
|
||||
appendLogToCL(aclCompiler *cl, const std::string &logStr);
|
||||
|
||||
const char *getDeviceName(const aclTargetInfo &target);
|
||||
|
||||
// Select the correct library from the target information.
|
||||
amd::LibrarySelector getLibraryType(const aclTargetInfo *target);
|
||||
|
||||
// get family_enum from the target information.
|
||||
unsigned getFamilyEnum(const aclTargetInfo *target);
|
||||
|
||||
// get chip_enum from the target information.
|
||||
unsigned getChipEnum(const aclTargetInfo *target);
|
||||
|
||||
// get isa type name (compute capability) from the target information.
|
||||
const std::string &getIsaTypeName(const aclTargetInfo *target);
|
||||
|
||||
// get isa type (compute capability) from the target information.
|
||||
int getIsaType(const aclTargetInfo *target);
|
||||
|
||||
// get Feature String for target.
|
||||
std::string getFeatureString(const aclTargetInfo& target, amd::option::Options *OptionsObj);
|
||||
|
||||
// Create a copy of an ELF and duplicate all sections/symbols
|
||||
aclBinary*
|
||||
createELFCopy(aclBinary *src);
|
||||
|
||||
// Create a BIF2.1 elf from a BIF 2.0 elf
|
||||
aclBinary*
|
||||
convertBIF20ToBIF21(aclBinary *src);
|
||||
|
||||
// Create a BIF3.0 elf from a BIF 2.0 elf
|
||||
aclBinary*
|
||||
convertBIF20ToBIF30(aclBinary *src);
|
||||
|
||||
// Create a BIF3.1 elf from a BIF 2.0 elf
|
||||
aclBinary*
|
||||
convertBIF20ToBIF31(aclBinary *src);
|
||||
|
||||
// Create a BIF2.0 elf from a BIF 2.1 elf
|
||||
aclBinary*
|
||||
convertBIF21ToBIF20(aclBinary *src);
|
||||
|
||||
// Create a BIF3.0 elf from a BIF 2.1 elf
|
||||
aclBinary*
|
||||
convertBIF21ToBIF30(aclBinary *src);
|
||||
|
||||
// Create a BIF3.1 elf from a BIF 2.1 elf
|
||||
aclBinary*
|
||||
convertBIF21ToBIF31(aclBinary *src);
|
||||
|
||||
// Create a BIF2.0 elf from a BIF 3.0 elf
|
||||
aclBinary*
|
||||
convertBIF30ToBIF20(aclBinary *src);
|
||||
|
||||
// Create a BIF2.1 elf from a BIF 3.0 elf
|
||||
aclBinary*
|
||||
convertBIF30ToBIF21(aclBinary *src);
|
||||
|
||||
// Create a BIF3.1 elf from a BIF 3.0 elf
|
||||
aclBinary*
|
||||
convertBIF30ToBIF31(aclBinary *src);
|
||||
|
||||
// Create a BIF2.0 elf from a BIF 3.1 elf
|
||||
aclBinary*
|
||||
convertBIF31ToBIF20(aclBinary *src);
|
||||
|
||||
// Create a BIF2.1 elf from a BIF 3.1 elf
|
||||
aclBinary*
|
||||
convertBIF31ToBIF21(aclBinary *src);
|
||||
|
||||
// Create a BIF3.0 elf from a BIF 3.1 elf
|
||||
aclBinary*
|
||||
convertBIF31ToBIF30(aclBinary *src);
|
||||
|
||||
// get a pointer to the aclBIF irrespective of the
|
||||
// binary version.
|
||||
aclBIF*
|
||||
aclutGetBIF(aclBinary*);
|
||||
|
||||
// Get a pointer to the aclOptions irrespective of
|
||||
// the binary version.
|
||||
aclOptions*
|
||||
aclutGetOptions(aclBinary*);
|
||||
|
||||
// Get a pointer to the aclBinaryOptions struct
|
||||
// irrespective of the binary version.
|
||||
aclBinaryOptions*
|
||||
aclutGetBinOpts(aclBinary*);
|
||||
|
||||
// Get a pointer to the target info struct
|
||||
// irrespective of the binary version.
|
||||
aclTargetInfo*
|
||||
aclutGetTargetInfo(aclBinary*);
|
||||
|
||||
// Get a pointer to the device caps
|
||||
// irrespective of the binary version.
|
||||
aclDevCaps*
|
||||
aclutGetCaps(aclBinary*);
|
||||
|
||||
// Copy two binary option structures irrespective
|
||||
// of the binary version and uses defaults when
|
||||
// things don't match up.
|
||||
void
|
||||
aclutCopyBinOpts(aclBinaryOptions *dst,
|
||||
const aclBinaryOptions *src,
|
||||
bool is64bit);
|
||||
|
||||
// Retrieve kernel statistics from binary
|
||||
// and insert to elf as symbol
|
||||
acl_error aclutInsertKernelStatistics(aclCompiler*, aclBinary*);
|
||||
|
||||
// Returns target chip name.
|
||||
std::string aclutGetCodegenName(const aclTargetInfo &tgtInfo);
|
||||
|
||||
// Helper function that returns the
|
||||
// allocation function from the binary.
|
||||
AllocFunc
|
||||
aclutAlloc(const aclBinary *bin);
|
||||
|
||||
// Helper function that returns the
|
||||
// de-allocation function from the binary.
|
||||
FreeFunc
|
||||
aclutFree(const aclBinary *bin);
|
||||
|
||||
|
||||
// Helper function that returns the
|
||||
// allocation function from the compiler.
|
||||
AllocFunc
|
||||
aclutAlloc(const aclCompiler *bin);
|
||||
|
||||
// Helper function that returns the
|
||||
// de-allocation function from the compiler.
|
||||
FreeFunc
|
||||
aclutFree(const aclCompiler *bin);
|
||||
|
||||
// Helper function that returns the
|
||||
// allocation function from the compiler options.
|
||||
AllocFunc
|
||||
aclutAlloc(const aclCompilerOptions *bin);
|
||||
|
||||
// Helper function that returns the
|
||||
// de-allocation function from the compiler options.
|
||||
FreeFunc
|
||||
aclutFree(const aclCompilerOptions *bin);
|
||||
|
||||
inline std::vector<std::string> splitSpaceSeparatedString(char *str)
|
||||
{
|
||||
std::string s(str);
|
||||
std::stringstream ss(s);
|
||||
std::istream_iterator<std::string> beg(ss), end;
|
||||
std::vector<std::string> vec(beg, end);
|
||||
return vec;
|
||||
}
|
||||
|
||||
// Helper function that returns OpenCL mangled kernel name.
|
||||
inline std::string
|
||||
aclutOpenclMangledKernelName(const std::string& kernel_name)
|
||||
{
|
||||
const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclKernel);
|
||||
assert(sym && "symbol not found");
|
||||
return std::string("&") + sym->str[PRE] + kernel_name + sym->str[POST];
|
||||
}
|
||||
|
||||
// Helper function that returns OpenCL mangled kernel metadata symbol name.
|
||||
inline std::string
|
||||
aclutOpenclMangledKernelMetadataName(const std::string& kernel_name)
|
||||
{
|
||||
const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclMeta);
|
||||
assert(sym && "symbol not found");
|
||||
return sym->str[PRE] + aclutOpenclMangledKernelName(kernel_name) + sym->str[POST];
|
||||
}
|
||||
|
||||
#ifdef WITH_TARGET_HSAIL
|
||||
// Helper function that updates metadata for all the kernels in binary;
|
||||
// the updated attribute is the number of hidden kernel arguments.
|
||||
inline acl_error
|
||||
aclutUpdateMetadataWithHiddenKernargsNum(aclCompiler* cl, aclBinary* bin, uint32_t num) {
|
||||
if (num == MAX_HIDDEN_KERNARGS_NUM) {
|
||||
return ACL_SUCCESS;
|
||||
}
|
||||
const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclMeta);
|
||||
assert(sym && "symbol not found");
|
||||
aclSections secID = sym->sections[0];
|
||||
size_t kernelNamesSize = 0;
|
||||
acl_error error_code = aclQueryInfo(cl, bin, RT_KERNEL_NAMES, NULL, NULL, &kernelNamesSize);
|
||||
if (error_code != ACL_SUCCESS) {
|
||||
return error_code;
|
||||
}
|
||||
char* kernelNames = new char[kernelNamesSize];
|
||||
error_code = aclQueryInfo(cl, bin, RT_KERNEL_NAMES, NULL, kernelNames, &kernelNamesSize);
|
||||
if (error_code != ACL_SUCCESS) {
|
||||
delete[] kernelNames;
|
||||
return error_code;
|
||||
}
|
||||
std::vector<std::string> vKernels = splitSpaceSeparatedString(kernelNames);
|
||||
delete[] kernelNames;
|
||||
size_t roSize = 0;
|
||||
for (auto it = vKernels.begin(); it != vKernels.end(); ++it) {
|
||||
std::string symbol = aclutOpenclMangledKernelMetadataName(*it);
|
||||
void* roSec = const_cast<void*>(aclExtractSymbol(cl, bin, &roSize, secID, symbol.c_str(), &error_code));
|
||||
if (error_code != ACL_SUCCESS) {
|
||||
return error_code;
|
||||
}
|
||||
if (!roSec || roSize == 0) {
|
||||
error_code = ACL_ELF_ERROR;
|
||||
return error_code;
|
||||
}
|
||||
aclMetadata *md = reinterpret_cast<aclMetadata*>(roSec);
|
||||
md->numHiddenKernelArgs = num;
|
||||
error_code = aclRemoveSymbol(cl, bin, secID, symbol.c_str());
|
||||
if (error_code != ACL_SUCCESS) {
|
||||
return error_code;
|
||||
}
|
||||
error_code = aclInsertSymbol(cl, bin, md, roSize, secID, symbol.c_str());
|
||||
if (error_code != ACL_SUCCESS) {
|
||||
return error_code;
|
||||
}
|
||||
}
|
||||
return error_code;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct _target_mappings_rec;
|
||||
typedef _target_mappings_rec TargetMapping;
|
||||
|
||||
// Returns the TargetMapping for the specific target device.
|
||||
const TargetMapping& getTargetMapping(const aclTargetInfo &target);
|
||||
|
||||
inline bool is64BitTarget(const aclTargetInfo& target)
|
||||
{
|
||||
return (target.arch_id == aclX64 ||
|
||||
target.arch_id == aclAMDIL64 ||
|
||||
target.arch_id == aclHSAIL64);
|
||||
}
|
||||
|
||||
inline bool isCpuTarget(const aclTargetInfo& target)
|
||||
{
|
||||
return (target.arch_id == aclX64 || target.arch_id == aclX86);
|
||||
}
|
||||
|
||||
inline bool isGpuTarget(const aclTargetInfo& target)
|
||||
{
|
||||
return (target.arch_id == aclAMDIL || target.arch_id == aclAMDIL64 ||
|
||||
target.arch_id == aclHSAIL || target.arch_id == aclHSAIL64);
|
||||
}
|
||||
|
||||
inline bool isAMDILTarget(const aclTargetInfo& target)
|
||||
{
|
||||
return (target.arch_id == aclAMDIL || target.arch_id == aclAMDIL64);
|
||||
}
|
||||
|
||||
inline bool isHSAILTarget(const aclTargetInfo& target)
|
||||
{
|
||||
return (target.arch_id == aclHSAIL || target.arch_id == aclHSAIL64);
|
||||
}
|
||||
|
||||
const std::string& getLegacyLibName();
|
||||
|
||||
inline bool isValidTarget(const aclTargetInfo& target)
|
||||
{
|
||||
return (target.arch_id && target.chip_id);
|
||||
}
|
||||
|
||||
bool isChipSupported(const aclTargetInfo& target);
|
||||
|
||||
enum scId {
|
||||
SC_AMDIL = 0,
|
||||
SC_HSAIL = 0,
|
||||
SC_LAST,
|
||||
};
|
||||
|
||||
// Helper function that allocates an aligned memory.
|
||||
inline void*
|
||||
alignedMalloc(size_t size, size_t alignment)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return ::_aligned_malloc(size, alignment);
|
||||
#else
|
||||
void * ptr = NULL;
|
||||
if (0 == ::posix_memalign(&ptr, alignment, size)) {
|
||||
return ptr;
|
||||
}
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Helper function that frees an aligned memory.
|
||||
inline void
|
||||
alignedFree(void *ptr)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
::_aligned_free(ptr);
|
||||
#else
|
||||
free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
inline void convertLongAbsFilePathIfNeeded(std::string &filename)
|
||||
{
|
||||
if (filename.empty()) {
|
||||
return;
|
||||
}
|
||||
std::wstring ws(filename.begin(), filename.end());
|
||||
wchar_t abs_path[_MAX_ENV];
|
||||
_wfullpath(abs_path, ws.c_str(), _MAX_ENV);
|
||||
std::wstring ws_abs = std::wstring(abs_path);
|
||||
if (ws_abs.size() >= _MAX_PATH) {
|
||||
std::string s(ws_abs.begin(), ws_abs.end());
|
||||
filename = "\\\\?\\" + s;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
inline char* readFile(std::string source_filename, size_t& size)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
convertLongAbsFilePathIfNeeded(source_filename);
|
||||
#endif
|
||||
FILE *fp = ::fopen( source_filename.c_str(), "rb" );
|
||||
unsigned int length;
|
||||
size_t offset = 0;
|
||||
char *ptr;
|
||||
if (!fp) {
|
||||
return NULL;
|
||||
}
|
||||
// obtain file size
|
||||
::fseek (fp , 0 , SEEK_END);
|
||||
length = ::ftell (fp);
|
||||
::rewind (fp);
|
||||
ptr = reinterpret_cast<char*>(::malloc(offset + length + 1));
|
||||
if (length != fread(&ptr[offset], 1, length, fp))
|
||||
{
|
||||
::free(ptr);
|
||||
::fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
ptr[offset + length] = '\0';
|
||||
size = offset + length;
|
||||
::fclose(fp);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
inline bool writeFile(std::string source_filename, const char *source, size_t size)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
convertLongAbsFilePathIfNeeded(source_filename);
|
||||
#endif
|
||||
FILE *fp = ::fopen(source_filename.c_str(), "wb");
|
||||
if (!fp) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (!::fwrite(source, size, 1, fp)) {
|
||||
::fclose(fp);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
::fclose(fp);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#if !defined(BCMAG)
|
||||
#define BCMAG "BC"
|
||||
#define SBCMAG 2
|
||||
#endif
|
||||
// Helper predicate returns true if p starts with bit code signature.
|
||||
// TODO: Move it into Compiler Lib back in new 1_0 API
|
||||
inline static bool
|
||||
isBcMagic(const char* p)
|
||||
{
|
||||
if (p==NULL || strncmp(p, BCMAG, SBCMAG) != 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void dump(aclBinary *bin);
|
||||
|
||||
#endif // _CL_LIB_UTILS_0_8_H_
|
||||
@@ -1,18 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// This is a compatibility header file. Either define the version
|
||||
// of the compiler library to use or include the version specific
|
||||
// header file directly.
|
||||
#ifndef TARGET_MAPPINGS_H_
|
||||
#define TARGET_MAPPINGS_H_
|
||||
|
||||
#include "v0_8/target_mappings.h"
|
||||
|
||||
#define X86TargetMapping X86TargetMapping_0_8
|
||||
#define X64TargetMapping X64TargetMapping_0_8
|
||||
#define AMDILTargetMapping AMDILTargetMapping_0_8
|
||||
#define HSAILTargetMapping HSAILTargetMapping_0_8
|
||||
#define AMDIL64TargetMapping AMDIL64TargetMapping_0_8
|
||||
#define HSAIL64TargetMapping HSAIL64TargetMapping_0_8
|
||||
#endif // TARGET_MAPPINGS_H_
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,421 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _CL_LIB_UTILS_0_8_H_
|
||||
#define _CL_LIB_UTILS_0_8_H_
|
||||
#include "acl.h"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iterator>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include "library.hpp"
|
||||
#include "utils/bif_section_labels.hpp"
|
||||
#include "utils/options.hpp"
|
||||
using namespace bif;
|
||||
|
||||
// Utility function to set a flag in option structure
|
||||
// of the aclDevCaps.
|
||||
void
|
||||
setFlag(aclDevCaps *elf, compDeviceCaps option);
|
||||
|
||||
// Utility function to flip a flag in option structure
|
||||
// of the aclDevCaps.
|
||||
void
|
||||
flipFlag(aclDevCaps *elf, compDeviceCaps option);
|
||||
|
||||
// Utility function to clear a flag in option structure
|
||||
// of the aclDevCaps.
|
||||
void
|
||||
clearFlag(aclDevCaps *elf, compDeviceCaps option);
|
||||
|
||||
// Utility function to check that a flag in option structure
|
||||
// of the aclDevCaps is set.
|
||||
bool
|
||||
checkFlag(aclDevCaps *elf, compDeviceCaps option);
|
||||
|
||||
// Utility function to initialize and elf device capabilities
|
||||
void
|
||||
initElfDeviceCaps(aclBinary *elf);
|
||||
|
||||
// Append the string to the aclCompiler log string.
|
||||
void
|
||||
appendLogToCL(aclCompiler *cl, const std::string &logStr);
|
||||
|
||||
const char *getDeviceName(const aclTargetInfo &target);
|
||||
|
||||
// Select the correct library from the target information.
|
||||
amd::LibrarySelector getLibraryType(const aclTargetInfo *target);
|
||||
|
||||
// get family_enum from the target information.
|
||||
unsigned getFamilyEnum(const aclTargetInfo *target);
|
||||
|
||||
// get chip_enum from the target information.
|
||||
unsigned getChipEnum(const aclTargetInfo *target);
|
||||
|
||||
// get isa type name (compute capability) from the target information.
|
||||
const std::string &getIsaTypeName(const aclTargetInfo *target);
|
||||
|
||||
// get isa type (compute capability) from the target information.
|
||||
int getIsaType(const aclTargetInfo *target);
|
||||
|
||||
// get Feature String for target.
|
||||
std::string getFeatureString(const aclTargetInfo& target, amd::option::Options *OptionsObj);
|
||||
|
||||
// Create a copy of an ELF and duplicate all sections/symbols
|
||||
aclBinary*
|
||||
createELFCopy(aclBinary *src);
|
||||
|
||||
// Create a BIF2.1 elf from a BIF 2.0 elf
|
||||
aclBinary*
|
||||
convertBIF20ToBIF21(aclBinary *src);
|
||||
|
||||
// Create a BIF3.0 elf from a BIF 2.0 elf
|
||||
aclBinary*
|
||||
convertBIF20ToBIF30(aclBinary *src);
|
||||
|
||||
// Create a BIF3.1 elf from a BIF 2.0 elf
|
||||
aclBinary*
|
||||
convertBIF20ToBIF31(aclBinary *src);
|
||||
|
||||
// Create a BIF2.0 elf from a BIF 2.1 elf
|
||||
aclBinary*
|
||||
convertBIF21ToBIF20(aclBinary *src);
|
||||
|
||||
// Create a BIF3.0 elf from a BIF 2.1 elf
|
||||
aclBinary*
|
||||
convertBIF21ToBIF30(aclBinary *src);
|
||||
|
||||
// Create a BIF3.1 elf from a BIF 2.1 elf
|
||||
aclBinary*
|
||||
convertBIF21ToBIF31(aclBinary *src);
|
||||
|
||||
// Create a BIF2.0 elf from a BIF 3.0 elf
|
||||
aclBinary*
|
||||
convertBIF30ToBIF20(aclBinary *src);
|
||||
|
||||
// Create a BIF2.1 elf from a BIF 3.0 elf
|
||||
aclBinary*
|
||||
convertBIF30ToBIF21(aclBinary *src);
|
||||
|
||||
// Create a BIF3.1 elf from a BIF 3.0 elf
|
||||
aclBinary*
|
||||
convertBIF30ToBIF31(aclBinary *src);
|
||||
|
||||
// Create a BIF2.0 elf from a BIF 3.1 elf
|
||||
aclBinary*
|
||||
convertBIF31ToBIF20(aclBinary *src);
|
||||
|
||||
// Create a BIF2.1 elf from a BIF 3.1 elf
|
||||
aclBinary*
|
||||
convertBIF31ToBIF21(aclBinary *src);
|
||||
|
||||
// Create a BIF3.0 elf from a BIF 3.1 elf
|
||||
aclBinary*
|
||||
convertBIF31ToBIF30(aclBinary *src);
|
||||
|
||||
// get a pointer to the aclBIF irrespective of the
|
||||
// binary version.
|
||||
aclBIF*
|
||||
aclutGetBIF(aclBinary*);
|
||||
|
||||
// Get a pointer to the aclOptions irrespective of
|
||||
// the binary version.
|
||||
aclOptions*
|
||||
aclutGetOptions(aclBinary*);
|
||||
|
||||
// Get a pointer to the aclBinaryOptions struct
|
||||
// irrespective of the binary version.
|
||||
aclBinaryOptions*
|
||||
aclutGetBinOpts(aclBinary*);
|
||||
|
||||
// Get a pointer to the target info struct
|
||||
// irrespective of the binary version.
|
||||
aclTargetInfo*
|
||||
aclutGetTargetInfo(aclBinary*);
|
||||
|
||||
// Get a pointer to the device caps
|
||||
// irrespective of the binary version.
|
||||
aclDevCaps*
|
||||
aclutGetCaps(aclBinary*);
|
||||
|
||||
// Copy two binary option structures irrespective
|
||||
// of the binary version and uses defaults when
|
||||
// things don't match up.
|
||||
void
|
||||
aclutCopyBinOpts(aclBinaryOptions *dst,
|
||||
const aclBinaryOptions *src,
|
||||
bool is64bit);
|
||||
|
||||
// Retrieve kernel statistics from binary
|
||||
// and insert to elf as symbol
|
||||
acl_error aclutInsertKernelStatistics(aclCompiler*, aclBinary*);
|
||||
|
||||
// Returns target chip name.
|
||||
std::string aclutGetCodegenName(const aclTargetInfo &tgtInfo);
|
||||
|
||||
// Helper function that returns the
|
||||
// allocation function from the binary.
|
||||
AllocFunc
|
||||
aclutAlloc(const aclBinary *bin);
|
||||
|
||||
// Helper function that returns the
|
||||
// de-allocation function from the binary.
|
||||
FreeFunc
|
||||
aclutFree(const aclBinary *bin);
|
||||
|
||||
|
||||
// Helper function that returns the
|
||||
// allocation function from the compiler.
|
||||
AllocFunc
|
||||
aclutAlloc(const aclCompiler *bin);
|
||||
|
||||
// Helper function that returns the
|
||||
// de-allocation function from the compiler.
|
||||
FreeFunc
|
||||
aclutFree(const aclCompiler *bin);
|
||||
|
||||
// Helper function that returns the
|
||||
// allocation function from the compiler options.
|
||||
AllocFunc
|
||||
aclutAlloc(const aclCompilerOptions *bin);
|
||||
|
||||
// Helper function that returns the
|
||||
// de-allocation function from the compiler options.
|
||||
FreeFunc
|
||||
aclutFree(const aclCompilerOptions *bin);
|
||||
|
||||
inline std::vector<std::string> splitSpaceSeparatedString(char *str)
|
||||
{
|
||||
std::string s(str);
|
||||
std::stringstream ss(s);
|
||||
std::istream_iterator<std::string> beg(ss), end;
|
||||
std::vector<std::string> vec(beg, end);
|
||||
return vec;
|
||||
}
|
||||
|
||||
// Helper function that returns OpenCL mangled kernel name.
|
||||
inline std::string
|
||||
aclutOpenclMangledKernelName(const std::string& kernel_name)
|
||||
{
|
||||
const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclKernel);
|
||||
assert(sym && "symbol not found");
|
||||
return std::string("&") + sym->str[PRE] + kernel_name + sym->str[POST];
|
||||
}
|
||||
|
||||
// Helper function that returns OpenCL mangled kernel metadata symbol name.
|
||||
inline std::string
|
||||
aclutOpenclMangledKernelMetadataName(const std::string& kernel_name)
|
||||
{
|
||||
const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclMeta);
|
||||
assert(sym && "symbol not found");
|
||||
return sym->str[PRE] + aclutOpenclMangledKernelName(kernel_name) + sym->str[POST];
|
||||
}
|
||||
|
||||
#ifdef WITH_TARGET_HSAIL
|
||||
// Helper function that updates metadata for all the kernels in binary;
|
||||
// the updated attribute is the number of hidden kernel arguments.
|
||||
inline acl_error
|
||||
aclutUpdateMetadataWithHiddenKernargsNum(aclCompiler* cl, aclBinary* bin, uint32_t num) {
|
||||
if (num == MAX_HIDDEN_KERNARGS_NUM) {
|
||||
return ACL_SUCCESS;
|
||||
}
|
||||
const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclMeta);
|
||||
assert(sym && "symbol not found");
|
||||
aclSections secID = sym->sections[0];
|
||||
size_t kernelNamesSize = 0;
|
||||
acl_error error_code = aclQueryInfo(cl, bin, RT_KERNEL_NAMES, NULL, NULL, &kernelNamesSize);
|
||||
if (error_code != ACL_SUCCESS) {
|
||||
return error_code;
|
||||
}
|
||||
char* kernelNames = new char[kernelNamesSize];
|
||||
error_code = aclQueryInfo(cl, bin, RT_KERNEL_NAMES, NULL, kernelNames, &kernelNamesSize);
|
||||
if (error_code != ACL_SUCCESS) {
|
||||
delete[] kernelNames;
|
||||
return error_code;
|
||||
}
|
||||
std::vector<std::string> vKernels = splitSpaceSeparatedString(kernelNames);
|
||||
delete[] kernelNames;
|
||||
size_t roSize = 0;
|
||||
for (auto it = vKernels.begin(); it != vKernels.end(); ++it) {
|
||||
std::string symbol = aclutOpenclMangledKernelMetadataName(*it);
|
||||
void* roSec = const_cast<void*>(aclExtractSymbol(cl, bin, &roSize, secID, symbol.c_str(), &error_code));
|
||||
if (error_code != ACL_SUCCESS) {
|
||||
return error_code;
|
||||
}
|
||||
if (!roSec || roSize == 0) {
|
||||
error_code = ACL_ELF_ERROR;
|
||||
return error_code;
|
||||
}
|
||||
aclMetadata *md = reinterpret_cast<aclMetadata*>(roSec);
|
||||
md->numHiddenKernelArgs = num;
|
||||
error_code = aclRemoveSymbol(cl, bin, secID, symbol.c_str());
|
||||
if (error_code != ACL_SUCCESS) {
|
||||
return error_code;
|
||||
}
|
||||
error_code = aclInsertSymbol(cl, bin, md, roSize, secID, symbol.c_str());
|
||||
if (error_code != ACL_SUCCESS) {
|
||||
return error_code;
|
||||
}
|
||||
}
|
||||
return error_code;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct _target_mappings_rec;
|
||||
typedef _target_mappings_rec TargetMapping;
|
||||
|
||||
// Returns the TargetMapping for the specific target device.
|
||||
const TargetMapping& getTargetMapping(const aclTargetInfo &target);
|
||||
|
||||
inline bool is64BitTarget(const aclTargetInfo& target)
|
||||
{
|
||||
return (target.arch_id == aclX64 ||
|
||||
target.arch_id == aclAMDIL64 ||
|
||||
target.arch_id == aclHSAIL64);
|
||||
}
|
||||
|
||||
inline bool isCpuTarget(const aclTargetInfo& target)
|
||||
{
|
||||
return (target.arch_id == aclX64 || target.arch_id == aclX86);
|
||||
}
|
||||
|
||||
inline bool isGpuTarget(const aclTargetInfo& target)
|
||||
{
|
||||
return (target.arch_id == aclAMDIL || target.arch_id == aclAMDIL64 ||
|
||||
target.arch_id == aclHSAIL || target.arch_id == aclHSAIL64);
|
||||
}
|
||||
|
||||
inline bool isAMDILTarget(const aclTargetInfo& target)
|
||||
{
|
||||
return (target.arch_id == aclAMDIL || target.arch_id == aclAMDIL64);
|
||||
}
|
||||
|
||||
inline bool isHSAILTarget(const aclTargetInfo& target)
|
||||
{
|
||||
return (target.arch_id == aclHSAIL || target.arch_id == aclHSAIL64);
|
||||
}
|
||||
|
||||
const std::string& getLegacyLibName();
|
||||
|
||||
inline bool isValidTarget(const aclTargetInfo& target)
|
||||
{
|
||||
return (target.arch_id && target.chip_id);
|
||||
}
|
||||
|
||||
bool isChipSupported(const aclTargetInfo& target);
|
||||
|
||||
enum scId {
|
||||
SC_AMDIL = 0,
|
||||
SC_HSAIL = 0,
|
||||
SC_LAST,
|
||||
};
|
||||
|
||||
// Helper function that allocates an aligned memory.
|
||||
inline void*
|
||||
alignedMalloc(size_t size, size_t alignment)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return ::_aligned_malloc(size, alignment);
|
||||
#else
|
||||
void * ptr = NULL;
|
||||
if (0 == ::posix_memalign(&ptr, alignment, size)) {
|
||||
return ptr;
|
||||
}
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Helper function that frees an aligned memory.
|
||||
inline void
|
||||
alignedFree(void *ptr)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
::_aligned_free(ptr);
|
||||
#else
|
||||
free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
inline void convertLongAbsFilePathIfNeeded(std::string &filename)
|
||||
{
|
||||
if (filename.empty()) {
|
||||
return;
|
||||
}
|
||||
std::wstring ws(filename.begin(), filename.end());
|
||||
wchar_t abs_path[_MAX_ENV];
|
||||
_wfullpath(abs_path, ws.c_str(), _MAX_ENV);
|
||||
std::wstring ws_abs = std::wstring(abs_path);
|
||||
if (ws_abs.size() >= _MAX_PATH) {
|
||||
std::string s(ws_abs.begin(), ws_abs.end());
|
||||
filename = "\\\\?\\" + s;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
inline char* readFile(std::string source_filename, size_t& size)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
convertLongAbsFilePathIfNeeded(source_filename);
|
||||
#endif
|
||||
FILE *fp = ::fopen( source_filename.c_str(), "rb" );
|
||||
unsigned int length;
|
||||
size_t offset = 0;
|
||||
char *ptr;
|
||||
if (!fp) {
|
||||
return NULL;
|
||||
}
|
||||
// obtain file size
|
||||
::fseek (fp , 0 , SEEK_END);
|
||||
length = ::ftell (fp);
|
||||
::rewind (fp);
|
||||
ptr = reinterpret_cast<char*>(::malloc(offset + length + 1));
|
||||
if (length != fread(&ptr[offset], 1, length, fp))
|
||||
{
|
||||
::free(ptr);
|
||||
::fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
ptr[offset + length] = '\0';
|
||||
size = offset + length;
|
||||
::fclose(fp);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
inline bool writeFile(std::string source_filename, const char *source, size_t size)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
convertLongAbsFilePathIfNeeded(source_filename);
|
||||
#endif
|
||||
FILE *fp = ::fopen(source_filename.c_str(), "wb");
|
||||
if (!fp) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (!::fwrite(source, size, 1, fp)) {
|
||||
::fclose(fp);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
::fclose(fp);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#if !defined(BCMAG)
|
||||
#define BCMAG "BC"
|
||||
#define SBCMAG 2
|
||||
#endif
|
||||
// Helper predicate returns true if p starts with bit code signature.
|
||||
// TODO: Move it into Compiler Lib back in new 1_0 API
|
||||
inline static bool
|
||||
isBcMagic(const char* p)
|
||||
{
|
||||
if (p==NULL || strncmp(p, BCMAG, SBCMAG) != 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void dump(aclBinary *bin);
|
||||
|
||||
#endif // _CL_LIB_UTILS_0_8_H_
|
||||
@@ -1,311 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _CL_UTILS_TARGET_MAPPINGS_0_8_H_
|
||||
#define _CL_UTILS_TARGET_MAPPINGS_0_8_H_
|
||||
#include "top.hpp"
|
||||
#include "library.hpp"
|
||||
#include "aclTypes.h"
|
||||
#ifndef FAMILY_UNKNOWN
|
||||
#define FAMILY_UNKNOWN 0
|
||||
#endif
|
||||
|
||||
#ifndef FAMILY_X86
|
||||
#define FAMILY_X86 1
|
||||
#endif
|
||||
|
||||
#ifndef FAMILY_X64
|
||||
#define FAMILY_X64 2
|
||||
#endif
|
||||
|
||||
#define ARRAY_SIZEOF(A) (sizeof(A)/sizeof(A[0]))
|
||||
|
||||
typedef struct _target_mappings_rec {
|
||||
const char* family_name;
|
||||
const char* chip_name;
|
||||
const char* codegen_name;
|
||||
amd::LibrarySelector lib;
|
||||
unsigned chip_enum;
|
||||
uint64_t chip_options;
|
||||
bool supported; // a false value means this device is not supported.
|
||||
bool default_chip; // Chip to select if multiple chips with the same name exist.
|
||||
unsigned family_enum; // Only used for GPU devices currently, for CPU we should put features.
|
||||
bool xnack_supported; // XNACK support as per http://confluence.amd.com/pages/viewpage.action?spaceKey=ASLC&title=AMDGPU+Target+Names
|
||||
} TargetMapping;
|
||||
|
||||
const TargetMapping UnknownTarget = { "UnknownFamily", "UnknownChip", "UnknownCodeGen",
|
||||
amd::LibraryUndefined, 0, 0, false, false, FAMILY_UNKNOWN, false};
|
||||
const TargetMapping InvalidTarget = { NULL, NULL, NULL,
|
||||
amd::LibraryUndefined, 0, 0, false, false, FAMILY_UNKNOWN, false};
|
||||
|
||||
typedef struct _family_map_rec {
|
||||
const TargetMapping* target;
|
||||
const char* architecture;
|
||||
const char* triple;
|
||||
unsigned children_size;
|
||||
} FamilyMapping;
|
||||
const FamilyMapping UnknownFamily = { NULL, "UnknownFamily", "unknown", 0 };
|
||||
const FamilyMapping InvalidFamily = { NULL, NULL, NULL, 0 };
|
||||
typedef enum {
|
||||
F_CPU_CMOV = 1,
|
||||
F_CPU_POPCNT = 2,
|
||||
F_CPU_MMX = 3,
|
||||
F_CPU_SSE1 = 4,
|
||||
F_CPU_SSE2 = 5,
|
||||
F_CPU_SSE3 = 6,
|
||||
F_CPU_SSSE3 = 7,
|
||||
F_CPU_SSE41 = 8,
|
||||
F_CPU_SSE42 = 9,
|
||||
F_CPU_SSE4A = 10,
|
||||
F_CPU_3DNow = 11,
|
||||
F_CPU_3DNowA = 12,
|
||||
F_CPU_64Bit = 13,
|
||||
F_CPU_SBTMem = 14,
|
||||
F_CPU_FUAMem = 15,
|
||||
F_CPU_AVX = 16,
|
||||
F_CPU_CLMUL = 17,
|
||||
F_CPU_VUAMem = 18,
|
||||
F_CPU_AES = 19,
|
||||
F_CPU_CXCHG16B = 20,
|
||||
F_CPU_AVX2 = 21,
|
||||
F_CPU_FMA3 = 22,
|
||||
F_CPU_FMA4 = 23,
|
||||
F_CPU_MOVBE = 24,
|
||||
F_CPU_RDRAND = 25,
|
||||
F_CPU_F16C = 26,
|
||||
F_CPU_64BitMode = 27,
|
||||
F_CPU_LZCNT = 28,
|
||||
F_CPU_BMI = 29,
|
||||
F_CPU_BMI2 = 30, // LLVM 3.1 only
|
||||
F_CPU_LeaForSP = 31, // LLVM 3.1 only
|
||||
F_CPU_FSGSBASE = 32, // LLVM 3.1 only
|
||||
F_CPU_XOP = 33, // LLVM 3.1 only
|
||||
F_CPU_ATOM = 34, // LLVM 3.1 only
|
||||
F_CPU_LAST = 35
|
||||
} CPUCodeGenFlags;
|
||||
|
||||
static const char* CPUCodeGenFlagTable[] =
|
||||
{
|
||||
"cmov",
|
||||
"popcnt",
|
||||
"mmx",
|
||||
"sse",
|
||||
"sse2",
|
||||
"sse3",
|
||||
"ssse3",
|
||||
"sse41",
|
||||
"sse42",
|
||||
"sse4a",
|
||||
"3dnow",
|
||||
"3dnowa",
|
||||
"64bit",
|
||||
"slow-bt-mem",
|
||||
"fast-unaligned-mem",
|
||||
"avx",
|
||||
"clmul",
|
||||
"vector-unaligned-mem",
|
||||
"aes",
|
||||
"cmpxchg16b",
|
||||
"avx2",
|
||||
"fma3",
|
||||
"fma4",
|
||||
"movbe",
|
||||
"rdrand",
|
||||
"f16c",
|
||||
"fsgsbase",
|
||||
"lzcnt",
|
||||
"bmi",
|
||||
"bmi2",
|
||||
"lea-sp",
|
||||
"64bit-mode",
|
||||
"xop",
|
||||
"atom"
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
// Bits for each feature.
|
||||
F_FP64 = 0x0001,
|
||||
F_BYTE_ADDRESSABLE = 0x0002,
|
||||
F_BARRIER_DETECT = 0x0004,
|
||||
F_IMAGES = 0x0008,
|
||||
F_MULTI_UAV = 0x0010,
|
||||
F_MACRO_DB = 0x0020,
|
||||
F_NO_ALIAS = 0x0040,
|
||||
F_NO_INLINE = 0x0080,
|
||||
F_64BIT_PTR = 0x0100,
|
||||
F_32ON64BIT_PTR = 0x0200,
|
||||
F_DEBUG = 0x0400,
|
||||
F_MWGS_256 = 0x0800,
|
||||
F_MWGS_128 = 0x1000,
|
||||
F_MWGS_64 = 0x2000,
|
||||
F_MWGS_32 = 0x4000,
|
||||
F_MWGS_16 = 0x8000,
|
||||
F_MD_30 = 0x10000,
|
||||
F_STACK_UAV = 0x20000,
|
||||
F_MACRO_CALL = 0x40000,
|
||||
// Bitmasks for each device type.
|
||||
F_RV7XX_BASE = F_MACRO_DB|F_BARRIER_DETECT|F_MD_30,
|
||||
F_RV710 = F_RV7XX_BASE|F_MWGS_32,
|
||||
F_RV730 = F_RV7XX_BASE|F_MWGS_16,
|
||||
F_RV770 = F_RV7XX_BASE|F_MWGS_64|F_FP64,
|
||||
F_EG_BASE = F_BYTE_ADDRESSABLE|F_IMAGES|F_MACRO_DB|F_MD_30,
|
||||
F_EG_EXT = F_EG_BASE|F_FP64|F_MWGS_256,
|
||||
F_CEDAR = F_EG_BASE|F_MWGS_128,
|
||||
F_REDWOOD = F_EG_BASE|F_MWGS_256,
|
||||
F_JUNIPER = F_EG_BASE|F_MWGS_256,
|
||||
F_NI_BASE = F_EG_BASE|F_MWGS_256,
|
||||
F_NI_EXT = F_NI_BASE|F_FP64,
|
||||
F_SI_BASE = F_NI_EXT|F_STACK_UAV|F_MACRO_CALL,
|
||||
F_SI_64BIT_PTR = F_SI_BASE|F_64BIT_PTR
|
||||
} GPUCodeGenFlags;
|
||||
|
||||
typedef enum {
|
||||
// Bits for each feature.
|
||||
F_FP32_DENORMS = 0x0001,
|
||||
// Bitmasks for each device type.
|
||||
F_CI_BASE = 0,
|
||||
F_VI_BASE = F_CI_BASE | F_FP32_DENORMS,
|
||||
F_AI_BASE = F_VI_BASE
|
||||
} HSAILCodeGenFlags;
|
||||
|
||||
static const char* GPUCodeGenFlagTable[] = {
|
||||
"fp64",
|
||||
"byte_addressable_store",
|
||||
"barrier_detect",
|
||||
"images",
|
||||
"multi_uav",
|
||||
"macrodb",
|
||||
"noalias",
|
||||
"no-inline",
|
||||
"64bitptr",
|
||||
"small-global-objects",
|
||||
"debug",
|
||||
"mwgs-3-256-1-1",
|
||||
"mwgs-3-128-1-1",
|
||||
"mwgs-3-64-1-1",
|
||||
"mwgs-3-32-1-1",
|
||||
"mwgs-3-16-1-1",
|
||||
"metadata30",
|
||||
"stack-uav",
|
||||
"macro-call"
|
||||
};
|
||||
|
||||
static const char* HSAILCodeGenFlagTable[] = {
|
||||
"fp32-denormals"
|
||||
};
|
||||
|
||||
static const char* calTargetMapping[] = {
|
||||
"RV600", "RV610", "RV630", "RV670",
|
||||
"RV770", "RV770", "RV710", "RV730",
|
||||
"Cypress", "Juniper", "Redwood", "Cedar",
|
||||
"WinterPark", "BeaverCreek", "Loveland",
|
||||
"Cayman", "Kauai", "Barts", "Turks", "Caicos",
|
||||
"Tahiti", "Pitcairn", "Capeverde",
|
||||
"Devastator", "Scrapper",
|
||||
"Oland", "Bonaire",
|
||||
"Spectre", "Spooky", "Kalindi",
|
||||
"Hainan", "Hawaii",
|
||||
"Iceland", "Tonga", "Mullins", "Fiji",
|
||||
"Carrizo", "Ellesmere", "Baffin",
|
||||
IF(IS_BRAHMA,"","gfx900"),
|
||||
"Stoney",
|
||||
"gfx804",
|
||||
IF(IS_BRAHMA,"","gfx901"),
|
||||
IF(IS_BRAHMA,"","gfx902"),
|
||||
IF(IS_BRAHMA,"","gfx903"),
|
||||
IF(IS_BRAHMA,"","gfx904"),
|
||||
IF(IS_BRAHMA,"","gfx905"),
|
||||
IF(IS_BRAHMA,"","gfx906"),
|
||||
IF(IS_BRAHMA,"","gfx907"),
|
||||
IF(IS_BRAHMA,"","gfx908"),
|
||||
IF(IS_BRAHMA,"","gfx1000"),
|
||||
IF(IS_BRAHMA,"","gfx1010"),
|
||||
IF(IS_BRAHMA,"","gfx1011"),
|
||||
IF(IS_BRAHMA,"","gfx1012"),
|
||||
};
|
||||
|
||||
#include "utils/v0_8/target_mappings_amdil.h"
|
||||
#include "utils/v0_8/target_mappings_hsail.h"
|
||||
#include "utils/v0_8/target_mappings_x86.h"
|
||||
#include "utils/v0_8/target_mappings_x64.h"
|
||||
#include "utils/v0_8/target_mappings_amdil64.h"
|
||||
#include "utils/v0_8/target_mappings_hsail64.h"
|
||||
// FIXME: Add static asserts to make sure that all of the arrays for TargetMapping match the enum table.
|
||||
|
||||
#define DATA_LAYOUT_64BIT "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16" \
|
||||
"-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:32:32" \
|
||||
"-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64" \
|
||||
"-v96:128:128-v128:128:128-v192:256:256-v256:256:256" \
|
||||
"-v512:512:512-v1024:1024:1024-v2048:2048:2048-a0:0:64" \
|
||||
"-n32"
|
||||
|
||||
#define DATA_LAYOUT_32BIT "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" \
|
||||
"-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:32:32" \
|
||||
"-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64" \
|
||||
"-v96:128:128-v128:128:128-v192:256:256-v256:256:256" \
|
||||
"-v512:512:512-v1024:1024:1024-v2048:2048:2048-a0:0:64" \
|
||||
"-n32"
|
||||
|
||||
inline const char* getArchitecture(aclDevType arch_id)
|
||||
{
|
||||
switch (arch_id) {
|
||||
case aclX86:
|
||||
return "x86";
|
||||
case aclAMDIL:
|
||||
return "amdil";
|
||||
case aclHSAIL:
|
||||
return "hsail";
|
||||
case aclX64:
|
||||
return "x86-64";
|
||||
case aclHSAIL64:
|
||||
return "hsail64";
|
||||
case aclAMDIL64:
|
||||
return "amdil64";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
inline const char* getTriple(aclDevType arch_id)
|
||||
{
|
||||
switch (arch_id) {
|
||||
case aclX86:
|
||||
#ifdef _WIN32
|
||||
return "i686-pc-mingw32-amdopencl";
|
||||
#else
|
||||
return "i686-pc-linux-amdopencl";
|
||||
#endif
|
||||
case aclAMDIL:
|
||||
return "amdil-pc-unknown-amdopencl";
|
||||
case aclHSAIL:
|
||||
return "hsail-pc-unknown-amdopencl";
|
||||
case aclX64:
|
||||
#ifdef _WIN32
|
||||
return "x86_64-pc-mingw32-amdopencl";
|
||||
#else
|
||||
return "x86_64-pc-linux-amdopencl";
|
||||
#endif
|
||||
case aclHSAIL64:
|
||||
return "hsail64-pc-unknown-amdopencl";
|
||||
case aclAMDIL64:
|
||||
return "amdil64-pc-unknown-amdopencl";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// The contents of this array has to match the sequence defined in
|
||||
// aclDevType_0_8
|
||||
static const FamilyMapping familySet[] =
|
||||
{
|
||||
UnknownFamily,
|
||||
{ (const TargetMapping*)&X86TargetMapping_0_8, getArchitecture(aclX86), getTriple(aclX86), ARRAY_SIZEOF(X86TargetMapping_0_8) },
|
||||
{ (const TargetMapping*)&AMDILTargetMapping_0_8, getArchitecture(aclAMDIL), getTriple(aclAMDIL), ARRAY_SIZEOF(AMDILTargetMapping_0_8) },
|
||||
{ (const TargetMapping*)&HSAILTargetMapping_0_8, getArchitecture(aclHSAIL), getTriple(aclHSAIL), ARRAY_SIZEOF(HSAILTargetMapping_0_8) },
|
||||
{ (const TargetMapping*)&X64TargetMapping_0_8, getArchitecture(aclX64), getTriple(aclX64), ARRAY_SIZEOF(X64TargetMapping_0_8) },
|
||||
{ (const TargetMapping*)&HSAIL64TargetMapping_0_8, getArchitecture(aclHSAIL64), getTriple(aclHSAIL64), ARRAY_SIZEOF(HSAIL64TargetMapping_0_8) },
|
||||
{ (const TargetMapping*)&AMDIL64TargetMapping_0_8, getArchitecture(aclAMDIL64), getTriple(aclAMDIL64), ARRAY_SIZEOF(AMDIL64TargetMapping_0_8) },
|
||||
InvalidFamily
|
||||
};
|
||||
|
||||
#endif // _CL_UTILS_TARGET_MAPPINGS_0_8_H_
|
||||
@@ -1,109 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _CL_UTILS_TARGET_MAPPINGS_AMDIL_0_8_H_
|
||||
#define _CL_UTILS_TARGET_MAPPINGS_AMDIL_0_8_H_
|
||||
|
||||
#include "evergreen_id.h"
|
||||
#include "r700id.h"
|
||||
#include "tn_id.h"
|
||||
#include "sumo_id.h"
|
||||
#include "northernisland_id.h"
|
||||
#include "si_id.h"
|
||||
#include "kv_id.h"
|
||||
#include "ci_id.h"
|
||||
#include "vi_id.h"
|
||||
#include "cz_id.h"
|
||||
#include "ai_id.h"
|
||||
#include "atiid.h"
|
||||
|
||||
static const TargetMapping AMDILTargetMapping_0_8[] = {
|
||||
UnknownTarget,
|
||||
{ "R7XX", "RV770", "rv770", amd::GPU_Library_7xx, WEKIVA_A11, F_RV770, false, false, FAMILY_RV7XX },
|
||||
{ "R7XX", "RV770", "rv770", amd::GPU_Library_7xx, WEKIVA_A12, F_RV770, false, true , FAMILY_RV7XX },
|
||||
{ "R7XX", "RV790", "rv770", amd::GPU_Library_7xx, WEKIVA_A21, F_RV770, false, true , FAMILY_RV7XX },
|
||||
{ "R7XX", "RV730", "rv730", amd::GPU_Library_7xx, MARIO_A11, F_RV730, false, false, FAMILY_RV7XX },
|
||||
{ "R7XX", "RV730", "rv730", amd::GPU_Library_7xx, MARIO_A12, F_RV730, false, false, FAMILY_RV7XX },
|
||||
{ "R7XX", "RV730", "rv730", amd::GPU_Library_7xx, MARIO_A13, F_RV730, false, true , FAMILY_RV7XX },
|
||||
{ "R7XX", "RV710", "rv710", amd::GPU_Library_7xx, LUIGI_A11, F_RV710, false, false, FAMILY_RV7XX },
|
||||
{ "R7XX", "RV710", "rv710", amd::GPU_Library_7xx, LUIGI_A12, F_RV710, false, true , FAMILY_RV7XX },
|
||||
{ "R7XX", "RV710", "rv710", amd::GPU_Library_7xx, LUIGI_APU_A11, F_RV710, false, false, FAMILY_RV7XX },
|
||||
{ "R7XX", "RV740", "rv770", amd::GPU_Library_7xx, WALDEN_A11, F_RV770, false, false, FAMILY_RV7XX },
|
||||
{ "R7XX", "RV740", "rv770", amd::GPU_Library_7xx, WALDEN_A12, F_RV770, false, true , FAMILY_RV7XX },
|
||||
{ "Evergreen", "Cypress", "cypress", amd::GPU_Library_Evergreen, CYPRESS_A11, F_EG_EXT, false , false, FAMILY_EVERGREEN },
|
||||
{ "Evergreen", "Cypress", "cypress", amd::GPU_Library_Evergreen, CYPRESS_A12, F_EG_EXT, false , true , FAMILY_EVERGREEN },
|
||||
{ "Evergreen", "Juniper", "juniper", amd::GPU_Library_Evergreen, JUNIPER_A11, F_JUNIPER, false , false, FAMILY_EVERGREEN },
|
||||
{ "Evergreen", "Juniper", "juniper", amd::GPU_Library_Evergreen, JUNIPER_A12, F_JUNIPER, false , true , FAMILY_EVERGREEN },
|
||||
{ "Evergreen", "Redwood", "redwood", amd::GPU_Library_Evergreen, REDWOOD_A11, F_REDWOOD, false , false, FAMILY_EVERGREEN },
|
||||
{ "Evergreen", "Redwood", "redwood", amd::GPU_Library_Evergreen, REDWOOD_A12, F_REDWOOD, false , true , FAMILY_EVERGREEN },
|
||||
{ "Evergreen", "Cedar", "cedar", amd::GPU_Library_Evergreen, CEDAR_A11, F_CEDAR, false , false, FAMILY_EVERGREEN },
|
||||
{ "Evergreen", "Cedar", "cedar", amd::GPU_Library_Evergreen, CEDAR_A12, F_CEDAR, false , true , FAMILY_EVERGREEN },
|
||||
{ "NI", "Cayman", "cayman", amd::GPU_Library_Evergreen, NI_CAYMAN_P_A11, F_NI_EXT, false , true , FAMILY_NI },
|
||||
{ "NI", "Barts", "barts", amd::GPU_Library_Evergreen, NI_BARTS_PM_A11, F_NI_BASE, false , true , FAMILY_NI },
|
||||
{ "NI", "Turks", "turks", amd::GPU_Library_Evergreen, NI_TURKS_M_A11, F_NI_BASE, false , true , FAMILY_NI },
|
||||
{ "NI", "Lombok", "turks", amd::GPU_Library_Evergreen, NI_TURKS_LOMBOK_M_A11, F_NI_BASE, false , true , FAMILY_NI },
|
||||
{ "NI", "Caicos", "caicos", amd::GPU_Library_Evergreen, NI_CAICOS_V_A11, F_NI_BASE, false , true , FAMILY_NI },
|
||||
{ "NI", "Kauai", "kauai", amd::GPU_Library_Evergreen, KAUAI_A11, F_NI_BASE, false, false, FAMILY_NI },
|
||||
{ "Sumo", "BeaverCreek", "redwood", amd::GPU_Library_Evergreen, SUPERSUMO_A0, F_REDWOOD, false , false, FAMILY_SUMO },
|
||||
{ "Sumo", "BeaverCreek", "redwood", amd::GPU_Library_Evergreen, SUPERSUMO_B0, F_REDWOOD, false , true , FAMILY_SUMO },
|
||||
{ "Sumo", "WinterPark", "redwood", amd::GPU_Library_Evergreen, SUMO_A0, F_REDWOOD, false , false, FAMILY_SUMO },
|
||||
{ "Sumo", "WinterPark", "redwood", amd::GPU_Library_Evergreen, SUMO_B0, F_REDWOOD, false , true , FAMILY_SUMO },
|
||||
{ "Sumo", "Loveland", "cedar", amd::GPU_Library_Evergreen, WRESTLER_A0, F_REDWOOD, false , false, FAMILY_SUMO },
|
||||
{ "Sumo", "Loveland", "cedar", amd::GPU_Library_Evergreen, WRESTLER_A1, F_REDWOOD, false , false, FAMILY_SUMO },
|
||||
{ "Sumo", "Loveland", "cedar", amd::GPU_Library_Evergreen, WRESTLER_B0, F_REDWOOD, false , false, FAMILY_SUMO },
|
||||
{ "Sumo", "Loveland", "cedar", amd::GPU_Library_Evergreen, WRESTLER_C0, F_REDWOOD, false , true , FAMILY_SUMO },
|
||||
{ "Sumo", "Bheem", "cedar", amd::GPU_Library_Evergreen, BHEEM_A0, F_REDWOOD, false , true , FAMILY_SUMO },
|
||||
{ "SI", "Tahiti", "tahiti", amd::GPU_Library_SI, SI_TAHITI_P_A11, F_SI_BASE, true ,false, FAMILY_SI },
|
||||
{ "SI", "Tahiti", "tahiti", amd::GPU_Library_SI, SI_TAHITI_P_A0, F_SI_BASE, true ,false, FAMILY_SI },
|
||||
{ "SI", "Tahiti", "tahiti", amd::GPU_Library_SI, SI_TAHITI_P_A21, F_SI_BASE, true ,false, FAMILY_SI },
|
||||
{ "SI", "Tahiti", "tahiti", amd::GPU_Library_SI, SI_TAHITI_P_B0, F_SI_BASE, true ,false, FAMILY_SI },
|
||||
{ "SI", "Tahiti", "tahiti", amd::GPU_Library_SI, SI_TAHITI_P_A22, F_SI_BASE, true ,false, FAMILY_SI },
|
||||
{ "SI", "Tahiti", "tahiti", amd::GPU_Library_SI, SI_TAHITI_P_B1, F_SI_BASE, true , true, FAMILY_SI },
|
||||
{ "SI", "Pitcairn", "pitcairn", amd::GPU_Library_SI, SI_PITCAIRN_PM_A11, F_SI_BASE, true ,false, FAMILY_SI },
|
||||
{ "SI", "Pitcairn", "pitcairn", amd::GPU_Library_SI, SI_PITCAIRN_PM_A0, F_SI_BASE, true ,false, FAMILY_SI },
|
||||
{ "SI", "Pitcairn", "pitcairn", amd::GPU_Library_SI, SI_PITCAIRN_PM_A12, F_SI_BASE, true ,false, FAMILY_SI },
|
||||
{ "SI", "Pitcairn", "pitcairn", amd::GPU_Library_SI, SI_PITCAIRN_PM_A1, F_SI_BASE, true , true, FAMILY_SI },
|
||||
{ "SI", "Capeverde", "capeverde", amd::GPU_Library_SI, SI_CAPEVERDE_M_A11, F_SI_BASE, true ,false, FAMILY_SI },
|
||||
{ "SI", "Capeverde", "capeverde", amd::GPU_Library_SI, SI_CAPEVERDE_M_A0, F_SI_BASE, true ,false, FAMILY_SI },
|
||||
{ "SI", "Capeverde", "capeverde", amd::GPU_Library_SI, SI_CAPEVERDE_M_A12, F_SI_BASE, true ,false, FAMILY_SI },
|
||||
{ "SI", "Capeverde", "capeverde", amd::GPU_Library_SI, SI_CAPEVERDE_M_A1, F_SI_BASE, true , true, FAMILY_SI },
|
||||
{ "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_M_A0, F_NI_EXT, false, false, FAMILY_TN },
|
||||
{ "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_M_A1, F_NI_EXT, false, true, FAMILY_TN },
|
||||
{ "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_LITE_MV_A0, F_NI_EXT, false, false, FAMILY_TN },
|
||||
{ "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_LITE_MV_A1, F_NI_EXT, false, false, FAMILY_TN },
|
||||
{ "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_V_A0, F_NI_EXT, false, false, FAMILY_TN },
|
||||
{ "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_V_A1, F_NI_EXT, false, false, FAMILY_TN },
|
||||
{ "TN", "Scrapper", "trinity", amd::GPU_Library_Evergreen, TN_SCRAPPER_V_A0, F_NI_EXT, false, false, FAMILY_TN },
|
||||
{ "TN", "Scrapper", "trinity", amd::GPU_Library_Evergreen, TN_SCRAPPER_V_A1, F_NI_EXT, false, true, FAMILY_TN },
|
||||
{ "TN", "Scrapper", "trinity", amd::GPU_Library_Evergreen, TN_DVST_DUO_V_A0, F_NI_EXT, false, false, FAMILY_TN },
|
||||
{ "KV", "Spectre", "spectre", amd::GPU_Library_CI, KV_SPECTRE_A0, F_SI_BASE, false, true, FAMILY_KV },
|
||||
{ "KV", "Spooky", "spooky", amd::GPU_Library_CI, KV_SPOOKY_A0, F_SI_BASE, false, true, FAMILY_KV },
|
||||
{ "KV", "Kalindi", "kalindi", amd::GPU_Library_CI, KB_KALINDI_A0, F_SI_BASE, false, true, FAMILY_KV },
|
||||
{ "CI", "Hawaii", "hawaii", amd::GPU_Library_CI, CI_HAWAII_P_A0, F_SI_BASE, false, true, FAMILY_CI },
|
||||
{ "KV", "Mullins", "mullins", amd::GPU_Library_CI, ML_GODAVARI_A0, F_SI_BASE, false, true, FAMILY_KV },
|
||||
{ "SI", "Oland", "oland", amd::GPU_Library_SI, SI_OLAND_M_A0, F_SI_BASE, true, true, FAMILY_SI },
|
||||
{ "CI", "Bonaire", "bonaire", amd::GPU_Library_CI, CI_BONAIRE_M_A0, F_SI_BASE, false, false, FAMILY_CI },
|
||||
{ "SI", "Hainan", "hainan", amd::GPU_Library_SI, SI_HAINAN_V_A0, F_SI_BASE, true, true, FAMILY_SI },
|
||||
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
{ "CZ", "Carrizo", "carrizo", amd::GPU_Library_CI, CARRIZO_A0, F_SI_BASE, false, true, FAMILY_CZ },
|
||||
{ "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_W_A0, F_NI_EXT, false, false, FAMILY_TN },
|
||||
{ "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_W_A1, F_NI_EXT, false, false, FAMILY_TN },
|
||||
{ "TN", "Scrapper", "trinity", amd::GPU_Library_Evergreen, TN_SCRAPPER_LV_A0, F_NI_EXT, false, false, FAMILY_TN },
|
||||
{ "TN", "Scrapper", "trinity", amd::GPU_Library_Evergreen, TN_SCRAPPER_LV_A1, F_NI_EXT, false, false, FAMILY_TN },
|
||||
|
||||
{ "VI", "Iceland", "iceland", amd::GPU_Library_CI, VI_ICELAND_M_A0, F_SI_BASE, false, true, FAMILY_VI },
|
||||
{ "VI", "Tonga", "tonga", amd::GPU_Library_CI, VI_TONGA_P_A0, F_SI_BASE, false, true, FAMILY_VI },
|
||||
{ "CI", "Bonaire", "bonaire", amd::GPU_Library_CI, CI_BONAIRE_M_A1, F_SI_BASE, false, true, FAMILY_CI },
|
||||
{ "VI", "Fiji", "fiji", amd::GPU_Library_CI, VI_FIJI_P_A0, F_SI_BASE, false, true, FAMILY_VI },
|
||||
{ "CZ", "Stoney", "stoney", amd::GPU_Library_CI, STONEY_A0, F_SI_BASE, false, true, FAMILY_CZ },
|
||||
{ "VI", "Baffin", "baffin", amd::GPU_Library_CI, VI_BAFFIN_M_A0, F_SI_BASE, false, false, FAMILY_VI },
|
||||
{ "VI", "Baffin", "baffin", amd::GPU_Library_CI, VI_BAFFIN_M_A1, F_SI_BASE, false, true, FAMILY_VI },
|
||||
{ "VI", "Ellesmere", "ellesmere", amd::GPU_Library_CI, VI_ELLESMERE_P_A0, F_SI_BASE, false, false, FAMILY_VI },
|
||||
{ "VI", "Ellesmere", "ellesmere", amd::GPU_Library_CI, VI_ELLESMERE_P_A1, F_SI_BASE, false, true, FAMILY_VI },
|
||||
{ "VI", "gfx804", "gfx804", amd::GPU_Library_CI, VI_LEXA_V_A0, F_SI_BASE, false, true, FAMILY_VI },
|
||||
InvalidTarget
|
||||
};
|
||||
|
||||
#endif // _CL_UTILS_TARGET_MAPPINGS_AMDIL_0_8_H_
|
||||
@@ -1,55 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _CL_UTILS_TARGET_MAPPINGS_AMDIL64_0_8_H_
|
||||
#define _CL_UTILS_TARGET_MAPPINGS_AMDIL64_0_8_H_
|
||||
|
||||
#include "si_id.h"
|
||||
#include "kv_id.h"
|
||||
#include "ci_id.h"
|
||||
#include "vi_id.h"
|
||||
#include "cz_id.h"
|
||||
#include "atiid.h"
|
||||
|
||||
static const TargetMapping AMDIL64TargetMapping_0_8[] = {
|
||||
UnknownTarget,
|
||||
{ "SI", "Tahiti", "tahiti", amd::GPU64_Library_SI, SI_TAHITI_P_A11, F_SI_64BIT_PTR, true, false, FAMILY_SI },
|
||||
{ "SI", "Tahiti", "tahiti", amd::GPU64_Library_SI, SI_TAHITI_P_A0, F_SI_64BIT_PTR, true, false, FAMILY_SI },
|
||||
{ "SI", "Tahiti", "tahiti", amd::GPU64_Library_SI, SI_TAHITI_P_A21, F_SI_64BIT_PTR, true, false, FAMILY_SI },
|
||||
{ "SI", "Tahiti", "tahiti", amd::GPU64_Library_SI, SI_TAHITI_P_B0, F_SI_64BIT_PTR, true, false, FAMILY_SI },
|
||||
{ "SI", "Tahiti", "tahiti", amd::GPU64_Library_SI, SI_TAHITI_P_A22, F_SI_64BIT_PTR, true, false, FAMILY_SI },
|
||||
{ "SI", "Tahiti", "tahiti", amd::GPU64_Library_SI, SI_TAHITI_P_B1, F_SI_64BIT_PTR, true, true, FAMILY_SI },
|
||||
{ "SI", "Pitcairn", "pitcairn", amd::GPU64_Library_SI, SI_PITCAIRN_PM_A11, F_SI_64BIT_PTR, true, false, FAMILY_SI },
|
||||
{ "SI", "Pitcairn", "pitcairn", amd::GPU64_Library_SI, SI_PITCAIRN_PM_A0, F_SI_64BIT_PTR, true, false, FAMILY_SI },
|
||||
{ "SI", "Pitcairn", "pitcairn", amd::GPU64_Library_SI, SI_PITCAIRN_PM_A12, F_SI_64BIT_PTR, true, false, FAMILY_SI },
|
||||
{ "SI", "Pitcairn", "pitcairn", amd::GPU64_Library_SI, SI_PITCAIRN_PM_A1, F_SI_64BIT_PTR, true, true, FAMILY_SI },
|
||||
{ "SI", "Capeverde", "capeverde", amd::GPU64_Library_SI, SI_CAPEVERDE_M_A11, F_SI_64BIT_PTR, true, false, FAMILY_SI },
|
||||
{ "SI", "Capeverde", "capeverde", amd::GPU64_Library_SI, SI_CAPEVERDE_M_A0, F_SI_64BIT_PTR, true, false, FAMILY_SI },
|
||||
{ "SI", "Capeverde", "capeverde", amd::GPU64_Library_SI, SI_CAPEVERDE_M_A12, F_SI_64BIT_PTR, true, false, FAMILY_SI },
|
||||
{ "SI", "Capeverde", "capeverde", amd::GPU64_Library_SI, SI_CAPEVERDE_M_A1, F_SI_64BIT_PTR, true, true, FAMILY_SI },
|
||||
{ "KV", "Spectre", "spectre", amd::GPU64_Library_CI, KV_SPECTRE_A0, F_SI_64BIT_PTR, false, true, FAMILY_KV },
|
||||
{ "KV", "Spooky", "spooky", amd::GPU64_Library_CI, KV_SPOOKY_A0, F_SI_64BIT_PTR, false, true, FAMILY_KV },
|
||||
{ "KV", "Kalindi", "kalindi", amd::GPU64_Library_CI, KB_KALINDI_A0, F_SI_64BIT_PTR, false, true, FAMILY_KV },
|
||||
{ "CI", "Hawaii", "hawaii", amd::GPU64_Library_CI, CI_HAWAII_P_A0, F_SI_64BIT_PTR, false, true, FAMILY_CI },
|
||||
{ "KV", "Mullins", "mullins", amd::GPU64_Library_CI, ML_GODAVARI_A0, F_SI_64BIT_PTR, false, true, FAMILY_KV },
|
||||
{ "SI", "Oland", "oland", amd::GPU64_Library_SI, SI_OLAND_M_A0, F_SI_64BIT_PTR, true, true, FAMILY_SI },
|
||||
{ "CI", "Bonaire", "bonaire", amd::GPU64_Library_CI, CI_BONAIRE_M_A0, F_SI_64BIT_PTR, false, false, FAMILY_CI },
|
||||
{ "SI", "Hainan", "hainan", amd::GPU64_Library_SI, SI_HAINAN_V_A0, F_SI_64BIT_PTR, true, true, FAMILY_SI },
|
||||
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
{ "CZ", "Carrizo", "carrizo", amd::GPU64_Library_CI, CARRIZO_A0, F_SI_64BIT_PTR, false, true, FAMILY_CZ },
|
||||
{ "VI", "Iceland", "iceland", amd::GPU64_Library_CI, VI_ICELAND_M_A0, F_SI_64BIT_PTR, false, true, FAMILY_VI },
|
||||
{ "VI", "Tonga", "tonga", amd::GPU64_Library_CI, VI_TONGA_P_A0, F_SI_64BIT_PTR, false, true, FAMILY_VI },
|
||||
{ "CI", "Bonaire", "bonaire", amd::GPU64_Library_CI, CI_BONAIRE_M_A0, F_SI_64BIT_PTR, false, true, FAMILY_CI },
|
||||
{ "VI", "Fiji", "fiji", amd::GPU64_Library_CI, VI_FIJI_P_A0, F_SI_64BIT_PTR, false, true, FAMILY_VI },
|
||||
{ "CZ", "Stoney", "stoney", amd::GPU64_Library_CI, STONEY_A0, F_SI_64BIT_PTR, false, true, FAMILY_CZ },
|
||||
{ "VI", "Baffin", "baffin", amd::GPU64_Library_CI, VI_BAFFIN_M_A0, F_SI_64BIT_PTR, false, false, FAMILY_VI },
|
||||
{ "VI", "Baffin", "baffin", amd::GPU64_Library_CI, VI_BAFFIN_M_A1, F_SI_64BIT_PTR, false, true, FAMILY_VI },
|
||||
{ "VI", "Ellesmere", "ellesmere", amd::GPU64_Library_CI, VI_ELLESMERE_P_A0, F_SI_64BIT_PTR, false, false, FAMILY_VI },
|
||||
{ "VI", "Ellesmere", "ellesmere", amd::GPU64_Library_CI, VI_ELLESMERE_P_A1, F_SI_64BIT_PTR, false, true, FAMILY_VI },
|
||||
{ "VI", "gfx804", "gfx804", amd::GPU64_Library_CI, VI_LEXA_V_A0, F_SI_64BIT_PTR, false, true, FAMILY_VI },
|
||||
InvalidTarget
|
||||
};
|
||||
|
||||
#endif // _CL_UTILS_TARGET_MAPPINGS_AMDIL64_0_8_H_
|
||||
@@ -1,82 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _CL_UTILS_TARGET_MAPPINGS_HSAIL_0_8_H_
|
||||
#define _CL_UTILS_TARGET_MAPPINGS_HSAIL_0_8_H_
|
||||
|
||||
#include "si_id.h"
|
||||
#include "kv_id.h"
|
||||
#include "ci_id.h"
|
||||
#include "cz_id.h"
|
||||
#include "ai_id.h"
|
||||
#include "rv_id.h"
|
||||
#include "nv_id.h"
|
||||
#include "atiid.h"
|
||||
|
||||
static const TargetMapping HSAILTargetMapping_0_8[] = {
|
||||
UnknownTarget,
|
||||
{ "KV", "Spectre", "GFX7", amd::GPU_Library_HSAIL, KV_SPECTRE_A0, F_CI_BASE, true, true, FAMILY_KV, false },
|
||||
{ "KV", "Spooky", "GFX7", amd::GPU_Library_HSAIL, KV_SPOOKY_A0, F_CI_BASE, true, true, FAMILY_KV, false },
|
||||
{ "KV", "Kalindi", "GFX7", amd::GPU_Library_HSAIL, KB_KALINDI_A0, F_CI_BASE, true, true, FAMILY_KV, false },
|
||||
{ "KV", "Mullins", "GFX7", amd::GPU_Library_HSAIL, ML_GODAVARI_A0, F_CI_BASE, true, true, FAMILY_KV, false },
|
||||
{ "CI", "Bonaire", "GFX7", amd::GPU_Library_HSAIL, CI_BONAIRE_M_A0, F_CI_BASE, true, false, FAMILY_CI, false },
|
||||
{ "CI", "Bonaire", "GFX7", amd::GPU_Library_HSAIL, CI_BONAIRE_M_A1, F_CI_BASE, true, true, FAMILY_CI, false },
|
||||
{ "CI", "Hawaii", "GFX7", amd::GPU_Library_HSAIL, CI_HAWAII_P_A0, F_CI_BASE, true, true, FAMILY_CI, false },
|
||||
{ "VI", "Iceland", "GFX8", amd::GPU_Library_HSAIL, VI_ICELAND_M_A0, F_VI_BASE, true, true, FAMILY_VI, false },
|
||||
{ "VI", "Tonga", "GFX8", amd::GPU_Library_HSAIL, VI_TONGA_P_A0, F_VI_BASE, true, true, FAMILY_VI, false },
|
||||
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
{ "CZ", "Carrizo", "GFX8", amd::GPU_Library_HSAIL, CARRIZO_A0, F_VI_BASE, true, true, FAMILY_CZ, false },
|
||||
{ "VI", "Fiji", "GFX8", amd::GPU_Library_HSAIL, VI_FIJI_P_A0, F_VI_BASE, true, true, FAMILY_VI, false },
|
||||
{ "CZ", "Stoney", "GFX8", amd::GPU_Library_HSAIL, STONEY_A0, F_VI_BASE, true, true, FAMILY_CZ, false },
|
||||
{ "VI", "Baffin", "GFX8", amd::GPU_Library_HSAIL, VI_BAFFIN_M_A0, F_VI_BASE, true, false, FAMILY_VI, false },
|
||||
{ "VI", "Baffin", "GFX8", amd::GPU_Library_HSAIL, VI_BAFFIN_M_A1, F_VI_BASE, true, true, FAMILY_VI, false },
|
||||
{ "VI", "Ellesmere", "GFX8", amd::GPU_Library_HSAIL, VI_ELLESMERE_P_A0, F_VI_BASE, true, false, FAMILY_VI, false },
|
||||
{ "VI", "Ellesmere", "GFX8", amd::GPU_Library_HSAIL, VI_ELLESMERE_P_A1, F_VI_BASE, true, true, FAMILY_VI, false },
|
||||
#ifndef BRAHMA
|
||||
{ "AI", "gfx900", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A0, F_AI_BASE, true, false, FAMILY_AI },
|
||||
{ "AI", "gfx900", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A1, F_AI_BASE, true, true, FAMILY_AI },
|
||||
#else
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
#endif
|
||||
{ "VI", "gfx804", "GFX8", amd::GPU_Library_HSAIL, VI_LEXA_V_A0, F_VI_BASE, true, true, FAMILY_VI },
|
||||
#ifndef BRAHMA
|
||||
{ "AI", "gfx901", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A0, F_AI_BASE, true, false, FAMILY_AI ,true },
|
||||
{ "AI", "gfx901", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A1, F_AI_BASE, true, true, FAMILY_AI ,true },
|
||||
{ "RV", "gfx902", "GFX9", amd::GPU_Library_HSAIL, RAVEN_A0, F_AI_BASE, true, true, FAMILY_RV, false },
|
||||
{ "RV", "gfx902", "GFX9", amd::GPU_Library_HSAIL, RENOIR_A0, F_AI_BASE, true, true, FAMILY_RV, false },
|
||||
{ "RV", "gfx903", "GFX9", amd::GPU_Library_HSAIL, RAVEN_A0, F_AI_BASE, true, true, FAMILY_RV, true },
|
||||
{ "RV", "gfx903", "GFX9", amd::GPU_Library_HSAIL, RENOIR_A0, F_AI_BASE, true, true, FAMILY_RV, true },
|
||||
{ "AI", "gfx904", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA12_P_A0, F_AI_BASE, true, true, FAMILY_AI, false },
|
||||
{ "AI", "gfx905", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA12_P_A0, F_AI_BASE, true, true, FAMILY_AI, true },
|
||||
{ "AI", "gfx906", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA20_P_A0, F_AI_BASE, true, true, FAMILY_AI, false },
|
||||
{ "AI", "gfx907", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA20_P_A0, F_AI_BASE, true, true, FAMILY_AI, true },
|
||||
{ "AI", "gfx908", "GFX9", amd::GPU_Library_HSAIL, AI_MI100_P_A0, F_AI_BASE, true, true, FAMILY_AI, true },
|
||||
{ "NV", "gfx1000", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI10_LITE_P_A0, F_AI_BASE, true, true, FAMILY_NV, false },
|
||||
{ "NV", "gfx1010", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI10_P_A0, F_AI_BASE, true, true, FAMILY_NV, false },
|
||||
{ "NV", "gfx1011", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI12_P_A0, F_AI_BASE, true, true, FAMILY_NV, false },
|
||||
{ "NV", "gfx1012", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI14_M_A0, F_AI_BASE, true, true, FAMILY_NV, false },
|
||||
|
||||
#else
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
#endif
|
||||
InvalidTarget
|
||||
};
|
||||
|
||||
#endif // _CL_UTILS_TARGET_MAPPINGS_HSAIL_0_8_H_
|
||||
@@ -1,80 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _CL_UTILS_TARGET_MAPPINGS_HSAIL64_0_8_H_
|
||||
#define _CL_UTILS_TARGET_MAPPINGS_HSAIL64_0_8_H_
|
||||
|
||||
#include "si_id.h"
|
||||
#include "kv_id.h"
|
||||
#include "ci_id.h"
|
||||
#include "ai_id.h"
|
||||
#include "rv_id.h"
|
||||
#include "nv_id.h"
|
||||
#include "atiid.h"
|
||||
|
||||
static const TargetMapping HSAIL64TargetMapping_0_8[] = {
|
||||
UnknownTarget,
|
||||
{ "KV", "Spectre", "GFX7", amd::GPU_Library_HSAIL, KV_SPECTRE_A0, F_CI_BASE, true, true, FAMILY_KV, false },
|
||||
{ "KV", "Spooky", "GFX7", amd::GPU_Library_HSAIL, KV_SPOOKY_A0, F_CI_BASE, true, true, FAMILY_KV, false },
|
||||
{ "KV", "Kalindi", "GFX7", amd::GPU_Library_HSAIL, KB_KALINDI_A0, F_CI_BASE, true, true, FAMILY_KV, false },
|
||||
{ "KV", "Mullins", "GFX7", amd::GPU_Library_HSAIL, ML_GODAVARI_A0, F_CI_BASE, true, true, FAMILY_KV, false },
|
||||
{ "CI", "Bonaire", "GFX7", amd::GPU_Library_HSAIL, CI_BONAIRE_M_A0, F_CI_BASE, true, false, FAMILY_CI, false },
|
||||
{ "CI", "Bonaire", "GFX7", amd::GPU_Library_HSAIL, CI_BONAIRE_M_A1, F_CI_BASE, true, true, FAMILY_CI, false },
|
||||
{ "CI", "Hawaii", "GFX7", amd::GPU_Library_HSAIL, CI_HAWAII_P_A0, F_CI_BASE, true, true, FAMILY_CI, false },
|
||||
{ "VI", "Iceland", "GFX8", amd::GPU_Library_HSAIL, VI_ICELAND_M_A0, F_VI_BASE, true, true, FAMILY_VI, false },
|
||||
{ "VI", "Tonga", "GFX8", amd::GPU_Library_HSAIL, VI_TONGA_P_A0, F_VI_BASE, true, true, FAMILY_VI, false },
|
||||
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
{ "CZ", "Carrizo", "GFX8", amd::GPU_Library_HSAIL, CARRIZO_A0, F_VI_BASE, true, true, FAMILY_CZ, false },
|
||||
{ "VI", "Fiji", "GFX8", amd::GPU_Library_HSAIL, VI_FIJI_P_A0, F_VI_BASE, true, true, FAMILY_VI, false },
|
||||
{ "CZ", "Stoney", "GFX8", amd::GPU_Library_HSAIL, STONEY_A0, F_VI_BASE, true, true, FAMILY_CZ, false },
|
||||
{ "VI", "Baffin", "GFX8", amd::GPU_Library_HSAIL, VI_BAFFIN_M_A0, F_VI_BASE, true, false, FAMILY_VI, false },
|
||||
{ "VI", "Baffin", "GFX8", amd::GPU_Library_HSAIL, VI_BAFFIN_M_A1, F_VI_BASE, true, true, FAMILY_VI, false },
|
||||
{ "VI", "Ellesmere", "GFX8", amd::GPU_Library_HSAIL, VI_ELLESMERE_P_A0, F_VI_BASE, true, false, FAMILY_VI, false },
|
||||
{ "VI", "Ellesmere", "GFX8", amd::GPU_Library_HSAIL, VI_ELLESMERE_P_A1, F_VI_BASE, true, true, FAMILY_VI, false },
|
||||
#ifndef BRAHMA
|
||||
{ "AI", "gfx900", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A0, F_AI_BASE, true, false, FAMILY_AI, false },
|
||||
{ "AI", "gfx900", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A1, F_AI_BASE, true, true, FAMILY_AI, false },
|
||||
#else
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
#endif
|
||||
{ "VI", "gfx804", "GFX8", amd::GPU_Library_HSAIL, VI_LEXA_V_A0, F_VI_BASE, true, true, FAMILY_VI, false },
|
||||
#ifndef BRAHMA
|
||||
{ "AI", "gfx901", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A0, F_AI_BASE, true, false, FAMILY_AI, true },
|
||||
{ "AI", "gfx901", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A1, F_AI_BASE, true, true, FAMILY_AI, true },
|
||||
{ "RV", "gfx902", "GFX9", amd::GPU_Library_HSAIL, RAVEN_A0, F_AI_BASE, true, true, FAMILY_RV, false },
|
||||
{ "RV", "gfx902", "GFX9", amd::GPU_Library_HSAIL, RENOIR_A0, F_AI_BASE, true, true, FAMILY_RV, false },
|
||||
{ "RV", "gfx903", "GFX9", amd::GPU_Library_HSAIL, RAVEN_A0, F_AI_BASE, true, true, FAMILY_RV, true },
|
||||
{ "RV", "gfx903", "GFX9", amd::GPU_Library_HSAIL, RENOIR_A0, F_AI_BASE, true, true, FAMILY_RV, true },
|
||||
{ "AI", "gfx904", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA12_P_A0, F_AI_BASE, true, true, FAMILY_AI, false },
|
||||
{ "AI", "gfx905", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA12_P_A0, F_AI_BASE, true, true, FAMILY_AI, true },
|
||||
{ "AI", "gfx906", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA20_P_A0, F_AI_BASE, true, true, FAMILY_AI, false },
|
||||
{ "AI", "gfx907", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA20_P_A0, F_AI_BASE, true, true, FAMILY_AI, true },
|
||||
{ "AI", "gfx908", "GFX9", amd::GPU_Library_HSAIL, AI_MI100_P_A0, F_AI_BASE, true, true, FAMILY_AI, true },
|
||||
{ "NV", "gfx1000", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI10_LITE_P_A0, F_AI_BASE, true, true, FAMILY_NV, false },
|
||||
{ "NV", "gfx1010", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI10_P_A0, F_AI_BASE, true, true, FAMILY_NV, false },
|
||||
{ "NV", "gfx1011", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI12_P_A0, F_AI_BASE, true, true, FAMILY_NV, false },
|
||||
{ "NV", "gfx1012", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI14_M_A0, F_AI_BASE, true, true, FAMILY_NV, false },
|
||||
#else
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
UnknownTarget,
|
||||
#endif
|
||||
InvalidTarget
|
||||
};
|
||||
|
||||
#endif // _CL_UTILS_TARGET_MAPPINGS_HSAIL64_0_8_H_
|
||||
@@ -1,46 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _CL_UTILS_TARGET_MAPPINGS_X64_0_8_H_
|
||||
#define _CL_UTILS_TARGET_MAPPINGS_X64_0_8_H_
|
||||
|
||||
#define CPU_MAPPING_LIB(A, B, C, D, E) { #A, #B, #C, D, 0, E, LP64_SWITCH(false, true), LP64_SWITCH(false, true), FAMILY_X64}
|
||||
#define CPU_MAPPING(A, B, C, D) CPU_MAPPING_LIB(A, B, C, amd::CPU64_Library_Generic, D)
|
||||
#define NCPU_MAPPING_LIB(A, B, C, D, E) { #A, #B, #C, D, 0, E, false, false, FAMILY_X64}
|
||||
#define NCPU_MAPPING(A, B, C, D) { #A, #B, #C, amd::CPU64_Library_Generic, 0, D, false, false, FAMILY_X64}
|
||||
static const TargetMapping X64TargetMapping_0_8[] = {
|
||||
UnknownTarget,
|
||||
CPU_MAPPING(X64, Generic, generic, 0x1),
|
||||
CPU_MAPPING(NetBurst, Prescott, prescott, 0x1),
|
||||
CPU_MAPPING(Xeon, Nocona, nocona, 0x1),
|
||||
CPU_MAPPING(Core, Core2, core2, 0x1),
|
||||
CPU_MAPPING(Core, Penryn, penryn, 0x1),
|
||||
CPU_MAPPING(Nehalem, Corei7, corei7, 0x1),
|
||||
CPU_MAPPING(Nehalem, Nehalem, nehalem, 0x1),
|
||||
CPU_MAPPING(Nehalem, Westmere, westmere, 0x1),
|
||||
NCPU_MAPPING_LIB(SandyBridge, Corei7_AVX, sandybridge, amd::CPU64_Library_AVX, 0x2 | 0x1), // LLVM 2.9 only
|
||||
CPU_MAPPING_LIB(SandyBridge, Corei7_AVX, corei7-avx, amd::CPU64_Library_AVX, 0x2 | 0x1),
|
||||
CPU_MAPPING(SandyBridge, IvyBridge, core-avx-i, 0x2 | 0x1), // LLVM 3.0
|
||||
CPU_MAPPING(Haswell, Haswell, core-avx2, 0x4 | 0x2 | 0x1), // LLVM 3.0
|
||||
CPU_MAPPING(K8, K8, k8, 0x1),
|
||||
CPU_MAPPING(K8, Opteron, opteron, 0x1),
|
||||
CPU_MAPPING(K8, Athlon64, athlon64, 0x1),
|
||||
CPU_MAPPING(K8, AthlonFX, athlon-fx, 0x1),
|
||||
CPU_MAPPING(K8, K8_SSE3, k8-sse3, 0x1),
|
||||
CPU_MAPPING(K8, Opteron_SSE3,opteron-sse3, 0x1),
|
||||
CPU_MAPPING(K8, Athlon64SSE3,athlon64-sse3, 0x1),
|
||||
CPU_MAPPING(K10, AMDFAM10, amdfam10, 0x1),
|
||||
NCPU_MAPPING(K10, Barcelona, barcelona, 0x1),
|
||||
NCPU_MAPPING(K10, Istanbul, istanbul, 0x1),
|
||||
NCPU_MAPPING(K10, Shanghai, shanghai, 0x1),
|
||||
CPU_MAPPING(Family14h, Bobcat, btver1, 0x1),
|
||||
CPU_MAPPING_LIB(Family15h, Bulldozer, bdver1, amd::CPU64_Library_FMA4, 0x8 | 0x1),
|
||||
CPU_MAPPING_LIB(Family15h, Piledriver, bdver2, amd::CPU64_Library_FMA4, 0x8 | 0x4 | 0x1),
|
||||
CPU_MAPPING(Atom, Atom, atom, 0x1),
|
||||
InvalidTarget
|
||||
};
|
||||
#undef CPU_MAPPING
|
||||
#undef NCPU_MAPPING
|
||||
#undef CPU_MAPPING_LIB
|
||||
#undef NCPU_MAPPING_LIB
|
||||
#endif // _CL_UTILS_TARGET_MAPPINGS_X64_0_8_H_
|
||||
@@ -1,73 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
#ifndef _CL_UTILS_TARGET_MAPPINGS_X86_0_8_H_
|
||||
#define _CL_UTILS_TARGET_MAPPINGS_X86_0_8_H_
|
||||
#define CPU_MAPPING_LIB(A, B, C, D, E) { #A, #B, #C, D, 0, E, true, true, FAMILY_X86}
|
||||
#define CPU_MAPPING(A, B, C, D) CPU_MAPPING_LIB(A, B, C, amd::CPU_Library_Generic, D)
|
||||
#define NCPU_MAPPING_LIB(A, B, C, D, E) { #A, #B, #C, D, 0, E, false, false, FAMILY_X86}
|
||||
#define NCPU_MAPPING(A, B, C, D) { #A, #B, #C, amd::CPU_Library_Generic, 0, D, false, false, FAMILY_X86}
|
||||
static const TargetMapping X86TargetMapping_0_8[] = {
|
||||
UnknownTarget,
|
||||
CPU_MAPPING(X86, Generic, generic, 0),
|
||||
// This has to be specified manually since GCC defines i386 as a macro.
|
||||
{ "X86", "i386", "i386", amd::CPU_Library_Generic, 0, 0, true, true, FAMILY_X86 },
|
||||
CPU_MAPPING(X86, i486, i486, 0),
|
||||
CPU_MAPPING(X86, i586, i586, 0),
|
||||
CPU_MAPPING(Pentium, Pentium, pentium, 0),
|
||||
CPU_MAPPING(Pentium_MMX, Pentium_MMX, pentium-mmx, 0),
|
||||
CPU_MAPPING(X86, i686, i686, 0),
|
||||
CPU_MAPPING(PentiumPro, PentiumPro, pentiumpro, 0),
|
||||
CPU_MAPPING(Pentium2, Pentium2, pentium2, 0),
|
||||
CPU_MAPPING(Pentium3, Pentium3, pentium3, 0),
|
||||
CPU_MAPPING(Pentium3m, Pentium3m, pentium3m, 0),
|
||||
CPU_MAPPING(Pentium_M, Pentium_M, pentium-m, 0x1),
|
||||
CPU_MAPPING(NetBurst, Pentium4, pentium4, 0x1),
|
||||
CPU_MAPPING(NetBurst, Pentium4m, pentium4m, 0x1),
|
||||
CPU_MAPPING(Pentium_M, Yonah, yonah, 0x1),
|
||||
CPU_MAPPING(Pentium4, Prescott, prescott, 0x1),
|
||||
CPU_MAPPING(Xeon, Nocona, nocona, 0x1),
|
||||
CPU_MAPPING(Core, Core2, core2, 0x1),
|
||||
CPU_MAPPING(Core, Penryn, penryn, 0x1),
|
||||
CPU_MAPPING(Nehalem, Corei7, corei7, 0x1), // Corei3 and Corei5 also
|
||||
CPU_MAPPING(Nehalem, Nehalem, nehalem, 0x1),
|
||||
CPU_MAPPING(Nehalem, Westmere, westmere, 0x1),
|
||||
NCPU_MAPPING_LIB(SandyBridge, Corei7_AVX, sandybridge, amd::CPU64_Library_AVX, 0x2 | 0x1), // LLVM 2.9 only
|
||||
CPU_MAPPING(SandyBridge, Corei7_AVX, corei7-avx, 0x2 | 0x1), // LLVM 3.0 only
|
||||
CPU_MAPPING(SandyBridge, IvyBridge, core-avx-i, 0x2 | 0x1), // LLVM 3.0 only
|
||||
CPU_MAPPING(Haswell, Haswell, core-avx2, 0x4 | 0x2 | 0x1), // LLVM 3.0 only
|
||||
CPU_MAPPING(K6, K6, k6, 0),
|
||||
CPU_MAPPING(K6, K6_2, k6-2, 0),
|
||||
CPU_MAPPING(K6, K6_3, k6-3, 0),
|
||||
CPU_MAPPING(K7, Athlon, athlon, 0),
|
||||
CPU_MAPPING(K7, AthlonTBIRD, athlon-tbird, 0),
|
||||
CPU_MAPPING(K7, Athlon4, athlon-4, 0),
|
||||
CPU_MAPPING(K7, AthlonXP, athlon-xp, 0),
|
||||
CPU_MAPPING(K7, AthlonMP, athlon-mp, 0),
|
||||
CPU_MAPPING(K8, K8, k8, 0x1),
|
||||
CPU_MAPPING(K8, Opteron, opteron, 0x1),
|
||||
CPU_MAPPING(K8, Athlon64, athlon64, 0x1),
|
||||
CPU_MAPPING(K8, AthlonFX, athlon-fx, 0x1),
|
||||
CPU_MAPPING(K8, K8_SSE3, k8-sse3, 0x1),
|
||||
CPU_MAPPING(K8, Opteron_SSE3,opteron-sse3, 0x1),
|
||||
CPU_MAPPING(K8, Athlon64SSE3,athlon64-sse3, 0x1),
|
||||
CPU_MAPPING(K10, AMDFAM10, amdfam10, 0x1),
|
||||
NCPU_MAPPING(K10, Barcelona, barcelona, 0x1),
|
||||
NCPU_MAPPING(K10, Istanbul, istanbul, 0x1),
|
||||
NCPU_MAPPING(K10, Shanghai, shanghai, 0x1),
|
||||
CPU_MAPPING(Winchip, Winchip_C6, winchip-c6, 0),
|
||||
CPU_MAPPING(Winchip, Winchip2, winchip2, 0),
|
||||
CPU_MAPPING(Via, C3, c3, 0),
|
||||
CPU_MAPPING(Via, C3_2, c3-2, 0),
|
||||
CPU_MAPPING(Family14h, Bobcat, btver1, 0x1), // LLVM 3.1 only
|
||||
CPU_MAPPING_LIB(Family15h, Bulldozer, bdver1, amd::CPU_Library_FMA4, 0x8 | 0x1), // LLVM 3.1 only
|
||||
CPU_MAPPING_LIB(Family15h, Piledriver, bdver2, amd::CPU_Library_FMA4, 0x8 | 0x4 | 0x1), // LLVM 3.1 only
|
||||
CPU_MAPPING(Atom, Atom, atom, 0x1), // LLVM 3.1 only
|
||||
InvalidTarget
|
||||
};
|
||||
#undef CPU_MAPPING
|
||||
#undef NCPU_MAPPING
|
||||
#undef CPU_MAPPING_LIB
|
||||
#undef NCPU_MAPPING_LIB
|
||||
|
||||
#endif // _CL_UTILS_TARGET_MAPPINGS_X86_0_8_H_
|
||||
@@ -1,52 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2010 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef _CL_VERSIONS_HPP_
|
||||
#define _CL_VERSIONS_HPP_
|
||||
|
||||
#include "utils/macros.hpp"
|
||||
|
||||
#ifndef AMD_COMPILER_NAME
|
||||
# define AMD_COMPILER_NAME "AMD COMPILER"
|
||||
#endif // AMD_COMPILER_NAME
|
||||
|
||||
#ifndef AMD_COMPILER_BUILD_NUMBER
|
||||
# define AMD_COMPILER_BUILD_NUMBER 0
|
||||
#endif // AMD_COMPILER_BUILD_NUMBER
|
||||
|
||||
#ifndef AMD_COMPILER_REVISION_NUMBER
|
||||
# define AMD_COMPILER_REVISION_NUMBER 0
|
||||
#endif // AMD_COMPILER_REVISION_NUMBER
|
||||
|
||||
#ifndef AMD_SC_COMPILER_REVISION_NUMBER
|
||||
#define AMD_SC_COMPILER_REVISION_NUMBER SC_BUILD_NUMBER
|
||||
#endif // AMD_SC_COMPILER_REVISION_NUMBER
|
||||
|
||||
#ifndef AMD_COMPILER_MAJOR_VERSION
|
||||
# define AMD_COMPILER_MAJOR_VERSION 0
|
||||
#endif // AMD_COMPILER_MAJOR_VERSION
|
||||
|
||||
#ifndef AMD_COMPILER_MINOR_VERSION
|
||||
# define AMD_COMPILER_MINOR_VERSION 8
|
||||
#endif // AMD_COMPILER_MINOR_VERSION
|
||||
|
||||
#ifndef AMD_COMPILER_RELEASE_INFO
|
||||
# define AMD_COMPILER_RELEASE_INFO
|
||||
#endif // AMD_COMPILER_RELEASE_INFO
|
||||
|
||||
#ifndef AMD_COMPILER_NAME
|
||||
# define AMD_COMPILER_NAME "AMD Compiler Library"
|
||||
#endif // AMD_COMPILER_NAME
|
||||
|
||||
#define AMD_BUILD_STRING XSTR(AMD_COMPILER_BUILD_NUMBER) \
|
||||
"." XSTR(AMD_COMPILER_REVISION_NUMBER) "." XSTR(AMD_SC_COMPILER_REVISION_NUMBER)
|
||||
|
||||
#ifndef AMD_COMPILER_INFO
|
||||
# define AMD_COMPILER_INFO "AMD-COMP-LIB-" \
|
||||
"v" XSTR(AMD_COMPILER_MAJOR_VERSION) "." XSTR(AMD_COMPILER_MINOR_VERSION) \
|
||||
AMD_COMPILER_RELEASE_INFO DEBUG_ONLY(".dbg") " (" AMD_BUILD_STRING ")"
|
||||
#endif // AMD_COMPILER_INFO
|
||||
|
||||
|
||||
#endif // _CL_VERSIONS_HPP_
|
||||
Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 356 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Bloquear um usuário