Skip to content

Commit 218d190

Browse files
committed
Revert "[Offload] Don't check in generated files (llvm#141982)"
This reverts commit b78bc35.
1 parent 0f53563 commit 218d190

File tree

15 files changed

+2799
-69
lines changed

15 files changed

+2799
-69
lines changed

offload/CMakeLists.txt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,23 @@ set(LIBOMPTARGET_LLVM_LIBRARY_DIR "${LLVM_LIBRARY_DIR}" CACHE STRING
427427
set(LIBOMPTARGET_LLVM_LIBRARY_INTDIR "${LIBOMPTARGET_INTDIR}" CACHE STRING
428428
"Path to folder where intermediate libraries will be output")
429429

430-
add_subdirectory(tools/offload-tblgen)
430+
if(SANITIZER_AMDGPU)
431+
add_definitions(-DSANITIZER_AMDGPU=1)
432+
# Check for COMGr package , ASan requires COMGr with minimum version 2.4
433+
find_package(amd_comgr QUIET 2.4.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
434+
endif()
435+
436+
# An Emissary API is a subset of Host APIs that are executed from Offload devices
437+
# using the offload RPC mechanism such as FORTRAN IO runtime and MPI.
438+
option(OFFLOAD_ENABLE_EMISSARY_APIS "Enable build of GPU Emissary APIs" ON)
439+
if(OFFLOAD_ENABLE_EMISSARY_APIS)
440+
# Header install location
441+
add_definitions(-DOFFLOAD_ENABLE_EMISSARY_APIS)
442+
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/DeviceRTL/include/EmissaryIds.h
443+
DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH})
444+
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/DeviceRTL/include/EmissaryMPI.h
445+
DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH})
446+
endif()
431447

432448
# Build offloading plugins and device RTLs if they are available.
433449
add_subdirectory(plugins-nextgen)
@@ -438,7 +454,9 @@ add_subdirectory(DeviceRTL)
438454
# Build target agnostic offloading library.
439455
add_subdirectory(libomptarget)
440456

441-
add_subdirectory(liboffload)
457+
# FIXME: Re-enable once OMPT design allows
458+
# add_subdirectory(tools/offload-tblgen)
459+
# add_subdirectory(liboffload)
442460

443461
# Add tests.
444462
add_subdirectory(test)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//===- Auto-generated file, part of the LLVM/Offload project --------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef OFFLOAD_ERRC
10+
#error Please define the macro OFFLOAD_ERRCODE(Name, Desc, Value)
11+
#endif
12+
13+
// Error codes are shared between PluginInterface and liboffload.
14+
// To add new error codes, add them to offload/liboffload/API/Common.td and run
15+
// the GenerateOffload target.
16+
17+
OFFLOAD_ERRC(SUCCESS, "success", 0)
18+
OFFLOAD_ERRC(UNKNOWN, "unknown or internal error", 1)
19+
OFFLOAD_ERRC(HOST_IO, "I/O error on host", 2)
20+
OFFLOAD_ERRC(INVALID_BINARY, "a provided binary image is malformed", 3)
21+
OFFLOAD_ERRC(INVALID_NULL_POINTER,
22+
"a pointer argument is null when it should not be", 4)
23+
OFFLOAD_ERRC(INVALID_ARGUMENT, "an argument is invalid", 5)
24+
OFFLOAD_ERRC(NOT_FOUND, "requested object was not found in the binary image", 6)
25+
OFFLOAD_ERRC(OUT_OF_RESOURCES, "out of resources", 7)
26+
OFFLOAD_ERRC(
27+
INVALID_SIZE,
28+
"invalid size or dimensions (e.g., must not be zero, or is out of bounds)",
29+
8)
30+
OFFLOAD_ERRC(INVALID_ENUMERATION, "enumerator argument is not valid", 9)
31+
OFFLOAD_ERRC(HOST_TOOL_NOT_FOUND,
32+
"a required binary (linker, etc.) was not found on the host", 10)
33+
OFFLOAD_ERRC(INVALID_VALUE, "invalid value", 11)
34+
OFFLOAD_ERRC(UNIMPLEMENTED,
35+
"generic error code for features currently unimplemented by the "
36+
"device/backend",
37+
12)
38+
OFFLOAD_ERRC(
39+
UNSUPPORTED,
40+
"generic error code for features unsupported by the device/backend", 13)
41+
OFFLOAD_ERRC(ASSEMBLE_FAILURE,
42+
"assembler failure while processing binary image", 14)
43+
OFFLOAD_ERRC(LINK_FAILURE, "linker failure while processing binary image", 15)
44+
OFFLOAD_ERRC(BACKEND_FAILURE,
45+
"the plugin backend is in an invalid or unsupported state", 16)
46+
OFFLOAD_ERRC(INVALID_NULL_HANDLE,
47+
"a handle argument is null when it should not be", 17)
48+
OFFLOAD_ERRC(INVALID_PLATFORM, "invalid platform", 18)
49+
OFFLOAD_ERRC(INVALID_DEVICE, "invalid device", 19)
50+
OFFLOAD_ERRC(INVALID_QUEUE, "invalid queue", 20)
51+
OFFLOAD_ERRC(INVALID_EVENT, "invalid event", 21)

