Skip to content

Commit

Permalink
quick start and integrations guides for the docs (#47)
Browse files Browse the repository at this point in the history
Authors:
  - Corey J. Nolet (https://github.com/cjnolet)

Approvers:
  - Ben Frederickson (https://github.com/benfred)
  - Jake Awe (https://github.com/AyodeAwe)

URL: #47
  • Loading branch information
cjnolet authored Mar 13, 2024
1 parent bfb7f57 commit 9c0e380
Show file tree
Hide file tree
Showing 12 changed files with 559 additions and 369 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ _xml
# sphinx
_html
_text
docs/source/_static/rust

# clang tooling
compile_commands.json
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

## Useful Resources

- [cuVS Reference Documentation](https://docs.rapids.ai/api/cuvs/stable/): API Documentation.
- [cuVS Getting Started](./docs/source/quick_start.md): Getting started with RAFT.
- [Build and Install cuVS](./docs/source/build.md): Instructions for installing and building cuVS.
- [Example Notebooks](./notebooks): Example jupyer notebooks
- [Code Examples](https://github.com/rapidsai/cuvs/tree/HEAD/examples): Self-contained Code Examples.
- [API Reference Documentation](https://docs.rapids.ai/api/cuvs/nightly/api_docs): API Documentation.
- [Getting Started Guide](https://docs.rapids.ai/api/cuvs/nightly/getting_started): Getting started with RAFT.
- [Build and Install Guide](https://docs.rapids.ai/api/cuvs/nightly/build): Instructions for installing and building cuVS.
- [RAPIDS Community](https://rapids.ai/community.html): Get help, contribute, and collaborate.
- [GitHub repository](https://github.com/rapidsai/cuvs): Download the cuVS source code.
- [Issue tracker](https://github.com/rapidsai/cuvs/issues): Report issues or request features.
Expand Down
4 changes: 2 additions & 2 deletions docs/source/api_docs.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
API Documentation
=================
API Reference
=============

.. toctree::
:maxdepth: 1
Expand Down
90 changes: 90 additions & 0 deletions docs/source/basics.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
cuVS API Basics
===============

- `Memory management`_
- `Resource management`_

Memory management
-----------------

Centralized memory management allows flexible configuration of allocation strategies, such as sharing the same CUDA memory pool across library boundaries. cuVS uses the [RMM](https://github.com/rapidsai/rmm) library, which eases the burden of configuring different allocation strategies globally across GPU-accelerated libraries.

RMM currently has APIs for C++ and Python.

C++
^^^

Here's an example of configuring RMM to use a pool allocator in C++ (derived from the RMM example `here <https://github.com/rapidsai/rmm?tab=readme-ov-file#example>`_):

.. code-block:: c++

rmm::mr::cuda_memory_resource cuda_mr;
// Construct a resource that uses a coalescing best-fit pool allocator
// With the pool initially half of available device memory
auto initial_size = rmm::percent_of_free_device_memory(50);
rmm::mr::pool_memory_resource<rmm::mr::cuda_memory_resource> pool_mr{&cuda_mr, initial_size};
rmm::mr::set_current_device_resource(&pool_mr); // Updates the current device resource pointer to `pool_mr`
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource(); // Points to `pool_mr`

Python
^^^^^^

And the corresponding code in Python (derived from the RMM example `here <https://github.com/rapidsai/rmm?tab=readme-ov-file#memoryresource-objects>`_):

.. code-block:: python
import rmm
pool = rmm.mr.PoolMemoryResource(
rmm.mr.CudaMemoryResource(),
initial_pool_size=2**30,
maximum_pool_size=2**32)
rmm.mr.set_current_device_resource(pool)
Resource management
-------------------

cuVS uses an API from the `RAFT <https://github.com/rapidsai/raft>`_ library of ML and data mining primitives to centralize and reuse expensive resources, such as memory management. The below code examples demonstrate how to create these resources for use throughout this guide.

See RAFT's `resource API documentation <https://docs.rapids.ai/api/raft/nightly/cpp_api/core_resources/>`_ for more information.

C
^

.. code-block:: c
#include <cuda_runtime.h>
#include <cuvs/core/c_api.h>
cuvsResources_t res;
cuvsResourcesCreate(&res);
// ... do some processing ...
cuvsResourcesDestroy(res);
C++
^^^

.. code-block:: c++

#include <raft/core/device_resources.hpp>

raft::device_resources res;

Python
^^^^^^

.. code-block:: python
import pylibraft
res = pylibraft.common.DeviceResources()
Rust
^^^^

.. code-block:: rust
let res = cuvs::Resources::new()?;
178 changes: 0 additions & 178 deletions docs/source/build.md

This file was deleted.

Loading

0 comments on commit 9c0e380

Please sign in to comment.