From 9f4f52ca7386b991889da7aba988d61cbb280ad0 Mon Sep 17 00:00:00 2001 From: foreman Date: Thu, 1 Aug 2019 12:44:10 -0400 Subject: [PATCH] P4 to Git Change 1977054 by kzhuravl@kzhuravl-spot-ocl on 2019/08/01 12:32:41 SWDEV-79445 - OCL generic changes and code clean-up - Fix COMGR+CMAKE combination - http://git.amd.com:8080/c/compute/ec/opencl/+/247843 - Fix and clean up packaging (cmake) - http://git.amd.com:8080/c/compute/ec/opencl/+/247844 Affected files ... ... //depot/stg/opencl/drivers/opencl/CMakeLists.txt#26 edit ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/CMakeLists.txt#19 edit ... //depot/stg/opencl/drivers/opencl/runtime/CMakeLists.txt#16 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.cpp#54 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/CMakeLists.txt#21 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#104 edit ... //depot/stg/opencl/drivers/opencl/tools/clinfo/CMakeLists.txt#6 edit --- rocclr/CMakeLists.txt | 190 ++++++++++++---------- rocclr/runtime/CMakeLists.txt | 10 +- rocclr/runtime/device/devprogram.cpp | 2 +- rocclr/runtime/device/rocm/CMakeLists.txt | 151 ++++++++--------- rocclr/runtime/device/rocm/rocprogram.cpp | 2 +- 5 files changed, 193 insertions(+), 162 deletions(-) diff --git a/rocclr/CMakeLists.txt b/rocclr/CMakeLists.txt index 3d04b39a5c..b5544361aa 100644 --- a/rocclr/CMakeLists.txt +++ b/rocclr/CMakeLists.txt @@ -5,6 +5,9 @@ if (POLICY CMP0048) 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) @@ -14,9 +17,13 @@ if(ROCM_OPENCL_CCACHE_BUILD) else() message(FATAL_ERROR "Unable to find the program ccache. Set ROCM_OPENCL_CCACHE_BUILD to OFF") endif() - 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 "") + + # 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(OpenCL-ROCm) @@ -28,52 +35,65 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) -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 "") +# FIXME: Remove following if block after enabling COMGR by default +if (${USE_COMGR_LIBRARY} STREQUAL "no") + set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "") + set(LLVM_BUILD_TOOLS OFF CACHE BOOL "") + set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "") + set(LLVM_TARGETS_TO_BUILD "AMDGPU" CACHE STRING "") + set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "") + set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "") -# override default option value in library and driver -set(GENERIC_IS_ZERO ON CACHE BOOL ON FORCE) + # override default option value in library and driver + set(GENERIC_IS_ZERO ON CACHE BOOL ON FORCE) -add_subdirectory(compiler/llvm EXCLUDE_FROM_ALL) + add_subdirectory(compiler/llvm EXCLUDE_FROM_ALL) -find_package(LLVM REQUIRED CONFIG PATHS ${CMAKE_BINARY_DIR}/compiler/llvm NO_DEFAULT_PATH) + find_package(LLVM REQUIRED CONFIG PATHS ${CMAKE_BINARY_DIR}/compiler/llvm NO_DEFAULT_PATH) -list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") -include(AddLLVM) + 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) + 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) + # 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 $ $ + 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="yes") - include_directories(${CMAKE_SOURCE_DIR}/compiler/llvm/include) + add_definitions(-DCOMGR_DYN_DLL) add_definitions(-DUSE_COMGR_LIBRARY) if( ${BUILD_HIP} MATCHES "yes") - add_subdirectory(api/hip) + add_subdirectory(api/hip) endif() -else() - add_subdirectory(compiler/driver EXCLUDE_FROM_ALL) endif() -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/lib/loaders/elf/utils/libelf) find_package(ROCT REQUIRED) @@ -89,68 +109,68 @@ add_subdirectory(api/opencl/khronos/icd) add_subdirectory(tools/clinfo) -install(PROGRAMS $ $ - DESTINATION bin/x86_64 - COMPONENT libraries) +###--- Packaging ------------------------------------------------------------### +# MAIN package +install(PROGRAMS $ + DESTINATION bin/x86_64 + COMPONENT MAIN) +install(PROGRAMS $ + DESTINATION lib/x86_64 + COMPONENT MAIN) install(PROGRAMS $ DESTINATION lib/x86_64 - COMPONENT applications) + COMPONENT MAIN) +install(PROGRAMS $ + DESTINATION lib/x86_64 + COMPONENT MAIN) +# 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 $ DESTINATION lib/x86_64 - COMPONENT libraries) + COMPONENT DEV) -install(DIRECTORY - "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL" - DESTINATION include - COMPONENT libraries - USE_SOURCE_PERMISSIONS - PATTERN cl_egl.h EXCLUDE) +# Generic CPACK variables +set(CPACK_GENERATOR "DEB;RPM" CACHE STRING "Default packaging generators") -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 libraries) -endforeach() +set(CPACK_PACKAGE_CONTACT "Advanced Micro Devices Inc.") +set(CPACK_PACKAGE_VENDOR "AMD") +set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/rocm/opencl") -## CPack standard variables -set ( CPACK_PACKAGE_NAME "rocm-opencl" ) -set ( CPACK_PACKAGE_FILE_NAME "rocm-opencl-1.2.0" ) -set ( CPACK_PACKAGE_VENDOR "AMD" ) -set ( CPACK_PACKAGE_VERSION_MAJOR "1" ) -set ( CPACK_PACKAGE_VERSION_MINOR "2" ) -set ( CPACK_PACKAGE_VERSION_PATCH "0" ) -set ( CPACK_PACKAGE_CONTACT "Advanced Micro Devices Inc." ) -set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime" ) +set(CPACK_PACKAGE_VERSION_MAJOR "1") +set(CPACK_PACKAGE_VERSION_MINOR "2") +set(CPACK_PACKAGE_VERSION_PATCH "0") -set ( CPACK_GENERATOR RPM DEB ) -set ( CPACK_PACKAGING_INSTALL_PREFIX "/opt/rocm/opencl" ) +# Debian CPACK variables +set(CPACK_DEB_COMPONENT_INSTALL ON) -## Debian package values +set(CPACK_DEBIAN_MAIN_FILE_NAME "rocm-opencl-1.2.0.deb") +set(CPACK_DEBIAN_MAIN_PACKAGE_NAME "rocm-opencl") +set(CPACK_DEBIAN_MAIN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/DEB/postinst;${CMAKE_CURRENT_SOURCE_DIR}/DEB/prerm") -set ( CPACK_DEBIAN_PACKAGE_MAINTAINER "AMD" ) -set ( CPACK_DEBIAN_PACKAGE_DEPENDS "" ) -set ( CPACK_DEB_COMPONENT_INSTALL ON) -set ( CPACK_DEBIAN_applications_PACKAGE_NAME "rocm-opencl" ) -set ( CPACK_DEBIAN_applications_FILE_NAME "rocm-opencl-1.2.0.deb" ) -set ( CPACK_DEBIAN_libraries_PACKAGE_NAME "rocm-opencl-dev" ) -set ( CPACK_DEBIAN_libraries_FILE_NAME "rocm-opencl-dev-1.2.0.deb" ) -set ( CPACK_DEBIAN_libraries_PACKAGE_DEPENDS "rocm-opencl" ) -set ( CPACK_DEBIAN_applications_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/DEB/postinst;${CMAKE_CURRENT_SOURCE_DIR}/DEB/prerm" ) +set(CPACK_DEBIAN_DEV_FILE_NAME "rocm-opencl-dev-1.2.0.deb") +set(CPACK_DEBIAN_DEV_PACKAGE_NAME "rocm-opencl-dev") +set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "rocm-opencl") -## RPM package values +# RPM CPACK variables +set(CPACK_RPM_COMPONENT_INSTALL ON) -set ( CPACK_RPM_COMPONENT_INSTALL ON) -set ( CPACK_RPM_applications_PACKAGE_NAME "rocm-opencl" ) -set ( CPACK_RPM_applications_FILE_NAME "rocm-opencl-1.2.0.rpm" ) -set ( CPACK_RPM_libraries_PACKAGE_NAME "rocm-opencl-devel" ) -set ( CPACK_RPM_libraries_FILE_NAME "rocm-opencl-devel-1.2.0.rpm" ) -set ( CPACK_RPM_libraries_PACKAGE_DEPENDS "rocm-opencl" ) -set ( CPACK_RPM_applications_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_post" ) -set ( CPACK_RPM_applications_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_postun" ) +set(CPACK_RPM_MAIN_FILE_NAME "rocm-opencl-1.2.0.rpm") +set(CPACK_RPM_MAIN_PACKAGE_NAME "rocm-opencl") +set(CPACK_RPM_MAIN_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_post") +set(CPACK_RPM_MAIN_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_postun") -set ( CPACK_COMPONENTS_ALL applications libraries ) -include ( CPack ) +set(CPACK_RPM_DEV_FILE_NAME "rocm-opencl-devel-1.2.0.rpm") +set(CPACK_RPM_DEV_PACKAGE_NAME "rocm-opencl-devel") +set(CPACK_RPM_DEV_PACKAGE_DEPENDS "rocm-opencl") + +set(CPACK_COMPONENTS_ALL MAIN DEV) +include(CPack) diff --git a/rocclr/runtime/CMakeLists.txt b/rocclr/runtime/CMakeLists.txt index 0a55cf58ae..2c9dfd6800 100644 --- a/rocclr/runtime/CMakeLists.txt +++ b/rocclr/runtime/CMakeLists.txt @@ -8,13 +8,21 @@ if(CMAKE_BUILD_TYPE MATCHES "^Debug$") endif() include_directories(${ROCR_INCLUDES}) +if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "") + include_directories(${LLVM_INCLUDES}) +endif() # if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "") include_directories(${CMAKE_SOURCE_DIR}/runtime) include_directories(${CMAKE_SOURCE_DIR}/api/opencl) include_directories(${CMAKE_SOURCE_DIR}/api/opencl/khronos) include_directories(${CMAKE_SOURCE_DIR}/api/opencl/khronos/headers) include_directories(${CMAKE_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2) -include_directories(${CMAKE_SOURCE_DIR}/compiler/llvm/include) + +# FIXME: Remove following if block after enabling COMGR by default +if (${USE_COMGR_LIBRARY} STREQUAL "no") + include_directories(${CMAKE_SOURCE_DIR}/compiler/llvm/include) +endif() # if (${USE_COMGR_LIBRARY} STREQUAL "no") + include_directories(${CMAKE_SOURCE_DIR}/compiler/driver/src) include_directories(${CMAKE_SOURCE_DIR}/compiler/lib) include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/include) diff --git a/rocclr/runtime/device/devprogram.cpp b/rocclr/runtime/device/devprogram.cpp index 1bc93b23b6..f08698d227 100644 --- a/rocclr/runtime/device/devprogram.cpp +++ b/rocclr/runtime/device/devprogram.cpp @@ -1766,7 +1766,7 @@ bool Program::linkImplLC(amd::option::Options* options) { } if (device().settings().lcWavefrontSize64_) { - codegenOptions.append(" -mwavefrontsize64"); + codegenOptions.push_back("-mwavefrontsize64"); } // Tokenize the options string into a vector of strings diff --git a/rocclr/runtime/device/rocm/CMakeLists.txt b/rocclr/runtime/device/rocm/CMakeLists.txt index 7dce5b9738..5870b6540f 100644 --- a/rocclr/runtime/device/rocm/CMakeLists.txt +++ b/rocclr/runtime/device/rocm/CMakeLists.txt @@ -29,80 +29,83 @@ add_library(oclrocm OBJECT ) set_target_properties(oclrocm PROPERTIES POSITION_INDEPENDENT_CODE ON) -# generating libraries.amdgcn.inc -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc "// Automatically generated file; DO NOT EDIT.\n") +# FIXME: Remove following if block after enabling COMGR by default +if (${USE_COMGR_LIBRARY} STREQUAL "no") + # generating libraries.amdgcn.inc + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc "// Automatically generated file; DO NOT EDIT.\n") -foreach(AMDGCN_LIB_TARGET ${AMDGCN_LIB_TARGETS}) - get_target_property(lib_file ${AMDGCN_LIB_TARGET} OUTPUT_NAME) - get_target_property(lib_file_name ${AMDGCN_LIB_TARGET} ARCHIVE_OUTPUT_NAME) - get_target_property(lib_file_path ${AMDGCN_LIB_TARGET} ARCHIVE_OUTPUT_DIRECTORY) - set(bclib "${lib_file}") - set(header "${lib_file_name}.${INC_SUFFIX}") - set(symbol "${lib_file_name}_lib") - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${header} - COMMAND bc2h ${bclib} ${CMAKE_CURRENT_BINARY_DIR}/${header} ${symbol} - DEPENDS bc2h ${AMDGCN_LIB_TARGET} - COMMENT "Generating ${header}" + foreach(AMDGCN_LIB_TARGET ${AMDGCN_LIB_TARGETS}) + get_target_property(lib_file ${AMDGCN_LIB_TARGET} OUTPUT_NAME) + get_target_property(lib_file_name ${AMDGCN_LIB_TARGET} ARCHIVE_OUTPUT_NAME) + get_target_property(lib_file_path ${AMDGCN_LIB_TARGET} ARCHIVE_OUTPUT_DIRECTORY) + set(bclib "${lib_file}") + set(header "${lib_file_name}.${INC_SUFFIX}") + set(symbol "${lib_file_name}_lib") + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${header} + COMMAND bc2h ${bclib} ${CMAKE_CURRENT_BINARY_DIR}/${header} ${symbol} + DEPENDS bc2h ${AMDGCN_LIB_TARGET} + COMMENT "Generating ${header}" + ) + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/${target}.inc) + + add_custom_target(${header}_target ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${header}) + add_dependencies(oclrocm ${header}_target) + + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc "#include \"${header}\"\n") + endforeach() + + # Generate function to select libraries for a given GFXIP number. + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc + "static inline std::tuple get_oclc_isa_version(uint gfxip) { \ + switch (gfxip) {\n") + foreach(AMDGCN_LIB_TARGET ${AMDGCN_LIB_TARGETS}) + if (${AMDGCN_LIB_TARGET} MATCHES "^oclc_isa_version_[0-9]+_lib$") + string(REGEX REPLACE "^oclc_isa_version_([0-9]+)_lib$" "\\1" gfxip ${AMDGCN_LIB_TARGET}) + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc + "case ${gfxip}: return std::make_tuple( \"oclc_isa_version_${gfxip}_lib.bc\"," + " oclc_isa_version_${gfxip}_lib, oclc_isa_version_${gfxip}_lib_size); break;\n") + endif() + endforeach() + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc + "default: return std::make_tuple(\"\",(const void*)0,(size_t)0); }\n}\n") + + foreach(AMDGCN_LIB_TARGET ${AMDGCN_LIB_TARGETS}) + if (${AMDGCN_LIB_TARGET} MATCHES "oclc_(.*)_on_lib") + string(REGEX REPLACE "oclc_(.*)_on_lib" "\\1" function ${AMDGCN_LIB_TARGET}) + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc + "static inline std::tuple get_oclc_${function}(bool on)" + " { return std::make_tuple( on ? \"oclc_${function}_on_lib.bc\" : \"oclc_${function}_off_lib.bc\"," + " (const void*)(on ? oclc_${function}_on_lib : oclc_${function}_off_lib)," + " on ? oclc_${function}_on_lib_size : oclc_${function}_off_lib_size); }\n") + endif() + endforeach() + + # generating opencl*.inc files + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch + COMMAND clang -cc1 -x cl-header -triple amdgcn-amd-amdhsa -Werror -O3 -DNDEBUG -cl-std=CL1.2 -emit-pch -o ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch < ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h + DEPENDS clang ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h + COMMENT "Generating opencl1.2-c.amdgcn.pch" ) - set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/${target}.inc) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.inc + COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.inc opencl1_2_c + DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch + COMMENT "Generating opencl1.2-c.amdgcn.inc" + ) + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.inc ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch) + add_custom_target(opencl1.2-c.amdgcn.inc_target ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.inc) + add_dependencies(oclrocm opencl1.2-c.amdgcn.inc_target) - add_custom_target(${header}_target ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${header}) - add_dependencies(oclrocm ${header}_target) - - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc "#include \"${header}\"\n") -endforeach() - -# Generate function to select libraries for a given GFXIP number. -file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc - "static inline std::tuple get_oclc_isa_version(uint gfxip) { \ - switch (gfxip) {\n") -foreach(AMDGCN_LIB_TARGET ${AMDGCN_LIB_TARGETS}) - if (${AMDGCN_LIB_TARGET} MATCHES "^oclc_isa_version_[0-9]+_lib$") - string(REGEX REPLACE "^oclc_isa_version_([0-9]+)_lib$" "\\1" gfxip ${AMDGCN_LIB_TARGET}) - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc - "case ${gfxip}: return std::make_tuple( \"oclc_isa_version_${gfxip}_lib.bc\"," - " oclc_isa_version_${gfxip}_lib, oclc_isa_version_${gfxip}_lib_size); break;\n") - endif() -endforeach() -file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc - "default: return std::make_tuple(\"\",(const void*)0,(size_t)0); }\n}\n") - -foreach(AMDGCN_LIB_TARGET ${AMDGCN_LIB_TARGETS}) - if (${AMDGCN_LIB_TARGET} MATCHES "oclc_(.*)_on_lib") - string(REGEX REPLACE "oclc_(.*)_on_lib" "\\1" function ${AMDGCN_LIB_TARGET}) - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libraries.amdgcn.inc - "static inline std::tuple get_oclc_${function}(bool on)" - " { return std::make_tuple( on ? \"oclc_${function}_on_lib.bc\" : \"oclc_${function}_off_lib.bc\"," - " (const void*)(on ? oclc_${function}_on_lib : oclc_${function}_off_lib)," - " on ? oclc_${function}_on_lib_size : oclc_${function}_off_lib_size); }\n") - endif() -endforeach() - -# generating opencl*.inc files -add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch - COMMAND clang -cc1 -x cl-header -triple amdgcn-amd-amdhsa -Werror -O3 -DNDEBUG -cl-std=CL1.2 -emit-pch -o ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch < ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h - DEPENDS clang ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h - COMMENT "Generating opencl1.2-c.amdgcn.pch" -) -add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.inc - COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.inc opencl1_2_c - DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch - COMMENT "Generating opencl1.2-c.amdgcn.inc" -) -set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.inc ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch) -add_custom_target(opencl1.2-c.amdgcn.inc_target ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.inc) -add_dependencies(oclrocm opencl1.2-c.amdgcn.inc_target) - -add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch - COMMAND clang -cc1 -x cl-header -triple amdgcn-amd-amdhsa -Werror -O3 -DNDEBUG -cl-std=CL2.0 -emit-pch -o ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch < ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h - DEPENDS clang ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h - COMMENT "Generating opencl2.0-c.amdgcn.pch" -) -add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.inc - COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.inc opencl2_0_c - DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch - COMMENT "Generating opencl2.0-c.amdgcn.inc" -) -set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.inc ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch) -add_custom_target(opencl2.0-c.amdgcn.inc_target ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.inc) -add_dependencies(oclrocm opencl2.0-c.amdgcn.inc_target) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch + COMMAND clang -cc1 -x cl-header -triple amdgcn-amd-amdhsa -Werror -O3 -DNDEBUG -cl-std=CL2.0 -emit-pch -o ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch < ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h + DEPENDS clang ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h + COMMENT "Generating opencl2.0-c.amdgcn.pch" + ) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.inc + COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.inc opencl2_0_c + DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch + COMMENT "Generating opencl2.0-c.amdgcn.inc" + ) + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.inc ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch) + add_custom_target(opencl2.0-c.amdgcn.inc_target ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.inc) + add_dependencies(oclrocm opencl2.0-c.amdgcn.inc_target) +endif() # if (${USE_COMGR_LIBRARY} STREQUAL "no") diff --git a/rocclr/runtime/device/rocm/rocprogram.cpp b/rocclr/runtime/device/rocm/rocprogram.cpp index 191e58c0e7..0155dc2d18 100644 --- a/rocclr/runtime/device/rocm/rocprogram.cpp +++ b/rocclr/runtime/device/rocm/rocprogram.cpp @@ -9,9 +9,9 @@ #include "rockernel.hpp" #if defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY) #include -#include "libraries.amdgcn.inc" #ifndef USE_COMGR_LIBRARY #include "driver/AmdCompiler.h" +#include "libraries.amdgcn.inc" #endif #endif // defined(WITH_LIGHTNING_COMPILER) || defined(USE_COMGR_LIBRARY)