diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index 081169966c3..3341f60583e 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -21,7 +21,7 @@ name: Nightly-build on: schedule: - - cron: '0 21 * * *' + - cron: '0 22 * * *' pull_request: branches: - main diff --git a/cpp/daal/include/algorithms/decision_forest/decision_forest_classification_training_types.h b/cpp/daal/include/algorithms/decision_forest/decision_forest_classification_training_types.h index cdb99e8a685..ef692839b0f 100755 --- a/cpp/daal/include/algorithms/decision_forest/decision_forest_classification_training_types.h +++ b/cpp/daal/include/algorithms/decision_forest/decision_forest_classification_training_types.h @@ -176,7 +176,7 @@ class DAAL_EXPORT Result : public classifier::training::Result * \param[in] id Identifier of the result * \return Result that corresponds to the given identifier */ - engines::EnginePtr get(ResultEngineId id) const; + engines::EngineIfacePtr get(ResultEngineId id) const; protected: using daal::algorithms::interface1::Result::check; diff --git a/cpp/daal/include/algorithms/decision_forest/decision_forest_regression_training_types.h b/cpp/daal/include/algorithms/decision_forest/decision_forest_regression_training_types.h index 9c13a132f3a..749b93c4341 100755 --- a/cpp/daal/include/algorithms/decision_forest/decision_forest_regression_training_types.h +++ b/cpp/daal/include/algorithms/decision_forest/decision_forest_regression_training_types.h @@ -245,7 +245,7 @@ class DAAL_EXPORT Result : public algorithms::regression::training::Result * \param[in] id Identifier of the result * \return Result that corresponds to the given identifier */ - engines::EnginePtr get(ResultEngineId id) const; + engines::EngineIfacePtr get(ResultEngineId id) const; protected: using daal::algorithms::interface1::Result::check; diff --git a/cpp/daal/include/algorithms/decision_forest/decision_forest_training_parameter.h b/cpp/daal/include/algorithms/decision_forest/decision_forest_training_parameter.h index 6c506aceb0a..4041fa1587c 100644 --- a/cpp/daal/include/algorithms/decision_forest/decision_forest_training_parameter.h +++ b/cpp/daal/include/algorithms/decision_forest/decision_forest_training_parameter.h @@ -28,7 +28,7 @@ #include "data_management/data/numeric_table.h" #include "data_management/data/data_serialize.h" #include "services/daal_defines.h" -#include "algorithms/engines/mt2203/mt2203.h" +#include "algorithms/engines/engine.h" namespace daal { @@ -138,7 +138,7 @@ class DAAL_EXPORT Parameter size_t minObservationsInLeafNode; /*!< Minimal number of observations in a leaf node. Default is 1 for classification, 5 for regression. */ size_t seed; /*!< Seed for the random numbers generator used by the algorithms \DAAL_DEPRECATED_USE{ engine } */ - engines::EnginePtr engine; /*!< Engine for the random numbers generator used by the algorithms */ + engines::EngineIfacePtr engine; /*!< Engine for the random numbers generator used by the algorithms */ double impurityThreshold; /*!< Threshold value used as stopping criteria: if the impurity value in the node is smaller than the threshold then the node is not split anymore.*/ VariableImportanceMode varImportance; /*!< Variable importance computation mode */ diff --git a/cpp/daal/include/algorithms/em/em_gmm_init_types.h b/cpp/daal/include/algorithms/em/em_gmm_init_types.h index b8d7cbcd22a..9e191e94c88 100644 --- a/cpp/daal/include/algorithms/em/em_gmm_init_types.h +++ b/cpp/daal/include/algorithms/em/em_gmm_init_types.h @@ -29,7 +29,7 @@ #include "data_management/data/homogen_numeric_table.h" #include "services/daal_defines.h" #include "algorithms/em/em_gmm_covariance_storage_id.h" -#include "algorithms/engines/mt19937/mt19937.h" +#include "algorithms/engines/engine.h" namespace daal { @@ -131,7 +131,7 @@ struct DAAL_EXPORT Parameter : public daal::algorithms::Parameter size_t seed; /*!< Seed for randomly generating data points to start the initialization of short EM */ double accuracyThreshold; /*!< Threshold for the termination of the algorithm */ em_gmm::CovarianceStorageId covarianceStorage; /*!< Type of covariance in the Gaussian mixture model. */ - engines::EnginePtr engine; /*!< Engine to be used for randomly generating data points to start the initialization of short EM */ + engines::EngineIfacePtr engine; /*!< Engine to be used for randomly generating data points to start the initialization of short EM */ }; /* [Parameter source code] */ diff --git a/cpp/daal/include/algorithms/engines/engine.h b/cpp/daal/include/algorithms/engines/engine.h index 25d0fb02790..9dea2ce499e 100644 --- a/cpp/daal/include/algorithms/engines/engine.h +++ b/cpp/daal/include/algorithms/engines/engine.h @@ -17,14 +17,15 @@ /* //++ -// Implementation engine. +// Public interface for random number engines. //-- */ #ifndef __ENGINE_H__ #define __ENGINE_H__ -#include "algorithms/engines/engine_types.h" +#include "services/daal_defines.h" +#include "services/daal_shared_ptr.h" namespace daal { @@ -36,75 +37,56 @@ namespace engines * @ingroup engines * @{ */ +/** + * + * \brief Available random number engine types + */ +enum EngineType +{ + mt19937Engine = 0, /*!< Mersenne Twister engine (mt19937) */ + mt2203Engine = 1, /*!< Mersenne Twister engine (mt2203) */ + mcg59Engine = 2, /*!< Multiplicative congruential generator (mcg59) */ + mrg32k3aEngine = 3, /*!< Combined multiple recursive generator (mrg32k3a) */ + philox4x32x10Engine = 4 /*!< Philox 4x32-10 counter-based engine */ +}; + namespace interface1 { /** - * - * \brief Class representing an engine + * + * \brief Minimal public interface for random number engines */ -class BatchBase : public daal::algorithms::Analysis +class DAAL_EXPORT EngineIface { public: - typedef algorithms::engines::Input InputType; - typedef algorithms::engines::Result ResultType; - - InputType input; /*!< Input of the engine */ - - BatchBase() {} - virtual ~BatchBase() {} - - /** - * Saves current engine state to destination - * \param[in] dest Destination to save the state - * - * \return Status of computations - */ - services::Status saveState(byte * dest) const { return saveStateImpl(dest); } - - /** - * Rewrites current state with source one - * \param[in] src Source state - * - * \return Status of computations - */ - services::Status loadState(const byte * src) { return loadStateImpl(src); } - - /** - * Enables the usage of current engine in parallel regions of code with leapfrog method - * \param[in] threadIdx Index of the thread - * \param[in] nThreads Number of threads - * - * \return Status of computations - */ - services::Status leapfrog(size_t threadIdx, size_t nThreads) { return leapfrogImpl(threadIdx, nThreads); } - - /** - * Enables the usage of current engine in parallel regions of code with skipAhead method - * \param[in] nSkip Number of elements that will be skipped - * - * \return Status of computations - */ - services::Status skipAhead(size_t nSkip) { return skipAheadImpl(nSkip); } + virtual ~EngineIface() {} /** * Returns a pointer to the newly allocated engine * with a copy of input objects and parameters of this engine * \return Pointer to the newly allocated engine */ - services::SharedPtr clone() const { return services::SharedPtr(cloneImpl()); } + virtual services::SharedPtr clone() const = 0; protected: - virtual services::Status saveStateImpl(byte * /*dest*/) const { return services::Status(); } - virtual services::Status loadStateImpl(const byte * /*src*/) { return services::Status(); } - virtual services::Status leapfrogImpl(size_t /*threadNum*/, size_t /*nThreads*/) { return services::Status(services::ErrorMethodNotSupported); } - virtual services::Status skipAheadImpl(size_t /*nSkip*/) { return services::Status(); } - virtual BatchBase * cloneImpl() const = 0; + EngineIface() {} }; -typedef services::SharedPtr EnginePtr; +typedef services::SharedPtr EngineIfacePtr; + +/** + * Creates a random number engine of specified type + * \tparam algorithmFPType Data type for the engine (float or double) + * \param[in] type Type of the engine to create + * \param[in] seed Initial seed for the engine + * \return Pointer to the newly created engine + */ +template +DAAL_EXPORT EngineIfacePtr createEngine(EngineType type, size_t seed = 777); } // namespace interface1 -using interface1::BatchBase; -using interface1::EnginePtr; +using interface1::EngineIface; +using interface1::EngineIfacePtr; +using interface1::createEngine; /** @} */ } // namespace engines } // namespace algorithms diff --git a/cpp/daal/include/algorithms/gradient_boosted_trees/gbt_training_parameter.h b/cpp/daal/include/algorithms/gradient_boosted_trees/gbt_training_parameter.h index 7c5ca03dab1..eb5b9adbc5c 100644 --- a/cpp/daal/include/algorithms/gradient_boosted_trees/gbt_training_parameter.h +++ b/cpp/daal/include/algorithms/gradient_boosted_trees/gbt_training_parameter.h @@ -113,7 +113,7 @@ class DAAL_EXPORT Parameter Default is 0 (use all features) */ size_t minObservationsInLeafNode; /*!< Minimal number of observations in a leaf node. Default is 5. */ bool memorySavingMode; /*!< If true then use memory saving (but slower) mode. Default is false */ - engines::EnginePtr engine; /*!< Engine for the random numbers generator used by the algorithms */ + engines::EngineIfacePtr engine; /*!< Engine for the random numbers generator used by the algorithms */ size_t maxBins; /*!< Used with 'inexact' split finding method only. Maximal number of discrete bins to bucket continuous features. Default is 256. Increasing the number results in higher computation costs */ diff --git a/cpp/daal/include/algorithms/implicit_als/implicit_als_training_init_types.h b/cpp/daal/include/algorithms/implicit_als/implicit_als_training_init_types.h index c2b3ebb1c8d..37378fb10d2 100644 --- a/cpp/daal/include/algorithms/implicit_als/implicit_als_training_init_types.h +++ b/cpp/daal/include/algorithms/implicit_als/implicit_als_training_init_types.h @@ -27,7 +27,7 @@ #include "algorithms/implicit_als/implicit_als_model.h" #include "algorithms/implicit_als/implicit_als_training_types.h" #include "data_management/data/csr_numeric_table.h" -#include "algorithms/engines/mt19937/mt19937.h" +#include "algorithms/engines/engine.h" namespace daal { @@ -160,10 +160,10 @@ struct DAAL_EXPORT Parameter : public daal::algorithms::Parameter */ Parameter(size_t nFactors = 10, size_t fullNUsers = 0, size_t seed = 777777); - size_t nFactors; /*!< Total number of factors */ - size_t fullNUsers; /*!< Full number of users */ - size_t seed; /*!< Seed for generating random numbers in the initialization step \DAAL_DEPRECATED_USE{ engine } */ - engines::EnginePtr engine; /*!< Engine for generating random numbers in the initialization step */ + size_t nFactors; /*!< Total number of factors */ + size_t fullNUsers; /*!< Full number of users */ + size_t seed; /*!< Seed for generating random numbers in the initialization step \DAAL_DEPRECATED_USE{ engine } */ + engines::EngineIfacePtr engine; /*!< Engine for generating random numbers in the initialization step */ services::Status check() const override; }; diff --git a/cpp/daal/include/algorithms/k_nearest_neighbors/bf_knn_classification_model.h b/cpp/daal/include/algorithms/k_nearest_neighbors/bf_knn_classification_model.h index d566fcffc50..4aef56ac86a 100644 --- a/cpp/daal/include/algorithms/k_nearest_neighbors/bf_knn_classification_model.h +++ b/cpp/daal/include/algorithms/k_nearest_neighbors/bf_knn_classification_model.h @@ -25,7 +25,7 @@ #define __BF_KNN_CLASSIFICATION_MODEL_H__ #include "algorithms/classifier/classifier_model.h" -#include "algorithms/engines/mcg59/mcg59.h" +#include "algorithms/engines/engine.h" namespace daal { @@ -102,7 +102,7 @@ struct DAAL_EXPORT Parameter : public daal::algorithms::classifier::Parameter dataUseInModel(dataUse), resultsToCompute(resToCompute), voteWeights(vote), - engine(engines::mcg59::Batch<>::create()) + engine(engines::createEngine(engines::mcg59Engine)) { this->resultsToEvaluate = resToEvaluate; } @@ -147,11 +147,11 @@ struct DAAL_EXPORT Parameter : public daal::algorithms::classifier::Parameter */ services::Status check() const override; - size_t k; /*!< Number of neighbors */ - DataUseInModel dataUseInModel; /*!< The option to enable/disable an usage of the input dataset in kNN model */ - DAAL_UINT64 resultsToCompute; /*!< 64 bit integer flag that indicates the results to compute */ - VoteWeights voteWeights; /*!< Weight function used in prediction */ - engines::EnginePtr engine; /*!< Engine for random choosing elements from training dataset */ + size_t k; /*!< Number of neighbors */ + DataUseInModel dataUseInModel; /*!< The option to enable/disable an usage of the input dataset in kNN model */ + DAAL_UINT64 resultsToCompute; /*!< 64 bit integer flag that indicates the results to compute */ + VoteWeights voteWeights; /*!< Weight function used in prediction */ + engines::EngineIfacePtr engine; /*!< Engine for random choosing elements from training dataset */ }; /* [Parameter source code] */ diff --git a/cpp/daal/include/algorithms/k_nearest_neighbors/kdtree_knn_classification_model.h b/cpp/daal/include/algorithms/k_nearest_neighbors/kdtree_knn_classification_model.h index 960e286569e..fdc02770088 100644 --- a/cpp/daal/include/algorithms/k_nearest_neighbors/kdtree_knn_classification_model.h +++ b/cpp/daal/include/algorithms/k_nearest_neighbors/kdtree_knn_classification_model.h @@ -28,7 +28,7 @@ #include "data_management/data/aos_numeric_table.h" #include "data_management/data/soa_numeric_table.h" #include "data_management/data/homogen_numeric_table.h" -#include "algorithms/engines/mcg59/mcg59.h" +#include "algorithms/engines/engine.h" namespace daal { @@ -107,7 +107,7 @@ struct DAAL_EXPORT Parameter : public daal::algorithms::classifier::Parameter k(nNeighbors), seed(randomSeed), dataUseInModel(dataUse), - engine(engines::mcg59::Batch<>::create()), + engine(engines::createEngine(engines::mcg59Engine)), resultsToCompute(resToCompute), voteWeights(vote) { @@ -119,12 +119,12 @@ struct DAAL_EXPORT Parameter : public daal::algorithms::classifier::Parameter */ services::Status check() const override; - size_t k; /*!< Number of neighbors */ - int seed; /*!< Seed for random choosing elements from training dataset \DAAL_DEPRECATED_USE{ engine } */ - DataUseInModel dataUseInModel; /*!< The option to enable/disable an usage of the input dataset in kNN model */ - engines::EnginePtr engine; /*!< Engine for random choosing elements from training dataset */ - DAAL_UINT64 resultsToCompute; /*!< 64 bit integer flag that indicates the results to compute */ - VoteWeights voteWeights; /*!< Weight function used in prediction */ + size_t k; /*!< Number of neighbors */ + int seed; /*!< Seed for random choosing elements from training dataset \DAAL_DEPRECATED_USE{ engine } */ + DataUseInModel dataUseInModel; /*!< The option to enable/disable an usage of the input dataset in kNN model */ + engines::EngineIfacePtr engine; /*!< Engine for random choosing elements from training dataset */ + DAAL_UINT64 resultsToCompute; /*!< 64 bit integer flag that indicates the results to compute */ + VoteWeights voteWeights; /*!< Weight function used in prediction */ }; /* [Parameter source code] */ } // namespace interface3 diff --git a/cpp/daal/include/algorithms/kmeans/kmeans_init_types.h b/cpp/daal/include/algorithms/kmeans/kmeans_init_types.h index 25a93ed2791..b850cd1e72e 100644 --- a/cpp/daal/include/algorithms/kmeans/kmeans_init_types.h +++ b/cpp/daal/include/algorithms/kmeans/kmeans_init_types.h @@ -29,7 +29,7 @@ #include "data_management/data/homogen_numeric_table.h" #include "data_management/data/data_collection.h" #include "services/daal_defines.h" -#include "algorithms/engines/mt19937/mt19937.h" +#include "algorithms/engines/engine.h" namespace daal { @@ -296,7 +296,7 @@ struct DAAL_EXPORT Parameter : public daal::algorithms::Parameter L = nClusters* oversamplingFactor points are sampled in a round. */ size_t nRounds; /*!< Kmeans|| only. Number of rounds for k-means||. (oversamplingFactor*nRounds) > 1 is a requirement.*/ - engines::EnginePtr engine; /*!< Engine to be used for generating random numbers for the initialization */ + engines::EngineIfacePtr engine; /*!< Engine to be used for generating random numbers for the initialization */ services::Status check() const override; }; diff --git a/cpp/daal/include/algorithms/optimization_solver/coordinate_descent/coordinate_descent_types.h b/cpp/daal/include/algorithms/optimization_solver/coordinate_descent/coordinate_descent_types.h index c0c5006b48f..0871faa7e0d 100644 --- a/cpp/daal/include/algorithms/optimization_solver/coordinate_descent/coordinate_descent_types.h +++ b/cpp/daal/include/algorithms/optimization_solver/coordinate_descent/coordinate_descent_types.h @@ -28,7 +28,7 @@ #include "data_management/data/homogen_numeric_table.h" #include "services/daal_defines.h" #include "algorithms/optimization_solver/iterative_solver/iterative_solver_types.h" -#include "algorithms/engines/mt19937/mt19937.h" +#include "algorithms/engines/engine.h" #include "algorithms/optimization_solver/objective_function/logistic_loss_batch.h" namespace daal @@ -99,9 +99,9 @@ struct DAAL_EXPORT Parameter : public optimization_solver::iterative_solver::Par */ services::Status check() const override; - size_t seed; /*!< Seed for random generation of 32 bit integer indices of terms + size_t seed; /*!< Seed for random generation of 32 bit integer indices of terms in the objective function. \DAAL_DEPRECATED_USE{ engine } */ - engines::EnginePtr engine; /*!< Engine for random generation of 32 bit integer indices of terms + engines::EngineIfacePtr engine; /*!< Engine for random generation of 32 bit integer indices of terms in the objective function. */ SelectionStrategy selection; bool positive; diff --git a/cpp/daal/include/algorithms/optimization_solver/lbfgs/lbfgs_types.h b/cpp/daal/include/algorithms/optimization_solver/lbfgs/lbfgs_types.h index 6cad4c9961c..5e1da9f4a2c 100644 --- a/cpp/daal/include/algorithms/optimization_solver/lbfgs/lbfgs_types.h +++ b/cpp/daal/include/algorithms/optimization_solver/lbfgs/lbfgs_types.h @@ -31,7 +31,7 @@ #include "services/daal_defines.h" #include "algorithms/optimization_solver/iterative_solver/iterative_solver_batch.h" #include "algorithms/optimization_solver/objective_function/sum_of_functions_batch.h" -#include "algorithms/engines/mt19937/mt19937.h" +#include "algorithms/engines/engine.h" namespace daal { @@ -114,12 +114,12 @@ struct DAAL_EXPORT Parameter : public optimization_solver::iterative_solver::Par virtual ~Parameter() {} - size_t m; /*!< Memory parameter of LBFGS. + size_t m; /*!< Memory parameter of LBFGS. The maximum number of correction pairs that define the approximation of inverse Hessian matrix. */ - size_t L; /*!< The number of iterations between the curvature estimates calculations */ - size_t seed; /*!< Seed for random choosing terms from objective function. \DAAL_DEPRECATED_USE{ engine } */ - engines::EnginePtr engine; /*!< Engine for random choosing terms from objective function. */ + size_t L; /*!< The number of iterations between the curvature estimates calculations */ + size_t seed; /*!< Seed for random choosing terms from objective function. \DAAL_DEPRECATED_USE{ engine } */ + engines::EngineIfacePtr engine; /*!< Engine for random choosing terms from objective function. */ data_management::NumericTablePtr batchIndices; diff --git a/cpp/daal/include/daal.h b/cpp/daal/include/daal.h index 8ad8668ec36..25db8a4d4fe 100755 --- a/cpp/daal/include/daal.h +++ b/cpp/daal/include/daal.h @@ -206,17 +206,6 @@ #include "algorithms/linear_model/linear_model_training_batch.h" #include "algorithms/linear_model/linear_model_predict.h" #include "algorithms/engines/engine.h" -#include "algorithms/engines/mt19937/mt19937.h" -#include "algorithms/engines/mt19937/mt19937_types.h" -#include "algorithms/engines/mcg59/mcg59.h" -#include "algorithms/engines/mcg59/mcg59_types.h" -#include "algorithms/engines/engine_family.h" -#include "algorithms/engines/mt2203/mt2203.h" -#include "algorithms/engines/mt2203/mt2203_types.h" -#include "algorithms/engines/mrg32k3a/mrg32k3a.h" -#include "algorithms/engines/mrg32k3a/mrg32k3a_types.h" -#include "algorithms/engines/philox4x32x10/philox4x32x10.h" -#include "algorithms/engines/philox4x32x10/philox4x32x10_types.h" #include "algorithms/dbscan/dbscan_types.h" #include "algorithms/dbscan/dbscan_batch.h" #include "algorithms/dbscan/dbscan_distributed.h" diff --git a/cpp/daal/include/daal_win.h b/cpp/daal/include/daal_win.h index 54e681025ca..29067d7bf99 100644 --- a/cpp/daal/include/daal_win.h +++ b/cpp/daal/include/daal_win.h @@ -218,17 +218,6 @@ #include "algorithms/linear_model/linear_model_training_batch.h" #include "algorithms/linear_model/linear_model_predict.h" #include "algorithms/engines/engine.h" -#include "algorithms/engines/mt19937/mt19937.h" -#include "algorithms/engines/mt19937/mt19937_types.h" -#include "algorithms/engines/mcg59/mcg59.h" -#include "algorithms/engines/mcg59/mcg59_types.h" -#include "algorithms/engines/engine_family.h" -#include "algorithms/engines/mt2203/mt2203.h" -#include "algorithms/engines/mt2203/mt2203_types.h" -#include "algorithms/engines/mrg32k3a/mrg32k3a.h" -#include "algorithms/engines/mrg32k3a/mrg32k3a_types.h" -#include "algorithms/engines/philox4x32x10/philox4x32x10.h" -#include "algorithms/engines/philox4x32x10/philox4x32x10_types.h" #include "algorithms/dbscan/dbscan_types.h" #include "algorithms/dbscan/dbscan_batch.h" #include "algorithms/dbscan/dbscan_distributed.h" diff --git a/cpp/daal/src/algorithms/distributions/bernoulli/bernoulli_kernel.h b/cpp/daal/src/algorithms/distributions/bernoulli/bernoulli_kernel.h index 638070b4407..4159fe15605 100644 --- a/cpp/daal/src/algorithms/distributions/bernoulli/bernoulli_kernel.h +++ b/cpp/daal/src/algorithms/distributions/bernoulli/bernoulli_kernel.h @@ -28,6 +28,7 @@ #include "src/data_management/service_numeric_table.h" #include "src/externals/service_rng.h" #include "src/algorithms/distributions/uniform/uniform_kernel.h" +#include "src/algorithms/engines/engine_impl.h" using namespace daal::services; using namespace daal::data_management; diff --git a/cpp/daal/src/algorithms/distributions/distribution_types.cpp b/cpp/daal/src/algorithms/distributions/distribution_types.cpp index a8a89fff3e2..484207cc80c 100644 --- a/cpp/daal/src/algorithms/distributions/distribution_types.cpp +++ b/cpp/daal/src/algorithms/distributions/distribution_types.cpp @@ -31,7 +31,7 @@ namespace distributions { namespace internal { -ParameterBase::ParameterBase() : engine(engines::mt19937::Batch<>::create()) {} +ParameterBase::ParameterBase() : engine(services::dynamicPointerCast(engines::createEngine(engines::mt19937Engine))) {} ParameterBase::~ParameterBase() {} Input::Input() : daal::algorithms::Input(1) {} diff --git a/cpp/daal/src/algorithms/distributions/distribution_types.h b/cpp/daal/src/algorithms/distributions/distribution_types.h index 425affcdc92..e748ddac655 100644 --- a/cpp/daal/src/algorithms/distributions/distribution_types.h +++ b/cpp/daal/src/algorithms/distributions/distribution_types.h @@ -28,7 +28,7 @@ #include "services/daal_defines.h" #include "data_management/data/numeric_table.h" #include "data_management/data/homogen_numeric_table.h" -#include "algorithms/engines/engine.h" +#include "src/algorithms/engines/engine_impl.h" namespace daal { diff --git a/cpp/daal/src/algorithms/distributions/normal/normal_kernel.h b/cpp/daal/src/algorithms/distributions/normal/normal_kernel.h index 59645ca280c..86d82d17ba8 100644 --- a/cpp/daal/src/algorithms/distributions/normal/normal_kernel.h +++ b/cpp/daal/src/algorithms/distributions/normal/normal_kernel.h @@ -27,6 +27,7 @@ #include "src/algorithms/kernel.h" #include "data_management/data/numeric_table.h" #include "src/algorithms/engines/engine_batch_impl.h" +#include "src/algorithms/engines/engine_impl.h" #include "src/externals/service_rng.h" #include "src/services/service_unique_ptr.h" diff --git a/cpp/daal/src/algorithms/distributions/uniform/uniform_kernel.h b/cpp/daal/src/algorithms/distributions/uniform/uniform_kernel.h index 4a79dff7362..de98162bac2 100644 --- a/cpp/daal/src/algorithms/distributions/uniform/uniform_kernel.h +++ b/cpp/daal/src/algorithms/distributions/uniform/uniform_kernel.h @@ -27,6 +27,7 @@ #include "src/algorithms/kernel.h" #include "data_management/data/numeric_table.h" #include "src/algorithms/engines/engine_batch_impl.h" +#include "src/algorithms/engines/engine_impl.h" #include "src/externals/service_rng.h" #include "src/services/service_unique_ptr.h" diff --git a/cpp/daal/src/algorithms/dtrees/forest/classification/df_classification_training_types.cpp b/cpp/daal/src/algorithms/dtrees/forest/classification/df_classification_training_types.cpp index 39bdc2b3a91..1cb28857265 100644 --- a/cpp/daal/src/algorithms/dtrees/forest/classification/df_classification_training_types.cpp +++ b/cpp/daal/src/algorithms/dtrees/forest/classification/df_classification_training_types.cpp @@ -134,7 +134,7 @@ services::Status Result::check(const daal::algorithms::Input * input, const daal return s; } -engines::EnginePtr Result::get(ResultEngineId id) const +engines::EngineIfacePtr Result::get(ResultEngineId id) const { return _impl->getEngine(); } diff --git a/cpp/daal/src/algorithms/dtrees/forest/classification/df_classification_training_types_result.h b/cpp/daal/src/algorithms/dtrees/forest/classification/df_classification_training_types_result.h index 30dd2b04002..1af7dfda5ad 100755 --- a/cpp/daal/src/algorithms/dtrees/forest/classification/df_classification_training_types_result.h +++ b/cpp/daal/src/algorithms/dtrees/forest/classification/df_classification_training_types_result.h @@ -22,6 +22,8 @@ */ #include "algorithms/decision_forest/decision_forest_classification_training_types.h" +#include "src/algorithms/engines/engine_impl.h" +#include "algorithms/engines/engine.h" using namespace daal::data_management; using namespace daal::services; @@ -49,13 +51,13 @@ class Result::ResultImpl ResultImpl() {} ResultImpl(const ResultImpl & other) { - if (other._engine) _engine = other._engine->clone(); + if (other._engine) _engine = services::dynamicPointerCast(other._engine->clone()); } void setEngine(engines::EnginePtr engine) { _engine = engine; } engines::EnginePtr getEngine() { - if (!_engine) _engine = engines::mt2203::Batch<>::create(); + if (!_engine) _engine = services::dynamicPointerCast(engines::createEngine(engines::mt2203Engine)); return _engine; } diff --git a/cpp/daal/src/algorithms/dtrees/forest/df_train_dense_default_impl.i b/cpp/daal/src/algorithms/dtrees/forest/df_train_dense_default_impl.i index bec2aaaeeb1..1dc9b91c121 100644 --- a/cpp/daal/src/algorithms/dtrees/forest/df_train_dense_default_impl.i +++ b/cpp/daal/src/algorithms/dtrees/forest/df_train_dense_default_impl.i @@ -470,7 +470,7 @@ services::Status computeImpl(const NumericTable * x, const NumericTable * y, con DAAL_CHECK_STATUS_VAR(s); DAAL_CHECK_MALLOC(md.size() == par.nTrees); - res.updatedEngine = enginesCollection.getUpdatedEngine(par.engine, engines, numElems); + res.updatedEngine = services::dynamicPointerCast(enginesCollection.getUpdatedEngine(par.engine, engines, numElems)); //finalize results computation //variable importance diff --git a/cpp/daal/src/algorithms/dtrees/forest/df_training_parameter.cpp b/cpp/daal/src/algorithms/dtrees/forest/df_training_parameter.cpp index fe30c5357de..adc7df86d69 100755 --- a/cpp/daal/src/algorithms/dtrees/forest/df_training_parameter.cpp +++ b/cpp/daal/src/algorithms/dtrees/forest/df_training_parameter.cpp @@ -46,7 +46,7 @@ Parameter::Parameter() maxTreeDepth(0), minObservationsInLeafNode(0), seed(777), - engine(engines::mt2203::Batch<>::create()), + engine(engines::createEngine(engines::mt2203Engine)), impurityThreshold(0.), varImportance(none), resultsToCompute(0), diff --git a/cpp/daal/src/algorithms/dtrees/forest/regression/df_regression_training_result.cpp b/cpp/daal/src/algorithms/dtrees/forest/regression/df_regression_training_result.cpp index 29a82d4d17d..35b918b73d8 100644 --- a/cpp/daal/src/algorithms/dtrees/forest/regression/df_regression_training_result.cpp +++ b/cpp/daal/src/algorithms/dtrees/forest/regression/df_regression_training_result.cpp @@ -122,7 +122,7 @@ services::Status Result::check(const daal::algorithms::Input * input, const daal return s; } -engines::EnginePtr Result::get(ResultEngineId id) const +engines::EngineIfacePtr Result::get(ResultEngineId id) const { return _impl->getEngine(); } diff --git a/cpp/daal/src/algorithms/dtrees/forest/regression/df_regression_training_types_result.h b/cpp/daal/src/algorithms/dtrees/forest/regression/df_regression_training_types_result.h index 922d0b65be3..1424819a432 100755 --- a/cpp/daal/src/algorithms/dtrees/forest/regression/df_regression_training_types_result.h +++ b/cpp/daal/src/algorithms/dtrees/forest/regression/df_regression_training_types_result.h @@ -22,6 +22,8 @@ */ #include "algorithms/decision_forest/decision_forest_regression_training_types.h" +#include "src/algorithms/engines/engine_impl.h" +#include "algorithms/engines/engine.h" using namespace daal::data_management; using namespace daal::services; @@ -44,13 +46,13 @@ class Result::ResultImpl ResultImpl() {} ResultImpl(const ResultImpl & other) { - if (other._engine) _engine = other._engine->clone(); + if (other._engine) _engine = services::dynamicPointerCast(other._engine->clone()); } void setEngine(engines::EnginePtr engine) { _engine = engine; } engines::EnginePtr getEngine() { - if (!_engine) _engine = engines::mt2203::Batch<>::create(); + if (!_engine) _engine = services::dynamicPointerCast(engines::createEngine(engines::mt2203Engine)); return _engine; } diff --git a/cpp/daal/src/algorithms/dtrees/gbt/gbt_training_parameter.cpp b/cpp/daal/src/algorithms/dtrees/gbt/gbt_training_parameter.cpp index 5c3daf226a0..653e4828e01 100644 --- a/cpp/daal/src/algorithms/dtrees/gbt/gbt_training_parameter.cpp +++ b/cpp/daal/src/algorithms/dtrees/gbt/gbt_training_parameter.cpp @@ -25,7 +25,7 @@ #include "src/algorithms/dtrees/gbt/gbt_training_parameter.h" #include "src/services/daal_strings.h" #include "src/algorithms/dtrees/gbt/gbt_internal.h" -#include "algorithms/engines/mt19937/mt19937.h" +#include "algorithms/engines/engine.h" using namespace daal::data_management; using namespace daal::services; @@ -51,7 +51,7 @@ Parameter::Parameter() featuresPerNode(0), minObservationsInLeafNode(5), memorySavingMode(false), - engine(engines::mt19937::Batch<>::create()), + engine(engines::createEngine(engines::mt19937Engine)), minBinSize(5), maxBins(256), internalOptions(gbt::internal::parallelAll) diff --git a/cpp/daal/src/algorithms/em/em_gmm_init_batch.cpp b/cpp/daal/src/algorithms/em/em_gmm_init_batch.cpp index 6868dfb3aff..e0dbf6a383f 100644 --- a/cpp/daal/src/algorithms/em/em_gmm_init_batch.cpp +++ b/cpp/daal/src/algorithms/em/em_gmm_init_batch.cpp @@ -49,7 +49,7 @@ Parameter::Parameter(size_t nComponents, size_t nTrials, size_t nIterations, siz seed(seed), accuracyThreshold(accuracyThreshold), covarianceStorage(covarianceStorage), - engine(engines::mt19937::Batch<>::create()) + engine(engines::createEngine(engines::mt19937Engine)) {} /** diff --git a/cpp/daal/src/algorithms/em/em_gmm_init_dense_default_batch_container.h b/cpp/daal/src/algorithms/em/em_gmm_init_dense_default_batch_container.h index ebfe523d6c1..52efefd5eef 100644 --- a/cpp/daal/src/algorithms/em/em_gmm_init_dense_default_batch_container.h +++ b/cpp/daal/src/algorithms/em/em_gmm_init_dense_default_batch_container.h @@ -93,7 +93,7 @@ services::Status BatchContainer::compute() daal::services::Environment::env & env = *_env; __DAAL_CALL_KERNEL(env, internal::EMInitKernel, __DAAL_KERNEL_ARGUMENTS(algorithmFPType, method), compute, *inputData, *inputWeights, *inputMeans, - inputCovariances, *emPar, *emPar->engine); + inputCovariances, *emPar, *services::dynamicPointerCast(emPar->engine)); } } // namespace internal diff --git a/cpp/daal/src/algorithms/em/em_gmm_init_dense_default_batch_kernel.h b/cpp/daal/src/algorithms/em/em_gmm_init_dense_default_batch_kernel.h index f25b149f50d..2379a2de017 100644 --- a/cpp/daal/src/algorithms/em/em_gmm_init_dense_default_batch_kernel.h +++ b/cpp/daal/src/algorithms/em/em_gmm_init_dense_default_batch_kernel.h @@ -33,6 +33,7 @@ #include "algorithms/em/em_gmm_init_batch.h" #include "algorithms/em/em_gmm.h" #include "src/algorithms/distributions/uniform/uniform_kernel.h" +#include "src/algorithms/engines/engine_impl.h" namespace daal { diff --git a/cpp/daal/src/algorithms/engines/engine_batch.h b/cpp/daal/src/algorithms/engines/engine_batch.h index 5ae4afa907d..412896cf854 100644 --- a/cpp/daal/src/algorithms/engines/engine_batch.h +++ b/cpp/daal/src/algorithms/engines/engine_batch.h @@ -23,7 +23,7 @@ #ifndef __ENGINE_BATCH__ #define __ENGINE_BATCH__ -#include "algorithms/engines/engine_types.h" +#include "src/algorithms/engines/engine_types.h" namespace daal { @@ -31,10 +31,10 @@ namespace algorithms { namespace engines { -namespace interface1 +namespace internal { template -DAAL_EXPORT services::Status Result::allocate(const daal::algorithms::Input * input, const daal::algorithms::Parameter * par, const int method) +services::Status Result::allocate(const daal::algorithms::Input * input, const daal::algorithms::Parameter * par, const int method) { const Input * algInput = static_cast(input); @@ -42,7 +42,7 @@ DAAL_EXPORT services::Status Result::allocate(const daal::algorithms::Input * in return services::Status(); } -} // namespace interface1 +} // namespace internal } // namespace engines } // namespace algorithms } // namespace daal diff --git a/cpp/daal/src/algorithms/engines/engine_batch_fpt.cpp b/cpp/daal/src/algorithms/engines/engine_batch_fpt.cpp index b332b404f46..ac8326c48ce 100644 --- a/cpp/daal/src/algorithms/engines/engine_batch_fpt.cpp +++ b/cpp/daal/src/algorithms/engines/engine_batch_fpt.cpp @@ -29,12 +29,12 @@ namespace algorithms { namespace engines { -namespace interface1 +namespace internal { -template DAAL_EXPORT services::Status Result::allocate(const daal::algorithms::Input * input, const daal::algorithms::Parameter * par, - const int method); +template services::Status Result::allocate(const daal::algorithms::Input * input, const daal::algorithms::Parameter * par, + const int method); -} // namespace interface1 +} // namespace internal } // namespace engines } // namespace algorithms } // namespace daal diff --git a/cpp/daal/src/algorithms/engines/engine_factory.cpp b/cpp/daal/src/algorithms/engines/engine_factory.cpp new file mode 100644 index 00000000000..eefcb034017 --- /dev/null +++ b/cpp/daal/src/algorithms/engines/engine_factory.cpp @@ -0,0 +1,60 @@ +/* file: engine_factory.cpp */ +/******************************************************************************* +* Copyright contributors to the oneDAL project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*******************************************************************************/ + +/* +//++ +// Implementation of engine factory function. +//-- +*/ + +#include "algorithms/engines/engine.h" +#include "src/algorithms/engines/mt19937/mt19937.h" +#include "src/algorithms/engines/mt2203/mt2203.h" +#include "src/algorithms/engines/mcg59/mcg59.h" +#include "src/algorithms/engines/mrg32k3a/mrg32k3a.h" +#include "src/algorithms/engines/philox4x32x10/philox4x32x10.h" + +namespace daal +{ +namespace algorithms +{ +namespace engines +{ +namespace interface1 +{ +template +DAAL_EXPORT EngineIfacePtr createEngine(EngineType type, size_t seed) +{ + switch (type) + { + case mt19937Engine: return mt19937::internal::Batch::create(seed); + case mt2203Engine: return mt2203::internal::Batch::create(seed); + case mcg59Engine: return mcg59::internal::Batch::create(seed); + case mrg32k3aEngine: return mrg32k3a::internal::Batch::create(seed); + case philox4x32x10Engine: return philox4x32x10::internal::Batch::create(seed); + default: return EngineIfacePtr(); + } +} + +// Explicit instantiations +template DAAL_EXPORT EngineIfacePtr createEngine(EngineType type, size_t seed); +template DAAL_EXPORT EngineIfacePtr createEngine(EngineType type, size_t seed); + +} // namespace interface1 +} // namespace engines +} // namespace algorithms +} // namespace daal diff --git a/cpp/daal/src/algorithms/engines/engine_family.cpp b/cpp/daal/src/algorithms/engines/engine_family.cpp index 5bc9114c63f..ab681dd0d35 100644 --- a/cpp/daal/src/algorithms/engines/engine_family.cpp +++ b/cpp/daal/src/algorithms/engines/engine_family.cpp @@ -19,7 +19,7 @@ // Implementation of initializer types. //-- -#include "algorithms/engines/engine_family.h" +#include "src/algorithms/engines/engine_family.h" namespace daal { @@ -31,7 +31,7 @@ namespace engines * @ingroup engines * @{ */ -namespace interface1 +namespace internal { FamilyBatchBase::FamilyBatchBase() {} @@ -57,7 +57,7 @@ size_t FamilyBatchBase::getMaxNumberOfStreams() const return getMaxNumberOfStreamsImpl(); } -} // namespace interface1 +} // namespace internal } // namespace engines } // namespace algorithms } // namespace daal diff --git a/cpp/daal/include/algorithms/engines/engine_family.h b/cpp/daal/src/algorithms/engines/engine_family.h similarity index 93% rename from cpp/daal/include/algorithms/engines/engine_family.h rename to cpp/daal/src/algorithms/engines/engine_family.h index f3c2e1e47cb..0e75581c783 100644 --- a/cpp/daal/include/algorithms/engines/engine_family.h +++ b/cpp/daal/src/algorithms/engines/engine_family.h @@ -24,7 +24,7 @@ #ifndef __ENGINE_FAMILY_H__ #define __ENGINE_FAMILY_H__ -#include "algorithms/engines/engine.h" +#include "src/algorithms/engines/engine_impl.h" namespace daal { @@ -36,7 +36,7 @@ namespace engines * @ingroup engines * @{ */ -namespace interface1 +namespace internal { /** * @@ -44,7 +44,7 @@ namespace interface1 * * \DAAL_DEPRECATED */ -class DAAL_EXPORT FamilyBatchBase : public engines::BatchBase +class FamilyBatchBase : public engines::BatchBase { public: typedef engines::BatchBase super; @@ -98,9 +98,9 @@ class DAAL_EXPORT FamilyBatchBase : public engines::BatchBase }; typedef services::SharedPtr FamilyEnginePtr; -} // namespace interface1 -using interface1::FamilyBatchBase; -using interface1::FamilyEnginePtr; +} // namespace internal +using internal::FamilyBatchBase; +using internal::FamilyEnginePtr; /** @} */ } // namespace engines } // namespace algorithms diff --git a/cpp/daal/src/algorithms/engines/engine_impl.h b/cpp/daal/src/algorithms/engines/engine_impl.h new file mode 100644 index 00000000000..5885400fa7d --- /dev/null +++ b/cpp/daal/src/algorithms/engines/engine_impl.h @@ -0,0 +1,127 @@ +/* file: engine_impl.h */ +/******************************************************************************* +* Copyright contributors to the oneDAL project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*******************************************************************************/ + +/* +//++ +// Implementation of engine internal classes (deprecated, for internal use only). +//-- +*/ + +#ifndef __ENGINE_IMPL_H__ +#define __ENGINE_IMPL_H__ + +#include "services/daal_defines.h" +#include "algorithms/engines/engine.h" +#include "algorithms/algorithm.h" +#include "src/algorithms/engines/engine_types.h" + +namespace daal +{ +namespace algorithms +{ +namespace engines +{ +namespace interface1 +{ + +// Non-covariant return type for cloneImpl() overrides. +// Using the exact base class return type avoids MSVC C1075 error caused by +// covariant return thunk generation with multiple inheritance (EngineIface + Analysis). +using EngineCloneReturnType = daal::algorithms::Algorithm; + +/** + * + * \brief Class representing an engine (internal implementation) + * + * \DAAL_DEPRECATED Internal use only + */ +class BatchBase : public EngineIface, public daal::algorithms::Analysis +{ +public: + typedef algorithms::engines::Input InputType; + typedef algorithms::engines::Result ResultType; + + InputType input; /*!< Input of the engine */ + + BatchBase() {} + virtual ~BatchBase() {} + + /** + * Saves current engine state to destination + * \param[in] dest Destination to save the state + * + * \return Status of computations + */ + services::Status saveState(byte * dest) const { return saveStateImpl(dest); } + + /** + * Rewrites current state with source one + * \param[in] src Source state + * + * \return Status of computations + */ + services::Status loadState(const byte * src) { return loadStateImpl(src); } + + /** + * Enables the usage of current engine in parallel regions of code with leapfrog method + * \param[in] threadIdx Index of the thread + * \param[in] nThreads Number of threads + * + * \return Status of computations + */ + services::Status leapfrog(size_t threadIdx, size_t nThreads) { return leapfrogImpl(threadIdx, nThreads); } + + /** + * Enables the usage of current engine in parallel regions of code with skipAhead method + * \param[in] nSkip Number of elements that will be skipped + * + * \return Status of computations + */ + services::Status skipAhead(size_t nSkip) { return skipAheadImpl(nSkip); } + + /** + * Returns a pointer to the newly allocated engine + * with a copy of input objects and parameters of this engine + * \return Pointer to the newly allocated engine + */ + services::SharedPtr clone() const override { return services::SharedPtr(static_cast(cloneImpl())); } + + /** + * Returns a pointer to the newly allocated engine (BatchBase type) + * with a copy of input objects and parameters of this engine + * \return Pointer to the newly allocated engine + */ + services::SharedPtr cloneBatch() const { return services::SharedPtr(static_cast(cloneImpl())); } + +protected: + virtual services::Status saveStateImpl(byte * /*dest*/) const { return services::Status(); } + virtual services::Status loadStateImpl(const byte * /*src*/) { return services::Status(); } + virtual services::Status leapfrogImpl(size_t /*threadNum*/, size_t /*nThreads*/) { return services::Status(services::ErrorMethodNotSupported); } + virtual services::Status skipAheadImpl(size_t /*nSkip*/) { return services::Status(); } + // cloneImpl() inherited from Algorithm — not redeclared here to avoid + // covariant return, which triggers MSVC C1075 with multiple inheritance +}; +typedef services::SharedPtr EnginePtr; + +} // namespace interface1 +using interface1::EngineCloneReturnType; +using interface1::BatchBase; +using interface1::EnginePtr; +} // namespace engines +} // namespace algorithms +} // namespace daal +#endif diff --git a/cpp/daal/src/algorithms/engines/engine_types.cpp b/cpp/daal/src/algorithms/engines/engine_types.cpp index 1f9ab34890d..1a74f11c019 100644 --- a/cpp/daal/src/algorithms/engines/engine_types.cpp +++ b/cpp/daal/src/algorithms/engines/engine_types.cpp @@ -19,7 +19,7 @@ // Implementation of initializer types. //-- -#include "algorithms/engines/engine_types.h" +#include "src/algorithms/engines/engine_types.h" #include "src/services/daal_strings.h" namespace daal @@ -28,7 +28,7 @@ namespace algorithms { namespace engines { -namespace interface1 +namespace internal { Input::Input() : daal::algorithms::Input(1) {} @@ -70,7 +70,7 @@ services::Status Result::check(const daal::algorithms::Input * input, const daal return data_management::checkNumericTable(get(randomNumbers).get(), randomNumbersStr()); } -} // namespace interface1 +} // namespace internal } // namespace engines } // namespace algorithms } // namespace daal diff --git a/cpp/daal/include/algorithms/engines/engine_types.h b/cpp/daal/src/algorithms/engines/engine_types.h similarity index 93% rename from cpp/daal/include/algorithms/engines/engine_types.h rename to cpp/daal/src/algorithms/engines/engine_types.h index eb530c13c47..7a67705c2a9 100644 --- a/cpp/daal/include/algorithms/engines/engine_types.h +++ b/cpp/daal/src/algorithms/engines/engine_types.h @@ -65,7 +65,7 @@ enum ResultId /** * \brief Contains version 1.0 of oneAPI Data Analytics Library interface. */ -namespace interface1 +namespace internal { /** * @@ -73,7 +73,7 @@ namespace interface1 * * \DAAL_DEPRECATED */ -class DAAL_EXPORT Input : public daal::algorithms::Input +class Input : public daal::algorithms::Input { public: /** @@ -115,7 +115,7 @@ class DAAL_EXPORT Input : public daal::algorithms::Input * * \DAAL_DEPRECATED */ -class DAAL_EXPORT Result : public daal::algorithms::Result +class Result : public daal::algorithms::Result { public: /** \brief Constructor */ @@ -132,7 +132,7 @@ class DAAL_EXPORT Result : public daal::algorithms::Result * \return Status of computations */ template - DAAL_EXPORT services::Status allocate(const daal::algorithms::Input * input, const daal::algorithms::Parameter * par, const int method); + services::Status allocate(const daal::algorithms::Input * input, const daal::algorithms::Parameter * par, const int method); /** * Returns result of the engine @@ -185,10 +185,10 @@ class DAAL_EXPORT Result : public daal::algorithms::Result } }; typedef services::SharedPtr ResultPtr; -} // namespace interface1 -using interface1::Input; -using interface1::Result; -using interface1::ResultPtr; +} // namespace internal +using internal::Input; +using internal::Result; +using internal::ResultPtr; } // namespace engines /** @} */ } // namespace algorithms diff --git a/cpp/daal/src/algorithms/engines/engine_types_internal.h b/cpp/daal/src/algorithms/engines/engine_types_internal.h index d36678896b2..b010726356c 100644 --- a/cpp/daal/src/algorithms/engines/engine_types_internal.h +++ b/cpp/daal/src/algorithms/engines/engine_types_internal.h @@ -23,7 +23,7 @@ #define __ENGINE_TYPES_INTERNAL_H__ #include "src/algorithms/engines/engine_batch_impl.h" -#include "algorithms/engines/engine_family.h" +#include "src/algorithms/engines/engine_family.h" #include "src/services/service_arrays.h" namespace daal @@ -53,15 +53,19 @@ class EnginesCollection size_t _numberOfStreams; public: - EnginesCollection(engines::EnginePtr engine, ParallelizationTechnique technique, Params & params, + EnginesCollection(engines::EngineIfacePtr engineIface, ParallelizationTechnique technique, Params & params, services::internal::TArray & engines, services::Status * st) { - *st = initEngines(engine, technique, params, engines); + // Cast EngineIfacePtr to EnginePtr for internal usage + engines::EnginePtr engine = services::dynamicPointerCast(engineIface); + *st = initEngines(engine, technique, params, engines); } - engines::EnginePtr getUpdatedEngine(engines::EnginePtr engine, services::internal::TArray & engines, - services::internal::TArray & numElems) + engines::EngineIfacePtr getUpdatedEngine(engines::EngineIfacePtr engineIface, services::internal::TArray & engines, + services::internal::TArray & numElems) { + // Cast to EnginePtr for internal operations + engines::EnginePtr engine = services::dynamicPointerCast(engineIface); switch (_technique) { case skipahead: @@ -78,13 +82,13 @@ class EnginesCollection nSkip = numElems[i]; } } - auto updatedEngine = engine->clone(); + auto updatedEngine = engine->cloneBatch(); updatedEngine->skipAhead(nSkip); return updatedEngine; } case family: return _clonedEngine; } - return engines::EnginePtr(); + return engines::EngineIfacePtr(); } services::Status initEngines(engines::EnginePtr engine, ParallelizationTechnique technique, Params & params, @@ -102,7 +106,7 @@ class EnginesCollection { for (size_t i = 0; i < _numberOfStreams; i++) { - auto engineLocal = engine->clone(); + auto engineLocal = services::dynamicPointerCast(engine->clone()); DAAL_CHECK_STATUS_VAR(engineLocal->skipAhead(params.nSkip[i])); engines[i] = engineLocal; } @@ -112,7 +116,7 @@ class EnginesCollection { for (size_t i = 0; i < _numberOfStreams; i++) { - auto engineLocal = engine->clone(); + auto engineLocal = services::dynamicPointerCast(engine->clone()); DAAL_CHECK_STATUS_VAR(engineLocal->leapfrog(i, params.numberOfStreams)); engines[i] = engineLocal; } diff --git a/cpp/daal/src/algorithms/engines/mcg59/mcg59.cpp b/cpp/daal/src/algorithms/engines/mcg59/mcg59.cpp index 0b3569f76b8..e954dc6958e 100644 --- a/cpp/daal/src/algorithms/engines/mcg59/mcg59.cpp +++ b/cpp/daal/src/algorithms/engines/mcg59/mcg59.cpp @@ -19,7 +19,7 @@ // Implementation of mcg59 engine //-- -#include "algorithms/engines/mcg59/mcg59.h" +#include "src/algorithms/engines/mcg59/mcg59.h" #include "src/externals/service_dispatch.h" #include "src/algorithms/engines/mcg59/mcg59_batch_impl.h" @@ -31,7 +31,7 @@ namespace engines { namespace mcg59 { -namespace interface1 +namespace internal { using namespace daal::services; using namespace mcg59::internal; @@ -48,10 +48,10 @@ SharedPtr > Batch::creat return engPtr; } -template SharedPtr > DAAL_EXPORT Batch::create(size_t seed); -template SharedPtr > DAAL_EXPORT Batch::create(size_t seed); +template SharedPtr > Batch::create(size_t seed); +template SharedPtr > Batch::create(size_t seed); -} // namespace interface1 +} // namespace internal } // namespace mcg59 } // namespace engines } // namespace algorithms diff --git a/cpp/daal/include/algorithms/engines/mcg59/mcg59.h b/cpp/daal/src/algorithms/engines/mcg59/mcg59.h similarity index 84% rename from cpp/daal/include/algorithms/engines/mcg59/mcg59.h rename to cpp/daal/src/algorithms/engines/mcg59/mcg59.h index 9e07b469c20..82b3da1df75 100644 --- a/cpp/daal/include/algorithms/engines/mcg59/mcg59.h +++ b/cpp/daal/src/algorithms/engines/mcg59/mcg59.h @@ -24,8 +24,8 @@ #ifndef __MCG59_H__ #define __MCG59_H__ -#include "algorithms/engines/mcg59/mcg59_types.h" -#include "algorithms/engines/engine.h" +#include "src/algorithms/engines/mcg59/mcg59_types.h" +#include "src/algorithms/engines/engine_impl.h" namespace daal { @@ -40,7 +40,7 @@ namespace mcg59 * @ingroup engines_mcg59 * @{ */ -namespace interface1 +namespace internal { /** * @@ -53,13 +53,13 @@ namespace interface1 * - mcg59::Method Computation methods for the mcg59 engine * * \par References - * - \ref engines::interface1::Input "engines::Input" class - * - \ref engines::interface1::Result "engines::Result" class + * - \ref engines::internal::Input "engines::Input" class + * - \ref engines::internal::Result "engines::Result" class * * \DAAL_DEPRECATED */ template -class DAAL_EXPORT Batch : public engines::BatchBase +class Batch : public engines::BatchBase { public: typedef engines::BatchBase super; @@ -106,8 +106,6 @@ class DAAL_EXPORT Batch : public engines::BatchBase * with a copy of input objects and parameters of this mcg59 engine * \return Pointer to the newly allocated engine */ - services::SharedPtr > clone() const { return services::SharedPtr >(cloneImpl()); } - /** * Allocates memory to store the result of the mcg59 engine * @@ -125,7 +123,7 @@ class DAAL_EXPORT Batch : public engines::BatchBase Batch(const Batch & other); - Batch * cloneImpl() const override { return new Batch(*this); } + EngineCloneReturnType * cloneImpl() const override { return new Batch(*this); } void initialize(); @@ -137,10 +135,10 @@ class DAAL_EXPORT Batch : public engines::BatchBase typedef services::SharedPtr > mcg59Ptr; typedef services::SharedPtr > mcg59ConstPtr; -} // namespace interface1 -using interface1::Batch; -using interface1::mcg59Ptr; -using interface1::mcg59ConstPtr; +} // namespace internal +using internal::Batch; +using internal::mcg59Ptr; +using internal::mcg59ConstPtr; /** @} */ } // namespace mcg59 } // namespace engines diff --git a/cpp/daal/src/algorithms/engines/mcg59/mcg59_batch_container.h b/cpp/daal/src/algorithms/engines/mcg59/mcg59_batch_container.h index 83f234da24d..a0e253a92d7 100644 --- a/cpp/daal/src/algorithms/engines/mcg59/mcg59_batch_container.h +++ b/cpp/daal/src/algorithms/engines/mcg59/mcg59_batch_container.h @@ -24,7 +24,7 @@ #ifndef __MCG59_BATCH_CONTAINER_H__ #define __MCG59_BATCH_CONTAINER_H__ -#include "algorithms/engines/mcg59/mcg59.h" +#include "src/algorithms/engines/mcg59/mcg59.h" #include "src/algorithms/algorithm_dispatch_container_batch.h" #include "src/algorithms/engines/mcg59/mcg59_kernel.h" @@ -41,7 +41,7 @@ namespace internal /** * * \brief Provides methods to run implementations of the mcg59 engine. - * This class is associated with the \ref mcg59::interface1::Batch "mcg59::Batch" class + * This class is associated with the \ref mcg59::internal::Batch "mcg59::Batch" class * and supports the method of mcg59 engine computation in the batch processing mode * * \tparam algorithmFPType Data type to use in intermediate computations of mcg59 engine, double or float diff --git a/cpp/daal/src/algorithms/engines/mcg59/mcg59_batch_impl.h b/cpp/daal/src/algorithms/engines/mcg59/mcg59_batch_impl.h index c72c0714ab6..9236f45d8bd 100644 --- a/cpp/daal/src/algorithms/engines/mcg59/mcg59_batch_impl.h +++ b/cpp/daal/src/algorithms/engines/mcg59/mcg59_batch_impl.h @@ -21,7 +21,7 @@ //-- */ -#include "algorithms/engines/mcg59/mcg59.h" +#include "src/algorithms/engines/mcg59/mcg59.h" #include "src/algorithms/engines/engine_batch_impl.h" #include "src/externals/service_rng.h" #include "src/data_management/service_numeric_table.h" @@ -39,10 +39,10 @@ namespace internal using namespace daal::internal; template -class BatchImpl : public algorithms::engines::mcg59::interface1::Batch, public algorithms::engines::internal::BatchBaseImpl +class BatchImpl : public algorithms::engines::mcg59::internal::Batch, public algorithms::engines::internal::BatchBaseImpl { public: - typedef algorithms::engines::mcg59::interface1::Batch super1; + typedef algorithms::engines::mcg59::internal::Batch super1; typedef algorithms::engines::internal::BatchBaseImpl super2; BatchImpl(size_t seed = 777) : baseRng(seed, __DAAL_BRNG_MCG59), super2(seed) {} @@ -84,7 +84,7 @@ class BatchImpl : public algorithms::engines::mcg59::interface1::Batch * cloneImpl() const override { return new BatchImpl(*this); } + EngineCloneReturnType * cloneImpl() const override { return new BatchImpl(*this); } bool hasSupport(engines::internal::ParallelizationTechnique technique) const override { diff --git a/cpp/daal/src/algorithms/engines/mcg59/mcg59_dense_default_batch_fpt_dispatcher.cpp b/cpp/daal/src/algorithms/engines/mcg59/mcg59_dense_default_batch_fpt_dispatcher.cpp index 52e8dc5524b..77d703b8293 100644 --- a/cpp/daal/src/algorithms/engines/mcg59/mcg59_dense_default_batch_fpt_dispatcher.cpp +++ b/cpp/daal/src/algorithms/engines/mcg59/mcg59_dense_default_batch_fpt_dispatcher.cpp @@ -30,7 +30,7 @@ namespace engines { namespace mcg59 { -namespace interface1 +namespace internal { template <> void Batch::initialize() @@ -40,7 +40,7 @@ void Batch::initialize() _result.reset(new ResultType()); } template <> -DAAL_EXPORT Batch::Batch(size_t seed) +Batch::Batch(size_t seed) { initialize(); } @@ -48,12 +48,12 @@ DAAL_EXPORT Batch::Batch(size_t seed) using BatchType = Batch; template <> -DAAL_EXPORT BatchType::Batch(const BatchType & other) : super(other) +BatchType::Batch(const BatchType & other) : super(other) { initialize(); } -} // namespace interface1 +} // namespace internal } // namespace mcg59 } // namespace engines } // namespace algorithms diff --git a/cpp/daal/src/algorithms/engines/mcg59/mcg59_kernel.h b/cpp/daal/src/algorithms/engines/mcg59/mcg59_kernel.h index b771c8fd970..4428ce5314a 100644 --- a/cpp/daal/src/algorithms/engines/mcg59/mcg59_kernel.h +++ b/cpp/daal/src/algorithms/engines/mcg59/mcg59_kernel.h @@ -22,7 +22,7 @@ #ifndef __MCG59_KERNEL_H__ #define __MCG59_KERNEL_H__ -#include "algorithms/engines/mcg59/mcg59.h" +#include "src/algorithms/engines/mcg59/mcg59.h" #include "src/algorithms/kernel.h" #include "data_management/data/numeric_table.h" diff --git a/cpp/daal/include/algorithms/engines/mcg59/mcg59_types.h b/cpp/daal/src/algorithms/engines/mcg59/mcg59_types.h similarity index 100% rename from cpp/daal/include/algorithms/engines/mcg59/mcg59_types.h rename to cpp/daal/src/algorithms/engines/mcg59/mcg59_types.h diff --git a/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a.cpp b/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a.cpp index 3d3366fbb4f..4839e8dac91 100644 --- a/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a.cpp +++ b/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a.cpp @@ -20,7 +20,7 @@ // with two components of order 3, optimized for batch processing. //-- -#include "algorithms/engines/mrg32k3a/mrg32k3a.h" +#include "src/algorithms/engines/mrg32k3a/mrg32k3a.h" #include "src/algorithms/engines/mrg32k3a/mrg32k3a_batch_impl.h" #include "src/externals/service_dispatch.h" @@ -32,7 +32,7 @@ namespace engines { namespace mrg32k3a { -namespace interface1 +namespace internal { using namespace daal::services; using namespace mrg32k3a::internal; @@ -50,10 +50,10 @@ SharedPtr > Batch::creat return engPtr; } -template SharedPtr > DAAL_EXPORT Batch::create(size_t seed); -template SharedPtr > DAAL_EXPORT Batch::create(size_t seed); +template SharedPtr > Batch::create(size_t seed); +template SharedPtr > Batch::create(size_t seed); -} // namespace interface1 +} // namespace internal } // namespace mrg32k3a } // namespace engines } // namespace algorithms diff --git a/cpp/daal/include/algorithms/engines/mrg32k3a/mrg32k3a.h b/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a.h similarity index 85% rename from cpp/daal/include/algorithms/engines/mrg32k3a/mrg32k3a.h rename to cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a.h index 7a5deb6171f..e72fbb31ead 100644 --- a/cpp/daal/include/algorithms/engines/mrg32k3a/mrg32k3a.h +++ b/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a.h @@ -25,8 +25,8 @@ #ifndef __MRG32K3A_H__ #define __MRG32K3A_H__ -#include "algorithms/engines/mrg32k3a/mrg32k3a_types.h" -#include "algorithms/engines/engine.h" +#include "src/algorithms/engines/mrg32k3a/mrg32k3a_types.h" +#include "src/algorithms/engines/engine_impl.h" namespace daal { @@ -41,7 +41,7 @@ namespace mrg32k3a * @ingroup engines_mrg32k3a * @{ */ -namespace interface1 +namespace internal { /** * @@ -54,13 +54,13 @@ namespace interface1 * - mrg32k3a::Method Computation methods for the mrg32k3a engine * * \par References - * - \ref engines::interface1::Input "engines::Input" class - * - \ref engines::interface1::Result "engines::Result" class + * - \ref engines::internal::Input "engines::Input" class + * - \ref engines::internal::Result "engines::Result" class * * \DAAL_DEPRECATED */ template -class DAAL_EXPORT Batch : public engines::BatchBase +class Batch : public engines::BatchBase { public: typedef engines::BatchBase super; @@ -107,8 +107,6 @@ class DAAL_EXPORT Batch : public engines::BatchBase * with a copy of input objects and parameters of this mrg32k3a engine * \return Pointer to the newly allocated engine */ - services::SharedPtr > clone() const { return services::SharedPtr >(cloneImpl()); } - /** * Allocates memory to store the result of the mrg32k3a engine * @@ -128,7 +126,7 @@ class DAAL_EXPORT Batch : public engines::BatchBase Batch(const Batch & other); - Batch * cloneImpl() const override { return new Batch(*this); } + EngineCloneReturnType * cloneImpl() const override { return new Batch(*this); } void initialize(); @@ -140,10 +138,10 @@ class DAAL_EXPORT Batch : public engines::BatchBase typedef services::SharedPtr > mrg32k3aPtr; typedef services::SharedPtr > mrg32k3aConstPtr; -} // namespace interface1 -using interface1::Batch; -using interface1::mrg32k3aPtr; -using interface1::mrg32k3aConstPtr; +} // namespace internal +using internal::Batch; +using internal::mrg32k3aPtr; +using internal::mrg32k3aConstPtr; /** @} */ } // namespace mrg32k3a } // namespace engines diff --git a/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_batch_container.h b/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_batch_container.h index 9ab182e81ce..3bef7ed54b8 100644 --- a/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_batch_container.h +++ b/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_batch_container.h @@ -24,7 +24,7 @@ #ifndef __MRG32K3A_BATCH_CONTAINER_H__ #define __MRG32K3A_BATCH_CONTAINER_H__ -#include "algorithms/engines/mrg32k3a/mrg32k3a.h" +#include "src/algorithms/engines/mrg32k3a/mrg32k3a.h" #include "src/algorithms/algorithm_dispatch_container_batch.h" #include "src/algorithms/engines/mrg32k3a/mrg32k3a_kernel.h" @@ -41,7 +41,7 @@ namespace internal /** * * \brief Provides methods to run implementations of the mrg32k3a engine. - * This class is associated with the \ref mrg32k3a::interface1::Batch "mrg32k3a::Batch" class + * This class is associated with the \ref mrg32k3a::internal::Batch "mrg32k3a::Batch" class * and supports the method of mrg32k3a engine computation in the batch processing mode * * \tparam algorithmFPType Data type to use in intermediate computations of mrg32k3a engine, double or float diff --git a/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_batch_impl.h b/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_batch_impl.h index 91bfac27183..8a2630951f0 100644 --- a/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_batch_impl.h +++ b/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_batch_impl.h @@ -21,7 +21,7 @@ //-- */ -#include "algorithms/engines/mrg32k3a/mrg32k3a.h" +#include "src/algorithms/engines/mrg32k3a/mrg32k3a.h" #include "src/algorithms/engines/engine_batch_impl.h" #include "src/externals/service_rng.h" #include "src/data_management/service_numeric_table.h" @@ -39,11 +39,10 @@ namespace internal using namespace daal::internal; template -class BatchImpl : public algorithms::engines::mrg32k3a::interface1::Batch, - public algorithms::engines::internal::BatchBaseImpl +class BatchImpl : public algorithms::engines::mrg32k3a::internal::Batch, public algorithms::engines::internal::BatchBaseImpl { public: - typedef algorithms::engines::mrg32k3a::interface1::Batch super1; + typedef algorithms::engines::mrg32k3a::internal::Batch super1; typedef algorithms::engines::internal::BatchBaseImpl super2; BatchImpl(size_t seed = 777) : baseRng(seed, __DAAL_BRNG_MRG32K3A), super2(seed) {} @@ -85,7 +84,7 @@ class BatchImpl : public algorithms::engines::mrg32k3a::interface1::Batch * cloneImpl() const override { return new BatchImpl(*this); } + EngineCloneReturnType * cloneImpl() const override { return new BatchImpl(*this); } bool hasSupport(engines::internal::ParallelizationTechnique technique) const override { diff --git a/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_dense_default_batch_fpt_dispatcher.cpp b/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_dense_default_batch_fpt_dispatcher.cpp index 61b7a891b8a..e275d05660f 100644 --- a/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_dense_default_batch_fpt_dispatcher.cpp +++ b/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_dense_default_batch_fpt_dispatcher.cpp @@ -30,7 +30,7 @@ namespace engines { namespace mrg32k3a { -namespace interface1 +namespace internal { template <> void Batch::initialize() @@ -40,7 +40,7 @@ void Batch::initialize() _result.reset(new ResultType()); } template <> -DAAL_EXPORT Batch::Batch(size_t seed) +Batch::Batch(size_t seed) { initialize(); } @@ -48,7 +48,7 @@ DAAL_EXPORT Batch::Batch(size_t se using BatchType = Batch; template <> -DAAL_EXPORT BatchType::Batch(const BatchType & other) : super(other) +BatchType::Batch(const BatchType & other) : super(other) { initialize(); } @@ -60,7 +60,7 @@ BatchType::~Batch() Analysis::_ac = NULL; } -} // namespace interface1 +} // namespace internal } // namespace mrg32k3a } // namespace engines } // namespace algorithms diff --git a/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_kernel.h b/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_kernel.h index 3eaabd82264..a189a583a7a 100644 --- a/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_kernel.h +++ b/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_kernel.h @@ -22,7 +22,7 @@ #ifndef __MRG32K3A_KERNEL_H__ #define __MRG32K3A_KERNEL_H__ -#include "algorithms/engines/mrg32k3a/mrg32k3a.h" +#include "src/algorithms/engines/mrg32k3a/mrg32k3a.h" #include "src/algorithms/kernel.h" #include "data_management/data/numeric_table.h" diff --git a/cpp/daal/include/algorithms/engines/mrg32k3a/mrg32k3a_types.h b/cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_types.h similarity index 100% rename from cpp/daal/include/algorithms/engines/mrg32k3a/mrg32k3a_types.h rename to cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_types.h diff --git a/cpp/daal/src/algorithms/engines/mt19937/mt19937.cpp b/cpp/daal/src/algorithms/engines/mt19937/mt19937.cpp index a84312da119..d7bb560729b 100644 --- a/cpp/daal/src/algorithms/engines/mt19937/mt19937.cpp +++ b/cpp/daal/src/algorithms/engines/mt19937/mt19937.cpp @@ -19,7 +19,7 @@ // Implementation of mt19937 engine //-- -#include "algorithms/engines/mt19937/mt19937.h" +#include "src/algorithms/engines/mt19937/mt19937.h" #include "src/externals/service_dispatch.h" #include "src/algorithms/engines/mt19937/mt19937_batch_impl.h" @@ -31,7 +31,7 @@ namespace engines { namespace mt19937 { -namespace interface1 +namespace internal { using namespace daal::services; using namespace mt19937::internal; @@ -49,10 +49,10 @@ SharedPtr > Batch::creat return engPtr; } -template SharedPtr > DAAL_EXPORT Batch::create(size_t seed); -template SharedPtr > DAAL_EXPORT Batch::create(size_t seed); +template SharedPtr > Batch::create(size_t seed); +template SharedPtr > Batch::create(size_t seed); -} // namespace interface1 +} // namespace internal } // namespace mt19937 } // namespace engines } // namespace algorithms diff --git a/cpp/daal/include/algorithms/engines/mt19937/mt19937.h b/cpp/daal/src/algorithms/engines/mt19937/mt19937.h similarity index 80% rename from cpp/daal/include/algorithms/engines/mt19937/mt19937.h rename to cpp/daal/src/algorithms/engines/mt19937/mt19937.h index 83d8da7e4f9..da6c3974d1c 100644 --- a/cpp/daal/include/algorithms/engines/mt19937/mt19937.h +++ b/cpp/daal/src/algorithms/engines/mt19937/mt19937.h @@ -24,8 +24,8 @@ #ifndef __MT19937_H__ #define __MT19937_H__ -#include "algorithms/engines/mt19937/mt19937_types.h" -#include "algorithms/engines/engine.h" +#include "src/algorithms/engines/mt19937/mt19937_types.h" +#include "src/algorithms/engines/engine_impl.h" namespace daal { @@ -40,7 +40,7 @@ namespace mt19937 * @ingroup engines_mt19937 * @{ */ -namespace interface1 +namespace internal { /** * @@ -53,13 +53,13 @@ namespace interface1 * - mt19937::Method Computation methods for the mt19937 engine * * \par References - * - \ref engines::interface1::Input "engines::Input" class - * - \ref engines::interface1::Result "engines::Result" class + * - \ref engines::internal::Input "engines::Input" class + * - \ref engines::internal::Result "engines::Result" class * * \DAAL_DEPRECATED */ template -class DAAL_EXPORT Batch : public engines::BatchBase +class Batch : public engines::BatchBase { public: typedef engines::BatchBase super; @@ -101,13 +101,6 @@ class DAAL_EXPORT Batch : public engines::BatchBase return services::Status(); } - /** - * Returns a pointer to the newly allocated mt19937 engine - * with a copy of input objects and parameters of this mt19937 engine - * \return Pointer to the newly allocated engine - */ - services::SharedPtr > clone() const { return services::SharedPtr >(cloneImpl()); } - /** * Allocates memory to store the result of the mt19937 engine * @@ -125,7 +118,7 @@ class DAAL_EXPORT Batch : public engines::BatchBase Batch(const Batch & other); - Batch * cloneImpl() const override { return new Batch(*this); } + EngineCloneReturnType * cloneImpl() const override { return new Batch(*this); } void initialize(); @@ -137,10 +130,10 @@ class DAAL_EXPORT Batch : public engines::BatchBase typedef services::SharedPtr > mt19937Ptr; typedef services::SharedPtr > mt19937ConstPtr; -} // namespace interface1 -using interface1::Batch; -using interface1::mt19937Ptr; -using interface1::mt19937ConstPtr; +} // namespace internal +using internal::Batch; +using internal::mt19937Ptr; +using internal::mt19937ConstPtr; /** @} */ } // namespace mt19937 } // namespace engines diff --git a/cpp/daal/src/algorithms/engines/mt19937/mt19937_batch_container.h b/cpp/daal/src/algorithms/engines/mt19937/mt19937_batch_container.h index 063b4765b04..a98403c8310 100644 --- a/cpp/daal/src/algorithms/engines/mt19937/mt19937_batch_container.h +++ b/cpp/daal/src/algorithms/engines/mt19937/mt19937_batch_container.h @@ -24,7 +24,7 @@ #ifndef __MT19937_BATCH_CONTAINER_H__ #define __MT19937_BATCH_CONTAINER_H__ -#include "algorithms/engines/mt19937/mt19937.h" +#include "src/algorithms/engines/mt19937/mt19937.h" #include "src/algorithms/algorithm_dispatch_container_batch.h" #include "src/algorithms/engines/mt19937/mt19937_kernel.h" @@ -41,7 +41,7 @@ namespace internal /** * * \brief Provides methods to run implementations of the mt19937 engine. - * This class is associated with the \ref mt19937::interface1::Batch "mt19937::Batch" class + * This class is associated with the \ref mt19937::internal::Batch "mt19937::Batch" class * and supports the method of mt19937 engine computation in the batch processing mode * * \tparam algorithmFPType Data type to use in intermediate computations of mt19937 engine, double or float diff --git a/cpp/daal/src/algorithms/engines/mt19937/mt19937_batch_impl.h b/cpp/daal/src/algorithms/engines/mt19937/mt19937_batch_impl.h index 49c447eef5e..6073ee15e4a 100644 --- a/cpp/daal/src/algorithms/engines/mt19937/mt19937_batch_impl.h +++ b/cpp/daal/src/algorithms/engines/mt19937/mt19937_batch_impl.h @@ -21,7 +21,7 @@ //-- */ -#include "algorithms/engines/mt19937/mt19937.h" +#include "src/algorithms/engines/mt19937/mt19937.h" #include "src/algorithms/engines/engine_batch_impl.h" #include "src/externals/service_rng.h" #include "src/data_management/service_numeric_table.h" @@ -39,10 +39,10 @@ namespace internal using namespace daal::internal; template -class BatchImpl : public algorithms::engines::mt19937::interface1::Batch, public algorithms::engines::internal::BatchBaseImpl +class BatchImpl : public algorithms::engines::mt19937::internal::Batch, public algorithms::engines::internal::BatchBaseImpl { public: - typedef algorithms::engines::mt19937::interface1::Batch super1; + typedef algorithms::engines::mt19937::internal::Batch super1; typedef algorithms::engines::internal::BatchBaseImpl super2; BatchImpl(size_t seed = 777) : baseRng(seed, __DAAL_BRNG_MT19937), super2(seed) {} @@ -84,7 +84,7 @@ class BatchImpl : public algorithms::engines::mt19937::interface1::Batch * cloneImpl() const override { return new BatchImpl(*this); } + EngineCloneReturnType * cloneImpl() const override { return new BatchImpl(*this); } bool hasSupport(engines::internal::ParallelizationTechnique technique) const override { diff --git a/cpp/daal/src/algorithms/engines/mt19937/mt19937_dense_default_batch_fpt_dispatcher.cpp b/cpp/daal/src/algorithms/engines/mt19937/mt19937_dense_default_batch_fpt_dispatcher.cpp index 186620be6ca..399e07c1306 100644 --- a/cpp/daal/src/algorithms/engines/mt19937/mt19937_dense_default_batch_fpt_dispatcher.cpp +++ b/cpp/daal/src/algorithms/engines/mt19937/mt19937_dense_default_batch_fpt_dispatcher.cpp @@ -30,7 +30,7 @@ namespace engines { namespace mt19937 { -namespace interface1 +namespace internal { template <> void Batch::initialize() @@ -40,7 +40,7 @@ void Batch::initialize() _result.reset(new ResultType()); } template <> -DAAL_EXPORT Batch::Batch(size_t seed) +Batch::Batch(size_t seed) { initialize(); } @@ -48,12 +48,12 @@ DAAL_EXPORT Batch::Batch(size_t see using BatchType = Batch; template <> -DAAL_EXPORT BatchType::Batch(const BatchType & other) : super(other) +BatchType::Batch(const BatchType & other) : super(other) { initialize(); } -} // namespace interface1 +} // namespace internal } // namespace mt19937 } // namespace engines } // namespace algorithms diff --git a/cpp/daal/src/algorithms/engines/mt19937/mt19937_kernel.h b/cpp/daal/src/algorithms/engines/mt19937/mt19937_kernel.h index aaef4dfe029..f7e7f2c2915 100644 --- a/cpp/daal/src/algorithms/engines/mt19937/mt19937_kernel.h +++ b/cpp/daal/src/algorithms/engines/mt19937/mt19937_kernel.h @@ -22,7 +22,7 @@ #ifndef __MT19937_KERNEL_H__ #define __MT19937_KERNEL_H__ -#include "algorithms/engines/mt19937/mt19937.h" +#include "src/algorithms/engines/mt19937/mt19937.h" #include "src/algorithms/kernel.h" #include "data_management/data/numeric_table.h" diff --git a/cpp/daal/include/algorithms/engines/mt19937/mt19937_types.h b/cpp/daal/src/algorithms/engines/mt19937/mt19937_types.h similarity index 100% rename from cpp/daal/include/algorithms/engines/mt19937/mt19937_types.h rename to cpp/daal/src/algorithms/engines/mt19937/mt19937_types.h diff --git a/cpp/daal/src/algorithms/engines/mt2203/mt2203.cpp b/cpp/daal/src/algorithms/engines/mt2203/mt2203.cpp index df5b887add0..dc69f1c8541 100644 --- a/cpp/daal/src/algorithms/engines/mt2203/mt2203.cpp +++ b/cpp/daal/src/algorithms/engines/mt2203/mt2203.cpp @@ -19,7 +19,7 @@ // Implementation of mt2203 engine //-- -#include "algorithms/engines/mt2203/mt2203.h" +#include "src/algorithms/engines/mt2203/mt2203.h" #include "src/externals/service_dispatch.h" #include "src/algorithms/engines/mt2203/mt2203_batch_impl.h" @@ -31,7 +31,7 @@ namespace engines { namespace mt2203 { -namespace interface1 +namespace internal { using namespace daal::services; using namespace mt2203::internal; @@ -49,10 +49,10 @@ SharedPtr > Batch::creat return engPtr; } -template SharedPtr > DAAL_EXPORT Batch::create(size_t seed, services::Status * st); -template SharedPtr > DAAL_EXPORT Batch::create(size_t seed, services::Status * st); +template SharedPtr > Batch::create(size_t seed, services::Status * st); +template SharedPtr > Batch::create(size_t seed, services::Status * st); -} // namespace interface1 +} // namespace internal } // namespace mt2203 } // namespace engines } // namespace algorithms diff --git a/cpp/daal/include/algorithms/engines/mt2203/mt2203.h b/cpp/daal/src/algorithms/engines/mt2203/mt2203.h similarity index 84% rename from cpp/daal/include/algorithms/engines/mt2203/mt2203.h rename to cpp/daal/src/algorithms/engines/mt2203/mt2203.h index 588573e4627..40162789b1d 100644 --- a/cpp/daal/include/algorithms/engines/mt2203/mt2203.h +++ b/cpp/daal/src/algorithms/engines/mt2203/mt2203.h @@ -24,8 +24,8 @@ #ifndef __MT2203_H__ #define __MT2203_H__ -#include "algorithms/engines/mt2203/mt2203_types.h" -#include "algorithms/engines/engine_family.h" +#include "src/algorithms/engines/mt2203/mt2203_types.h" +#include "src/algorithms/engines/engine_family.h" namespace daal { @@ -40,7 +40,7 @@ namespace mt2203 * @ingroup engines_mt2203 * @{ */ -namespace interface1 +namespace internal { /** * @@ -53,13 +53,13 @@ namespace interface1 * - mt2203::Method Computation methods for the mt2203 engine * * \par References - * - \ref engines::interface1::Input "engines::Input" class - * - \ref engines::interface1::Result "engines::Result" class + * - \ref engines::internal::Input "engines::Input" class + * - \ref engines::internal::Result "engines::Result" class * * \DAAL_DEPRECATED */ template -class DAAL_EXPORT Batch : public engines::FamilyBatchBase +class Batch : public engines::FamilyBatchBase { public: typedef engines::FamilyBatchBase super; @@ -107,8 +107,6 @@ class DAAL_EXPORT Batch : public engines::FamilyBatchBase * with a copy of input objects and parameters of this mt2203 engine * \return Pointer to the newly allocated engine */ - services::SharedPtr > clone() const { return services::SharedPtr >(cloneImpl()); } - /** * Allocates memory to store the result of the mt2203 engine * @@ -126,7 +124,7 @@ class DAAL_EXPORT Batch : public engines::FamilyBatchBase Batch(const Batch & other); - Batch * cloneImpl() const override { return new Batch(*this); } + EngineCloneReturnType * cloneImpl() const override { return new Batch(*this); } void initialize(); @@ -138,10 +136,10 @@ class DAAL_EXPORT Batch : public engines::FamilyBatchBase typedef services::SharedPtr > mt2203Ptr; typedef services::SharedPtr > mt2203ConstPtr; -} // namespace interface1 -using interface1::Batch; -using interface1::mt2203Ptr; -using interface1::mt2203ConstPtr; +} // namespace internal +using internal::Batch; +using internal::mt2203Ptr; +using internal::mt2203ConstPtr; /** @} */ } // namespace mt2203 } // namespace engines diff --git a/cpp/daal/src/algorithms/engines/mt2203/mt2203_batch_container.h b/cpp/daal/src/algorithms/engines/mt2203/mt2203_batch_container.h index 3f205d81f46..84c2482790a 100644 --- a/cpp/daal/src/algorithms/engines/mt2203/mt2203_batch_container.h +++ b/cpp/daal/src/algorithms/engines/mt2203/mt2203_batch_container.h @@ -24,7 +24,7 @@ #ifndef __MT2203_BATCH_CONTAINER_H__ #define __MT2203_BATCH_CONTAINER_H__ -#include "algorithms/engines/mt2203/mt2203.h" +#include "src/algorithms/engines/mt2203/mt2203.h" #include "src/algorithms/algorithm_dispatch_container_batch.h" #include "src/algorithms/engines/mt2203/mt2203_kernel.h" @@ -41,7 +41,7 @@ namespace internal /** * * \brief Provides methods to run implementations of the mt2203 engine. - * This class is associated with the \ref mt2203::interface1::Batch "mt2203::Batch" class + * This class is associated with the \ref mt2203::internal::Batch "mt2203::Batch" class * and supports the method of mt2203 engine computation in the batch processing mode * * \tparam algorithmFPType Data type to use in intermediate computations of mt2203 engine, double or float diff --git a/cpp/daal/src/algorithms/engines/mt2203/mt2203_batch_impl.h b/cpp/daal/src/algorithms/engines/mt2203/mt2203_batch_impl.h index ea434a0b4ff..fb534b1223a 100644 --- a/cpp/daal/src/algorithms/engines/mt2203/mt2203_batch_impl.h +++ b/cpp/daal/src/algorithms/engines/mt2203/mt2203_batch_impl.h @@ -21,7 +21,7 @@ //-- */ -#include "algorithms/engines/mt2203/mt2203.h" +#include "src/algorithms/engines/mt2203/mt2203.h" #include "src/algorithms/engines/engine_batch_impl.h" #include "src/externals/service_rng.h" #include "src/data_management/service_numeric_table.h" @@ -40,7 +40,7 @@ namespace internal using namespace daal::internal; template -class BatchImpl : public algorithms::engines::mt2203::interface1::Batch, public algorithms::engines::internal::BatchBaseImpl +class BatchImpl : public algorithms::engines::mt2203::internal::Batch, public algorithms::engines::internal::BatchBaseImpl { private: using BaseRNGsPtr = SharedPtr >; @@ -49,7 +49,7 @@ class BatchImpl : public algorithms::engines::mt2203::interface1::Batch super1; + typedef algorithms::engines::mt2203::internal::Batch super1; typedef algorithms::engines::internal::BatchBaseImpl super2; BatchImpl(size_t seed = 777, services::Status * st = nullptr) : super1(seed), super2(seed) @@ -147,7 +147,7 @@ class BatchImpl : public algorithms::engines::mt2203::interface1::Batch * cloneImpl() const override { return new BatchImpl(*this); } + EngineCloneReturnType * cloneImpl() const override { return new BatchImpl(*this); } size_t getNumberOfStreamsImpl() const override { return _streams.size(); } diff --git a/cpp/daal/src/algorithms/engines/mt2203/mt2203_dense_default_batch_fpt_dispatcher.cpp b/cpp/daal/src/algorithms/engines/mt2203/mt2203_dense_default_batch_fpt_dispatcher.cpp index 9154df12e10..3fdec3a1db9 100644 --- a/cpp/daal/src/algorithms/engines/mt2203/mt2203_dense_default_batch_fpt_dispatcher.cpp +++ b/cpp/daal/src/algorithms/engines/mt2203/mt2203_dense_default_batch_fpt_dispatcher.cpp @@ -30,7 +30,7 @@ namespace engines { namespace mt2203 { -namespace interface1 +namespace internal { template <> void Batch::initialize() @@ -40,7 +40,7 @@ void Batch::initialize() _result.reset(new ResultType()); } template <> -DAAL_EXPORT Batch::Batch(size_t seed) +Batch::Batch(size_t seed) { initialize(); } @@ -48,12 +48,12 @@ DAAL_EXPORT Batch::Batch(size_t seed using BatchType = Batch; template <> -DAAL_EXPORT BatchType::Batch(const BatchType & other) : super(other) +BatchType::Batch(const BatchType & other) : super(other) { initialize(); } -} // namespace interface1 +} // namespace internal } // namespace mt2203 } // namespace engines } // namespace algorithms diff --git a/cpp/daal/src/algorithms/engines/mt2203/mt2203_kernel.h b/cpp/daal/src/algorithms/engines/mt2203/mt2203_kernel.h index dbad1e97408..be7101a5dcf 100644 --- a/cpp/daal/src/algorithms/engines/mt2203/mt2203_kernel.h +++ b/cpp/daal/src/algorithms/engines/mt2203/mt2203_kernel.h @@ -22,7 +22,7 @@ #ifndef __MT2203_KERNEL_H__ #define __MT2203_KERNEL_H__ -#include "algorithms/engines/mt2203/mt2203.h" +#include "src/algorithms/engines/mt2203/mt2203.h" #include "src/algorithms/kernel.h" #include "data_management/data/numeric_table.h" diff --git a/cpp/daal/include/algorithms/engines/mt2203/mt2203_types.h b/cpp/daal/src/algorithms/engines/mt2203/mt2203_types.h similarity index 100% rename from cpp/daal/include/algorithms/engines/mt2203/mt2203_types.h rename to cpp/daal/src/algorithms/engines/mt2203/mt2203_types.h diff --git a/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10.cpp b/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10.cpp index 61c9c5cddb4..8ae6ca912dd 100644 --- a/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10.cpp +++ b/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10.cpp @@ -20,7 +20,7 @@ // that uses 4x32-bit keys and performs 10 rounds of mixing to produce high-quality randomness. //-- -#include "algorithms/engines/philox4x32x10/philox4x32x10.h" +#include "src/algorithms/engines/philox4x32x10/philox4x32x10.h" #include "src/externals/service_dispatch.h" #include "src/algorithms/engines/philox4x32x10/philox4x32x10_batch_impl.h" @@ -32,7 +32,7 @@ namespace engines { namespace philox4x32x10 { -namespace interface1 +namespace internal { using namespace daal::services; using namespace philox4x32x10::internal; @@ -49,10 +49,10 @@ SharedPtr > Batch::creat return engPtr; } -template SharedPtr > DAAL_EXPORT Batch::create(size_t seed); -template SharedPtr > DAAL_EXPORT Batch::create(size_t seed); +template SharedPtr > Batch::create(size_t seed); +template SharedPtr > Batch::create(size_t seed); -} // namespace interface1 +} // namespace internal } // namespace philox4x32x10 } // namespace engines } // namespace algorithms diff --git a/cpp/daal/include/algorithms/engines/philox4x32x10/philox4x32x10.h b/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10.h similarity index 85% rename from cpp/daal/include/algorithms/engines/philox4x32x10/philox4x32x10.h rename to cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10.h index 0f448f1e196..91c4eedc131 100644 --- a/cpp/daal/include/algorithms/engines/philox4x32x10/philox4x32x10.h +++ b/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10.h @@ -25,8 +25,8 @@ #ifndef __PHILOX4X32X10_H__ #define __PHILOX4X32X10_H__ -#include "algorithms/engines/philox4x32x10/philox4x32x10_types.h" -#include "algorithms/engines/engine.h" +#include "src/algorithms/engines/philox4x32x10/philox4x32x10_types.h" +#include "src/algorithms/engines/engine_impl.h" namespace daal { @@ -41,7 +41,7 @@ namespace philox4x32x10 * @ingroup engines_philox4x32x10 * @{ */ -namespace interface1 +namespace internal { /** * @@ -54,13 +54,13 @@ namespace interface1 * - philox4x32x10::Method Computation methods for the philox4x32x10 engine * * \par References - * - \ref engines::interface1::Input "engines::Input" class - * - \ref engines::interface1::Result "engines::Result" class + * - \ref engines::internal::Input "engines::Input" class + * - \ref engines::internal::Result "engines::Result" class * * \DAAL_DEPRECATED */ template -class DAAL_EXPORT Batch : public engines::BatchBase +class Batch : public engines::BatchBase { public: typedef engines::BatchBase super; @@ -107,8 +107,6 @@ class DAAL_EXPORT Batch : public engines::BatchBase * with a copy of input objects and parameters of this philox4x32x10 engine * \return Pointer to the newly allocated engine */ - services::SharedPtr > clone() const { return services::SharedPtr >(cloneImpl()); } - /** * Allocates memory to store the result of the philox4x32x10 engine * @@ -128,7 +126,7 @@ class DAAL_EXPORT Batch : public engines::BatchBase Batch(const Batch & other); - Batch * cloneImpl() const override { return new Batch(*this); } + EngineCloneReturnType * cloneImpl() const override { return new Batch(*this); } void initialize(); @@ -140,10 +138,10 @@ class DAAL_EXPORT Batch : public engines::BatchBase typedef services::SharedPtr > philox4x32x10Ptr; typedef services::SharedPtr > philox4x32x10ConstPtr; -} // namespace interface1 -using interface1::Batch; -using interface1::philox4x32x10Ptr; -using interface1::philox4x32x10ConstPtr; +} // namespace internal +using internal::Batch; +using internal::philox4x32x10Ptr; +using internal::philox4x32x10ConstPtr; /** @} */ } // namespace philox4x32x10 } // namespace engines diff --git a/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_batch_container.h b/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_batch_container.h index 7fc03b660cd..3a187dc9ac2 100644 --- a/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_batch_container.h +++ b/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_batch_container.h @@ -24,7 +24,7 @@ #ifndef __PHILOX4X32X10_BATCH_CONTAINER_H__ #define __PHILOX4X32X10_BATCH_CONTAINER_H__ -#include "algorithms/engines/philox4x32x10/philox4x32x10.h" +#include "src/algorithms/engines/philox4x32x10/philox4x32x10.h" #include "src/algorithms/algorithm_dispatch_container_batch.h" #include "src/algorithms/engines/philox4x32x10/philox4x32x10_kernel.h" @@ -41,7 +41,7 @@ namespace internal /** * * \brief Provides methods to run implementations of the philox4x32x10 engine. - * This class is associated with the \ref philox4x32x10::interface1::Batch "philox4x32x10::Batch" class + * This class is associated with the \ref philox4x32x10::internal::Batch "philox4x32x10::Batch" class * and supports the method of philox4x32x10 engine computation in the batch processing mode * * \tparam algorithmFPType Data type to use in intermediate computations of philox4x32x10 engine, double or float diff --git a/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_batch_impl.h b/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_batch_impl.h index 56c23081577..09a8e8cf73e 100644 --- a/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_batch_impl.h +++ b/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_batch_impl.h @@ -21,7 +21,7 @@ //-- */ -#include "algorithms/engines/philox4x32x10/philox4x32x10.h" +#include "src/algorithms/engines/philox4x32x10/philox4x32x10.h" #include "src/algorithms/engines/engine_batch_impl.h" #include "src/externals/service_rng.h" #include "src/data_management/service_numeric_table.h" @@ -39,11 +39,11 @@ namespace internal using namespace daal::internal; template -class BatchImpl : public algorithms::engines::philox4x32x10::interface1::Batch, +class BatchImpl : public algorithms::engines::philox4x32x10::internal::Batch, public algorithms::engines::internal::BatchBaseImpl { public: - typedef algorithms::engines::philox4x32x10::interface1::Batch super1; + typedef algorithms::engines::philox4x32x10::internal::Batch super1; typedef algorithms::engines::internal::BatchBaseImpl super2; BatchImpl(size_t seed = 777) : baseRng(seed, __DAAL_BRNG_PHILOX4X32X10), super2(seed) {} @@ -85,7 +85,7 @@ class BatchImpl : public algorithms::engines::philox4x32x10::interface1::Batch * cloneImpl() const override { return new BatchImpl(*this); } + EngineCloneReturnType * cloneImpl() const override { return new BatchImpl(*this); } bool hasSupport(engines::internal::ParallelizationTechnique technique) const override { diff --git a/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_dense_default_batch_fpt_dispatcher.cpp b/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_dense_default_batch_fpt_dispatcher.cpp index bd24d724cf6..7dcd7b70d36 100644 --- a/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_dense_default_batch_fpt_dispatcher.cpp +++ b/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_dense_default_batch_fpt_dispatcher.cpp @@ -30,7 +30,7 @@ namespace engines { namespace philox4x32x10 { -namespace interface1 +namespace internal { template <> void Batch::initialize() @@ -40,7 +40,7 @@ void Batch::initialize() _result.reset(new ResultType()); } template <> -DAAL_EXPORT Batch::Batch(size_t seed) +Batch::Batch(size_t seed) { initialize(); } @@ -48,7 +48,7 @@ DAAL_EXPORT Batch::Batch(size using BatchType = Batch; template <> -DAAL_EXPORT BatchType::Batch(const BatchType & other) : super(other) +BatchType::Batch(const BatchType & other) : super(other) { initialize(); } @@ -60,7 +60,7 @@ BatchType::~Batch() Analysis::_ac = NULL; } -} // namespace interface1 +} // namespace internal } // namespace philox4x32x10 } // namespace engines } // namespace algorithms diff --git a/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_kernel.h b/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_kernel.h index c5004838a77..aad8d43c438 100644 --- a/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_kernel.h +++ b/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_kernel.h @@ -22,7 +22,7 @@ #ifndef __PHILOX4X32X10_KERNEL_H__ #define __PHILOX4X32X10_KERNEL_H__ -#include "algorithms/engines/philox4x32x10/philox4x32x10.h" +#include "src/algorithms/engines/philox4x32x10/philox4x32x10.h" #include "src/algorithms/kernel.h" #include "data_management/data/numeric_table.h" diff --git a/cpp/daal/include/algorithms/engines/philox4x32x10/philox4x32x10_types.h b/cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_types.h similarity index 100% rename from cpp/daal/include/algorithms/engines/philox4x32x10/philox4x32x10_types.h rename to cpp/daal/src/algorithms/engines/philox4x32x10/philox4x32x10_types.h diff --git a/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_container.h b/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_container.h index 3963ce893e2..03f2eef02b0 100644 --- a/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_container.h +++ b/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_container.h @@ -161,7 +161,7 @@ services::Status BatchContainer::compute() daal::services::Environment::env & env = *_env; __DAAL_CALL_KERNEL(env, internal::ImplicitALSInitKernel, __DAAL_KERNEL_ARGUMENTS(algorithmFPType, method), compute, a, items, users, par, - *par->engine); + *services::dynamicPointerCast(par->engine)); } /** @@ -220,7 +220,8 @@ services::Status DistributedContainer: daal::services::Environment::env & env = *_env; __DAAL_CALL_KERNEL(env, internal::ImplicitALSInitDistrKernel, __DAAL_KERNEL_ARGUMENTS(algorithmFPType, method), compute, dataTable, - partitionTable, dataPartsPtr.get(), blocksToLocalPtr.get(), userOffsetsPtr.get(), result, par, *par->engine); + partitionTable, dataPartsPtr.get(), blocksToLocalPtr.get(), userOffsetsPtr.get(), result, par, + *services::dynamicPointerCast(par->engine)); } /** diff --git a/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_default_batch_impl.i b/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_default_batch_impl.i index cc6aa25356a..7319d1daa17 100644 --- a/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_default_batch_impl.i +++ b/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_default_batch_impl.i @@ -52,7 +52,7 @@ services::Status ImplicitALSInitKernelBase::randFactors(si TArray, cpu> engines(nBlocks - 1); for (size_t i = 0; i < nBlocks - 1; i++) { - engines[i] = engine.clone(); + engines[i] = services::dynamicPointerCast(engine.clone()); } daal::SafeStatus safeStatus; diff --git a/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_kernel.h b/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_kernel.h index 2fa0ebddbc7..fc06288ff9f 100644 --- a/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_kernel.h +++ b/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_kernel.h @@ -28,6 +28,7 @@ #include "algorithms/implicit_als/implicit_als_training_init_batch.h" #include "algorithms/implicit_als/implicit_als_model.h" #include "src/algorithms/kernel.h" +#include "src/algorithms/engines/engine_impl.h" namespace daal { diff --git a/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_result.cpp b/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_result.cpp index 59fb9f0e5bd..ca46eccbc00 100644 --- a/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_result.cpp +++ b/cpp/daal/src/algorithms/implicit_als/implicit_als_train_init_result.cpp @@ -42,7 +42,7 @@ namespace interface1 { __DAAL_REGISTER_SERIALIZATION_CLASS(Result, SERIALIZATION_IMPLICIT_ALS_TRAINING_INIT_RESULT_ID); Parameter::Parameter(size_t nFactors, size_t fullNUsers, size_t seed) - : nFactors(nFactors), fullNUsers(fullNUsers), seed(seed), engine(engines::mt19937::Batch<>::create()) + : nFactors(nFactors), fullNUsers(fullNUsers), seed(seed), engine(engines::createEngine(engines::mt19937Engine)) {} services::Status Parameter::check() const diff --git a/cpp/daal/src/algorithms/k_nearest_neighbors/bf_knn_classification_train_container.h b/cpp/daal/src/algorithms/k_nearest_neighbors/bf_knn_classification_train_container.h index 56cf34444a6..1f2153a094c 100644 --- a/cpp/daal/src/algorithms/k_nearest_neighbors/bf_knn_classification_train_container.h +++ b/cpp/daal/src/algorithms/k_nearest_neighbors/bf_knn_classification_train_container.h @@ -99,7 +99,7 @@ services::Status BatchContainer::compute() DAAL_CHECK_STATUS_VAR(status); __DAAL_CALL_KERNEL(env, internal::KNNClassificationTrainKernel, __DAAL_KERNEL_ARGUMENTS(algorithmFpType), compute, r->impl()->getData().get(), - r->impl()->getLabels().get(), r.get(), *par, *par->engine); + r->impl()->getLabels().get(), r.get(), *par, *services::dynamicPointerCast(par->engine)); } } // namespace internal diff --git a/cpp/daal/src/algorithms/k_nearest_neighbors/bf_knn_classification_train_kernel.h b/cpp/daal/src/algorithms/k_nearest_neighbors/bf_knn_classification_train_kernel.h index 767da3ca2b0..8b55a468d66 100755 --- a/cpp/daal/src/algorithms/k_nearest_neighbors/bf_knn_classification_train_kernel.h +++ b/cpp/daal/src/algorithms/k_nearest_neighbors/bf_knn_classification_train_kernel.h @@ -22,6 +22,7 @@ #include "src/algorithms/kernel.h" #include "algorithms/k_nearest_neighbors/bf_knn_classification_training_types.h" #include "src/algorithms/k_nearest_neighbors/bf_knn_classification_model_impl.h" +#include "src/algorithms/engines/engine_impl.h" namespace daal { diff --git a/cpp/daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_container.h b/cpp/daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_container.h index ddbbb958346..f5155c817cd 100755 --- a/cpp/daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_container.h +++ b/cpp/daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_container.h @@ -111,7 +111,7 @@ services::Status BatchContainer::compute() } __DAAL_CALL_KERNEL(env, internal::KNNClassificationTrainBatchKernel, __DAAL_KERNEL_ARGUMENTS(algorithmFpType, method), compute, - r->impl()->getData().get(), labelsPtr, r.get(), *par->engine); + r->impl()->getData().get(), labelsPtr, r.get(), *services::dynamicPointerCast(par->engine)); } } // namespace internal } // namespace training diff --git a/cpp/daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_dense_default_impl.i b/cpp/daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_dense_default_impl.i index 07e8f4de778..ff03f6e237a 100644 --- a/cpp/daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_dense_default_impl.i +++ b/cpp/daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_dense_default_impl.i @@ -1014,7 +1014,7 @@ Status KNNClassificationTrainBatchKernel(engine.clone()); DAAL_CHECK_THR(engineLocal, ErrorCloneMethodFailed); diff --git a/cpp/daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_kernel.h b/cpp/daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_kernel.h index 2d3a95d6203..ba95425359f 100755 --- a/cpp/daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_kernel.h +++ b/cpp/daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_kernel.h @@ -28,6 +28,7 @@ #include "algorithms/algorithm_base_common.h" #include "algorithms/k_nearest_neighbors/kdtree_knn_classification_training_types.h" #include "src/algorithms/service_error_handling.h" +#include "src/algorithms/engines/engine_impl.h" #if defined(_MSC_VER) #define DAAL_FORCEINLINE __forceinline diff --git a/cpp/daal/src/algorithms/kmeans/kmeans_init_container.h b/cpp/daal/src/algorithms/kmeans/kmeans_init_container.h index 7fa4b3993f2..0dd380d3e91 100644 --- a/cpp/daal/src/algorithms/kmeans/kmeans_init_container.h +++ b/cpp/daal/src/algorithms/kmeans/kmeans_init_container.h @@ -139,7 +139,8 @@ services::Status BatchContainer::compute() daal::services::Environment::env & env = *_env; - __DAAL_CALL_KERNEL(env, internal::KMeansInitKernel, __DAAL_KERNEL_ARGUMENTS(method, algorithmFPType), compute, na, a, nr, r, par, *par->engine); + __DAAL_CALL_KERNEL(env, internal::KMeansInitKernel, __DAAL_KERNEL_ARGUMENTS(method, algorithmFPType), compute, na, a, nr, r, par, + *services::dynamicPointerCast(par->engine)); } /** @@ -303,8 +304,9 @@ services::Status DistributedContainer: NumericTable * pNumPartialClusters = pRes->get(partialClustersNumber).get(); Parameter * par = static_cast(_par); daal::services::Environment::env & env = *_env; - services::Status s = __DAAL_CALL_KERNEL_STATUS(env, internal::KMeansInitStep1LocalKernel, __DAAL_KERNEL_ARGUMENTS(method, algorithmFPType), - compute, pData, par, pNumPartialClusters, pPartialClusters, *par->engine); + services::Status s = + __DAAL_CALL_KERNEL_STATUS(env, internal::KMeansInitStep1LocalKernel, __DAAL_KERNEL_ARGUMENTS(method, algorithmFPType), compute, pData, par, + pNumPartialClusters, pPartialClusters, *services::dynamicPointerCast(par->engine)); static_cast(_pres)->set(partialClusters, pPartialClusters); //can be null return s; } @@ -427,7 +429,8 @@ services::Status DistributedContainer DAAL_CHECK(pRngState, services::ErrorNullPtr); const Parameter * par = (const Parameter *)(_par); __DAAL_CALL_KERNEL(env, internal::KMeansInitStep3MasterKernel, __DAAL_KERNEL_ARGUMENTS(method, algorithmFPType), compute, par, - input->get(inputOfStep3FromStep2).get(), pRngState, pr->get(outputOfStep3ForStep4).get(), *par->engine); + input->get(inputOfStep3FromStep2).get(), pRngState, pr->get(outputOfStep3ForStep4).get(), + *services::dynamicPointerCast(par->engine)); } template @@ -507,7 +510,8 @@ services::Status DistributedContainer Result * pRes = static_cast(_res); DAAL_CHECK(pRngState, services::ErrorNullPtr); __DAAL_CALL_KERNEL(env, internal::KMeansInitStep5MasterKernel, __DAAL_KERNEL_ARGUMENTS(method, algorithmFPType), finalizeCompute, par, - ntCandidates, ntWeights, pRngState, pRes->get(centroids).get(), *par->engine); + ntCandidates, ntWeights, pRngState, pRes->get(centroids).get(), + *services::dynamicPointerCast(par->engine)); } } // namespace internal diff --git a/cpp/daal/src/algorithms/kmeans/kmeans_init_kernel.h b/cpp/daal/src/algorithms/kmeans/kmeans_init_kernel.h index 7eaee287091..25f0df2e514 100644 --- a/cpp/daal/src/algorithms/kmeans/kmeans_init_kernel.h +++ b/cpp/daal/src/algorithms/kmeans/kmeans_init_kernel.h @@ -29,6 +29,7 @@ #include "data_management/data/numeric_table.h" #include "data_management/data/memory_block.h" #include "services/daal_defines.h" +#include "src/algorithms/engines/engine_impl.h" namespace daal { diff --git a/cpp/daal/src/algorithms/kmeans/kmeans_init_parameter_types.cpp b/cpp/daal/src/algorithms/kmeans/kmeans_init_parameter_types.cpp index 68c28aca186..915cdb7c66c 100644 --- a/cpp/daal/src/algorithms/kmeans/kmeans_init_parameter_types.cpp +++ b/cpp/daal/src/algorithms/kmeans/kmeans_init_parameter_types.cpp @@ -45,7 +45,7 @@ Parameter::Parameter(size_t _nClusters, size_t _offset, size_t _seed) seed(_seed), oversamplingFactor(0.5), nRounds(5), - engine(engines::mt19937::Batch<>::create(_seed)) + engine(engines::createEngine(engines::mt19937Engine, _seed)) {} /** diff --git a/cpp/daal/src/algorithms/optimization_solver/coordinate_descent/coordinate_descent_batch_container.h b/cpp/daal/src/algorithms/optimization_solver/coordinate_descent/coordinate_descent_batch_container.h index b8beb0157bb..0723163fd4b 100644 --- a/cpp/daal/src/algorithms/optimization_solver/coordinate_descent/coordinate_descent_batch_container.h +++ b/cpp/daal/src/algorithms/optimization_solver/coordinate_descent/coordinate_descent_batch_container.h @@ -99,7 +99,7 @@ services::Status BatchContainer::compute() optimization_solver::objective_function::ResultPtr(new optimization_solver::objective_function::Result()); __DAAL_CALL_KERNEL(env, internal::CoordinateDescentKernel, __DAAL_KERNEL_ARGUMENTS(algorithmFPType, method), compute, inputArgument, minimum, - nIterations, parameter, *parameter->engine, hesGrResultPtr, proxResultPtr); + nIterations, parameter, *services::dynamicPointerCast(parameter->engine), hesGrResultPtr, proxResultPtr); } } // namespace internal diff --git a/cpp/daal/src/algorithms/optimization_solver/coordinate_descent/coordinate_descent_dense_default_kernel.h b/cpp/daal/src/algorithms/optimization_solver/coordinate_descent/coordinate_descent_dense_default_kernel.h index c99efa96771..00b665d744c 100644 --- a/cpp/daal/src/algorithms/optimization_solver/coordinate_descent/coordinate_descent_dense_default_kernel.h +++ b/cpp/daal/src/algorithms/optimization_solver/coordinate_descent/coordinate_descent_dense_default_kernel.h @@ -27,6 +27,7 @@ #include "data_management/data/numeric_table.h" #include "src/externals/service_math.h" #include "src/data_management/service_micro_table.h" +#include "src/algorithms/engines/engine_impl.h" using namespace daal::data_management; using namespace daal::internal; diff --git a/cpp/daal/src/algorithms/optimization_solver/coordinate_descent/coordinate_descent_types.cpp b/cpp/daal/src/algorithms/optimization_solver/coordinate_descent/coordinate_descent_types.cpp index 0bf3be3f9c8..82442a0330a 100644 --- a/cpp/daal/src/algorithms/optimization_solver/coordinate_descent/coordinate_descent_types.cpp +++ b/cpp/daal/src/algorithms/optimization_solver/coordinate_descent/coordinate_descent_types.cpp @@ -42,7 +42,7 @@ Parameter::Parameter(const sum_of_functions::BatchPtr & function, size_t nIterat optimization_solver::iterative_solver::Parameter(function, nIterations, accuracyThreshold, false, 1), seed(seed), - engine(engines::mt19937::Batch<>::create()), + engine(engines::createEngine(engines::mt19937Engine)), selection(cyclic), positive(false), skipTheFirstComponents(false) diff --git a/cpp/daal/src/algorithms/optimization_solver/iterative_solver_kernel.h b/cpp/daal/src/algorithms/optimization_solver/iterative_solver_kernel.h index acded9ea663..60926aff74b 100755 --- a/cpp/daal/src/algorithms/optimization_solver/iterative_solver_kernel.h +++ b/cpp/daal/src/algorithms/optimization_solver/iterative_solver_kernel.h @@ -32,6 +32,7 @@ #include "src/algorithms/distributions/uniform/uniform_kernel.h" #include "src/algorithms/distributions/uniform/uniform_impl.i" #include "src/services/service_data_utils.h" +#include "src/algorithms/engines/engine_impl.h" using namespace daal::data_management; using namespace daal::internal; diff --git a/cpp/daal/src/algorithms/optimization_solver/lbfgs/lbfgs_batch_container.h b/cpp/daal/src/algorithms/optimization_solver/lbfgs/lbfgs_batch_container.h index 56ce43609ba..cfa26f88ad2 100644 --- a/cpp/daal/src/algorithms/optimization_solver/lbfgs/lbfgs_batch_container.h +++ b/cpp/daal/src/algorithms/optimization_solver/lbfgs/lbfgs_batch_container.h @@ -101,7 +101,8 @@ services::Status BatchContainer::compute() __DAAL_CALL_KERNEL(env, internal::LBFGSKernel, __DAAL_KERNEL_ARGUMENTS(algorithmFPType, method), compute, correctionPairsInput, correctionIndicesInput, inputArgument, averageArgLIterInput, optionalArgumentInput, correctionPairsResult, - correctionIndicesResult, minimum, nIterations, averageArgLIterResult, optionalArgumentResult, parameter, *parameter->engine); + correctionIndicesResult, minimum, nIterations, averageArgLIterResult, optionalArgumentResult, parameter, + *services::dynamicPointerCast(parameter->engine)); } } // namespace internal diff --git a/cpp/daal/src/algorithms/optimization_solver/lbfgs/lbfgs_dense_default_kernel.h b/cpp/daal/src/algorithms/optimization_solver/lbfgs/lbfgs_dense_default_kernel.h index 17f7c96ef03..bd66a8871b5 100644 --- a/cpp/daal/src/algorithms/optimization_solver/lbfgs/lbfgs_dense_default_kernel.h +++ b/cpp/daal/src/algorithms/optimization_solver/lbfgs/lbfgs_dense_default_kernel.h @@ -23,6 +23,7 @@ #define __LBFGS_DENSE_DEFAULT_KERNEL_H__ #include "src/algorithms/optimization_solver/lbfgs/lbfgs_base.h" +#include "src/algorithms/engines/engine_impl.h" using namespace daal::data_management; diff --git a/cpp/daal/src/algorithms/optimization_solver/lbfgs/lbfgs_types.cpp b/cpp/daal/src/algorithms/optimization_solver/lbfgs/lbfgs_types.cpp index 8dcaae9f0db..6b4be1a6f32 100644 --- a/cpp/daal/src/algorithms/optimization_solver/lbfgs/lbfgs_types.cpp +++ b/cpp/daal/src/algorithms/optimization_solver/lbfgs/lbfgs_types.cpp @@ -49,7 +49,7 @@ Parameter::Parameter(sum_of_functions::BatchPtr function, size_t nIterations, do L(L), seed(seed), stepLengthSequence(HomogenNumericTable<>::create(1, 1, NumericTableIface::doAllocate, 1.0)), - engine(engines::mt19937::Batch<>::create()) + engine(engines::createEngine(engines::mt19937Engine)) {} services::Status Parameter::check() const diff --git a/cpp/oneapi/dal/algo/decision_forest/backend/cpu/train_kernel_cls.cpp b/cpp/oneapi/dal/algo/decision_forest/backend/cpu/train_kernel_cls.cpp index a2168f98772..6db35c2c27d 100644 --- a/cpp/oneapi/dal/algo/decision_forest/backend/cpu/train_kernel_cls.cpp +++ b/cpp/oneapi/dal/algo/decision_forest/backend/cpu/train_kernel_cls.cpp @@ -103,7 +103,9 @@ static result_t call_daal_kernel(const context_cpu& ctx, daal_parameter.minObservationsInLeafNode = dal::detail::integral_cast(desc.get_min_observations_in_leaf_node()); // TODO take engines from desc - daal_parameter.engine = daal::algorithms::engines::mt2203::Batch<>::create(desc.get_seed()); + daal_parameter.engine = + daal::algorithms::engines::createEngine(daal::algorithms::engines::mt2203Engine, + desc.get_seed()); daal_parameter.impurityThreshold = desc.get_impurity_threshold(); daal_parameter.memorySavingMode = desc.get_memory_saving_mode(); daal_parameter.bootstrap = desc.get_bootstrap(); diff --git a/cpp/oneapi/dal/algo/decision_forest/backend/cpu/train_kernel_reg.cpp b/cpp/oneapi/dal/algo/decision_forest/backend/cpu/train_kernel_reg.cpp index b2a88340641..d248a19d532 100644 --- a/cpp/oneapi/dal/algo/decision_forest/backend/cpu/train_kernel_reg.cpp +++ b/cpp/oneapi/dal/algo/decision_forest/backend/cpu/train_kernel_reg.cpp @@ -78,7 +78,9 @@ static result_t call_daal_kernel(const context_cpu& ctx, daal_parameter.minObservationsInLeafNode = dal::detail::integral_cast(desc.get_min_observations_in_leaf_node()); // TODO take engines from desc - daal_parameter.engine = daal::algorithms::engines::mt2203::Batch<>::create(desc.get_seed()); + daal_parameter.engine = + daal::algorithms::engines::createEngine(daal::algorithms::engines::mt2203Engine, + desc.get_seed()); daal_parameter.impurityThreshold = desc.get_impurity_threshold(); daal_parameter.memorySavingMode = desc.get_memory_saving_mode(); daal_parameter.bootstrap = desc.get_bootstrap(); diff --git a/cpp/oneapi/dal/algo/kmeans/detail/train_init_centroids.hpp b/cpp/oneapi/dal/algo/kmeans/detail/train_init_centroids.hpp index ca5a3e6c4c8..b13e7ce9b06 100644 --- a/cpp/oneapi/dal/algo/kmeans/detail/train_init_centroids.hpp +++ b/cpp/oneapi/dal/algo/kmeans/detail/train_init_centroids.hpp @@ -68,7 +68,13 @@ inline daal::data_management::NumericTablePtr daal_generate_centroids(const desc return init_kernel_t::value, Method>() - .compute(init_len_input, init_input, init_len_output, init_output, &par, *(par.engine)); + .compute(init_len_input, + init_input, + init_len_output, + init_output, + &par, + *daal::services::dynamicPointerCast( + par.engine)); })); return daal_initial_centroids; } diff --git a/cpp/oneapi/dal/algo/kmeans_init/backend/cpu/compute_kernel.cpp b/cpp/oneapi/dal/algo/kmeans_init/backend/cpu/compute_kernel.cpp index 821357f7cd0..73da307a032 100644 --- a/cpp/oneapi/dal/algo/kmeans_init/backend/cpu/compute_kernel.cpp +++ b/cpp/oneapi/dal/algo/kmeans_init/backend/cpu/compute_kernel.cpp @@ -74,7 +74,13 @@ static compute_result call_daal_kernel(const context_cpu& ctx, Float, oneapi::dal::backend::interop::to_daal_cpu_type::value, Method>() - .compute(len_input, input, len_output, output, &par, *(par.engine)); + .compute(len_input, + input, + len_output, + output, + &par, + *daal::services::dynamicPointerCast( + par.engine)); })); return compute_result().set_centroids( diff --git a/cpp/oneapi/dal/algo/knn/backend/cpu/train_kernel_brute_force.cpp b/cpp/oneapi/dal/algo/knn/backend/cpu/train_kernel_brute_force.cpp index ad16bf59da4..483b48b29d9 100644 --- a/cpp/oneapi/dal/algo/knn/backend/cpu/train_kernel_brute_force.cpp +++ b/cpp/oneapi/dal/algo/knn/backend/cpu/train_kernel_brute_force.cpp @@ -69,13 +69,14 @@ static train_result call_daal_kernel(const context_cpu& ctx, model_ptr->impl()->setLabels(daal_responses, false); } - interop::status_to_exception( - interop::call_daal_kernel(ctx, - daal_data.get(), - daal_responses.get(), - model_ptr.get(), - daal_parameter, - *daal_parameter.engine)); + interop::status_to_exception(interop::call_daal_kernel( + ctx, + daal_data.get(), + daal_responses.get(), + model_ptr.get(), + daal_parameter, + *daal::services::dynamicPointerCast( + daal_parameter.engine))); const auto model_impl = std::make_shared>(data, responses); return train_result().set_model(dal::detail::make_private(model_impl)); diff --git a/cpp/oneapi/dal/algo/knn/backend/cpu/train_kernel_kd_tree.cpp b/cpp/oneapi/dal/algo/knn/backend/cpu/train_kernel_kd_tree.cpp index bdfc1494a2b..a1883a4e88c 100644 --- a/cpp/oneapi/dal/algo/knn/backend/cpu/train_kernel_kd_tree.cpp +++ b/cpp/oneapi/dal/algo/knn/backend/cpu/train_kernel_kd_tree.cpp @@ -85,7 +85,8 @@ static train_result call_daal_kernel(const context_cpu& ctx, knn_model->impl()->getData().get(), knn_model->impl()->getLabels().get(), knn_model, - *daal_parameter.engine.get())); + *daal::services::dynamicPointerCast( + daal_parameter.engine))); const auto model_impl = std::make_shared>(new daal_model_interop_t(model_ptr)); diff --git a/cpp/oneapi/dal/backend/primitives/rng/device_engine.hpp b/cpp/oneapi/dal/backend/primitives/rng/device_engine.hpp index a49faaa3803..b87c5704684 100644 --- a/cpp/oneapi/dal/backend/primitives/rng/device_engine.hpp +++ b/cpp/oneapi/dal/backend/primitives/rng/device_engine.hpp @@ -21,11 +21,11 @@ #include "oneapi/dal/backend/primitives/rng/utils.hpp" #include "oneapi/dal/backend/primitives/rng/rng_types.hpp" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include @@ -244,23 +244,43 @@ class device_engine { : q(queue) { switch (method) { case engine_type_internal::mt2203: - host_engine_ = daal::algorithms::engines::mt2203::Batch<>::create(seed); + host_engine_ = + daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine( + daal::algorithms::engines::mt2203Engine, + seed)); dpc_engine_ = std::make_shared(queue, seed, idx); break; case engine_type_internal::mcg59: - host_engine_ = daal::algorithms::engines::mcg59::Batch<>::create(seed); + host_engine_ = + daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine( + daal::algorithms::engines::mcg59Engine, + seed)); dpc_engine_ = std::make_shared(queue, seed); break; case engine_type_internal::mrg32k3a: - host_engine_ = daal::algorithms::engines::mrg32k3a::Batch<>::create(seed); + host_engine_ = + daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine( + daal::algorithms::engines::mrg32k3aEngine, + seed)); dpc_engine_ = std::make_shared(queue, seed); break; case engine_type_internal::philox4x32x10: - host_engine_ = daal::algorithms::engines::philox4x32x10::Batch<>::create(seed); + host_engine_ = + daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine( + daal::algorithms::engines::philox4x32x10Engine, + seed)); dpc_engine_ = std::make_shared(queue, seed); break; case engine_type_internal::mt19937: - host_engine_ = daal::algorithms::engines::mt19937::Batch<>::create(seed); + host_engine_ = + daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine( + daal::algorithms::engines::mt19937Engine, + seed)); dpc_engine_ = std::make_shared(queue, seed); break; default: throw std::invalid_argument("Unsupported engine type 1"); diff --git a/cpp/oneapi/dal/backend/primitives/rng/host_engine.hpp b/cpp/oneapi/dal/backend/primitives/rng/host_engine.hpp index b4597c11746..bf4b19668cc 100644 --- a/cpp/oneapi/dal/backend/primitives/rng/host_engine.hpp +++ b/cpp/oneapi/dal/backend/primitives/rng/host_engine.hpp @@ -16,11 +16,11 @@ #pragma once -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "oneapi/dal/backend/primitives/ndarray.hpp" #include "oneapi/dal/backend/primitives/rng/utils.hpp" @@ -43,19 +43,39 @@ class host_engine { engine_type_internal method = engine_type_internal::mt2203) { switch (method) { case engine_type_internal::mt2203: - host_engine_ = daal::algorithms::engines::mt2203::Batch<>::create(seed); + host_engine_ = + daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine( + daal::algorithms::engines::mt2203Engine, + seed)); break; case engine_type_internal::mcg59: - host_engine_ = daal::algorithms::engines::mcg59::Batch<>::create(seed); + host_engine_ = + daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine( + daal::algorithms::engines::mcg59Engine, + seed)); break; case engine_type_internal::mrg32k3a: - host_engine_ = daal::algorithms::engines::mrg32k3a::Batch<>::create(seed); + host_engine_ = + daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine( + daal::algorithms::engines::mrg32k3aEngine, + seed)); break; case engine_type_internal::philox4x32x10: - host_engine_ = daal::algorithms::engines::philox4x32x10::Batch<>::create(seed); + host_engine_ = + daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine( + daal::algorithms::engines::philox4x32x10Engine, + seed)); break; case engine_type_internal::mt19937: - host_engine_ = daal::algorithms::engines::mt19937::Batch<>::create(seed); + host_engine_ = + daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine( + daal::algorithms::engines::mt19937Engine, + seed)); break; default: throw std::invalid_argument("Unsupported engine type 1"); } diff --git a/cpp/oneapi/dal/backend/primitives/rng/host_engine_collection.hpp b/cpp/oneapi/dal/backend/primitives/rng/host_engine_collection.hpp index 10b8f4fe4f5..2ef71a92445 100644 --- a/cpp/oneapi/dal/backend/primitives/rng/host_engine_collection.hpp +++ b/cpp/oneapi/dal/backend/primitives/rng/host_engine_collection.hpp @@ -61,15 +61,28 @@ class host_engine_collection { engine_type_internal method) { switch (method) { case engine_type_internal::mt2203: - return daal::algorithms::engines::mt2203::Batch<>::create(seed); + return daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine(daal::algorithms::engines::mt2203Engine, + seed)); case engine_type_internal::mcg59: - return daal::algorithms::engines::mcg59::Batch<>::create(seed); + return daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine(daal::algorithms::engines::mcg59Engine, + seed)); case engine_type_internal::mrg32k3a: - return daal::algorithms::engines::mrg32k3a::Batch<>::create(seed); + return daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine( + daal::algorithms::engines::mrg32k3aEngine, + seed)); case engine_type_internal::philox4x32x10: - return daal::algorithms::engines::philox4x32x10::Batch<>::create(seed); + return daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine( + daal::algorithms::engines::philox4x32x10Engine, + seed)); case engine_type_internal::mt19937: - return daal::algorithms::engines::mt19937::Batch<>::create(seed); + return daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine( + daal::algorithms::engines::mt19937Engine, + seed)); default: throw std::invalid_argument("Unsupported engine type"); } } diff --git a/cpp/oneapi/dal/backend/primitives/rng/rnd_seq.hpp b/cpp/oneapi/dal/backend/primitives/rng/rnd_seq.hpp index 836e579033f..ccd6622a587 100644 --- a/cpp/oneapi/dal/backend/primitives/rng/rnd_seq.hpp +++ b/cpp/oneapi/dal/backend/primitives/rng/rnd_seq.hpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include "oneapi/dal/array.hpp" @@ -50,7 +50,8 @@ class rnd_seq { private: void generate(sycl::queue& queue, Float a, Float b) { - auto engine = daal::algorithms::engines::mcg59::Batch<>::create(); + auto engine = daal::services::dynamicPointerCast( + daal::algorithms::engines::createEngine(daal::algorithms::engines::mcg59Engine)); auto engine_impl = dynamic_cast(&(*engine)); ONEDAL_ASSERT(engine_impl != nullptr); diff --git a/cpp/oneapi/dal/backend/primitives/selection/kselect_by_rows_quick.hpp b/cpp/oneapi/dal/backend/primitives/selection/kselect_by_rows_quick.hpp index 88dea31f419..6feb8fddb31 100644 --- a/cpp/oneapi/dal/backend/primitives/selection/kselect_by_rows_quick.hpp +++ b/cpp/oneapi/dal/backend/primitives/selection/kselect_by_rows_quick.hpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include "oneapi/dal/backend/primitives/selection/row_partitioning_kernel.hpp" diff --git a/docs/source/daal/algorithms/decision_forest/decision-forest.rst b/docs/source/daal/algorithms/decision_forest/decision-forest.rst index 25d53dd3a76..10d07095cf6 100644 --- a/docs/source/daal/algorithms/decision_forest/decision-forest.rst +++ b/docs/source/daal/algorithms/decision_forest/decision-forest.rst @@ -289,7 +289,7 @@ At the training stage, decision forest regression has the following parameters: - If true, the training set for a tree is a bootstrap of the whole training set. If false, the whole training set is used to build trees. * - ``engine`` - - ``SharePtr()>`` + - ``engines::createEngine(engines::mt2203Engine)`` - Pointer to the random number generator engine. The random numbers produced by this engine are used to choose the bootstrap set, diff --git a/docs/source/daal/algorithms/decision_tree/decision-tree-regression.rst b/docs/source/daal/algorithms/decision_tree/decision-tree-regression.rst index b1cd27fcc09..f0191e39ec4 100644 --- a/docs/source/daal/algorithms/decision_tree/decision-tree-regression.rst +++ b/docs/source/daal/algorithms/decision_tree/decision-tree-regression.rst @@ -122,7 +122,7 @@ parameters: Can be any number in the interval (0, 1). If pruning is not used, all observations are used to build the decision tree regardless of this parameter value. * - ``engine`` - - `SharedPtr >()` + - ``engines::createEngine(engines::mt19937Engine)`` - Pointer to the random number engine to be used for random sampling for reduced error post-pruning. Prediction diff --git a/examples/daal/cpp/source/decision_forest/df_cls_default_dense_batch.cpp b/examples/daal/cpp/source/decision_forest/df_cls_default_dense_batch.cpp index 9edc914261b..4cb040583d6 100644 --- a/examples/daal/cpp/source/decision_forest/df_cls_default_dense_batch.cpp +++ b/examples/daal/cpp/source/decision_forest/df_cls_default_dense_batch.cpp @@ -53,8 +53,9 @@ const double minImpurityDecreaseInSplitNode = 0.0; /* It must be greater than or const size_t nClasses = 5; /* Number of classes */ -training::ResultPtr trainModel(); -void testModel(const training::ResultPtr& res); +training::ResultPtr trainModel(const engines::EngineIfacePtr& engine, + const std::string& engineName); +void testModel(const training::ResultPtr& res, const std::string& engineName); int main(int argc, char* argv[]) { checkArguments(argc, @@ -65,23 +66,35 @@ int main(int argc, char* argv[]) { &testDatasetFileName, &testDatasetLabelFileName); - training::ResultPtr trainingResult = trainModel(); - testModel(trainingResult); + /* Train and test with different engines */ + const engines::EngineIfacePtr mt19937 = engines::createEngine(engines::mt19937Engine, 777); + training::ResultPtr result1 = trainModel(mt19937, "mt19937"); + testModel(result1, "mt19937"); + + const engines::EngineIfacePtr mt2203 = engines::createEngine(engines::mt2203Engine, 777); + training::ResultPtr result2 = trainModel(mt2203, "mt2203"); + testModel(result2, "mt2203"); + + const engines::EngineIfacePtr mcg59 = engines::createEngine(engines::mcg59Engine, 777); + training::ResultPtr result3 = trainModel(mcg59, "mcg59"); + testModel(result3, "mcg59"); + + const engines::EngineIfacePtr philox = engines::createEngine(engines::philox4x32x10Engine, 777); + training::ResultPtr result4 = trainModel(philox, "philox4x32x10"); + testModel(result4, "philox4x32x10"); return 0; } -training::ResultPtr trainModel() { +training::ResultPtr trainModel(const engines::EngineIfacePtr& engine, + const std::string& engineName) { /* Create Numeric Tables for training data and dependent variables */ - /* Initialize FileDataSource to retrieve the input data - * from a .csv file */ FileDataSource trainDataSource(trainDatasetFileName, DataSource::doAllocateNumericTable, DataSource::doDictionaryFromContext); FileDataSource trainLabelSource(trainDatasetLabelFileName, DataSource::doAllocateNumericTable, DataSource::doDictionaryFromContext); - /* Retrieve the data from the input file */ trainDataSource.loadDataBlock(); trainLabelSource.loadDataBlock(); @@ -101,26 +114,28 @@ training::ResultPtr trainModel() { algorithm.parameter().varImportance = algorithms::decision_forest::training::MDI; algorithm.parameter().resultsToCompute = algorithms::decision_forest::training::computeOutOfBagError; + algorithm.parameter().engine = engine->clone(); /* Build the decision forest classification model */ algorithm.compute(); /* Retrieve the algorithm results */ training::ResultPtr trainingResult = algorithm.getResult(); + + std::cout << "== Decision forest classification with " << engineName + << " engine ==" << std::endl; printNumericTable(trainingResult->get(training::variableImportance), "Variable importance results: "); printNumericTable(trainingResult->get(training::outOfBagError), "OOB error: "); return trainingResult; } -void testModel(const training::ResultPtr& trainingResult) { - /* Initialize FileDataSource to retrieve the test data from - * a .csv file */ +void testModel(const training::ResultPtr& trainingResult, const std::string& engineName) { FileDataSource testDataSource(testDatasetFileName, DataSource::doAllocateNumericTable, DataSource::doDictionaryFromContext); - testDataSource.loadDataBlock(); + FileDataSource testLabelSource(testDatasetLabelFileName, DataSource::doAllocateNumericTable, DataSource::doDictionaryFromContext); @@ -129,17 +144,17 @@ void testModel(const training::ResultPtr& trainingResult) { /* Create an algorithm object to predict values of decision forest classification */ prediction::Batch<> algorithm(nClasses); - /* Pass a testing data set and the trained model to the algorithm */ algorithm.input.set(classifier::prediction::data, testDataSource.getNumericTable()); algorithm.input.set(classifier::prediction::model, trainingResult->get(classifier::training::model)); algorithm.parameter().votingMethod = prediction::weighted; algorithm.parameter().resultsToEvaluate |= classifier::computeClassProbabilities; - /* Predict values of decision forest classification */ + algorithm.compute(); - /* Retrieve the algorithm results */ classifier::prediction::ResultPtr predictionResult = algorithm.getResult(); + + std::cout << "== Prediction with " << engineName << " engine ==" << std::endl; printNumericTable(predictionResult->get(classifier::prediction::prediction), "Decision forest prediction results (first 10 rows):", 10);