Skip to content

Commit

Permalink
Apply changes to rename to oneMath
Browse files Browse the repository at this point in the history
  • Loading branch information
Rbiessy committed Dec 5, 2024
1 parent 7b3357e commit b878516
Show file tree
Hide file tree
Showing 23 changed files with 386 additions and 377 deletions.
8 changes: 4 additions & 4 deletions docs/domains/sparse_linear_algebra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
<https://rocm.docs.amd.com/projects/rocSPARSE/en/latest/how-to/basics.html#coo-storage-format>`_.
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
<https://rocm.docs.amd.com/projects/rocSPARSE/en/latest/how-to/basics.html#csr-storage-format>`_.
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
<https://github.com/ROCm/rocSPARSE/issues/332>`_.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion include/oneapi/math/detail/backends_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static std::map<domain, std::map<device, std::vector<const char*>>> libraries =
} },
{ device::amdgpu,
{
#ifdef ONEMKL_ENABLE_ROCSPARSE_BACKEND
#ifdef ONEMATH_ENABLE_ROCSPARSE_BACKEND
LIB_NAME("sparse_blas_rocsparse")
#endif
} } } },
Expand Down
3 changes: 3 additions & 0 deletions include/oneapi/math/sparse_blas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Original file line number Diff line number Diff line change
Expand Up @@ -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_
83 changes: 41 additions & 42 deletions src/sparse_blas/backends/common_launch_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T, typename Container>
auto get_value_accessor(sycl::handler& cgh, Container container) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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<FP_TYPE>(cgh, sm_handle, other_containers...); \
Expand Down Expand Up @@ -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<float>)
ONEMATH_SUBMIT_INT(std::complex<float>)
}
else if (value_type == data_type::complex_fp64) {
ONEMKL_SUBMIT_INT(std::complex<double>)
ONEMATH_SUBMIT_INT(std::complex<double>)
}

#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
Expand All @@ -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");
}
}
}
Expand All @@ -293,30 +292,30 @@ 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<FP_TYPE>(cgh, container_handle); \
submit_host_task(cgh, queue, functor, fp_accs); \
})

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<float>);
ONEMATH_SUBMIT(std::complex<float>);
}
else if (value_type == data_type::complex_fp64) {
ONEMKL_SUBMIT(std::complex<double>);
ONEMATH_SUBMIT(std::complex<double>);
}

#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) {
Expand Down Expand Up @@ -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_
20 changes: 10 additions & 10 deletions src/sparse_blas/backends/rocsparse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -31,36 +31,36 @@ add_library(${LIB_OBJ} OBJECT
operations/rocsparse_spsv.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: 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)

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
POSITION_INDEPENDENT_CODE ON
)
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()

Expand All @@ -73,8 +73,8 @@ set_target_properties(${LIB_NAME} PROPERTIES
list(APPEND CMAKE_BUILD_RPATH $<TARGET_FILE_DIR:${LIB_NAME}>)

# 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
Expand Down
Loading

0 comments on commit b878516

Please sign in to comment.