RISA
risa::cuda::Attenuation Class Reference

This stage computes the attenuation coefficients in the fan beam sinogram. More...

#include <Attenuation.h>

Collaboration diagram for risa::cuda::Attenuation:

Public Types

using input_type = glados::Image< glados::cuda::DeviceMemoryManager< 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< float, 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< float, glados::cuda::async_copy_policy >
 

Public Member Functions

 Attenuation (const std::string &configFile)
 Initializes everything, that needs to be done only once. More...
 
 ~Attenuation ()
 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 (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 init () -> void
 Capsules the average computation of dark and reference measurement. More...
 
template<typename T >
auto computeAverage (const std::vector< T > &values, std::vector< float > &average) -> void
 computes the average values from the given input files More...
 
template<typename T >
auto computeDarkAverage (const std::vector< T > &values, std::vector< float > &average) -> void
 
template<typename T >
auto readDarkInputFiles (std::string &file, std::vector< T > &values) -> void
 
template<typename T >
auto readInput (std::string &path, std::vector< T > &values, const int numberOfFrames) -> void
 
template<typename T >
auto relevantAreaMask (std::vector< T > &mask) -> void
 Computes a mask to hide the unrelevant areas in the fan beam sinogram. 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...
 
int numberOfDevices_
 the number of available CUDA devices in the system More...
 
unsigned int chunkSize_ {500u}
 defines how much input data is loaded from reference and dark input at once More...
 
int numberOfDetectorModules_
 the number of detector modules 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 numberOfPlanes_
 the number of detector planes More...
 
int numberOfDarkFrames_
 the number of frames in the dark measurement More...
 
int numberOfRefFrames_
 the number of frames in the reference measurement More...
 
std::string pathDark_
 file path to dark measurement data More...
 
std::string pathReference_
 file path to reference measurement data More...
 
double sourceOffset_
 source offset in the fan beam sinogram More...
 
double lowerLimOffset_
 lower offset, which is masked More...
 
double upperLimOffset_
 upper offset, which is masked More...
 
unsigned int xa_
 
unsigned int xb_
 
unsigned int xc_
 
unsigned int xd_
 
unsigned int xe_
 
unsigned int xf_
 
double threshMin_
 minimum threshold for defect detector interpolation More...
 
double threshMax_
 maximum threshold for defect detector interpolation More...
 
int blockSize2D_
 2D block size of the attenuation kernel More...
 
int memPoolSize_
 specifies, how many elements are allocated by memory pool More...
 
std::vector< float > avgDark_
 stores averaged dark measurement on host More...
 
std::vector< float > avgReference_
 stores averaged reference measurement on host More...
 

Detailed Description

This stage computes the attenuation coefficients in the fan beam sinogram.

This class represents the attenuation stage. It computes the attenuation data on the GPU device using the CUDA language. Multi GPU usage is possible.

Definition at line 68 of file Attenuation.h.

Member Typedef Documentation

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

Definition at line 71 of file Attenuation.h.

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

Definition at line 73 of file Attenuation.h.

Constructor & Destructor Documentation

risa::cuda::Attenuation::Attenuation ( 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 48 of file Attenuation.cu.

risa::cuda::Attenuation::~Attenuation ( )

Destroys everything that is not destroyed automatically.

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

Definition at line 81 of file Attenuation.cu.

Member Function Documentation

template<typename T >
auto risa::cuda::Attenuation::computeAverage ( const std::vector< T > &  values,
std::vector< float > &  average 
) -> void
private

computes the average values from the given input files

Parameters
[in]valuesvector, containing the data read from the input files
[out]averagevector, containing the averaged data

Definition at line 237 of file Attenuation.cu.

template<typename T >
auto risa::cuda::Attenuation::computeDarkAverage ( const std::vector< T > &  values,
std::vector< float > &  average 
) -> void
private

Definition at line 220 of file Attenuation.cu.

auto risa::cuda::Attenuation::init ( ) -> void
private

Capsules the average computation of dark and reference measurement.

Fills the host vectors avgDark_ and avgReference_ with the computed data from the input files.

Definition at line 177 of file Attenuation.cu.

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

Pushes the sinogram to the processor-threads.

Parameters
[in]imginput data that arrived from previous stage

Definition at line 93 of file Attenuation.cu.

auto risa::cuda::Attenuation::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 queue. It calls the attenuation CUDA kernel in its own stream. After the computation of the attenuation data, the fan beam sinogram is pushed into the output queue

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

Definition at line 118 of file Attenuation.cu.

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

template<typename T >
auto risa::cuda::Attenuation::readDarkInputFiles ( std::string &  file,
std::vector< T > &  values 
) -> void
private

Definition at line 254 of file Attenuation.cu.

template<typename T >
auto risa::cuda::Attenuation::readInput ( std::string &  path,
std::vector< T > &  values,
const int  numberOfFrames 
) -> void
private

Definition at line 275 of file Attenuation.cu.

template<typename T >
auto risa::cuda::Attenuation::relevantAreaMask ( std::vector< T > &  mask) -> void
private

Computes a mask to hide the unrelevant areas in the fan beam sinogram.

Due to the special geometry of ROFEX (e.g. limited angle) there are areas where it is known from a priori knowledge that all values need to be zero. This mask is multiplied with the fan beam sinogramm after the attenuation computation.

Parameters
[out]maskcontains the values of the mask

Definition at line 328 of file Attenuation.cu.

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

Member Data Documentation

std::vector<float> risa::cuda::Attenuation::avgDark_
private

stores averaged dark measurement on host

Definition at line 202 of file Attenuation.h.

std::vector<float> risa::cuda::Attenuation::avgReference_
private

stores averaged reference measurement on host

Definition at line 203 of file Attenuation.h.

int risa::cuda::Attenuation::blockSize2D_
private

2D block size of the attenuation kernel

Definition at line 198 of file Attenuation.h.

unsigned int risa::cuda::Attenuation::chunkSize_ {500u}
private

defines how much input data is loaded from reference and dark input at once

Definition at line 171 of file Attenuation.h.

double risa::cuda::Attenuation::lowerLimOffset_
private

lower offset, which is masked

Definition at line 185 of file Attenuation.h.

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

stores the indeces received when regisitering in MemoryPool

Definition at line 113 of file Attenuation.h.

int risa::cuda::Attenuation::memPoolSize_
private

specifies, how many elements are allocated by memory pool

Definition at line 199 of file Attenuation.h.

int risa::cuda::Attenuation::numberOfDarkFrames_
private

the number of frames in the dark measurement

Definition at line 178 of file Attenuation.h.

int risa::cuda::Attenuation::numberOfDetectorModules_
private

the number of detector modules

Definition at line 174 of file Attenuation.h.

int risa::cuda::Attenuation::numberOfDetectors_
private

the number of detectors in the fan beam sinogram

Definition at line 175 of file Attenuation.h.

int risa::cuda::Attenuation::numberOfDevices_
private

the number of available CUDA devices in the system

Definition at line 169 of file Attenuation.h.

int risa::cuda::Attenuation::numberOfPlanes_
private

the number of detector planes

Definition at line 177 of file Attenuation.h.

int risa::cuda::Attenuation::numberOfProjections_
private

the number of projections in the fan beam sinogram

Definition at line 176 of file Attenuation.h.

int risa::cuda::Attenuation::numberOfRefFrames_
private

the number of frames in the reference measurement

Definition at line 179 of file Attenuation.h.

std::string risa::cuda::Attenuation::pathDark_
private

file path to dark measurement data

Definition at line 180 of file Attenuation.h.

std::string risa::cuda::Attenuation::pathReference_
private

file path to reference measurement data

Definition at line 181 of file Attenuation.h.

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

stores the processor()-threads

Definition at line 111 of file Attenuation.h.

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

the output queue in which the processed sinograms are stored

Definition at line 109 of file Attenuation.h.

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

one separate input queue for each available CUDA device

Definition at line 108 of file Attenuation.h.

double risa::cuda::Attenuation::sourceOffset_
private

source offset in the fan beam sinogram

Definition at line 184 of file Attenuation.h.

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

stores the cudaStreams that are created once

Definition at line 112 of file Attenuation.h.

double risa::cuda::Attenuation::threshMax_
private

maximum threshold for defect detector interpolation

Definition at line 195 of file Attenuation.h.

double risa::cuda::Attenuation::threshMin_
private

minimum threshold for defect detector interpolation

Definition at line 194 of file Attenuation.h.

double risa::cuda::Attenuation::upperLimOffset_
private

upper offset, which is masked

Definition at line 186 of file Attenuation.h.

unsigned int risa::cuda::Attenuation::xa_
private

Definition at line 187 of file Attenuation.h.

unsigned int risa::cuda::Attenuation::xb_
private

Definition at line 188 of file Attenuation.h.

unsigned int risa::cuda::Attenuation::xc_
private

Definition at line 189 of file Attenuation.h.

unsigned int risa::cuda::Attenuation::xd_
private

Definition at line 190 of file Attenuation.h.

unsigned int risa::cuda::Attenuation::xe_
private

Definition at line 191 of file Attenuation.h.

unsigned int risa::cuda::Attenuation::xf_
private

Definition at line 192 of file Attenuation.h.


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