23 #ifndef __PCA_DISTRIBUTED_H__
24 #define __PCA_DISTRIBUTED_H__
26 #include "algorithms/algorithm.h"
27 #include "data_management/data/numeric_table.h"
28 #include "services/daal_defines.h"
29 #include "services/daal_memory.h"
30 #include "algorithms/pca/pca_types.h"
31 #include "algorithms/pca/pca_online.h"
51 template<ComputeStep computeStep,
typename algorithmFPType, Method method, CpuType cpu>
52 class DAAL_EXPORT DistributedContainer
59 template<
typename algorithmFPType, CpuType cpu>
60 class DAAL_EXPORT DistributedContainer<step1Local, algorithmFPType, correlationDense, cpu> :
public
61 OnlineContainer<algorithmFPType, correlationDense, cpu>
65 DistributedContainer(daal::services::Environment::env *daalEnv) : OnlineContainer<algorithmFPType, correlationDense, cpu>(daalEnv) {};
66 virtual ~DistributedContainer() {}
73 template<
typename algorithmFPType, CpuType cpu>
74 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, correlationDense, cpu> :
public AnalysisContainerIface<distributed>
82 DistributedContainer(daal::services::Environment::env *daalEnv);
84 virtual ~DistributedContainer();
90 services::Status compute() DAAL_C11_OVERRIDE;
95 services::Status finalizeCompute() DAAL_C11_OVERRIDE;
103 template<
typename algorithmFPType, CpuType cpu>
104 class DAAL_EXPORT DistributedContainer<step1Local, algorithmFPType, svdDense, cpu> :
public OnlineContainer<algorithmFPType, svdDense, cpu>
108 DistributedContainer(daal::services::Environment::env *daalEnv) : OnlineContainer<algorithmFPType, svdDense, cpu>(daalEnv) {};
109 virtual ~DistributedContainer() {}
116 template<
typename algorithmFPType, CpuType cpu>
117 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, svdDense, cpu> :
public AnalysisContainerIface<distributed>
125 DistributedContainer(daal::services::Environment::env *daalEnv);
127 ~DistributedContainer();
133 services::Status compute() DAAL_C11_OVERRIDE;
138 services::Status finalizeCompute() DAAL_C11_OVERRIDE;
155 template<ComputeStep computeStep,
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = correlationDense>
156 class DAAL_EXPORT Distributed :
public Analysis<distributed> {};
172 template<
typename algorithmFPType, Method method>
173 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> :
public Online<algorithmFPType, method>
176 typedef Online<algorithmFPType, method> super;
178 typedef typename super::InputType InputType;
179 typedef typename super::ParameterType ParameterType;
180 typedef typename super::ResultType ResultType;
181 typedef typename super::PartialResultType PartialResultType;
184 Distributed() : Online<algorithmFPType, method>() {}
191 Distributed(
const Distributed<step1Local, algorithmFPType, method> &other) :
192 Online<algorithmFPType, method>(other)
200 services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone()
const
202 return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
206 virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
208 return new Distributed<step1Local, algorithmFPType, method>(*this);
219 template<
typename algorithmFPType>
220 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, correlationDense> :
public Analysis<distributed>
223 typedef algorithms::pca::DistributedInput<correlationDense> InputType;
224 typedef algorithms::pca::DistributedParameter<step2Master, algorithmFPType, correlationDense> ParameterType;
225 typedef algorithms::pca::Result ResultType;
226 typedef algorithms::pca::PartialResult<correlationDense> PartialResultType;
239 Distributed(
const Distributed<step2Master, algorithmFPType, correlationDense> &other) :
240 input(other.input), parameter(other.parameter)
251 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)correlationDense; }
257 services::Status setPartialResult(
const services::SharedPtr<PartialResult<correlationDense> >& partialResult)
259 DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
260 _partialResult = partialResult;
261 _pres = _partialResult.get();
262 return services::Status();
269 services::SharedPtr<PartialResult<correlationDense> > getPartialResult()
271 _partialResult->set(sumCorrelation, parameter.covariance->getPartialResult()->get(covariance::sum));
272 _partialResult->set(nObservationsCorrelation, parameter.covariance->getPartialResult()->get(covariance::nObservations));
273 _partialResult->set(crossProductCorrelation, parameter.covariance->getPartialResult()->get(covariance::crossProduct));
274 return _partialResult;
281 services::Status setResult(
const ResultPtr& res)
283 DAAL_CHECK(res, services::ErrorNullResult)
285 _res = _result.get();
286 return services::Status();
293 ResultPtr getResult()
303 services::SharedPtr<Distributed<step2Master, algorithmFPType, correlationDense> > clone()
const
305 return services::SharedPtr<Distributed<step2Master, algorithmFPType, correlationDense> >(cloneImpl());
308 DistributedInput<correlationDense> input;
309 DistributedParameter<step2Master, algorithmFPType, correlationDense> parameter;
312 services::SharedPtr<PartialResult<correlationDense> > _partialResult;
315 virtual Distributed<step2Master, algorithmFPType, correlationDense> * cloneImpl() const DAAL_C11_OVERRIDE
317 return new Distributed<step2Master, algorithmFPType, correlationDense>(*this);
320 services::Status allocateResult() DAAL_C11_OVERRIDE
322 services::Status s =_result->allocate<algorithmFPType>(_pres, ¶meter, correlationDense);
323 _res = _result.get();
327 services::Status allocatePartialResult() DAAL_C11_OVERRIDE
329 services::Status s = _partialResult->allocate<algorithmFPType>(&input, ¶meter, correlationDense);
330 _pres = _partialResult.get();
334 services::Status initializePartialResult() DAAL_C11_OVERRIDE {
return services::Status(); }
338 _ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, correlationDense)(&_env);
341 _partialResult.reset(
new PartialResult<correlationDense>());
342 _result.reset(
new ResultType());
353 template<
typename algorithmFPType>
354 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, svdDense> :
public Analysis<distributed>
357 typedef algorithms::pca::DistributedInput<svdDense> InputType;
358 typedef algorithms::pca::DistributedParameter<step2Master, algorithmFPType, svdDense> ParameterType;
359 typedef algorithms::pca::Result ResultType;
360 typedef algorithms::pca::PartialResult<svdDense> PartialResultType;
373 Distributed(
const Distributed<step2Master, algorithmFPType, svdDense> &other) :
374 input(other.input), parameter(other.parameter)
385 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)svdDense; }
391 services::Status setPartialResult(
const services::SharedPtr<PartialResult<svdDense> >& partialResult)
393 DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
394 _partialResult = partialResult;
395 _pres = _partialResult.get();
396 return services::Status();
403 services::SharedPtr<PartialResult<svdDense> > getPartialResult()
405 return _partialResult;
412 services::Status setResult(
const ResultPtr& res)
414 DAAL_CHECK(res, services::ErrorNullResult)
416 _res = _result.get();
417 return services::Status();
424 ResultPtr getResult()
434 services::SharedPtr<Distributed<step2Master, algorithmFPType, svdDense> > clone()
const
436 return services::SharedPtr<Distributed<step2Master, algorithmFPType, svdDense> >(cloneImpl());
439 DistributedInput<svdDense> input;
440 DistributedParameter<step2Master, algorithmFPType, svdDense> parameter;
443 services::SharedPtr<PartialResult<svdDense> > _partialResult;
446 virtual Distributed<step2Master, algorithmFPType, svdDense> * cloneImpl() const DAAL_C11_OVERRIDE
448 return new Distributed<step2Master, algorithmFPType, svdDense>(*this);
451 services::Status allocateResult() DAAL_C11_OVERRIDE
453 services::Status s = _result->allocate<algorithmFPType>(_pres, ¶meter, svdDense);
454 _res = _result.get();
458 services::Status allocatePartialResult() DAAL_C11_OVERRIDE
460 services::Status s = _partialResult->allocate<algorithmFPType>(&input, ¶meter, svdDense);
461 _pres = _partialResult.get();
464 services::Status initializePartialResult() DAAL_C11_OVERRIDE{
return services::Status(); }
468 _ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, svdDense)(&_env);
471 _partialResult.reset(
new PartialResult<svdDense>());
472 _result.reset(
new ResultType());
477 using interface1::DistributedContainer;
478 using interface1::Distributed;
daal::algorithms::pca::interface1::DistributedParameter< step2Master, algorithmFPType, svdDense >
daal::algorithms::pca::interface1::Distributed< step1Local, algorithmFPType, method >
Computes the results of the PCA algorithm on the local nodes.
Definition: pca_distributed.h:173
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::Distributed
Distributed()
Definition: pca_distributed.h:229
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::input
DistributedInput< svdDense > input
Definition: pca_distributed.h:439
daal::algorithms::covariance::crossProduct
Definition: covariance_types.h:77
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, correlationDense > &other)
Definition: pca_distributed.h:239
daal
Definition: algorithm_base_common.h:31
daal::algorithms::pca::interface1::Online
Computes the results of the PCA algorithm.
Definition: pca_online.h:114
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::getResult
ResultPtr getResult()
Definition: pca_distributed.h:424
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:105
daal::algorithms::pca::interface1::OnlineContainer
Class containing methods to compute the result of the PCA algorithm.
Definition: pca_online.h:50
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::setResult
services::Status setResult(const ResultPtr &res)
Definition: pca_distributed.h:412
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >
Computes the result of the PCA Correlation algorithm on local nodes.
Definition: pca_distributed.h:220
daal::algorithms::kmeans::init::interface2::Distributed
class DAAL_EXPORT Distributed
Computes initial clusters for the K-Means algorithm in the distributed processing mode...
Definition: kmeans_init_distributed.h:275
daal::distributed
Definition: daal_defines.h:111
daal::algorithms::covariance::sum
Definition: covariance_types.h:78
daal::algorithms::pca::interface1::PartialResult
Provides methods to access partial results obtained with the compute() method of the PCA algorithm in...
Definition: pca_types.h:261
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::getPartialResult
services::SharedPtr< PartialResult< svdDense > > getPartialResult()
Definition: pca_distributed.h:403
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::input
DistributedInput< correlationDense > input
Definition: pca_distributed.h:308
daal::algorithms::pca::svdDense
Definition: pca_types.h:57
daal::algorithms::pca::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: pca_distributed.h:191
daal::algorithms::pca::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: pca_distributed.h:200
daal::algorithms::pca::interface1::DistributedContainer
Class containing methods to compute the results of the PCA algorithm in the distributed processing mo...
Definition: pca_distributed.h:52
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::Distributed
Distributed()
Definition: pca_distributed.h:363
daal::algorithms::pca::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed()
Definition: pca_distributed.h:184
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, svdDense > &other)
Definition: pca_distributed.h:373
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::parameter
DistributedParameter< step2Master, algorithmFPType, correlationDense > parameter
Definition: pca_distributed.h:309
daal::algorithms::kmeans::interface1::DistributedContainer
class DAAL_EXPORT DistributedContainer
Provides methods to run implementations of the K-Means algorithm. This class is associated with the d...
Definition: kmeans_distributed.h:55
daal::step1Local
Definition: daal_defines.h:121
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >
Computes the result of the PCA SVD algorithm on local nodes.
Definition: pca_distributed.h:354
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::setPartialResult
services::Status setPartialResult(const services::SharedPtr< PartialResult< svdDense > > &partialResult)
Definition: pca_distributed.h:391
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::setResult
services::Status setResult(const ResultPtr &res)
Definition: pca_distributed.h:281
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::getPartialResult
services::SharedPtr< PartialResult< correlationDense > > getPartialResult()
Definition: pca_distributed.h:269
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::setPartialResult
services::Status setPartialResult(const services::SharedPtr< PartialResult< correlationDense > > &partialResult)
Definition: pca_distributed.h:257
daal::step2Master
Definition: daal_defines.h:122
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, svdDense > > clone() const
Definition: pca_distributed.h:434
daal::algorithms::pca::interface1::DistributedContainer< step1Local, algorithmFPType, correlationDense, cpu >::DistributedContainer
DistributedContainer(daal::services::Environment::env *daalEnv)
Constructor.
Definition: pca_distributed.h:65
daal::algorithms::covariance::nObservations
Definition: covariance_types.h:76
daal::algorithms::pca::interface1::DistributedParameter< step2Master, algorithmFPType, correlationDense >
Class that specifies the parameters of the PCA Correlation algorithm in the distributed computing mod...
Definition: pca_types.h:520
daal::algorithms::pca::interface1::DistributedContainer< step1Local, algorithmFPType, svdDense, cpu >::DistributedContainer
DistributedContainer(daal::services::Environment::env *daalEnv)
Constructor.
Definition: pca_distributed.h:108
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: pca_distributed.h:251
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::pca::interface1::Distributed
Computes the result of the PCA algorithm.
Definition: pca_distributed.h:156
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::parameter
DistributedParameter< step2Master, algorithmFPType, svdDense > parameter
Definition: pca_distributed.h:440
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: pca_distributed.h:385
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, correlationDense > > clone() const
Definition: pca_distributed.h:303
daal::algorithms::pca::correlationDense
Definition: pca_types.h:55
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::getResult
ResultPtr getResult()
Definition: pca_distributed.h:293