Skip to content

Work around sub_group load/store issues #1642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 20, 2024
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ set(CYTHON_FLAGS "-t -w \"${CMAKE_SOURCE_DIR}\"")
find_package(Cython REQUIRED)
find_package(Dpctl REQUIRED)

message(STATUS "Dpctl_INCLUDE_DIRS=" ${Dpctl_INCLUDE_DIRS})
message(STATUS "Dpctl_INCLUDE_DIR=" ${Dpctl_INCLUDE_DIR})
message(STATUS "Dpctl_TENSOR_INCLUDE_DIR=" ${Dpctl_TENSOR_INCLUDE_DIR})

if(WIN32)
Expand Down
2 changes: 2 additions & 0 deletions dpnp/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ target_compile_definitions(${_trgt} PUBLIC PSTL_USE_PARALLEL_POLICIES=0)
target_compile_definitions(${_trgt} PUBLIC ONEDPL_USE_PREDEFINED_POLICIES=0)

target_include_directories(${_trgt} PUBLIC ${Dpctl_INCLUDE_DIR})
target_include_directories(${_trgt} PUBLIC ${Dpctl_TENSOR_INCLUDE_DIR})

target_link_directories(${_trgt} PUBLIC "${Dpctl_INCLUDE_DIR}/..")
target_link_libraries(${_trgt} PUBLIC DPCTLSyclInterface)

Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/lapack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ set_target_properties(${python_module_name} PROPERTIES CMAKE_POSITION_INDEPENDEN
target_include_directories(${python_module_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include)
target_include_directories(${python_module_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../src)

target_include_directories(${python_module_name} PUBLIC ${Dpctl_INCLUDE_DIRS})
target_include_directories(${python_module_name} PUBLIC ${Dpctl_INCLUDE_DIR})
target_include_directories(${python_module_name} PUBLIC ${Dpctl_TENSOR_INCLUDE_DIR})

if (WIN32)
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/sycl_ext/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ set_target_properties(${python_module_name} PROPERTIES CMAKE_POSITION_INDEPENDEN
target_include_directories(${python_module_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include)
target_include_directories(${python_module_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../src)

target_include_directories(${python_module_name} PUBLIC ${Dpctl_INCLUDE_DIRS})
target_include_directories(${python_module_name} PUBLIC ${Dpctl_INCLUDE_DIR})
target_include_directories(${python_module_name} PUBLIC ${Dpctl_TENSOR_INCLUDE_DIR})

if (WIN32)
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/vm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ set_target_properties(${python_module_name} PROPERTIES CMAKE_POSITION_INDEPENDEN
target_include_directories(${python_module_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include)
target_include_directories(${python_module_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../src)

target_include_directories(${python_module_name} PUBLIC ${Dpctl_INCLUDE_DIRS})
target_include_directories(${python_module_name} PUBLIC ${Dpctl_INCLUDE_DIR})
target_include_directories(${python_module_name} PUBLIC ${Dpctl_TENSOR_INCLUDE_DIR})

if (WIN32)
Expand Down
11 changes: 10 additions & 1 deletion dpnp/backend/kernels/dpnp_krnl_bitwise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
#include "dpnpc_memory_adapter.hpp"
#include "queue_sycl.hpp"

// dpctl tensor headers
#include "kernels/alignment.hpp"

using dpctl::tensor::kernels::alignment_utils::is_aligned;
using dpctl::tensor::kernels::alignment_utils::required_alignment;

template <typename _KernelNameSpecialization>
class dpnp_invert_c_kernel;

Expand Down Expand Up @@ -67,7 +73,10 @@ DPCTLSyclEventRef dpnp_invert_c(DPCTLSyclQueueRef q_ref,
vec_sz * (nd_it.get_group(0) * nd_it.get_local_range(0) +
sg.get_group_id()[0] * max_sg_size);

if (start + static_cast<size_t>(vec_sz) * max_sg_size < size) {
if (is_aligned<required_alignment>(input_data) &&
is_aligned<required_alignment>(result) &&
(start + static_cast<size_t>(vec_sz) * max_sg_size < size))
{
auto input_multi_ptr = sycl::address_space_cast<
sycl::access::address_space::global_space,
sycl::access::decorated::yes>(&input_data[start]);
Expand Down
14 changes: 12 additions & 2 deletions dpnp/backend/kernels/dpnp_krnl_elemwise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
#include "dpnpc_memory_adapter.hpp"
#include "queue_sycl.hpp"

// dpctl tensor headers
#include "kernels/alignment.hpp"

using dpctl::tensor::kernels::alignment_utils::is_aligned;
using dpctl::tensor::kernels::alignment_utils::required_alignment;

#define MACRO_1ARG_2TYPES_OP(__name__, __operation1__, __operation2__) \
template <typename _KernelNameSpecialization1, \
typename _KernelNameSpecialization2> \
Expand Down Expand Up @@ -1198,8 +1204,12 @@ static void func_map_init_elemwise_1arg_1type(func_map_t &fmap)
(nd_it.get_group(0) * nd_it.get_local_range(0) + \
sg.get_group_id()[0] * max_sg_size); \
\
if (start + static_cast<size_t>(vec_sz) * max_sg_size < \
result_size) { \
if (is_aligned<required_alignment>(input1_data) && \
is_aligned<required_alignment>(input2_data) && \
is_aligned<required_alignment>(result) && \
(start + static_cast<size_t>(vec_sz) * max_sg_size < \
result_size)) \
{ \
auto input1_multi_ptr = sycl::address_space_cast< \
sycl::access::address_space::global_space, \
sycl::access::decorated::yes>( \
Expand Down
14 changes: 12 additions & 2 deletions dpnp/backend/kernels/dpnp_krnl_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
#include "dpnpc_memory_adapter.hpp"
#include "queue_sycl.hpp"

// dpctl tensor headers
#include "kernels/alignment.hpp"

using dpctl::tensor::kernels::alignment_utils::is_aligned;
using dpctl::tensor::kernels::alignment_utils::required_alignment;

template <typename _DataType, typename _ResultType>
class dpnp_all_c_kernel;

Expand Down Expand Up @@ -610,8 +616,12 @@ DPCTLSyclEventRef (*dpnp_any_ext_c)(DPCTLSyclQueueRef,
vec_sz * (nd_it.get_group(0) * nd_it.get_local_range(0) + \
sg.get_group_id()[0] * max_sg_size); \
\
if (start + static_cast<size_t>(vec_sz) * max_sg_size < \
result_size) { \
if (is_aligned<required_alignment>(input1_data) && \
is_aligned<required_alignment>(input2_data) && \
is_aligned<required_alignment>(result) && \
(start + static_cast<size_t>(vec_sz) * max_sg_size < \
result_size)) \
{ \
auto input1_multi_ptr = sycl::address_space_cast< \
sycl::access::address_space::global_space, \
sycl::access::decorated::yes>(&input1_data[start]); \
Expand Down
11 changes: 10 additions & 1 deletion dpnp/backend/kernels/dpnp_krnl_mathematical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
#include "dpnpc_memory_adapter.hpp"
#include "queue_sycl.hpp"

// dpctl tensor headers
#include "kernels/alignment.hpp"

using dpctl::tensor::kernels::alignment_utils::is_aligned;
using dpctl::tensor::kernels::alignment_utils::required_alignment;

static_assert(__SYCL_COMPILER_VERSION >= __SYCL_COMPILER_VECTOR_ABS_CHANGED,
"SYCL DPC++ compiler does not meet minimum version requirement");

Expand Down Expand Up @@ -163,7 +169,10 @@ DPCTLSyclEventRef
vec_sz * (nd_it.get_group(0) * nd_it.get_local_range(0) +
sg.get_group_id()[0] * max_sg_size);

if (start + static_cast<size_t>(vec_sz) * max_sg_size < size) {
if (is_aligned<required_alignment>(array1) &&
is_aligned<required_alignment>(result) &&
(start + static_cast<size_t>(vec_sz) * max_sg_size < size))
{
auto array_multi_ptr = sycl::address_space_cast<
sycl::access::address_space::global_space,
sycl::access::decorated::yes>(&array1[start]);
Expand Down