Skip to content

Commit cc94322

Browse files
committed
Move tutorial pages into a mdbook
1 parent cef7538 commit cc94322

23 files changed

+1987
-164
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ exclude = [
1515
"arrayfire/*",
1616
]
1717

18+
[package.metadata.docs.rs]
19+
rustdoc-args = [ "--html-in-header", "./scripts/mathjax.script", ]
20+
1821
[features]
1922
algorithm = []
2023
arithmetic = []

doc/external_docs.css

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

generate_docs.sh

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

scripts/generate_documentation.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
# this script meant to be run from the root of arrayfire-rust
4+
5+
cargo rustdoc -- --html-in-header ./scripts/mathjax.script
6+
7+
mdbook build tutorials-book && cp -r tutorials-book/book ./target/doc/arrayfire/
File renamed without changes.

src/lib.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,25 @@
77
//! not be concerned about low-level optimizations that are frequently required to
88
//! achieve high throughput on most parallel architectures.
99
10-
//! This crate provides Rust bindings for the ArrayFire library. Given below table shows the rust bindings compatability with ArrayFire upstream. If you find any bugs, please report them on [github](https://github.com/arrayfire/arrayfire-rust/issues).
10+
//! This crate provides Rust bindings for the ArrayFire library. Given below table shows
11+
//! the rust bindings compatability with ArrayFire upstream. If you find any bugs,
12+
//! please report them on [github](https://github.com/arrayfire/arrayfire-rust/issues).
1113
//!
1214
//! | arrayfire-rust crate | ArrayFire Upstream |
13-
//! |:--------------|:---------|
14-
//! | M.m.p1 | M.m.p2 |
15+
//! |:--------------------:|:------------------:|
16+
//! | M.m.p1 | M.m.p2 |
1517
//!
1618
//! Only, Major(M) & Minor(m) version numbers need to match. *p1* and *p2*
1719
//! are patch/fix updates for `arrayfire-rust` & `ArrayFire` respectively,
1820
//! and they don't need to match.
1921
//!
20-
//! ## Tutorials
21-
//!
22-
//! - [Getting Started with ArrayFire](./getting_started.html)
23-
//! - [Introduction to Vectorization](./vectorization.html)
24-
//! - [Array and Matrix Manipulation](./array_and_matrix_manipulation.html)
25-
//! - [Indexing](./indexing.html)
26-
//! - [Configure ArrayFire Environment](./configuring_arrayfire_environment.html)
22+
//! Please go through our [tutorials](./book/index.html) book for more explanations on how to
23+
//! use ArrayFire to speedup your code.
2724
2825
#![doc(
2926
html_logo_url = "http://www.arrayfire.com/logos/arrayfire_logo_symbol.png",
3027
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
31-
html_root_url = "http://arrayfire.com/docs/rust"
28+
html_root_url = "http://arrayfire.org/arrayfire-rust/arrayfire/index.html"
3229
)]
3330
#![warn(missing_docs)]
3431
#![allow(non_camel_case_types)]

tutorials-book/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
book

tutorials-book/book.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[book]
2+
authors = ["Pradeep Garigipati"]
3+
language = "en"
4+
multilingual = false
5+
src = "src"
6+
title = "Rust Wrapper for ArrayFire HPC Library"
7+
8+
[output.html]
9+
theme = "src/theme"
10+
mathjax-support = true
11+
default-theme = "ayu"

tutorials-book/src/SUMMARY.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Summary
2+
3+
- [Getting Started](./getting_started.md)
4+
- [Introduction to Vectorization](./vectorization.md)
5+
- [Array and Matrix Manipulation](./array_and_matrix_manipulation.md)
6+
- [Indexing](./indexing.md)
7+
- [Configuring ArrayFire Runtime Environment](./configuring_arrayfire_environment.md)

doc/array_and_matrix_manipulation.md renamed to tutorials-book/src/array_and_matrix_manipulation.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
% Array and Matrix Manipulation
1+
# Array and Matrix Manipulation
22

