22 #ifndef __SVD_DISTRIBUTED_H__
23 #define __SVD_DISTRIBUTED_H__
25 #include "algorithms/algorithm.h"
26 #include "data_management/data/numeric_table.h"
27 #include "services/daal_defines.h"
28 #include "algorithms/svd/svd_types.h"
29 #include "algorithms/svd/svd_online.h"
54 template<ComputeStep step,
typename algorithmFPType, Method method, CpuType cpu>
55 class DAAL_EXPORT DistributedContainer
66 template<
typename algorithmFPType, Method method, CpuType cpu>
67 class DAAL_EXPORT DistributedContainer<step1Local, algorithmFPType, method, cpu> :
public
68 OnlineContainer<algorithmFPType, method, cpu>
72 DistributedContainer(daal::services::Environment::env *daalEnv) : OnlineContainer<algorithmFPType, method, cpu>(daalEnv) {}
74 virtual ~DistributedContainer() {}
85 template<
typename algorithmFPType, Method method, CpuType cpu>
86 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, method, cpu> :
87 public daal::algorithms::AnalysisContainerIface<distributed>
95 DistributedContainer(daal::services::Environment::env *daalEnv);
97 virtual ~DistributedContainer();
102 virtual services::Status compute() DAAL_C11_OVERRIDE;
107 virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
118 template<
typename algorithmFPType, Method method, CpuType cpu>
119 class DAAL_EXPORT DistributedContainer<step3Local, algorithmFPType, method, cpu> :
120 public daal::algorithms::AnalysisContainerIface<distributed>
128 DistributedContainer(daal::services::Environment::env *daalEnv);
130 virtual ~DistributedContainer();
135 virtual services::Status compute() DAAL_C11_OVERRIDE;
140 virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
155 template<ComputeStep step,
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
156 class DAAL_EXPORT Distributed :
public daal::algorithms::Analysis<distributed> {};
169 template<
typename algorithmFPType, Method method>
170 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> :
public Online<algorithmFPType, method>
173 typedef Online<algorithmFPType, method> super;
175 typedef typename super::InputType InputType;
176 typedef typename super::ParameterType ParameterType;
177 typedef typename super::ResultType ResultType;
178 typedef typename super::PartialResultType PartialResultType;
180 Distributed() : Online<algorithmFPType, method>() {}
188 Distributed(
const Distributed<step1Local, algorithmFPType, method> &other) :
189 Online<algorithmFPType, method>(other)
197 services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone()
const
199 return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
203 virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
205 return new Distributed<step1Local, algorithmFPType, method>(*this);
220 template<
typename algorithmFPType, Method method>
221 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> :
public daal::algorithms::Analysis<distributed>
224 typedef algorithms::svd::DistributedStep2Input InputType;
225 typedef algorithms::svd::Parameter ParameterType;
226 typedef algorithms::svd::Result ResultType;
227 typedef algorithms::svd::DistributedPartialResult PartialResultType;
230 ParameterType parameter;
243 Distributed(
const Distributed<step2Master, algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
252 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)method; }
258 ResultPtr getResult()
260 return _partialResult->get(finalResultFromStep2Master);
267 DistributedPartialResultPtr getPartialResult()
269 return _partialResult;
275 services::Status setPartialResult(
const DistributedPartialResultPtr& partialRes)
277 DAAL_CHECK(partialRes, services::ErrorNullPartialResult);
278 DAAL_CHECK(partialRes->get(finalResultFromStep2Master), services::ErrorNullResult)
279 _partialResult = partialRes;
280 _pres = _partialResult.get();
281 return services::Status();
287 services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
290 return services::Status(services::ErrorNullResult);
291 return _partialResult->check(_par, method);
299 services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone()
const
301 return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
305 virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
307 return new Distributed<step2Master, algorithmFPType, method>(*this);
310 virtual services::Status allocateResult() DAAL_C11_OVERRIDE{
return services::Status(); }
312 virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
314 _partialResult.reset(
new PartialResultType());
315 services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
316 _pres = _partialResult.get();
320 virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
322 _pres = _partialResult.get();
323 return services::Status();
328 Analysis<distributed>::_ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
334 DistributedPartialResultPtr _partialResult;
348 template<
typename algorithmFPType, Method method>
349 class DAAL_EXPORT Distributed<step3Local, algorithmFPType, method> :
public
350 daal::algorithms::Analysis<distributed>
353 typedef algorithms::svd::DistributedStep3Input InputType;
354 typedef algorithms::svd::Parameter ParameterType;
355 typedef algorithms::svd::Result ResultType;
356 typedef algorithms::svd::DistributedPartialResultStep3 PartialResultType;
359 ParameterType parameter;
372 Distributed(
const Distributed<step3Local, algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
381 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)method; }
387 ResultPtr getResult()
389 return _partialResult->get(finalResultFromStep3);
396 DistributedPartialResultStep3Ptr getPartialResult()
398 return _partialResult;
405 services::Status setPartialResult(
const DistributedPartialResultStep3Ptr& partialRes)
407 DAAL_CHECK(partialRes, services::ErrorNullPartialResult);
408 DAAL_CHECK(partialRes->get(finalResultFromStep3), services::ErrorNullResult)
409 _partialResult = partialRes;
410 _pres = _partialResult.get();
411 return services::Status();
418 services::Status setResult(
const ResultPtr& res) {
return services::Status(); }
423 services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
426 return services::Status(services::ErrorNullResult);
427 return _partialResult->check(_par, method);
435 services::SharedPtr<Distributed<step3Local, algorithmFPType, method> > clone()
const
437 return services::SharedPtr<Distributed<step3Local, algorithmFPType, method> >(cloneImpl());
441 virtual Distributed<step3Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
443 return new Distributed<step3Local, algorithmFPType, method>(*this);
446 virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
448 _partialResult.reset(
new PartialResultType());
450 services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
454 data_management::DataCollectionPtr qCollection = input.get(inputOfStep3FromStep1);
456 s = _partialResult->setPartialResultStorage<algorithmFPType>(qCollection.get());
458 _pres = _partialResult.get();
462 virtual services::Status allocateResult() DAAL_C11_OVERRIDE{
return services::Status(); }
464 virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE{
return services::Status(); }
468 Analysis<distributed>::_ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step3Local, algorithmFPType, method)(&_env);
474 DistributedPartialResultStep3Ptr _partialResult;
478 using interface1::DistributedContainer;
479 using interface1::Distributed;
daal::algorithms::svd::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: svd_distributed.h:197
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::setResult
services::Status setResult(const ResultPtr &res)
Definition: svd_distributed.h:418
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step3Local, algorithmFPType, method > > clone() const
Definition: svd_distributed.h:435
daal::algorithms::svd::interface1::Distributed< step1Local, algorithmFPType, method >
Runs the first step of the SVD algorithm in the distributed processing mode.
Definition: svd_distributed.h:170
daal
Definition: algorithm_base_common.h:31
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::svd::interface1::Online
Computes results of the SVD algorithm in the online processing mode.
Definition: svd_online.h:88
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, method > > clone() const
Definition: svd_distributed.h:299
daal::algorithms::svd::inputOfStep3FromStep1
Definition: svd_types.h:147
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:105
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const DistributedPartialResultPtr &partialRes)
Definition: svd_distributed.h:275
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >
Runs the third step of the SVD algorithm in the distributed processing mode.
Definition: svd_distributed.h:349
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >
Runs the second step of the SVD algorithm in the distributed processing mode.
Definition: svd_distributed.h:221
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::checkFinalizeComputeParams
services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
Definition: svd_distributed.h:287
daal::algorithms::svd::interface1::DistributedContainer
Provides methods to run implementations of the SVD algorithm.
Definition: svd_distributed.h:55
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:255
daal::distributed
Definition: daal_defines.h:107
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::input
InputType input
Definition: svd_distributed.h:358
daal::algorithms::svd::interface1::DistributedContainer< step1Local, algorithmFPType, method, cpu >::~DistributedContainer
virtual ~DistributedContainer()
Definition: svd_distributed.h:74
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
ParameterType parameter
Definition: svd_distributed.h:230
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::getPartialResult
DistributedPartialResultStep3Ptr getPartialResult()
Definition: svd_distributed.h:396
daal::algorithms::svd::finalResultFromStep2Master
Definition: svd_types.h:116
daal::algorithms::svd::interface1::DistributedContainer< step1Local, algorithmFPType, method, cpu >::DistributedContainer
DistributedContainer(daal::services::Environment::env *daalEnv)
Definition: svd_distributed.h:72
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::input
InputType input
Definition: svd_distributed.h:229
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: svd_distributed.h:258
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::parameter
ParameterType parameter
Definition: svd_distributed.h:359
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: svd_distributed.h:381
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::getPartialResult
DistributedPartialResultPtr getPartialResult()
Definition: svd_distributed.h:267
daal::algorithms::svd::interface1::OnlineContainer
Provides methods to run implementations of the SVD algorithm in the online processing mode...
Definition: svd_online.h:53
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const DistributedPartialResultStep3Ptr &partialRes)
Definition: svd_distributed.h:405
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: svd_distributed.h:387
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step3Local, algorithmFPType, method > &other)
Definition: svd_distributed.h:372
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::svd::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: svd_distributed.h:188
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:117
daal::algorithms::svd::finalResultFromStep3
Definition: svd_types.h:127
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: svd_distributed.h:252
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::checkFinalizeComputeParams
services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
Definition: svd_distributed.h:423
daal::step2Master
Definition: daal_defines.h:118
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: svd_distributed.h:243
daal::step3Local
Definition: daal_defines.h:119
daal::algorithms::svd::interface1::Distributed
Computes results of the SVD algorithm in the distributed processing mode.
Definition: svd_distributed.h:156
daal::services::ErrorNullResult
Definition: error_indexes.h:96