C++ API Reference for Intel® Data Analytics Acceleration Library 2020 Update 1

low_order_moments_distributed.h
1 /* file: low_order_moments_distributed.h */
2 /*******************************************************************************
3 * Copyright 2014-2020 Intel Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *******************************************************************************/
17 
18 /*
19 //++
20 // Implementation of the interface for the low order moments algorithm in the
21 // distributed processing mode
22 //--
23 */
24 
25 #ifndef __LOW_ORDER_MOMENTS_DISTRIBUTED_H__
26 #define __LOW_ORDER_MOMENTS_DISTRIBUTED_H__
27 
28 #include "algorithms/algorithm.h"
29 #include "services/daal_defines.h"
30 #include "algorithms/moments/low_order_moments_types.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace low_order_moments
37 {
38 
39 namespace interface1
40 {
56 template<ComputeStep step, typename algorithmFPType, Method method, CpuType cpu>
57 class DistributedContainer
58 {};
59 
69 template<typename algorithmFPType, Method method, CpuType cpu>
70 class DistributedContainer<step2Master, algorithmFPType, method, cpu> :
71  public daal::algorithms::AnalysisContainerIface<distributed>
72 {
73 public:
79  DistributedContainer(daal::services::Environment::env *daalEnv);
81  virtual ~DistributedContainer();
86  virtual services::Status compute() DAAL_C11_OVERRIDE;
91  virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
92 };
93 
94 
114 template<ComputeStep step, typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
115 class DAAL_EXPORT Distributed{};
116 
132 template<typename algorithmFPType, Method method>
133 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> : public Online<algorithmFPType, method>
134 {
135 public:
136  typedef Online<algorithmFPType, method> super;
137 
138  typedef typename super::InputType InputType;
139  typedef typename super::ParameterType ParameterType;
140  typedef typename super::ResultType ResultType;
141  typedef typename super::PartialResultType PartialResultType;
142 
144  Distributed()
145  {}
146 
153  Distributed(const Distributed<step1Local, algorithmFPType, method> &other) : Online<algorithmFPType, method>(other)
154  {}
155 
161  services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone() const
162  {
163  return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
164  }
165 
166 protected:
167  virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
168  {
169  return new Distributed<step1Local, algorithmFPType, method>(*this);
170  }
171 };
172 
188 template<typename algorithmFPType, Method method>
189 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> : public daal::algorithms::Analysis<distributed>
190 {
191 public:
192  typedef algorithms::low_order_moments::DistributedInput<step2Master> InputType;
193  typedef algorithms::low_order_moments::Parameter ParameterType;
194  typedef algorithms::low_order_moments::Result ResultType;
195  typedef algorithms::low_order_moments::PartialResult PartialResultType;
196 
197  DistributedInput<step2Master> input;
198  ParameterType parameter;
201  Distributed()
202  {
203  initialize();
204  }
205 
212  Distributed(const Distributed<step2Master, algorithmFPType, method> &other) : parameter(other.parameter), input(other.input)
213  {
214  initialize();
215  }
216 
221  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
222 
227  ResultPtr getResult()
228  {
229  return _result;
230  }
231 
236  services::Status setResult(const ResultPtr &result)
237  {
238  DAAL_CHECK(result, services::ErrorNullResult)
239  _result = result;
240  _res = _result.get();
241  return services::Status();
242  }
243 
248  PartialResultPtr getPartialResult()
249  {
250  return _partialResult;
251  }
252 
258  services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag = false)
259  {
260  DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
261  _partialResult = partialResult;
262  _pres = _partialResult.get();
263  setInitFlag(initFlag);
264  return services::Status();
265  }
266 
272  services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone() const
273  {
274  return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
275  }
276 
277 protected:
278  virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
279  {
280  return new Distributed<step2Master, algorithmFPType, method>(*this);
281  }
282 
283  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
284  {
285  services::Status s = _result->allocate<algorithmFPType>(_pres, 0, 0);
286  _res = _result.get();
287  return s;
288  }
289 
290  virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
291  {
292  services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
293  _pres = _partialResult.get();
294  return s;
295  }
296 
297  virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
298  {
299  return services::Status();
300  }
301 
302  void initialize()
303  {
304  Analysis<distributed>::_ac = new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
305  _in = &input;
306  _par = &parameter;
307  _result.reset(new ResultType());
308  _partialResult.reset(new PartialResultType());
309  }
310 
311 private:
312  PartialResultPtr _partialResult;
313  ResultPtr _result;
314 };
316 } // namespace interface1
317 using interface1::DistributedInput;
318 using interface1::DistributedContainer;
319 using interface1::Distributed;
320 
321 } // namespace daal::algorithms::low_order_moments
322 }
323 }
324 #endif
daal::step1Local
Definition: daal_defines.h:123
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::setResult
services::Status setResult(const ResultPtr &result)
Definition: low_order_moments_distributed.h:236
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:57
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:272
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:189
daal::step2Master
Definition: daal_defines.h:124
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
ParameterType parameter
Definition: low_order_moments_distributed.h:198
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::input
DistributedInput< step2Master > input
Definition: low_order_moments_distributed.h:197
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed()
Definition: low_order_moments_distributed.h:201
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::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag=false)
Definition: low_order_moments_distributed.h:258
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::low_order_moments::interface1::Online
Computes moments of low order in the online processing mode.
Definition: low_order_moments_online.h:94
daal_defines.h
daal::algorithms::low_order_moments::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed()
Definition: low_order_moments_distributed.h:144
daal::algorithms::low_order_moments::interface1::DistributedInput< step2Master >
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: low_order_moments_distributed.h:212
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:161
daal::algorithms::low_order_moments::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: low_order_moments_distributed.h:153
daal::algorithms::low_order_moments::interface1::Distributed
Computes moments of low order in the distributed processing mode.
Definition: low_order_moments_distributed.h:115
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:133
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: low_order_moments_distributed.h:221
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::getPartialResult
PartialResultPtr getPartialResult()
Definition: low_order_moments_distributed.h:248
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::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: low_order_moments_distributed.h:227
daal::distributed
Definition: daal_defines.h:113

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