forked from uxlfoundation/oneTBB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Get Started Guide (uxlfoundation#1110)
- Loading branch information
Showing
15 changed files
with
254 additions
and
131 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
.. _Get_Started_Guide: | ||
|
||
Get Started with |short_name| | ||
============================== | ||
Get Started with |full_name| | ||
============================= | ||
|
||
.. include:: intro_gsg.rst | ||
|short_name| Get Started Guide provides the information you need to begin working with oneTBB. | ||
It is helpful for new users of parallel programming and experienced developers that want to improve code performance. | ||
|
||
.. include:: system_requirements.rst | ||
It is recommended for you to have a basic knowledge of C++ programming and some experience with parallel programming concepts. | ||
|
||
.. include:: before_beginning_and_example.rst | ||
|
||
.. include:: hybrid_cpu_support.rst | ||
To start using oneTBB, follow the next steps: | ||
********************************************* | ||
|
||
Find more | ||
********* | ||
#. Learn what :ref:`oneTBB is<intro>` and see the :ref:`System Requirements<system_requirements>`. | ||
#. :ref:`Install oneTBB<installation>`. | ||
#. Run your program using oneTBB following the :ref:`Next Steps <next_steps>`. | ||
#. Learn how to :ref:`Integrate oneTBB into your project <integrate>` using CMake* and pkg-config tool. | ||
#. See :ref:`oneTBB Samples <samples>`. | ||
|
||
|
||
|
||
|
||
|
||
See our `documentation <https://oneapi-src.github.io/oneTBB/>`_ to learn more about |short_name|. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
.. _integrate: | ||
|
||
Integrate oneTBB | ||
================ | ||
|
||
If you want to improve the performance and scalability of your application, you can integrate oneTBB into your project. | ||
For example, you may want to integrate oneTBB if your application needs to process large amounts of data in parallel. | ||
|
||
To integrate oneTBB, you need to: | ||
|
||
* Link oneTBB with the project's source code. | ||
* Provide the necessary compiler and linker flags. | ||
|
||
However, you can use CMake* and the pkg-config tool to simplify the process of integrating oneTBB into your project and handling its dependencies. | ||
See the instructions below to learn how to use the tools. | ||
|
||
CMake* | ||
******* | ||
|
||
CMake* is a cross-platform build tool that helps you manage dependencies and build systems. | ||
Integrating oneTBB into your project using CMake*: | ||
|
||
* Simplifies the process of building and linking against the library. | ||
* Ensures that your project can be built and run on multiple platforms. | ||
* Lets you manage oneTBB dependencies. | ||
|
||
To add oneTBB to another project using CMake*, add the following commands to your ``CMakeLists.txt`` file: | ||
|
||
.. code-block:: | ||
`find_package(TBB REQUIRED)` | ||
`target_link_libraries(my_executable TBB::tbb)` | ||
After that, configure your project with CMake* as usual. | ||
|
||
|
||
Compile a Program Using pkg-config | ||
*********************************** | ||
|
||
The pkg-config tool is used to simplify the compilation line by retrieving information about packages | ||
from special metadata files. It helps avoid large hard-coded paths and makes compilation more portable. | ||
|
||
To compile a test program ``test.cpp`` with oneTBB on Linux* OS, | ||
provide the full path to search for included files and libraries, or provide a line as the following: | ||
|
||
.. code-block:: | ||
g++ -o test test.cpp $(pkg-config --libs --cflags tbb) | ||
Where: | ||
|
||
``--cflags`` provides oneTBB library include path: | ||
|
||
.. code-block:: | ||
$ pkg-config --cflags tbb | ||
-I<path-to>/tbb/latest/lib/pkgconfig/../..//include | ||
``--libs`` provides the Intel(R) oneTBB library name and the search path to find it: | ||
|
||
.. code-block:: | ||
$ pkg-config –libs tbb | ||
-L<path to>tbb/latest/lib/pkgconfig/../..//lib/intel64/gcc4.8 -ltbb | ||
.. note:: | ||
|
||
For Windows* OS, additionally, use the ``--msvc-syntax`` option flag that converts the compiling and linking flags in an appropriate mode. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.. _intro: | ||
|
||
What oneTBB Is | ||
============== | ||
|
||
|full_name| is a runtime-based parallel programming model for C++ code that uses threads. | ||
The template-based runtime library can help you harness the latent performance of multi-core processors. | ||
|
||
oneTBB enables you to simplify parallel programming by breaking computation into parallel running tasks. Within a single process, | ||
parallelism is carried out through threads, an operating system mechanism that allows the same or different sets of instructions | ||
to be executed simultaneously. Using threads can make your program work faster and more efficiently. | ||
|
||
Here you can see one of the possible executions of tasks by threads. | ||
|
||
.. figure:: Images/how-oneTBB-works.png | ||
:scale: 70% | ||
:align: center | ||
|
||
Use oneTBB to write scalable applications that: | ||
|
||
* Specify logical parallel structure instead of threads. | ||
* Emphasize data-parallel programming. | ||
* Take advantage of concurrent collections and parallel algorithms. | ||
|
||
oneTBB supports nested parallelism and load balancing. It means that you can use the library without worrying about oversubscribing a system, which happens when more tasks are assigned to a system than it can handle efficiently. | ||
|
||
oneTBB is used in different areas, such as scientific simulations, gaming, data analysis, etc. | ||
|
||
It is available as a stand-alone product and as part of the |base_tk|. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
.. _next_steps: | ||
|
||
Next Steps | ||
=========== | ||
|
||
After installing oneTBB, complete the following steps to start working with the library. | ||
|
||
Set the Environment Variables | ||
***************************** | ||
|
||
After installing |short_name|, set the environment variables: | ||
|
||
#. Go to the oneTBB installation directory. | ||
|
||
#. Set the environment variables using the script in ``<install_dir>`` by running: | ||
|
||
* On Linux* OS: ``vars.{sh|csh} in <install_dir>/tbb/latest/env`` | ||
* On Windows* OS: ``vars.bat in <install_dir>/tbb/latest/env`` | ||
|
||
|
||
Build and Run a Sample | ||
********************** | ||
|
||
.. tabs:: | ||
|
||
.. group-tab:: Windows* OS | ||
|
||
#. Create a new C++ project using your IDE. In this example, Microsoft* Visual Studio* Code is used. | ||
#. Create an ``example.cpp`` file in the project. | ||
#. Copy and paste the code below. It is a typical example of a |short_name| algorithm. The sample calculates a sum of all integer numbers from 1 to 100. | ||
|
||
.. code:: | ||
#include <oneapi/tbb.h> | ||
int main (){ | ||
int sum = oneapi::tbb::parallel_reduce( | ||
oneapi::tbb::blocked_range<int>(1,101), 0, | ||
[](oneapi::tbb::blocked_range<int> const& r, int init) -> int { | ||
for (int v = r.begin(); v != r.end(); v++) { | ||
init += v; | ||
} | ||
return init; | ||
}, | ||
[](int lhs, int rhs) -> int { | ||
return lhs + rhs; | ||
} | ||
); | ||
printf("Sum: %d\n", sum); | ||
return 0; | ||
} | ||
#. Open the ``tasks.json`` file in the ``.vscode`` directory and paste the following lines to the args array: | ||
|
||
* ``-Ipath/to/oneTBB/include`` to add oneTBB include directory. | ||
* ``path/to/oneTBB/`` to add oneTBB. | ||
|
||
For example: | ||
|
||
.. code-block:: | ||
{ | ||
"tasks": [ | ||
{ | ||
"label": "build & run", | ||
"type": "cppbuild", | ||
"group": { | ||
"args": [ | ||
"/IC:\\Program Files (x86)\\Intel\\oneAPI\\tbb\\2021.9.0\\include", | ||
"C:\\Program Files (x86)\\Intel\\oneAPI\\tbb\\2021.9.0\\lib\\ia32\\vc14\\tbb12.lib" | ||
#. Build the project. | ||
#. Run the example. | ||
#. If oneTBB is configured correctly, the output displays ``Sum: 5050``. | ||
|
||
.. group-tab:: Linux* OS | ||
|
||
#. Create an ``example.cpp`` file in the project. | ||
#. Copy and paste the code below. It is a typical example of a |short_name| algorithm. The sample calculates a sum of all integer numbers from 1 to 100. | ||
|
||
.. code:: | ||
#include <oneapi/tbb.h> | ||
int main(){ | ||
int sum = oneapi::tbb::parallel_reduce( | ||
oneapi::tbb::blocked_range<int>(1,101), 0, | ||
[](oneapi::tbb::blocked_range<int> const& r, int init) -> int { | ||
for (int v = r.begin(); v != r.end(); v++) { | ||
init += v; | ||
} | ||
return init; | ||
}, | ||
[](int lhs, int rhs) -> int { | ||
return lhs + rhs; | ||
} | ||
); | ||
printf("Sum: %d\n", sum); | ||
return 0; | ||
} | ||
#. Compile the code using oneTBB. For example, | ||
|
||
.. code-block:: | ||
g++ -std=c++11 example.cpp -o example -ltbb | ||
#. Run the executable: | ||
|
||
.. code-block:: | ||
./example | ||
#. If oneTBB is configured correctly, the output displays ``Sum: 5050``. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.