-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick updates for docs 6.2 (#429)
* Bump jinja2 from 3.1.3 to 3.1.4 in /docs/sphinx (#406) Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.3 to 3.1.4. - [Release notes](https://github.com/pallets/jinja/releases) - [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - [Commits](pallets/jinja@3.1.3...3.1.4) --- updated-dependencies: - dependency-name: jinja2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update replace.h (#413) correct CopyAssignable link error * Update Read the Docs configuration to use Python 3.10 and latest rocm-docs-core (#419) * Add documentation for HIP backend policies (par, par_nosync) (#421) The HIP backend defines two policies (hip_rocprim::par, hip_rocprim::par_nosync) that may be of interest to users who want more control over the way their algorithms are executing. The par_nosync policy is currently documented in the thrust changelog, but is not part of the rocThrust documentation. This change adds a description of par and par_nosync to the documentation, along with a code example. * Bump urllib3 from 2.2.1 to 2.2.2 in /docs/sphinx (#423) Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.2.1 to 2.2.2. - [Release notes](https://github.com/urllib3/urllib3/releases) - [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst) - [Commits](urllib3/urllib3@2.2.1...2.2.2) --- updated-dependencies: - dependency-name: urllib3 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add changelog entry and documentation regarding hipGraph support (#412) Currently, we don't support calling rocThrust API function from within hipGraphs. Add a note to the changelog, and a page to the documentation to indicate this. * Bump rocm-docs-core from 1.4.0 to 1.4.1 in /docs/sphinx (#425) Bumps [rocm-docs-core](https://github.com/ROCm/rocm-docs-core) from 1.4.0 to 1.4.1. - [Release notes](https://github.com/ROCm/rocm-docs-core/releases) - [Changelog](https://github.com/ROCm/rocm-docs-core/blob/develop/CHANGELOG.md) - [Commits](ROCm/rocm-docs-core@v1.4.0...v1.4.1) --- updated-dependencies: - dependency-name: rocm-docs-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Sam Wu <22262939+samjwu@users.noreply.github.com> Co-authored-by: Wayne Franz <wayfranz@amd.com>
- Loading branch information
1 parent
f3a28e4
commit ae693f6
Showing
8 changed files
with
172 additions
and
62 deletions.
There are no files selected for viewing
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
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
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,87 @@ | ||
.. meta:: | ||
:description: rocThrust documentation and API reference | ||
:keywords: rocThrust, ROCm, API, reference, execution policy | ||
|
||
.. _hip-execution-policies: | ||
|
||
****************************************** | ||
Execution Policies | ||
****************************************** | ||
|
||
In addition to the standard Thrust execution policies (eg. ``thrust::host``, ``thrust::device``, ``thrust::seq``), | ||
rocThrust's HIP backend provides the following: | ||
|
||
* ``hip_rocprim::par`` - This policy causes algorithms to be launched in a parallel configuration. | ||
API calls are blocking (synchronous with respect to the host). | ||
|
||
* ``hip_rocprim::par_nosync`` - This policy tells Thrust that algorithms may avoid synchronization | ||
barriers when it is possible to do so. As a result, algorithms may be launched asynchronously with | ||
respect to the host. This can allow you to perform other host-side work while the algorithms | ||
are running on the device. If you use this policy, you must synchronize before accessing results | ||
on the host side. | ||
|
||
The example below illustrates the behaviour of these two policies. | ||
|
||
.. code-block:: cpp | ||
#include <hip/hip_runtime_api.h> | ||
#include <thrust/host_vector.h> | ||
#include <thrust/device_vector.h> | ||
#include <thrust/random.h> | ||
#include <thrust/count.h> | ||
#include <thrust/reduce.h> | ||
#include <thrust/system/hip/execution_policy.h> | ||
#include <ctime> | ||
#include <iostream> | ||
int main(int argc, char* argv[]) | ||
{ | ||
// Allocate host and device vectors. | ||
const size_t size = 100; | ||
thrust::host_vector<int> h_vec(size); | ||
thrust::device_vector<int> d_vec1(size); | ||
thrust::device_vector<int> d_vec2(size); | ||
// Fill host vector with random values. | ||
const int limit = 100; | ||
auto seed = std::time(nullptr); | ||
thrust::default_random_engine rng(seed); | ||
for (int i = 0; i < size; i++) | ||
h_vec[i] = rng() % limit; | ||
// Copy data to device vectors. | ||
d_vec1 = h_vec; | ||
d_vec2 = h_vec; | ||
// Launch some algorithms using the hip_rocprim::par policy. | ||
// The calls below are blocking with respect to the host. | ||
// However, internally, each algorithm will run in parallel. | ||
auto par_policy = thrust::hip_rocprim::par; | ||
int count = thrust::count(par_policy, d_vec1.begin(), d_vec1.end(), 50); | ||
int reduction = thrust::reduce(par_policy, d_vec2.begin(), d_vec2.end()); | ||
// Print out the results. | ||
std::cout << "par results:" << std::endl; | ||
std::cout << "count: " << count << std::endl; | ||
std::cout << "reduction: " << reduction << std::endl; | ||
// Launch the algorithms using the hip_rocprim::par_nosync policy. | ||
// These calls may not be blocking with respect to the host. | ||
auto nosync_policy = thrust::hip_rocprim::par_nosync; | ||
int count2 = thrust::count(nosync_policy, d_vec1.begin(), d_vec1.end(), 50); | ||
int reduction2 = thrust::reduce(nosync_policy, d_vec2.begin(), d_vec2.end()); | ||
// We can perform other host-side work here, and it may overlap with the | ||
// algorithms launched above. | ||
DoHostSideWork(); | ||
// We must synchronize before accessing the results on the host. | ||
hipDeviceSynchronize(); | ||
// Print out the results. | ||
std::cout << "par_nosync results:" << std::endl; | ||
std::cout << "count: " << count2 << std::endl; | ||
std::cout << "reduction: " << reduction2 << std::endl; | ||
return 0; | ||
} |
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,24 @@ | ||
.. meta:: | ||
:description: rocThrust documentation and API reference | ||
:keywords: rocThrust, ROCm, API, reference, hipGraph | ||
|
||
.. _hipgraph-support: | ||
|
||
****************************************** | ||
hipGraph Support | ||
****************************************** | ||
Currently, rocThrust does not support the use of ``hipGraphs``. ``hipGraphs`` are not allowed to contain any synchronous | ||
function calls or barriers. Thrust API functions are blocking (synchronous with respect to the host) by default. | ||
|
||
Thrust does provide asynchronous versions of a number of algorithms. These are contained in the ``thrust::async`` namespace | ||
(see the headers in ``rocThrust/thrust/async/``). However, these algorithms operate asynchronously by returning futures. | ||
This approach is different from the form of asynchronous execution required within ``hipGraphs``, which must be achieved by | ||
issuing calls into a user-defined ``hipStream``. | ||
|
||
While it is possible to create execution policies that encourage Thrust API algorithms to execute within a user-defined stream, | ||
(eg. ``thrust::hip_rocprim::par.on(stream)``), this is not enough to guarentee that synchronization will not occur within | ||
a given algorithm. This is because some Thrust functions require execution policies to be passed in at compile time (via template | ||
arguments) rather than at runtime. Since streams must be created at runtime, there is no way to pass these functions a stream. | ||
Adding a stream argument to such functions breaks compatibility with the Thrust API. | ||
|
||
For these reasons, we recommend that you do not use hipGraphs together with rocThrust code. |
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
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 +1 @@ | ||
rocm-docs-core==0.38.1 | ||
rocm-docs-core==1.4.1 |
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
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