-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1126 from utwente-fmt/sycl-examples-and-bugfixes
More sycl examples and bugfixes
- Loading branch information
Showing
83 changed files
with
1,010 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// -*- tab-width:2 ; indent-tabs-mode:nil -*- | ||
//:: cases Overloading | ||
//:: tools silicon | ||
//:: verdict Pass | ||
|
||
//@ ensures \result == 1; | ||
int method(int number); | ||
|
||
//@ ensures \result == 2; | ||
int method(float number); | ||
|
||
//@ ensures \result == 3; | ||
int method(int number, int number2); | ||
|
||
void test() { | ||
//@ assert method(1) == 1; | ||
//@ assert method(1.0f) == 2; | ||
//@ assert method(1, 2) == 3; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <sycl/sycl.hpp> | ||
|
||
/*@ | ||
requires \pointer(a, 10, write); | ||
requires \pointer(b, 10, write); | ||
requires \pointer(c, 10, write); | ||
*/ | ||
void test(bool a[], int* b, float c[]) { | ||
sycl::buffer<bool, 1> aBuffer = sycl::buffer<bool>(a, sycl::range<1>(10)); | ||
sycl::buffer<int, 2> bBuffer = sycl::buffer<int, 2>(b, sycl::range<2>(2, 5)); | ||
sycl::buffer<float, 3> cBuffer = sycl::buffer(c, sycl::range<3>(2, 5, 1)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <sycl/sycl.hpp> | ||
|
||
//@ requires \pointer(a, 10, write); | ||
void test(bool* a) { | ||
sycl::buffer<bool, 1> aBuffer = sycl::buffer(a, sycl::range<1>(-1)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <sycl/sycl.hpp> | ||
|
||
//@ requires \pointer(a, 10, read); | ||
void test(bool* a) { | ||
sycl::buffer<bool, 1> aBuffer = sycl::buffer(a, sycl::range<1>(10)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
#include <sycl/sycl.hpp> | ||
|
||
/*@ | ||
requires \pointer(a, 10, write); | ||
*/ | ||
//@ requires \pointer(a, 10, write); | ||
void test(bool* a) { | ||
sycl::buffer<bool, 1> aBuffer = sycl::buffer(a, sycl::range<1>(10)); | ||
|
||
bool x = a[5]; // Not allowed | ||
} |
6 changes: 1 addition & 5 deletions
6
...ncepts/sycl/buffers/ReleaseFromBuffer.cpp → ...ts/sycl/buffers/ReleaseDataFromBuffer.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
.../concepts/sycl/buffers/TooSmallBuffer.cpp → ...s/concepts/sycl/buffers/SmallerBuffer.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
#include <sycl/sycl.hpp> | ||
|
||
/*@ | ||
requires \pointer(a, 10, write); | ||
*/ | ||
//@ requires \pointer(a, 10, write); | ||
void test(bool* a) { | ||
sycl::buffer<bool, 1> aBuffer = sycl::buffer(a, sycl::range<1>(11)); // Buffer to big, so should fail | ||
// a is only guaranteed to have 10 elements, so cannot make buffer with 11 | ||
sycl::buffer<bool, 1> aBuffer = sycl::buffer(a, sycl::range<1>(11)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
examples/concepts/sycl/buffers/UnfoldingExclusiveHostDataAccessPredicate.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
examples/concepts/sycl/buffers/WrongGenericArgumentForConstructorHostdataType.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <sycl/sycl.hpp> | ||
|
||
//@ requires \pointer(a, 10, write); | ||
void test(bool a[]) { | ||
sycl::buffer<int>(a, sycl::range<1>(10)); | ||
} |
6 changes: 6 additions & 0 deletions
6
examples/concepts/sycl/buffers/WrongGenericArgumentForConstructorRangeType1.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <sycl/sycl.hpp> | ||
|
||
//@ requires \pointer(a, 10, write); | ||
void test(bool a[]) { | ||
sycl::buffer<bool, 2>(a, sycl::range<1>(10)); | ||
} |
7 changes: 7 additions & 0 deletions
7
examples/concepts/sycl/buffers/WrongGenericArgumentForConstructorRangeType2.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include <sycl/sycl.hpp> | ||
|
||
//@ requires \pointer(a, 10, write); | ||
void test(bool a[]) { | ||
// generic arg <int> will be expanded to <int, 1> | ||
sycl::buffer<int>(a, sycl::range<2>(10)); | ||
} |
6 changes: 6 additions & 0 deletions
6
examples/concepts/sycl/buffers/WrongGenericArgumentForHostdataType.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <sycl/sycl.hpp> | ||
|
||
//@ requires \pointer(a, 10, write); | ||
void test(bool a[]) { | ||
sycl::buffer<int, 1> aBuffer = sycl::buffer(a, sycl::range<1>(10)); | ||
} |
6 changes: 6 additions & 0 deletions
6
examples/concepts/sycl/buffers/WrongGenericArgumentForRangeType.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <sycl/sycl.hpp> | ||
|
||
//@ requires \pointer(a, 10, write); | ||
void test(bool a[]) { | ||
sycl::buffer<bool, 2> aBuffer = sycl::buffer(a, sycl::range<1>(10)); | ||
} |
47 changes: 47 additions & 0 deletions
47
examples/concepts/sycl/dataAccessors/AccessorDeclarations.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <sycl/sycl.hpp> | ||
|
||
/*@ | ||
requires \pointer(a, 12, write); | ||
requires \pointer(b, 12, write); | ||
requires \pointer(c, 12, write); | ||
requires \pointer(d, 12, write); | ||
*/ | ||
void test(int* a, int* b, int* c, int* d) { | ||
sycl::queue myQueue; | ||
|
||
sycl::buffer<int, 1> aBuffer = sycl::buffer(a, sycl::range<1>(12)); | ||
sycl::buffer<int, 2> bBuffer = sycl::buffer(b, sycl::range<2>(3, 4)); | ||
sycl::buffer<int, 3> cBuffer = sycl::buffer(c, sycl::range<3>(2, 3, 2)); | ||
sycl::buffer<int, 1> dBuffer = sycl::buffer(d, sycl::range<1>(12)); | ||
|
||
myQueue.submit( | ||
[&](sycl::handler& cgh) { | ||
|
||
sycl::accessor<int, 1, sycl::access_mode::read> a_accessor = sycl::accessor(aBuffer, cgh, sycl::read_only); | ||
sycl::accessor<int, 2> b_accessor = sycl::accessor(bBuffer, cgh, sycl::read_write); | ||
sycl::accessor<int, 2, sycl::access_mode::read_write> bb_accessor = sycl::accessor<int, 2>(bBuffer, cgh, sycl::read_write); | ||
sycl::accessor<int, 2, sycl::access_mode::read_write> bbb_accessor = sycl::accessor<int, 2, sycl::access_mode::read_write>(bBuffer, cgh, sycl::read_write); | ||
sycl::accessor<int, 3, sycl::access_mode::read> c_accessor = sycl::accessor(cBuffer, cgh, sycl::read_only); | ||
sycl::accessor<int, 3, sycl::access_mode::read> ccc_accessor = sycl::accessor<int, 3, sycl::access_mode::read>(cBuffer, cgh, sycl::read_only); | ||
sycl::accessor<int, 1> d_accessor = sycl::accessor<int>(dBuffer, cgh, sycl::read_write); | ||
|
||
cgh.parallel_for(sycl::range<1>(1), | ||
/*@ | ||
context 1 < a_accessor.get_range().get(0); | ||
context 1 < b_accessor.get_range().get(0); | ||
context 2 < b_accessor.get_range().get(1); | ||
context 1 < c_accessor.get_range().get(0); | ||
context 2 < c_accessor.get_range().get(1); | ||
context 1 < c_accessor.get_range().get(2); | ||
context it.get_range(0) == 1; | ||
context Perm(a_accessor[1], read); | ||
context Perm(b_accessor[1][2], write); | ||
context Perm(c_accessor[1][2][1], read); | ||
*/ | ||
[=] (sycl::item<1> it) { | ||
b_accessor[1][2] = c_accessor[1][2][1] + a_accessor[1]; | ||
} | ||
); | ||
} | ||
); | ||
} |
File renamed without changes.
File renamed without changes.
7 changes: 2 additions & 5 deletions
7
.../AccessorGetRangeDimensionOutOfBounds.cpp → ...cessors/GetRangeDimensionOutOfBounds1.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
examples/concepts/sycl/dataAccessors/GetRangeDimensionOutOfBounds2.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <sycl/sycl.hpp> | ||
|
||
//@ requires \pointer(a, 6, write); | ||
void test(int* a) { | ||
sycl::queue myQueue; | ||
|
||
sycl::buffer<int, 2> aBuffer = sycl::buffer(a, sycl::range<2>(2, 3)); | ||
|
||
myQueue.submit( | ||
[&](sycl::handler& cgh) { | ||
|
||
sycl::accessor<int, 2, sycl::access_mode::read> a_accessor = sycl::accessor(aBuffer, cgh, sycl::read_only); | ||
|
||
cgh.parallel_for(sycl::range<2>(2, 3), | ||
[=] (sycl::item<2> it) { | ||
a_accessor.get_range().get(-1); // Dimension cannot be negative | ||
} | ||
); | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.