### Install stdgpu using Provided Script Source: https://stotko.github.io/stdgpu/getting_started/building_from_source.html Installs the compiled stdgpu library using the provided installation script. ```bash bash tools/install.sh Release ``` -------------------------------- ### Install stdgpu from Build Directory Source: https://stotko.github.io/stdgpu/getting_started/building_from_source.html Installs the compiled stdgpu library to the system after building from the build directory. ```bash cmake --install build --config Release ``` -------------------------------- ### Install Documentation Dependencies Source: https://stotko.github.io/stdgpu/development/contributing/documentation.html Install the necessary Python packages for building the documentation with Sphinx. Ensure you are in the project's root directory. ```bash pip install -r docs/requirements.txt ``` -------------------------------- ### Build Documentation with CMake Source: https://stotko.github.io/stdgpu/development/contributing/documentation.html Build the project documentation using CMake after installing dependencies. This command generates the documentation files. ```bash cmake --build build --target stdgpu_doc --parallel 8 ``` -------------------------------- ### Link Against Pre-Installed stdgpu Source: https://stotko.github.io/stdgpu/getting_started/integrating_into_your_project.html Use this snippet when stdgpu is already installed on your system. It finds the installed package and links your project target against the `stdgpu::stdgpu` target. ```cmake find_package(stdgpu REQUIRED) add_library(your_project ...) # ... # Link your project against stdgpu target_link_libraries(your_project PUBLIC stdgpu::stdgpu) ``` -------------------------------- ### Creating and Destroying Host-Device Objects Source: https://stotko.github.io/stdgpu/api/object.html Example demonstrating the creation and destruction of host and device objects using the `MyHostDeviceObjectClass` API. This pattern simplifies memory management for GPU-aware programming. ```C++ MyClass device_object = MyClass::createDeviceObject(1000); MyClass hoste_object = MyClass::createHostObject(1000); // Do something with device_object and host_object MyClass::destroyDeviceObject(device_object); MyClass::destroyHostObject(host_object); ``` -------------------------------- ### stdgpu::allocator_traits::construct Example Source: https://stotko.github.io/stdgpu/doxygen/structstdgpu_1_1allocator__traits_ae5d87a1cbef8e36523432c391504c4ac.html Demonstrates how to use the construct method to create an object at a given pointer using an allocator. This function is available for both host and device execution. ```cpp template template static STDGPU_HOST_DEVICE void stdgpu::allocator_traits< Allocator >::construct(Allocator & _a_, T * _p_, Args &&... _args_) ``` -------------------------------- ### Configure Build with CMake (Direct Command) Source: https://stotko.github.io/stdgpu/getting_started/building_from_source.html Configure the stdgpu build using CMake, specifying the build type and installation prefix. This command creates a build directory and sets up the build configuration. ```bash mkdir build cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=bin ``` -------------------------------- ### Uninstall stdgpu using Provided Script Source: https://stotko.github.io/stdgpu/getting_started/building_from_source.html Reverts the installation of stdgpu by running the uninstall script if the build directory is still present. ```bash bash tools/uninstall.sh Release ``` -------------------------------- ### Apply Code Style with Script Source: https://stotko.github.io/stdgpu/development/contributing/coding_style.html Use this shell script to reformat the codebase according to the project's style guide. This is useful for fixing formatting issues before committing. ```bash bash tools/dev/apply_code_style.sh ``` -------------------------------- ### Build stdgpu From Source (Git Submodule) Source: https://stotko.github.io/stdgpu/getting_started/integrating_into_your_project.html Integrate stdgpu as a git submodule and build it alongside your project. This method allows for disabling examples, benchmarks, and tests to reduce build time and complexity. ```cmake # Exclude unneeded parts from the build set(STDGPU_BUILD_EXAMPLES OFF CACHE INTERNAL "") set(STDGPU_BUILD_BENCHMARKS OFF CACHE INTERNAL "") set(STDGPU_BUILD_TESTS OFF CACHE INTERNAL "") add_subdirectory(stdgpu) add_library(your_project ...) # ... # Link your project against stdgpu target_link_libraries(your_project PUBLIC stdgpu::stdgpu) ``` -------------------------------- ### Build Documentation with Script Source: https://stotko.github.io/stdgpu/development/contributing/documentation.html Alternatively, use the provided shell script to build the documentation. Ensure the STDGPU_BUILD_DOCUMENTATION option is enabled during CMake configuration. ```bash bash tools/dev/build_documentation.sh ``` -------------------------------- ### stdgpu::copy_n (ExecutionPolicy) Source: https://stotko.github.io/stdgpu/doxygen/algorithm_8h_source.html Copies the first 'n' elements from an input range starting at 'begin' to an output range starting at 'output_begin'. Requires an execution policy. ```cpp template >)> OutputIt copy_n(ExecutionPolicy&& policy, InputIt begin, Size n, OutputIt output_begin); ``` -------------------------------- ### stdgpu::destroy_n Source: https://stotko.github.io/stdgpu/doxygen/memory_8h_source.html Destroys a specified number of elements starting from an iterator. ```APIDOC ## destroy_n ### Description Destroys the first `n` elements in the range starting from `first`. ### Signature ```cpp template Iterator destroy_n(ExecutionPolicy&& policy, Iterator first, Size n); ``` ### Parameters - `policy` (ExecutionPolicy&&): The execution policy to use. - `first` (Iterator): Iterator to the beginning of the range. - `n` (Size): The number of elements to destroy. ### Returns - `Iterator`: An iterator to the element immediately following the last destroyed element. ``` -------------------------------- ### stdgpu::device_begin Function Source: https://stotko.github.io/stdgpu/doxygen/iterator_8h_source.html Creates a pointer to the beginning of a given device array. ```cpp device_ptr< T > device_begin(T *device_array) Creates a pointer to the begin of the given device array. ``` -------------------------------- ### stdgpu::uninitialized_fill_n Source: https://stotko.github.io/stdgpu/doxygen/memory_8h_source.html Fills a specified number of elements starting from an iterator with a given value. ```APIDOC ## stdgpu::uninitialized_fill_n ### Description Writes the given value to into the given range using the copy constructor. ### Signature ```cpp Iterator uninitialized_fill_n(ExecutionPolicy &&policy, Iterator begin, Size n, const T &value) ``` ### Parameters * **policy** (ExecutionPolicy &&) - The execution policy. * **begin** (Iterator) - An iterator to the beginning of the range. * **n** (Size) - The number of elements to fill. * **value** (const T &) - The value to fill the elements with. ``` -------------------------------- ### stdgpu::vector::device_begin Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1vector_a69b463e7d3cfd4d50608dee6df709e61.html Creates a pointer to the begin of the device container. This overload accepts an execution policy. ```APIDOC ## device_begin() [3/4] template> template >) > | device_ptr< T > stdgpu::vector< T, Allocator >::device_begin | ( | ExecutionPolicy && | _policy_| ) Creates a pointer to the begin of the device container. Template Parameters: ExecutionPolicy| The type of the execution policy Parameters: [in]| policy| The execution policy, e.g. host or device, corresponding to the allocator Returns: A pointer to the begin of the object ``` -------------------------------- ### stdgpu::destroy Function (Count) Source: https://stotko.github.io/stdgpu/doxygen/memory_8h_source.html Destroys a specified number of objects starting from an iterator. ```cpp template >)> Iterator destroy_n(ExecutionPolicy&& policy, Iterator first, Size n); ``` -------------------------------- ### Get Dynamic Memory Type Source: https://stotko.github.io/stdgpu/doxygen/memory_8h_source.html Determines the type of memory (host, device, or invalid) an array pointer refers to. ```cpp template dynamic_memory_type get_dynamic_memory_type(T* array); ``` -------------------------------- ### stdgpu::host_begin Function Source: https://stotko.github.io/stdgpu/doxygen/iterator_8h_source.html Creates a pointer to the beginning of a given host array. ```cpp host_ptr< T > host_begin(T *host_array) Creates a pointer to the begin of the given host array. ``` -------------------------------- ### Get Size of transform_range Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1transform__range.html Returns the total number of elements in the transformed range. This can be used for pre-allocation or size-based algorithms. ```cpp STDGPU_HOST_DEVICE index64_t | size () const ``` -------------------------------- ### stdgpu::device_range::begin() Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1device__range_a3a242586f6b016bdd2e24572caf64c6a.html Returns an iterator pointing to the beginning of the device range. ```APIDOC ## ◆ begin() template | | STDGPU_HOST_DEVICE iterator stdgpu::device_range< T >::begin | ( | | ) | const --- noexcept An iterator to the begin of the range. Returns An iterator to the begin of the range ``` -------------------------------- ### stdgpu::device_begin Source: https://stotko.github.io/stdgpu/doxygen/group__iterator_ga2547330e223bdf1f9c73ee056634a4d4.html Creates a pointer to the beginning of the given device container. This function is templated to work with various container types. ```APIDOC ## stdgpu::device_begin() ### Description Creates a pointer to the begin of the given device container. ### Template Parameters * C: The type of the container. ### Parameters * _device_container_ (C&): An array (device container). ### Returns A pointer to the begin of the device container. ``` -------------------------------- ### stdgpu::copy Source: https://stotko.github.io/stdgpu/doxygen/algorithm_8h.html Copies elements from a range [begin, end) to a destination starting at output_begin, using a specified execution policy. ```APIDOC ## stdgpu::copy ### Description Copies elements from the range `[begin, end)` to the range beginning at `output_begin`. The copy operation is performed according to the specified `ExecutionPolicy`. ### Signature ```cpp template >) > OutputIt stdgpu::copy (ExecutionPolicy &&policy, InputIt begin, InputIt end, OutputIt output_begin) ``` ### Parameters * **policy** (ExecutionPolicy &&) - The execution policy to use for the copy operation. * **begin** (InputIt) - Iterator to the beginning of the input range. * **end** (InputIt) - Iterator to the end of the input range. * **output_begin** (OutputIt) - Iterator to the beginning of the destination range. ### Returns An iterator to the element following the last element copied in the destination range. ``` -------------------------------- ### Create Host and Device Arrays Source: https://stotko.github.io/stdgpu/api/memory.html Creates and initializes host and device arrays of a specified length with an optional initial value. If no value is provided, it defaults to the default-constructed object. ```cpp #include float* device_float_vector = createDeviceArray(1000, 42.0f); float* host_float_vector = createHostArray(1000, 42.0f); ``` -------------------------------- ### Function to Get Array Size Source: https://stotko.github.io/stdgpu/doxygen/iterator_8h_source.html Calculates the size of an array. An overload is provided for void* to handle generic array pointers. ```cpp template index64_t size(T* array); index64_t size(void* array); ``` -------------------------------- ### Configure Build with CMake (Provided Script) Source: https://stotko.github.io/stdgpu/getting_started/building_from_source.html Use the provided script to configure the stdgpu build for CUDA in Release mode. ```bash bash tools/backend/configure_cuda.sh Release ``` -------------------------------- ### createDeviceObject Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1unordered__map_a40dfbbdac1d4dd6fa7637c4ffedefb56.html Creates an instance of stdgpu::unordered_map on the GPU with a specified capacity and allocator. ```APIDOC ## createDeviceObject() ### Description Creates an object of this class on the GPU (device). ### Method static ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Parameters - **_capacity_** (const index_t &) - Required - The capacity of the object. - **_allocator_** (const Allocator &) - Optional - The allocator instance to use. Defaults to `Allocator()`. ### Precondition capacity > 0 ### Returns A newly created object of this class allocated on the GPU (device). ### Request Example ``` // No explicit request example provided in the source. ``` ### Response #### Success Response (200) - **unordered_map** (stdgpu::unordered_map< Key, T, Hash, KeyEqual, Allocator >) - A newly created object of this class allocated on the GPU (device). #### Response Example ``` // No explicit response example provided in the source. ``` ``` -------------------------------- ### Uninstall stdgpu using CMake Target Source: https://stotko.github.io/stdgpu/getting_started/building_from_source.html Reverts the installation of stdgpu by calling the uninstall target if the build directory is still present. ```bash cmake --build build --config Release --target uninstall ``` -------------------------------- ### stdgpu::host_begin Source: https://stotko.github.io/stdgpu/doxygen/group__iterator_gaeff91d38431463f68e8de5303ddb25a2.html Creates a constant pointer to the beginning of the given host container. This function is templated to work with various container types. ```APIDOC ## stdgpu::host_begin() ### Description Creates a constant pointer to the begin of the given host container. ### Method auto ### Parameters #### Path Parameters - **_host_container_** (const C&) - Input - An array ### Returns A constant pointer to the begin of the host container. ``` -------------------------------- ### stdgpu::uninitialized_fill_n Source: https://stotko.github.io/stdgpu/doxygen/group__memory.html Fills a specified number of elements starting from an iterator with a value without value-initialization, using a given execution policy. ```APIDOC ## stdgpu::uninitialized_fill_n ### Description Fills `n` elements starting from the iterator `begin` with copies of `value` without value-initializing the elements. Uses the specified `ExecutionPolicy`. ### Signature ```cpp template >) > Iterator | stdgpu::uninitialized_fill_n (ExecutionPolicy &&policy, Iterator begin, Size n, const T &value) ``` ### Parameters * `policy` (ExecutionPolicy&&): The execution policy to use for the operation. * `begin` (Iterator): Iterator to the beginning of the range to fill. * `n` (Size): The number of elements to fill. * `value` (const T&): The value to fill the elements with. ### Returns * Iterator: Iterator to the end of the filled range. ``` -------------------------------- ### createDeviceObject Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1unordered__set_aaa2c8ed250b2cbe7c327873101dcbcc4.html Creates an `stdgpu::unordered_set` object on the GPU with a specified capacity and allocator, utilizing an execution policy. ```APIDOC ## createDeviceObject() ### Description Creates an `stdgpu::unordered_set` object on the GPU (device). ### Method `static` ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters * **policy** (`ExecutionPolicy`) - Required - The execution policy, e.g. host or device, corresponding to the allocator. * **capacity** (`index_t`) - Required - The capacity of the object. * **allocator** (`Allocator`) - Optional - The allocator instance to use. Defaults to `Allocator()`. ### Request Example ```cpp // Example usage (assuming Key, Hash, KeyEqual, Allocator are defined) // auto my_set = stdgpu::unordered_set::createDeviceObject(policy, capacity, allocator); ``` ### Response #### Success Response * **stdgpu::unordered_set< Key, Hash, KeyEqual, Allocator >** - A newly created object of this class allocated on the GPU (device). #### Response Example ```cpp // stdgpu::unordered_set device_set = stdgpu::unordered_set::createDeviceObject(stdgpu::device_policy(), 100); ``` ``` -------------------------------- ### stdgpu::vector::device_begin Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1vector_a2aea3401cc292a32c58ecd3603ce58c9.html Creates a pointer to the begin of the device container. This overload is for execution policies and returns a const pointer. ```APIDOC ## device_begin() [4/4] template> template >) > | device_ptr< const T > stdgpu::vector< T, Allocator >::device_begin | ( | ExecutionPolicy && | _policy_| ) | const ### Description Creates a pointer to the begin of the device container. ### Parameters #### Path Parameters - **policy** (ExecutionPolicy) - in - The execution policy, e.g. host or device, corresponding to the allocator ### Returns A const pointer to the begin of the object ``` -------------------------------- ### GPU Iota Operation Source: https://stotko.github.io/stdgpu/doxygen/numeric_8h_source.html Fills a range on the GPU with sequentially increasing values starting from a given value. This is a declaration and requires an implementation. ```cpp template >)> void iota(ExecutionPolicy&& policy, Iterator begin, Iterator end, T value); ``` -------------------------------- ### stdgpu::host_begin Source: https://stotko.github.io/stdgpu/doxygen/group__iterator_ga34f43f98cd4f89db43d145fc313e9c93.html Creates a pointer to the beginning of a given host array. This is useful for initializing GPU data structures or iterators. ```APIDOC ## stdgpu::host_begin() ### Description Creates a pointer to the begin of the given host array. ### Method stdgpu::host_begin ### Signature ```cpp template host_ptr< T > stdgpu::host_begin(T * _host_array_) ``` ### Parameters #### Path Parameters - **_host_array_** (T*) - Input - An array ### Returns - **host_ptr< T >** - A pointer to the begin of the host array ``` -------------------------------- ### stdgpu::iota Source: https://stotko.github.io/stdgpu/doxygen/group__numeric.html Fills a range with sequentially increasing values, starting from a specified initial value. This function is designed to operate on the GPU. ```APIDOC ## stdgpu::iota ### Description Fills a range with sequentially increasing values, starting from a specified initial value. This function is designed to operate on the GPU. ### Method `void` ### Parameters - **policy** (ExecutionPolicy &&): The execution policy for the operation. - **begin** (Iterator): An iterator to the beginning of the range. - **end** (Iterator): An iterator to the end of the range. - **value** (T): The initial value to start filling the range with. ``` -------------------------------- ### stdgpu::fill_n (ExecutionPolicy) Source: https://stotko.github.io/stdgpu/doxygen/algorithm_8h_source.html Fills the first 'n' elements of a range starting from 'begin' with a specified value. Requires an execution policy. ```cpp template >)> Iterator fill_n(ExecutionPolicy&& policy, Iterator begin, Size n, const T& value); ``` -------------------------------- ### stdgpu::fill_n Source: https://stotko.github.io/stdgpu/doxygen/algorithm_8h.html Fills the first 'n' elements of a range starting at 'begin' with a specified value, using a specified execution policy. ```APIDOC ## stdgpu::fill_n ### Description Fills the first `n` elements of the range starting at `begin` with the specified `value`. The fill operation is performed according to the specified `ExecutionPolicy`. ### Signature ```cpp template >) > Iterator stdgpu::fill_n (ExecutionPolicy &&policy, Iterator begin, Size n, const T &value) ``` ### Parameters * **policy** (ExecutionPolicy &&) - The execution policy to use for the fill operation. * **begin** (Iterator) - Iterator to the beginning of the range. * **n** (Size) - The number of elements to fill. * **value** (const T &) - The value to fill the elements with. ### Returns An iterator to the element following the last element filled. ``` -------------------------------- ### Device Iterator Functions Source: https://stotko.github.io/stdgpu/doxygen/iterator_8h_source.html Provides functions to get device iterators (begin and end) for device arrays. These return device_ptr objects. ```cpp template device_ptr device_begin(T* device_array); template device_ptr device_end(T* device_array); template device_ptr device_begin(const T* device_array); template device_ptr device_end(const T* device_array); ``` -------------------------------- ### Copy Create Device to Host Array Source: https://stotko.github.io/stdgpu/doxygen/memory_8h_source.html Creates a new host array by copying data from a device array. Supports optional safety checks. ```cpp template [[nodiscard]] T* copyCreateDevice2HostArray(const T* device_array, const stdgpu::index64_t count, const MemoryCopy check_safety = MemoryCopy::RANGE_CHECK); ``` -------------------------------- ### Host Iterator Functions Source: https://stotko.github.io/stdgpu/doxygen/iterator_8h_source.html Provides functions to get host iterators (begin and end) for host arrays. These return host_ptr objects. ```cpp template host_ptr host_begin(T* host_array); template host_ptr host_end(T* host_array); template host_ptr host_begin(const T* host_array); template host_ptr host_end(const T* host_array); ``` -------------------------------- ### stdgpu::device_cbegin Source: https://stotko.github.io/stdgpu/doxygen/group__iterator_gab677890f4cbebfe871e2ba88c8833565.html Creates a constant pointer to the begin of the given device container. This function is templated and accepts any container type `C` that supports `device_begin`. ```APIDOC ## stdgpu::device_cbegin() [1/2] template auto stdgpu::device_cbegin(const C & _device_container_) -> decltype(device_begin(_device_container_)) Creates a constant pointer to the begin of the given device container. ### Parameters - `_device_container_` (const C&): An array (device container). ### Returns A constant pointer to the begin of the device container. ``` -------------------------------- ### Get Begin Iterator for transform_range Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1transform__range.html Returns a thrust::transform_iterator pointing to the beginning of the transformed range. This is essential for iterating over the elements after transformation. ```cpp STDGPU_HOST_DEVICE iterator | begin () const noexcept ``` -------------------------------- ### stdgpu::make_device, stdgpu::make_host Source: https://stotko.github.io/stdgpu/doxygen/group__iterator.html Helper functions to create device or host pointers from raw pointers. ```APIDOC ## stdgpu::make_device, stdgpu::make_host ### Description Helper functions to create device or host pointers from raw pointers. ### Signatures ```cpp template STDGPU_HOST_DEVICE device_ptr< T > stdgpu::make_device (T *device_array) template STDGPU_HOST_DEVICE host_ptr< T > stdgpu::make_host (T *host_array) ``` ### Parameters * `device_array` (T *) - A raw pointer to device memory. * `host_array` (T *) - A raw pointer to host memory. ``` -------------------------------- ### begin Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1unordered__map.html Returns an iterator to the beginning of the unordered_map. Overloaded for const and non-const access, and device-only execution. ```APIDOC ## begin ### Description Returns an iterator to the beginning of the unordered_map. Supports both const and non-const access, and can be executed on the device. ### Method Iterator retrieval ### Parameters None ### Returns An iterator to the first element. ``` -------------------------------- ### stdgpu::copy (ExecutionPolicy) Source: https://stotko.github.io/stdgpu/doxygen/algorithm_8h_source.html Copies elements from an input range [begin, end) to an output range starting at 'output_begin'. Requires an execution policy. ```cpp template >)> OutputIt copy(ExecutionPolicy&& policy, InputIt begin, InputIt end, OutputIt output_begin); ``` -------------------------------- ### createDeviceObject Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1unordered__set_ad85f0e80013c7f52c4cc06d794ae411a.html Creates an unordered_set object on the GPU with a specified capacity and allocator. ```APIDOC ## ◆ createDeviceObject() [1/2] template, typename KeyEqual = equal_to, typename Allocator = safe_device_allocator> | | static unordered_set stdgpu::unordered_set< Key, Hash, KeyEqual, Allocator >::createDeviceObject | ( | const index_t & | _capacity_ , --- | | const Allocator & | _allocator_ = `Allocator()` | ) static Creates an object of this class on the GPU (device) Parameters [in]| capacity| The capacity of the object --- [in]| allocator| The allocator instance to use Precondition capacity > 0 Returns A newly created object of this class allocated on the GPU (device) ``` -------------------------------- ### Get End Iterator for transform_range Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1transform__range.html Returns a thrust::transform_iterator pointing to the end of the transformed range. Used in conjunction with begin() for loop conditions. ```cpp STDGPU_HOST_DEVICE iterator | end () const noexcept ``` -------------------------------- ### Copying Data Between Host and Device Objects Source: https://stotko.github.io/stdgpu/api/object.html Illustrates how to create a copy of a device object on the host using `copyCreateDevice2HostObject`. This is crucial for transferring data between CPU and GPU memory spaces. ```C++ MyClass device_object = MyClass::createDeviceObject(1000); // Do something with device_object MyClass host_object = MyClass::copyCreateDevice2HostObject(device_object); // Do something with host_object MyClass::destroyDeviceObject(device_object); MyClass::destroyHostObject(host_object); ``` -------------------------------- ### device_range Source: https://stotko.github.io/stdgpu/doxygen/ranges_8h_source.html Represents a range of elements on the GPU. It provides iterators to access the beginning and end of the range, along with methods to get the size and check if the range is empty. ```APIDOC ## device_range ### Description Represents a range of elements on the GPU. It provides iterators to access the beginning and end of the range, along with methods to get the size and check if the range is empty. ### Template Parameters * **T**: The type of elements in the range. ### Member Types * **iterator**: `device_ptr` - An iterator to the elements in the range. * **value_type**: `typename iterator::value_type` - The type of the elements in the range. * **difference_type**: `typename iterator::difference_type` - The type used to represent the difference between two iterators. * **reference**: `typename iterator::reference` - The type used to refer to an element in the range. ### Constructors #### `device_range(T* p)` Constructor with automatic size inference from the given pointer. #### `STDGPU_HOST_DEVICE device_range(T* p, index64_t n)` Constructor that takes a pointer and the number of elements. #### `STDGPU_HOST_DEVICE device_range(iterator begin, index64_t n)` Constructor that takes a begin iterator and the number of elements. #### `STDGPU_HOST_DEVICE device_range(iterator begin, iterator end)` Constructor that takes a begin and an end iterator. ### Member Functions #### `STDGPU_HOST_DEVICE iterator begin() const noexcept` An iterator to the begin of the range. #### `STDGPU_HOST_DEVICE iterator end() const noexcept` An iterator to the end of the range. #### `STDGPU_HOST_DEVICE index64_t size() const` The size of the range. #### `[[nodiscard]] STDGPU_HOST_DEVICE bool empty() const` Checks if the range is empty. ``` -------------------------------- ### Host Precondition, Postcondition, and Assertion Macros Source: https://stotko.github.io/stdgpu/doxygen/contract_8h_source.html Macros for defining host-side preconditions, postconditions, and assertions. These expand to `STDGPU_DETAIL_HOST_CHECK` when contract checks are enabled. ```cpp #define STDGPU_DETAIL_HOST_EXPECTS(...) STDGPU_DETAIL_HOST_CHECK("Precondition", __VA_ARGS__) #define STDGPU_DETAIL_HOST_ENSURES(...) STDGPU_DETAIL_HOST_CHECK("Postcondition", __VA_ARGS__) #define STDGPU_DETAIL_HOST_ASSERT(...) STDGPU_DETAIL_HOST_CHECK("Assertion", __VA_ARGS__) ``` -------------------------------- ### insert(ValueIterator _begin, ValueIterator _end) Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1unordered__map_a6346cb21cbfb6b7770bb0e6bfc78452d.html Inserts the given range of elements into the container. This overload takes two iterators defining the start and end of the range to be inserted. ```APIDOC ## insert(ValueIterator _begin, ValueIterator _end) ### Description Inserts the given range of elements into the container. ### Method void ### Parameters #### Path Parameters - **_begin** (ValueIterator) - Required - The begin of the range - **_end** (ValueIterator) - Required - The end of the range ``` -------------------------------- ### Const Device Iterator Functions Source: https://stotko.github.io/stdgpu/doxygen/iterator_8h_source.html Provides functions to get constant device iterators (cbegin and cend) for constant device arrays. These return device_ptr objects. ```cpp template device_ptr device_cbegin(const T* device_array); template device_ptr device_cend(const T* device_array); ``` -------------------------------- ### Pointer creation functions Source: https://stotko.github.io/stdgpu/doxygen/iterator_8h_source.html Functions to create device and host pointers from raw C-style arrays. ```APIDOC ## Pointer Creation ### `make_device(T* device_array)` Creates a `device_ptr` from a raw `T*` pointer pointing to device memory. ### `make_host(T* host_array)` Creates a `host_ptr` from a raw `T*` pointer pointing to host memory. ``` -------------------------------- ### Const Host Iterator Functions Source: https://stotko.github.io/stdgpu/doxygen/iterator_8h_source.html Provides functions to get constant host iterators (cbegin and cend) for constant host arrays. These return host_ptr objects. ```cpp template host_ptr host_cbegin(const T* host_array); template host_ptr host_cend(const T* host_array); ``` -------------------------------- ### Copy Create Host to Device Array Source: https://stotko.github.io/stdgpu/doxygen/memory_8h_source.html Creates a new device array by copying data from a host array. Supports optional safety checks. ```cpp template [[nodiscard]] T* copyCreateHost2DeviceArray(const T* host_array, const stdgpu::index64_t count, const MemoryCopy check_safety = MemoryCopy::RANGE_CHECK); ``` -------------------------------- ### Build stdgpu From Source (Modern CMake FetchContent) Source: https://stotko.github.io/stdgpu/getting_started/integrating_into_your_project.html Use CMake's FetchContent module to download and build stdgpu directly from its Git repository. This method also allows disabling specific build components. ```cmake include(FetchContent) FetchContent_Declare( stdgpu GIT_REPOSITORY https://github.com/stotko/stdgpu.git GIT_TAG master ) # Exclude unneeded parts from the build set(STDGPU_BUILD_EXAMPLES OFF CACHE INTERNAL "") set(STDGPU_BUILD_BENCHMARKS OFF CACHE INTERNAL "") set(STDGPU_BUILD_TESTS OFF CACHE INTERNAL "") FetchContent_MakeAvailable(stdgpu) add_library(your_project ...) # ... # Link your project against stdgpu target_link_libraries(your_project PUBLIC stdgpu::stdgpu) ``` -------------------------------- ### stdgpu::host_begin, stdgpu::host_end, stdgpu::host_cbegin, stdgpu::host_cend Source: https://stotko.github.io/stdgpu/doxygen/group__iterator.html Functions to get iterators to the beginning and end of host memory ranges, supporting both mutable and const access. ```APIDOC ## stdgpu::host_begin, stdgpu::host_end, stdgpu::host_cbegin, stdgpu::host_cend ### Description Functions to get iterators to the beginning and end of host memory ranges, supporting both mutable and const access. ### Signatures ```cpp // For containers template auto stdgpu::host_begin (C &host_container) -> decltype(host_container.host_begin()) template auto stdgpu::host_begin (const C &host_container) -> decltype(host_container.host_begin()) template host_ptr< T > stdgpu::host_begin (T *host_array) template host_ptr< const T > stdgpu::host_begin (const T *host_array) template auto stdgpu::host_end (C &host_container) -> decltype(host_container.host_end()) template auto stdgpu::host_end (const C &host_container) -> decltype(host_container.host_end()) template host_ptr< T > stdgpu::host_end (T *host_array) template host_ptr< const T > stdgpu::host_end (const T *host_array) template auto stdgpu::host_cbegin (const C &host_container) -> decltype(host_begin(host_container)) template host_ptr< const T > stdgpu::host_cbegin (const T *host_array) template auto stdgpu::host_cend (const C &host_container) -> decltype(host_end(host_container)) template host_ptr< const T > stdgpu::host_cend (const T *host_array) ``` ### Parameters * `host_container` (C & or const C &) - A host container. * `host_array` (T * or const T *) - A pointer to a host array. ``` -------------------------------- ### stdgpu::stack Class Overview Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1stack.html Provides an overview of the stdgpu::stack class, its template parameters, and differences from std::stack. ```APIDOC ## stdgpu::stack< T, ContainerT > A generic container similar to std::stack on the GPU. ### Template Parameters * **T**: The type of the stored elements. * **ContainerT**: The type of the underlying container. ### Differences to std::stack: * `index_type` instead of `size_type`. * Manual allocation and destruction of container required. * No guaranteed valid state when reaching capacity limit. * Additional non-standard capacity functions: `full()`, `capacity()`, and `valid()`. * Several member functions missing. ``` -------------------------------- ### Allocate Memory with Hint Source: https://stotko.github.io/stdgpu/doxygen/structstdgpu_1_1allocator__traits.html Allocates raw memory for `n` elements using the provided allocator `a`, with an optional `hint` for placement. ```cpp static pointer allocate (Allocator &a, index_type n, const_void_pointer hint); ``` -------------------------------- ### stdgpu::device_begin, stdgpu::device_end, stdgpu::device_cbegin, stdgpu::device_cend Source: https://stotko.github.io/stdgpu/doxygen/group__iterator.html Functions to get iterators to the beginning and end of device memory ranges, supporting both mutable and const access. ```APIDOC ## stdgpu::device_begin, stdgpu::device_end, stdgpu::device_cbegin, stdgpu::device_cend ### Description Functions to get iterators to the beginning and end of device memory ranges, supporting both mutable and const access. ### Signatures ```cpp // For containers template auto stdgpu::device_begin (C &device_container) -> decltype(device_container.device_begin()) template auto stdgpu::device_begin (const C &device_container) -> decltype(device_container.device_begin()) template device_ptr< T > stdgpu::device_begin (T *device_array) template device_ptr< const T > stdgpu::device_begin (const T *device_array) template auto stdgpu::device_end (C &device_container) -> decltype(device_container.device_end()) template auto stdgpu::device_end (const C &device_container) -> decltype(device_container.device_end()) template device_ptr< T > stdgpu::device_end (T *device_array) template device_ptr< const T > stdgpu::device_end (const T *device_array) template auto stdgpu::device_cbegin (const C &device_container) -> decltype(device_begin(device_container)) template device_ptr< const T > stdgpu::device_cbegin (const T *device_array) template auto stdgpu::device_cend (const C &device_container) -> decltype(device_end(device_container)) template device_ptr< const T > stdgpu::device_cend (const T *device_array) ``` ### Parameters * `device_container` (C & or const C &) - A device container. * `device_array` (T * or const T *) - A pointer to a device array. ``` -------------------------------- ### Compile stdgpu with CMake (Provided Script) Source: https://stotko.github.io/stdgpu/getting_started/building_from_source.html Use the provided script to compile the stdgpu library in Release mode. ```bash bash tools/build.sh Release ``` -------------------------------- ### Create Host Array Source: https://stotko.github.io/stdgpu/doxygen/memory_8h_source.html Allocates memory on the host and initializes an array of the specified type and count. Optionally sets a default value. ```cpp template [[nodiscard]] T* createHostArray(const stdgpu::index64_t count, const T default_value = T()); ``` -------------------------------- ### stdgpu::queue::createDeviceObject Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1queue_a9160dd61252020f3f6ea4a508b79f049.html Creates an object of this class on the GPU (device). ```APIDOC ## stdgpu::queue::createDeviceObject ### Description Creates an object of this class on the GPU (device). ### Signature ```cpp template> static queue< T, ContainerT > stdgpu::queue< T, ContainerT >::createDeviceObject(const index_t & _size_) ``` ### Parameters #### Parameters - **_size_** (const index_t &) - Required - The size of managed array ### Returns A newly created object of this class allocated on the GPU (device) ``` -------------------------------- ### stdgpu::to_address Source: https://stotko.github.io/stdgpu/doxygen/group__memory_gaff8ce088add8599aea8906a71c5b2b56.html Converts a potential fancy pointer to a raw pointer. This function is useful when you need to obtain the underlying raw pointer from a smart pointer or other pointer-like object that overloads `operator->()` or has a `get()` method. ```APIDOC ## stdgpu::to_address() ### Description Converts a potential fancy pointer to a raw pointer. ### Template Parameters * `Ptr`: The fancy pointer type. ### Parameters * `_p` (const Ptr &): A fancy pointer. ### Returns The raw pointer held by the fancy pointer obtained via `operator->()` or `get()`. ``` -------------------------------- ### stdgpu::host_begin Source: https://stotko.github.io/stdgpu/doxygen/group__iterator_gaacf57ef317a4a0862456aa626b905bec.html Creates a constant pointer to the beginning of a given host array. This is useful for iterating over host data structures that will be processed on the GPU. ```APIDOC ## stdgpu::host_begin() ### Description Creates a constant pointer to the begin of the given host array. ### Method N/A (Function Signature) ### Signature `template stdgpu::host_ptr< const T > host_begin(const T * host_array)` ### Parameters #### Input Parameters - **host_array** (const T *) - The host array for which to get the beginning pointer. ### Returns - `stdgpu::host_ptr< const T >` - A constant pointer to the begin of the host array. ``` -------------------------------- ### createDeviceObject (with execution policy, capacity, and allocator) Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1unordered__map.html Creates a device-side unordered_map with a specified execution policy, capacity, and allocator. ```APIDOC ## createDeviceObject (with ExecutionPolicy) ### Description Creates a device-side unordered_map with a specified execution policy, capacity, and allocator. ### Method static ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **policy** (ExecutionPolicy &&) - Description: The execution policy to use. - **capacity** (const index_t &) - Description: The desired capacity of the unordered_map. - **allocator** (const Allocator &) - Optional - Description: The allocator to use for the unordered_map. Defaults to Allocator(). ### Request Example None ### Response #### Success Response (200) - **unordered_map** (stdgpu::unordered_map) - Description: The newly created device-side unordered_map. #### Response Example None ``` -------------------------------- ### createDeviceArray Function Source: https://stotko.github.io/stdgpu/doxygen/memory_8h_source.html Creates a new device array and initializes it with a default value. ```cpp T * createDeviceArray(const stdgpu::index64_t count, const T default_value=T()) ``` -------------------------------- ### device_cbegin() Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1vector_a5b36f0889defe3960b18f9c1414c9a5e.html Creates a pointer to the begin of the device container. This method returns a constant pointer, ensuring that the container's elements are not modified through the returned pointer. ```APIDOC ## device_cbegin() ### Description Creates a pointer to the begin of the device container. ### Method `device_cbegin()` ### Parameters This method takes no parameters. ### Returns A const pointer to the begin of the object. ``` -------------------------------- ### createDeviceObject (with execution policy, capacity, and allocator) Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1unordered__set.html Creates a device-side unordered_set with an execution policy, specified capacity, and allocator. ```APIDOC ## createDeviceObject (policy, capacity, allocator) ### Description Creates a device-side unordered_set using a specified execution policy, capacity, and an optional allocator. ### Method `template >) > static unordered_set | createDeviceObject (ExecutionPolicy &&policy, const index_t &capacity, const Allocator &allocator=Allocator())` ### Parameters #### Path Parameters - **policy** (ExecutionPolicy &&) - Description: The execution policy to use. - **capacity** (const index_t &) - Description: The desired capacity for the unordered_set. - **allocator** (const Allocator &) - Optional - Description: The allocator to use for memory management. Defaults to Allocator(). ### Response #### Success Response - **unordered_set** - The newly created device-side unordered_set object. ``` -------------------------------- ### stdgpu::vector::device_begin Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1vector_aec43b223c3575d0aca500ebe3d52cd2c.html Creates a pointer to the beginning of the device container. This method is part of the stdgpu::vector class and is used to access the first element of the vector residing on the GPU. ```APIDOC ## device_begin() [1/4] template> | device_ptr< T > stdgpu::vector< T, Allocator >::device_begin | ( | | ) | Creates a pointer to the begin of the device container. Returns A pointer to the begin of the object ``` -------------------------------- ### Run Tests with Provided Script Source: https://stotko.github.io/stdgpu/development/contributing/tests.html Utilize the provided shell script to run unit tests for a specific build configuration. This script simplifies the testing process. ```bash bash tools/run_tests.sh Release ``` -------------------------------- ### Device Precondition, Postcondition, and Assertion Macros Source: https://stotko.github.io/stdgpu/doxygen/contract_8h_source.html Macros for defining device-side preconditions, postconditions, and assertions. These expand to `STDGPU_DETAIL_DEVICE_CHECK` when contract checks are enabled. ```cpp #define STDGPU_DETAIL_DEVICE_EXPECTS(...) STDGPU_DETAIL_DEVICE_CHECK(__VA_ARGS__) #define STDGPU_DETAIL_DEVICE_ENSURES(...) STDGPU_DETAIL_DEVICE_CHECK(__VA_ARGS__) #define STDGPU_DETAIL_DEVICE_ASSERT(...) STDGPU_DETAIL_DEVICE_CHECK(__VA_ARGS__) ``` -------------------------------- ### stdgpu::vector::createDeviceObject Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1vector_acb0e1512188f7c1c9302066a49c0882a.html Creates an instance of `stdgpu::vector` on the GPU with a specified capacity and allocator. ```APIDOC ## createDeviceObject() [1/2] template> static vector< T, Allocator > stdgpu::vector< T, Allocator >::createDeviceObject(const index_t & _capacity_, const Allocator & _allocator_ = Allocator()) Creates an object of this class on the GPU (device) ### Parameters - **capacity** (index_t) - Required - The capacity of the object - **allocator** (Allocator) - Required - The allocator instance to use ### Returns A newly created object of this class allocated on the GPU (device) ### Precondition capacity > 0 ``` -------------------------------- ### stdgpu::unordered_set Class Overview Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1unordered__set.html Provides an overview of the stdgpu::unordered_set class, its template parameters, and key differences compared to the standard library's std::unordered_set. ```APIDOC ## Class stdgpu::unordered_set ### Description A generic container similar to `std::unordered_set` on the GPU. ### Template Parameters * **Key**: The key type. * **Hash**: The type of the hash functor. * **KeyEqual**: The type of the key equality functor. * **Allocator**: The allocator type. ### Differences to std::unordered_set * `index_type` instead of `size_type`. * Manual allocation and destruction of container required. * `max_size` and `capacity` limited to initially allocated size. * No guaranteed valid state when reaching capacity limit. * Additional non-standard capacity functions `full()` and `valid()`. * Some member functions missing. * Iterators may point at non-occupied and non-valid hash entry. * Difference between `begin()` and `end()` returns `max_size()` rather than `size()`. * Insert function returns iterator to `end()` rather than to the element preventing insertion. * Range insert and erase functions use iterators to `value_type` and `key_type`. ### Public Types * **allocator_type**: Alias for the Allocator type. * **const_iterator**: Alias for `const_pointer`. * **const_pointer**: Alias for `const value_type *`. * **const_reference**: Alias for `const value_type &`. * **difference_type**: Alias for `std::ptrdiff_t`. * **hasher**: Alias for the Hash functor type. * **index_type**: Alias for `index_t`. * **iterator**: Alias for `const_pointer`. * **key_equal**: Alias for the KeyEqual functor type. * **key_type**: Alias for the Key type. * **pointer**: Alias for `value_type *`. * **reference**: Alias for `value_type &`. * **value_type**: Alias for the Key type. ``` -------------------------------- ### createDeviceObject (with capacity and allocator) Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1unordered__map.html Creates a device-side unordered_map with a specified capacity and allocator. ```APIDOC ## createDeviceObject ### Description Creates a device-side unordered_map with a specified capacity and allocator. ### Method static ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **capacity** (const index_t &) - Description: The desired capacity of the unordered_map. - **allocator** (const Allocator &) - Optional - Description: The allocator to use for the unordered_map. Defaults to Allocator(). ### Request Example None ### Response #### Success Response (200) - **unordered_map** (stdgpu::unordered_map) - Description: The newly created device-side unordered_map. #### Response Example None ``` -------------------------------- ### createDeviceObject Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1bitset_a84c0a2dee20eeb155ecdc0563bce5332.html Creates an object of this class on the GPU (device). ```APIDOC ## createDeviceObject() ### Description Creates an object of this class on the GPU (device). ### Method static ### Signature template> bitset stdgpu::bitset< Block, Allocator >::createDeviceObject(const index_t & _size_, const Allocator & _allocator_ = Allocator()) ### Parameters #### Path Parameters - **_size_** (const index_t &) - Required - The size of this object - **_allocator_** (const Allocator &) - Optional - The allocator instance to use ### Returns A newly created object of this class allocated on the GPU (device) ``` -------------------------------- ### createDeviceObject (with execution policy, capacity, and allocator) Source: https://stotko.github.io/stdgpu/doxygen/classstdgpu_1_1vector.html Creates a device object (vector) with a specified capacity, allocator, and execution policy. This is a templated static method. ```APIDOC ## createDeviceObject (with execution policy, capacity, and allocator) ### Description Creates a device object (vector) with a specified capacity, allocator, and execution policy. This is a templated static method. ### Method static ### Signature template >) > vector< T, Allocator > createDeviceObject(ExecutionPolicy &&policy, const index_t &capacity, const Allocator &allocator = Allocator()) ### Parameters - **policy** (ExecutionPolicy &&) - The execution policy to use. - **capacity** (const index_t &) - The desired capacity for the device vector. - **allocator** (const Allocator &) - Optional. The allocator to use for the device vector. Defaults to an empty Allocator(). ### Returns - vector< T, Allocator > - A new device vector object. ``` -------------------------------- ### Functions to Create Device and Host Pointers Source: https://stotko.github.io/stdgpu/doxygen/iterator_8h_source.html Provides functions to create device_ptr and host_ptr from raw pointers. These functions are marked as STDGPU_HOST_DEVICE, meaning they can be executed on both the host and the device. ```cpp template STDGPU_HOST_DEVICE device_ptr make_device(T* device_array); template STDGPU_HOST_DEVICE host_ptr make_host(T* host_array); ```