From b87851662e5171d5ded7d491039cfb0d88d958be Mon Sep 17 00:00:00 2001 From: "romain.biessy" Date: Wed, 4 Dec 2024 09:46:34 +0000 Subject: [PATCH] Apply changes to rename to oneMath --- docs/domains/sparse_linear_algebra.rst | 8 +- .../sparse_blas_spmv_usm.cpp | 4 +- include/oneapi/math/detail/backends_table.hpp | 2 +- include/oneapi/math/sparse_blas.hpp | 3 + .../onemath_sparse_blas_rocsparse.hpp | 18 +-- .../detail/rocsparse/sparse_blas_ct.hpp | 18 +-- .../backends/common_launch_task.hpp | 83 ++++++------ .../backends/rocsparse/CMakeLists.txt | 20 +-- .../rocsparse/operations/rocsparse_spmm.cpp | 112 ++++++++-------- .../rocsparse/operations/rocsparse_spmv.cpp | 122 +++++++++--------- .../rocsparse/operations/rocsparse_spsv.cpp | 106 +++++++-------- .../backends/rocsparse/rocsparse_error.hpp | 116 ++++++++--------- .../rocsparse/rocsparse_global_handle.hpp | 10 +- .../backends/rocsparse/rocsparse_handles.cpp | 28 ++-- .../backends/rocsparse/rocsparse_handles.hpp | 20 +-- .../backends/rocsparse/rocsparse_helper.hpp | 42 +++--- .../rocsparse/rocsparse_scope_handle.cpp | 8 +- .../rocsparse/rocsparse_scope_handle.hpp | 16 +-- .../backends/rocsparse/rocsparse_task.hpp | 10 +- .../backends/rocsparse/rocsparse_wrappers.cpp | 6 +- tests/unit_tests/CMakeLists.txt | 4 +- tests/unit_tests/include/test_helper.hpp | 4 +- tests/unit_tests/main_test.cpp | 3 +- 23 files changed, 386 insertions(+), 377 deletions(-) diff --git a/docs/domains/sparse_linear_algebra.rst b/docs/domains/sparse_linear_algebra.rst index 10e82a403..0af792a3e 100644 --- a/docs/domains/sparse_linear_algebra.rst +++ b/docs/domains/sparse_linear_algebra.rst @@ -74,22 +74,22 @@ rocSPARSE backend Currently known limitations: - Using ``spmv`` with a ``type_view`` other than ``matrix_descr::general`` will - throw a ``oneapi::mkl::unimplemented`` exception. + throw a ``oneapi::math::unimplemented`` exception. - The COO format requires the indices to be sorted by row then by column. See the `rocSPARSE COO documentation `_. Sparse operations using matrices with the COO format without the property - ``matrix_property::sorted`` will throw a ``oneapi::mkl::unimplemented`` + ``matrix_property::sorted`` will throw a ``oneapi::math::unimplemented`` exception. - The CSR format requires the column indices to be sorted within each row. See the `rocSPARSE CSR documentation `_. Sparse operations using matrices with the CSR format without the property - ``matrix_property::sorted`` will throw a ``oneapi::mkl::unimplemented`` + ``matrix_property::sorted`` will throw a ``oneapi::math::unimplemented`` exception. - The same sparse matrix handle cannot be reused for multiple operations ``spmm``, ``spmv``, or ``spsv``. Doing so will throw a - ``oneapi::mkl::unimplemented`` exception. See `#332 + ``oneapi::math::unimplemented`` exception. See `#332 `_. diff --git a/examples/sparse_blas/run_time_dispatching/sparse_blas_spmv_usm.cpp b/examples/sparse_blas/run_time_dispatching/sparse_blas_spmv_usm.cpp index 255d877e2..5dbee489e 100644 --- a/examples/sparse_blas/run_time_dispatching/sparse_blas_spmv_usm.cpp +++ b/examples/sparse_blas/run_time_dispatching/sparse_blas_spmv_usm.cpp @@ -148,8 +148,8 @@ int run_sparse_matrix_vector_multiply_example(const sycl::device& dev) { // rocSPARSE backend requires that the property sorted is set when using matrices in CSR format. // Setting this property is also the best practice to get best performance. - oneapi::mkl::sparse::set_matrix_property(main_queue, A_handle, - oneapi::mkl::sparse::matrix_property::sorted); + oneapi::math::sparse::set_matrix_property(main_queue, A_handle, + oneapi::math::sparse::matrix_property::sorted); // Create and initialize dense vector handles oneapi::math::sparse::dense_vector_handle_t x_handle = nullptr; diff --git a/include/oneapi/math/detail/backends_table.hpp b/include/oneapi/math/detail/backends_table.hpp index c79e6b55c..3e83b070f 100644 --- a/include/oneapi/math/detail/backends_table.hpp +++ b/include/oneapi/math/detail/backends_table.hpp @@ -208,7 +208,7 @@ static std::map>> libraries = } }, { device::amdgpu, { -#ifdef ONEMKL_ENABLE_ROCSPARSE_BACKEND +#ifdef ONEMATH_ENABLE_ROCSPARSE_BACKEND LIB_NAME("sparse_blas_rocsparse") #endif } } } }, diff --git a/include/oneapi/math/sparse_blas.hpp b/include/oneapi/math/sparse_blas.hpp index ee9735374..59a203070 100644 --- a/include/oneapi/math/sparse_blas.hpp +++ b/include/oneapi/math/sparse_blas.hpp @@ -37,6 +37,9 @@ #ifdef ONEMATH_ENABLE_CUSPARSE_BACKEND #include "sparse_blas/detail/cusparse/sparse_blas_ct.hpp" #endif +#ifdef ONEMATH_ENABLE_ROCSPARSE_BACKEND +#include "sparse_blas/detail/rocsparse/sparse_blas_ct.hpp" +#endif #include "sparse_blas/detail/sparse_blas_rt.hpp" diff --git a/include/oneapi/math/sparse_blas/detail/rocsparse/onemath_sparse_blas_rocsparse.hpp b/include/oneapi/math/sparse_blas/detail/rocsparse/onemath_sparse_blas_rocsparse.hpp index 951978921..2e727996a 100644 --- a/include/oneapi/math/sparse_blas/detail/rocsparse/onemath_sparse_blas_rocsparse.hpp +++ b/include/oneapi/math/sparse_blas/detail/rocsparse/onemath_sparse_blas_rocsparse.hpp @@ -17,17 +17,17 @@ * **************************************************************************/ -#ifndef _ONEMKL_SPARSE_BLAS_DETAIL_ROCSPARSE_ONEMKL_SPARSE_BLAS_ROCSPARSE_HPP_ -#define _ONEMKL_SPARSE_BLAS_DETAIL_ROCSPARSE_ONEMKL_SPARSE_BLAS_ROCSPARSE_HPP_ +#ifndef _ONEMATH_SPARSE_BLAS_DETAIL_ROCSPARSE_ONEMATH_SPARSE_BLAS_ROCSPARSE_HPP_ +#define _ONEMATH_SPARSE_BLAS_DETAIL_ROCSPARSE_ONEMATH_SPARSE_BLAS_ROCSPARSE_HPP_ -#include "oneapi/mkl/detail/export.hpp" -#include "oneapi/mkl/sparse_blas/detail/helper_types.hpp" -#include "oneapi/mkl/sparse_blas/types.hpp" +#include "oneapi/math/detail/export.hpp" +#include "oneapi/math/sparse_blas/detail/helper_types.hpp" +#include "oneapi/math/sparse_blas/types.hpp" -namespace oneapi::mkl::sparse::rocsparse { +namespace oneapi::math::sparse::rocsparse { -#include "oneapi/mkl/sparse_blas/detail/onemkl_sparse_blas_backends.hxx" +#include "oneapi/math/sparse_blas/detail/onemath_sparse_blas_backends.hxx" -} // namespace oneapi::mkl::sparse::rocsparse +} // namespace oneapi::math::sparse::rocsparse -#endif // _ONEMKL_SPARSE_BLAS_DETAIL_ROCSPARSE_ONEMKL_SPARSE_BLAS_ROCSPARSE_HPP_ +#endif // _ONEMATH_SPARSE_BLAS_DETAIL_ROCSPARSE_ONEMATH_SPARSE_BLAS_ROCSPARSE_HPP_ diff --git a/include/oneapi/math/sparse_blas/detail/rocsparse/sparse_blas_ct.hpp b/include/oneapi/math/sparse_blas/detail/rocsparse/sparse_blas_ct.hpp index 645230fa6..fbf7d46aa 100644 --- a/include/oneapi/math/sparse_blas/detail/rocsparse/sparse_blas_ct.hpp +++ b/include/oneapi/math/sparse_blas/detail/rocsparse/sparse_blas_ct.hpp @@ -17,24 +17,24 @@ * **************************************************************************/ -#ifndef _ONEMKL_SPARSE_BLAS_DETAIL_ROCSPARSE_SPARSE_BLAS_CT_HPP_ -#define _ONEMKL_SPARSE_BLAS_DETAIL_ROCSPARSE_SPARSE_BLAS_CT_HPP_ +#ifndef _ONEMATH_SPARSE_BLAS_DETAIL_ROCSPARSE_SPARSE_BLAS_CT_HPP_ +#define _ONEMATH_SPARSE_BLAS_DETAIL_ROCSPARSE_SPARSE_BLAS_CT_HPP_ -#include "oneapi/mkl/detail/backends.hpp" -#include "oneapi/mkl/detail/backend_selector.hpp" +#include "oneapi/math/detail/backends.hpp" +#include "oneapi/math/detail/backend_selector.hpp" -#include "onemkl_sparse_blas_rocsparse.hpp" +#include "onemath_sparse_blas_rocsparse.hpp" namespace oneapi { -namespace mkl { +namespace math { namespace sparse { #define BACKEND rocsparse -#include "oneapi/mkl/sparse_blas/detail/sparse_blas_ct.hxx" +#include "oneapi/math/sparse_blas/detail/sparse_blas_ct.hxx" #undef BACKEND } //namespace sparse -} //namespace mkl +} //namespace math } //namespace oneapi -#endif // _ONEMKL_SPARSE_BLAS_DETAIL_ROCSPARSE_SPARSE_BLAS_CT_HPP_ +#endif // _ONEMATH_SPARSE_BLAS_DETAIL_ROCSPARSE_SPARSE_BLAS_CT_HPP_ diff --git a/src/sparse_blas/backends/common_launch_task.hpp b/src/sparse_blas/backends/common_launch_task.hpp index df245775a..fbd5fa200 100644 --- a/src/sparse_blas/backends/common_launch_task.hpp +++ b/src/sparse_blas/backends/common_launch_task.hpp @@ -17,12 +17,12 @@ * **************************************************************************/ -#ifndef _ONEMKL_SPARSE_BLAS_BACKENDS_COMMON_LAUNCH_TASK_HPP_ -#define _ONEMKL_SPARSE_BLAS_BACKENDS_COMMON_LAUNCH_TASK_HPP_ +#ifndef _ONEMATH_SPARSE_BLAS_BACKENDS_COMMON_LAUNCH_TASK_HPP_ +#define _ONEMATH_SPARSE_BLAS_BACKENDS_COMMON_LAUNCH_TASK_HPP_ /// This file provide a helper function to submit host_task using buffers or USM seamlessly -namespace oneapi::mkl::sparse::detail { +namespace oneapi::math::sparse::detail { template auto get_value_accessor(sycl::handler& cgh, Container container) { @@ -114,8 +114,8 @@ void submit_native_command_ext(sycl::handler& cgh, sycl::queue& queue, Functor f // extension ext_codeplay_enqueue_native_command is used to launch // the compute operation which depends on the previous optimize // step. In cuSPARSE the optimize step is synchronous but it is - // asynchronous in oneMKL Interface. The optimize step may not use - // the CUDA stream which would make it impossible for + // asynchronous in oneMath. The optimize step may not use the CUDA + // stream which would make it impossible for // ext_codeplay_enqueue_native_command to automatically ensure it // has completed before the compute function starts. These waits are // used to ensure the optimize step has completed before starting @@ -149,16 +149,15 @@ void submit_native_command_ext_with_acc(sycl::handler& cgh, sycl::queue& queue, auto unused = std::make_tuple(capture_only_accessors...); (void)unused; // The functor using ext_codeplay_enqueue_native_command need to - // explicitly wait on the events for the SPARSE domain. The - // extension ext_codeplay_enqueue_native_command is used to launch - // the compute operation which depends on the previous optimize - // step. In cuSPARSE the optimize step is synchronous but it is - // asynchronous in oneMKL Interface. The optimize step may not use - // the CUDA stream which would make it impossible for - // ext_codeplay_enqueue_native_command to automatically ensure it - // has completed before the compute function starts. These waits are - // used to ensure the optimize step has completed before starting - // the computation. + // explicitly wait on the events for the SPARSE domain. The extension + // ext_codeplay_enqueue_native_command is used to launch the compute + // operation which depends on the previous optimize step. In cuSPARSE + // the optimize step is synchronous but it is asynchronous in oneMath. + // The optimize step may not use the CUDA stream which would make it + // impossible for ext_codeplay_enqueue_native_command to automatically + // ensure it has completed before the compute function starts. These + // waits are used to ensure the optimize step has completed before + // starting the computation. for (auto event : dependencies) { event.wait(); } @@ -196,7 +195,7 @@ sycl::event dispatch_submit_impl_fp_int(const std::string& function_name, sycl:: data_type value_type = sm_handle->get_value_type(); data_type int_type = sm_handle->get_int_type(); -#define ONEMKL_SUBMIT(FP_TYPE, INT_TYPE) \ +#define ONEMATH_SUBMIT(FP_TYPE, INT_TYPE) \ return queue.submit([&](sycl::handler& cgh) { \ cgh.depends_on(dependencies); \ auto fp_accs = get_fp_accessors(cgh, sm_handle, other_containers...); \ @@ -233,32 +232,32 @@ sycl::event dispatch_submit_impl_fp_int(const std::string& function_name, sycl:: } \ } \ }) -#define ONEMKL_SUBMIT_INT(FP_TYPE) \ - if (int_type == data_type::int32) { \ - ONEMKL_SUBMIT(FP_TYPE, std::int32_t); \ - } \ - else if (int_type == data_type::int64) { \ - ONEMKL_SUBMIT(FP_TYPE, std::int64_t); \ +#define ONEMATH_SUBMIT_INT(FP_TYPE) \ + if (int_type == data_type::int32) { \ + ONEMATH_SUBMIT(FP_TYPE, std::int32_t); \ + } \ + else if (int_type == data_type::int64) { \ + ONEMATH_SUBMIT(FP_TYPE, std::int64_t); \ } if (value_type == data_type::real_fp32) { - ONEMKL_SUBMIT_INT(float) + ONEMATH_SUBMIT_INT(float) } else if (value_type == data_type::real_fp64) { - ONEMKL_SUBMIT_INT(double) + ONEMATH_SUBMIT_INT(double) } else if (value_type == data_type::complex_fp32) { - ONEMKL_SUBMIT_INT(std::complex) + ONEMATH_SUBMIT_INT(std::complex) } else if (value_type == data_type::complex_fp64) { - ONEMKL_SUBMIT_INT(std::complex) + ONEMATH_SUBMIT_INT(std::complex) } -#undef ONEMKL_SUBMIT_INT -#undef ONEMKL_SUBMIT +#undef ONEMATH_SUBMIT_INT +#undef ONEMATH_SUBMIT - throw oneapi::mkl::exception("sparse_blas", function_name, - "Could not dispatch buffer kernel to a supported type"); + throw oneapi::math::exception("sparse_blas", function_name, + "Could not dispatch buffer kernel to a supported type"); } else { // USM submit does not need to capture accessors @@ -279,8 +278,8 @@ sycl::event dispatch_submit_impl_fp_int(const std::string& function_name, sycl:: }); } else { - throw oneapi::mkl::exception("sparse_blas", function_name, - "Internal error: Cannot use accessor workspace with USM"); + throw oneapi::math::exception("sparse_blas", function_name, + "Internal error: Cannot use accessor workspace with USM"); } } } @@ -293,7 +292,7 @@ sycl::event dispatch_submit_impl_fp(const std::string& function_name, sycl::queu if (container_handle->all_use_buffer()) { data_type value_type = container_handle->get_value_type(); -#define ONEMKL_SUBMIT(FP_TYPE) \ +#define ONEMATH_SUBMIT(FP_TYPE) \ return queue.submit([&](sycl::handler& cgh) { \ cgh.depends_on(dependencies); \ auto fp_accs = get_fp_accessors(cgh, container_handle); \ @@ -301,22 +300,22 @@ sycl::event dispatch_submit_impl_fp(const std::string& function_name, sycl::queu }) if (value_type == data_type::real_fp32) { - ONEMKL_SUBMIT(float); + ONEMATH_SUBMIT(float); } else if (value_type == data_type::real_fp64) { - ONEMKL_SUBMIT(double); + ONEMATH_SUBMIT(double); } else if (value_type == data_type::complex_fp32) { - ONEMKL_SUBMIT(std::complex); + ONEMATH_SUBMIT(std::complex); } else if (value_type == data_type::complex_fp64) { - ONEMKL_SUBMIT(std::complex); + ONEMATH_SUBMIT(std::complex); } -#undef ONEMKL_SUBMIT +#undef ONEMATH_SUBMIT - throw oneapi::mkl::exception("sparse_blas", function_name, - "Could not dispatch buffer kernel to a supported type"); + throw oneapi::math::exception("sparse_blas", function_name, + "Could not dispatch buffer kernel to a supported type"); } else { return queue.submit([&](sycl::handler& cgh) { @@ -409,6 +408,6 @@ sycl::event dispatch_submit_native_ext(const std::string& function_name, sycl::q function_name, queue, {}, functor, sm_handle, no_workspace, other_containers...); } -} // namespace oneapi::mkl::sparse::detail +} // namespace oneapi::math::sparse::detail -#endif // _ONEMKL_SPARSE_BLAS_BACKENDS_COMMON_LAUNCH_TASK_HPP_ +#endif // _ONEMATH_SPARSE_BLAS_BACKENDS_COMMON_LAUNCH_TASK_HPP_ diff --git a/src/sparse_blas/backends/rocsparse/CMakeLists.txt b/src/sparse_blas/backends/rocsparse/CMakeLists.txt index af26b50eb..841614550 100644 --- a/src/sparse_blas/backends/rocsparse/CMakeLists.txt +++ b/src/sparse_blas/backends/rocsparse/CMakeLists.txt @@ -17,7 +17,7 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== -set(LIB_NAME onemkl_sparse_blas_rocsparse) +set(LIB_NAME onemath_sparse_blas_rocsparse) set(LIB_OBJ ${LIB_NAME}_obj) include(WarningsUtils) @@ -31,16 +31,16 @@ add_library(${LIB_OBJ} OBJECT operations/rocsparse_spsv.cpp $<$: rocsparse_wrappers.cpp> ) -add_dependencies(onemkl_backend_libs_sparse_blas ${LIB_NAME}) +add_dependencies(onemath_backend_libs_sparse_blas ${LIB_NAME}) target_include_directories(${LIB_OBJ} PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/bin - ${ONEMKL_GENERATED_INCLUDE_PATH} + ${ONEMATH_GENERATED_INCLUDE_PATH} ) -target_compile_options(${LIB_OBJ} PRIVATE ${ONEMKL_BUILD_COPT}) +target_compile_options(${LIB_OBJ} PRIVATE ${ONEMATH_BUILD_COPT}) find_package(HIP REQUIRED) find_package(rocsparse REQUIRED) @@ -48,8 +48,8 @@ find_package(rocsparse REQUIRED) target_link_libraries(${LIB_OBJ} PRIVATE hip::host roc::rocsparse) target_link_libraries(${LIB_OBJ} - PUBLIC ONEMKL::SYCL::SYCL - PRIVATE onemkl_warnings + PUBLIC ONEMATH::SYCL::SYCL + PRIVATE onemath_warnings ) set_target_properties(${LIB_OBJ} PROPERTIES @@ -57,10 +57,10 @@ set_target_properties(${LIB_OBJ} PROPERTIES ) target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ}) -#Set oneMKL libraries as not transitive for dynamic +#Set oneMATH libraries as not transitive for dynamic if(BUILD_SHARED_LIBS) set_target_properties(${LIB_NAME} PROPERTIES - INTERFACE_LINK_LIBRARIES ONEMKL::SYCL::SYCL + INTERFACE_LINK_LIBRARIES ONEMATH::SYCL::SYCL ) endif() @@ -73,8 +73,8 @@ set_target_properties(${LIB_NAME} PROPERTIES list(APPEND CMAKE_BUILD_RPATH $) # Add the library to install package -install(TARGETS ${LIB_OBJ} EXPORT oneMKLTargets) -install(TARGETS ${LIB_NAME} EXPORT oneMKLTargets +install(TARGETS ${LIB_OBJ} EXPORT oneMATHTargets) +install(TARGETS ${LIB_NAME} EXPORT oneMATHTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib diff --git a/src/sparse_blas/backends/rocsparse/operations/rocsparse_spmm.cpp b/src/sparse_blas/backends/rocsparse/operations/rocsparse_spmm.cpp index 85c894596..c810e207c 100644 --- a/src/sparse_blas/backends/rocsparse/operations/rocsparse_spmm.cpp +++ b/src/sparse_blas/backends/rocsparse/operations/rocsparse_spmm.cpp @@ -17,7 +17,7 @@ * **************************************************************************/ -#include "oneapi/mkl/sparse_blas/detail/rocsparse/onemkl_sparse_blas_rocsparse.hpp" +#include "oneapi/math/sparse_blas/detail/rocsparse/onemath_sparse_blas_rocsparse.hpp" #include "sparse_blas/backends/rocsparse/rocsparse_error.hpp" #include "sparse_blas/backends/rocsparse/rocsparse_handles.hpp" @@ -29,7 +29,7 @@ #include "sparse_blas/matrix_view_comparison.hpp" #include "sparse_blas/sycl_helper.hpp" -namespace oneapi::mkl::sparse { +namespace oneapi::math::sparse { // Complete the definition of the incomplete type struct spmm_descr { @@ -41,18 +41,18 @@ struct spmm_descr { std::size_t temp_buffer_size = 0; bool buffer_size_called = false; bool optimized_called = false; - oneapi::mkl::transpose last_optimized_opA; - oneapi::mkl::transpose last_optimized_opB; - oneapi::mkl::sparse::matrix_view last_optimized_A_view; - oneapi::mkl::sparse::matrix_handle_t last_optimized_A_handle; - oneapi::mkl::sparse::dense_matrix_handle_t last_optimized_B_handle; - oneapi::mkl::sparse::dense_matrix_handle_t last_optimized_C_handle; - oneapi::mkl::sparse::spmm_alg last_optimized_alg; + oneapi::math::transpose last_optimized_opA; + oneapi::math::transpose last_optimized_opB; + oneapi::math::sparse::matrix_view last_optimized_A_view; + oneapi::math::sparse::matrix_handle_t last_optimized_A_handle; + oneapi::math::sparse::dense_matrix_handle_t last_optimized_B_handle; + oneapi::math::sparse::dense_matrix_handle_t last_optimized_C_handle; + oneapi::math::sparse::spmm_alg last_optimized_alg; }; -} // namespace oneapi::mkl::sparse +} // namespace oneapi::math::sparse -namespace oneapi::mkl::sparse::rocsparse { +namespace oneapi::math::sparse::rocsparse { namespace detail { @@ -78,16 +78,16 @@ void check_valid_spmm(const std::string& function_name, matrix_view A_view, } inline void common_spmm_optimize( - oneapi::mkl::transpose opA, oneapi::mkl::transpose opB, bool is_alpha_host_accessible, - oneapi::mkl::sparse::matrix_view A_view, oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_matrix_handle_t B_handle, bool is_beta_host_accessible, - oneapi::mkl::sparse::dense_matrix_handle_t C_handle, oneapi::mkl::sparse::spmm_alg alg, - oneapi::mkl::sparse::spmm_descr_t spmm_descr) { + oneapi::math::transpose opA, oneapi::math::transpose opB, bool is_alpha_host_accessible, + oneapi::math::sparse::matrix_view A_view, oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_matrix_handle_t B_handle, bool is_beta_host_accessible, + oneapi::math::sparse::dense_matrix_handle_t C_handle, oneapi::math::sparse::spmm_alg alg, + oneapi::math::sparse::spmm_descr_t spmm_descr) { check_valid_spmm("spmm_optimize", A_view, A_handle, B_handle, C_handle, is_alpha_host_accessible, is_beta_host_accessible); if (!spmm_descr->buffer_size_called) { - throw mkl::uninitialized("sparse_blas", "spmm_optimize", - "spmm_buffer_size must be called before spmm_optimize."); + throw math::uninitialized("sparse_blas", "spmm_optimize", + "spmm_buffer_size must be called before spmm_optimize."); } spmm_descr->optimized_called = true; spmm_descr->last_optimized_opA = opA; @@ -99,12 +99,12 @@ inline void common_spmm_optimize( spmm_descr->last_optimized_alg = alg; } -void spmm_optimize_impl(rocsparse_handle roc_handle, oneapi::mkl::transpose opA, - oneapi::mkl::transpose opB, const void* alpha, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_matrix_handle_t B_handle, const void* beta, - oneapi::mkl::sparse::dense_matrix_handle_t C_handle, - oneapi::mkl::sparse::spmm_alg alg, std::size_t buffer_size, +void spmm_optimize_impl(rocsparse_handle roc_handle, oneapi::math::transpose opA, + oneapi::math::transpose opB, const void* alpha, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_matrix_handle_t B_handle, const void* beta, + oneapi::math::sparse::dense_matrix_handle_t C_handle, + oneapi::math::sparse::spmm_alg alg, std::size_t buffer_size, void* workspace_ptr, bool is_alpha_host_accessible) { auto roc_a = A_handle->backend_handle; auto roc_b = B_handle->backend_handle; @@ -164,13 +164,14 @@ sycl::event release_spmm_descr(sycl::queue& queue, spmm_descr_t spmm_descr, return event; } -void spmm_buffer_size(sycl::queue& queue, oneapi::mkl::transpose opA, oneapi::mkl::transpose opB, - const void* alpha, oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_matrix_handle_t B_handle, const void* beta, - oneapi::mkl::sparse::dense_matrix_handle_t C_handle, - oneapi::mkl::sparse::spmm_alg alg, - oneapi::mkl::sparse::spmm_descr_t spmm_descr, std::size_t& temp_buffer_size) { +void spmm_buffer_size(sycl::queue& queue, oneapi::math::transpose opA, oneapi::math::transpose opB, + const void* alpha, oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_matrix_handle_t B_handle, const void* beta, + oneapi::math::sparse::dense_matrix_handle_t C_handle, + oneapi::math::sparse::spmm_alg alg, + oneapi::math::sparse::spmm_descr_t spmm_descr, + std::size_t& temp_buffer_size) { bool is_alpha_host_accessible = detail::is_ptr_accessible_on_host(queue, alpha); bool is_beta_host_accessible = detail::is_ptr_accessible_on_host(queue, beta); detail::check_valid_spmm(__func__, A_view, A_handle, B_handle, C_handle, @@ -201,12 +202,13 @@ void spmm_buffer_size(sycl::queue& queue, oneapi::mkl::transpose opA, oneapi::mk spmm_descr->buffer_size_called = true; } -void spmm_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, oneapi::mkl::transpose opB, - const void* alpha, oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_matrix_handle_t B_handle, const void* beta, - oneapi::mkl::sparse::dense_matrix_handle_t C_handle, - oneapi::mkl::sparse::spmm_alg alg, oneapi::mkl::sparse::spmm_descr_t spmm_descr, +void spmm_optimize(sycl::queue& queue, oneapi::math::transpose opA, oneapi::math::transpose opB, + const void* alpha, oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_matrix_handle_t B_handle, const void* beta, + oneapi::math::sparse::dense_matrix_handle_t C_handle, + oneapi::math::sparse::spmm_alg alg, + oneapi::math::sparse::spmm_descr_t spmm_descr, sycl::buffer workspace) { bool is_alpha_host_accessible = detail::is_ptr_accessible_on_host(queue, alpha); bool is_beta_host_accessible = detail::is_ptr_accessible_on_host(queue, beta); @@ -217,7 +219,7 @@ void spmm_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, oneapi::mkl:: is_beta_host_accessible, C_handle, alg, spmm_descr); // Copy the buffer to extend its lifetime until the descriptor is free'd. spmm_descr->workspace.set_buffer_untyped(workspace); - if (alg == oneapi::mkl::sparse::spmm_alg::no_optimize_alg) { + if (alg == oneapi::math::sparse::spmm_alg::no_optimize_alg) { return; } std::size_t buffer_size = spmm_descr->temp_buffer_size; @@ -246,14 +248,14 @@ void spmm_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, oneapi::mkl:: } } -sycl::event spmm_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, - oneapi::mkl::transpose opB, const void* alpha, - oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_matrix_handle_t B_handle, const void* beta, - oneapi::mkl::sparse::dense_matrix_handle_t C_handle, - oneapi::mkl::sparse::spmm_alg alg, - oneapi::mkl::sparse::spmm_descr_t spmm_descr, void* workspace, +sycl::event spmm_optimize(sycl::queue& queue, oneapi::math::transpose opA, + oneapi::math::transpose opB, const void* alpha, + oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_matrix_handle_t B_handle, const void* beta, + oneapi::math::sparse::dense_matrix_handle_t C_handle, + oneapi::math::sparse::spmm_alg alg, + oneapi::math::sparse::spmm_descr_t spmm_descr, void* workspace, const std::vector& dependencies) { bool is_alpha_host_accessible = detail::is_ptr_accessible_on_host(queue, alpha); bool is_beta_host_accessible = detail::is_ptr_accessible_on_host(queue, beta); @@ -263,7 +265,7 @@ sycl::event spmm_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, detail::common_spmm_optimize(opA, opB, is_alpha_host_accessible, A_view, A_handle, B_handle, is_beta_host_accessible, C_handle, alg, spmm_descr); spmm_descr->workspace.usm_ptr = workspace; - if (alg == oneapi::mkl::sparse::spmm_alg::no_optimize_alg) { + if (alg == oneapi::math::sparse::spmm_alg::no_optimize_alg) { return detail::collapse_dependencies(queue, dependencies); } std::size_t buffer_size = spmm_descr->temp_buffer_size; @@ -277,12 +279,12 @@ sycl::event spmm_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, C_handle); } -sycl::event spmm(sycl::queue& queue, oneapi::mkl::transpose opA, oneapi::mkl::transpose opB, - const void* alpha, oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_matrix_handle_t B_handle, const void* beta, - oneapi::mkl::sparse::dense_matrix_handle_t C_handle, - oneapi::mkl::sparse::spmm_alg alg, oneapi::mkl::sparse::spmm_descr_t spmm_descr, +sycl::event spmm(sycl::queue& queue, oneapi::math::transpose opA, oneapi::math::transpose opB, + const void* alpha, oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_matrix_handle_t B_handle, const void* beta, + oneapi::math::sparse::dense_matrix_handle_t C_handle, + oneapi::math::sparse::spmm_alg alg, oneapi::math::sparse::spmm_descr_t spmm_descr, const std::vector& dependencies) { bool is_alpha_host_accessible = detail::is_ptr_accessible_on_host(queue, alpha); bool is_beta_host_accessible = detail::is_ptr_accessible_on_host(queue, beta); @@ -290,7 +292,7 @@ sycl::event spmm(sycl::queue& queue, oneapi::mkl::transpose opA, oneapi::mkl::tr detail::throw_incompatible_container(__func__); } if (!spmm_descr->optimized_called) { - throw mkl::uninitialized( + throw math::uninitialized( "sparse_blas", __func__, "spmm_optimize must be called with the same arguments before spmm."); } @@ -347,4 +349,4 @@ sycl::event spmm(sycl::queue& queue, oneapi::mkl::transpose opA, oneapi::mkl::tr } } -} // namespace oneapi::mkl::sparse::rocsparse +} // namespace oneapi::math::sparse::rocsparse diff --git a/src/sparse_blas/backends/rocsparse/operations/rocsparse_spmv.cpp b/src/sparse_blas/backends/rocsparse/operations/rocsparse_spmv.cpp index d7b647d82..ead19ec40 100644 --- a/src/sparse_blas/backends/rocsparse/operations/rocsparse_spmv.cpp +++ b/src/sparse_blas/backends/rocsparse/operations/rocsparse_spmv.cpp @@ -17,7 +17,7 @@ * **************************************************************************/ -#include "oneapi/mkl/sparse_blas/detail/rocsparse/onemkl_sparse_blas_rocsparse.hpp" +#include "oneapi/math/sparse_blas/detail/rocsparse/onemath_sparse_blas_rocsparse.hpp" #include "sparse_blas/backends/rocsparse/rocsparse_error.hpp" #include "sparse_blas/backends/rocsparse/rocsparse_handles.hpp" @@ -29,7 +29,7 @@ #include "sparse_blas/matrix_view_comparison.hpp" #include "sparse_blas/sycl_helper.hpp" -namespace oneapi::mkl::sparse { +namespace oneapi::math::sparse { // Complete the definition of the incomplete type struct spmv_descr { @@ -41,17 +41,17 @@ struct spmv_descr { std::size_t temp_buffer_size = 0; bool buffer_size_called = false; bool optimized_called = false; - oneapi::mkl::transpose last_optimized_opA; - oneapi::mkl::sparse::matrix_view last_optimized_A_view; - oneapi::mkl::sparse::matrix_handle_t last_optimized_A_handle; - oneapi::mkl::sparse::dense_vector_handle_t last_optimized_x_handle; - oneapi::mkl::sparse::dense_vector_handle_t last_optimized_y_handle; - oneapi::mkl::sparse::spmv_alg last_optimized_alg; + oneapi::math::transpose last_optimized_opA; + oneapi::math::sparse::matrix_view last_optimized_A_view; + oneapi::math::sparse::matrix_handle_t last_optimized_A_handle; + oneapi::math::sparse::dense_vector_handle_t last_optimized_x_handle; + oneapi::math::sparse::dense_vector_handle_t last_optimized_y_handle; + oneapi::math::sparse::spmv_alg last_optimized_alg; }; -} // namespace oneapi::mkl::sparse +} // namespace oneapi::math::sparse -namespace oneapi::mkl::sparse::rocsparse { +namespace oneapi::math::sparse::rocsparse { namespace detail { @@ -66,34 +66,34 @@ inline auto get_roc_spmv_alg(spmv_alg alg) { } } -void check_valid_spmv(const std::string& function_name, oneapi::mkl::transpose opA, - oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_vector_handle_t x_handle, - oneapi::mkl::sparse::dense_vector_handle_t y_handle, +void check_valid_spmv(const std::string& function_name, oneapi::math::transpose opA, + oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_vector_handle_t x_handle, + oneapi::math::sparse::dense_vector_handle_t y_handle, bool is_alpha_host_accessible, bool is_beta_host_accessible) { check_valid_spmv_common(function_name, opA, A_view, A_handle, x_handle, y_handle, is_alpha_host_accessible, is_beta_host_accessible); A_handle->check_valid_handle(__func__); - if (A_view.type_view != oneapi::mkl::sparse::matrix_descr::general) { - throw mkl::unimplemented( + if (A_view.type_view != oneapi::math::sparse::matrix_descr::general) { + throw math::unimplemented( "sparse_blas", function_name, "The backend does not support spmv with a `type_view` other than `matrix_descr::general`."); } } -inline void common_spmv_optimize(oneapi::mkl::transpose opA, bool is_alpha_host_accessible, - oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_vector_handle_t x_handle, +inline void common_spmv_optimize(oneapi::math::transpose opA, bool is_alpha_host_accessible, + oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_vector_handle_t x_handle, bool is_beta_host_accessible, - oneapi::mkl::sparse::dense_vector_handle_t y_handle, - oneapi::mkl::sparse::spmv_alg alg, - oneapi::mkl::sparse::spmv_descr_t spmv_descr) { + oneapi::math::sparse::dense_vector_handle_t y_handle, + oneapi::math::sparse::spmv_alg alg, + oneapi::math::sparse::spmv_descr_t spmv_descr) { check_valid_spmv("spmv_optimize", opA, A_view, A_handle, x_handle, y_handle, is_alpha_host_accessible, is_beta_host_accessible); if (!spmv_descr->buffer_size_called) { - throw mkl::uninitialized( + throw math::uninitialized( "sparse_blas", "spmv_optimize", "spmv_buffer_size must be called with the same arguments before spmv_optimize."); } @@ -106,11 +106,11 @@ inline void common_spmv_optimize(oneapi::mkl::transpose opA, bool is_alpha_host_ spmv_descr->last_optimized_alg = alg; } -void spmv_optimize_impl(rocsparse_handle roc_handle, oneapi::mkl::transpose opA, const void* alpha, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_vector_handle_t x_handle, const void* beta, - oneapi::mkl::sparse::dense_vector_handle_t y_handle, - oneapi::mkl::sparse::spmv_alg alg, std::size_t buffer_size, +void spmv_optimize_impl(rocsparse_handle roc_handle, oneapi::math::transpose opA, const void* alpha, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_vector_handle_t x_handle, const void* beta, + oneapi::math::sparse::dense_vector_handle_t y_handle, + oneapi::math::sparse::spmv_alg alg, std::size_t buffer_size, void* workspace_ptr, bool is_alpha_host_accessible) { auto roc_a = A_handle->backend_handle; auto roc_x = x_handle->backend_handle; @@ -169,13 +169,14 @@ sycl::event release_spmv_descr(sycl::queue& queue, spmv_descr_t spmv_descr, return event; } -void spmv_buffer_size(sycl::queue& queue, oneapi::mkl::transpose opA, const void* alpha, - oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_vector_handle_t x_handle, const void* beta, - oneapi::mkl::sparse::dense_vector_handle_t y_handle, - oneapi::mkl::sparse::spmv_alg alg, - oneapi::mkl::sparse::spmv_descr_t spmv_descr, std::size_t& temp_buffer_size) { +void spmv_buffer_size(sycl::queue& queue, oneapi::math::transpose opA, const void* alpha, + oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_vector_handle_t x_handle, const void* beta, + oneapi::math::sparse::dense_vector_handle_t y_handle, + oneapi::math::sparse::spmv_alg alg, + oneapi::math::sparse::spmv_descr_t spmv_descr, + std::size_t& temp_buffer_size) { bool is_alpha_host_accessible = detail::is_ptr_accessible_on_host(queue, alpha); bool is_beta_host_accessible = detail::is_ptr_accessible_on_host(queue, beta); detail::check_valid_spmv(__func__, opA, A_view, A_handle, x_handle, y_handle, @@ -205,12 +206,13 @@ void spmv_buffer_size(sycl::queue& queue, oneapi::mkl::transpose opA, const void spmv_descr->buffer_size_called = true; } -void spmv_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, const void* alpha, - oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_vector_handle_t x_handle, const void* beta, - oneapi::mkl::sparse::dense_vector_handle_t y_handle, - oneapi::mkl::sparse::spmv_alg alg, oneapi::mkl::sparse::spmv_descr_t spmv_descr, +void spmv_optimize(sycl::queue& queue, oneapi::math::transpose opA, const void* alpha, + oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_vector_handle_t x_handle, const void* beta, + oneapi::math::sparse::dense_vector_handle_t y_handle, + oneapi::math::sparse::spmv_alg alg, + oneapi::math::sparse::spmv_descr_t spmv_descr, sycl::buffer workspace) { bool is_alpha_host_accessible = detail::is_ptr_accessible_on_host(queue, alpha); bool is_beta_host_accessible = detail::is_ptr_accessible_on_host(queue, beta); @@ -221,7 +223,7 @@ void spmv_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, const void* a is_beta_host_accessible, y_handle, alg, spmv_descr); // Copy the buffer to extend its lifetime until the descriptor is free'd. spmv_descr->workspace.set_buffer_untyped(workspace); - if (alg == oneapi::mkl::sparse::spmv_alg::no_optimize_alg) { + if (alg == oneapi::math::sparse::spmv_alg::no_optimize_alg) { return; } std::size_t buffer_size = spmv_descr->temp_buffer_size; @@ -247,13 +249,13 @@ void spmv_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, const void* a } } -sycl::event spmv_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, const void* alpha, - oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_vector_handle_t x_handle, const void* beta, - oneapi::mkl::sparse::dense_vector_handle_t y_handle, - oneapi::mkl::sparse::spmv_alg alg, - oneapi::mkl::sparse::spmv_descr_t spmv_descr, void* workspace, +sycl::event spmv_optimize(sycl::queue& queue, oneapi::math::transpose opA, const void* alpha, + oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_vector_handle_t x_handle, const void* beta, + oneapi::math::sparse::dense_vector_handle_t y_handle, + oneapi::math::sparse::spmv_alg alg, + oneapi::math::sparse::spmv_descr_t spmv_descr, void* workspace, const std::vector& dependencies) { bool is_alpha_host_accessible = detail::is_ptr_accessible_on_host(queue, alpha); bool is_beta_host_accessible = detail::is_ptr_accessible_on_host(queue, beta); @@ -263,7 +265,7 @@ sycl::event spmv_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, const detail::common_spmv_optimize(opA, is_alpha_host_accessible, A_view, A_handle, x_handle, is_beta_host_accessible, y_handle, alg, spmv_descr); spmv_descr->workspace.usm_ptr = workspace; - if (alg == oneapi::mkl::sparse::spmv_alg::no_optimize_alg) { + if (alg == oneapi::math::sparse::spmv_alg::no_optimize_alg) { return detail::collapse_dependencies(queue, dependencies); } std::size_t buffer_size = spmv_descr->temp_buffer_size; @@ -277,12 +279,12 @@ sycl::event spmv_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, const y_handle); } -sycl::event spmv(sycl::queue& queue, oneapi::mkl::transpose opA, const void* alpha, - oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_vector_handle_t x_handle, const void* beta, - oneapi::mkl::sparse::dense_vector_handle_t y_handle, - oneapi::mkl::sparse::spmv_alg alg, oneapi::mkl::sparse::spmv_descr_t spmv_descr, +sycl::event spmv(sycl::queue& queue, oneapi::math::transpose opA, const void* alpha, + oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_vector_handle_t x_handle, const void* beta, + oneapi::math::sparse::dense_vector_handle_t y_handle, + oneapi::math::sparse::spmv_alg alg, oneapi::math::sparse::spmv_descr_t spmv_descr, const std::vector& dependencies) { bool is_alpha_host_accessible = detail::is_ptr_accessible_on_host(queue, alpha); bool is_beta_host_accessible = detail::is_ptr_accessible_on_host(queue, beta); @@ -293,7 +295,7 @@ sycl::event spmv(sycl::queue& queue, oneapi::mkl::transpose opA, const void* alp is_alpha_host_accessible, is_beta_host_accessible); if (!spmv_descr->optimized_called) { - throw mkl::uninitialized( + throw math::uninitialized( "sparse_blas", __func__, "spmv_optimize must be called with the same arguments before spmv."); } @@ -347,4 +349,4 @@ sycl::event spmv(sycl::queue& queue, oneapi::mkl::transpose opA, const void* alp } } -} // namespace oneapi::mkl::sparse::rocsparse +} // namespace oneapi::math::sparse::rocsparse diff --git a/src/sparse_blas/backends/rocsparse/operations/rocsparse_spsv.cpp b/src/sparse_blas/backends/rocsparse/operations/rocsparse_spsv.cpp index 43dde34d4..07a6c72d9 100644 --- a/src/sparse_blas/backends/rocsparse/operations/rocsparse_spsv.cpp +++ b/src/sparse_blas/backends/rocsparse/operations/rocsparse_spsv.cpp @@ -17,7 +17,7 @@ * **************************************************************************/ -#include "oneapi/mkl/sparse_blas/detail/rocsparse/onemkl_sparse_blas_rocsparse.hpp" +#include "oneapi/math/sparse_blas/detail/rocsparse/onemath_sparse_blas_rocsparse.hpp" #include "sparse_blas/backends/rocsparse/rocsparse_error.hpp" #include "sparse_blas/backends/rocsparse/rocsparse_handles.hpp" @@ -29,7 +29,7 @@ #include "sparse_blas/matrix_view_comparison.hpp" #include "sparse_blas/sycl_helper.hpp" -namespace oneapi::mkl::sparse { +namespace oneapi::math::sparse { // Complete the definition of the incomplete type struct spsv_descr { @@ -41,17 +41,17 @@ struct spsv_descr { std::size_t temp_buffer_size = 0; bool buffer_size_called = false; bool optimized_called = false; - oneapi::mkl::transpose last_optimized_opA; - oneapi::mkl::sparse::matrix_view last_optimized_A_view; - oneapi::mkl::sparse::matrix_handle_t last_optimized_A_handle; - oneapi::mkl::sparse::dense_vector_handle_t last_optimized_x_handle; - oneapi::mkl::sparse::dense_vector_handle_t last_optimized_y_handle; - oneapi::mkl::sparse::spsv_alg last_optimized_alg; + oneapi::math::transpose last_optimized_opA; + oneapi::math::sparse::matrix_view last_optimized_A_view; + oneapi::math::sparse::matrix_handle_t last_optimized_A_handle; + oneapi::math::sparse::dense_vector_handle_t last_optimized_x_handle; + oneapi::math::sparse::dense_vector_handle_t last_optimized_y_handle; + oneapi::math::sparse::spsv_alg last_optimized_alg; }; -} // namespace oneapi::mkl::sparse +} // namespace oneapi::math::sparse -namespace oneapi::mkl::sparse::rocsparse { +namespace oneapi::math::sparse::rocsparse { namespace detail { @@ -67,17 +67,17 @@ void check_valid_spsv(const std::string& function_name, matrix_view A_view, A_handle->check_valid_handle(function_name); } -inline void common_spsv_optimize(oneapi::mkl::transpose opA, bool is_alpha_host_accessible, - oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_vector_handle_t x_handle, - oneapi::mkl::sparse::dense_vector_handle_t y_handle, - oneapi::mkl::sparse::spsv_alg alg, - oneapi::mkl::sparse::spsv_descr_t spsv_descr) { +inline void common_spsv_optimize(oneapi::math::transpose opA, bool is_alpha_host_accessible, + oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_vector_handle_t x_handle, + oneapi::math::sparse::dense_vector_handle_t y_handle, + oneapi::math::sparse::spsv_alg alg, + oneapi::math::sparse::spsv_descr_t spsv_descr) { check_valid_spsv("spsv_optimize", A_view, A_handle, x_handle, y_handle, is_alpha_host_accessible); if (!spsv_descr->buffer_size_called) { - throw mkl::uninitialized( + throw math::uninitialized( "sparse_blas", "spsv_optimize", "spsv_buffer_size must be called with the same arguments before spsv_optimize."); } @@ -90,12 +90,12 @@ inline void common_spsv_optimize(oneapi::mkl::transpose opA, bool is_alpha_host_ spsv_descr->last_optimized_alg = alg; } -void spsv_optimize_impl(rocsparse_handle roc_handle, oneapi::mkl::transpose opA, const void* alpha, - oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_vector_handle_t x_handle, - oneapi::mkl::sparse::dense_vector_handle_t y_handle, - oneapi::mkl::sparse::spsv_alg alg, std::size_t buffer_size, +void spsv_optimize_impl(rocsparse_handle roc_handle, oneapi::math::transpose opA, const void* alpha, + oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_vector_handle_t x_handle, + oneapi::math::sparse::dense_vector_handle_t y_handle, + oneapi::math::sparse::spsv_alg alg, std::size_t buffer_size, void* workspace_ptr, bool is_alpha_host_accessible) { auto roc_a = A_handle->backend_handle; auto roc_x = x_handle->backend_handle; @@ -154,13 +154,14 @@ sycl::event release_spsv_descr(sycl::queue& queue, spsv_descr_t spsv_descr, return event; } -void spsv_buffer_size(sycl::queue& queue, oneapi::mkl::transpose opA, const void* alpha, - oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_vector_handle_t x_handle, - oneapi::mkl::sparse::dense_vector_handle_t y_handle, - oneapi::mkl::sparse::spsv_alg alg, - oneapi::mkl::sparse::spsv_descr_t spsv_descr, std::size_t& temp_buffer_size) { +void spsv_buffer_size(sycl::queue& queue, oneapi::math::transpose opA, const void* alpha, + oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_vector_handle_t x_handle, + oneapi::math::sparse::dense_vector_handle_t y_handle, + oneapi::math::sparse::spsv_alg alg, + oneapi::math::sparse::spsv_descr_t spsv_descr, + std::size_t& temp_buffer_size) { bool is_alpha_host_accessible = detail::is_ptr_accessible_on_host(queue, alpha); detail::check_valid_spsv(__func__, A_view, A_handle, x_handle, y_handle, is_alpha_host_accessible); @@ -190,12 +191,13 @@ void spsv_buffer_size(sycl::queue& queue, oneapi::mkl::transpose opA, const void spsv_descr->buffer_size_called = true; } -void spsv_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, const void* alpha, - oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_vector_handle_t x_handle, - oneapi::mkl::sparse::dense_vector_handle_t y_handle, - oneapi::mkl::sparse::spsv_alg alg, oneapi::mkl::sparse::spsv_descr_t spsv_descr, +void spsv_optimize(sycl::queue& queue, oneapi::math::transpose opA, const void* alpha, + oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_vector_handle_t x_handle, + oneapi::math::sparse::dense_vector_handle_t y_handle, + oneapi::math::sparse::spsv_alg alg, + oneapi::math::sparse::spsv_descr_t spsv_descr, sycl::buffer workspace) { bool is_alpha_host_accessible = detail::is_ptr_accessible_on_host(queue, alpha); if (!A_handle->all_use_buffer()) { @@ -230,13 +232,13 @@ void spsv_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, const void* a } } -sycl::event spsv_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, const void* alpha, - oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_vector_handle_t x_handle, - oneapi::mkl::sparse::dense_vector_handle_t y_handle, - oneapi::mkl::sparse::spsv_alg alg, - oneapi::mkl::sparse::spsv_descr_t spsv_descr, void* workspace, +sycl::event spsv_optimize(sycl::queue& queue, oneapi::math::transpose opA, const void* alpha, + oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_vector_handle_t x_handle, + oneapi::math::sparse::dense_vector_handle_t y_handle, + oneapi::math::sparse::spsv_alg alg, + oneapi::math::sparse::spsv_descr_t spsv_descr, void* workspace, const std::vector& dependencies) { bool is_alpha_host_accessible = detail::is_ptr_accessible_on_host(queue, alpha); if (A_handle->all_use_buffer()) { @@ -258,12 +260,12 @@ sycl::event spsv_optimize(sycl::queue& queue, oneapi::mkl::transpose opA, const y_handle); } -sycl::event spsv(sycl::queue& queue, oneapi::mkl::transpose opA, const void* alpha, - oneapi::mkl::sparse::matrix_view A_view, - oneapi::mkl::sparse::matrix_handle_t A_handle, - oneapi::mkl::sparse::dense_vector_handle_t x_handle, - oneapi::mkl::sparse::dense_vector_handle_t y_handle, - oneapi::mkl::sparse::spsv_alg alg, oneapi::mkl::sparse::spsv_descr_t spsv_descr, +sycl::event spsv(sycl::queue& queue, oneapi::math::transpose opA, const void* alpha, + oneapi::math::sparse::matrix_view A_view, + oneapi::math::sparse::matrix_handle_t A_handle, + oneapi::math::sparse::dense_vector_handle_t x_handle, + oneapi::math::sparse::dense_vector_handle_t y_handle, + oneapi::math::sparse::spsv_alg alg, oneapi::math::sparse::spsv_descr_t spsv_descr, const std::vector& dependencies) { bool is_alpha_host_accessible = detail::is_ptr_accessible_on_host(queue, alpha); if (A_handle->all_use_buffer() != spsv_descr->workspace.use_buffer()) { @@ -273,7 +275,7 @@ sycl::event spsv(sycl::queue& queue, oneapi::mkl::transpose opA, const void* alp is_alpha_host_accessible); if (!spsv_descr->optimized_called) { - throw mkl::uninitialized( + throw math::uninitialized( "sparse_blas", __func__, "spsv_optimize must be called with the same arguments before spsv."); } @@ -328,4 +330,4 @@ sycl::event spsv(sycl::queue& queue, oneapi::mkl::transpose opA, const void* alp } } -} // namespace oneapi::mkl::sparse::rocsparse +} // namespace oneapi::math::sparse::rocsparse diff --git a/src/sparse_blas/backends/rocsparse/rocsparse_error.hpp b/src/sparse_blas/backends/rocsparse/rocsparse_error.hpp index cd3191ad2..59da045c9 100644 --- a/src/sparse_blas/backends/rocsparse/rocsparse_error.hpp +++ b/src/sparse_blas/backends/rocsparse/rocsparse_error.hpp @@ -17,78 +17,78 @@ * **************************************************************************/ -#ifndef _ONEMKL_SPARSE_BLAS_BACKENDS_ROCSPARSE_ERROR_HPP_ -#define _ONEMKL_SPARSE_BLAS_BACKENDS_ROCSPARSE_ERROR_HPP_ +#ifndef _ONEMATH_SPARSE_BLAS_BACKENDS_ROCSPARSE_ERROR_HPP_ +#define _ONEMATH_SPARSE_BLAS_BACKENDS_ROCSPARSE_ERROR_HPP_ #include #include #include -#include "oneapi/mkl/exceptions.hpp" +#include "oneapi/math/exceptions.hpp" -namespace oneapi::mkl::sparse::rocsparse::detail { +namespace oneapi::math::sparse::rocsparse::detail { inline std::string hip_result_to_str(hipError_t result) { switch (result) { -#define ONEMKL_ROCSPARSE_CASE(STATUS) \ +#define ONEMATH_ROCSPARSE_CASE(STATUS) \ case STATUS: return #STATUS - ONEMKL_ROCSPARSE_CASE(hipSuccess); - ONEMKL_ROCSPARSE_CASE(hipErrorInvalidContext); - ONEMKL_ROCSPARSE_CASE(hipErrorInvalidKernelFile); - ONEMKL_ROCSPARSE_CASE(hipErrorMemoryAllocation); - ONEMKL_ROCSPARSE_CASE(hipErrorInitializationError); - ONEMKL_ROCSPARSE_CASE(hipErrorLaunchFailure); - ONEMKL_ROCSPARSE_CASE(hipErrorLaunchOutOfResources); - ONEMKL_ROCSPARSE_CASE(hipErrorInvalidDevice); - ONEMKL_ROCSPARSE_CASE(hipErrorInvalidValue); - ONEMKL_ROCSPARSE_CASE(hipErrorInvalidDevicePointer); - ONEMKL_ROCSPARSE_CASE(hipErrorInvalidMemcpyDirection); - ONEMKL_ROCSPARSE_CASE(hipErrorUnknown); - ONEMKL_ROCSPARSE_CASE(hipErrorInvalidResourceHandle); - ONEMKL_ROCSPARSE_CASE(hipErrorNotReady); - ONEMKL_ROCSPARSE_CASE(hipErrorNoDevice); - ONEMKL_ROCSPARSE_CASE(hipErrorPeerAccessAlreadyEnabled); - ONEMKL_ROCSPARSE_CASE(hipErrorPeerAccessNotEnabled); - ONEMKL_ROCSPARSE_CASE(hipErrorRuntimeMemory); - ONEMKL_ROCSPARSE_CASE(hipErrorRuntimeOther); - ONEMKL_ROCSPARSE_CASE(hipErrorHostMemoryAlreadyRegistered); - ONEMKL_ROCSPARSE_CASE(hipErrorHostMemoryNotRegistered); - ONEMKL_ROCSPARSE_CASE(hipErrorMapBufferObjectFailed); - ONEMKL_ROCSPARSE_CASE(hipErrorTbd); + ONEMATH_ROCSPARSE_CASE(hipSuccess); + ONEMATH_ROCSPARSE_CASE(hipErrorInvalidContext); + ONEMATH_ROCSPARSE_CASE(hipErrorInvalidKernelFile); + ONEMATH_ROCSPARSE_CASE(hipErrorMemoryAllocation); + ONEMATH_ROCSPARSE_CASE(hipErrorInitializationError); + ONEMATH_ROCSPARSE_CASE(hipErrorLaunchFailure); + ONEMATH_ROCSPARSE_CASE(hipErrorLaunchOutOfResources); + ONEMATH_ROCSPARSE_CASE(hipErrorInvalidDevice); + ONEMATH_ROCSPARSE_CASE(hipErrorInvalidValue); + ONEMATH_ROCSPARSE_CASE(hipErrorInvalidDevicePointer); + ONEMATH_ROCSPARSE_CASE(hipErrorInvalidMemcpyDirection); + ONEMATH_ROCSPARSE_CASE(hipErrorUnknown); + ONEMATH_ROCSPARSE_CASE(hipErrorInvalidResourceHandle); + ONEMATH_ROCSPARSE_CASE(hipErrorNotReady); + ONEMATH_ROCSPARSE_CASE(hipErrorNoDevice); + ONEMATH_ROCSPARSE_CASE(hipErrorPeerAccessAlreadyEnabled); + ONEMATH_ROCSPARSE_CASE(hipErrorPeerAccessNotEnabled); + ONEMATH_ROCSPARSE_CASE(hipErrorRuntimeMemory); + ONEMATH_ROCSPARSE_CASE(hipErrorRuntimeOther); + ONEMATH_ROCSPARSE_CASE(hipErrorHostMemoryAlreadyRegistered); + ONEMATH_ROCSPARSE_CASE(hipErrorHostMemoryNotRegistered); + ONEMATH_ROCSPARSE_CASE(hipErrorMapBufferObjectFailed); + ONEMATH_ROCSPARSE_CASE(hipErrorTbd); default: return ""; } } -#define HIP_ERROR_FUNC(func, ...) \ - do { \ - auto res = func(__VA_ARGS__); \ - if (res != hipSuccess) { \ - throw oneapi::mkl::exception("sparse_blas", #func, \ - "hip error: " + detail::hip_result_to_str(res)); \ - } \ +#define HIP_ERROR_FUNC(func, ...) \ + do { \ + auto res = func(__VA_ARGS__); \ + if (res != hipSuccess) { \ + throw oneapi::math::exception("sparse_blas", #func, \ + "hip error: " + detail::hip_result_to_str(res)); \ + } \ } while (0) inline std::string rocsparse_status_to_str(rocsparse_status status) { switch (status) { -#define ONEMKL_ROCSPARSE_CASE(STATUS) \ +#define ONEMATH_ROCSPARSE_CASE(STATUS) \ case STATUS: return #STATUS - ONEMKL_ROCSPARSE_CASE(rocsparse_status_success); - ONEMKL_ROCSPARSE_CASE(rocsparse_status_invalid_handle); - ONEMKL_ROCSPARSE_CASE(rocsparse_status_not_implemented); - ONEMKL_ROCSPARSE_CASE(rocsparse_status_invalid_pointer); - ONEMKL_ROCSPARSE_CASE(rocsparse_status_invalid_size); - ONEMKL_ROCSPARSE_CASE(rocsparse_status_memory_error); - ONEMKL_ROCSPARSE_CASE(rocsparse_status_internal_error); - ONEMKL_ROCSPARSE_CASE(rocsparse_status_invalid_value); - ONEMKL_ROCSPARSE_CASE(rocsparse_status_arch_mismatch); - ONEMKL_ROCSPARSE_CASE(rocsparse_status_zero_pivot); - ONEMKL_ROCSPARSE_CASE(rocsparse_status_not_initialized); - ONEMKL_ROCSPARSE_CASE(rocsparse_status_type_mismatch); - ONEMKL_ROCSPARSE_CASE(rocsparse_status_requires_sorted_storage); - ONEMKL_ROCSPARSE_CASE(rocsparse_status_thrown_exception); - ONEMKL_ROCSPARSE_CASE(rocsparse_status_continue); -#undef ONEMKL_ROCSPARSE_CASE + ONEMATH_ROCSPARSE_CASE(rocsparse_status_success); + ONEMATH_ROCSPARSE_CASE(rocsparse_status_invalid_handle); + ONEMATH_ROCSPARSE_CASE(rocsparse_status_not_implemented); + ONEMATH_ROCSPARSE_CASE(rocsparse_status_invalid_pointer); + ONEMATH_ROCSPARSE_CASE(rocsparse_status_invalid_size); + ONEMATH_ROCSPARSE_CASE(rocsparse_status_memory_error); + ONEMATH_ROCSPARSE_CASE(rocsparse_status_internal_error); + ONEMATH_ROCSPARSE_CASE(rocsparse_status_invalid_value); + ONEMATH_ROCSPARSE_CASE(rocsparse_status_arch_mismatch); + ONEMATH_ROCSPARSE_CASE(rocsparse_status_zero_pivot); + ONEMATH_ROCSPARSE_CASE(rocsparse_status_not_initialized); + ONEMATH_ROCSPARSE_CASE(rocsparse_status_type_mismatch); + ONEMATH_ROCSPARSE_CASE(rocsparse_status_requires_sorted_storage); + ONEMATH_ROCSPARSE_CASE(rocsparse_status_thrown_exception); + ONEMATH_ROCSPARSE_CASE(rocsparse_status_continue); +#undef ONEMATH_ROCSPARSE_CASE default: return ""; } } @@ -102,15 +102,15 @@ inline void check_status(rocsparse_status status, const std::string& function, error_str += "rocSPARSE status: " + rocsparse_status_to_str(status); switch (status) { case rocsparse_status_not_implemented: - throw oneapi::mkl::unimplemented("sparse_blas", function, error_str); + throw oneapi::math::unimplemented("sparse_blas", function, error_str); case rocsparse_status_invalid_handle: case rocsparse_status_invalid_pointer: case rocsparse_status_invalid_size: case rocsparse_status_invalid_value: - throw oneapi::mkl::invalid_argument("sparse_blas", function, error_str); + throw oneapi::math::invalid_argument("sparse_blas", function, error_str); case rocsparse_status_not_initialized: - throw oneapi::mkl::uninitialized("sparse_blas", function, error_str); - default: throw oneapi::mkl::exception("sparse_blas", function, error_str); + throw oneapi::math::uninitialized("sparse_blas", function, error_str); + default: throw oneapi::math::exception("sparse_blas", function, error_str); } } } @@ -121,6 +121,6 @@ inline void check_status(rocsparse_status status, const std::string& function, detail::check_status(status, #func); \ } while (0) -} // namespace oneapi::mkl::sparse::rocsparse::detail +} // namespace oneapi::math::sparse::rocsparse::detail -#endif // _ONEMKL_SPARSE_BLAS_BACKENDS_ROCSPARSE_ERROR_HPP_ +#endif // _ONEMATH_SPARSE_BLAS_BACKENDS_ROCSPARSE_ERROR_HPP_ diff --git a/src/sparse_blas/backends/rocsparse/rocsparse_global_handle.hpp b/src/sparse_blas/backends/rocsparse/rocsparse_global_handle.hpp index bba2b5b1d..78699bc8f 100644 --- a/src/sparse_blas/backends/rocsparse/rocsparse_global_handle.hpp +++ b/src/sparse_blas/backends/rocsparse/rocsparse_global_handle.hpp @@ -17,8 +17,8 @@ * **************************************************************************/ -#ifndef _ONEMKL_SPARSE_BLAS_BACKENDS_ROCSPARSE_GLOBAL_HANDLE_HPP_ -#define _ONEMKL_SPARSE_BLAS_BACKENDS_ROCSPARSE_GLOBAL_HANDLE_HPP_ +#ifndef _ONEMATH_SPARSE_BLAS_BACKENDS_ROCSPARSE_GLOBAL_HANDLE_HPP_ +#define _ONEMATH_SPARSE_BLAS_BACKENDS_ROCSPARSE_GLOBAL_HANDLE_HPP_ /** * @file Similar to blas_handle.hpp @@ -29,7 +29,7 @@ #include #include -namespace oneapi::mkl::sparse::rocsparse::detail { +namespace oneapi::math::sparse::rocsparse::detail { template struct rocsparse_global_handle { @@ -58,6 +58,6 @@ struct rocsparse_global_handle { } }; -} // namespace oneapi::mkl::sparse::rocsparse::detail +} // namespace oneapi::math::sparse::rocsparse::detail -#endif // _ONEMKL_SPARSE_BLAS_BACKENDS_ROCSPARSE_GLOBAL_HANDLE_HPP_ +#endif // _ONEMATH_SPARSE_BLAS_BACKENDS_ROCSPARSE_GLOBAL_HANDLE_HPP_ diff --git a/src/sparse_blas/backends/rocsparse/rocsparse_handles.cpp b/src/sparse_blas/backends/rocsparse/rocsparse_handles.cpp index bfa23dfbd..63cd41c7e 100644 --- a/src/sparse_blas/backends/rocsparse/rocsparse_handles.cpp +++ b/src/sparse_blas/backends/rocsparse/rocsparse_handles.cpp @@ -17,7 +17,7 @@ * **************************************************************************/ -#include "oneapi/mkl/sparse_blas/detail/rocsparse/onemkl_sparse_blas_rocsparse.hpp" +#include "oneapi/math/sparse_blas/detail/rocsparse/onemath_sparse_blas_rocsparse.hpp" #include "rocsparse_error.hpp" #include "rocsparse_helper.hpp" @@ -26,7 +26,7 @@ #include "rocsparse_task.hpp" #include "sparse_blas/macros.hpp" -namespace oneapi::mkl::sparse::rocsparse { +namespace oneapi::math::sparse::rocsparse { /** * In this file RocsparseScopedContextHandler are used to ensure that a rocsparse_handle is created before any other rocSPARSE call, as required by the specification. @@ -165,7 +165,7 @@ void init_dense_matrix(sycl::queue& queue, dense_matrix_handle_t* p_dmhandle, st template void set_dense_matrix_data(sycl::queue& queue, dense_matrix_handle_t dmhandle, std::int64_t num_rows, std::int64_t num_cols, std::int64_t ld, - oneapi::mkl::layout dense_layout, sycl::buffer val) { + oneapi::math::layout dense_layout, sycl::buffer val) { detail::check_can_reset_value_handle(__func__, dmhandle, true); auto event = queue.submit([&](sycl::handler& cgh) { auto acc = val.template get_access(cgh); @@ -195,8 +195,8 @@ void set_dense_matrix_data(sycl::queue& queue, dense_matrix_handle_t dmhandle, template void set_dense_matrix_data(sycl::queue&, dense_matrix_handle_t dmhandle, std::int64_t num_rows, - std::int64_t num_cols, std::int64_t ld, oneapi::mkl::layout dense_layout, - fpType* val) { + std::int64_t num_cols, std::int64_t ld, + oneapi::math::layout dense_layout, fpType* val) { detail::check_can_reset_value_handle(__func__, dmhandle, false); if (dmhandle->num_rows != num_rows || dmhandle->num_cols != num_cols || dmhandle->ld != ld || dmhandle->dense_layout != dense_layout) { @@ -231,7 +231,7 @@ sycl::event release_dense_matrix(sycl::queue& queue, dense_matrix_handle_t dmhan // COO matrix template void init_coo_matrix(sycl::queue& queue, matrix_handle_t* p_smhandle, std::int64_t num_rows, - std::int64_t num_cols, std::int64_t nnz, oneapi::mkl::index_base index, + std::int64_t num_cols, std::int64_t nnz, oneapi::math::index_base index, sycl::buffer row_ind, sycl::buffer col_ind, sycl::buffer val) { auto event = queue.submit([&](sycl::handler& cgh) { @@ -259,7 +259,7 @@ void init_coo_matrix(sycl::queue& queue, matrix_handle_t* p_smhandle, std::int64 template void init_coo_matrix(sycl::queue& queue, matrix_handle_t* p_smhandle, std::int64_t num_rows, - std::int64_t num_cols, std::int64_t nnz, oneapi::mkl::index_base index, + std::int64_t num_cols, std::int64_t nnz, oneapi::math::index_base index, intType* row_ind, intType* col_ind, fpType* val) { auto event = queue.submit([&](sycl::handler& cgh) { detail::submit_host_task(cgh, queue, [=](sycl::interop_handle ih) { @@ -282,7 +282,7 @@ void init_coo_matrix(sycl::queue& queue, matrix_handle_t* p_smhandle, std::int64 template void set_coo_matrix_data(sycl::queue& queue, matrix_handle_t smhandle, std::int64_t num_rows, - std::int64_t num_cols, std::int64_t nnz, oneapi::mkl::index_base index, + std::int64_t num_cols, std::int64_t nnz, oneapi::math::index_base index, sycl::buffer row_ind, sycl::buffer col_ind, sycl::buffer val) { detail::check_can_reset_sparse_handle(__func__, smhandle, true); @@ -321,7 +321,7 @@ void set_coo_matrix_data(sycl::queue& queue, matrix_handle_t smhandle, std::int6 template void set_coo_matrix_data(sycl::queue&, matrix_handle_t smhandle, std::int64_t num_rows, - std::int64_t num_cols, std::int64_t nnz, oneapi::mkl::index_base index, + std::int64_t num_cols, std::int64_t nnz, oneapi::math::index_base index, intType* row_ind, intType* col_ind, fpType* val) { detail::check_can_reset_sparse_handle(__func__, smhandle, false); if (smhandle->num_rows != num_rows || smhandle->num_cols != num_cols || smhandle->nnz != nnz || @@ -352,7 +352,7 @@ FOR_EACH_FP_AND_INT_TYPE(INSTANTIATE_COO_MATRIX_FUNCS); // CSR matrix template void init_csr_matrix(sycl::queue& queue, matrix_handle_t* p_smhandle, std::int64_t num_rows, - std::int64_t num_cols, std::int64_t nnz, oneapi::mkl::index_base index, + std::int64_t num_cols, std::int64_t nnz, oneapi::math::index_base index, sycl::buffer row_ptr, sycl::buffer col_ind, sycl::buffer val) { auto event = queue.submit([&](sycl::handler& cgh) { @@ -380,7 +380,7 @@ void init_csr_matrix(sycl::queue& queue, matrix_handle_t* p_smhandle, std::int64 template void init_csr_matrix(sycl::queue& queue, matrix_handle_t* p_smhandle, std::int64_t num_rows, - std::int64_t num_cols, std::int64_t nnz, oneapi::mkl::index_base index, + std::int64_t num_cols, std::int64_t nnz, oneapi::math::index_base index, intType* row_ptr, intType* col_ind, fpType* val) { auto event = queue.submit([&](sycl::handler& cgh) { detail::submit_host_task(cgh, queue, [=](sycl::interop_handle ih) { @@ -403,7 +403,7 @@ void init_csr_matrix(sycl::queue& queue, matrix_handle_t* p_smhandle, std::int64 template void set_csr_matrix_data(sycl::queue& queue, matrix_handle_t smhandle, std::int64_t num_rows, - std::int64_t num_cols, std::int64_t nnz, oneapi::mkl::index_base index, + std::int64_t num_cols, std::int64_t nnz, oneapi::math::index_base index, sycl::buffer row_ptr, sycl::buffer col_ind, sycl::buffer val) { detail::check_can_reset_sparse_handle(__func__, smhandle, true); @@ -442,7 +442,7 @@ void set_csr_matrix_data(sycl::queue& queue, matrix_handle_t smhandle, std::int6 template void set_csr_matrix_data(sycl::queue&, matrix_handle_t smhandle, std::int64_t num_rows, - std::int64_t num_cols, std::int64_t nnz, oneapi::mkl::index_base index, + std::int64_t num_cols, std::int64_t nnz, oneapi::math::index_base index, intType* row_ptr, intType* col_ind, fpType* val) { detail::check_can_reset_sparse_handle(__func__, smhandle, false); if (smhandle->num_rows != num_rows || smhandle->num_cols != num_cols || smhandle->nnz != nnz || @@ -488,4 +488,4 @@ bool set_matrix_property(sycl::queue&, matrix_handle_t smhandle, matrix_property return false; } -} // namespace oneapi::mkl::sparse::rocsparse +} // namespace oneapi::math::sparse::rocsparse diff --git a/src/sparse_blas/backends/rocsparse/rocsparse_handles.hpp b/src/sparse_blas/backends/rocsparse/rocsparse_handles.hpp index 3ac985dca..a7c429fad 100644 --- a/src/sparse_blas/backends/rocsparse/rocsparse_handles.hpp +++ b/src/sparse_blas/backends/rocsparse/rocsparse_handles.hpp @@ -17,14 +17,14 @@ * **************************************************************************/ -#ifndef _ONEMKL_SRC_SPARSE_BLAS_BACKENDS_ROCSPARSE_HANDLES_HPP_ -#define _ONEMKL_SRC_SPARSE_BLAS_BACKENDS_ROCSPARSE_HANDLES_HPP_ +#ifndef _ONEMATH_SRC_SPARSE_BLAS_BACKENDS_ROCSPARSE_HANDLES_HPP_ +#define _ONEMATH_SRC_SPARSE_BLAS_BACKENDS_ROCSPARSE_HANDLES_HPP_ #include #include "sparse_blas/generic_container.hpp" -namespace oneapi::mkl::sparse { +namespace oneapi::math::sparse { // Complete the definition of incomplete types dense_vector_handle, dense_matrix_handle and matrix_handle. @@ -66,7 +66,7 @@ struct matrix_handle : public detail::generic_sparse_handle matrix_handle(rocsparse_spmat_descr roc_descr, intType* row_ptr, intType* col_ptr, fpType* value_ptr, detail::sparse_format format, std::int64_t num_rows, - std::int64_t num_cols, std::int64_t nnz, oneapi::mkl::index_base index) + std::int64_t num_cols, std::int64_t nnz, oneapi::math::index_base index) : detail::generic_sparse_handle( roc_descr, row_ptr, col_ptr, value_ptr, format, num_rows, num_cols, nnz, index) {} @@ -75,7 +75,7 @@ struct matrix_handle : public detail::generic_sparse_handle col_buffer, const sycl::buffer value_buffer, detail::sparse_format format, std::int64_t num_rows, std::int64_t num_cols, std::int64_t nnz, - oneapi::mkl::index_base index) + oneapi::math::index_base index) : detail::generic_sparse_handle(roc_descr, row_buffer, col_buffer, value_buffer, format, num_rows, num_cols, nnz, index) { @@ -83,19 +83,19 @@ struct matrix_handle : public detail::generic_sparse_handleformat == detail::sparse_format::COO && !this->has_matrix_property(matrix_property::sorted)) { - throw mkl::unimplemented( + throw math::unimplemented( "sparse_blas", function_name, "The backend does not support unsorted COO format. Use `set_matrix_property` to set the property `matrix_property::sorted`"); } if (this->format == detail::sparse_format::CSR && !this->has_matrix_property(matrix_property::sorted)) { - throw mkl::unimplemented( + throw math::unimplemented( "sparse_blas", function_name, "The backend does not support unsorted CSR format. Use `set_matrix_property` to set the property `matrix_property::sorted`"); } @@ -106,6 +106,6 @@ struct matrix_handle : public detail::generic_sparse_handle #include @@ -26,14 +26,14 @@ #include -#include "oneapi/mkl/sparse_blas/types.hpp" +#include "oneapi/math/sparse_blas/types.hpp" #include "sparse_blas/enum_data_types.hpp" #include "sparse_blas/sycl_helper.hpp" #include "rocsparse_error.hpp" -namespace oneapi::mkl::sparse::rocsparse::detail { +namespace oneapi::math::sparse::rocsparse::detail { -using namespace oneapi::mkl::sparse::detail; +using namespace oneapi::math::sparse::detail; template struct RocEnumType; @@ -70,16 +70,16 @@ inline std::string cast_enum_to_str(E e) { return std::to_string(static_cast(e)); } -inline auto get_roc_value_type(data_type onemkl_data_type) { - switch (onemkl_data_type) { +inline auto get_roc_value_type(data_type onemath_data_type) { + switch (onemath_data_type) { case data_type::real_fp32: return rocsparse_datatype_f32_r; case data_type::real_fp64: return rocsparse_datatype_f64_r; case data_type::complex_fp32: return rocsparse_datatype_f32_c; case data_type::complex_fp64: return rocsparse_datatype_f64_c; default: - throw oneapi::mkl::invalid_argument( + throw oneapi::math::invalid_argument( "sparse_blas", "get_roc_value_type", - "Invalid data type: " + cast_enum_to_str(onemkl_data_type)); + "Invalid data type: " + cast_enum_to_str(onemath_data_type)); } } @@ -88,8 +88,8 @@ inline auto get_roc_order(layout l) { case layout::row_major: return rocsparse_order_row; case layout::col_major: return rocsparse_order_column; default: - throw oneapi::mkl::invalid_argument("sparse_blas", "get_roc_order", - "Unknown layout: " + cast_enum_to_str(l)); + throw oneapi::math::invalid_argument("sparse_blas", "get_roc_order", + "Unknown layout: " + cast_enum_to_str(l)); } } @@ -98,8 +98,8 @@ inline auto get_roc_index_base(index_base index) { case index_base::zero: return rocsparse_index_base_zero; case index_base::one: return rocsparse_index_base_one; default: - throw oneapi::mkl::invalid_argument("sparse_blas", "get_roc_index_base", - "Unknown index_base: " + cast_enum_to_str(index)); + throw oneapi::math::invalid_argument("sparse_blas", "get_roc_index_base", + "Unknown index_base: " + cast_enum_to_str(index)); } } @@ -109,7 +109,7 @@ inline auto get_roc_operation(transpose op) { case transpose::trans: return rocsparse_operation_transpose; case transpose::conjtrans: return rocsparse_operation_conjugate_transpose; default: - throw oneapi::mkl::invalid_argument( + throw oneapi::math::invalid_argument( "sparse_blas", "get_roc_operation", "Unknown transpose operation: " + cast_enum_to_str(op)); } @@ -120,8 +120,8 @@ inline auto get_roc_uplo(uplo uplo_val) { case uplo::upper: return rocsparse_fill_mode_upper; case uplo::lower: return rocsparse_fill_mode_lower; default: - throw oneapi::mkl::invalid_argument("sparse_blas", "get_roc_uplo", - "Unknown uplo: " + cast_enum_to_str(uplo_val)); + throw oneapi::math::invalid_argument("sparse_blas", "get_roc_uplo", + "Unknown uplo: " + cast_enum_to_str(uplo_val)); } } @@ -130,13 +130,13 @@ inline auto get_roc_diag(diag diag_val) { case diag::nonunit: return rocsparse_diag_type_non_unit; case diag::unit: return rocsparse_diag_type_unit; default: - throw oneapi::mkl::invalid_argument("sparse_blas", "get_roc_diag", - "Unknown diag: " + cast_enum_to_str(diag_val)); + throw oneapi::math::invalid_argument("sparse_blas", "get_roc_diag", + "Unknown diag: " + cast_enum_to_str(diag_val)); } } inline void set_matrix_attributes(const std::string& func_name, rocsparse_spmat_descr roc_a, - oneapi::mkl::sparse::matrix_view A_view) { + oneapi::math::sparse::matrix_view A_view) { auto roc_fill_mode = get_roc_uplo(A_view.uplo_view); auto status = rocsparse_spmat_set_attribute(roc_a, rocsparse_spmat_fill_mode, &roc_fill_mode, sizeof(roc_fill_mode)); @@ -157,6 +157,6 @@ inline void set_pointer_mode(rocsparse_handle roc_handle, bool is_ptr_accessible : rocsparse_pointer_mode_device); } -} // namespace oneapi::mkl::sparse::rocsparse::detail +} // namespace oneapi::math::sparse::rocsparse::detail -#endif //_ONEMKL_SPARSE_BLAS_BACKENDS_ROCSPARSE_HELPER_HPP_ +#endif //_ONEMATH_SPARSE_BLAS_BACKENDS_ROCSPARSE_HELPER_HPP_ diff --git a/src/sparse_blas/backends/rocsparse/rocsparse_scope_handle.cpp b/src/sparse_blas/backends/rocsparse/rocsparse_scope_handle.cpp index 97011598a..b933b4ba4 100644 --- a/src/sparse_blas/backends/rocsparse/rocsparse_scope_handle.cpp +++ b/src/sparse_blas/backends/rocsparse/rocsparse_scope_handle.cpp @@ -23,7 +23,7 @@ #include "rocsparse_scope_handle.hpp" -namespace oneapi::mkl::sparse::rocsparse::detail { +namespace oneapi::math::sparse::rocsparse::detail { /** * Inserts a new element in the map if its key is unique. This new element @@ -32,7 +32,7 @@ namespace oneapi::mkl::sparse::rocsparse::detail { * takes place if no other element in the container has a key equivalent to * the one being emplaced (keys in a map container are unique). */ -#ifdef ONEAPI_ONEMKL_PI_INTERFACE_REMOVED +#ifdef ONEAPI_ONEMATH_PI_INTERFACE_REMOVED thread_local rocsparse_handle_container RocsparseScopedContextHandler::handle_helper = rocsparse_handle_container{}; @@ -91,7 +91,7 @@ std::pair RocsparseScopedContextHandler::get_hand auto hipDevice = ih.get_native_device(); hipCtx_t desired; HIP_ERROR_FUNC(hipDevicePrimaryCtxRetain, &desired, hipDevice); -#ifdef ONEAPI_ONEMKL_PI_INTERFACE_REMOVED +#ifdef ONEAPI_ONEMATH_PI_INTERFACE_REMOVED auto piPlacedContext_ = reinterpret_cast(desired); #else auto piPlacedContext_ = reinterpret_cast(desired); @@ -132,4 +132,4 @@ std::pair RocsparseScopedContextHandler::get_hand #pragma clang diagnostic pop -} // namespace oneapi::mkl::sparse::rocsparse::detail +} // namespace oneapi::math::sparse::rocsparse::detail diff --git a/src/sparse_blas/backends/rocsparse/rocsparse_scope_handle.hpp b/src/sparse_blas/backends/rocsparse/rocsparse_scope_handle.hpp index c32e13132..3cb72f455 100644 --- a/src/sparse_blas/backends/rocsparse/rocsparse_scope_handle.hpp +++ b/src/sparse_blas/backends/rocsparse/rocsparse_scope_handle.hpp @@ -16,8 +16,8 @@ * limitations under the License. * **************************************************************************/ -#ifndef _ONEMKL_SPARSE_BLAS_BACKENDS_ROCSPARSE_SCOPE_HANDLE_HPP_ -#define _ONEMKL_SPARSE_BLAS_BACKENDS_ROCSPARSE_SCOPE_HANDLE_HPP_ +#ifndef _ONEMATH_SPARSE_BLAS_BACKENDS_ROCSPARSE_SCOPE_HANDLE_HPP_ +#define _ONEMATH_SPARSE_BLAS_BACKENDS_ROCSPARSE_SCOPE_HANDLE_HPP_ /** * @file Similar to rocblas_scope_handle.hpp @@ -30,8 +30,8 @@ #endif // After Plugin Interface removal in DPC++ ur.hpp is the new include -#if __has_include() && !defined(ONEAPI_ONEMKL_PI_INTERFACE_REMOVED) -#define ONEAPI_ONEMKL_PI_INTERFACE_REMOVED +#if __has_include() && !defined(ONEAPI_ONEMATH_PI_INTERFACE_REMOVED) +#define ONEAPI_ONEMATH_PI_INTERFACE_REMOVED #endif #include @@ -40,7 +40,7 @@ #include "rocsparse_global_handle.hpp" #include "rocsparse_helper.hpp" -namespace oneapi::mkl::sparse::rocsparse::detail { +namespace oneapi::math::sparse::rocsparse::detail { template struct rocsparse_handle_container { @@ -57,7 +57,7 @@ class RocsparseScopedContextHandler { sycl::context* placedContext_; sycl::interop_handle& ih; bool needToRecover_; -#ifdef ONEAPI_ONEMKL_PI_INTERFACE_REMOVED +#ifdef ONEAPI_ONEMATH_PI_INTERFACE_REMOVED static thread_local rocsparse_handle_container handle_helper; #else static thread_local rocsparse_handle_container handle_helper; @@ -82,6 +82,6 @@ inline void* get_mem(sycl::interop_handle ih, AccT acc) { return reinterpret_cast(hipPtr); } -} // namespace oneapi::mkl::sparse::rocsparse::detail +} // namespace oneapi::math::sparse::rocsparse::detail -#endif //_ONEMKL_SPARSE_BLAS_BACKENDS_ROCSPARSE_SCOPE_HANDLE_HPP_ +#endif //_ONEMATH_SPARSE_BLAS_BACKENDS_ROCSPARSE_SCOPE_HANDLE_HPP_ diff --git a/src/sparse_blas/backends/rocsparse/rocsparse_task.hpp b/src/sparse_blas/backends/rocsparse/rocsparse_task.hpp index 5b94c7f7b..29a4ef901 100644 --- a/src/sparse_blas/backends/rocsparse/rocsparse_task.hpp +++ b/src/sparse_blas/backends/rocsparse/rocsparse_task.hpp @@ -17,13 +17,13 @@ * **************************************************************************/ -#ifndef _ONEMKL_SPARSE_BLAS_BACKENDS_ROCSPARSE_TASK_HPP_ -#define _ONEMKL_SPARSE_BLAS_BACKENDS_ROCSPARSE_TASK_HPP_ +#ifndef _ONEMATH_SPARSE_BLAS_BACKENDS_ROCSPARSE_TASK_HPP_ +#define _ONEMATH_SPARSE_BLAS_BACKENDS_ROCSPARSE_TASK_HPP_ #include "rocsparse_error.hpp" #include "sparse_blas/backends/common_launch_task.hpp" -namespace oneapi::mkl::sparse::rocsparse::detail { +namespace oneapi::math::sparse::rocsparse::detail { // Helper function for functors submitted to host_task or native_command. // When the extension is disabled, host_task are used and the synchronization is needed to ensure the sycl::event corresponds to the end of the whole functor. @@ -39,6 +39,6 @@ inline void synchronize_if_needed(bool is_in_order_queue, hipStream_t hip_stream #endif } -} // namespace oneapi::mkl::sparse::rocsparse::detail +} // namespace oneapi::math::sparse::rocsparse::detail -#endif // _ONEMKL_SPARSE_BLAS_BACKENDS_ROCSPARSE_TASK_HPP_ +#endif // _ONEMATH_SPARSE_BLAS_BACKENDS_ROCSPARSE_TASK_HPP_ diff --git a/src/sparse_blas/backends/rocsparse/rocsparse_wrappers.cpp b/src/sparse_blas/backends/rocsparse/rocsparse_wrappers.cpp index eaa8d82d2..0c23372d8 100644 --- a/src/sparse_blas/backends/rocsparse/rocsparse_wrappers.cpp +++ b/src/sparse_blas/backends/rocsparse/rocsparse_wrappers.cpp @@ -17,16 +17,16 @@ * **************************************************************************/ -#include "oneapi/mkl/sparse_blas/types.hpp" +#include "oneapi/math/sparse_blas/types.hpp" -#include "oneapi/mkl/sparse_blas/detail/rocsparse/onemkl_sparse_blas_rocsparse.hpp" +#include "oneapi/math/sparse_blas/detail/rocsparse/onemath_sparse_blas_rocsparse.hpp" #include "sparse_blas/function_table.hpp" #define WRAPPER_VERSION 1 #define BACKEND rocsparse -extern "C" sparse_blas_function_table_t mkl_sparse_blas_table = { +extern "C" sparse_blas_function_table_t onemath_sparse_blas_table = { WRAPPER_VERSION, #include "sparse_blas/backends/backend_wrappers.cxx" }; diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt index cddb0a9c1..e335d4315 100644 --- a/tests/unit_tests/CMakeLists.txt +++ b/tests/unit_tests/CMakeLists.txt @@ -198,8 +198,8 @@ foreach(domain ${TEST_TARGET_DOMAINS}) endif() if(domain STREQUAL "sparse_blas" AND ENABLE_ROCSPARSE_BACKEND) - add_dependencies(test_main_${domain}_ct onemkl_${domain}_rocsparse) - list(APPEND ONEMKL_LIBRARIES_${domain} onemkl_${domain}_rocsparse) + add_dependencies(test_main_${domain}_ct onemath_${domain}_rocsparse) + list(APPEND ONEMATH_LIBRARIES_${domain} onemath_${domain}_rocsparse) endif() target_link_libraries(test_main_${domain}_ct PUBLIC diff --git a/tests/unit_tests/include/test_helper.hpp b/tests/unit_tests/include/test_helper.hpp index 3293d6f7f..f91d71d96 100644 --- a/tests/unit_tests/include/test_helper.hpp +++ b/tests/unit_tests/include/test_helper.hpp @@ -183,9 +183,9 @@ #define TEST_RUN_NVIDIAGPU_CUSPARSE_SELECT(q, func, ...) #endif -#ifdef ONEMKL_ENABLE_ROCSPARSE_BACKEND +#ifdef ONEMATH_ENABLE_ROCSPARSE_BACKEND #define TEST_RUN_AMDGPU_ROCSPARSE_SELECT(q, func, ...) \ - func(oneapi::mkl::backend_selector{ q }, __VA_ARGS__) + func(oneapi::math::backend_selector{ q }, __VA_ARGS__) #else #define TEST_RUN_AMDGPU_ROCSPARSE_SELECT(q, func, ...) #endif diff --git a/tests/unit_tests/main_test.cpp b/tests/unit_tests/main_test.cpp index c2def0a09..bcc0bec38 100644 --- a/tests/unit_tests/main_test.cpp +++ b/tests/unit_tests/main_test.cpp @@ -135,7 +135,8 @@ int main(int argc, char** argv) { #if !defined(ONEMATH_ENABLE_ROCBLAS_BACKEND) && !defined(ONEMATH_ENABLE_ROCRAND_BACKEND) && \ !defined(ONEMATH_ENABLE_ROCSOLVER_BACKEND) && \ !defined(ONEMATH_ENABLE_PORTBLAS_BACKEND_AMD_GPU) && \ - !defined(ONEMATH_ENABLE_ROCFFT_BACKEND) && !defined(ONEMATH_ENABLE_PORTFFT_BACKEND) && !defined(ONEMATH_ENABLE_ROCSPARSE_BACKEND) + !defined(ONEMATH_ENABLE_ROCFFT_BACKEND) && !defined(ONEMATH_ENABLE_PORTFFT_BACKEND) && \ + !defined(ONEMATH_ENABLE_ROCSPARSE_BACKEND) if (dev.is_gpu() && vendor_id == AMD_ID) continue; #endif