33
ArrayFire provides several different methods for manipulating arrays and matrices.
44
The functionality includes:
@@ -16,13 +16,13 @@ Below we provide several examples of these functions and their use.
1616

1717
### moddims()
1818

19-
The [moddims](./fn.moddims.html) function changes the dimensions of an array without
19+
The [moddims](../fn.moddims.html) function changes the dimensions of an array without
2020
changing its data or order. Note that this function modifies only the _metadata_
2121
associated with the array. It does not modify the content of the array.
2222
Here is an example of moddims() converting an 8x1 array into a 2x4 and then
2323
back to a 8x1:
2424

25-
```rust
25+
```rust,noplaypen
2626
a [8 1 1 1]
2727
1.0000
2828
2.0000
@@ -53,7 +53,7 @@ let out = moddims(&a, a.elements(), 1, 1, 1);
5353

5454
### flat()
5555

56-
The [flat](./fn.flat.html) function flattens an array to one dimension:
56+
The [flat](../fn.flat.html) function flattens an array to one dimension:
5757

5858
```
5959
a [3 3 1 1]
@@ -76,11 +76,11 @@ flat(&a)
7676

7777
### flip()
7878

79-
The [flip](./fn.flip.html) function flips the contents of an array along a
79+
The [flip](../fn.flip.html) function flips the contents of an array along a
8080
chosen dimension. In the example below, we show the 5x2 array flipped
8181
along the zeroth (i.e. within a column) and first (e.g. across rows) axes:
8282

83-
```rust
83+
```rust,noplaypen
8484
a [5 2 1 1]
8585
1.0000 6.0000
8686
2.0000 7.0000
@@ -105,12 +105,12 @@ flip(a, 1) [5 2 1 1]
105105

106106
### join()
107107

108-
The [join](./fn.join.html), [join_many](./fn.join_many.html) functions can be
108+
The [join](../fn.join.html), [join_many](../fn.join_many.html) functions can be
109109
used to join arrays along a specific dimension.
110110

111111
Here is an example of how to use join an array to itself:
112112

113-
```rust
113+
```rust,noplaypen
114114
a [5 1 1 1]
115115
1.0000
116116
2.0000
@@ -140,11 +140,11 @@ join(1, a, a) [5 2 1 1]
140140

141141
### reorder()
142142

143-
The [reorder](./fn.reorder.html) function modifies the order of data within an array by
143+
The [reorder](../fn.reorder.html) function modifies the order of data within an array by
144144
exchanging data according to the change in dimensionality. The linear ordering
145145
of data within the array is preserved.
146146

147-
```rust
147+
```rust,noplaypen
148148
a [2 2 3 1]
149149
1.0000 3.0000
150150
2.0000 4.0000
@@ -181,10 +181,10 @@ reorder(&a, 2, 0, 1)
181181

182182
### shift()
183183

184-
The [shift](./fn.shift.html) function shifts data in a circular buffer fashion along a
184+
The [shift](../fn.shift.html) function shifts data in a circular buffer fashion along a
185185
chosen dimension. Consider the following example:
186186

187-
```rust
187+
```rust,noplaypen
188188
a [3 5 1 1]
189189
0.0000 0.0000 0.0000 0.0000 0.0000
190190
3.0000 4.0000 5.0000 1.0000 2.0000
@@ -205,11 +205,11 @@ shift(&a, -1, 2 )
205205

206206
### tile()
207207

208-
The [tile](./fn.tile.html) function repeats an array along the specified dimension.
208+
The [tile](../fn.tile.html) function repeats an array along the specified dimension.
209209
For example below we show how to tile an array along the zeroth and first
210210
dimensions of an array:
211211

212-
```rust
212+
```rust,noplaypen
213213
a [3 1 1 1]
214214
1.0000
215215
2.0000
@@ -254,10 +254,10 @@ tile(a, tile_dims) [3 2 3 1]
254254

255255
### transpose()
256256

257-
The [transpose](./fn.transpose.html) function performs a standard matrix transpose. The input
257+
The [transpose](../fn.transpose.html) function performs a standard matrix transpose. The input
258258
array must have the dimensions of a 2D-matrix.
259259

260-
```rust
260+
```rust,noplaypen
261261
a [3 3 1 1]
262262
1.0000 3.0000 3.0000
263263
2.0000 1.0000 3.0000

doc/configuring_arrayfire_environment.md renamed to tutorials-book/src/configuring_arrayfire_environment.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
% Configuring Arrayfire Environment
1+
# Configuring Arrayfire Environment
22

33
Following are the list of environment and runtime configurations that will help enhance
44
your experience with ArrayFire.
55

6-
# AF_PATH
6+
## AF_PATH
77

88
This is the path with ArrayFire gets installed, ie. the includes and libs are
99
present in this directory. You can use this variable to add include paths and
1010
libraries to your projects.
1111

12-
# AF_PRINT_ERRORS
12+
## AF_PRINT_ERRORS
1313

1414
When AF_PRINT_ERRORS is set to 1, the exceptions thrown are more verbose and
1515
detailed. This helps in locating the exact failure.
@@ -18,10 +18,10 @@ detailed. This helps in locating the exact failure.
1818
AF_PRINT_ERRORS=1 ./myprogram
1919
```
2020

