fml  0.1-0
Fused Matrix Library
gpuhelpers Namespace Reference

GPU class helpers. More...

Functions

std::shared_ptr< cardnew_card (int id=0)
 Initialize a new card. More...
 
template<typename REAL_IN , typename REAL_OUT >
void gpu2cpu (const gpuvec< REAL_IN > &gpu, cpuvec< REAL_OUT > &cpu)
 Copy data from a GPU object to a CPU object. More...
 
template<typename REAL >
gpuvec< REAL > gpu2cpu (const gpuvec< REAL > &gpu)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename REAL_IN , typename REAL_OUT >
void gpu2cpu (const gpumat< REAL_IN > &gpu, cpumat< REAL_OUT > &cpu)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename REAL >
cpumat< REAL > gpu2cpu (const gpumat< REAL > &gpu)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename REAL_IN , typename REAL_OUT >
void cpu2gpu (const cpuvec< REAL_IN > &cpu, gpuvec< REAL_OUT > &gpu)
 Copy data from a CPU object to a GPU object. More...
 
template<typename REAL_IN , typename REAL_OUT >
void cpu2gpu (const cpumat< REAL_IN > &cpu, gpumat< REAL_OUT > &gpu)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename REAL_IN , typename REAL_OUT >
void gpu2gpu (const gpuvec< REAL_IN > &gpu_in, gpuvec< REAL_OUT > &gpu_out)
 Copy data from a GPU object to another. More...
 
template<typename REAL >
gpuvec< REAL > gpu2gpu (const gpuvec< REAL > &gpu_in)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename REAL_IN , typename REAL_OUT >
void gpu2gpu (const gpumat< REAL_IN > &gpu_in, gpumat< REAL_OUT > &gpu_out)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename REAL >
gpumat< REAL > gpu2gpu (const gpumat< REAL > &gpu_in)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Detailed Description

GPU class helpers.

Function Documentation

◆ cpu2gpu()

template<typename REAL_IN , typename REAL_OUT >
void gpuhelpers::cpu2gpu ( const cpuvec< REAL_IN > &  cpu,
gpuvec< REAL_OUT > &  gpu 
)

Copy data from a CPU object to a GPU object.

Parameters
[in]cpuInput data.
[out]gpuOutput. Dimensions should match those of the input data. If not, the matrix will automatically be resized.
Memory Allocations\n If the output dimensions do not match those of the input, the
internal data will automatically be re-allocated.
Exceptions\n If a reallocation is triggered and fails, a bad_alloc exception
will be thrown.
Template Parameters
REAL_IN,REAL_OUTShould be float or double. They do not have to be the same type. Additionally, REAL_OUT can be __half.

◆ gpu2cpu()

template<typename REAL_IN , typename REAL_OUT >
void gpuhelpers::gpu2cpu ( const gpuvec< REAL_IN > &  gpu,
cpuvec< REAL_OUT > &  cpu 
)

Copy data from a GPU object to a CPU object.

Parameters
[in]gpuInput data.
[out]cpuOutput. Dimensions should match those of the input data. If not, the matrix will automatically be resized.
Memory Allocations\n If the output dimensions do not match those of the input, the
internal data will automatically be re-allocated.
Exceptions\n If a reallocation is triggered and fails, a bad_alloc exception
will be thrown.
Template Parameters
REAL_IN,REAL_OUTShould be float or double. They do not have to be the same type. Additionally, REAL_IN can be __half.

◆ gpu2gpu()

template<typename REAL_IN , typename REAL_OUT >
void gpuhelpers::gpu2gpu ( const gpuvec< REAL_IN > &  gpu_in,
gpuvec< REAL_OUT > &  gpu_out 
)

Copy data from a GPU object to another.

The GPU objects should be on the same card.

Parameters
[in]gpu_inInput data.
[out]gpu_outOutput. Dimensions should match those of the input data. If not, the matrix will automatically be resized.
Memory Allocations\n If the output dimensions do not match those of the input, the
internal data will automatically be re-allocated.
Exceptions\n If a reallocation is triggered and fails, a bad_alloc exception
will be thrown. If the objects are on different cards, a logic_error exception will be thrown.
Template Parameters
REAL_IN,REAL_OUTshould be __half, float, or double. They do not have to be the same type.

◆ new_card()

std::shared_ptr<card> gpuhelpers::new_card ( int  id = 0)
inline

Initialize a new card.

Parameters
[in]idGPU id number.
Returns
Shared pointer to initialized card object.
Exceptions\n If the GPU can not be initialized, or if the allocation of one of the
handles fails, the method will throw a 'runtime_error' exception.