Skip to content

Commit f301308

Browse files
committed
Revert "[Flang-RT] Changes required for embedded GPU LLVM IR Flang runtime (#757)"
This reverts commit 4b92bcf.
1 parent c8b3b30 commit f301308

File tree

17 files changed

+15
-81
lines changed

17 files changed

+15
-81
lines changed

flang-rt/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ if (NOT "${FLANG_RT_LIBCXX_PROVIDER}" IN_LIST FLANG_RT_SUPPORTED_PROVIDERS)
152152
endif ()
153153

154154
option(FLANG_RT_ENABLE_STATIC "Build Flang-RT as a static library." ON)
155-
option(FLANG_RT_EMBED_GPU_LLVM_IR "Build Flang-RT as GPU LLVM IR library" ON)
156-
157155
if (WIN32)
158156
# Windows DLL currently not implemented.
159157
set(FLANG_RT_ENABLE_SHARED OFF)
@@ -329,9 +327,7 @@ endif ()
329327

330328
if (FLANG_RT_INCLUDE_TESTS)
331329
add_subdirectory(test)
332-
if (NOT "${LLVM_RUNTIMES_TARGET}" MATCHES "^amdgcn|^nvptx")
333-
add_subdirectory(unittests)
334-
endif()
330+
add_subdirectory(unittests)
335331
else ()
336332
add_custom_target(check-flang-rt)
337333
endif()

flang-rt/cmake/modules/AddFlangRT.cmake

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,6 @@ function (add_flangrt_library name)
219219
# Minimum required C++ version for Flang-RT, even if CMAKE_CXX_STANDARD is defined to something else.
220220
target_compile_features(${tgtname} PRIVATE cxx_std_17)
221221

222-
# Determine which version of GPU Flang-RT we want to build:
223-
# flang_rt.hostdevice or the implicitly linked device flang_rt.runtime.
224-
if (FLANG_RT_EMBED_GPU_LLVM_IR)
225-
target_compile_definitions(${tgtname} PRIVATE EMBED_FLANG_RT_GPU_LLVM_IR)
226-
endif ()
227-
228222
# When building the flang runtime if LTO is enabled the archive file
229223
# contains LLVM IR rather than object code. Currently flang is not
230224
# LTO aware so cannot link this file to compiled Fortran code.

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
#endif
2424

