C++ API Reference for Intel® Data Analytics Acceleration Library 2019

low_order_moments_distributed.h
1 /* file: low_order_moments_distributed.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Implementation of the interface for the low order moments algorithm in the
19 // distributed processing mode
20 //--
21 */
22 
23 #ifndef __LOW_ORDER_MOMENTS_DISTRIBUTED_H__
24 #define __LOW_ORDER_MOMENTS_DISTRIBUTED_H__
25 
26 #include "algorithms/algorithm.h"
27 #include "services/daal_defines.h"
28 #include "algorithms/moments/low_order_moments_types.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
34 namespace low_order_moments
35 {
36 
37 namespace interface1
38 {
54 template<ComputeStep step, typename algorithmFPType, Method method, CpuType cpu>
55 class DAAL_EXPORT DistributedContainer
56 {};
57 
67 template<typename algorithmFPType, Method method, CpuType cpu>
68 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, method, cpu> :
69  public daal::algorithms::AnalysisContainerIface<distributed>
70 {
71 public:
77  DistributedContainer(daal::services::Environment::env *daalEnv);
79  virtual ~DistributedContainer();
84  virtual services::Status compute() DAAL_C11_OVERRIDE;
89  virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
90 };
91 
92 
112 template<ComputeStep step, typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
113 class DAAL_EXPORT Distributed{};
114 
130 template<typename algorithmFPType, Method method>
131 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> : public Online<algorithmFPType, method>
132 {
133 public:
134  typedef Online<algorithmFPType, method> super;
135 
136  typedef typename super::InputType InputType;
137  typedef typename super::ParameterType ParameterType;
138  typedef typename super::ResultType ResultType;
139  typedef typename super::PartialResultType PartialResultType;
140 
142  Distributed()
143  {}
144 
151  Distributed(const Distributed<step1Local, algorithmFPType, method> &other) : Online<algorithmFPType, method>(other)
152  {}
153 
159  services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone() const
160  {
161  return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
162  }
163 
164 protected:
165  virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
166  {
167  return new Distributed<step1Local, algorithmFPType, method>(*this);
168  }
169 };
170 
186 template<typename algorithmFPType, Method method>
187 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> : public daal::algorithms::Analysis<distributed>
188 {
189 public:
190  typedef algorithms::low_order_moments::DistributedInput<step2Master> InputType;
191  typedef algorithms::low_order_moments::Parameter ParameterType;
192  typedef algorithms::low_order_moments::Result ResultType;
193  typedef algorithms::low_order_moments::PartialResult PartialResultType;
194 
195  DistributedInput<step2Master> input;
196  ParameterType parameter;
199  Distributed()
200  {
201  initialize();
202  }
203 
210  Distributed(const Distributed<step2Master, algorithmFPType, method> &other) : parameter(other.parameter), input(other.input)
211  {
212  initialize();
213  }
214 
219  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
220 
225  ResultPtr getResult()
226  {
227  return _result;
228  }
229 
234  services::Status setResult(const ResultPtr &result)
235  {
236  DAAL_CHECK(result, services::ErrorNullResult)
237  _result = result;
238  _res = _result.get();
239  return services::Status();
240  }
241 
246  PartialResultPtr getPartialResult()
247  {
248  return _partialResult;
249  }
250 
256  services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag = false)
257  {
258  DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
259  _partialResult = partialResult;
260  _pres = _partialResult.get();
261  setInitFlag(initFlag);
262  return services::Status();
263  }
264 
270  services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone() const
271  {
272  return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
273  }
274 
275 protected:
276  virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
277  {
278  return new Distributed<step2Master, algorithmFPType, method>(*this);
279  }
280 
281  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
282  {
283  services::Status s = _result->allocate<algorithmFPType>(_pres, 0, 0);
284  _res = _result.get();
285  return s;
286  }
287 
288  virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
289  {
290  services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
291  _pres = _partialResult.get();
292  return s;
293  }
294 
295  virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
296  {
297  return services::Status();
298  }
299 
300  void initialize()
301  {
302  Analysis<distributed>::_ac = new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
303  _in = &input;
304  _par = &parameter;
305  _result.reset(new ResultType());
306  _partialResult.reset(new PartialResultType());
307  }
308 
309 private:
310  PartialResultPtr _partialResult;
311  ResultPtr _result;
312 };
314 } // namespace interface1
315 using interface1::DistributedInput;
316 using interface1::DistributedContainer;
317 using interface1::Distributed;
318 
319 } // namespace daal::algorithms::low_order_moments
320 }
321 }
322 #endif
daal
Definition: algorithm_base_common.h:31
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
ParameterType parameter
Definition: low_order_moments_distributed.h:196
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >
Computes the result of the second step of the moments of low order algorithm in the distributed proce...
Definition: low_order_moments_distributed.h:187
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, method > > clone() const
Definition: low_order_moments_distributed.h:270
daal::algorithms::low_order_moments::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: low_order_moments_distributed.h:151
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:105
daal::algorithms::low_order_moments::interface1::Online
Computes moments of low order in the online processing mode.
Definition: low_order_moments_online.h:92
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: low_order_moments_distributed.h:219
daal_defines.h
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::setResult
services::Status setResult(const ResultPtr &result)
Definition: low_order_moments_distributed.h:234
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed()
Definition: low_order_moments_distributed.h:199
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::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::input
DistributedInput< step2Master > input
Definition: low_order_moments_distributed.h:195
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::getPartialResult
PartialResultPtr getPartialResult()
Definition: low_order_moments_distributed.h:246
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: low_order_moments_distributed.h:210
daal::algorithms::low_order_moments::interface1::DistributedContainer
Provides methods to run implementations of the low order moments algorithm in the distributed process...
Definition: low_order_moments_distributed.h:55
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: low_order_moments_distributed.h:225
daal::algorithms::low_order_moments::interface1::DistributedInput< step2Master >
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::low_order_moments::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: low_order_moments_distributed.h:159
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag=false)
Definition: low_order_moments_distributed.h:256
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::low_order_moments::interface1::Distributed
Computes moments of low order in the distributed processing mode.
Definition: low_order_moments_distributed.h:113
daal::step2Master
Definition: daal_defines.h:118
daal::algorithms::low_order_moments::interface1::Distributed< step1Local, algorithmFPType, method >
Computes the result of the first step of the moments of low order algorithm in the distributed proces...
Definition: low_order_moments_distributed.h:131
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::low_order_moments::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed()
Definition: low_order_moments_distributed.h:142

For more complete information about compiler optimizations, see our Optimization Notice.