Class BitonicSort

Synopsis

#include <Source/Falcor/Utils/Algorithm/BitonicSort.h>

class dlldecl BitonicSort : public std::enable_shared_from_this<BitonicSort>

Description

In-place bitonic sort in chunks of N elements.

This sort method is efficient for sorting shorter sequences. The time complexity is O(N*log^2(N)), but it parallelizes very well and has practically no branching. The sort is implemented using horizontal operations within warps, and shared memory across warps.

This code requires an NVIDIA GPU and NVAPI. Set _ENABLE_NVAPI to true in FalcorConfig.h.

Inheritance

Ancestors: std::enable_shared_from_this< BitonicSort >

Methods

BitonicSort
~BitonicSort
createCreate a new bitonic sort object.
executeIn-place bitonic sort in chunks of N elements

Source

Lines 43-74 in Source/Falcor/Utils/Algorithm/BitonicSort.h.

class dlldecl BitonicSort : public std::enable_shared_from_this<BitonicSort>
{
public:
    using SharedPtr = std::shared_ptr<BitonicSort>;
    using SharedConstPtr = std::shared_ptr<const BitonicSort>;
    virtual ~BitonicSort() = default;
    /** Create a new bitonic sort object.
        \return New object, or throws an exception on error.
    */
    static SharedPtr create();
    /** In-place bitonic sort in chunks of N elements. Each chunk is sorted in ascending order.
        \param[in] pRenderContext The render context.
        \param[in] pData The data buffer to sort in-place.
        \param[in] totalSize The total number of elements in the buffer. This does _not_ have to be a multiple of chunkSize.
        \param[in] chunkSize The number of elements per chunk. Each chunk is individually sorted. Must be a power-of-two in the range [1, groupSize].
        \param[in] groupSize Thread group size. Must be a power-of-two in the range [1,1024]. The default group size of 256 is generally the fastest.
        \return True if successful, false if an error occured.
    */
    bool execute(RenderContext* pRenderContext, Buffer::SharedPtr pData, uint32_t totalSize, uint32_t chunkSize, uint32_t groupSize = 256);
protected:
    BitonicSort();
    struct
    {
        ComputeState::SharedPtr pState;
        ComputeProgram::SharedPtr pProgram;
        ComputeVars::SharedPtr pVars;
    } mSort;
};





Add Discussion as Guest

Log in to DocsForge