Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions onemath/sycl/blas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# *
# **************************************************************************/
cmake_minimum_required(VERSION 3.4.3)
project(blas VERSION 0.1.0 LANGUAGES CXX)
project(blas VERSION 0.2.0 LANGUAGES CXX)

if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
Expand Down Expand Up @@ -63,14 +63,18 @@ set(ONEMATH_SYCL_BLAS_INSTALL_SRC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/

option(BLAS_ENABLE_EXTENSIONS "Whether to enable BLAS extensions" ON)
option(BLAS_ENABLE_COMPLEX "Whether to enable complex data type for GEMM" ON)
option(BLAS_ENABLE_USM "Whether to enable USM API" ON)
option(BLAS_ENABLE_HALF "Whether to enable sycl::half data type for supported operators" ON)

if (SYCL_COMPILER MATCHES "adaptivecpp")
if (SYCL_COMPILER MATCHES "adaptivecpp" OR ${CMAKE_CXX_COMPILER} MATCHES "acpp|syclcc")
if(BLAS_ENABLE_COMPLEX)
message(STATUS "SYCL Complex data is not supported on AdaptiveCpp/hipSYCL. Complex
data type is disabled")
message(STATUS "SYCL Complex data is not supported on AdaptiveCpp/hipSYCL. Complex data type is disabled")
set(BLAS_ENABLE_COMPLEX OFF)
endif()
if (BLAS_ENABLE_USM)
message(STATUS "USM API is not supported on AdaptiveCpp/hipSYCL. USM API is disabled")
set(BLAS_ENABLE_USM OFF)
endif()
endif()

add_library(onemath_sycl_blas INTERFACE)
Expand All @@ -79,7 +83,6 @@ set_target_properties(onemath_sycl_blas PROPERTIES
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-fsycl" is_dpcpp)
if(is_dpcpp)
target_compile_definitions(onemath_sycl_blas INTERFACE "SB_ENABLE_USM")
check_cxx_compiler_flag("-mllvm=-enable-global-offset=false" support_disable_global_offset)
if (${support_disable_global_offset})
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM"
Expand All @@ -95,6 +98,9 @@ endif()
if(${BLAS_ENABLE_COMPLEX})
target_compile_definitions(onemath_sycl_blas INTERFACE "BLAS_ENABLE_COMPLEX")
endif()
if(${BLAS_ENABLE_USM})
target_compile_definitions(onemath_sycl_blas INTERFACE "SB_ENABLE_USM")
endif()
target_compile_definitions(onemath_sycl_blas INTERFACE ${TUNING_TARGET})
target_compile_options(onemath_sycl_blas INTERFACE -Wno-deprecated-declarations)
target_compile_options(onemath_sycl_blas INTERFACE -Wno-deprecated-copy-with-user-provided-copy)
Expand All @@ -107,15 +113,24 @@ if((${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM") AND NOT
endif()

include(CMakePackageConfigHelpers)
set(version_file "${CMAKE_CURRENT_BINARY_DIR}/cmake/onemath_sycl_blas-version.cmake")
set(version_file "${CMAKE_CURRENT_BINARY_DIR}/cmake/onemath_sycl_blas-config-version.cmake")
set(config_file "${CMAKE_CURRENT_BINARY_DIR}/cmake/onemath_sycl_blas-config.cmake")
set(targets_name "onemath_sycl_blas-targets")
write_basic_package_version_file(${version_file}
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(
cmake/config.cmake.in
${config_file}
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}
)
install(FILES ${version_file} ${config_file}
DESTINATION ${CMAKE_INSTALL_PREFIX})

include(GNUInstallDirs)
install(TARGETS onemath_sycl_blas
EXPORT onemath_sycl_blas
EXPORT ${targets_name}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand All @@ -132,16 +147,9 @@ install(DIRECTORY ${ONEMATH_SYCL_BLAS_INCLUDE}
FILES_MATCHING PATTERN "*.hpp"
)

install(FILES ${version_file} DESTINATION ${CMAKE_INSTALL_PREFIX})
install(EXPORT onemath_sycl_blas
install(EXPORT ${targets_name}
DESTINATION ${CMAKE_INSTALL_PREFIX}
NAMESPACE ONEMATH_SYCL_BLAS::
FILE onemath_sycl_blas-config.cmake
)

export(EXPORT onemath_sycl_blas
NAMESPACE ONEMATH_SYCL_BLAS::
FILE onemath_sycl_blas-config.cmake
)

option(BLAS_ENABLE_CONST_INPUT "Whether to enable kernel instantiation with const input buffer" ON)
27 changes: 27 additions & 0 deletions onemath/sycl/blas/cmake/config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#/***************************************************************************
# *
# * @license
# * Copyright (C) Codeplay Software Limited
# * Licensed under the Apache License, Version 2.0 (the "License");
# * you may not use this file except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.apache.org/licenses/LICENSE-2.0
# *
# * For your convenience, a copy of the License has been included in this
# * repository.
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *
# *
# *
# **************************************************************************/
@PACKAGE_INIT@
set(BLAS_ENABLE_COMPLEX "@BLAS_ENABLE_COMPLEX@")
set(BLAS_ENABLE_USM "@BLAS_ENABLE_USM@")

include("${CMAKE_CURRENT_LIST_DIR}/@targets_name@.cmake")
21 changes: 0 additions & 21 deletions onemath/sycl/blas/include/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,6 @@ using add_const = typename std::conditional<
typename std::remove_pointer<container_t>::type>::type>::type,
container_t>::type;

template <typename container_t>
typename std::enable_if<std::is_same<
container_t, typename AllocHelper<typename ValueType<container_t>::type,
AllocType::usm>::type>::value>::type
enqueue_deallocate(std::vector<sycl::event> dependencies, container_t mem,
sycl::queue q) {
#ifdef SB_ENABLE_USM
auto event = q.submit([&](sycl::handler &cgh) {
cgh.depends_on(dependencies);
cgh.host_task([=]() { sycl::free(mem, q); });
});
#endif
return;
}

template <typename container_t>
typename std::enable_if<std::is_same<
container_t, typename AllocHelper<typename ValueType<container_t>::type,
AllocType::buffer>::type>::value>::type
enqueue_deallocate(std::vector<sycl::event>, container_t mem, sycl::queue q) {}

inline bool has_local_memory(sycl::queue &q) {
return (
q.get_device().template get_info<sycl::info::device::local_mem_type>() ==
Expand Down
15 changes: 14 additions & 1 deletion onemath/sycl/blas/src/operations/blas3/gemm_local.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ class Gemm<input_t, output_t, DoubleBuffer, NbcA, NbcB, ClSize, TileType,
element_t *reg, OutputPointerType out_ptr) {
vector_out_t out_vec{};

#ifdef BLAS_ENABLE_COMPLEX
// This if-statement is necessary starting from late 2024 nightly, because
// an update made casting raw pointers of sycl::complex to multi_ptr
// ambiguous.
Expand All @@ -542,14 +543,26 @@ class Gemm<input_t, output_t, DoubleBuffer, NbcA, NbcB, ClSize, TileType,

out_vec.template store<address_t::global_space,
sycl::access::decorated::legacy>(0, out_ptr);
} else {
} else
#endif
{
#ifdef __ADAPTIVECPP__
// AdaptiveCpp 24.10 doesn't support IsDecorated template parameter here
out_vec.template load<address_t::private_space>(
#else
out_vec.template load<address_t::private_space,
sycl::access::decorated::legacy>(
#endif
0, sycl::multi_ptr<const element_t, address_t::private_space>(reg));
out_vec *= alpha_;

#ifdef __ADAPTIVECPP__
// AdaptiveCpp 24.10 doesn't support IsDecorated template parameter here
out_vec.template store<address_t::global_space>(
#else
out_vec.template store<address_t::global_space,
sycl::access::decorated::legacy>(
#endif
0, sycl::multi_ptr<element_t, address_t::global_space>(out_ptr));
}
}
Expand Down