Skip to content

Commit badb379

Browse files
authored
Fix BLAS compilation with AdaptiveCpp and export CMake options
2 parents e69a355 + 6ff15e7 commit badb379

File tree

4 files changed

+64
-37
lines changed

4 files changed

+64
-37
lines changed

onemath/sycl/blas/CMakeLists.txt

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# *
2222
# **************************************************************************/
2323
cmake_minimum_required(VERSION 3.4.3)
24-
project(blas VERSION 0.1.0 LANGUAGES CXX)
24+
project(blas VERSION 0.2.0 LANGUAGES CXX)
2525

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

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

68-
if (SYCL_COMPILER MATCHES "adaptivecpp")
69+
if (SYCL_COMPILER MATCHES "adaptivecpp" OR ${CMAKE_CXX_COMPILER} MATCHES "acpp|syclcc")
6970
if(BLAS_ENABLE_COMPLEX)
70-
message(STATUS "SYCL Complex data is not supported on AdaptiveCpp/hipSYCL. Complex
71-
data type is disabled")
71+
message(STATUS "SYCL Complex data is not supported on AdaptiveCpp/hipSYCL. Complex data type is disabled")
7272
set(BLAS_ENABLE_COMPLEX OFF)
7373
endif()
74+
if (BLAS_ENABLE_USM)
75+
message(STATUS "USM API is not supported on AdaptiveCpp/hipSYCL. USM API is disabled")
76+
set(BLAS_ENABLE_USM OFF)
77+
endif()
7478
endif()
7579

7680
add_library(onemath_sycl_blas INTERFACE)
@@ -79,7 +83,6 @@ set_target_properties(onemath_sycl_blas PROPERTIES
7983
include(CheckCXXCompilerFlag)
8084
check_cxx_compiler_flag("-fsycl" is_dpcpp)
8185
if(is_dpcpp)
82-
target_compile_definitions(onemath_sycl_blas INTERFACE "SB_ENABLE_USM")
8386
check_cxx_compiler_flag("-mllvm=-enable-global-offset=false" support_disable_global_offset)
8487
if (${support_disable_global_offset})
8588
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM"
@@ -95,6 +98,9 @@ endif()
9598
if(${BLAS_ENABLE_COMPLEX})
9699
target_compile_definitions(onemath_sycl_blas INTERFACE "BLAS_ENABLE_COMPLEX")
97100
endif()
101+
if(${BLAS_ENABLE_USM})
102+
target_compile_definitions(onemath_sycl_blas INTERFACE "SB_ENABLE_USM")
103+
endif()
98104
target_compile_definitions(onemath_sycl_blas INTERFACE ${TUNING_TARGET})
99105
target_compile_options(onemath_sycl_blas INTERFACE -Wno-deprecated-declarations)
100106
target_compile_options(onemath_sycl_blas INTERFACE -Wno-deprecated-copy-with-user-provided-copy)
@@ -107,15 +113,24 @@ if((${CMAKE_CXX_COMPILER_ID} STREQUAL "IntelLLVM") AND NOT
107113
endif()
108114

109115
include(CMakePackageConfigHelpers)
110-
set(version_file "${CMAKE_CURRENT_BINARY_DIR}/cmake/onemath_sycl_blas-version.cmake")
116+
set(version_file "${CMAKE_CURRENT_BINARY_DIR}/cmake/onemath_sycl_blas-config-version.cmake")
117+
set(config_file "${CMAKE_CURRENT_BINARY_DIR}/cmake/onemath_sycl_blas-config.cmake")
118+
set(targets_name "onemath_sycl_blas-targets")
111119
write_basic_package_version_file(${version_file}
112120
VERSION ${PROJECT_VERSION}
113121
COMPATIBILITY AnyNewerVersion
114122
)
123+
configure_package_config_file(
124+
cmake/config.cmake.in
125+
${config_file}
126+
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}
127+
)
128+
install(FILES ${version_file} ${config_file}
129+
DESTINATION ${CMAKE_INSTALL_PREFIX})
115130

116131
include(GNUInstallDirs)
117132
install(TARGETS onemath_sycl_blas
118-
EXPORT onemath_sycl_blas
133+
EXPORT ${targets_name}
119134
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
120135
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
121136
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -132,16 +147,9 @@ install(DIRECTORY ${ONEMATH_SYCL_BLAS_INCLUDE}
132147
FILES_MATCHING PATTERN "*.hpp"
133148
)
134149

135-
install(FILES ${version_file} DESTINATION ${CMAKE_INSTALL_PREFIX})
136-
install(EXPORT onemath_sycl_blas
150+
install(EXPORT ${targets_name}
137151
DESTINATION ${CMAKE_INSTALL_PREFIX}
138152
NAMESPACE ONEMATH_SYCL_BLAS::
139-
FILE onemath_sycl_blas-config.cmake
140-
)
141-
142-
export(EXPORT onemath_sycl_blas
143-
NAMESPACE ONEMATH_SYCL_BLAS::
144-
FILE onemath_sycl_blas-config.cmake
145153
)
146154

147155
option(BLAS_ENABLE_CONST_INPUT "Whether to enable kernel instantiation with const input buffer" ON)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#/***************************************************************************
2+
# *
3+
# * @license
4+
# * Copyright (C) Codeplay Software Limited
5+
# * Licensed under the Apache License, Version 2.0 (the "License");
6+
# * you may not use this file except in compliance with the License.
7+
# * You may obtain a copy of the License at
8+
# *
9+
# * http://www.apache.org/licenses/LICENSE-2.0
10+
# *
11+
# * For your convenience, a copy of the License has been included in this
12+
# * repository.
13+
# *
14+
# * Unless required by applicable law or agreed to in writing, software
15+
# * distributed under the License is distributed on an "AS IS" BASIS,
16+
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
# * See the License for the specific language governing permissions and
18+
# * limitations under the License.
19+
# *
20+
# *
21+
# *
22+
# **************************************************************************/
23+
@PACKAGE_INIT@
24+
set(BLAS_ENABLE_COMPLEX "@BLAS_ENABLE_COMPLEX@")
25+
set(BLAS_ENABLE_USM "@BLAS_ENABLE_USM@")
26+
27+
include("${CMAKE_CURRENT_LIST_DIR}/@targets_name@.cmake")

onemath/sycl/blas/include/helper.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -88,27 +88,6 @@ using add_const = typename std::conditional<
8888
typename std::remove_pointer<container_t>::type>::type>::type,
8989
container_t>::type;
9090

91-
template <typename container_t>
92-
typename std::enable_if<std::is_same<
93-
container_t, typename AllocHelper<typename ValueType<container_t>::type,
94-
AllocType::usm>::type>::value>::type
95-
enqueue_deallocate(std::vector<sycl::event> dependencies, container_t mem,
96-
sycl::queue q) {
97-
#ifdef SB_ENABLE_USM
98-
auto event = q.submit([&](sycl::handler &cgh) {
99-
cgh.depends_on(dependencies);
100-
cgh.host_task([=]() { sycl::free(mem, q); });
101-
});
102-
#endif
103-
return;
104-
}
105-
106-
template <typename container_t>
107-
typename std::enable_if<std::is_same<
108-
container_t, typename AllocHelper<typename ValueType<container_t>::type,
109-
AllocType::buffer>::type>::value>::type
110-
enqueue_deallocate(std::vector<sycl::event>, container_t mem, sycl::queue q) {}
111-
11291
inline bool has_local_memory(sycl::queue &q) {
11392
return (
11493
q.get_device().template get_info<sycl::info::device::local_mem_type>() ==

onemath/sycl/blas/src/operations/blas3/gemm_local.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ class Gemm<input_t, output_t, DoubleBuffer, NbcA, NbcB, ClSize, TileType,
527527
element_t *reg, OutputPointerType out_ptr) {
528528
vector_out_t out_vec{};
529529

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

543544
out_vec.template store<address_t::global_space,
544545
sycl::access::decorated::legacy>(0, out_ptr);
545-
} else {
546+
} else
547+
#endif
548+
{
549+
#ifdef __ADAPTIVECPP__
550+
// AdaptiveCpp 24.10 doesn't support IsDecorated template parameter here
551+
out_vec.template load<address_t::private_space>(
552+
#else
546553
out_vec.template load<address_t::private_space,
547554
sycl::access::decorated::legacy>(
555+
#endif
548556
0, sycl::multi_ptr<const element_t, address_t::private_space>(reg));
549557
out_vec *= alpha_;
550558

559+
#ifdef __ADAPTIVECPP__
560+
// AdaptiveCpp 24.10 doesn't support IsDecorated template parameter here
561+
out_vec.template store<address_t::global_space>(
562+
#else
551563
out_vec.template store<address_t::global_space,
552564
sycl::access::decorated::legacy>(
565+
#endif
553566
0, sycl::multi_ptr<element_t, address_t::global_space>(out_ptr));
554567
}
555568
}

0 commit comments

Comments
 (0)