RISA
risa::cuda::H2D Class Reference

This stage transfers the input data element from device to host. More...

#include <H2D.h>

Collaboration diagram for risa::cuda::H2D:

Public Types

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

Public Member Functions

 H2D (const std::string &configFile)
 Initializes everything, that needs to be done only once. More...
 
 ~H2D ()
 Destroys everything that is not destroyed automatically. More...
 
auto process (input_type &&sinogram) -> 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 (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 > > sinograms_
 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...
 
std::map< int, unsigned int > memoryPoolIdxs_
 stores the indeces received when regisitering in MemoryPool More...
 
double worstCaseTime_
 stores the worst case time between the arrival of two following sinograms More...
 
double bestCaseTime_
 stores the besst case time between the arrival of two following sinograms More...
 
Timer tmr_
 used to measure the timings More...
 
std::size_t lastIndex_
 stores the index of the last sinogram. Used to analyze which percentage of the arrived sinograms could be reconstructed More...
 
std::size_t lostSinos_
 stores the number of sinograms that could not be reconstructed More...
 
std::size_t count_ { 0 }
 counts the total number of reconstructed sinograms More...
 
int lastDevice_
 stores, to which device the last arrived sinogram was sent More...
 
int numberOfDevices_
 the number of available CUDA devices in the system More...
 
int numberOfDetectors_
 the number of detectors in the fan beam sinogram More...
 
int numberOfProjections_
 the number of projections in the fan beam sinogram More...
 
int memPoolSize_
 specifies, how many elements are allocated by memory pool More...
 

Detailed Description

This stage transfers the input data element from device to host.

This class transfers the data to be processed from host to device. Furthermore, it performs the scheduling between the available devices. Scheduling is done statically, so far. Heterogeneous can be used, by adapting the scheduling in a way, that the more powerful device receives more data inputs.

Definition at line 52 of file H2D.h.

Member Typedef Documentation

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

Definition at line 55 of file H2D.h.

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

Definition at line 57 of file H2D.h.

Constructor & Destructor Documentation

risa::cuda::H2D::H2D ( 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 for all CUDA devices.

Parameters
[in]configFilepath to configuration file

Definition at line 41 of file H2D.cu.

risa::cuda::H2D::~H2D ( )

Destroys everything that is not destroyed automatically.

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

Definition at line 71 of file H2D.cu.

Member Function Documentation

auto risa::cuda::H2D::process ( input_type &&  sinogram) -> 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 84 of file H2D.cu.

auto risa::cuda::H2D::processor ( 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 sinogram from the input queue sinograms_. The sinogram is transfered to the device using the asynchronous cudaMemcpyAsync()-operation. The resulting device strucutre is pushed back into the output queue results_.

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

Definition at line 134 of file H2D.cu.

auto risa::cuda::H2D::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 171 of file H2D.cu.

auto risa::cuda::H2D::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 130 of file H2D.cu.

Member Data Documentation

double risa::cuda::H2D::bestCaseTime_
private

stores the besst case time between the arrival of two following sinograms

Definition at line 113 of file H2D.h.

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

counts the total number of reconstructed sinograms

Definition at line 119 of file H2D.h.

int risa::cuda::H2D::lastDevice_
private

stores, to which device the last arrived sinogram was sent

Definition at line 121 of file H2D.h.

std::size_t risa::cuda::H2D::lastIndex_
private

stores the index of the last sinogram. Used to analyze which percentage of the arrived sinograms could be reconstructed

Definition at line 116 of file H2D.h.

std::size_t risa::cuda::H2D::lostSinos_
private

stores the number of sinograms that could not be reconstructed

Definition at line 117 of file H2D.h.

std::map<int, unsigned int> risa::cuda::H2D::memoryPoolIdxs_
private

stores the indeces received when regisitering in MemoryPool

Definition at line 100 of file H2D.h.

int risa::cuda::H2D::memPoolSize_
private

specifies, how many elements are allocated by memory pool

Definition at line 128 of file H2D.h.

int risa::cuda::H2D::numberOfDetectors_
private

the number of detectors in the fan beam sinogram

Definition at line 125 of file H2D.h.

int risa::cuda::H2D::numberOfDevices_
private

the number of available CUDA devices in the system

Definition at line 123 of file H2D.h.

int risa::cuda::H2D::numberOfProjections_
private

the number of projections in the fan beam sinogram

Definition at line 126 of file H2D.h.

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

stores the processor()-threads

Definition at line 98 of file H2D.h.

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

the output queue in which the processed sinograms are stored

Definition at line 96 of file H2D.h.

std::map<int, glados::Queue<input_type> > risa::cuda::H2D::sinograms_
private

one separate input queue for each available CUDA device

Definition at line 95 of file H2D.h.

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

stores the cudaStreams that are created once

Definition at line 99 of file H2D.h.

Timer risa::cuda::H2D::tmr_
private

used to measure the timings

Definition at line 114 of file H2D.h.

double risa::cuda::H2D::worstCaseTime_
private

stores the worst case time between the arrival of two following sinograms

Definition at line 112 of file H2D.h.


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