Skip to content

Commit 08d47ec

Browse files
committed
[Comgr][v3.0] Remove deprecated ADD_DEVICE_LIBRARIES action
- AMD_COMGR_ACTION_ADD_DEVICE_LIBRARIES Remove the ability for Comgr to configure device libraries for linking, as this functionality has been shifted to the clang driver. We also consolidate comgr-libraries.h and comgr-device-libraries.h into a single file, and remove the compile_device_libs test Change-Id: I1d3a2158fb02b8b47f57ee59df501cfcf830e6b7
1 parent 3a4054a commit 08d47ec

File tree

8 files changed

+26
-455
lines changed

8 files changed

+26
-455
lines changed

amd/comgr/docs/ReleaseNotes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ Removed Comgr Actions and Data Types
167167
- This is a legacy action that was never implemented
168168
- (Language) AMD\_COMGR\_LANGUAGE\_HC
169169
- This is a legacy language that was never used
170+
- (Action) AMD\_COMGR\_ACTION\_ADD\_DEVICE\_LIBRARIES
171+
- This has been replaced with
172+
AMD\_COMGR\_ACTION\_COMPILE\_SOURCE\_WITH\_DEVICE\_LIBS\_TO\_BC
170173

171174
Comgr Testing, Debugging, and Logging Updates
172175
---------------------------------------------

amd/comgr/include/amd_comgr.h.in

