25 #ifndef __PCA_DISTRIBUTED_H__
26 #define __PCA_DISTRIBUTED_H__
28 #include "algorithms/algorithm.h"
29 #include "data_management/data/numeric_table.h"
30 #include "services/daal_defines.h"
31 #include "services/daal_memory.h"
32 #include "algorithms/pca/pca_types.h"
33 #include "algorithms/pca/pca_online.h"
53 template<ComputeStep computeStep,
typename algorithmFPType, Method method, CpuType cpu>
54 class DistributedContainer
61 template<
typename algorithmFPType, CpuType cpu>
62 class DistributedContainer<step1Local, algorithmFPType, correlationDense, cpu> :
public
63 OnlineContainer<algorithmFPType, correlationDense, cpu>
67 DistributedContainer(daal::services::Environment::env *daalEnv) : OnlineContainer<algorithmFPType, correlationDense, cpu>(daalEnv) {};
68 virtual ~DistributedContainer() {}
75 template<
typename algorithmFPType, CpuType cpu>
76 class DistributedContainer<step2Master, algorithmFPType, correlationDense, cpu> :
public AnalysisContainerIface<distributed>
84 DistributedContainer(daal::services::Environment::env *daalEnv);
86 virtual ~DistributedContainer();
92 services::Status compute() DAAL_C11_OVERRIDE;
97 services::Status finalizeCompute() DAAL_C11_OVERRIDE;
105 template<
typename algorithmFPType, CpuType cpu>
106 class DistributedContainer<step1Local, algorithmFPType, svdDense, cpu> :
public OnlineContainer<algorithmFPType, svdDense, cpu>
110 DistributedContainer(daal::services::Environment::env *daalEnv) : OnlineContainer<algorithmFPType, svdDense, cpu>(daalEnv) {};
111 virtual ~DistributedContainer() {}
118 template<
typename algorithmFPType, CpuType cpu>
119 class DistributedContainer<step2Master, algorithmFPType, svdDense, cpu> :
public AnalysisContainerIface<distributed>
127 DistributedContainer(daal::services::Environment::env *daalEnv);
129 ~DistributedContainer();
135 services::Status compute() DAAL_C11_OVERRIDE;
140 services::Status finalizeCompute() DAAL_C11_OVERRIDE;
157 template<ComputeStep computeStep,
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = correlationDense>
158 class DAAL_EXPORT Distributed :
public Analysis<distributed> {};
174 template<
typename algorithmFPType, Method method>
175 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> :
public Online<algorithmFPType, method>
178 typedef Online<algorithmFPType, method> super;
180 typedef typename super::InputType InputType;
181 typedef typename super::ParameterType ParameterType;
182 typedef typename super::ResultType ResultType;
183 typedef typename super::PartialResultType PartialResultType;
186 Distributed() : Online<algorithmFPType, method>() {}
193 Distributed(
const Distributed<step1Local, algorithmFPType, method> &other) :
194 Online<algorithmFPType, method>(other)
202 services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone()
const
204 return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
208 virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
210 return new Distributed<step1Local, algorithmFPType, method>(*this);
221 template<
typename algorithmFPType>
222 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, correlationDense> :
public Analysis<distributed>
225 typedef algorithms::pca::DistributedInput<correlationDense> InputType;
226 typedef algorithms::pca::DistributedParameter<step2Master, algorithmFPType, correlationDense> ParameterType;
227 typedef algorithms::pca::Result ResultType;
228 typedef algorithms::pca::PartialResult<correlationDense> PartialResultType;
241 Distributed(
const Distributed<step2Master, algorithmFPType, correlationDense> &other) :
242 input(other.input), parameter(other.parameter)
253 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)correlationDense; }
259 services::Status setPartialResult(
const services::SharedPtr<PartialResult<correlationDense> >& partialResult)
261 DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
262 _partialResult = partialResult;
263 _pres = _partialResult.get();
264 return services::Status();
271 services::SharedPtr<PartialResult<correlationDense> > getPartialResult()
273 _partialResult->set(sumCorrelation, parameter.covariance->getPartialResult()->get(covariance::sum));
274 _partialResult->set(nObservationsCorrelation, parameter.covariance->getPartialResult()->get(covariance::nObservations));
275 _partialResult->set(crossProductCorrelation, parameter.covariance->getPartialResult()->get(covariance::crossProduct));
276 return _partialResult;
283 services::Status setResult(
const ResultPtr& res)
285 DAAL_CHECK(res, services::ErrorNullResult)
287 _res = _result.get();
288 return services::Status();
295 ResultPtr getResult()
305 services::SharedPtr<Distributed<step2Master, algorithmFPType, correlationDense> > clone()
const
307 return services::SharedPtr<Distributed<step2Master, algorithmFPType, correlationDense> >(cloneImpl());
310 DistributedInput<correlationDense> input;
311 DistributedParameter<step2Master, algorithmFPType, correlationDense> parameter;
314 services::SharedPtr<PartialResult<correlationDense> > _partialResult;
317 virtual Distributed<step2Master, algorithmFPType, correlationDense> * cloneImpl() const DAAL_C11_OVERRIDE
319 return new Distributed<step2Master, algorithmFPType, correlationDense>(*this);
322 services::Status allocateResult() DAAL_C11_OVERRIDE
324 services::Status s =_result->allocate<algorithmFPType>(_pres, ¶meter, correlationDense);
325 _res = _result.get();
329 services::Status allocatePartialResult() DAAL_C11_OVERRIDE
331 services::Status s = _partialResult->allocate<algorithmFPType>(&input, ¶meter, correlationDense);
332 _pres = _partialResult.get();
336 services::Status initializePartialResult() DAAL_C11_OVERRIDE {
return services::Status(); }
340 _ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, correlationDense)(&_env);
343 _partialResult.reset(
new PartialResult<correlationDense>());
344 _result.reset(
new ResultType());
355 template<
typename algorithmFPType>
356 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, svdDense> :
public Analysis<distributed>
359 typedef algorithms::pca::DistributedInput<svdDense> InputType;
360 typedef algorithms::pca::DistributedParameter<step2Master, algorithmFPType, svdDense> ParameterType;
361 typedef algorithms::pca::Result ResultType;
362 typedef algorithms::pca::PartialResult<svdDense> PartialResultType;
375 Distributed(
const Distributed<step2Master, algorithmFPType, svdDense> &other) :
376 input(other.input), parameter(other.parameter)
387 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)svdDense; }
393 services::Status setPartialResult(
const services::SharedPtr<PartialResult<svdDense> >& partialResult)
395 DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
396 _partialResult = partialResult;
397 _pres = _partialResult.get();
398 return services::Status();
405 services::SharedPtr<PartialResult<svdDense> > getPartialResult()
407 return _partialResult;
414 services::Status setResult(
const ResultPtr& res)
416 DAAL_CHECK(res, services::ErrorNullResult)
418 _res = _result.get();
419 return services::Status();
426 ResultPtr getResult()
436 services::SharedPtr<Distributed<step2Master, algorithmFPType, svdDense> > clone()
const
438 return services::SharedPtr<Distributed<step2Master, algorithmFPType, svdDense> >(cloneImpl());
441 DistributedInput<svdDense> input;
442 DistributedParameter<step2Master, algorithmFPType, svdDense> parameter;
445 services::SharedPtr<PartialResult<svdDense> > _partialResult;
448 virtual Distributed<step2Master, algorithmFPType, svdDense> * cloneImpl() const DAAL_C11_OVERRIDE
450 return new Distributed<step2Master, algorithmFPType, svdDense>(*this);
453 services::Status allocateResult() DAAL_C11_OVERRIDE
455 services::Status s = _result->allocate<algorithmFPType>(_pres, ¶meter, svdDense);
456 _res = _result.get();
460 services::Status allocatePartialResult() DAAL_C11_OVERRIDE
462 services::Status s = _partialResult->allocate<algorithmFPType>(&input, ¶meter, svdDense);
463 _pres = _partialResult.get();
466 services::Status initializePartialResult() DAAL_C11_OVERRIDE{
return services::Status(); }
470 _ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, svdDense)(&_env);
473 _partialResult.reset(
new PartialResult<svdDense>());
474 _result.reset(
new ResultType());
479 using interface1::DistributedContainer;
480 using interface1::Distributed;
daal::step1Local
Definition: daal_defines.h:123
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >
Computes the result of the PCA SVD algorithm on local nodes.
Definition: pca_distributed.h:356
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::parameter
DistributedParameter< step2Master, algorithmFPType, svdDense > parameter
Definition: pca_distributed.h:442
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::Distributed
Distributed()
Definition: pca_distributed.h:365
daal::algorithms::pca::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: pca_distributed.h:193
daal::algorithms::pca::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: pca_distributed.h:202
daal::algorithms::pca::correlationDense
Definition: pca_types.h:57
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: pca_distributed.h:253
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: pca_distributed.h:387
daal::algorithms::pca::interface1::DistributedInput< svdDense >
Input objects of the PCA SVD algorithm in the distributed processing mode.
Definition: pca_types.h:602
daal::algorithms::pca::interface1::Distributed
Computes the result of the PCA algorithm.
Definition: pca_distributed.h:158
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:522
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::Distributed
Distributed()
Definition: pca_distributed.h:231
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, svdDense > &other)
Definition: pca_distributed.h:375
daal::algorithms::pca::interface1::DistributedContainer< step1Local, algorithmFPType, correlationDense, cpu >::DistributedContainer
DistributedContainer(daal::services::Environment::env *daalEnv)
Constructor.
Definition: pca_distributed.h:67
daal::step2Master
Definition: daal_defines.h:124
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::setResult
services::Status setResult(const ResultPtr &res)
Definition: pca_distributed.h:283
daal::algorithms::pca::interface1::DistributedParameter< step2Master, algorithmFPType, svdDense >
daal::algorithms::covariance::nObservations
Definition: covariance_types.h:78
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >
Computes the result of the PCA Correlation algorithm on local nodes.
Definition: pca_distributed.h:222
daal::algorithms::pca::svdDense
Definition: pca_types.h:59
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::setResult
services::Status setResult(const ResultPtr &res)
Definition: pca_distributed.h:414
daal::algorithms::pca::interface1::Distributed< step1Local, algorithmFPType, method >
Computes the results of the PCA algorithm on the local nodes.
Definition: pca_distributed.h:175
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:55
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::getResult
ResultPtr getResult()
Definition: pca_distributed.h:426
daal::algorithms::kmeans::init::interface2::Distributed
class DAAL_EXPORT Distributed
Computes initial clusters for K-Means algorithm in the distributed processing mode.
Definition: kmeans_init_distributed.h:277
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::getResult
ResultPtr getResult()
Definition: pca_distributed.h:295
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::parameter
DistributedParameter< step2Master, algorithmFPType, correlationDense > parameter
Definition: pca_distributed.h:311
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::setPartialResult
services::Status setPartialResult(const services::SharedPtr< PartialResult< svdDense > > &partialResult)
Definition: pca_distributed.h:393
daal::algorithms::pca::interface1::OnlineContainer
Class containing methods to compute the result of the PCA algorithm.
Definition: pca_online.h:52
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::input
DistributedInput< correlationDense > input
Definition: pca_distributed.h:310
daal::algorithms::covariance::crossProduct
Definition: covariance_types.h:79
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:54
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:263
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::getPartialResult
services::SharedPtr< PartialResult< svdDense > > getPartialResult()
Definition: pca_distributed.h:405
daal::algorithms::pca::interface1::DistributedContainer< step1Local, algorithmFPType, svdDense, cpu >::DistributedContainer
DistributedContainer(daal::services::Environment::env *daalEnv)
Constructor.
Definition: pca_distributed.h:110
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::setPartialResult
services::Status setPartialResult(const services::SharedPtr< PartialResult< correlationDense > > &partialResult)
Definition: pca_distributed.h:259
daal::algorithms::covariance::sum
Definition: covariance_types.h:80
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, svdDense > > clone() const
Definition: pca_distributed.h:436
daal::algorithms::pca::interface1::Online
Computes the results of the PCA algorithm.
Definition: pca_online.h:116
daal::algorithms::pca::interface1::DistributedInput< correlationDense >
Input objects for the PCA Correlation algorithm in the distributed processing mode.
Definition: pca_types.h:550
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:107
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, correlationDense > &other)
Definition: pca_distributed.h:241
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::input
DistributedInput< svdDense > input
Definition: pca_distributed.h:441
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, correlationDense > > clone() const
Definition: pca_distributed.h:305
daal::distributed
Definition: daal_defines.h:113
daal::algorithms::pca::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed()
Definition: pca_distributed.h:186
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::getPartialResult
services::SharedPtr< PartialResult< correlationDense > > getPartialResult()
Definition: pca_distributed.h:271