-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL][USM] Initial commit of flattening for kernel submission on queue #911
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0c23419
Initial commit of flattening for kernel submission on queue
jbrodman 068331a
Requested style changes
jbrodman 68ad9eb
Fix compile errors introduced by style changes
jbrodman f82bf87
Add single event versions and comments.
jbrodman 2b07f8a
Add doxygen style comments
jbrodman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,66 @@ | ||
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda %s -o %t1.out | ||
// RUN: env SYCL_DEVICE_TYPE=HOST %t1.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t1.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t1.out | ||
|
||
//==--------------- pfor_flatten.cpp - Kernel Launch Flattening test -------==// | ||
// | ||
// 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 <CL/sycl.hpp> | ||
|
||
using namespace cl::sycl; | ||
|
||
class foo; | ||
int main() { | ||
int *array = nullptr; | ||
const int N = 42; | ||
const int MAGIC_NUM = 42; | ||
|
||
queue q; | ||
auto ctxt = q.get_context(); | ||
|
||
array = (int *)malloc_host(N * sizeof(int), q); | ||
if (array == nullptr) { | ||
return -1; | ||
} | ||
|
||
range<1> R{N}; | ||
auto e1 = q.parallel_for(R, [=](id<1> ID) { | ||
int i = ID[0]; | ||
array[i] = MAGIC_NUM-4; | ||
}); | ||
|
||
|
||
auto e2 = q.parallel_for(R, e1, [=](id<1> ID) { | ||
int i = ID[0]; | ||
array[i] += 2; | ||
}); | ||
|
||
auto e3 = | ||
q.parallel_for(nd_range<1>{R, range<1>{1}}, {e1, e2}, [=](nd_item<1> ID) { | ||
int i = ID.get_global_id(0); | ||
array[i]++; | ||
}); | ||
|
||
q.single_task({e3}, [=]() { | ||
for (int i = 0; i < N; i++) { | ||
array[i]++; | ||
} | ||
}); | ||
|
||
q.wait(); | ||
|
||
for (int i = 0; i < N; i++) { | ||
if (array[i] != MAGIC_NUM) { | ||
return -1; | ||
} | ||
} | ||
free(array, ctxt); | ||
|
||
return 0; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.