Skip to content

Commit

Permalink
Merge branch 'main' into KHRGA-70_DA_Accessors_BC
Browse files Browse the repository at this point in the history
  • Loading branch information
PetroBondar committed Nov 14, 2023
2 parents 6bb4497 + 93d240f commit 46b956b
Show file tree
Hide file tree
Showing 22 changed files with 1,263 additions and 273 deletions.
8 changes: 7 additions & 1 deletion source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ def make_ref(ref_str, ref_view, ref_sufix):
"#_unified_shared_memory_pointer_queries",
)
+ make_ref("SYCL_SPEC_USM_ALLOC", "Section 4.8.3", "#_usm_allocations")
+ make_ref("SYCL_BUFF_PROP", "Section 4.7.2.2", "#sec:buffer-properties")
+ make_ref(
"SYCL_SPEC_COMMON_REFERENCE",
"Section 4.5.2",
"#sec:reference-semantics",
)
+ make_ref(
"SYCL_SPEC_COMMON_BYVAL", "Section 4.5.3", "#sec:byval-semantics"
)
Expand All @@ -141,6 +147,7 @@ def make_ref(ref_str, ref_view, ref_sufix):
"Section 3.11.2",
"#sec:multi-dim-subscript",
)
+ make_ref("SYCL_SPEC_BUFFER", "Section 4.7.2", "#subsec:buffers")
+ f"""
.. _`SYCL Specification`: {sycl_ref_url}
.. |true| replace:: ``true``
Expand All @@ -149,7 +156,6 @@ def make_ref(ref_str, ref_view, ref_sufix):
.. _oneAPI: https://oneapi.com
.. _SYCL: https://www.khronos.org/sycl/
.. |SYCL_SPEC| replace:: `SYCL Specification`_
.. |SYCL_SPEC_BUFFER| replace:: `SYCL Specification`_ Section 4.7.2
.. |SYCL_SPEC_IMAGE| replace:: `SYCL Specification`_ Section 4.7.3
.. |SYCL_SPEC_BUFFER_ACCESSOR| replace:: `SYCL Specification`_ Section 4.7.6.9
.. |SYCL_SPEC_LOCAL_ACCESSOR| replace:: `SYCL Specification`_ Section 4.7.6.11
Expand Down
59 changes: 59 additions & 0 deletions source/examples/creating-sub-buffers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// SPDX-FileCopyrightText: 2023 The Khronos Group Inc.
//
// SPDX-License-Identifier: Apache-2.0

#include <sycl/sycl.hpp>

#include <iostream>

int main() {

// Create 2-d buffer with 8x8 ints
sycl::buffer<int, 2> parent_buffer{sycl::range<2>{8, 8}};

try {
// OK: Contiguous region from middle of buffer
sycl::buffer<int, 2> sub_buf1{parent_buffer,
/*offset*/ sycl::range<2>{2, 0},
/*size*/ sycl::range<2>{2, 8}};

std::cout << "sub_buf1 created successfully" << std::endl;
} catch (const sycl::exception &e) {
std::cerr << "Exception while creating sub_buf1: " << e.what() << std::endl;
}

try {
// invalid exception: Non-contiguous regions of 2-d buffer
sycl::buffer<int, 2> sub_buf2{parent_buffer,
/*offset*/ sycl::range<2>{2, 0},
/*size*/ sycl::range<2>{2, 2}};

std::cout << "sub_buf2 created successfully" << std::endl;
} catch (const sycl::exception &e) {
std::cerr << "Exception while creating sub_buf2: " << e.what() << std::endl;
}

try {
// invalid exception: Non-contiguous regions of 2-d buffer
sycl::buffer<int, 2> sub_buf3{parent_buffer,
/*offset*/ sycl::range<2>{2, 2},
/*size*/ sycl::range<2>{2, 6}};

std::cout << "sub_buf3 created successfully" << std::endl;
} catch (const sycl::exception &e) {
std::cerr << "Exception while creating sub_buf3: " << e.what() << std::endl;
}

try {
// invalid exception: Out-of-bounds size
sycl::buffer<int, 2> sub_buf4{parent_buffer,
/*offset*/ sycl::range<2>{2, 2},
/*size*/ sycl::range<2>{2, 8}};

std::cout << "sub_buf4 created successfully" << std::endl;
} catch (const sycl::exception &e) {
std::cerr << "Exception while creating sub_buf4: " << e.what() << std::endl;
}

return 0;
}
8 changes: 8 additions & 0 deletions source/examples/creating-sub-buffers.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-FileCopyrightText: 2020 The Khronos Group Inc.
#
# SPDX-License-Identifier: CC-BY-4.0

sub_buf1 created successfully
Exception while creating sub_buf2: Requested sub-buffer region is not contiguous -30 (PI_ERROR_INVALID_VALUE)
Exception while creating sub_buf3: Requested sub-buffer region is not contiguous -30 (PI_ERROR_INVALID_VALUE)
Exception while creating sub_buf4: Requested sub-buffer size exceeds the size of the parent buffer -30 (PI_ERROR_INVALID_VALUE)
Loading

0 comments on commit 46b956b

Please sign in to comment.