offload/plugins-nextgen/common/include/OffloadError.h renamed to offload/include/Shared/OffloadError.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace error {
1818

1919
enum class ErrorCode {
2020
#define OFFLOAD_ERRC(Name, _, Value) Name = Value,
21-
#include "OffloadErrcodes.inc"
21+
#include "Shared/OffloadErrcodes.inc"
2222
#undef OFFLOAD_ERRC
2323
};
2424

offload/liboffload/API/CMakeLists.txt

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,29 @@
1-
# We want to clang-format the generated files if possible, since OffloadAPI.h is
2-
# the main public header for liboffload. Generate them in a temporary location,
3-
# then clang-format and copy them to the proper location. If clang-format is
4-
# missing just copy them.
5-
# Ideally we'd just clang-format them in place and avoid the copy but cmake
6-
# gets confused about the same path being a byproduct of two custom commands.
1+
# The OffloadGenerate target is used to regenerate the generated files in the
2+
# include directory. These files are checked in with the rest of the source,
3+
# therefore it is only needed when making changes to the API.
74

8-
set(LLVM_TARGET_DEFINITIONS ${CMAKE_CURRENT_SOURCE_DIR}/OffloadAPI.td)
9-
set(files_to_copy "")
5+
find_program(CLANG_FORMAT clang-format PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
6+
if (CLANG_FORMAT)
7+
set(LLVM_TARGET_DEFINITIONS ${CMAKE_CURRENT_SOURCE_DIR}/OffloadAPI.td)
108

11-
macro(offload_tablegen file)
12-
tablegen(OFFLOAD generated/${file}.gen ${ARGN})
13-
list(APPEND files_to_copy ${file})
14-
endmacro()
9+
tablegen(OFFLOAD OffloadAPI.h -gen-api)
10+
tablegen(OFFLOAD OffloadEntryPoints.inc -gen-entry-points)
11+
tablegen(OFFLOAD OffloadFuncs.inc -gen-func-names)
12+
tablegen(OFFLOAD OffloadImplFuncDecls.inc -gen-impl-func-decls)
13+
tablegen(OFFLOAD OffloadPrint.hpp -gen-print-header)
14+
tablegen(OFFLOAD OffloadErrcodes.inc -gen-errcodes)
1515

16-
offload_tablegen(OffloadAPI.h -gen-api)
17-
offload_tablegen(OffloadEntryPoints.inc -gen-entry-points)
18-
offload_tablegen(OffloadFuncs.inc -gen-func-names)
19-
offload_tablegen(OffloadImplFuncDecls.inc -gen-impl-func-decls)
20-
offload_tablegen(OffloadPrint.hpp -gen-print-header)
21-
22-
add_public_tablegen_target(OffloadGenerate)
23-
24-
add_custom_target(OffloadAPI DEPENDS OffloadGenerate)
25-
find_program(clang_format clang-format PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
26-
if (clang_format)
27-
foreach(file IN LISTS files_to_copy)
28-
add_custom_command(
29-
OUTPUT ${file}
30-
COMMAND ${clang_format} -i generated/${file}.gen
31-
COMMAND ${CMAKE_COMMAND} -E copy_if_different generated/${file}.gen ${CMAKE_CURRENT_BINARY_DIR}/${file}
32-
DEPENDS generated/${file}.gen
33-
)
34-
add_custom_target(OffloadAPI.${file} DEPENDS ${file})
35-
add_dependencies(OffloadAPI OffloadAPI.${file})
36-
endforeach()
16+
set(FILES_TO_COPY "OffloadAPI.h;OffloadEntryPoints.inc;OffloadFuncs.inc;OffloadImplFuncDecls.inc;OffloadPrint.hpp")
17+
set(GEN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include/generated)
18+
add_public_tablegen_target(OffloadGenerate)
19+
add_custom_command(TARGET OffloadGenerate POST_BUILD COMMAND ${CLANG_FORMAT}
20+
-i ${TABLEGEN_OUTPUT})
21+
add_custom_command(TARGET OffloadGenerate POST_BUILD COMMAND ${CMAKE_COMMAND}
22+
-E copy_if_different ${FILES_TO_COPY} ${GEN_DIR})
23+
add_custom_command(TARGET OffloadGenerate POST_BUILD COMMAND ${CMAKE_COMMAND}
24+
-E copy_if_different OffloadErrcodes.inc "${LIBOMPTARGET_INCLUDE_DIR}/Shared/OffloadErrcodes.inc")
3725
else()
38-
message(WARNING "clang-format not found, the generated Offload API headers will not be formatted")
39-
foreach(file IN LISTS files_to_copy)
40-
add_custom_command(
41-
OUTPUT ${file}
42-
COMMAND ${CMAKE_COMMAND} -E copy_if_different generated/${file}.gen ${CMAKE_CURRENT_BINARY_DIR}/${file}
43-
DEPENDS generated/${file}.gen
44-
)
45-
endforeach()
26+
message(WARNING "clang-format was not found, so the OffloadGenerate target\
27+
will not be available. Offload will still build, but you will not be\
28+
able to make changes to the API.")
4629
endif()

offload/liboffload/CMakeLists.txt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ add_llvm_library(
88
LINK_COMPONENTS
99
FrontendOpenMP
1010
Support
11-
12-
DEPENDS
13-
OffloadAPI
14-
PluginErrcodes
1511
)
1612

1713
foreach(plugin IN LISTS LIBOMPTARGET_PLUGINS_TO_BUILD)
@@ -23,13 +19,11 @@ if(LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
2319
endif()
2420

2521
target_include_directories(LLVMOffload PUBLIC
26-
${CMAKE_CURRENT_BINARY_DIR}/API
2722
${CMAKE_CURRENT_BINARY_DIR}/../include
2823
${CMAKE_CURRENT_SOURCE_DIR}/include
24+
${CMAKE_CURRENT_SOURCE_DIR}/include/generated
2925
${CMAKE_CURRENT_SOURCE_DIR}/../include
30-
${CMAKE_CURRENT_SOURCE_DIR}/../plugins-nextgen/common/include
31-
${CMAKE_CURRENT_BINARY_DIR}/../plugins-nextgen/common/include
32-
)
26+
${CMAKE_CURRENT_SOURCE_DIR}/../plugins-nextgen/common/include)
3327

3428
target_compile_options(LLVMOffload PRIVATE ${offload_compile_flags})
3529
target_link_options(LLVMOffload PRIVATE ${offload_link_flags})
@@ -45,5 +39,5 @@ set_target_properties(LLVMOffload PROPERTIES
4539
BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/..")
4640
install(TARGETS LLVMOffload LIBRARY COMPONENT LLVMOffload DESTINATION "${OFFLOAD_INSTALL_LIBDIR}")
4741

48-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/API/OffloadAPI.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/offload)
49-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/API/OffloadPrint.hpp DESTINATION ${CMAKE_INSTALL_PREFIX}/include/offload)
42+
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/generated/OffloadAPI.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/offload)
43+
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/generated/OffloadPrint.hpp DESTINATION ${CMAKE_INSTALL_PREFIX}/include/offload)

0 commit comments

Comments
 (0)