Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Commit ee7d92d

Browse files
compnerddan-zheng
andauthoredDec 21, 2020
documentation: improve explanation for CMake based builds (#1161)
documentation: improve explanation for CMake based builds This adds additional documentation on how to avoid building X10 if the prebuilt option is being used or if it has been built previously manually. Add a note about CMake defaulting to building a copy of X10 if one is not provided. Additionally, add examples of what the flags should look like for various cases to avoid building X10 by default with CMake. Co-authored-by: Dan Zheng <danielzheng@google.com>
1 parent fd04e95 commit ee7d92d

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed
 

‎Documentation/Development.md

+42-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ tensor computation in the TensorFlow Swift APIs. This library builds atop of
1515
the TensorFlow library, using the XLA compiler to perform optimizations over
1616
the tensor computation.
1717

18+
In the case that a prebuilt option is not available for your platform, note that
19+
by default the CMake based build will build a copy of X10 if it does not find
20+
one.
21+
1822
#### (Option 1) Use a prebuilt version of X10
1923

2024
You can use a prebuilt version of the X10 library for building the TensorFlow
@@ -247,23 +251,55 @@ $ swift test -Xcc -I/Library/tensorflow-2.4.0/usr/include -Xlinker -L/Library/te
247251

248252
#### CMake
249253

250-
*Note: CMake is required for building X10 modules.*
251-
252-
In-tree builds are not supported.
254+
*Note: In-tree builds are not supported.*
253255

254256
*Note: To enable CUDA support, run `export TF_NEED_CUDA=1` before the steps below.*
255257

256258
*Note: If `swiftc` is not in your `PATH`, you must specify the path to it using
257259
`-D CMAKE_Swift_COMPILER=`.*
258260

259-
This will build X10 as part of the build. Ensure that you do not have the
260-
x10 modules in the toolchain that you are using to develop here.
261+
By default, CMake will build X10 if it is not informed of where the library is
262+
available. If you wish to build X10 as part of the CMake build, ensure that you
263+
do not have the X10 modules in the toolchain that you are using to develop here
264+
(more explicitly, use a stock toolchain rather than a TensorFlow toolchain).
261265

262266
```shell
263-
cmake -B out -G Ninja -S swift-apis
267+
cmake -B out -G Ninja -S swift-apis -D CMAKE_BUILD_TYPE=Release
264268
cmake --build out
265269
```
266270

271+
If you have a prebuilt version of the X10 library that you wish to use (i.e. you
272+
are using one of the prebuilt libraries referenced above or have built it
273+
yourself above), you can inform CMake where to find the build time components of
274+
the library (SDK contents) and avoid building X10.
275+
276+
The path to these libraries is not fixed and depends on your machine setup.
277+
You should substitute the paths with the appropriate values. In the example
278+
commands below, we assume that the library is packaged in a traditional Unix
279+
style layout and placed in `/Library/tensorflow-2.4.0`.
280+
281+
Because the library name differs based on the platform, the following examples
282+
may help identify what the flags should look like for the target that you are
283+
building for.
284+
285+
macOS:
286+
287+
```shell
288+
-D X10_LIBRARY=/Library/tensorflow-2.4.0/usr/lib/libx10.dylib -D X10_INCLUDE_DIRS=/Library/tensorflow-2.4.0/usr/include
289+
```
290+
291+
Windows:
292+
293+
```shell
294+
-D X10_LIBRARY=/Library/tensorflow-2.4.0/usr/lib/x10.lib -D X10_INCLUDE_DIRS=/Library/tensorflow-2.4.0/usr/include
295+
```
296+
297+
Other Unix systems (e.g. Linux, BSD, Android, etc):
298+
299+
```shell
300+
-D X10_LIBRARY=/Library/tensorflow-2.4.0/usr/lib/libx10.so -D X10_INCLUDE_DIRS=/Library/tensorflow-2.4.0/usr/include
301+
```
302+
267303
To run tests:
268304

269305
*Note: To view failure output, run `export CTEST_OUTPUT_ON_FAILURE=1` before

0 commit comments

Comments
 (0)