Skip to content

Commit 75f81de

Browse files
authored
[Flang][FlangRT][Runtime] Add RT_OFFLOAD_API_GROUP_BEGIN to missing symbols on AMDGPU (#147612)
After the recent move to work queues, in certain cases when linking in the fortran runtime built for offload on AMDGPU as required in certain cases, we'll get missing symbols when linking. This PR tries to address this issue by encompassing more of the library in RT_OFFLOAD_API_GROUP_BEGIN, which has the affect of compiling these functions for AMDGPU, resolving the missing symbols. This PR should address the following issue: #145888
1 parent 59a99c6 commit 75f81de

File tree

9 files changed

+41
-0
lines changed

9 files changed

+41
-0
lines changed

flang-rt/include/flang-rt/runtime/format.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class Descriptor;
2525

2626
namespace Fortran::runtime::io {
2727

28+
RT_OFFLOAD_API_GROUP_BEGIN
29+
2830
class IoStatementState;
2931

3032
enum EditingFlags {
@@ -200,5 +202,8 @@ template <typename CONTEXT> class FormatControl {
200202
// must be last, may be incomplete
201203
Iteration stack_[maxMaxHeight];
202204
};
205+
206+
RT_OFFLOAD_API_GROUP_END
207+
203208
} // namespace Fortran::runtime::io
204209
#endif // FLANG_RT_RUNTIME_FORMAT_H_

flang-rt/include/flang-rt/runtime/internal-unit.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
namespace Fortran::runtime::io {
2020

21+
RT_OFFLOAD_API_GROUP_BEGIN
22+
2123
class IoErrorHandler;
2224

2325
// Points to (but does not own) a CHARACTER scalar or array for internal I/O.
@@ -55,5 +57,8 @@ template <Direction DIR> class InternalDescriptorUnit : public ConnectionState {
5557

5658
extern template class InternalDescriptorUnit<Direction::Output>;
5759
extern template class InternalDescriptorUnit<Direction::Input>;
60+
61+
RT_OFFLOAD_API_GROUP_END
62+
5863
} // namespace Fortran::runtime::io
5964
#endif // FLANG_RT_RUNTIME_INTERNAL_UNIT_H_

flang-rt/include/flang-rt/runtime/io-stmt.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
namespace Fortran::runtime::io {
3030

31+
RT_OFFLOAD_API_GROUP_BEGIN
32+
3133
class ExternalFileUnit;
3234
class ChildIo;
3335

@@ -880,5 +882,7 @@ class ErroneousIoStatementState : public IoStatementBase {
880882
ExternalFileUnit *unit_{nullptr};
881883
};
882884

885+
RT_OFFLOAD_API_GROUP_END
886+
883887
} // namespace Fortran::runtime::io
884888
#endif // FLANG_RT_RUNTIME_IO_STMT_H_

flang-rt/include/flang-rt/runtime/non-tbp-dio.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class DerivedType;
3232

3333
namespace Fortran::runtime::io {
3434

35+
RT_OFFLOAD_API_GROUP_BEGIN
36+
3537
struct NonTbpDefinedIo {
3638
const typeInfo::DerivedType &derivedType;
3739
void (*subroutine)(); // null means no non-TBP defined I/O here
@@ -52,5 +54,7 @@ struct NonTbpDefinedIoTable {
5254
bool ignoreNonTbpEntries{false};
5355
};
5456

57+
RT_OFFLOAD_API_GROUP_END
58+
5559
} // namespace Fortran::runtime::io
5660
#endif // FLANG_RT_RUNTIME_NON_TBP_DIO_H_

flang-rt/include/flang-rt/runtime/work-queue.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ namespace Fortran::runtime {
7474
class Terminator;
7575
class WorkQueue;
7676

77+
RT_OFFLOAD_API_GROUP_BEGIN
78+
7779
// Ticket worker base classes
7880

7981
template <typename TICKET> class ImmediateTicketRunner {
@@ -361,6 +363,7 @@ class DescriptorIoTicket
361363
: ImmediateTicketRunner<DescriptorIoTicket>(*this),
362364
Elementwise{descriptor}, io_{io}, table_{table},
363365
anyIoTookPlace_{anyIoTookPlace} {}
366+
364367
RT_API_ATTRS int Begin(WorkQueue &);
365368
RT_API_ATTRS int Continue(WorkQueue &);
366369
RT_API_ATTRS bool &anyIoTookPlace() { return anyIoTookPlace_; }
@@ -551,5 +554,7 @@ class WorkQueue {
551554
TicketList *firstFree_{static_};
552555
};
553556

557+
RT_OFFLOAD_API_GROUP_END
558+
554559
} // namespace Fortran::runtime
555560
#endif // FLANG_RT_RUNTIME_WORK_QUEUE_H_

flang-rt/lib/runtime/edit-input.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
namespace Fortran::runtime::io {
1717

18+
RT_OFFLOAD_API_GROUP_BEGIN
19+
1820
RT_API_ATTRS bool EditIntegerInput(
1921
IoStatementState &, const DataEdit &, void *, int kind, bool isSigned);
2022

@@ -49,5 +51,7 @@ extern template RT_API_ATTRS bool EditCharacterInput(
4951
extern template RT_API_ATTRS bool EditCharacterInput(
5052
IoStatementState &, const DataEdit &, char32_t *, std::size_t);
5153

54+
RT_OFFLOAD_API_GROUP_END
55+
5256
} // namespace Fortran::runtime::io
5357
#endif // FLANG_RT_RUNTIME_EDIT_INPUT_H_

flang-rt/lib/runtime/edit-output.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
namespace Fortran::runtime::io {
2727

28+
RT_OFFLOAD_API_GROUP_BEGIN
29+
2830
// I, B, O, Z, and G output editing for INTEGER.
2931
// The DataEdit reference is const here (and elsewhere in this header) so that
3032
// one edit descriptor with a repeat factor may safely serve to edit
@@ -137,5 +139,7 @@ extern template class RealOutputEditing<10>;
137139
// TODO: double/double
138140
extern template class RealOutputEditing<16>;
139141

142+
RT_OFFLOAD_API_GROUP_END
143+
140144
} // namespace Fortran::runtime::io
141145
#endif // FLANG_RT_RUNTIME_EDIT_OUTPUT_H_

flang-rt/lib/runtime/unit.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ extern RT_VAR_ATTRS ExternalFileUnit *defaultOutput; // unit 6
4646
extern RT_VAR_ATTRS ExternalFileUnit *errorOutput; // unit 0 extension
4747
RT_OFFLOAD_VAR_GROUP_END
4848

49+
RT_OFFLOAD_API_GROUP_BEGIN
50+
4951
#if defined(RT_USE_PSEUDO_FILE_UNIT)
5052
// A flavor of OpenFile class that pretends to be a terminal,
5153
// and only provides basic buffering of the output
@@ -298,5 +300,7 @@ class ChildIo {
298300
Fortran::common::optional<IoStatementState> io_;
299301
};
300302

303+
RT_OFFLOAD_API_GROUP_END
304+
301305
} // namespace Fortran::runtime::io
302306
#endif // FLANG_RT_RUNTIME_UNIT_H_

flang/include/flang/Decimal/decimal.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ enum DecimalConversionFlags {
6565
#define EXTRA_DECIMAL_CONVERSION_SPACE (1 + 1 + 2 * 16 - 1)
6666

6767
#ifdef __cplusplus
68+
69+
RT_OFFLOAD_API_GROUP_BEGIN
70+
6871
template <int PREC>
6972
RT_API_ATTRS ConversionToDecimalResult ConvertToDecimal(char *, size_t,
7073
DecimalConversionFlags, int digits, enum FortranRounding rounding,
@@ -110,6 +113,9 @@ extern template RT_API_ATTRS ConversionToBinaryResult<64> ConvertToBinary<64>(
110113
const char *&, enum FortranRounding, const char *end);
111114
extern template RT_API_ATTRS ConversionToBinaryResult<113> ConvertToBinary<113>(
112115
const char *&, enum FortranRounding, const char *end);
116+
117+
RT_OFFLOAD_API_GROUP_END
118+
113119
} // namespace Fortran::decimal
114120
extern "C" {
115121
#define NS(x) Fortran::decimal::x

0 commit comments

Comments
 (0)