25 #ifndef __COVARIANCE_DISTRIBUTED_H__
26 #define __COVARIANCE_DISTRIBUTED_H__
28 #include "algorithms/algorithm.h"
29 #include "data_management/data/numeric_table.h"
30 #include "services/daal_defines.h"
31 #include "algorithms/covariance/covariance_types.h"
32 #include "algorithms/covariance/covariance_online.h"
56 template<ComputeStep step>
57 class DistributedContainerIface
69 class DistributedContainerIface<step2Master> :
public daal::algorithms::AnalysisContainerIface<distributed>
72 DistributedContainerIface() {}
73 virtual ~DistributedContainerIface() {}
79 virtual services::Status compute() = 0;
84 virtual services::Status finalizeCompute() = 0;
97 template<ComputeStep step,
typename algorithmFPType, Method method, CpuType cpu>
98 class DistributedContainer
106 template<
typename algorithmFPType, Method method, CpuType cpu>
107 class DistributedContainer<step2Master, algorithmFPType, method, cpu> :
public DistributedContainerIface<step2Master>
115 DistributedContainer(daal::services::Environment::env *daalEnv);
117 virtual ~DistributedContainer();
122 virtual services::Status compute() DAAL_C11_OVERRIDE;
127 virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
151 template<ComputeStep step>
152 class DAAL_EXPORT DistributedIface :
public daal::algorithms::Analysis<distributed>
177 class DistributedIface<step1Local> :
public OnlineImpl
180 typedef OnlineImpl super;
182 typedef algorithms::covariance::DistributedInput<step1Local> InputType;
183 typedef super::ParameterType ParameterType;
184 typedef super::ResultType ResultType;
185 typedef super::PartialResultType PartialResultType;
188 DistributedIface() : OnlineImpl()
198 DistributedIface(
const DistributedIface<step1Local> &other) : OnlineImpl(other)
207 services::SharedPtr<DistributedIface<step1Local> > clone()
const
209 return services::SharedPtr<DistributedIface<step1Local> >(cloneImpl());
213 virtual DistributedIface<step1Local> * cloneImpl() const DAAL_C11_OVERRIDE = 0;
238 class DAAL_EXPORT DistributedIface<step2Master> : public daal::algorithms::Analysis<distributed>
241 typedef algorithms::covariance::DistributedInput<step2Master> InputType;
242 typedef algorithms::covariance::Parameter ParameterType;
243 typedef algorithms::covariance::Result ResultType;
244 typedef algorithms::covariance::PartialResult PartialResultType;
259 DistributedIface(
const DistributedIface<step2Master> &other) : parameter(other.parameter)
262 data_management::DataCollectionPtr collection = other.input.get(partialResults);
263 for (
size_t i = 0; i < collection->size(); i++)
265 input.add(partialResults,
266 services::staticPointerCast<PartialResultType, data_management::SerializationIface>((*collection)[i]));
270 virtual ~DistributedIface() {}
276 ResultPtr getResult()
285 virtual services::Status setResult(
const ResultPtr &result)
287 DAAL_CHECK(result, services::ErrorNullResult)
289 _res = _result.get();
290 return services::Status();
297 PartialResultPtr getPartialResult()
299 return _partialResult;
307 virtual services::Status setPartialResult(
const PartialResultPtr &partialResult,
bool initFlag =
false)
309 DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
310 _partialResult = partialResult;
311 _pres = _partialResult.get();
312 setInitFlag(initFlag);
313 return services::Status();
319 services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
322 if(this->_partialResult)
324 s |= this->_partialResult->check(this->_par, getMethod());
329 return services::Status(services::ErrorNullResult);
334 s |= this->_result->check(this->_pres, this->_par, getMethod());
339 return services::Status(services::ErrorNullResult);
350 services::SharedPtr<DistributedIface<step2Master> > clone()
const
352 return services::SharedPtr<DistributedIface<step2Master> >(cloneImpl());
355 DistributedInput<step2Master> input;
356 ParameterType parameter;
359 virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
361 return services::Status();
368 _result.reset(
new ResultType());
369 _partialResult.reset(
new PartialResultType());
372 virtual DistributedIface<step2Master> * cloneImpl() const DAAL_C11_OVERRIDE = 0;
374 PartialResultPtr _partialResult;
399 template<ComputeStep step, typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
400 class DAAL_EXPORT Distributed : public DistributedIface<step>
424 template<
typename algorithmFPType, Method method>
425 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> :
public Online<algorithmFPType, method>
428 typedef Online<algorithmFPType, method> super;
430 typedef algorithms::covariance::DistributedInput<step1Local> InputType;
431 typedef typename super::ParameterType ParameterType;
432 typedef typename super::ResultType ResultType;
433 typedef typename super::PartialResultType PartialResultType;
435 Distributed<step1Local, algorithmFPType, method>() : Online<algorithmFPType, method>()
445 Distributed(
const Distributed<step1Local, algorithmFPType, method> &other) :
446 Online<algorithmFPType, method>(other)
455 services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone()
const
457 return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
461 virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
463 return new Distributed<step1Local, algorithmFPType, method>(*this);
488 template<
typename algorithmFPType, Method method>
489 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> :
public DistributedIface<step2Master>
492 typedef DistributedIface<step2Master> super;
494 typedef typename super::InputType InputType;
495 typedef typename super::ParameterType ParameterType;
496 typedef typename super::ResultType ResultType;
497 typedef typename super::PartialResultType PartialResultType;
512 Distributed(
const Distributed<step2Master, algorithmFPType, method> &other) :
513 DistributedIface<step2Master>(other)
518 virtual ~Distributed() {}
524 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)method; }
532 services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone()
const
534 return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
538 virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
540 return new Distributed<step2Master, algorithmFPType, method>(*this);
543 virtual services::Status allocateResult() DAAL_C11_OVERRIDE
545 ResultPtr result = this->getResult();
546 services::Status s = result->template allocate<algorithmFPType>(this->_partialResult.get(), this->_par, (int)method);
547 this->_res = this->_result.get();
548 this->_pres = this->_partialResult.get();
552 virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
554 services::Status s = this->_partialResult->template allocate<algorithmFPType>(&(this->input), this->_par, (
int)method);
555 this->_pres = this->_partialResult.get();
561 this->_ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
566 using interface1::DistributedContainerIface;
567 using interface1::DistributedContainer;
568 using interface1::DistributedIface;
569 using interface1::Distributed;
574 #endif // __COVARIANCE_DISTRIBUTED_H__
daal::algorithms::covariance::interface1::DistributedIface< step1Local >
Interface for correlation or variance-covariance matrix computation algorithms in the distributed pro...
Definition: covariance_distributed.h:177
daal::step1Local
Definition: daal_defines.h:123
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::clone
services::SharedPtr< DistributedIface< step2Master > > clone() const
Definition: covariance_distributed.h:350
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:57
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::getPartialResult
PartialResultPtr getPartialResult()
Definition: covariance_distributed.h:297
daal::algorithms::covariance::interface1::DistributedIface< step2Master >
Interface for correlation or variance-covariance matrix computation algorithms in the distributed pro...
Definition: covariance_distributed.h:238
daal::algorithms::covariance::covariance
Definition: covariance_types.h:90
daal::algorithms::covariance::interface1::Distributed
Computes correlation or variance-covariance matrix in the distributed processing mode.
Definition: covariance_distributed.h:400
daal::algorithms::covariance::interface1::DistributedIface< step1Local >::clone
services::SharedPtr< DistributedIface< step1Local > > clone() const
Definition: covariance_distributed.h:207
daal::algorithms::covariance::Method
Method
Definition: covariance_types.h:48
daal::step2Master
Definition: daal_defines.h:124
daal::algorithms::covariance::interface1::DistributedIface< step1Local >::DistributedIface
DistributedIface()
Definition: covariance_distributed.h:188
daal::algorithms::covariance::partialResults
Definition: covariance_types.h:112
daal::algorithms::covariance::defaultDense
Definition: covariance_types.h:50
daal::services::ErrorNullResult
Definition: error_indexes.h:98
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:489
daal::algorithms::covariance::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: covariance_distributed.h:455
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:55
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::DistributedIface
DistributedIface()
Definition: covariance_distributed.h:247
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::setPartialResult
virtual services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag=false)
Definition: covariance_distributed.h:307
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::covariance::interface1::DistributedInput< step2Master >
Input parameters of the distributed Covariance algorithm. Represents inputs of the algorithm on maste...
Definition: covariance_types.h:395
daal::algorithms::covariance::interface1::DistributedIface
Interface for the correlation or variance-covariance matrix algorithm in the distributed processing m...
Definition: covariance_distributed.h:152
daal::algorithms::covariance::interface1::DistributedInput< step2Master >::get
data_management::DataCollectionPtr get(MasterInputId id) const
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::parameter
ParameterType parameter
Definition: covariance_distributed.h:356
daal::algorithms::covariance::interface1::OnlineImpl
Abstract class that specifies interface of the algorithms for computing correlation or variance-covar...
Definition: covariance_online.h:289
daal::algorithms::covariance::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: covariance_distributed.h:445
daal::ComputeStep
ComputeStep
Definition: daal_defines.h:121
daal::algorithms::covariance::interface1::Online
Computes correlation or variance-covariance matrix in the online processing mode. ...
Definition: covariance_online.h:412
daal::algorithms::covariance::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed()
Definition: covariance_distributed.h:500
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:425
daal::algorithms::covariance::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: covariance_distributed.h:524
daal::algorithms::covariance::interface1::DistributedContainer
Provides methods to run implementations of the correlation or variance-covariance matrix algorithm in...
Definition: covariance_distributed.h:98
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::input
DistributedInput< step2Master > input
Definition: covariance_distributed.h:355
daal::algorithms::covariance::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: covariance_distributed.h:512
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::checkFinalizeComputeParams
services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
Definition: covariance_distributed.h:319
daal::algorithms::covariance::interface1::DistributedIface< step1Local >::DistributedIface
DistributedIface(const DistributedIface< step1Local > &other)
Definition: covariance_distributed.h:198
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::DistributedIface
DistributedIface(const DistributedIface< step2Master > &other)
Definition: covariance_distributed.h:259
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:107
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::getResult
ResultPtr getResult()
Definition: covariance_distributed.h:276
daal::distributed
Definition: daal_defines.h:113
daal::algorithms::covariance::interface1::Distributed< step2Master, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, method > > clone() const
Definition: covariance_distributed.h:532
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::setResult
virtual services::Status setResult(const ResultPtr &result)
Definition: covariance_distributed.h:285