21-
# AF_CUDA_DEFAULT_DEVICE
21+
## AF_CUDA_DEFAULT_DEVICE
2222

2323
Use this variable to set the default CUDA device. Valid values for this
24-
variable are the device identifiers shown when [af::info](./fn.info.html) is run.
24+
variable are the device identifiers shown when [af::info](../fn.info.html) is run.
2525

2626
```
2727
AF_CUDA_DEFAULT_DEVICE=1 ./myprogram
@@ -30,19 +30,19 @@ AF_CUDA_DEFAULT_DEVICE=1 ./myprogram
3030
Note: af::setDevice call in the source code will take precedence over this
3131
variable.
3232

33-
# AF_OPENCL_DEFAULT_DEVICE
33+
## AF_OPENCL_DEFAULT_DEVICE
3434

3535
Use this variable to set the default OpenCL device. Valid values for this
36-
variable are the device identifiers shown when [af::info](./fn.info.html) is run.
36+
variable are the device identifiers shown when [af::info](../fn.info.html) is run.
3737

3838
```
3939
AF_OPENCL_DEFAULT_DEVICE=1 ./myprogram
4040
```
4141

42-
Note: [af::set_device](./fn.set_device.html) call in the source code will take precedence over this
42+
Note: [af::set_device](../fn.set_device.html) call in the source code will take precedence over this
4343
variable.
4444

45-
# AF_OPENCL_DEFAULT_DEVICE_TYPE
45+
## AF_OPENCL_DEFAULT_DEVICE_TYPE
4646

4747
Use this variable to set the default OpenCL device type. Valid values for this
4848
variable are: CPU, GPU, ACC (Accelerators).
@@ -53,9 +53,9 @@ When set, the first device of the specified type is chosen as default device.
5353
AF_OPENCL_DEFAULT_DEVICE_TYPE=CPU ./myprogram
5454
```
5555

56-
Note: `AF_OPENCL_DEFAULT_DEVICE` and [af::set_device](./fn.set_device.html) takes precedence over this variable.
56+
Note: `AF_OPENCL_DEFAULT_DEVICE` and [af::set_device](../fn.set_device.html) takes precedence over this variable.
5757

58-
# AF_OPENCL_DEVICE_TYPE
58+
## AF_OPENCL_DEVICE_TYPE
5959

