Skip to content

RPP - Enhanced Handle Initialization and API Optimization#386

Merged
r-abishek merged 7 commits intor-abishek:ar/rpp_restructure_handlefrom
Dineshbabu-Ravichandran:db/handle_modification
Jan 22, 2025
Merged

RPP - Enhanced Handle Initialization and API Optimization#386
r-abishek merged 7 commits intor-abishek:ar/rpp_restructure_handlefrom
Dineshbabu-Ravichandran:db/handle_modification

Conversation

@Dineshbabu-Ravichandran
Copy link
Copy Markdown

  • Added rppCreate and rppDestroy for handle initialization and destruction.
  • Removed unused handle APIs and constructor functions.

Copy link
Copy Markdown
Owner

@r-abishek r-abishek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dineshbabu-Ravichandran Please address comments.
All changes after addressing comments are okay except these 4 files for this PR:

  • handle.hpp
  • handleocl.cpp
  • handlehost.cpp
  • handlehip.cpp

RPP_ERROR_INVALID_DST_DIMS = -24
} RppStatus;

typedef enum
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add docs something like:

/*! \brief RPP RppBackend type enums
 * \ingroup group_rppdefs
 */

/*! \brief Creates RPP handle for HOST and HIP batch processing.
* \details Function to create a RPP handle for a batch. To be called in the beginning to initialize the RPP environment.
* \param [in] handle A pointer to RPP handle of type <tt> \ref rppHandle_t</tt>.
* \param [in] nBatchSize Batch size.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The \param [in] needs to be added for all new arguments

* \retval rppStatusUnsupportedOp
*/
extern "C" SHARED_PUBLIC rppStatus_t rppCreateWithBatchSize(rppHandle_t* handle, size_t nBatchSize, Rpp32u numThreads = 0);
extern "C" SHARED_PUBLIC rppStatus_t rppCreate(rppHandle_t* handle, size_t nBatchSize, void* numThreadsOrStream, RppBackend backend = RppBackend::RPP_HOST_BACKEND);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure none of the voxel hip kernels use openmp and hip streams? Is there any situation where we need both threads and streams? Pls verify

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I verified , There is no constructor of handle that accepts stream and numThread at the same time and also there is no api named rppCreateWithStreamAndThread .

include/rpp.h Outdated
extern "C" SHARED_PUBLIC rppStatus_t rppCreate(rppHandle_t* handle);

/*! \brief Creates RPP handle for HOST batch processing.
/*! \brief Creates RPP handle for HOST and HIP batch processing.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Creates RPP handle for HOST/HIP/OCL backend batch processing."

include/rpp.h Outdated

/*! \brief Destory RPP handle.
* \details Function to destroy a RPP handle. To be called in the end to break down the RPP environment.
/*! \brief Destory RPP HOST/GPU handle.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Destroys RPP handle for HOST/HIP/OCL backend batch processing."

return rpp::try_([&] { rpp_destroy_object(handle); });
if(backend == RppBackend::RPP_HIP_BACKEND || backend == RppBackend::RPP_OCL_BACKEND)
{
#if GPU_SUPPORT
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The #if GPU_SUPPORT could be outside with an else-if inside.
Also, why do we need a static_cast of a reinterpret_cast?

if(backend == RppBackend::RPP_HOST_BACKEND)
{
    Rpp32u numThreads = *reinterpret_cast<Rpp32u*>(numThreadsOrStream);
    return rpp::try_([&] { rpp::deref(handle) = new rpp::Handle(nBatchSize, numThreads); });
}
#if GPU_SUPPORT
else if ((backend == RppBackend::RPP_HIP_BACKEND) || (backend == RppBackend::RPP_OCL_BACKEND))
{
    rppAcceleratorQueue_t deviceQueue = reinterpret_cast<rppAcceleratorQueue_t>(numThreadsOrStream);
    return rpp::try_([&] { rpp::deref(handle) = new rpp::Handle(deviceQueue, nBatchSize); });
}
#endif // GPU_SUPPORT
else
{
    return rppStatusNotImplemented;
}

The above is okay except please change the order of arguments in "new rpp::Handle" so that nBatchSize is always first. There is a discrepancy for host and device above.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I directly reinterpret_cast to Rpp32u . I am getting below error :

error: cast from pointer to smaller type 'Rpp32u' (aka 'unsigned int') loses information
   33 |         Rpp32u numThreads = (reinterpret_cast<Rpp32u>(numThreadsOrStream));
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated when compiling for gfx908.

I changed the argument order for HIP and OCL .

return device;
}

void set_device(int id)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasons to remove these 5?

  • set_device()
  • set_default_device()
  • create_stream()
  • Handle::Handle(rppAcceleratorQueue_t stream) : impl(new HandleImpl())
  • Handle::Handle() : impl(new HandleImpl())
  • void Handle::SetStream(rppAcceleratorQueue_t streamID) const

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • set_device() function is used inside the set_default_device()
  • set_default_device() and create_stream() is used in the default constructor of handle with no argument Handle::Handle() : impl(new HandleImpl())
  • We are using the constructor of handle with batchsize and thread as a arguments and batchsize and stream as a arguments . SO I removed the remaining constructors (default constructor and constructor with only stream ).
  • setStream() - not called. I searched through global search and removed it .

impl->PreInitializeBufferCPU();
}

Handle::Handle() : impl(new HandleImpl())
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same on handlehost. Reasons to remove?

  • Handle::Handle() : impl(new HandleImpl())

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Same for the HOST handle constructor .
  • I keep the handle constructor with batchsize and threadnum as a argument.
  • So I removed the remaining constructor (default constructor).

impl->PreInitializeBuffer();
}

Handle::Handle(rppAcceleratorQueue_t stream) : impl(new HandleImpl())
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the handleocl file. Reasons to remove?

  • Handle::Handle(rppAcceleratorQueue_t stream) : impl(new HandleImpl())
  • Handle::Handle() : impl(new HandleImpl())
  • Handle::SetStream(rppAcceleratorQueue_t streamID) const

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the OCL Constructor also

  • Keep only constructor with batchSize and stream as a argument to constructor .
  • Removed the remaining constructor (default constructor and constructor with stream as a argument )
  • SetStream() is not called on any file . I searched via global search and removed it .

{
Handle();
Handle(size_t nBatchSize, Rpp32u numThreads = 0);
Handle(Handle&&) noexcept;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment for changes in this file

Copy link
Copy Markdown
Author

@Dineshbabu-Ravichandran Dineshbabu-Ravichandran Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the declaration of the removed functions on handlehost , handlehip and handleocl file on handle file .

@r-abishek r-abishek added the enhancement New feature or request label Jan 16, 2025
Copy link
Copy Markdown
Owner

@r-abishek r-abishek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@r-abishek r-abishek added this to the sow12ms1 milestone Jan 22, 2025
@r-abishek r-abishek changed the base branch from develop to ar/rpp_restructure_handle January 22, 2025 08:24
@r-abishek r-abishek merged commit fd7be3f into r-abishek:ar/rpp_restructure_handle Jan 22, 2025
ManasaDattaT pushed a commit to ManasaDattaT/rpp that referenced this pull request Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants