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

algorithm_base_mode.h
1 /* file: algorithm_base_mode.h */
2 /*******************************************************************************
3 * Copyright 2014-2019 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 base classes defining algorithm interface.
19 //--
20 */
21 
22 #ifndef __ALGORITHM_BASE_MODE_H__
23 #define __ALGORITHM_BASE_MODE_H__
24 
25 #include "services/daal_memory.h"
26 #include "services/daal_kernel_defines.h"
27 #include "services/error_handling.h"
28 #include "services/env_detect.h"
29 #include "algorithms/algorithm_types.h"
30 #include "algorithms/algorithm_base_common.h"
31 
32 namespace daal
33 {
34 namespace algorithms
35 {
36 namespace interface1
37 {
38 
50 template<ComputeMode mode> class Algorithm : public AlgorithmIfaceImpl
51 {
52 public:
54  Algorithm() : _ac(0), _in(0), _pres(0), _res(0), _par(0) { }
55 
56  virtual ~Algorithm()
57  {
58  if(_ac)
59  {
60  delete _ac;
61  }
62  }
63 
64  virtual void clean() {}
65 
69  virtual services::Status checkPartialResult() = 0;
70 
74  virtual services::Status checkFinalizeComputeParams() = 0;
75 
76 protected:
77  PartialResult *allocatePartialResultMemory()
78  {
79  if(_pres == 0)
80  {
81  allocatePartialResult();
82  }
83 
84  return _pres;
85  }
86 
87  virtual void setParameter() {}
88 
89  services::Status allocateResultMemory()
90  {
91  if(_res == 0)
92  return allocateResult();
93  return services::Status();
94  }
95 
96  services::Status initPartialResult()
97  {
98  return initializePartialResult();
99  }
100 
101  virtual services::Status allocatePartialResult() = 0;
102  virtual services::Status allocateResult() = 0;
103 
104  virtual services::Status initializePartialResult() = 0;
105  virtual Algorithm<mode> *cloneImpl() const = 0;
106 
107  bool getInitFlag() { return _pres->getInitFlag(); }
108  void setInitFlag(bool flag) { _pres->setInitFlag(flag); }
109 
110  AlgorithmContainerImpl<mode> *_ac;
111 
112  Input *_in;
113  PartialResult *_pres;
114  Result *_res;
115  Parameter *_par;
116 };
117 
124 template<> class Algorithm<batch> : public AlgorithmIfaceImpl
125 {
126 public:
128  Algorithm() : _ac(0), _par(0), _in(0), _res(0) { }
129 
130  virtual ~Algorithm()
131  {
132  if(_ac)
133  {
134  delete _ac;
135  }
136  }
137 
141  virtual services::Status checkComputeParams() = 0;
142 
143  Parameter * getBaseParameter() { return _par; }
144 
145 protected:
146  services::Status allocateResultMemory()
147  {
148  if(_res == 0)
149  return allocateResult();
150  return services::Status();
151  }
152 
153  virtual void setParameter() {}
154 
155  virtual services::Status allocateResult() = 0;
156 
157  virtual Algorithm<batch> *cloneImpl() const = 0;
158 
159  daal::algorithms::AlgorithmContainerImpl<batch> *_ac;
160 
161  Parameter *_par;
162  Input *_in;
163  Result *_res;
164 };
165 
167 } // namespace interface1
168 using interface1::Algorithm;
169 
170 }
171 }
172 #endif
daal
Definition: algorithm_base_common.h:31
daal::algorithms::interface1::Algorithm::checkFinalizeComputeParams
virtual services::Status checkFinalizeComputeParams()=0
daal::algorithms::interface1::Algorithm::checkPartialResult
virtual services::Status checkPartialResult()=0
daal::batch
Definition: daal_defines.h:110
daal::algorithms::interface1::Algorithm< batch >::Algorithm
Algorithm()
Definition: algorithm_base_mode.h:128
daal::algorithms::interface1::PartialResult::getInitFlag
bool getInitFlag()
Definition: algorithm_types.h:252
daal::algorithms::interface1::AlgorithmIfaceImpl
Implements the abstract interface AlgorithmIface. AlgorithmIfaceImpl is, in turn, the base class for ...
Definition: algorithm_base_common.h:85
daal::algorithms::interface1::Algorithm
Implements the abstract interface AlgorithmIface. Algorithm is, in turn, the base class for the class...
Definition: algorithm_base_mode.h:50
daal::algorithms::interface1::AlgorithmIface::checkComputeParams
virtual services::Status checkComputeParams()=0
daal_kernel_defines.h
daal::algorithms::interface1::Algorithm::Algorithm
Algorithm()
Definition: algorithm_base_mode.h:54
daal::algorithms::interface1::PartialResult::setInitFlag
void setInitFlag(bool flag)
Definition: algorithm_types.h:258

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