Skip to content

Commit 6959b30

Browse files
edwinsolisfsyurkevi
authored andcommitted
Added jit benchmark image, fixed some format issues
1 parent 37cf686 commit 6959b30

9 files changed

+48
-16
lines changed

docs/TODO

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
TODO
2+
=====
3+
4+
- Add docstring to function image processing
5+
- Change to where the Restructured Files for the undocumented functions point to (currently some point to docs in the arrayfire-binary-python-wrapper)
6+
- Add more detail to the constants and classes
7+
- Add more information in the python installation section

docs/afjit.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,45 @@
66
# following function.
77

88
import arrayfire as af
9+
import time
10+
11+
samples = int(9e8)
12+
x = af.randu((samples))
13+
y = af.randu((samples))
914

1015
def pi_no_jit(x, y, samples):
1116
temp = x * x
12-
temp.eval()
17+
af.eval(temp)
1318
temp += y * y
14-
temp.eval()
19+
af.eval(temp)
1520
temp = af.sqrt(temp)
16-
temp.eval()
21+
af.eval(temp)
1722
temp = temp < 1
18-
temp.eval()
23+
af.eval(temp)
1924
return 4.0 * af.sum(temp) / samples
2025

2126
def pi_jit(x, y, samples):
2227
temp = af.sqrt(x * x + y * y) < 1
23-
temp.eval()
28+
af.eval(temp)
2429
return 4.0 * af.sum(temp) / samples
2530

31+
# Print device info
32+
af.info()
33+
34+
# Time JIT code
35+
start = time.perf_counter()
36+
res = pi_jit(x, y, samples)
37+
af.sync()
38+
end = time.perf_counter()
39+
40+
print("jit:", end - start, res)
41+
af.device_gc()
42+
43+
# Time no JIT code
44+
start = time.perf_counter()
45+
res = pi_no_jit(x, y, samples)
46+
af.sync()
47+
end = time.perf_counter()
48+
print("no jit:", end - start, res)
49+
2650
# [jit-endsnippet]

docs/arrayfirejitcodegeneration.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ Specifically, as JIT is an integral feature of the ArrayFire library, it cannot
3434

3535
Timing these two implementations results in the following performance benchmark:
3636

37-
**Add Picture**
37+
.. image:: images/afjit_benchmark.png
38+
:alt: Benchmark Results
39+
:align: center
40+
:class: responsive-img
3841

39-
The above figure depicts the execution time (abscissa) as a function of the number of samples (ordinate) for the two implementations discussed above.
42+
The above figure depicts the execution time as a function of the number of samples for the two implementations discussed above.
4043

41-
When the number of samples is small, the execution time of pi_no_jit is dominated by the launch of multiple kernels and the execution time pi_jit is dominated by on-the-fly compilation of the JIT code required to launch a single kernel. Even with this JIT compilation time, pi_jit outperforms pi_no_jit by 1.4-2.0X for smaller sample sizes.
44+
When the number of samples is small (less than 100k samples), the execution time of pi_no_jit is dominated by the launch of multiple kernels and the execution time pi_jit is dominated by on-the-fly compilation of the JIT code required to launch a single kernel. Even with this JIT compilation time, pi_jit outperforms pi_no_jit by 1.4-2.0X for smaller sample sizes.
4245

43-
When the number of samples is large, both the kernel launch overhead and the JIT code creation are no longer the limiting factors – the kernel’s computational load dominates the execution time. Here, the pi_jit outperforms pi_no_jit by 2.0-2.7X.
46+
When the number of samples is large (more than 1 million samples), both the kernel launch overhead and the JIT code creation are no longer the limiting factors – the kernel’s computational load dominates the execution time. Here, the pi_jit outperforms pi_no_jit by 3-25X.
4447

4548
The number of applications that benefit from the JIT code generation is significant. The actual performance benefits are also application-dependent.

docs/configuringarrayfireenvironment.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ deallocations, and garbage collection.
150150
All trace statements printed to the console have a suffix with the following
151151
pattern.
152152

153-
**[category][Seconds since Epoch][Thread Id][source file relative path] \<Message\>**
153+
:literal:`[category][Seconds since Epoch][Thread Id][source file relative path] \<Message\>`
154154

155155
`AF_OPENCL_SHOW_BUILD_INFO`
156156
***************************

docs/images/afjit_benchmark.png

43.1 KB
Loading

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ Welcome to ArrayFire's documentation!
1111
:caption: The Basics
1212

1313
overview
14+
tutorial
1415
installation
1516
gettingstarted
16-
tutorial
1717

1818
.. toctree::
1919
:maxdepth: 1

docs/installation.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ Once the ArrayFire has been downloaded, run the installer.
2020

2121
The installer offers the option to automatically add ArrayFire to the path for all users. If the installer did not do this, simply append :literal:`%AF_PATH%/lib` to the PATH variable so that the loader can find ArrayFire DLLs.
2222

23-
For more information on using ArrayFire on Windows, visit the following page.
24-
2523

2624
.. _Linux:
2725

@@ -131,5 +129,6 @@ Getting help
131129
* Google Groups: https://groups.google.com/forum/#!forum/arrayfire-users
132130
* ArrayFire Services: `Consulting <https://arrayfire.com/consulting/>`_ | `Training <https://arrayfire.com/training/>`_
133131
* ArrayFire Blogs: http://arrayfire.com/blog/
132+
* ArrayFire `Contact Us <https://arrayfire.com/company/#contact-us>`_
134133
135134

docs/mathematical_operations_functions.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ Functions for performing fundamental arithmetic and mathematical operations on a
109109
- Elementwise minimum between two arrays
110110
* - :doc:`af.mod() <functions/mod>`
111111
- Calculate the modulus.
112-
* - :doc:`af.moddims() <functions/moddims>`
113-
- Modify the dimensions of an array without changing the order of its elements.
114112
* - :doc:`af.mul() <functions/mul>`
115113
- Elementwise multiply.
116114
* - :doc:`af.neg() <functions/neg>`
@@ -141,6 +139,7 @@ Functions for performing fundamental arithmetic and mathematical operations on a
141139
- Evaluate the square root.
142140
* - :doc:`af.sub() <functions/sub>`
143141
- Elementwise subtraction.
142+
* - :doc:`af.tan() <functions/tan>`
144143
- Evaluate the tangent function.
145144
* - :doc:`af.tanh() <functions/tanh>`
146145
- Evaluate the hyperbolic tangent function.

docs/special_functions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Functions for convolutions, creating and applying specific types of filters, com
1818
* - :doc:`af.canny() <functions/canny>`
1919
- Canny Edge Detector.
2020
* - :doc:`af.convolve1() <functions/convolve1>`
21-
- Convolution Integral for one dimensional data.
21+
- Convolution Integral for one dimensional data.
2222
* - :doc:`af.convolve2() <functions/convolve2>`
2323
- Convolution Integral for two dimensional data.
2424
* - :doc:`af.convolve2_gradient_nn() <functions/convolve2_gradient_nn>`

0 commit comments

Comments
 (0)