49 #ifndef __COVARIANCE_DISTRIBUTED_H__ 50 #define __COVARIANCE_DISTRIBUTED_H__ 52 #include "algorithms/algorithm.h" 53 #include "data_management/data/numeric_table.h" 54 #include "services/daal_defines.h" 55 #include "algorithms/covariance/covariance_types.h" 56 #include "algorithms/covariance/covariance_online.h" 80 template<ComputeStep step>
81 class DistributedContainerIface
93 class DistributedContainerIface<step2Master> :
public daal::algorithms::AnalysisContainerIface<distributed>
96 DistributedContainerIface() {};
97 virtual ~DistributedContainerIface() {};
103 virtual services::Status compute() = 0;
108 virtual services::Status finalizeCompute() = 0;
121 template<ComputeStep step,
typename algorithmFPType, Method method, CpuType cpu>
122 class DAAL_EXPORT DistributedContainer
130 template<
typename algorithmFPType, Method method, CpuType cpu>
131 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, method, cpu> :
public DistributedContainerIface<step2Master>
139 DistributedContainer(daal::services::Environment::env *daalEnv);
141 virtual ~DistributedContainer();
146 virtual services::Status compute() DAAL_C11_OVERRIDE;
151 virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
175 template<ComputeStep step>
176 class DAAL_EXPORT DistributedIface :
public daal::algorithms::Analysis<distributed>
201 class DistributedIface<step1Local> :
public OnlineImpl
204 typedef OnlineImpl super;
206 typedef algorithms::covariance::DistributedInput<step1Local> InputType;
207 typedef super::ParameterType ParameterType;
208 typedef super::ResultType ResultType;
209 typedef super::PartialResultType PartialResultType;
212 DistributedIface() : OnlineImpl()
222 DistributedIface(
const DistributedIface<step1Local> &other) : OnlineImpl(other)
231 services::SharedPtr<DistributedIface<step1Local> > clone()
const 233 return services::SharedPtr<DistributedIface<step1Local> >(cloneImpl());
237 virtual DistributedIface<step1Local> * cloneImpl()
const DAAL_C11_OVERRIDE = 0;
262 class DAAL_EXPORT DistributedIface<step2Master> :
public daal::algorithms::Analysis<distributed>
265 typedef algorithms::covariance::DistributedInput<step2Master> InputType;
266 typedef algorithms::covariance::Parameter ParameterType;
267 typedef algorithms::covariance::Result ResultType;
268 typedef algorithms::covariance::PartialResult PartialResultType;
283 DistributedIface(
const DistributedIface<step2Master> &other) : parameter(other.parameter)
286 data_management::DataCollectionPtr collection = other.input.get(partialResults);
287 for (
size_t i = 0; i < collection->size(); i++)
289 input.add(partialResults,
290 services::staticPointerCast<PartialResultType, data_management::SerializationIface>((*collection)[i]));
294 virtual ~DistributedIface() {}
300 ResultPtr getResult()
309 virtual services::Status setResult(
const ResultPtr &result)
311 DAAL_CHECK(result, services::ErrorNullResult)
313 _res = _result.get();
314 return services::Status();
321 PartialResultPtr getPartialResult()
323 return _partialResult;
331 virtual services::Status setPartialResult(
const PartialResultPtr &partialResult,
bool initFlag =
false)
333 DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
334 _partialResult = partialResult;
335 _pres = _partialResult.get();
336 setInitFlag(initFlag);
337 return services::Status();
343 services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
346 if(this->_partialResult)
348 s |= this->_partialResult->check(this->_par, getMethod());
353 return services::Status(services::ErrorNullResult);
358 s |= this->_result->check(this->_pres, this->_par, getMethod());
363 return services::Status(services::ErrorNullResult);
374 services::SharedPtr<DistributedIface<step2Master> > clone()
const 376 return services::SharedPtr<DistributedIface<step2Master> >(cloneImpl());
379 DistributedInput<step2Master> input;
380 ParameterType parameter;
383 virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
385 return services::Status();
392 _result.reset(
new ResultType());
393 _partialResult.reset(
new PartialResultType());
396 virtual DistributedIface<step2Master> * cloneImpl()
const DAAL_C11_OVERRIDE = 0;
398 PartialResultPtr _partialResult;
423 template<ComputeStep step,
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
424 class DAAL_EXPORT Distributed :
public DistributedIface<step>
448 template<
typename algorithmFPType, Method method>
449 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> :
public Online<algorithmFPType, method>
452 typedef Online<algorithmFPType, method> super;
454 typedef algorithms::covariance::DistributedInput<step1Local> InputType;
455 typedef typename super::ParameterType ParameterType;
456 typedef typename super::ResultType ResultType;
457 typedef typename super::PartialResultType PartialResultType;
459 Distributed<step1Local, algorithmFPType, method>() : Online<algorithmFPType, method>()
469 Distributed(
const Distributed<step1Local, algorithmFPType, method> &other) :
470 Online<algorithmFPType, method>(other)
479 services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone()
const 481 return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
485 virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl()
const DAAL_C11_OVERRIDE
487 return new Distributed<step1Local, algorithmFPType, method>(*this);
512 template<
typename algorithmFPType, Method method>
513 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> :
public DistributedIface<step2Master>
516 typedef DistributedIface<step2Master> super;
518 typedef typename super::InputType InputType;
519 typedef typename super::ParameterType ParameterType;
520 typedef typename super::ResultType ResultType;
521 typedef typename super::PartialResultType PartialResultType;
536 Distributed(
const Distributed<step2Master, algorithmFPType, method> &other) :
537 DistributedIface<step2Master>(other)
542 virtual ~Distributed() {}
548 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)method; }
556 services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone()
const 558 return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
562 virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl()
const DAAL_C11_OVERRIDE
564 return new Distributed<step2Master, algorithmFPType, method>(*this);
567 virtual services::Status allocateResult() DAAL_C11_OVERRIDE
569 ResultPtr result = this->getResult();
570 services::Status s = result->template allocate<algorithmFPType>(this->_partialResult.get(), this->_par, (int)method);
571 this->_res = this->_result.get();
572 this->_pres = this->_partialResult.get();
576 virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
578 services::Status s = this->_partialResult->template allocate<algorithmFPType>(&(this->input), this->_par, (
int)method);
579 this->_pres = this->_partialResult.get();
585 this->_ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
590 using interface1::DistributedContainerIface;
591 using interface1::DistributedContainer;
592 using interface1::DistributedIface;
593 using interface1::Distributed;
598 #endif // __COVARIANCE_DISTRIBUTED_H__ daal::algorithms::covariance::interface1::DistributedIface< step2Master >::setResult
virtual services::Status setResult(const ResultPtr &result)
Definition: covariance_distributed.h:309
daal::algorithms::covariance::interface1::OnlineParameter
Parameters of the correlation or variance-covariance matrix algorithm in the online processing mode...
Definition: covariance_types.h:295
daal::algorithms::covariance::interface1::DistributedIface< step2Master >
Interface for correlation or variance-covariance matrix computation algorithms in the distributed pro...
Definition: covariance_distributed.h:262
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::DistributedIface
DistributedIface(const DistributedIface< step2Master > &other)
Definition: covariance_distributed.h:283
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::covariance::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: covariance_distributed.h:469
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::parameter
ParameterType parameter
Definition: covariance_distributed.h:380
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:131
daal::algorithms::covariance::interface1::Parameter
Parameters of the correlation or variance-covariance matrix algorithm.
Definition: covariance_types.h:284
daal::algorithms::covariance::interface1::OnlineImpl
Abstract class that specifies interface of the algorithms for computing correlation or variance-covar...
Definition: covariance_online.h:313
daal::algorithms::covariance::interface1::DistributedIface< step1Local >::clone
services::SharedPtr< DistributedIface< step1Local > > clone() const
Definition: covariance_distributed.h:231
daal::algorithms::covariance::interface1::Online
Computes correlation or variance-covariance matrix in the online processing mode. ...
Definition: covariance_online.h:436
daal::algorithms::covariance::interface1::Distributed< step2Master, algorithmFPType, method >
Computes correlation or variance-covariance matrix in the second step of the distributed processing m...
Definition: covariance_distributed.h:513
daal::algorithms::covariance::interface1::DistributedContainer
Provides methods to run implementations of the correlation or variance-covariance matrix algorithm in...
Definition: covariance_distributed.h:122
daal::algorithms::covariance::interface1::DistributedIface
Interface for the correlation or variance-covariance matrix algorithm in the distributed processing m...
Definition: covariance_distributed.h:176
daal::algorithms::covariance::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: covariance_distributed.h:548
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::covariance::interface1::DistributedIface< step2Master >::input
DistributedInput< step2Master > input
Definition: covariance_distributed.h:379
daal::algorithms::covariance::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed()
Definition: covariance_distributed.h:524
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::covariance::interface1::Result
Provides methods to access final results obtained with the compute() method of the correlation or var...
Definition: covariance_types.h:317
daal::services::interface1::SharedPtr::get
T * get() const
Definition: daal_shared_ptr.h:332
daal::algorithms::covariance::partialResults
Definition: covariance_types.h:136
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::setPartialResult
virtual services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag=false)
Definition: covariance_distributed.h:331
daal::algorithms::covariance::interface1::PartialResult
Provides methods to access partial results obtained with the compute() method of the correlation or v...
Definition: covariance_types.h:204
daal::algorithms::covariance::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: covariance_distributed.h:479
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::clone
services::SharedPtr< DistributedIface< step2Master > > clone() const
Definition: covariance_distributed.h:374
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::getPartialResult
PartialResultPtr getPartialResult()
Definition: covariance_distributed.h:321
daal::algorithms::covariance::interface1::DistributedIface< step1Local >::DistributedIface
DistributedIface()
Definition: covariance_distributed.h:212
daal::algorithms::covariance::interface1::Distributed< step1Local, algorithmFPType, method >
Computes correlation or variance-covariance matrix in the first step of the distributed processing mo...
Definition: covariance_distributed.h:449
daal::algorithms::covariance::interface1::DistributedContainerIface
Class that spcifies interfaces of the correlation or variance-covariance matrix algorithm. This class is associated with daal::algorithms::covariance::DistributedIface class.
Definition: covariance_distributed.h:81
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::getResult
ResultPtr getResult()
Definition: covariance_distributed.h:300
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::DistributedIface
DistributedIface()
Definition: covariance_distributed.h:271
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:94
daal::algorithms::covariance::covariance
Definition: covariance_types.h:114
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::step2Master
Definition: daal_defines.h:144
daal::algorithms::covariance::interface1::Distributed
Computes correlation or variance-covariance matrix in the distributed processing mode.
Definition: covariance_distributed.h:424
daal::algorithms::covariance::interface1::DistributedIface< step1Local >
Interface for correlation or variance-covariance matrix computation algorithms in the distributed pro...
Definition: covariance_distributed.h:201
daal::algorithms::covariance::interface1::DistributedIface< step1Local >::DistributedIface
DistributedIface(const DistributedIface< step1Local > &other)
Definition: covariance_distributed.h:222
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::checkFinalizeComputeParams
services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
Definition: covariance_distributed.h:343
daal::services::ErrorNullResult
Definition: error_indexes.h:122
daal::algorithms::covariance::interface1::Distributed< step2Master, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, method > > clone() const
Definition: covariance_distributed.h:556
daal::algorithms::covariance::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: covariance_distributed.h:536