Skip to content

Commit 112eb04

Browse files
committed
Update docs
1 parent 48e200a commit 112eb04

File tree

3 files changed

+50
-46
lines changed

3 files changed

+50
-46
lines changed

flang-rt/README.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
77
-->
88

9-
# Fortran Runtime (flang-rt)
9+
# Fortran Runtime (Flang-RT)
1010

11-
Flang-rt is the runtime library for code emitted by the Flang compiler
11+
Flang-RT is the runtime library for code emitted by the Flang compiler
1212
(https://flang.llvm.org).
1313

1414

1515
## Getting Started
1616

17-
There are two build modes for the flang-rt. The bootstrap build, also
17+
There are two build modes for the Flang-RT. The bootstrap build, also
1818
called the in-tree build, and the runtime-only build, also called the
1919
out-of-tree build.
2020
Not to be confused with the terms
@@ -34,31 +34,31 @@ Requirements:
3434
### Bootstrap/In-Tree Build
3535

3636
The bootstrap build will first build Clang and Flang, then use these compilers
37-
to compile flang-rt. CMake will create a secondary build tree in
38-
configured with these just-built compilers. The secondary build will reuse the
39-
same build options (Flags, Debug/Release, ...) as the primary build. It will
40-
also ensure that once built, flang-rt is found by Flang from either
37+
to compile Flang-RT. CMake will create a secondary build tree
38+
configured to use these just-built compilers. The secondary build will reuse
39+
the same build options (Flags, Debug/Release, ...) as the primary build.
40+
It will also ensure that once built, Flang-RT is found by Flang from either
4141
the build- or install-prefix. To enable, add `flang-rt` to
4242
`LLVM_ENABLE_RUNTIMES`:
4343

4444
```bash
45-
cmake -S <path-to-llvm-project>/llvm \
46-
-DNinja \
47-
-DLLVM_ENABLE_PROJECTS=flang \
48-
-DLLVM_ENABLE_RUNTIMES=flang-rt \
45+
cmake -S <path-to-llvm-project-source>/llvm \
46+
-GNinja \
47+
-DLLVM_ENABLE_PROJECTS="clang;flang" \
48+
-DLLVM_ENABLE_RUNTIMES=flang-rt \
4949
...
5050
```
5151

52-
It is recommended to enable building OpenMP alongside Flang and flang-rt
52+
It is recommended to enable building OpenMP alongside Flang and Flang-RT
5353
as well. This will build `omp_lib.mod` required to use OpenMP from Fortran.
5454
Building Compiler-RT may also be required, particularly on platforms that do
5555
not provide all C-ABI functionality (such as Windows).
5656

5757
```bash
58-
cmake -S <path-to-llvm-project>/llvm \
59-
-DNinja \
60-
-DCMAKE_BUILD_TYPE=Release \
61-
-DLLVM_ENABLE_PROJECTS="flang;openmp" \
58+
cmake -S <path-to-llvm-project-source>/llvm \
59+
-GNinja \
60+
-DCMAKE_BUILD_TYPE=Release \
61+
-DLLVM_ENABLE_PROJECTS="clang;flang;openmp" \
6262
-DLLVM_ENABLE_RUNTIMES="compiler-rt;flang-rt" \
6363
...
6464
```
@@ -85,16 +85,16 @@ CMake's environment introspection to find a C, C++, and Fortran compiler. The
8585
compiler to be used can be controlled using CMake's standard mechanisms such as
8686
`CMAKE_CXX_COMPILER`, `CMAKE_CXX_COMPILER`, and `CMAKE_Fortran_COMPILER`.
8787
`CMAKE_Fortran_COMPILER` must be `flang` built from the same Git commit as
88-
flang-rt to ensure they are using the same ABI. The C and C++ compiler
88+
Flang-RT to ensure they are using the same ABI. The C and C++ compiler
8989
can be any compiler supporting the same ABI.
9090

9191
In addition to the compiler, the build be able to find LLVM development tools
92-
such as `lit` and `FileCheck` that are not found in an LLVM's install directory.
93-
Use `CMAKE_BINARY_DIR` to point to directory where LLVM has been built.
94-
A simple build configuration might look like the following:
92+
such as `lit` and `FileCheck` that are not found in an LLVM's install
93+
directory. Use `CMAKE_BINARY_DIR` to point to directory where LLVM has
94+
been built. A simple build configuration might look like the following:
9595

9696
```bash
97-
cmake -S <path-to-llvm-project>/runtimes \
97+
cmake -S <path-to-llvm-project-source>/runtimes \
9898
-GNinja \
9999
-DLLVM_BINARY_DIR=<path-to-llvm-builddir> \
100100
-DCMAKE_Fortran_COMPILER=<path-to-llvm-builddir>/bin/flang \
@@ -107,16 +107,16 @@ The `CMAKE_Fortran_COMPILER_WORKS` parameter must be set because otherwise CMake
107107
will test whether the Fortran compiler can compile and link programs which will
108108
obviously fail without a runtime library available yet.
109109

110-
Building flang-rt for cross-compilation triple, the target triple can
110+
Building Flang-RT for cross-compilation triple, the target triple can
111111
be selected using `LLVM_DEFAULT_TARGET_TRIPLE` AND `LLVM_RUNTIMES_TARGET`.
112-
Of course, flang-rt can be built multiple times with different build
112+
Of course, Flang-RT can be built multiple times with different build
113113
configurations, but have to be located manually when using with the Flang
114114
driver using the `-L` option.
115115

116116
A more complete build configuration could be the following:
117117

118118
```bash
119-
cmake -S <path-to-llvm-project>/runtimes \
119+
cmake -S <path-to-llvm-project-source>/runtimes \
120120
-GNinja \
121121
-DCMAKE_BUILD_TYPE=Release \
122122
-DCMAKE_INSTALL_PREFIX="${HOME}/local" \
@@ -134,7 +134,7 @@ cmake -S <path-to-llvm-project>/runtimes \
134134

135135
## Configuration Option Reference
136136

137-
Flang-rt has the followign configuration options. This is in
137+
Flang-RT has the followign configuration options. This is in
138138
addition to the build options the LLVM_ENABLE_RUNTIMES mechanism and
139139
CMake itself provide.
140140

@@ -153,11 +153,11 @@ CMake itself provide.
153153

154154
* `FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT` (values: `"CUDA"`,`"OpenMP"`, `""` default: `""`)
155155

156-
When set to `CUDA`, builds flang-rt with experimental support for GPU
156+
When set to `CUDA`, builds Flang-RT with experimental support for GPU
157157
accelerators using CUDA. `CMAKE_CUDA_COMPILER` must be set if not
158158
automatically detected by CMake. `nvcc` as well as `clang` are supported.
159159

160-
When set to `OpenMP`, builds flang-rt with experimental support for
160+
When set to `OpenMP`, builds Flang-RT with experimental support for
161161
GPU accelerators using OpenMP offloading. Only Clang is supported for
162162
`CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER`.
163163

@@ -170,7 +170,7 @@ CMake itself provide.
170170
(no `CMAKE_CUDA_COMPILER`).
171171

172172

173-
### CUDA Support
173+
### Exprimental CUDA Support
174174

175175
With `-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA`, the following
176176
additional configuration options become available.
@@ -186,13 +186,13 @@ additional configuration options become available.
186186
default.
187187

188188

189-
### OpenMP Offload Support
189+
### Exprimental OpenMP Offload Support
190190

191191
With `-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=OpenMP`, the following
192192
additional configuration options become available.
193193

194194
* `FLANG_RT_DEVICE_ARCHITECTURES` (default: `"all"`)
195195

196-
A list of device architectures that flang-rt is supporting.
196+
A list of device architectures that Flang-RT is going to support.
197197
If `"all"` uses a pre-defined list of architectures. Same purpose as
198198
`LIBOMPTARGET_DEVICE_ARCHITECTURES` from liboffload.

flang-rt/lib/CufRuntime/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
#
77
#===------------------------------------------------------------------------===#
88

9-
# Phony build target that does not include the CUDA version.
10-
add_custom_target(CufRuntime)
11-
129
# libCufRuntime depends on a certain version of CUDA. To be able to have
1310
# multiple build of this library with different CUDA version, the version is
1411
# added to the library name.
@@ -23,7 +20,6 @@ add_flangrt_library(${CUFRT_LIBNAME}
2320
memory.cpp
2421
registration.cpp
2522
)
26-
add_dependencies(CufRuntime ${CUFRT_LIBNAME})
2723
target_include_directories(${CUFRT_LIBNAME} PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
2824

2925
if (BUILD_SHARED_LIBS)
@@ -37,3 +33,8 @@ target_link_libraries(${CUFRT_LIBNAME}
3733
flang_rt
3834
${CUDA_RT_TARGET}
3935
)
36+
37+
# Phony build target that does not include the CUDA version.
38+
add_custom_target(CufRuntime)
39+
add_dependencies(CufRuntime ${CUFRT_LIBNAME})
40+

flang/docs/GettingStarted.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Flang runtime can be built for accelerators in experimental mode, i.e.
197197
complete enabling is WIP. CUDA and OpenMP target offload builds
198198
are currently supported.
199199

200-
#### Building out-of-tree (Runtime-only build)
200+
#### Building out-of-tree (runtime-only build)
201201

202202
##### CUDA build
203203
Clang with NVPTX backend and NVCC compilers are supported.
@@ -209,15 +209,15 @@ mkdir build_flang_runtime
209209
cd build_flang_runtime
210210

211211
cmake \
212-
-DLLVM_ENABLE_RUNTIMES=flang_rt \
212+
-DLLVM_ENABLE_RUNTIMES=flang-rt \
213213
-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
214214
-DCMAKE_CUDA_ARCHITECTURES=80 \
215215
-DCMAKE_C_COMPILER=clang \
216216
-DCMAKE_CXX_COMPILER=clang++ \
217217
-DCMAKE_CUDA_COMPILER=clang \
218218
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
219219
../runtimes/
220-
make -j`nprocs` flang_rt
220+
make flang-rt
221221
```
222222

223223
Note that the used version of `clang` must [support](https://releases.llvm.org/16.0.0/tools/clang/docs/ReleaseNotes.html#cuda-support)
@@ -232,7 +232,7 @@ mkdir build_flang_runtime
232232
cd build_flang_runtime
233233

234234
cmake \
235-
-DLLVM_ENABLE_RUNTIMES=flang_rt \
235+
-DLLVM_ENABLE_RUNTIMES=flang-rt \
236236
-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
237237
-DCMAKE_CUDA_ARCHITECTURES=80 \
238238
-DCMAKE_C_COMPILER=clang \
@@ -241,7 +241,7 @@ cmake \
241241
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
242242
../runtimes/
243243

244-
make -j`nprocs` flang_rt
244+
make flang-rt
245245
```
246246

247247
Note that `nvcc` might limit support to certain
@@ -260,7 +260,7 @@ build config:
260260

261261
For example:
262262
```bash
263-
-DLLVM_ENABLE_RUNTIMES=flang_rt \
263+
-DLLVM_ENABLE_RUNTIMES=flang-rt \
264264
-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
265265
-DCMAKE_CUDA_ARCHITECTURES=80 \
266266
-DCMAKE_C_COMPILER=clang \
@@ -272,7 +272,7 @@ For example:
272272

273273
Or:
274274
```bash
275-
-DLLVM_ENABLE_RUNTIMES=flang_rt \
275+
-DLLVM_ENABLE_RUNTIMES=flang-rt \
276276
-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA \
277277
-DCMAKE_CUDA_ARCHITECTURES=80 \
278278
-DCMAKE_C_COMPILER=gcc \
@@ -282,8 +282,11 @@ Or:
282282
../llvm
283283
```
284284

285-
Normal `make -j`nprocs` check-flang` will work with such CMake configuration.
286-
Consider a lower value instead of `nprocs` appropriate to the available RAM.
285+
Normal `make check-flang` will work with such CMake configuration.
286+
Consider building in parallel using the `-j<jobs>` flag, where `<jobs>` is a
287+
number low enough for all build jobs to fit into the available RAM. Using
288+
the number of harware threads (`nprocs`) is likely too much for most
289+
commodity computers.
287290

288291
##### OpenMP target offload build
289292
Only Clang compiler is currently supported.
@@ -295,14 +298,14 @@ mkdir build_flang_runtime
295298
cd build_flang_runtime
296299

297300
cmake \
298-
-DLLVM_ENABLE_RUNTIMES=flang_rt \
301+
-DLLVM_ENABLE_RUNTIMES=flang-rt \
299302
-DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT="OpenMP" \
300303
-DCMAKE_C_COMPILER=clang \
301304
-DCMAKE_CXX_COMPILER=clang++ \
302-
-DFLANG_RT_DEVICE_ARCHITECTURES="all" \
305+
-DFLANG_RT_DEVICE_ARCHITECTURES=all \
303306
../runtimes/
304307

305-
make -j`nprocs` flang_rt
308+
make flang-rt
306309
```
307310

308311
The result of the build is a "device-only" library, i.e. the host

0 commit comments

Comments
 (0)