-
Notifications
You must be signed in to change notification settings - Fork 32
[SYClomatic-test] Add help function for Block Load header #619
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
Changes from 1 commit
c08ae48
513b103
d8b7cb7
be5eefe
66ec770
146c0d1
ec5d9a8
400f48d
5878cb7
022e628
ae0e1d6
d2ae0ee
23b7023
7c2ff7e
fe51693
c5447c0
d99a828
5ddb779
ab0277a
300ac08
9c21a36
7cd159c
2b54c4c
24e80cc
0f4c9ee
890d4ff
6ec45aa
3a5c119
8b42494
e79a7fc
68618bc
1905ed9
cf9fdd9
31382c1
5a5881b
7f6ed89
92650b8
1a9d205
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,17 +133,17 @@ | |
<test testName="onedpl_test_tagged_pointer" configFile="config/TEMPLATE_help_function_usm.xml" /> | ||
<test testName="onedpl_test_temporary_allocation" configFile="config/TEMPLATE_help_function_usm.xml" /> | ||
<test testName="onedpl_test_transform_if" configFile="config/TEMPLATE_help_function_skip_cuda_backend.xml" /> | ||
<!-- <test testName="onedpl_test_transform" configFile="config/TEMPLATE_help_function_skip_cuda_backend.xml" /> --> | ||
<test testName="onedpl_test_transform" configFile="config/TEMPLATE_help_function_skip_cuda_backend.xml" /> | ||
<test testName="onedpl_test_transform_output_iterator" configFile="config/TEMPLATE_help_function_skip_cuda_backend.xml" /> | ||
<test testName="onedpl_test_group_sort" configFile="config/TEMPLATE_help_function.xml" /> | ||
<test testName="onedpl_test_group_load" configFile="config/TEMPLATE_help_function.xml" /> | ||
<test testName="onedpl_test_transform_reduce" configFile="config/TEMPLATE_help_function_skip_double.xml" splitGroup="double" /> | ||
<!-- <test testName="onedpl_test_translate_key" configFile="config/TEMPLATE_help_function_skip_double.xml" splitGroup="double" /> --> | ||
<!-- <test testName="onedpl_test_uninitialized_fill" configFile="config/TEMPLATE_help_function_skip_cuda_backend.xml" /> --> | ||
<test testName="onedpl_test_unique_by_key_copy" configFile="config/TEMPLATE_help_function_skip_cuda_backend.xml" /> | ||
<test testName="onedpl_test_unique_by_key" configFile="config/TEMPLATE_help_function_skip_cuda_backend.xml" /> | ||
<test testName="onedpl_test_unique" configFile="config/TEMPLATE_help_function_skip_cuda_backend.xml" /> | ||
<test testName="onedpl_test_vector" configFile="config/TEMPLATE_help_function_skip_cuda_backend.xml" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's move this line back to its original position. |
||
<test testName="onedpl_test_group_exchange" configFile="config/TEMPLATE_help_function.xml" /> | ||
danhoeflinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<test testName="util_select_from_sub_group" configFile="config/TEMPLATE_help_function_usm.xml" /> | ||
<test testName="util_shift_sub_group_left" configFile="config/TEMPLATE_help_function_usm.xml" /> | ||
<test testName="util_shift_sub_group_right" configFile="config/TEMPLATE_help_function_usm.xml" /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// ====------ onedpl_test_group_load.cpp---------- -*- C++ -* ----===//// | ||
abhilash1910 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// | ||
// ===----------------------------------------------------------------------===// | ||
#include <sycl/sycl.hpp> | ||
#include <dpct/dpct.hpp> | ||
#include <dpct/dpl_utils.hpp> | ||
#include <iostream> | ||
|
||
|
||
bool helper_function(const int* ptr,const char* func_name){ | ||
danhoeflinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
int expected[512]; | ||
danhoeflinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for (int i = 0; i < 512; ++i) { | ||
expected[i] = i; | ||
} | ||
for (int i = 0; i < 512; ++i) { | ||
if (ptr[i] != expected[i]) { | ||
danhoeflinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
std::cout << func_name <<" failed\n"; | ||
std::ostream_iterator<int> Iter(std::cout, ", "); | ||
std::copy(ptr, ptr + 512, Iter); | ||
std::cout << std::endl; | ||
return false; | ||
} | ||
} | ||
|
||
std::cout << func_name <<" pass\n"; | ||
return true; | ||
} | ||
|
||
bool test_load_blocked() { | ||
abhilash1910 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sycl::queue q; | ||
int data[512]; | ||
for (int i = 0; i < 512; i++) data[i] = i; | ||
|
||
sycl::buffer<int, 1> buffer(data, 512); | ||
abhilash1910 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
q.submit([&](sycl::handler &h) { | ||
sycl::accessor dacc(buffer, h, sycl::read_write); | ||
h.parallel_for( | ||
sycl::nd_range<3>(sycl::range<3>(1, 1, 128), sycl::range<3>(1, 1, 128)), | ||
[=](sycl::nd_item<3> item) { | ||
int thread_data[4]; | ||
auto *d = dacc.get_multi_ptr<sycl::access::decorated::yes>().get(); | ||
dpct::group::load_blocked<128>(item.get_local_linear_id(), d, thread_data); | ||
}); | ||
}); | ||
q.wait_and_throw(); | ||
|
||
sycl::host_accessor data_accessor(buffer, sycl::read_only); | ||
const int *ptr = data_accessor.get_multi_ptr<sycl::access::decorated::yes>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a big deal from my side, but |
||
return helper_function(ptr,"test_load_blocked"); | ||
} | ||
|
||
bool test_load_striped() { | ||
danhoeflinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sycl::queue q; | ||
int data[512]; | ||
for (int i = 0; i < 512; i++) data[i] = i; | ||
|
||
sycl::buffer<int, 1> buffer(data, 512); | ||
q.submit([&](sycl::handler &h) { | ||
sycl::accessor dacc(buffer, h, sycl::read_write); | ||
h.parallel_for( | ||
sycl::nd_range<3>(sycl::range<3>(1, 1, 128), sycl::range<3>(1, 1, 128)), | ||
[=](sycl::nd_item<3> item) { | ||
int thread_data[4]; | ||
auto *d = dacc.get_multi_ptr<sycl::access::decorated::yes>().get(); | ||
dpct::group::load_striped<128>(item.get_local_linear_id(), d, thread_data); | ||
}); | ||
}); | ||
q.wait_and_throw(); | ||
|
||
sycl::host_accessor data_accessor(buffer, sycl::read_only); | ||
const int *ptr = data_accessor.get_multi_ptr<sycl::access::decorated::yes>(); | ||
return helper_function(ptr,"test_load_blocked"); | ||
} | ||
|
||
bool test_load_subgroup_striped() { | ||
sycl::queue q; | ||
abhilash1910 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
int data[512]; | ||
for (int i = 0; i < 512; i++) data[i] = i; | ||
|
||
sycl::buffer<int, 1> buffer(data, 512); | ||
q.submit([&](sycl::handler &h) { | ||
sycl::accessor dacc(buffer, h, sycl::read_write); | ||
h.parallel_for( | ||
sycl::nd_range<3>(sycl::range<3>(1, 1, 128), sycl::range<3>(1, 1, 128)), | ||
[=](sycl::nd_item<3> item) { | ||
int thread_data[4]; | ||
auto *d = dacc.get_multi_ptr<sycl::access::decorated::yes>().get(); | ||
dpct::group::load_subgroup_striped<128, item>(item, item.get_local_linear_id(), d, thread_data); | ||
}); | ||
}); | ||
q.wait_and_throw(); | ||
|
||
sycl::host_accessor data_accessor(buffer, sycl::read_only); | ||
const int *ptr = data_accessor.get_multi_ptr<sycl::access::decorated::yes>(); | ||
return helper_function(ptr,"test_load_blocked"); | ||
} | ||
|
||
|
||
int main() { | ||
return !(test_load_blocked() && test_load_striped() && test_load_warp_striped()); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.