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

algorithm_base_common.h
1 /* file: algorithm_base_common.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 base classes defining algorithm interface.
21 //--
22 */
23 
24 #ifndef __ALGORITHM_BASE_COMMON_H__
25 #define __ALGORITHM_BASE_COMMON_H__
26 
27 #include "services/daal_memory.h"
28 #include "services/daal_kernel_defines.h"
29 #include "services/error_handling.h"
30 #include "services/env_detect.h"
31 #include "algorithms/algorithm_types.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace interface1
38 {
39 
51 class AlgorithmIface
52 {
53 public:
54  DAAL_NEW_DELETE();
55 
56  virtual ~AlgorithmIface() {}
57 
61  virtual services::Status checkComputeParams() = 0;
62 
66  virtual services::Status checkResult() = 0;
67 
72  virtual int getMethod() const = 0;
73 
79  virtual services::SharedPtr<services::ErrorCollection> getErrors() = 0;
80 };
81 
87 class AlgorithmIfaceImpl : public AlgorithmIface
88 {
89 public:
91  AlgorithmIfaceImpl() : _enableChecks(true)
92  {
93  getEnvironment();
94  }
95 
96  virtual ~AlgorithmIfaceImpl() {}
97 
102  void enableChecks(bool enableChecksFlag)
103  {
104  _enableChecks = enableChecksFlag;
105  }
106 
111  bool isChecksEnabled() const
112  {
113  return _enableChecks;
114  }
115 
121  services::SharedPtr<services::ErrorCollection> getErrors()
122  {
123  return _status.getCollection();
124  }
125 
126 private:
127  bool _enableChecks;
128 
129 protected:
130  services::Status getEnvironment()
131  {
132  int cpuid = (int)daal::services::Environment::getInstance()->getCpuId();
133  if(cpuid < 0)
134  return services::Status(services::ErrorCpuNotSupported);
135  _env.cpuid = cpuid;
136  _env.cpuid_init_flag = true;
137  return services::Status();
138  }
139 
140  daal::services::Environment::env _env;
141  services::Status _status;
142 };
143 
145 } // namespace interface1
146 using interface1::AlgorithmIface;
147 using interface1::AlgorithmIfaceImpl;
148 
149 }
150 }
151 #endif
daal::algorithms::interface1::AlgorithmIfaceImpl::getErrors
services::SharedPtr< services::ErrorCollection > getErrors()
Definition: algorithm_base_common.h:121
daal::algorithms::interface1::AlgorithmIfaceImpl
Implements the abstract interface AlgorithmIface. AlgorithmIfaceImpl is, in turn, the base class for ...
Definition: algorithm_base_common.h:87
daal::algorithms::interface1::AlgorithmIface::getErrors
virtual services::SharedPtr< services::ErrorCollection > getErrors()=0
daal::algorithms::interface1::AlgorithmIface
Abstract class which defines interface for the library component related to data processing involving...
Definition: algorithm_base_common.h:51
daal::algorithms::interface1::AlgorithmIfaceImpl::isChecksEnabled
bool isChecksEnabled() const
Definition: algorithm_base_common.h:111
daal::algorithms::interface1::AlgorithmIface::checkComputeParams
virtual services::Status checkComputeParams()=0
daal::algorithms::interface1::AlgorithmIface::checkResult
virtual services::Status checkResult()=0
daal::algorithms::interface1::AlgorithmIfaceImpl::AlgorithmIfaceImpl
AlgorithmIfaceImpl()
Definition: algorithm_base_common.h:91
daal::algorithms::interface1::AlgorithmIfaceImpl::enableChecks
void enableChecks(bool enableChecksFlag)
Definition: algorithm_base_common.h:102
daal::services::ErrorCpuNotSupported
Definition: error_indexes.h:149
daal_kernel_defines.h
daal::algorithms::interface1::AlgorithmIface::getMethod
virtual int getMethod() const =0

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