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

qr_distributed.h
1 /* file: qr_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 QR decomposition algorithm in the
45 // distributed processing mode
46 //--
47 */
48 
49 #ifndef __QR_DISTRIBUTED_H__
50 #define __QR_DISTRIBUTED_H__
51 
52 #include "algorithms/algorithm.h"
53 #include "data_management/data/numeric_table.h"
54 #include "services/daal_defines.h"
55 #include "algorithms/qr/qr_types.h"
56 #include "algorithms/qr/qr_online.h"
57 
58 namespace daal
59 {
60 namespace algorithms
61 {
62 namespace qr
63 {
64 
65 namespace interface1
66 {
81 template<ComputeStep step, typename algorithmFPType, Method method, CpuType cpu>
82 class DAAL_EXPORT DistributedContainer
83 {};
84 
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 
126 template<typename algorithmFPType, Method method, CpuType cpu>
127 class DAAL_EXPORT DistributedContainer<step3Local, algorithmFPType, method, cpu> :
128  public daal::algorithms::AnalysisContainerIface<distributed>
129 {
130 public:
136  DistributedContainer(daal::services::Environment::env *daalEnv);
138  virtual ~DistributedContainer();
143  virtual services::Status compute() DAAL_C11_OVERRIDE;
148  virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
149 };
150 
163 template<ComputeStep step, typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
164 class DAAL_EXPORT Distributed : public daal::algorithms::Analysis<distributed> {};
165 
177 template<typename algorithmFPType, Method method>
178 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> : public Online<algorithmFPType, method>
179 {
180 public:
181  Distributed() : Online<algorithmFPType, method>() {}
182 
189  Distributed(const Distributed<step1Local, algorithmFPType, method> &other) :
190  Online<algorithmFPType, method>(other)
191  {}
192 
198  services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone() const
199  {
200  return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
201  }
202 
203 protected:
204  virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
205  {
206  return new Distributed<step1Local, algorithmFPType, method>(*this);
207  }
208 };
209 
221 template<typename algorithmFPType, Method method>
222 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> : public daal::algorithms::Analysis<distributed>
223 {
224 public:
225  typedef DistributedStep2Input Input;
226 
227  Input input;
228  Parameter parameter;
230  Distributed()
231  {
232  initialize();
233  }
234 
241  Distributed(const Distributed<step2Master, algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
242  {
243  initialize();
244  }
245 
250  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
251 
256  ResultPtr getResult()
257  {
258  return _partialResult->get(finalResultFromStep2Master);
259  }
260 
265  DistributedPartialResultPtr getPartialResult()
266  {
267  return _partialResult;
268  }
269 
274  services::Status setPartialResult(const DistributedPartialResultPtr& partialRes)
275  {
276  DAAL_CHECK(partialRes, services::ErrorNullPartialResult);
277  DAAL_CHECK(partialRes->get(finalResultFromStep2Master), services::ErrorNullResult)
278  _partialResult = partialRes;
279  _pres = _partialResult.get();
280  return services::Status();
281  }
282 
286  services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
287  {
288  if(_partialResult)
289  {
290  return _partialResult->check(_par, method);
291  }
292  else
293  {
294  return services::Status(services::ErrorNullResult);
295  }
296  return services::Status();
297  }
298 
304  services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone() const
305  {
306  return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
307  }
308 
309 protected:
310  virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
311  {
312  return new Distributed<step2Master, algorithmFPType, method>(*this);
313  }
314 
315  virtual services::Status allocateResult() DAAL_C11_OVERRIDE { return services::Status(); }
316 
317  virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
318  {
319  _partialResult.reset(new DistributedPartialResult());
320  services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
321  _pres = _partialResult.get();
322  return s;
323  }
324 
325  virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
326  {
327  _pres = _partialResult.get();
328  return services::Status();
329  }
330 
331  void initialize()
332  {
333  Analysis<distributed>::_ac = new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
334  _in = &input;
335  _par = &parameter;
336  }
337 
338 private:
339  DistributedPartialResultPtr _partialResult;
340 };
341 
353 template<typename algorithmFPType, Method method>
354 class DAAL_EXPORT Distributed<step3Local, algorithmFPType, method> : public
355  daal::algorithms::Analysis<distributed>
356 {
357 public:
358  typedef DistributedStep3Input Input;
359 
360  Input input;
361  Parameter parameter;
364  Distributed()
365  {
366  initialize();
367  }
368 
375  Distributed(const Distributed<step3Local, algorithmFPType, method> &other) : input(other.input), parameter(other.parameter)
376  {
377  initialize();
378  }
379 
384  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int)method; }
385 
390  ResultPtr getResult()
391  {
392  return _partialResult->get(finalResultFromStep3);
393  }
394 
399  DistributedPartialResultStep3Ptr getPartialResult()
400  {
401  return _partialResult;
402  }
403 
408  services::Status setPartialResult(const DistributedPartialResultStep3Ptr& partialRes)
409  {
410  DAAL_CHECK(partialRes, services::ErrorNullPartialResult);
411  DAAL_CHECK(partialRes->get(finalResultFromStep3), services::ErrorNullResult)
412  _partialResult = partialRes;
413  _pres = _partialResult.get();
414  return services::Status();
415  }
416 
421  services::Status setResult(const ResultPtr& res) { return services::Status();}
422 
426  services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
427  {
428  if(_partialResult)
429  {
430  return _partialResult->check(_par, method);
431  }
432  else
433  {
434  return services::Status(services::ErrorNullResult);
435  }
436  return services::Status();
437  }
438 
444  services::SharedPtr<Distributed<step3Local, algorithmFPType, method> > clone() const
445  {
446  return services::SharedPtr<Distributed<step3Local, algorithmFPType, method> >(cloneImpl());
447  }
448 
449 protected:
450  virtual Distributed<step3Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
451  {
452  return new Distributed<step3Local, algorithmFPType, method>(*this);
453  }
454 
455  virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
456  {
457  _partialResult.reset(new DistributedPartialResultStep3());
458 
459  services::Status s = _partialResult->allocate<algorithmFPType>(_in, 0, 0);
460  if(!s) { return s; }
461 
462  data_management::DataCollectionPtr qCollection = input.get(inputOfStep3FromStep1);
463 
464  s = _partialResult->setPartialResultStorage<algorithmFPType>(qCollection.get());
465 
466  _pres = _partialResult.get();
467  return s;
468  }
469 
470  virtual services::Status allocateResult() DAAL_C11_OVERRIDE { return services::Status(); }
471 
472  virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE { return services::Status(); }
473 
474  void initialize()
475  {
476  Analysis<distributed>::_ac = new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step3Local, algorithmFPType, method)(&_env);
477  _in = &input;
478  _par = &parameter;
479  }
480 
481 private:
482  DistributedPartialResultStep3Ptr _partialResult;
483 };
485 } // namespace interface1
486 using interface1::DistributedContainer;
487 using interface1::Distributed;
488 
489 } // namespace daal::algorithms::qr
490 } // namespace daal::algorithms
491 } // namespace daal
492 #endif
daal::algorithms::qr::interface1::Distributed< step2Master, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const DistributedPartialResultPtr &partialRes)
Definition: qr_distributed.h:274
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::qr::interface1::Distributed< step3Local, algorithmFPType, method >::getPartialResult
DistributedPartialResultStep3Ptr getPartialResult()
Definition: qr_distributed.h:399
daal::algorithms::qr::interface1::Parameter
Parameters for the QR decomposition compute method.
Definition: qr_types.h:662
daal::algorithms::qr::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: qr_distributed.h:250
daal::algorithms::qr::finalResultFromStep2Master
Definition: qr_types.h:138
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:131
daal::algorithms::qr::interface1::Distributed< step3Local, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: qr_distributed.h:384
daal::algorithms::qr::interface1::Distributed< step1Local, algorithmFPType, method >
Computes the result of the first step of the QR decomposition algorithm in the distributed processing...
Definition: qr_distributed.h:178
daal::algorithms::qr::interface1::DistributedStep3Input
Input objects for the third step of the QR decomposition algorithm in the distributed processing mode...
Definition: qr_types.h:283
daal::algorithms::qr::inputOfStep3FromStep1
Definition: qr_types.h:169
daal::algorithms::qr::interface1::Distributed< step3Local, algorithmFPType, method >::parameter
Parameter parameter
Definition: qr_distributed.h:361
daal::algorithms::qr::interface1::Distributed
Computes the results of the QR decomposition algorithm in the distributed processing mode...
Definition: qr_distributed.h:164
daal::algorithms::qr::interface1::Distributed< step3Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step3Local, algorithmFPType, method > > clone() const
Definition: qr_distributed.h:444
daal::algorithms::qr::interface1::Distributed< step3Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step3Local, algorithmFPType, method > &other)
Definition: qr_distributed.h:375
daal::algorithms::qr::interface1::Online
Computes the results of the QR decomposition algorithm in the online processing mode.
Definition: qr_online.h:113
daal_defines.h
daal::algorithms::qr::interface1::Distributed< step3Local, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const DistributedPartialResultStep3Ptr &partialRes)
Definition: qr_distributed.h:408
daal::algorithms::qr::interface1::Distributed< step2Master, algorithmFPType, method >::getPartialResult
DistributedPartialResultPtr getPartialResult()
Definition: qr_distributed.h:265
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::qr::interface1::DistributedContainer
Provides methods to run implementations of the QR decomposition algorithm.
Definition: qr_distributed.h:82
daal::algorithms::qr::interface1::Distributed< step2Master, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, method > > clone() const
Definition: qr_distributed.h:304
daal::algorithms::qr::interface1::Distributed< step2Master, algorithmFPType, method >::checkFinalizeComputeParams
services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
Definition: qr_distributed.h:286
daal::algorithms::qr::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: qr_distributed.h:198
daal::algorithms::qr::interface1::Distributed< step3Local, algorithmFPType, method >
Computes the results of the QR decomposition algorithm on the third step in the distributed processin...
Definition: qr_distributed.h:354
daal::algorithms::qr::interface1::Distributed< step3Local, algorithmFPType, method >::input
Input input
Definition: qr_distributed.h:360
daal::algorithms::qr::interface1::Distributed< step3Local, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: qr_distributed.h:390
daal::algorithms::qr::interface1::Distributed< step2Master, algorithmFPType, method >::input
Input input
Definition: qr_distributed.h:227
daal::algorithms::qr::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: qr_distributed.h:241
daal::algorithms::qr::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: qr_distributed.h:189
daal::algorithms::qr::interface1::Distributed< step3Local, algorithmFPType, method >::setResult
services::Status setResult(const ResultPtr &res)
Definition: qr_distributed.h:421
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:94
daal::algorithms::qr::interface1::Distributed< step3Local, algorithmFPType, method >::checkFinalizeComputeParams
services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
Definition: qr_distributed.h:426
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::step2Master
Definition: daal_defines.h:143
daal::algorithms::qr::interface1::Distributed< step2Master, algorithmFPType, method >
Computes the results of the QR decomposition algorithm on the second step in the distributed processi...
Definition: qr_distributed.h:222
daal::algorithms::qr::interface1::Distributed< step3Local, algorithmFPType, method >::Distributed
Distributed()
Definition: qr_distributed.h:364
daal::algorithms::qr::interface1::DistributedStep2Input
Input objects for the second step of the QR decomposition algorithm in the distributed processing mod...
Definition: qr_types.h:228
daal::algorithms::qr::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
Parameter parameter
Definition: qr_distributed.h:228
daal::algorithms::qr::interface1::Distributed< step2Master, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: qr_distributed.h:256
daal::algorithms::qr::finalResultFromStep3
Definition: qr_types.h:148
daal::step3Local
Definition: daal_defines.h:144
daal::services::ErrorNullResult
Definition: error_indexes.h:122
daal::algorithms::qr::interface1::DistributedStep3Input::get
data_management::DataCollectionPtr get(FinalizeOnLocalInputId id) const

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