2525
#if USE_PTHREADS
26-
#if (not defined(__AMDGPU__) && not defined(__NVPTX__)) || not defined(EMBED_FLANG_RT_GPU_LLVM_IR)
2726
#include <pthread.h>
28-
#endif
2927
#elif defined(_WIN32)
3028
#include "flang/Common/windows-include.h"
3129
#else
@@ -47,7 +45,6 @@ class Lock {
4745
RT_API_ATTRS void Drop() {}
4846
RT_API_ATTRS bool TakeIfNoDeadlock() { return true; }
4947
#elif USE_PTHREADS
50-
#if (not defined(__AMDGPU__) && not defined(__NVPTX__)) || not defined(EMBED_FLANG_RT_GPU_LLVM_IR)
5148
Lock() { pthread_mutex_init(&mutex_, nullptr); }
5249
~Lock() { pthread_mutex_destroy(&mutex_); }
5350
void Take() {
@@ -71,14 +68,6 @@ class Lock {
7168
isBusy_ = false;
7269
pthread_mutex_unlock(&mutex_);
7370
}
74-
#else
75-
RT_API_ATTRS void Take(){}
76-
RT_API_ATTRS bool TakeIfNoDeadlock() {return true;}
77-
RT_API_ATTRS bool Try() {return true;}
78-
RT_API_ATTRS void Drop() {}
79-
Lock() {}
80-
~Lock() {}
81-
#endif
8271
#elif defined(_WIN32)
8372
Lock() { InitializeCriticalSection(&cs_); }
8473
~Lock() { DeleteCriticalSection(&cs_); }
@@ -102,11 +91,9 @@ class Lock {
10291
#if RT_USE_PSEUDO_FILE_UNIT
10392
// No state.
10493
#elif USE_PTHREADS
105-
#if (not defined(__AMDGPU__) && not defined(__NVPTX__)) || not defined(EMBED_FLANG_RT_GPU_LLVM_IR)
10694
pthread_mutex_t mutex_{};
10795
volatile bool isBusy_{false};
10896
volatile pthread_t holder_;
109-
#endif
11097
#elif defined(_WIN32)
11198
CRITICAL_SECTION cs_;
11299
#else

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@
4242
#define RT_USE_PSEUDO_FILE_UNIT 1
4343
#endif
4444

45-
#if (defined(__AMDGPU__) || defined(__NVPTX__)) && defined(EMBED_FLANG_RT_GPU_LLVM_IR)
46-
// Use the pseudo lock and pseudo file unit implementations
47-
// for the device.
48-
#define RT_USE_PSEUDO_LOCK 1
49-
#define RT_USE_PSEUDO_FILE_UNIT 1
50-
#endif
51-
5245
namespace Fortran::runtime {
5346

5447
class Terminator;

flang-rt/lib/runtime/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,7 @@ else ()
179179
endif ()
180180

181181
if ("${LLVM_RUNTIMES_TARGET}" MATCHES "^amdgcn|^nvptx")
182-
if (FLANG_RT_EMBED_GPU_LLVM_IR)
183-
set(sources ${supported_sources} ${gpu_sources})
184-
else ()
185-
set(sources ${gpu_sources})
186-
endif ()
182+
set(sources ${gpu_sources})
187183
elseif(FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
188184
set(sources ${supported_sources})
189185
else ()

flang-rt/lib/runtime/assign.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "flang/Runtime/assign.h"
10-
#if (not defined(__AMDGPU__) && not defined(__NVPTX__)) || not defined(EMBED_FLANG_RT_GPU_LLVM_IR)
1110
#include "flang/Runtime/stop.h"
12-
#endif
1311
#include "flang-rt/runtime/assign-impl.h"
1412
#include "flang-rt/runtime/derived.h"
1513
#include "flang-rt/runtime/descriptor.h"
@@ -864,6 +862,17 @@ void RTDEF(AssignPolymorphic)(Descriptor &to, const Descriptor &from,
864862
PolymorphicLHS);
865863
}
866864

865+
#if defined(OMP_OFFLOAD_BUILD)
866+
// To support a recently added use of variant in the OpenMP offload build,
867+
// added an abort wrapper which calls the flang-rt FortranAAbort.
868+
// Avoids the following linker error:
869+
// ld.lld: error: undefined symbol: abort
870+
// >>> referenced by /tmp/device_aassign.amdgcn.gfx90a-34a7ed.img.lto.o:(std::__throw_bad_variant_access(char const*))
871+
extern "C" void abort(void) {
872+
RTNAME(Abort)();
873+
}
874+
#endif
875+
867876
RT_EXT_API_GROUP_END
868877
} // extern "C"
869878
} // namespace Fortran::runtime

flang-rt/lib/runtime/descriptor.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
#include "flang-rt/runtime/descriptor.h"
1010
#include "ISO_Fortran_util.h"
11-
#if (not defined(__AMDGPU__) && not defined(__NVPTX__)) || not defined(EMBED_FLANG_RT_GPU_LLVM_IR)
1211
#include "memory.h"
13-
#endif
1412
#include "flang-rt/runtime/allocator-registry.h"
1513
#include "flang-rt/runtime/derived.h"
1614
#include "flang-rt/runtime/stat.h"

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,11 +569,7 @@ static RT_API_ATTRS void RaiseFPExceptions(
569569
#ifdef feraisexcept // a macro in some environments; omit std::
570570
#define RAISE feraiseexcept
571571
#else
572-
#if (not defined(__AMDGPU__) && not defined(__NVPTX__)) || not defined (EMBED_FLANG_RT_GPU_LLVM_IR)
573572
#define RAISE std::feraiseexcept
574-
#else
575-
#define RAISE
576-
#endif
577573
#endif
578574
#endif // !defined(RT_DEVICE_COMPILATION)
579575

flang-rt/lib/runtime/environment.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#if (not defined (__AMDGPU__) && not defined(__NVPTX__)) || not defined (EMBED_FLANG_RT_GPU_LLVM_IR)
109
#include "flang-rt/runtime/environment.h"
1110
#include "environment-default-list.h"
1211
#include "memory.h"
@@ -335,4 +334,3 @@ bool RTNAME(RegisterConfigureEnv)(
335334
} // extern "C"
336335

337336
} // namespace Fortran::runtime
338-
#endif

flang-rt/lib/runtime/file.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#if (not defined(__AMDGPU__) && not defined(__NVPTX__)) || not defined(EMBED_FLANG_RT_GPU_LLVM_IR)
109
#include "flang-rt/runtime/file.h"
1110
#include "flang-rt/runtime/memory.h"
1211
#include "flang-rt/runtime/tools.h"
@@ -487,4 +486,3 @@ RT_API_ATTRS std::int64_t SizeInBytes(const char *path) {
487486
#endif // defined(RT_DEVICE_COMPILATION)
488487

489488
} // namespace Fortran::runtime::io
490-
#endif

0 commit comments

Comments
 (0)