24 #ifndef __SVD_DISTRIBUTED_H__
25 #define __SVD_DISTRIBUTED_H__
27 #include "algorithms/algorithm.h"
28 #include "data_management/data/numeric_table.h"
29 #include "services/daal_defines.h"
30 #include "algorithms/svd/svd_types.h"
31 #include "algorithms/svd/svd_online.h"
56 template<ComputeStep step,
typename algorithmFPType, Method method, CpuType cpu>
57 class DistributedContainer
68 template<
typename algorithmFPType, Method method, CpuType cpu>
69 class DistributedContainer<step1Local, algorithmFPType, method, cpu> :
public
70 OnlineContainer<algorithmFPType, method, cpu>
74 DistributedContainer(daal::services::Environment::env *daalEnv) : OnlineContainer<algorithmFPType, method, cpu>(daalEnv) {}
76 virtual ~DistributedContainer() {}
87 template<
typename algorithmFPType, Method method, CpuType cpu>
88 class DistributedContainer<step2Master, algorithmFPType, method, cpu> :
89 public daal::algorithms::AnalysisContainerIface<distributed>
97 DistributedContainer(daal::services::Environment::env *daalEnv);
99 virtual ~DistributedContainer();
104 virtual services::Status compute() DAAL_C11_OVERRIDE;
109 virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
120 template<
typename algorithmFPType, Method method, CpuType cpu>
121 class DistributedContainer<step3Local, algorithmFPType, method, cpu> :
122 public daal::algorithms::AnalysisContainerIface<distributed>
130 DistributedContainer(daal::services::Environment::env *daalEnv);
132 virtual ~DistributedContainer();
137 virtual services::Status compute() DAAL_C11_OVERRIDE;
142 virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
157 template<ComputeStep step,
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
158 class DAAL_EXPORT Distributed :
public daal::algorithms::Analysis<distributed> {};
171 template<
typename algorithmFPType, Method method>
172 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> :
public Online<algorithmFPType, method>
175 typedef Online<algorithmFPType, method> super;
177 typedef typename super::InputType InputType;
178 typedef typename super::ParameterType ParameterType;
179 typedef typename super::ResultType ResultType;
180 typedef typename super::PartialResultType PartialResultType;
182 Distributed() : Online<algorithmFPType, method>() {}
190 Distributed(
const Distributed<step1Local, algorithmFPType, method> &other) :
191 Online<algorithmFPType, method>(other)
199 services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone()
const
201 return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
205 virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
207 return new Distributed<step1Local, algorithmFPType, method>(*this);
222 template<
typename algorithmFPType, Method method>
223 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> :
public daal::algorithms::Analysis<distributed>
226 typedef algorithms::svd::DistributedStep2Input InputType;
227 typedef algorithms::svd::Parameter ParameterType;
228 typedef algorithms::svd::Result ResultType;
229 typedef algorithms::svd::DistributedPartialResult PartialResultType;
232 ParameterType parameter;
245 Distributed(
const Distributed<step2Master, algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
254 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)method; }
260 ResultPtr getResult()
262 return _partialResult->get(finalResultFromStep2Master);
269 DistributedPartialResultPtr getPartialResult()
271 return _partialResult;
277 services::Status setPartialResult(
const DistributedPartialResultPtr& partialRes)
279 DAAL_CHECK(partialRes, services::ErrorNullPartialResult);
280 DAAL_CHECK(partialRes->get(finalResultFromStep2Master), services::ErrorNullResult)
281 _partialResult = partialRes;
282 _pres = _partialResult.get();
283 return services::Status();
289 services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
292 return services::Status(services::ErrorNullResult);
293 return _partialResult->check(_par, method);
301 services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone()
const
303 return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
307 virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
309 return new Distributed<step2Master, algorithmFPType, method>(*this);
312 virtual services::Status allocateResult() DAAL_C11_OVERRIDE{
return services::Status(); }
314 virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
316 _partialResult.reset(
new PartialResultType());
317 services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
318 _pres = _partialResult.get();
322 virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
324 _pres = _partialResult.get();
325 return services::Status();
330 Analysis<distributed>::_ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
336 DistributedPartialResultPtr _partialResult;
350 template<
typename algorithmFPType, Method method>
351 class DAAL_EXPORT Distributed<step3Local, algorithmFPType, method> :
public
352 daal::algorithms::Analysis<distributed>
355 typedef algorithms::svd::DistributedStep3Input InputType;
356 typedef algorithms::svd::Parameter ParameterType;
357 typedef algorithms::svd::Result ResultType;
358 typedef algorithms::svd::DistributedPartialResultStep3 PartialResultType;
361 ParameterType parameter;
374 Distributed(
const Distributed<step3Local, algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
383 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)method; }
389 ResultPtr getResult()
391 return _partialResult->get(finalResultFromStep3);
398 DistributedPartialResultStep3Ptr getPartialResult()
400 return _partialResult;
407 services::Status setPartialResult(
const DistributedPartialResultStep3Ptr& partialRes)
409 DAAL_CHECK(partialRes, services::ErrorNullPartialResult);
410 DAAL_CHECK(partialRes->get(finalResultFromStep3), services::ErrorNullResult)
411 _partialResult = partialRes;
412 _pres = _partialResult.get();
413 return services::Status();
420 services::Status setResult(
const ResultPtr& res) {
return services::Status(); }
425 services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
428 return services::Status(services::ErrorNullResult);
429 return _partialResult->check(_par, method);
437 services::SharedPtr<Distributed<step3Local, algorithmFPType, method> > clone()
const
439 return services::SharedPtr<Distributed<step3Local, algorithmFPType, method> >(cloneImpl());
443 virtual Distributed<step3Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
445 return new Distributed<step3Local, algorithmFPType, method>(*this);
448 virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
450 _partialResult.reset(
new PartialResultType());
452 services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
456 data_management::DataCollectionPtr qCollection = input.get(inputOfStep3FromStep1);
458 s = _partialResult->setPartialResultStorage<algorithmFPType>(qCollection.get());
460 _pres = _partialResult.get();
464 virtual services::Status allocateResult() DAAL_C11_OVERRIDE{
return services::Status(); }
466 virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE{
return services::Status(); }
470 Analysis<distributed>::_ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step3Local, algorithmFPType, method)(&_env);
476 DistributedPartialResultStep3Ptr _partialResult;
480 using interface1::DistributedContainer;
481 using interface1::Distributed;
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: svd_distributed.h:383
daal::step1Local
Definition: daal_defines.h:123
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::checkFinalizeComputeParams
services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
Definition: svd_distributed.h:289
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::input
InputType input
Definition: svd_distributed.h:360
daal::algorithms::svd::interface1::DistributedContainer< step1Local, algorithmFPType, method, cpu >::DistributedContainer
DistributedContainer(daal::services::Environment::env *daalEnv)
Definition: svd_distributed.h:74
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::getPartialResult
DistributedPartialResultPtr getPartialResult()
Definition: svd_distributed.h:269
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::parameter
ParameterType parameter
Definition: svd_distributed.h:361
daal::algorithms::svd::interface1::DistributedContainer
Provides methods to run implementations of the SVD algorithm.
Definition: svd_distributed.h:57
daal::algorithms::svd::interface1::DistributedContainer< step1Local, algorithmFPType, method, cpu >::~DistributedContainer
virtual ~DistributedContainer()
Definition: svd_distributed.h:76
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: svd_distributed.h:260
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:351
daal::algorithms::svd::inputOfStep3FromStep1
Definition: svd_types.h:149
daal::algorithms::svd::finalResultFromStep3
Definition: svd_types.h:129
daal::algorithms::svd::interface1::OnlineContainer
Provides methods to run implementations of the SVD algorithm in the online processing mode...
Definition: svd_online.h:55
daal::step2Master
Definition: daal_defines.h:124
daal::algorithms::svd::finalResultFromStep2Master
Definition: svd_types.h:118
daal::step3Local
Definition: daal_defines.h:125
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::svd::interface1::Distributed< step3Local, algorithmFPType, method >::setResult
services::Status setResult(const ResultPtr &res)
Definition: svd_distributed.h:420
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step3Local, algorithmFPType, method > > clone() const
Definition: svd_distributed.h:437
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
ParameterType parameter
Definition: svd_distributed.h:232
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::svd::interface1::Distributed< step3Local, algorithmFPType, method >::checkFinalizeComputeParams
services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
Definition: svd_distributed.h:425
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::input
InputType input
Definition: svd_distributed.h:231
daal::algorithms::svd::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: svd_distributed.h:199
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:172
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::getPartialResult
DistributedPartialResultStep3Ptr getPartialResult()
Definition: svd_distributed.h:398
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: svd_distributed.h:254
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: svd_distributed.h:389
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step3Local, algorithmFPType, method > &other)
Definition: svd_distributed.h:374
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const DistributedPartialResultPtr &partialRes)
Definition: svd_distributed.h:277
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:223
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: svd_distributed.h:245
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, method > > clone() const
Definition: svd_distributed.h:301
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:107
daal::algorithms::svd::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: svd_distributed.h:190
daal::distributed
Definition: daal_defines.h:113
daal::algorithms::svd::interface1::Online
Computes results of the SVD algorithm in the online processing mode.
Definition: svd_online.h:90
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const DistributedPartialResultStep3Ptr &partialRes)
Definition: svd_distributed.h:407
daal::algorithms::svd::interface1::Distributed
Computes results of the SVD algorithm in the distributed processing mode.
Definition: svd_distributed.h:158