48 #ifndef __SVD_DISTRIBUTED_H__ 49 #define __SVD_DISTRIBUTED_H__ 51 #include "algorithms/algorithm.h" 52 #include "data_management/data/numeric_table.h" 53 #include "services/daal_defines.h" 54 #include "algorithms/svd/svd_types.h" 55 #include "algorithms/svd/svd_online.h" 80 template<ComputeStep step,
typename algorithmFPType, Method method, CpuType cpu>
81 class DAAL_EXPORT DistributedContainer
92 template<
typename algorithmFPType, Method method, CpuType cpu>
93 class DAAL_EXPORT DistributedContainer<step1Local, algorithmFPType, method, cpu> :
public 94 OnlineContainer<algorithmFPType, method, cpu>
98 DistributedContainer(daal::services::Environment::env *daalEnv) : OnlineContainer<algorithmFPType, method, cpu>(daalEnv) {}
100 virtual ~DistributedContainer() {}
111 template<
typename algorithmFPType, Method method, CpuType cpu>
112 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, method, cpu> :
113 public daal::algorithms::AnalysisContainerIface<distributed>
121 DistributedContainer(daal::services::Environment::env *daalEnv);
123 virtual ~DistributedContainer();
128 virtual services::Status compute() DAAL_C11_OVERRIDE;
133 virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
144 template<
typename algorithmFPType, Method method, CpuType cpu>
145 class DAAL_EXPORT DistributedContainer<step3Local, algorithmFPType, method, cpu> :
146 public daal::algorithms::AnalysisContainerIface<distributed>
154 DistributedContainer(daal::services::Environment::env *daalEnv);
156 virtual ~DistributedContainer();
161 virtual services::Status compute() DAAL_C11_OVERRIDE;
166 virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
181 template<ComputeStep step,
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
182 class DAAL_EXPORT Distributed :
public daal::algorithms::Analysis<distributed> {};
195 template<
typename algorithmFPType, Method method>
196 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> :
public Online<algorithmFPType, method>
199 typedef Online<algorithmFPType, method> super;
201 typedef typename super::InputType InputType;
202 typedef typename super::ParameterType ParameterType;
203 typedef typename super::ResultType ResultType;
204 typedef typename super::PartialResultType PartialResultType;
206 Distributed() : Online<algorithmFPType, method>() {}
214 Distributed(
const Distributed<step1Local, algorithmFPType, method> &other) :
215 Online<algorithmFPType, method>(other)
223 services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone()
const 225 return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
229 virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl()
const DAAL_C11_OVERRIDE
231 return new Distributed<step1Local, algorithmFPType, method>(*this);
246 template<
typename algorithmFPType, Method method>
247 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> :
public daal::algorithms::Analysis<distributed>
250 typedef algorithms::svd::DistributedStep2Input InputType;
251 typedef algorithms::svd::Parameter ParameterType;
252 typedef algorithms::svd::Result ResultType;
253 typedef algorithms::svd::DistributedPartialResult PartialResultType;
256 ParameterType parameter;
269 Distributed(
const Distributed<step2Master, algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
278 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)method; }
284 ResultPtr getResult()
286 return _partialResult->get(finalResultFromStep2Master);
293 DistributedPartialResultPtr getPartialResult()
295 return _partialResult;
301 services::Status setPartialResult(
const DistributedPartialResultPtr& partialRes)
303 DAAL_CHECK(partialRes, services::ErrorNullPartialResult);
304 DAAL_CHECK(partialRes->get(finalResultFromStep2Master), services::ErrorNullResult)
305 _partialResult = partialRes;
306 _pres = _partialResult.get();
307 return services::Status();
313 services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
316 return services::Status(services::ErrorNullResult);
317 return _partialResult->check(_par, method);
325 services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone()
const 327 return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
331 virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl()
const DAAL_C11_OVERRIDE
333 return new Distributed<step2Master, algorithmFPType, method>(*this);
336 virtual services::Status allocateResult() DAAL_C11_OVERRIDE{
return services::Status(); }
338 virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
340 _partialResult.reset(
new PartialResultType());
341 services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
342 _pres = _partialResult.get();
346 virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
348 _pres = _partialResult.get();
349 return services::Status();
354 Analysis<distributed>::_ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
360 DistributedPartialResultPtr _partialResult;
374 template<
typename algorithmFPType, Method method>
375 class DAAL_EXPORT Distributed<step3Local, algorithmFPType, method> :
public 376 daal::algorithms::Analysis<distributed>
379 typedef algorithms::svd::DistributedStep3Input InputType;
380 typedef algorithms::svd::Parameter ParameterType;
381 typedef algorithms::svd::Result ResultType;
382 typedef algorithms::svd::DistributedPartialResultStep3 PartialResultType;
385 ParameterType parameter;
398 Distributed(
const Distributed<step3Local, algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
407 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)method; }
413 ResultPtr getResult()
415 return _partialResult->get(finalResultFromStep3);
422 DistributedPartialResultStep3Ptr getPartialResult()
424 return _partialResult;
431 services::Status setPartialResult(
const DistributedPartialResultStep3Ptr& partialRes)
433 DAAL_CHECK(partialRes, services::ErrorNullPartialResult);
434 DAAL_CHECK(partialRes->get(finalResultFromStep3), services::ErrorNullResult)
435 _partialResult = partialRes;
436 _pres = _partialResult.get();
437 return services::Status();
444 services::Status setResult(
const ResultPtr& res) {
return services::Status(); }
449 services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
452 return services::Status(services::ErrorNullResult);
453 return _partialResult->check(_par, method);
461 services::SharedPtr<Distributed<step3Local, algorithmFPType, method> > clone()
const 463 return services::SharedPtr<Distributed<step3Local, algorithmFPType, method> >(cloneImpl());
467 virtual Distributed<step3Local, algorithmFPType, method> * cloneImpl()
const DAAL_C11_OVERRIDE
469 return new Distributed<step3Local, algorithmFPType, method>(*this);
472 virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
474 _partialResult.reset(
new PartialResultType());
476 services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
480 data_management::DataCollectionPtr qCollection = input.get(inputOfStep3FromStep1);
482 s = _partialResult->setPartialResultStorage<algorithmFPType>(qCollection.get());
484 _pres = _partialResult.get();
488 virtual services::Status allocateResult() DAAL_C11_OVERRIDE{
return services::Status(); }
490 virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE{
return services::Status(); }
494 Analysis<distributed>::_ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step3Local, algorithmFPType, method)(&_env);
500 DistributedPartialResultStep3Ptr _partialResult;
504 using interface1::DistributedContainer;
505 using interface1::Distributed;
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::setResult
services::Status setResult(const ResultPtr &res)
Definition: svd_distributed.h:444
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:196
daal::algorithms::svd::interface1::Parameter
Parameters for the computation method of the SVD algorithm.
Definition: svd_types.h:187
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::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:79
daal::algorithms::svd::interface1::Online
Computes results of the SVD algorithm in the online processing mode.
Definition: svd_online.h:114
daal::algorithms::svd::inputOfStep3FromStep1
Definition: svd_types.h:173
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:131
daal::algorithms::svd::interface1::Result
Provides methods to access final results obtained with the compute() method of the SVD algorithm in t...
Definition: svd_types.h:425
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const DistributedPartialResultPtr &partialRes)
Definition: svd_distributed.h:301
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:375
daal::algorithms::svd::interface1::DistributedPartialResultStep3
Provides methods to access partial results obtained with the compute() method of the SVD algorithm in...
Definition: svd_types.h:609
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:247
daal::algorithms::svd::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: svd_distributed.h:223
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::checkFinalizeComputeParams
services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
Definition: svd_distributed.h:313
daal::algorithms::svd::interface1::DistributedContainer
Provides methods to run implementations of the SVD algorithm.
Definition: svd_distributed.h:81
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::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::input
InputType input
Definition: svd_distributed.h:384
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::svd::interface1::DistributedContainer< step1Local, algorithmFPType, method, cpu >::~DistributedContainer
virtual ~DistributedContainer()
Definition: svd_distributed.h:100
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, method > > clone() const
Definition: svd_distributed.h:325
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
ParameterType parameter
Definition: svd_distributed.h:256
daal::services::interface1::SharedPtr::get
T * get() const
Definition: daal_shared_ptr.h:332
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::getPartialResult
DistributedPartialResultStep3Ptr getPartialResult()
Definition: svd_distributed.h:422
daal::algorithms::svd::finalResultFromStep2Master
Definition: svd_types.h:142
daal::algorithms::svd::interface1::DistributedContainer< step1Local, algorithmFPType, method, cpu >::DistributedContainer
DistributedContainer(daal::services::Environment::env *daalEnv)
Definition: svd_distributed.h:98
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::input
InputType input
Definition: svd_distributed.h:255
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: svd_distributed.h:284
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::parameter
ParameterType parameter
Definition: svd_distributed.h:385
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: svd_distributed.h:407
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::getPartialResult
DistributedPartialResultPtr getPartialResult()
Definition: svd_distributed.h:293
daal::algorithms::svd::interface1::OnlineContainer
Provides methods to run implementations of the SVD algorithm in the online processing mode...
Definition: svd_online.h:79
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step3Local, algorithmFPType, method > > clone() const
Definition: svd_distributed.h:461
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const DistributedPartialResultStep3Ptr &partialRes)
Definition: svd_distributed.h:431
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: svd_distributed.h:413
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step3Local, algorithmFPType, method > &other)
Definition: svd_distributed.h:398
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:94
daal::algorithms::svd::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: svd_distributed.h:214
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::svd::finalResultFromStep3
Definition: svd_types.h:153
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: svd_distributed.h:278
daal::algorithms::svd::interface1::Distributed< step3Local, algorithmFPType, method >::checkFinalizeComputeParams
services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
Definition: svd_distributed.h:449
daal::step2Master
Definition: daal_defines.h:144
daal::algorithms::svd::interface1::OnlinePartialResult
Provides methods to access partial results obtained with the compute() method of the SVD algorithm in...
Definition: svd_types.h:342
daal::algorithms::svd::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: svd_distributed.h:269
daal::step3Local
Definition: daal_defines.h:145
daal::algorithms::svd::interface1::DistributedPartialResult
Provides methods to access partial results obtained with the compute() method of the SVD algorithm in...
Definition: svd_types.h:510
daal::algorithms::svd::interface1::Distributed
Computes results of the SVD algorithm in the distributed processing mode.
Definition: svd_distributed.h:182
daal::services::ErrorNullResult
Definition: error_indexes.h:122