Lines changed: 13 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,44 +1588,6 @@ typedef enum amd_comgr_action_kind_s {
15881588
* if isa name or language is not set in @p info.
15891589
*/
15901590
AMD_COMGR_ACTION_COMPILE_SOURCE_TO_BC = 0x2,
1591-
/**
1592-
* Copy all existing data objects in @p input to @p output, then add the
1593-
* device-specific and language-specific bitcode libraries required for
1594-
* compilation.
1595-
*
1596-
* Currently the only supported languages are @p AMD_COMGR_LANGUAGE_OPENCL_1_2,
1597-
* @p AMD_COMGR_LANGUAGE_OPENCL_2_0, and @p AMD_COMGR_LANGUAGE_HIP.
1598-
*
1599-
* The options in @p info should be set to a set of language-specific flags.
1600-
* For OpenCL and HIP these include:
1601-
*
1602-
* correctly_rounded_sqrt
1603-
* finite_only
1604-
* unsafe_math
1605-
* wavefrontsize64
1606-
*
1607-
* For example, to enable finite_only unsafe_math, the options should be set
1608-
* as:
1609-
*
1610-
* const char *options[] = {"finite_only", "unsafe_math"};
1611-
* size_t optionsCount = sizeof(options) / sizeof(options[0]);
1612-
* amd_comgr_action_info_set_option_list(info, options, optionsCount);
1613-
*
1614-
* Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT if isa name or language
1615-
* is not set in @p info, the language is not supported, an unknown
1616-
* language-specific flag is supplied, or a language-specific flag is
1617-
* repeated.
1618-
*
1619-
* @deprecated since 1.7
1620-
* @warning This action, followed by @c AMD_COMGR_ACTION_LINK_BC_TO_BC, may
1621-
* result in subtle bugs due to incorrect linking of the device libraries.
1622-
* The @c AMD_COMGR_ACTION_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC action can
1623-
* be used as a workaround which ensures the link occurs correctly.
1624-
*/
1625-
AMD_COMGR_ACTION_ADD_DEVICE_LIBRARIES
1626-
AMD_COMGR_DEPRECATED("Will be removed in Comgr v3.0 (Rocm v6.0). Use "
1627-
"AMD_COMGR_ACTION_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC "
1628-
"instead") = 0x3,
16291591
/**
16301592
* Link a collection of bitcodes, bundled bitcodes, and bundled bitcode
16311593
* archives in @p into a single composite (unbundled) bitcode @p.
@@ -1639,7 +1601,7 @@ typedef enum amd_comgr_action_kind_s {
16391601
* of all bc data objects in @p input, or if the Name field is not set for
16401602
* any DataObject in the input set.
16411603
*/
1642-
AMD_COMGR_ACTION_LINK_BC_TO_BC = 0x4,
1604+
AMD_COMGR_ACTION_LINK_BC_TO_BC = 0x3,
16431605
/**
16441606
* Perform code generation for each bc data object in @p input in
16451607
* order. For each successful code generation add a relocatable data
@@ -1652,7 +1614,7 @@ typedef enum amd_comgr_action_kind_s {
16521614
* if isa name is not set in @p info and does not match the isa name
16531615
* of all bc data objects in @p input.
16541616
*/
1655-
AMD_COMGR_ACTION_CODEGEN_BC_TO_RELOCATABLE = 0x5,
1617+
AMD_COMGR_ACTION_CODEGEN_BC_TO_RELOCATABLE = 0x4,
16561618
/**
16571619
* Perform code generation for each bc data object in @p input in
16581620
* order. For each successful code generation add an assembly source data
@@ -1665,7 +1627,7 @@ typedef enum amd_comgr_action_kind_s {
16651627
* if isa name is not set in @p info and does not match the isa name
16661628
* of all bc data objects in @p input.
16671629
*/
1668-
AMD_COMGR_ACTION_CODEGEN_BC_TO_ASSEMBLY = 0x6,
1630+
AMD_COMGR_ACTION_CODEGEN_BC_TO_ASSEMBLY = 0x5,
16691631
/**
16701632
* Link each relocatable data object in @p input together and add
16711633
* the linked relocatable data object to @p result. Any device
@@ -1678,7 +1640,7 @@ typedef enum amd_comgr_action_kind_s {
16781640
* if isa name is not set in @p info and does not match the isa name
16791641
* of all relocatable data objects in @p input.
16801642
*/
1681-
AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_RELOCATABLE = 0x7,
1643+
AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_RELOCATABLE = 0x6,
16821644
/**
16831645
* Link each relocatable data object in @p input together and add
16841646
* the linked executable data object to @p result. Any device
@@ -1691,7 +1653,7 @@ typedef enum amd_comgr_action_kind_s {
16911653
* if isa name is not set in @p info and does not match the isa name
16921654
* of all relocatable data objects in @p input.
16931655
*/
1694-
AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_EXECUTABLE = 0x8,
1656+
AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_EXECUTABLE = 0x7,
16951657
/**
16961658
* Assemble each source data object in @p input in order into machine code.
16971659
* For each successful assembly add a relocatable data object to @p result.
@@ -1704,7 +1666,7 @@ typedef enum amd_comgr_action_kind_s {
17041666
* Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT if isa name is not set in
17051667
* @p info.
17061668
*/
1707-
AMD_COMGR_ACTION_ASSEMBLE_SOURCE_TO_RELOCATABLE = 0x9,
1669+
AMD_COMGR_ACTION_ASSEMBLE_SOURCE_TO_RELOCATABLE = 0x8,
17081670
/**
17091671
* Disassemble each relocatable data object in @p input in
17101672
* order. For each successful disassembly add a source data object to
@@ -1717,7 +1679,7 @@ typedef enum amd_comgr_action_kind_s {
17171679
* if isa name is not set in @p info and does not match the isa name
17181680
* of all relocatable data objects in @p input.
17191681
*/
1720-
AMD_COMGR_ACTION_DISASSEMBLE_RELOCATABLE_TO_SOURCE = 0xA,
1682+
AMD_COMGR_ACTION_DISASSEMBLE_RELOCATABLE_TO_SOURCE = 0x9,
17211683
/**
17221684
* Disassemble each executable data object in @p input in order. For
17231685
* each successful disassembly add a source data object to @p result.
@@ -1729,7 +1691,7 @@ typedef enum amd_comgr_action_kind_s {
17291691
* if isa name is not set in @p info and does not match the isa name
17301692
* of all relocatable data objects in @p input.
17311693
*/
1732-
AMD_COMGR_ACTION_DISASSEMBLE_EXECUTABLE_TO_SOURCE = 0xB,
1694+
AMD_COMGR_ACTION_DISASSEMBLE_EXECUTABLE_TO_SOURCE = 0xA,
17331695
/**
17341696
* Disassemble each bytes data object in @p input in order. For each
17351697
* successful disassembly add a source data object to @p
@@ -1744,7 +1706,7 @@ typedef enum amd_comgr_action_kind_s {
17441706
* Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT
17451707
* if isa name is not set in @p info
17461708
*/
1747-
AMD_COMGR_ACTION_DISASSEMBLE_BYTES_TO_SOURCE = 0xC,
1709+
AMD_COMGR_ACTION_DISASSEMBLE_BYTES_TO_SOURCE = 0xB,
17481710
/**
17491711
* Compile each source data object in @p input in order. For each
17501712
* successful compilation add a bc data object to @p result. Resolve
@@ -1761,7 +1723,7 @@ typedef enum amd_comgr_action_kind_s {
17611723
* Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT
17621724
* if isa name or language is not set in @p info.
17631725
*/
1764-
AMD_COMGR_ACTION_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC = 0xD,
1726+
AMD_COMGR_ACTION_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC = 0xC,
17651727
/**
17661728
* Compile a single source data object in @p input in order. For each
17671729
* successful compilation add a relocatable data object to @p result.
@@ -1778,7 +1740,7 @@ typedef enum amd_comgr_action_kind_s {
17781740
* Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT
17791741
* if isa name or language is not set in @p info.
17801742
*/
1781-
AMD_COMGR_ACTION_COMPILE_SOURCE_TO_RELOCATABLE = 0xE,
1743+
AMD_COMGR_ACTION_COMPILE_SOURCE_TO_RELOCATABLE = 0xD,
17821744
/**
17831745
* Compile each source data object in @p input and create a single executabele
17841746
* in @p result. Resolve any include source names using the names of include
@@ -1794,7 +1756,7 @@ typedef enum amd_comgr_action_kind_s {
17941756
* Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT
17951757
* if isa name or language is not set in @p info.
17961758
*/
1797-
AMD_COMGR_ACTION_COMPILE_SOURCE_TO_EXECUTABLE = 0xF,
1759+
AMD_COMGR_ACTION_COMPILE_SOURCE_TO_EXECUTABLE = 0xE,
17981760

17991761
/**
18001762
* Unbundle each source data object in @p input. These objects can be
@@ -1808,7 +1770,7 @@ typedef enum amd_comgr_action_kind_s {
18081770
* Return @p AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT
18091771
* if isa name or language is not set in @p info.
18101772
*/
1811-
AMD_COMGR_ACTION_UNBUNDLE = 0x10,
1773+
AMD_COMGR_ACTION_UNBUNDLE = 0xF,
18121774

18131775
/**
18141776
* Marker for last valid action kind.

amd/comgr/src/comgr-device-libs.cpp

Lines changed: 10 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
#include "comgr-device-libs.h"
3737
#include "comgr.h"
38-
#include "comgr-libraries.h"
3938
#include "llvm/ADT/StringSwitch.h"
4039
#include <cstdint>
4140

@@ -62,13 +61,8 @@ static amd_comgr_status_t addObject(DataSet *DataSet,
6261
return AMD_COMGR_STATUS_SUCCESS;
6362
}
6463

65-
static amd_comgr_status_t
66-
addOCLCObject(DataSet *DataSet,
67-
std::tuple<const char *, const void *, size_t> OCLCLib) {
68-
return addObject(DataSet, AMD_COMGR_DATA_KIND_BC, std::get<0>(OCLCLib),
69-
std::get<1>(OCLCLib), std::get<2>(OCLCLib));
70-
}
71-
64+
#include "opencl1.2-c.inc"
65+
#include "opencl2.0-c.inc"
7266
amd_comgr_status_t addPrecompiledHeaders(DataAction *ActionInfo,
7367
DataSet *ResultSet) {
7468
switch (ActionInfo->Language) {
@@ -83,134 +77,14 @@ amd_comgr_status_t addPrecompiledHeaders(DataAction *ActionInfo,
8377
}
8478
}
8579

86-
amd_comgr_status_t addDeviceLibraries(DataAction *ActionInfo,
87-
DataSet *ResultSet) {
88-
if (ActionInfo->Language != AMD_COMGR_LANGUAGE_OPENCL_1_2 &&
89-
ActionInfo->Language != AMD_COMGR_LANGUAGE_OPENCL_2_0 &&
90-
ActionInfo->Language != AMD_COMGR_LANGUAGE_HIP) {
91-
return AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT;
92-
}
93-
94-
if (ActionInfo->Language == AMD_COMGR_LANGUAGE_HIP) {
95-
if (auto Status = addObject(ResultSet, AMD_COMGR_DATA_KIND_BC, "hip_lib.bc",
96-
hip_lib, hip_lib_size)) {
97-
return Status;
98-
}
99-
} else {
100-
if (auto Status = addObject(ResultSet, AMD_COMGR_DATA_KIND_BC,
101-
"opencl_lib.bc", opencl_lib, opencl_lib_size)) {
102-
return Status;
103-
}
104-
}
105-
106-
if (auto Status = addObject(ResultSet, AMD_COMGR_DATA_KIND_BC, "ocml_lib.bc",
107-
ocml_lib, ocml_lib_size)) {
108-
return Status;
109-
}
110-
if (auto Status = addObject(ResultSet, AMD_COMGR_DATA_KIND_BC, "ockl_lib.bc",
111-
ockl_lib, ockl_lib_size)) {
112-
return Status;
113-
}
114-
115-
TargetIdentifier Ident;
116-
if (auto Status = parseTargetIdentifier(ActionInfo->IsaName, Ident)) {
117-
return Status;
118-
}
119-
if (!Ident.Processor.consume_front("gfx")) {
120-
return AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT;
121-
}
122-
auto IsaVersion = get_oclc_isa_version(Ident.Processor);
123-
if (!std::get<0>(IsaVersion)) {
124-
report_fatal_error(Twine("Missing device library for gfx") +
125-
Ident.Processor);
126-
}
127-
if (auto Status = addOCLCObject(ResultSet, IsaVersion)) {
128-
return Status;
129-
}
130-
131-
bool CorrectlyRoundedSqrt = false, DazOpt = false, FiniteOnly = false,
132-
UnsafeMath = false, Wavefrontsize64 = false;
133-
unsigned CodeObjectVersion = 0;
134-
for (auto &Option : ActionInfo->getOptions()) {
135-
// Parse code_object_v<N>
136-
if (StringRef CoV = Option; CoV.consume_front("code_object_v")) {
137-
// String is invalid if:
138-
// - We already parsed a code object version
139-
// - We cannot parse the remaining str as an integer
140-
// - The version is out of bounds.
141-
if (CodeObjectVersion || CoV.getAsInteger(10, CodeObjectVersion) ||
142-
CodeObjectVersion < 4 || CodeObjectVersion > 6) {
143-
return AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT;
144-
}
145-
continue;
146-
}
147-
148-
bool *Flag = StringSwitch<bool *>(Option)
149-
.Case("correctly_rounded_sqrt", &CorrectlyRoundedSqrt)
150-
.Case("daz_opt", &DazOpt)
151-
.Case("finite_only", &FiniteOnly)
152-
.Case("unsafe_math", &UnsafeMath)
153-
.Case("wavefrontsize64", &Wavefrontsize64)
154-
.Default(nullptr);
155-
// It is invalid to provide an unknown option and to repeat an option.
156-
if (!Flag || *Flag) {
157-
return AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT;
158-
}
159-
160-
// TODO: Warn if daz_opt is used as it no longer does anything.
161-
*Flag = true;
162-
}
163-
164-
// Assume V5 in the absence of a code_object_v option.
165-
if (!CodeObjectVersion)
166-
CodeObjectVersion = 5;
167-
168-
if (auto Status = addOCLCObject(
169-
ResultSet, get_oclc_correctly_rounded_sqrt(CorrectlyRoundedSqrt))) {
170-
return Status;
171-
}
172-
if (auto Status =
173-
addOCLCObject(ResultSet, get_oclc_finite_only(FiniteOnly))) {
174-
return Status;
175-
}
176-
if (auto Status =
177-
addOCLCObject(ResultSet, get_oclc_unsafe_math(UnsafeMath))) {
178-
return Status;
179-
}
180-
if (auto Status =
181-
addOCLCObject(ResultSet, get_oclc_wavefrontsize64(Wavefrontsize64))) {
182-
return Status;
183-
}
184-
// TODO: We should generate a get_oclc function for the code object version,
185-
// but for now we have hardcoded the bitcode file names
186-
// if (auto Status =
187-
// addOCLCObject(ResultSet, get_oclc_code_object(CodeObjectV))) {
188-
// return Status;
189-
// }
190-
if (CodeObjectVersion == 6) {
191-
if (auto Status = addObject(
192-
ResultSet, AMD_COMGR_DATA_KIND_BC, "oclc_abi_version_600_lib.bc",
193-
oclc_abi_version_600_lib, oclc_abi_version_600_lib_size)) {
194-
return Status;
195-
}
196-
} else if (CodeObjectVersion == 5) {
197-
if (auto Status = addObject(ResultSet, AMD_COMGR_DATA_KIND_BC,
198-
"oclc_abi_version_500_lib.bc",
199-
oclc_abi_version_500_lib,
200-
oclc_abi_version_500_lib_size)) {
201-
return Status;
202-
}
203-
} else if (CodeObjectVersion == 4) {
204-
if (auto Status = addObject(ResultSet, AMD_COMGR_DATA_KIND_BC,
205-
"oclc_abi_version_400_lib.bc",
206-
oclc_abi_version_400_lib,
207-
oclc_abi_version_400_lib_size)) {
208-
return Status;
209-
}
210-
} else
211-
llvm_unreachable("CodeObjectVersion variable should have been set!");
212-
213-
return AMD_COMGR_STATUS_SUCCESS;
80+
#include "libraries.inc"
81+
llvm::ArrayRef<std::tuple<llvm::StringRef, llvm::StringRef>> getDeviceLibraries() {
82+
static std::tuple<llvm::StringRef, llvm::StringRef> DeviceLibs[] = {
83+
#define AMD_DEVICE_LIBS_TARGET(target) \
84+
{#target ".bc", llvm::StringRef(reinterpret_cast<const char *>(target##_lib), target##_lib_size)},
85+
#include "libraries_defs.inc"
86+
};
87+
return DeviceLibs;
21488
}
21589

21690
} // namespace COMGR

amd/comgr/src/comgr-device-libs.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ struct DataSet;
4949
amd_comgr_status_t addPrecompiledHeaders(DataAction *ActionInfo,
5050
DataSet *ResultSet);
5151

52-
amd_comgr_status_t addDeviceLibraries(DataAction *ActionInfo,
53-
DataSet *ResultSet);
54-
5552
llvm::ArrayRef<std::tuple<llvm::StringRef, llvm::StringRef>>
5653
getDeviceLibraries();
5754

amd/comgr/src/comgr-libraries.h

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)