19#define ERRCHECK(err) __checkCudaErrors((err), __func__, __FILE__, __LINE__)
22 if (error != cudaSuccess) {
23 std::stringstream errMsg;
24 errMsg << func <<
"(), " <<
file +
":" << std::to_string(
line) <<
" : " << cudaGetErrorString(error);
25 throw std::runtime_error(errMsg.str());
33DeviceMemory::DeviceMemory(std::size_t
n, std::size_t typeSize) : _size{
n}
36 ERRCHECK(::cudaMalloc(&ret,
n * typeSize));
39PinnedHostMemory::PinnedHostMemory(std::size_t
n, std::size_t typeSize) : _size{
n}
42 ERRCHECK(::cudaMallocHost(&ret,
n * typeSize));
47void Deleter<DeviceMemory>::operator()(
void *ptr)
53void Deleter<PinnedHostMemory>::operator()(
void *ptr)
66CudaEvent::CudaEvent(
bool forTiming)
68 auto event =
new cudaEvent_t;
69 ERRCHECK(cudaEventCreateWithFlags(
event, forTiming ? 0 : cudaEventDisableTiming));
74void Deleter<CudaEvent>::operator()(
void *ptr)
76 auto event =
reinterpret_cast<cudaEvent_t *
>(ptr);
83void Deleter<CudaStream>::operator()(
void *ptr)
85 auto stream =
reinterpret_cast<cudaStream_t *
>(ptr);
86 ERRCHECK(cudaStreamDestroy(*stream));
107CudaStream::CudaStream()
109 auto stream =
new cudaStream_t;
119bool CudaStream::isActive()
121 cudaError_t err = cudaStreamQuery(*
this);
122 if (err == cudaErrorNotReady)
124 else if (err == cudaSuccess)
150 ERRCHECK(::cudaEventElapsedTime(&ret, begin, end));
156void copyHostToDeviceImpl(
const void *
src,
void *
dest,
size_t nBytes, CudaStream *stream)
159 ERRCHECK(cudaMemcpyAsync(
dest,
src, nBytes, cudaMemcpyHostToDevice, *stream));
164void copyDeviceToHostImpl(
const void *
src,
void *
dest,
size_t nBytes, CudaStream *stream)
167 ERRCHECK(cudaMemcpyAsync(
dest,
src, nBytes, cudaMemcpyDeviceToHost, *stream));
static void __checkCudaErrors(cudaError_t error, std::string func, std::string file, int line)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
void cudaEventRecord(CudaEvent &, CudaStream &)
Records a CUDA event.
float cudaEventElapsedTime(CudaEvent &, CudaEvent &)
Calculates the elapsed time between two CUDA events.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
#define dest(otri, vertexptr)