Skip to content

Commit

Permalink
Merge pull request #27 from oneapi-src/main
Browse files Browse the repository at this point in the history
Pull the changes from main branch
  • Loading branch information
Vika-F authored Jul 30, 2024
2 parents 5dae044 + b81e5ad commit 2cfc753
Show file tree
Hide file tree
Showing 32 changed files with 1,314 additions and 140 deletions.
4 changes: 2 additions & 2 deletions .ci/env/apt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function add_repo {
}

function install_dpcpp {
sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-2024.1
sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-2024.2
sudo bash -c 'echo libintelocl.so > /etc/OpenCL/vendors/intel-cpu.icd'
}

Expand Down Expand Up @@ -63,7 +63,7 @@ function install_qemu_emulation_apt {
}

function install_qemu_emulation_deb {
qemu_deb=qemu-user-static_8.2.1+ds-1~bpo12+1_amd64.deb
qemu_deb=qemu-user-static_9.0.1+ds-1~bpo12+1_amd64.deb
set -eo pipefail
wget http://ftp.debian.org/debian/pool/main/q/qemu/${qemu_deb}
sudo dpkg -i ${qemu_deb}
Expand Down
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Documentation owners and reviewers
/docs/ @Vika-F @maria-Petrova @Alexsandruss @aepanchi
*.md @Vika-F @maria-Petrova @Alexsandruss @aepanchi
/docs/ @Vika-F @maria-Petrova @Alexsandruss @bdmoore1
*.md @Vika-F @maria-Petrova @Alexsandruss @bdmoore1

# TTP files
third-party* @maria-Petrova
Expand All @@ -22,7 +22,7 @@ deploy/ @Alexsandruss @napetrov @homksei @ahuber21 @ethanglaser
dev/ @Alexsandruss @napetrov @homksei @ahuber21 @ethanglaser

# C++ code
cpp/ @Alexsandruss @samir-nasibli @KulikovNikita @Alexandr-Solovev
cpp/ @Alexsandruss @samir-nasibli @Alexandr-Solovev

# Tree based methods
dtrees @razdoburdin @ahuber21 @avolkov-intel @icfaust
2 changes: 1 addition & 1 deletion .github/workflows/openssf-scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif
Expand Down
10 changes: 5 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ micromkl_repo(
micromkl_dpc_repo(
name = "micromkl_dpc",
root_env_var = "MKLGPUFPKROOT",
url = "https://github.com/oneapi-src/oneDAL/releases/download/Dependencies/mklgpufpk_lnx_2024-02-20.tgz",
sha256 = "1c60914461aafa5e5512181c7d5c1fdbdeff83746dbd980fe97074a3b65fc1ed",
url = "https://github.com/oneapi-src/oneDAL/releases/download/Dependencies/mklgpufpk_lnx_20240605.tgz",
sha256 = "0787a92e9580ed6b9fb97d054a0ed77994dbc18b4b3fb099451cb1e6ebdf4f16",
)

load("@onedal//dev/bazel/deps:openblas.bzl", "openblas_repo")
Expand Down Expand Up @@ -115,8 +115,8 @@ http_archive(

http_archive(
name = "fmt",
url = "https://github.com/fmtlib/fmt/archive/11.0.1.tar.gz",
sha256 = "7d009f7f89ac84c0a83f79ed602463d092fbf66763766a907c97fd02b100f5e9",
strip_prefix = "fmt-11.0.1",
url = "https://github.com/fmtlib/fmt/archive/11.0.2.tar.gz",
sha256 = "6cb1e6d37bdcb756dbbe59be438790db409cdb4868c66e888d5df9f13f7c027f",
strip_prefix = "fmt-11.0.2",
build_file = "@onedal//dev/bazel/deps:fmt.tpl.BUILD",
)
2 changes: 1 addition & 1 deletion cpp/daal/include/algorithms/pca/pca_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ class DAAL_EXPORT BaseBatchParameter : public daal::algorithms::Parameter
BaseBatchParameter();

DAAL_UINT64 resultsToCompute; /*!< 64 bit integer flag that indicates the results to compute */
size_t nComponents; /*!< number of components for reduced implementation */
size_t nComponents; /*!< number of components for reduced implementation (applicable for batch mode only) */
bool isDeterministic; /*!< sign flip if required */
bool doScale; /*!< scaling if required */
bool isCorrelation; /*!< correlation is provided */
Expand Down
1 change: 1 addition & 0 deletions cpp/oneapi/dal/algo/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ALGOS = [
"cosine_distance",
"dbscan",
"decision_tree",
"finiteness_checker",
"jaccard",
"kmeans",
"kmeans_init",
Expand Down
61 changes: 61 additions & 0 deletions cpp/oneapi/dal/algo/finiteness_checker/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package(default_visibility = ["//visibility:public"])
load("@onedal//dev/bazel:dal.bzl",
"dal_module",
"dal_test_suite",
)

dal_module(
name = "finiteness_checker",
auto = True,
dal_deps = [
"@onedal//cpp/oneapi/dal:core",
"@onedal//cpp/oneapi/dal/backend/primitives:reduction",
],
extra_deps = [
"@onedal//cpp/daal:data_management",
]
)

dal_test_suite(
name = "cpu_tests",
private = True,
compile_as = [ "c++" ],
srcs = glob([
"backend/cpu/test/*.cpp",
]),
dal_deps = [
":finiteness_checker",
],
)

dal_test_suite(
name = "gpu_tests",
private = True,
compile_as = [ "dpc++" ],
srcs = glob([
"backend/gpu/test/*.cpp",
]),
dal_deps = [
":finiteness_checker",
],
)

dal_test_suite(
name = "interface_tests",
framework = "catch2",
srcs = glob([
"test/*.cpp",
]),
dal_deps = [
":finiteness_checker",
],
)

dal_test_suite(
name = "tests",
tests = [
":cpu_tests",
":gpu_tests",
":interface_tests",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*******************************************************************************
* 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.
*******************************************************************************/

#pragma once

#include "oneapi/dal/algo/finiteness_checker/compute_types.hpp"
#include "oneapi/dal/backend/dispatcher.hpp"
#include "oneapi/dal/table/homogen.hpp"

namespace oneapi::dal::finiteness_checker::backend {

template <typename Float, typename Method, typename Task>
struct compute_kernel_cpu {
compute_result<Task> operator()(const dal::backend::context_cpu& ctx,
const detail::descriptor_base<Task>& params,
const compute_input<Task>& input) const;

#ifdef ONEDAL_DATA_PARALLEL
void operator()(const dal::backend::context_cpu& ctx,
const detail::descriptor_base<Task>& params,
const table& data,
bool& res) const;
#endif
};

} // namespace oneapi::dal::finiteness_checker::backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*******************************************************************************
* 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.
*******************************************************************************/

#include <daal/include/data_management/data/internal/finiteness_checker.h>

#include "oneapi/dal/algo/finiteness_checker/backend/cpu/compute_kernel.hpp"
#include "oneapi/dal/backend/interop/common.hpp"
#include "oneapi/dal/backend/interop/error_converter.hpp"
#include "oneapi/dal/backend/interop/table_conversion.hpp"
#include "oneapi/dal/exceptions.hpp"

#include "oneapi/dal/table/row_accessor.hpp"

namespace oneapi::dal::finiteness_checker::backend {

using dal::backend::context_cpu;
using input_t = compute_input<task::compute>;
using result_t = compute_result<task::compute>;
using descriptor_t = detail::descriptor_base<task::compute>;

namespace interop = dal::backend::interop;

template <typename Float>
static result_t call_daal_kernel(const context_cpu& ctx,
const descriptor_t& desc,
const table& data) {
const auto daal_data = interop::convert_to_daal_table<Float>(data);

return result_t().set_finite(
daal::data_management::internal::allValuesAreFinite<Float>(*daal_data.get(),
desc.get_allow_NaN()));
}

template <typename Float>
static result_t compute(const context_cpu& ctx, const descriptor_t& desc, const input_t& input) {
return call_daal_kernel<Float>(ctx, desc, input.get_data());
}

template <typename Float>
struct compute_kernel_cpu<Float, method::dense, task::compute> {
result_t operator()(const context_cpu& ctx,
const descriptor_t& desc,
const input_t& input) const {
return compute<Float>(ctx, desc, input);
}

#ifdef ONEDAL_DATA_PARALLEL
void operator()(const context_cpu& ctx,
const descriptor_t& desc,
const table& data,
bool& res) const {
throw unimplemented(dal::detail::error_messages::method_not_implemented());
}
#endif
};

template struct compute_kernel_cpu<float, method::dense, task::compute>;
template struct compute_kernel_cpu<double, method::dense, task::compute>;

} // namespace oneapi::dal::finiteness_checker::backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*******************************************************************************
* 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.
*******************************************************************************/

#pragma once

#include "oneapi/dal/algo/finiteness_checker/compute_types.hpp"
#include "oneapi/dal/backend/dispatcher.hpp"
#include "oneapi/dal/table/homogen.hpp"

namespace oneapi::dal::finiteness_checker::backend {

template <typename Float, typename Method, typename Task>
struct compute_kernel_gpu {
compute_result<Task> operator()(const dal::backend::context_gpu& ctx,
const detail::descriptor_base<Task>& params,
const compute_input<Task>& input) const;

#ifdef ONEDAL_DATA_PARALLEL
void operator()(const dal::backend::context_gpu& ctx,
const detail::descriptor_base<Task>& params,
const table& data,
bool& res);
#endif
};

} // namespace oneapi::dal::finiteness_checker::backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*******************************************************************************
* 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.
*******************************************************************************/

#include "oneapi/dal/algo/finiteness_checker/backend/gpu/compute_kernel.hpp"
#include "oneapi/dal/backend/primitives/reduction.hpp"
#include "oneapi/dal/backend/primitives/utils.hpp"
#include "oneapi/dal/detail/profiler.hpp"

namespace oneapi::dal::finiteness_checker::backend {

using dal::backend::context_gpu;
using input_t = compute_input<task::compute>;
using result_t = compute_result<task::compute>;
using descriptor_t = detail::descriptor_base<task::compute>;

namespace pr = dal::backend::primitives;

template <typename Float>
bool compute_finiteness(sycl::queue& queue,
const pr::ndview<Float, 1>& data_1d,
bool allowNaN,
const dal::backend::event_vector& deps = {}) {
Float out;

if (allowNaN) {
ONEDAL_PROFILER_TASK(finiteness_checker.reduce, queue);
out = pr::reduce_1d(queue, data_1d, pr::logical_or<Float>{}, pr::isinf<Float>{}, deps);
}
else {
ONEDAL_PROFILER_TASK(finiteness_checker.reduce, queue);
out = pr::reduce_1d(queue, data_1d, pr::logical_or<Float>{}, pr::isinfornan<Float>{}, deps);
}
// invert out to match daal implementation (assert result is finite)
return !static_cast<bool>(out);
}

template <typename Float>
static result_t compute(const context_gpu& ctx, const descriptor_t& desc, const input_t& input) {
auto& queue = ctx.get_queue();
const auto data = input.get_data();
const auto data_1d = pr::table2ndarray_1d<Float>(queue, data, sycl::usm::alloc::device);
return result_t{}.set_finite(compute_finiteness(queue, data_1d, desc.get_allow_NaN()));
}

template <typename Float>
struct compute_kernel_gpu<Float, method::dense, task::compute> {
result_t operator()(const context_gpu& ctx,
const descriptor_t& desc,
const input_t& input) const {
return compute<Float>(ctx, desc, input);
}

#ifdef ONEDAL_DATA_PARALLEL
void operator()(const context_gpu& ctx,
const descriptor_t& desc,
const table& data,
bool& res) {
auto& queue = ctx.get_queue();
const auto data_1d = pr::table2ndarray_1d<Float>(queue, data, sycl::usm::alloc::device);
res = compute_finiteness(queue, data_1d, desc.get_allow_NaN());
}
#endif
};

template struct compute_kernel_gpu<float, method::dense, task::compute>;
template struct compute_kernel_gpu<double, method::dense, task::compute>;

} // namespace oneapi::dal::finiteness_checker::backend
Loading

0 comments on commit 2cfc753

Please sign in to comment.