lambday / flash

Proof of concept for refactoring shogun's statistical hypothesis framework
GNU General Public License v3.0
0 stars 0 forks source link

Plan for the API #7

Closed lambday closed 8 years ago

lambday commented 8 years ago
// inside compute statistic
// make the computation manager store in the pimpl.. set once per ues_cpu()/use_gpu() call
ComputationManagerBase cm = ComputationManager<CPU/GPU>();
NextSamples next_burst = dm.next();
while (!next_burst.empty())
{
#pragma omp parallel for
  for (auto i = 0; i < next_burst.num_blocks(); ++i)
  {
    // do the fetching, as explained in other issues
    cm.data().push_back(kernel_on_the_present_block);
  }

  // from now on, we assume that each entry in kernel_matrices is populated with
  // a blockwise kernel matrix
  vector<float64_t> result = cm.elementwise_compute(MMD_statistic()); // does the block-wise sum on the matrix
  // fetch data for next burst
}
lambday commented 8 years ago
template <typename StorageType>
struct ComputationManagerBase
{
   typedef StorageType::vector_type vector;
   template<typename operation> 
   vector<typename operation::return_type> elementwise_compute(operation op)
   {
     for each i in data
     compute op(i)
     populate vector and return the result
   }
   vector<StorageType> data;
};
struct CPUComputationManager : struct ComputationManagerBase<SGMatrix<float64_t>>
{
};
struct GPUComputationManager : struct ComputationManagerBase<CGPUMatrix<float64_t>>
{
};
lambday commented 8 years ago

done