Xmipp  v3.23.11-Nereus
Public Member Functions | Public Attributes | List of all members
FRecBufferDataGPUWrapper Struct Reference

#include <cuda_gpu_reconstruct_fourier.h>

Collaboration diagram for FRecBufferDataGPUWrapper:
Collaboration graph
[legend]

Public Member Functions

 FRecBufferDataGPUWrapper (RecFourierBufferData *orig)
 
 ~FRecBufferDataGPUWrapper ()
 
void copyFrom (RecFourierBufferData *orig, int stream)
 
void copyToDevice (int stream)
 

Public Attributes

RecFourierBufferDataGPUcpuCopy
 
RecFourierBufferDataGPUgpuCopy
 

Detailed Description

This struct simplifies work with pointers on GPU It holds a copy both in CPU and GPU memory space

Definition at line 46 of file cuda_gpu_reconstruct_fourier.h.

Constructor & Destructor Documentation

◆ FRecBufferDataGPUWrapper()

FRecBufferDataGPUWrapper::FRecBufferDataGPUWrapper ( RecFourierBufferData orig)

Definition at line 319 of file cuda_gpu_reconstruct_fourier.cpp.

319  {
320  void* ptr;
321  cudaMallocHost(&ptr, sizeof(RecFourierBufferDataGPU)); // allocate page-locked
323  cpuCopy->create(orig);
324  gpuCopy = NULL;
325 }
void create(RecFourierBufferData *orig)
RecFourierBufferDataGPU * cpuCopy
RecFourierBufferDataGPU * gpuCopy

◆ ~FRecBufferDataGPUWrapper()

FRecBufferDataGPUWrapper::~FRecBufferDataGPUWrapper ( )

Definition at line 327 of file cuda_gpu_reconstruct_fourier.cpp.

327  {
328  cudaFree(gpuCopy);
329  gpuErrchk( cudaPeekAtLastError() );
330  cpuCopy->destroy();
331  cudaFreeHost(cpuCopy);
332 }
#define gpuErrchk(code)
Definition: cuda_asserts.h:31
RecFourierBufferDataGPU * cpuCopy
RecFourierBufferDataGPU * gpuCopy

Member Function Documentation

◆ copyFrom()

void FRecBufferDataGPUWrapper::copyFrom ( RecFourierBufferData orig,
int  stream 
)

Copy the content of the 'orig' buffer to new object Original buffer can be cleaned after. Works asynchronously on given stream

Definition at line 334 of file cuda_gpu_reconstruct_fourier.cpp.

334  {
335  cpuCopy->copyDataFrom(orig, stream);
336 }
RecFourierBufferDataGPU * cpuCopy
void copyDataFrom(RecFourierBufferData *orig, int stream)

◆ copyToDevice()

void FRecBufferDataGPUWrapper::copyToDevice ( int  stream)

Copy CPU version to GPU, asynchronously on given stream

Definition at line 338 of file cuda_gpu_reconstruct_fourier.cpp.

338  {
339  if (NULL == gpuCopy) {
340  cudaMalloc((void **) &gpuCopy, sizeof(RecFourierBufferDataGPU));
341  gpuErrchk( cudaPeekAtLastError() );
342  }
343  cudaMemcpyAsync(gpuCopy, cpuCopy, sizeof(RecFourierBufferDataGPU), cudaMemcpyHostToDevice, streams[stream]);
344  gpuErrchk( cudaPeekAtLastError() );
345 }
#define gpuErrchk(code)
Definition: cuda_asserts.h:31
RecFourierBufferDataGPU * cpuCopy
cudaStream_t * streams
RecFourierBufferDataGPU * gpuCopy

Member Data Documentation

◆ cpuCopy

RecFourierBufferDataGPU* FRecBufferDataGPUWrapper::cpuCopy

Definition at line 63 of file cuda_gpu_reconstruct_fourier.h.

◆ gpuCopy

RecFourierBufferDataGPU* FRecBufferDataGPUWrapper::gpuCopy

Definition at line 66 of file cuda_gpu_reconstruct_fourier.h.


The documentation for this struct was generated from the following files: