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

algorithm_base_mode.h
1 /* file: algorithm_base_mode.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 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 base classes defining algorithm interface.
45 //--
46 */
47 
48 #ifndef __ALGORITHM_BASE_MODE_H__
49 #define __ALGORITHM_BASE_MODE_H__
50 
51 #include "services/daal_memory.h"
52 #include "services/daal_kernel_defines.h"
53 #include "services/error_handling.h"
54 #include "services/env_detect.h"
55 #include "algorithms/algorithm_types.h"
56 #include "algorithms/algorithm_base_common.h"
57 
58 namespace daal
59 {
60 namespace algorithms
61 {
62 namespace interface1
63 {
64 
76 template<ComputeMode mode> class Algorithm : public AlgorithmIfaceImpl
77 {
78 public:
80  Algorithm() : _ac(0), _in(0), _pres(0), _res(0), _par(0) { }
81 
82  virtual ~Algorithm()
83  {
84  if(_ac)
85  {
86  delete _ac;
87  }
88  }
89 
90  virtual void clean() {}
91 
95  virtual services::Status checkPartialResult() = 0;
96 
100  virtual services::Status checkFinalizeComputeParams() = 0;
101 
102 protected:
103  PartialResult *allocatePartialResultMemory()
104  {
105  if(_pres == 0)
106  {
107  allocatePartialResult();
108  }
109 
110  return _pres;
111  }
112 
113  virtual void setParameter() {}
114 
115  services::Status allocateResultMemory()
116  {
117  if(_res == 0)
118  return allocateResult();
119  return services::Status();
120  }
121 
122  services::Status initPartialResult()
123  {
124  return initializePartialResult();
125  }
126 
127  virtual services::Status allocatePartialResult() = 0;
128  virtual services::Status allocateResult() = 0;
129 
130  virtual services::Status initializePartialResult() = 0;
131  virtual Algorithm<mode> *cloneImpl() const = 0;
132 
133  bool getInitFlag() { return _pres->getInitFlag(); }
134  void setInitFlag(bool flag) { _pres->setInitFlag(flag); }
135 
136  AlgorithmContainerImpl<mode> *_ac;
137 
138  Input *_in;
139  PartialResult *_pres;
140  Result *_res;
141  Parameter *_par;
142 };
143 
150 template<> class Algorithm<batch> : public AlgorithmIfaceImpl
151 {
152 public:
154  Algorithm() : _ac(0), _par(0), _in(0), _res(0) { }
155 
156  virtual ~Algorithm()
157  {
158  if(_ac)
159  {
160  delete _ac;
161  }
162  }
163 
167  virtual services::Status checkComputeParams() = 0;
168 
169  Parameter * getBaseParameter() { return _par; }
170 
171 protected:
172  services::Status allocateResultMemory()
173  {
174  if(_res == 0)
175  return allocateResult();
176  return services::Status();
177  }
178 
179  virtual void setParameter() {}
180 
181  virtual services::Status allocateResult() = 0;
182 
183  virtual Algorithm<batch> *cloneImpl() const = 0;
184 
185  daal::algorithms::AlgorithmContainerImpl<batch> *_ac;
186 
187  Parameter *_par;
188  Input *_in;
189  Result *_res;
190 };
191 
193 } // namespace interface1
194 using interface1::Algorithm;
195 
196 }
197 }
198 #endif
daal::services::interface1::Status
Class that holds the results of API calls. In case of API routine failure it contains the list of err...
Definition: error_handling.h:491
daal
Definition: algorithm_base_common.h:57
daal::algorithms::interface1::AlgorithmContainerImpl
Abstract interface class that provides virtual methods to access and run implementations of the algor...
Definition: algorithm_container_base_common.h:181
daal::algorithms::interface1::Result
Base class to represent final results of the computation. Algorithm-specific final results are repres...
Definition: algorithm_types.h:331
daal::algorithms::interface1::PartialResult
Base class to represent partial results of the computation. Algorithm-specific partial results are re...
Definition: algorithm_types.h:253
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:132
daal::algorithms::interface1::Parameter
Base class to represent computation parameters. Algorithm-specific parameters are represented as deri...
Definition: algorithm_types.h:86
daal::algorithms::interface1::Algorithm< batch >::Algorithm
Algorithm()
Definition: algorithm_base_mode.h:154
daal::algorithms::interface1::PartialResult::getInitFlag
bool getInitFlag()
Definition: algorithm_types.h:278
daal::algorithms::interface1::Algorithm< batch >
Implements the abstract interface AlgorithmIface. Algorithm<batch> is, in turn, the base class for th...
Definition: algorithm_base_mode.h:150
daal::algorithms::interface1::AlgorithmIfaceImpl
Implements the abstract interface AlgorithmIface. AlgorithmIfaceImpl is, in turn, the base class for ...
Definition: algorithm_base_common.h:111
daal::algorithms::interface1::Algorithm
Implements the abstract interface AlgorithmIface. Algorithm is, in turn, the base class for the class...
Definition: algorithm_base_mode.h:76
daal::algorithms::interface1::AlgorithmIface::checkComputeParams
virtual services::Status checkComputeParams()=0
daal::algorithms::interface1::Input
Base class to represent computation input arguments. Algorithm-specific input arguments are represent...
Definition: algorithm_types.h:217
daal_kernel_defines.h
daal::algorithms::interface1::Algorithm::Algorithm
Algorithm()
Definition: algorithm_base_mode.h:80
daal::algorithms::interface1::PartialResult::setInitFlag
void setInitFlag(bool flag)
Definition: algorithm_types.h:284

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