6060
Use this variable to only choose OpenCL devices of specified type. Valid values for this
6161
variable are:
@@ -71,7 +71,7 @@ When set, the remaining OpenCL device types are ignored by the OpenCL backend.
7171
AF_OPENCL_DEVICE_TYPE=CPU ./myprogram
7272
```
7373

74-
# AF_OPENCL_CPU_OFFLOAD
74+
## AF_OPENCL_CPU_OFFLOAD
7575

7676
When ArrayFire runs on devices with unified memory with the host (ie.
7777
`CL_DEVICE_HOST_UNIFIED_MENORY` is true for the device) then certain functions
@@ -92,13 +92,13 @@ Prior to v3.4, CPU Offload functionality was used only when the user set
9292
From v3.4 onwards, CPU Offload is enabled by default and is disabled only when
9393
`AF_OPENCL_CPU_OFFLOAD=0` is set.
9494

95-
# AF_OPENCL_SHOW_BUILD_INFO
95+
## AF_OPENCL_SHOW_BUILD_INFO
9696

9797
This variable is useful when debuggin OpenCL kernel compilation failures. When
9898
this variable is set to 1, and an error occurs during a OpenCL kernel
9999
compilation, then the log and kernel are printed to screen.
100100

101-
# AF_DISABLE_GRAPHICS
101+
## AF_DISABLE_GRAPHICS
102102

103103
Setting this variable to 1 will disable window creation when graphics
104104
functions are being called. Disabling window creation will disable all other
@@ -109,12 +109,12 @@ without displays. When graphics calls are run on such machines, they will
109109
print warning about window creation failing. To suppress those calls, set this
110110
variable.
111111

112-
# AF_SYNCHRONOUS_CALLS
112+
## AF_SYNCHRONOUS_CALLS
113113

114114
When this environment variable is set to 1, ArrayFire will execute all
115115
functions synchronously.
116116

117-
# AF_SHOW_LOAD_PATH
117+
## AF_SHOW_LOAD_PATH
118118

119119
When using the Unified backend, if this variable is set to 1, it will show the
120120
path where the ArrayFire backend libraries are loaded from.
@@ -123,7 +123,7 @@ If the libraries are loaded from system paths, such as PATH or LD_LIBRARY_PATH
123123
etc, then it will print "system path". If the libraries are loaded from other
124124
paths, then those paths are shown in full.
125125

126-
# AF_MEM_DEBUG
126+
## AF_MEM_DEBUG
127127

128128
When AF_MEM_DEBUG is set to 1 (or anything not equal to 0), the caching mechanism in the memory manager is disabled.
129129
The device buffers are allocated using native functions as needed and freed when going out of scope.
@@ -134,27 +134,27 @@ When the environment variable is not set, it is treated to be non zero.
134134
AF_MEM_DEBUG=1 ./myprogram
135135
```
136136

137-
# AF_MAX_BUFFERS
137+
## AF_MAX_BUFFERS
138138

139139
When AF_MAX_BUFFERS is set, this environment variable specifies the maximum number of buffers allocated before garbage collection kicks in.
140140

141141
Please note that the total number of buffers that can exist simultaneously can be higher than this number. This variable tells the garbage collector that it should free any available buffers immediately if the treshold is reached.
142142

143143
When not set, the default value is 1000.
144144

145-
# AF_OPENCL_MAX_JIT_LEN
145+
## AF_OPENCL_MAX_JIT_LEN
146146

147147
When set, this environment variable specifies the maximum height of the OpenCL JIT tree after which evaluation is forced.
148148

149149
The default value, as of v3.4, is 50 on OSX, 100 everywhere else. This value was 20 for older versions.
150150

151-
# AF_CUDA_MAX_JIT_LEN
151+
## AF_CUDA_MAX_JIT_LEN
152152

153153
When set, this environment variable specifies the maximum height of the CUDA JIT tree after which evaluation is forced.
154154

155155
The default value, as of v3.4, 100. This value was 20 for older versions.
156156

157-
# AF_CPU_MAX_JIT_LEN
157+
## AF_CPU_MAX_JIT_LEN
158158

159159
When set, this environment variable specifies the maximum length of the CPU JIT tree after which evaluation is forced.
160160

0 commit comments

Comments
 (0)