Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooFit::Detail::CudaHelpers Namespace Reference

Functions

std::pair< std::chrono::microseconds, std::chrono::microseconds > memcpyBenchmark (std::size_t nBytes)
 Measure the time taken to perform memory copy operations between host and device memory.
 

Function Documentation

◆ memcpyBenchmark()

std::pair< std::chrono::microseconds, std::chrono::microseconds > RooFit::Detail::CudaHelpers::memcpyBenchmark ( std::size_t  nBytes)

Measure the time taken to perform memory copy operations between host and device memory.

Parameters
nBytesThe number of bytes to be copied between host and device memory.
Returns
A pair of durations representing the average time taken for host-to-device and device-to-host copies.

This function measures the time taken to copy data between host and device memory using the CUDA API. It performs a series of copy operations and calculates the average time for both directions. The input parameter nBytes specifies the size of the data to be copied in bytes. The function returns a pair of durations, where the first duration represents the average time taken for host-to-device copies and the second duration represents the average time taken for device-to-host copies.

Example usage:

auto copyTimes = RooFit::Detail::CudaHelpers::memcpyBenchmark(1024 * 1024); // Measure copy time for 1 MB of data
std::cout << "Average Host-to-Device Copy Time: " << copyTimes.first.count() << " microseconds" << std::endl;
std::cout << "Average Device-to-Host Copy Time: " << copyTimes.second.count() << " microseconds" << std::endl;
std::pair< std::chrono::microseconds, std::chrono::microseconds > memcpyBenchmark(std::size_t nBytes)
Measure the time taken to perform memory copy operations between host and device memory.

Definition at line 37 of file CudaHelpers.cxx.