49 #ifndef __PCA_DISTRIBUTED_H__ 50 #define __PCA_DISTRIBUTED_H__ 52 #include "algorithms/algorithm.h" 53 #include "data_management/data/numeric_table.h" 54 #include "services/daal_defines.h" 55 #include "services/daal_memory.h" 56 #include "algorithms/pca/pca_types.h" 57 #include "algorithms/pca/pca_online.h" 77 template<ComputeStep computeStep,
typename algorithmFPType, Method method, CpuType cpu>
78 class DAAL_EXPORT DistributedContainer
85 template<
typename algorithmFPType, CpuType cpu>
86 class DAAL_EXPORT DistributedContainer<step1Local, algorithmFPType, correlationDense, cpu> :
public 87 OnlineContainer<algorithmFPType, correlationDense, cpu>
91 DistributedContainer(daal::services::Environment::env *daalEnv) : OnlineContainer<algorithmFPType, correlationDense, cpu>(daalEnv) {};
92 virtual ~DistributedContainer() {}
99 template<
typename algorithmFPType, CpuType cpu>
100 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, correlationDense, cpu> :
public AnalysisContainerIface<distributed>
108 DistributedContainer(daal::services::Environment::env *daalEnv);
110 virtual ~DistributedContainer();
116 services::Status compute() DAAL_C11_OVERRIDE;
121 services::Status finalizeCompute() DAAL_C11_OVERRIDE;
129 template<
typename algorithmFPType, CpuType cpu>
130 class DAAL_EXPORT DistributedContainer<step1Local, algorithmFPType, svdDense, cpu> :
public OnlineContainer<algorithmFPType, svdDense, cpu>
134 DistributedContainer(daal::services::Environment::env *daalEnv) : OnlineContainer<algorithmFPType, svdDense, cpu>(daalEnv) {};
135 virtual ~DistributedContainer() {}
142 template<
typename algorithmFPType, CpuType cpu>
143 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, svdDense, cpu> :
public AnalysisContainerIface<distributed>
151 DistributedContainer(daal::services::Environment::env *daalEnv);
153 ~DistributedContainer();
159 services::Status compute() DAAL_C11_OVERRIDE;
164 services::Status finalizeCompute() DAAL_C11_OVERRIDE;
181 template<ComputeStep computeStep,
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = correlationDense>
182 class DAAL_EXPORT Distributed :
public Analysis<distributed> {};
198 template<
typename algorithmFPType, Method method>
199 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> :
public Online<algorithmFPType, method>
202 typedef Online<algorithmFPType, method> super;
204 typedef typename super::InputType InputType;
205 typedef typename super::ParameterType ParameterType;
206 typedef typename super::ResultType ResultType;
207 typedef typename super::PartialResultType PartialResultType;
210 Distributed() : Online<algorithmFPType, method>() {}
217 Distributed(
const Distributed<step1Local, algorithmFPType, method> &other) :
218 Online<algorithmFPType, method>(other)
226 services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone()
const 228 return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
232 virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl()
const DAAL_C11_OVERRIDE
234 return new Distributed<step1Local, algorithmFPType, method>(*this);
245 template<
typename algorithmFPType>
246 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, correlationDense> :
public Analysis<distributed>
249 typedef algorithms::pca::DistributedInput<correlationDense> InputType;
250 typedef algorithms::pca::DistributedParameter<step2Master, algorithmFPType, correlationDense> ParameterType;
251 typedef algorithms::pca::Result ResultType;
252 typedef algorithms::pca::PartialResult<correlationDense> PartialResultType;
265 Distributed(
const Distributed<step2Master, algorithmFPType, correlationDense> &other) :
266 input(other.input), parameter(other.parameter)
277 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)correlationDense; }
283 services::Status setPartialResult(
const services::SharedPtr<PartialResult<correlationDense> >& partialResult)
285 DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
286 _partialResult = partialResult;
287 _pres = _partialResult.get();
288 return services::Status();
295 services::SharedPtr<PartialResult<correlationDense> > getPartialResult()
297 _partialResult->set(sumCorrelation, parameter.covariance->getPartialResult()->get(covariance::sum));
298 _partialResult->set(nObservationsCorrelation, parameter.covariance->getPartialResult()->get(covariance::nObservations));
299 _partialResult->set(crossProductCorrelation, parameter.covariance->getPartialResult()->get(covariance::crossProduct));
300 return _partialResult;
307 services::Status setResult(
const ResultPtr& res)
309 DAAL_CHECK(res, services::ErrorNullResult)
311 _res = _result.get();
312 return services::Status();
319 ResultPtr getResult()
329 services::SharedPtr<Distributed<step2Master, algorithmFPType, correlationDense> > clone()
const 331 return services::SharedPtr<Distributed<step2Master, algorithmFPType, correlationDense> >(cloneImpl());
334 DistributedInput<correlationDense> input;
335 DistributedParameter<step2Master, algorithmFPType, correlationDense> parameter;
338 services::SharedPtr<PartialResult<correlationDense> > _partialResult;
341 virtual Distributed<step2Master, algorithmFPType, correlationDense> * cloneImpl() const DAAL_C11_OVERRIDE
343 return new Distributed<step2Master, algorithmFPType, correlationDense>(*this);
346 services::Status allocateResult() DAAL_C11_OVERRIDE
348 services::Status s =_result->allocate<algorithmFPType>(_pres, ¶meter, correlationDense);
349 _res = _result.get();
353 services::Status allocatePartialResult() DAAL_C11_OVERRIDE
355 services::Status s = _partialResult->allocate<algorithmFPType>(&input, ¶meter, correlationDense);
356 _pres = _partialResult.get();
360 services::Status initializePartialResult() DAAL_C11_OVERRIDE {
return services::Status(); }
364 _ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, correlationDense)(&_env);
367 _partialResult.reset(
new PartialResult<correlationDense>());
368 _result.reset(
new ResultType());
379 template<
typename algorithmFPType>
380 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, svdDense> :
public Analysis<distributed>
383 typedef algorithms::pca::DistributedInput<svdDense> InputType;
384 typedef algorithms::pca::DistributedParameter<step2Master, algorithmFPType, svdDense> ParameterType;
385 typedef algorithms::pca::Result ResultType;
386 typedef algorithms::pca::PartialResult<svdDense> PartialResultType;
399 Distributed(
const Distributed<step2Master, algorithmFPType, svdDense> &other) :
400 input(other.input), parameter(other.parameter)
411 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)svdDense; }
417 services::Status setPartialResult(
const services::SharedPtr<PartialResult<svdDense> >& partialResult)
419 DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
420 _partialResult = partialResult;
421 _pres = _partialResult.get();
422 return services::Status();
429 services::SharedPtr<PartialResult<svdDense> > getPartialResult()
431 return _partialResult;
438 services::Status setResult(
const ResultPtr& res)
440 DAAL_CHECK(res, services::ErrorNullResult)
442 _res = _result.get();
443 return services::Status();
450 ResultPtr getResult()
460 services::SharedPtr<Distributed<step2Master, algorithmFPType, svdDense> > clone()
const 462 return services::SharedPtr<Distributed<step2Master, algorithmFPType, svdDense> >(cloneImpl());
465 DistributedInput<svdDense> input;
466 DistributedParameter<step2Master, algorithmFPType, svdDense> parameter;
469 services::SharedPtr<PartialResult<svdDense> > _partialResult;
472 virtual Distributed<step2Master, algorithmFPType, svdDense> * cloneImpl() const DAAL_C11_OVERRIDE
474 return new Distributed<step2Master, algorithmFPType, svdDense>(*this);
477 services::Status allocateResult() DAAL_C11_OVERRIDE
479 services::Status s = _result->allocate<algorithmFPType>(_pres, ¶meter, svdDense);
480 _res = _result.get();
484 services::Status allocatePartialResult() DAAL_C11_OVERRIDE
486 services::Status s = _partialResult->allocate<algorithmFPType>(&input, ¶meter, svdDense);
487 _pres = _partialResult.get();
490 services::Status initializePartialResult() DAAL_C11_OVERRIDE{
return services::Status(); }
494 _ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, svdDense)(&_env);
497 _partialResult.reset(
new PartialResult<svdDense>());
498 _result.reset(
new ResultType());
503 using interface1::DistributedContainer;
504 using interface1::Distributed;
daal::algorithms::pca::interface1::DistributedParameter
Class that specifies the parameters of the PCA algorithm in the distributed computing mode...
Definition: pca_types.h:539
daal::algorithms::pca::interface1::Distributed< step1Local, algorithmFPType, method >
Computes the results of the PCA algorithm on the local nodes.
Definition: pca_distributed.h:199
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::Distributed
Distributed()
Definition: pca_distributed.h:255
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::input
DistributedInput< svdDense > input
Definition: pca_distributed.h:465
daal::algorithms::covariance::crossProduct
Definition: covariance_types.h:103
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, correlationDense > &other)
Definition: pca_distributed.h:265
daal::services::interface1::Environment::_envStruct
The environment structure.
Definition: env_detect.h:95
daal::services::interface1::Status
Class that holds the results of API calls. In case of API routine failure it contains the list of err...
Definition: error_handling.h:491
daal
Definition: algorithm_base_common.h:57
daal::algorithms::pca::interface1::Online
Computes the results of the PCA algorithm.
Definition: pca_online.h:140
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:79
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:131
daal::algorithms::pca::interface1::OnlineContainer
Class containing methods to compute the result of the PCA algorithm.
Definition: pca_online.h:76
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::setResult
services::Status setResult(const ResultPtr &res)
Definition: pca_distributed.h:438
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >
Computes the result of the PCA Correlation algorithm on local nodes.
Definition: pca_distributed.h:246
daal::algorithms::kmeans::init::interface1::Distributed
class DAAL_EXPORT Distributed
Computes initial clusters for the K-Means algorithm in the distributed processing mode...
Definition: kmeans_init_distributed.h:281
daal::distributed
Definition: daal_defines.h:133
daal::services::interface1::SharedPtr
Shared pointer that retains shared ownership of an object through a pointer. Several SharedPtr object...
Definition: daal_shared_ptr.h:187
daal::algorithms::pca::interface2::Result
Provides methods to access results obtained with the PCA algorithm.
Definition: pca_types.h:753
daal::algorithms::covariance::sum
Definition: covariance_types.h:104
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:287
daal::algorithms::pca::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: pca_distributed.h:226
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::getPartialResult
services::SharedPtr< PartialResult< svdDense > > getPartialResult()
Definition: pca_distributed.h:429
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, svdDense > > clone() const
Definition: pca_distributed.h:460
daal::services::interface1::SharedPtr::get
T * get() const
Definition: daal_shared_ptr.h:332
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::input
DistributedInput< correlationDense > input
Definition: pca_distributed.h:334
daal::algorithms::pca::svdDense
Definition: pca_types.h:83
daal::services::interface1::SharedPtr::reset
void reset()
Definition: daal_shared_ptr.h:265
daal::algorithms::pca::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: pca_distributed.h:217
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:78
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::Distributed
Distributed()
Definition: pca_distributed.h:389
daal::algorithms::pca::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed()
Definition: pca_distributed.h:210
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, svdDense > &other)
Definition: pca_distributed.h:399
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:94
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::parameter
DistributedParameter< step2Master, algorithmFPType, correlationDense > parameter
Definition: pca_distributed.h:335
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:81
daal::step1Local
Definition: daal_defines.h:143
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >
Computes the result of the PCA SVD algorithm on local nodes.
Definition: pca_distributed.h:380
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::setPartialResult
services::Status setPartialResult(const services::SharedPtr< PartialResult< svdDense > > &partialResult)
Definition: pca_distributed.h:417
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::setResult
services::Status setResult(const ResultPtr &res)
Definition: pca_distributed.h:307
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::getPartialResult
services::SharedPtr< PartialResult< correlationDense > > getPartialResult()
Definition: pca_distributed.h:295
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::setPartialResult
services::Status setPartialResult(const services::SharedPtr< PartialResult< correlationDense > > &partialResult)
Definition: pca_distributed.h:283
daal::step2Master
Definition: daal_defines.h:144
daal::algorithms::pca::interface1::DistributedContainer< step1Local, algorithmFPType, correlationDense, cpu >::DistributedContainer
DistributedContainer(daal::services::Environment::env *daalEnv)
Constructor.
Definition: pca_distributed.h:91
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, correlationDense > > clone() const
Definition: pca_distributed.h:329
daal::algorithms::covariance::nObservations
Definition: covariance_types.h:102
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:546
daal::algorithms::pca::interface1::DistributedContainer< step1Local, algorithmFPType, svdDense, cpu >::DistributedContainer
DistributedContainer(daal::services::Environment::env *daalEnv)
Constructor.
Definition: pca_distributed.h:134
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, correlationDense >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: pca_distributed.h:277
daal::services::ErrorNullResult
Definition: error_indexes.h:122
daal::algorithms::pca::interface1::Distributed
Computes the result of the PCA algorithm.
Definition: pca_distributed.h:182
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::parameter
DistributedParameter< step2Master, algorithmFPType, svdDense > parameter
Definition: pca_distributed.h:466
daal::algorithms::pca::interface1::Distributed< step2Master, algorithmFPType, svdDense >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: pca_distributed.h:411
daal::algorithms::pca::correlationDense
Definition: pca_types.h:81