RISA
risa::cuda::D2H Class Reference

This stage transfer a data element from device to host. More...

#include <D2H.h>

Collaboration diagram for risa::cuda::D2H:

Public Types

using hostManagerType = glados::cuda::HostMemoryManager< float, glados::cuda::async_copy_policy >
 The input data type that needs to fit the output type of the previous stage. More...
 
using input_type = glados::Image< glados::cuda::DeviceMemoryManager< float, glados::cuda::async_copy_policy >>
 The output data type that needs to fit the input type of the following stage. More...
 
using output_type = glados::Image< glados::cuda::HostMemoryManager< float, glados::cuda::async_copy_policy >>
 

Public Member Functions

 D2H (const std::string &configFile)
 Initializes everything, that needs to be done only once. More...
 
 ~D2H ()
 Destroys everything that is not destroyed automatically. More...
 
auto process (input_type &&img) -> void
 Pushes the sinogram to the processor-threads. More...
 
auto wait () -> output_type
 Takes one sinogram from the output queue results_ and transfers it to the neighbored stage. More...
 

Private Member Functions

auto processor (const int deviceID) -> void
 main data processing routine executed in its own thread for each CUDA device, that performs the data processing of this stage More...
 
auto readConfig (const std::string &configFile) -> bool
 Read configuration values from configuration file. More...
 

Private Attributes

std::map< int, glados::Queue< input_type > > imgs_
 one separate input queue for each available CUDA device More...
 
glados::Queue< output_typeresults_
 the output queue in which the processed sinograms are stored More...
 
std::map< int, std::thread > processorThreads_
 stores the processor()-threads More...
 
std::map< int, cudaStream_t > streams_
 stores the cudaStreams that are created once More...
 
unsigned int memoryPoolIdx_
 stores the indeces received when regisitering in MemoryPool More...
 
int memPoolSize_
 specifies, how many elements are allocated by memory pool More...
 
int numberOfDevices_
 the number of available CUDA devices in the system More...
 
int numberOfPixels_
 the number of pixels in one direction in the reconstructed image More...
 
std::size_t count_ {0}
 counts the total number of reconstructed sinograms More...
 
double reconstructionRate_
 the average reconstruction rate More...
 
double counter_
 used for computing the average reconstruction rate More...
 
Timer tmr_
 used to measure the timings More...
 

Detailed Description

This stage transfer a data element from device to host.

Definition at line 42 of file D2H.h.

Member Typedef Documentation

The input data type that needs to fit the output type of the previous stage.

Definition at line 45 of file D2H.h.

The output data type that needs to fit the input type of the following stage.

Definition at line 47 of file D2H.h.

Constructor & Destructor Documentation

risa::cuda::D2H::D2H ( const std::string &  configFile)

Initializes everything, that needs to be done only once.

Runs as many processor-thread as CUDA devices are available in the system. Allocates memory using the MemoryPool.

Parameters
[in]configFilepath to configuration file

Definition at line 40 of file D2H.cu.

risa::cuda::D2H::~D2H ( )

Destroys everything that is not destroyed automatically.

Tells MemoryPool to free the allocated memory. Destroys the cudaStreams.

Definition at line 74 of file D2H.cu.

Member Function Documentation

auto risa::cuda::D2H::process ( input_type &&  img) -> void

Pushes the sinogram to the processor-threads.

The scheduling for multi-GPU usage is done in this function.

Parameters
[in]sinograminput data that arrived from previous stage

Definition at line 83 of file D2H.cu.

auto risa::cuda::D2H::processor ( const int  deviceID) -> void
private

main data processing routine executed in its own thread for each CUDA device, that performs the data processing of this stage

This method takes one image from the input queue imgs_. The image is transfered from device to host using the asynchronous cudaMemcpyAsync()-operation. The resulting host structure is pushed back into the output queue results_.

Parameters
[in]deviceIDspecifies on which CUDA device to execute the device functions

Definition at line 119 of file D2H.cu.

auto risa::cuda::D2H::readConfig ( const std::string &  configFile) -> bool
private

Read configuration values from configuration file.

All values needed for setting up the class are read from the config file in this function.

Parameters
[in]configFilepath to config file
Return values
trueconfiguration options were read successfully
falseconfiguration options could not be read successfully

Definition at line 150 of file D2H.cu.

auto risa::cuda::D2H::wait ( ) -> output_type

Takes one sinogram from the output queue results_ and transfers it to the neighbored stage.

Returns
the oldest sinogram in the output queue results_

Definition at line 115 of file D2H.cu.

Member Data Documentation

std::size_t risa::cuda::D2H::count_ {0}
private

counts the total number of reconstructed sinograms

Definition at line 97 of file D2H.h.

double risa::cuda::D2H::counter_
private

used for computing the average reconstruction rate

Definition at line 100 of file D2H.h.

std::map<int, glados::Queue<input_type> > risa::cuda::D2H::imgs_
private

one separate input queue for each available CUDA device

Definition at line 84 of file D2H.h.

unsigned int risa::cuda::D2H::memoryPoolIdx_
private

stores the indeces received when regisitering in MemoryPool

Definition at line 90 of file D2H.h.

int risa::cuda::D2H::memPoolSize_
private

specifies, how many elements are allocated by memory pool

Definition at line 92 of file D2H.h.

int risa::cuda::D2H::numberOfDevices_
private

the number of available CUDA devices in the system

Definition at line 94 of file D2H.h.

int risa::cuda::D2H::numberOfPixels_
private

the number of pixels in one direction in the reconstructed image

Definition at line 95 of file D2H.h.

std::map<int, std::thread> risa::cuda::D2H::processorThreads_
private

stores the processor()-threads

Definition at line 87 of file D2H.h.

double risa::cuda::D2H::reconstructionRate_
private

the average reconstruction rate

Definition at line 99 of file D2H.h.

glados::Queue<output_type> risa::cuda::D2H::results_
private

the output queue in which the processed sinograms are stored

Definition at line 85 of file D2H.h.

std::map<int, cudaStream_t> risa::cuda::D2H::streams_
private

stores the cudaStreams that are created once

Definition at line 88 of file D2H.h.

Timer risa::cuda::D2H::tmr_
private

used to measure the timings

Definition at line 102 of file D2H.h.


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