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

low_order_moments_distributed.h
1 /* file: low_order_moments_distributed.h */
2 /*******************************************************************************
3 * Copyright 2014-2017 Intel Corporation
4 * All Rights Reserved.
5 *
6 * If this software was obtained under the Intel Simplified Software License,
7 * the following terms apply:
8 *
9 * The source code, information and material ("Material") contained herein is
10 * owned by Intel Corporation or its suppliers or licensors, and title to such
11 * Material remains with Intel Corporation or its suppliers or licensors. The
12 * Material contains proprietary information of Intel or its suppliers and
13 * licensors. The Material is protected by worldwide copyright laws and treaty
14 * provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed or disclosed
16 * in any way without Intel's prior express written permission. No license under
17 * any patent, copyright or other intellectual property rights in the Material
18 * is granted to or conferred upon you, either expressly, by implication,
19 * inducement, estoppel or otherwise. Any license under such intellectual
20 * property rights must be express and approved by Intel in writing.
21 *
22 * Unless otherwise agreed by Intel in writing, you may not remove or alter this
23 * notice or any other notice embedded in Materials by Intel or Intel's
24 * suppliers or licensors in any way.
25 *
26 *
27 * If this software was obtained under the Apache License, Version 2.0 (the
28 * "License"), the following terms apply:
29 *
30 * You may not use this file except in compliance with the License. You may
31 * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
32 *
33 *
34 * Unless required by applicable law or agreed to in writing, software
35 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 *
38 * See the License for the specific language governing permissions and
39 * limitations under the License.
40 *******************************************************************************/
41 
42 /*
43 //++
44 // Implementation of the interface for the low order moments algorithm in the
45 // distributed processing mode
46 //--
47 */
48 
49 #ifndef __LOW_ORDER_MOMENTS_DISTRIBUTED_H__
50 #define __LOW_ORDER_MOMENTS_DISTRIBUTED_H__
51 
52 #include "algorithms/algorithm.h"
53 #include "services/daal_defines.h"
54 #include "algorithms/moments/low_order_moments_types.h"
55 
56 namespace daal
57 {
58 namespace algorithms
59 {
60 namespace low_order_moments
61 {
62 
63 namespace interface1
64 {
80 template<ComputeStep step, typename algorithmFPType, Method method, CpuType cpu>
81 class DAAL_EXPORT DistributedContainer
82 {};
83 
93 template<typename algorithmFPType, Method method, CpuType cpu>
94 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, method, cpu> :
95  public daal::algorithms::AnalysisContainerIface<distributed>
96 {
97 public:
103  DistributedContainer(daal::services::Environment::env *daalEnv);
105  virtual ~DistributedContainer();
110  virtual services::Status compute() DAAL_C11_OVERRIDE;
115  virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
116 };
117 
118 
138 template<ComputeStep step, typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
139 class DAAL_EXPORT Distributed{};
140 
156 template<typename algorithmFPType, Method method>
157 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> : public Online<algorithmFPType, method>
158 {
159 public:
161  Distributed()
162  {}
163 
170  Distributed(const Distributed<step1Local, algorithmFPType, method> &other) : Online<algorithmFPType, method>(other)
171  {}
172 
178  services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone() const
179  {
180  return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
181  }
182 
183 protected:
184  virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
185  {
186  return new Distributed<step1Local, algorithmFPType, method>(*this);
187  }
188 };
189 
205 template<typename algorithmFPType, Method method>
206 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> : public daal::algorithms::Analysis<distributed>
207 {
208 public:
209  DistributedInput<step2Master> input;
210  Parameter parameter;
213  Distributed()
214  {
215  initialize();
216  }
217 
224  Distributed(const Distributed<step2Master, algorithmFPType, method> &other) : parameter(other.parameter), input(other.input)
225  {
226  initialize();
227  }
228 
233  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
234 
239  ResultPtr getResult()
240  {
241  return _result;
242  }
243 
248  services::Status setResult(const ResultPtr &result)
249  {
250  DAAL_CHECK(result, services::ErrorNullResult)
251  _result = result;
252  _res = _result.get();
253  return services::Status();
254  }
255 
260  PartialResultPtr getPartialResult()
261  {
262  return _partialResult;
263  }
264 
270  services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag = false)
271  {
272  DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
273  _partialResult = partialResult;
274  _pres = _partialResult.get();
275  setInitFlag(initFlag);
276  return services::Status();
277  }
278 
284  services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone() const
285  {
286  return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
287  }
288 
289 protected:
290  virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
291  {
292  return new Distributed<step2Master, algorithmFPType, method>(*this);
293  }
294 
295  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
296  {
297  services::Status s = _result->allocate<algorithmFPType>(_pres, 0, 0);
298  _res = _result.get();
299  return s;
300  }
301 
302  virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
303  {
304  services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
305  _pres = _partialResult.get();
306  return s;
307  }
308 
309  virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
310  {
311  return services::Status();
312  }
313 
314  void initialize()
315  {
316  Analysis<distributed>::_ac = new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
317  _in = &input;
318  _par = &parameter;
319  _result.reset(new Result());
320  _partialResult.reset(new PartialResult());
321  }
322 
323 private:
324  PartialResultPtr _partialResult;
325  ResultPtr _result;
326 };
328 } // namespace interface1
329 using interface1::DistributedInput;
330 using interface1::DistributedContainer;
331 using interface1::Distributed;
332 
333 } // namespace daal::algorithms::low_order_moments
334 }
335 }
336 #endif
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::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:206
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:284
daal::algorithms::low_order_moments::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: low_order_moments_distributed.h:170
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:131
daal::algorithms::low_order_moments::interface1::Online
Computes moments of low order in the online processing mode.
Definition: low_order_moments_online.h:118
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: low_order_moments_distributed.h:233
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:248
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed()
Definition: low_order_moments_distributed.h:213
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:132
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::input
DistributedInput< step2Master > input
Definition: low_order_moments_distributed.h:209
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::getPartialResult
PartialResultPtr getPartialResult()
Definition: low_order_moments_distributed.h:260
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: low_order_moments_distributed.h:224
daal::algorithms::low_order_moments::interface1::Parameter
Low order moments algorithm parameters.
Definition: low_order_moments_types.h:293
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:81
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: low_order_moments_distributed.h:239
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:94
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:178
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:270
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:142
daal::algorithms::low_order_moments::interface1::Distributed
Computes moments of low order in the distributed processing mode.
Definition: low_order_moments_distributed.h:139
daal::step2Master
Definition: daal_defines.h:143
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:157
daal::services::ErrorNullResult
Definition: error_indexes.h:122
daal::algorithms::low_order_moments::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed()
Definition: low_order_moments_distributed.h:161
daal::algorithms::low_order_moments::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
Parameter parameter
Definition: low_order_moments_distributed.h:210

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