prepareForParallelization
C++ Function Reference
1 Signature
std::vector< svdPositions > BigDataStatMeth::prepareForParallelization(T *dsA, int M, int k, bool transp, int block_size, std::string strDatasetName)2 Parameters
dsA(T *)M(int)k(int)transp(bool)block_size(int)strDatasetName(std::string)
3 Returns
Type: class T
4 Call Graph
5 Source Code
NoteImplementation
File: inst/include/hdf5Algebra/matrixSvdBlock.hpp • Lines 136-219
std::vector<svdPositions> prepareForParallelization( T* dsA, int M, int k, bool transp, int block_size, std::string strDatasetName)
{
static_assert(std::is_same<T*, BigDataStatMeth::hdf5Dataset* >::value ||
std::is_same<T*, BigDataStatMeth::hdf5DatasetInternal* >::value,
"Error - type not allowed");
std::vector<svdPositions> pos;
try{
H5::Exception::dontPrint();
// // BigDataStatMeth::hdf5Dataset* unlimDataset = nullptr;
// std::unique_ptr<BigDataStatMeth::hdf5Dataset> unlimDataset(nullptr);
// int realsizeread, cummoffset;
int realsizeread;
int irows = dsA->ncols();
int icols = dsA->nrows();
if(transp == false) {
irows = dsA->ncols();
icols = dsA->nrows();
} else {
irows = dsA->nrows();
icols = dsA->ncols();
}
for( int i = 0; i< M ; i++)
{
int maxsizetoread = block_size;
pos.push_back(svdPositions());
pos[i].strDatasetName = strDatasetName + std::to_string(i/(M/k));
pos[i].totOffset = getInitialPosition( transp, (unsigned long long)(i*block_size) ); // Initial read position
// Get max block size to read - for blocks smaller than default block size
if( ((i+1)*block_size) > icols)
maxsizetoread = icols - (i*block_size);
if( i+1 == M && icols - maxsizetoread!=0) {
realsizeread = icols - (i*block_size);
} else{
realsizeread = maxsizetoread;
}
pos[i].count = getSizetoRead(transp, (unsigned long long)(realsizeread), icols, irows );
if( i%(M/k) == 0 || ( (i%(M/k) > 0 && !exists_HDF5_element(dsA->getFileptr(), pos[i].strDatasetName)) ) )
{
pos[i].cummoffset = 0;
} else {
pos[i].cummoffset = pos[i-1].cummoffset + pos[i-1].count[0];
}
pos[i].partOffset[1] = pos[i].cummoffset;
}
} catch( H5::FileIException& error ) {
throw std::runtime_error("c++ exception prepareForParallelization (File IException)");
} catch( H5::DataSetIException& error ) {
throw std::runtime_error("c++ exception prepareForParallelization (DataSet IException)");
} catch( H5::GroupIException& error ) {
throw std::runtime_error("c++ exception prepareForParallelization (Group IException)");
} catch( H5::DataTypeIException& error ) {
throw std::runtime_error("c++ exception prepareForParallelization (DataType IException)");
} catch( H5::DataSpaceIException& error ) {
throw std::runtime_error("c++ exception prepareForParallelization (DataSpace IException)");
} catch(std::exception &ex) {
throw std::runtime_error(std::string("c++ exception prepareForParallelization: ") + ex.what());
} catch (...) {
throw std::runtime_error("C++ exception prepareForParallelization (unknown reason)");
}
return(pos);
}6 Usage Example
#include "BigDataStatMeth.hpp"
// Example usage
auto result = prepareForParallelization(...);