-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL][USM] Fix queue::wait() behavior after USM operations (#1132)
Events for USM operations invoked as queue member functions were not associated with the queue. Signed-off-by: Sergey Semenov <sergey.semenov@intel.com>
- Loading branch information
1 parent
e8f1f29
commit 850fb9f
Showing
3 changed files
with
64 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// RUN: %clangxx -fsycl %s -o %t.out | ||
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
|
||
#include <CL/sycl.hpp> | ||
|
||
#include <cassert> | ||
#include <cstddef> | ||
|
||
using namespace cl::sycl; | ||
|
||
// This test checks that queue USM functions are properly waited for during | ||
// calls to queue::wait(). | ||
|
||
int main() { | ||
const std::size_t Size = 32; | ||
queue Q; | ||
std::cout << Q.is_host() << std::endl; | ||
device Dev = Q.get_device(); | ||
context Ctx = Q.get_context(); | ||
if (!(Dev.get_info<info::device::usm_device_allocations>() && | ||
Dev.get_info<info::device::usm_host_allocations>())) | ||
return 0; | ||
|
||
unsigned char *DevArr = (unsigned char *)malloc_device(Size, Dev, Ctx); | ||
assert(DevArr); | ||
unsigned char *HostArr = (unsigned char *)malloc_host(Size, Ctx); | ||
assert(HostArr); | ||
|
||
Q.memset(DevArr, 42, Size); | ||
Q.wait(); | ||
Q.memcpy(HostArr, DevArr, Size); | ||
Q.wait(); | ||
|
||
for (std::size_t i = 0; i < Size; ++i) | ||
assert(HostArr[i] == 42); | ||
|
||
free(DevArr, Ctx); | ||
free(HostArr, Ctx); | ||
|
||
return 0; | ||
} |