-
Notifications
You must be signed in to change notification settings - Fork 750
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Joshua Cranmer <joshua.cranmer@intel.com>
- Loading branch information
1 parent
866d634
commit feeacc1
Showing
10 changed files
with
190 additions
and
1 deletion.
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
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
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,89 @@ | ||
//==---- prefetch.cpp - USM prefetch 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// RUN: %clangxx -fsycl %s -o %t1.out -lOpenCL | ||
// RUN: env SYCL_DEVICE_TYPE=HOST %t1.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t1.out | ||
|
||
#include <CL/sycl.hpp> | ||
|
||
using namespace cl::sycl; | ||
|
||
static constexpr int count = 100; | ||
|
||
int main() { | ||
queue q([](exception_list el) { | ||
for (auto &e : el) | ||
throw e; | ||
}); | ||
float *src = (float*)malloc_shared(sizeof(float) * count, q.get_device(), | ||
q.get_context()); | ||
float *dest = (float*)malloc_shared(sizeof(float) * count, q.get_device(), | ||
q.get_context()); | ||
for (int i = 0; i < count; i++) | ||
src[i] = i; | ||
|
||
// Test handler::prefetch | ||
{ | ||
event init_prefetch = q.submit([&](handler &cgh) { | ||
cgh.prefetch(src, sizeof(float) * count); | ||
}); | ||
|
||
q.submit([&](handler &cgh) { | ||
cgh.depends_on(init_prefetch); | ||
cgh.single_task<class double_dest>([=]() { | ||
for (int i = 0; i < count; i++) | ||
dest[i] = 2 * src[i]; | ||
}); | ||
}); | ||
q.wait_and_throw(); | ||
|
||
for (int i = 0; i < count; i++) { | ||
assert(dest[i] == i * 2); | ||
} | ||
} | ||
|
||
// Test queue::prefetch | ||
{ | ||
event init_prefetch = q.prefetch(src, sizeof(float) * count); | ||
|
||
q.submit([&](handler &cgh) { | ||
cgh.depends_on(init_prefetch); | ||
cgh.single_task<class double_dest3>([=]() { | ||
for (int i = 0; i < count; i++) | ||
dest[i] = 3 * src[i]; | ||
}); | ||
}); | ||
q.wait_and_throw(); | ||
|
||
for (int i = 0; i < count; i++) { | ||
assert(dest[i] == i * 3); | ||
} | ||
} | ||
|
||
// Test ordered_queue::prefetch | ||
{ | ||
ordered_queue oq([](exception_list el) { | ||
for (auto &e : el) | ||
throw e; | ||
}); | ||
event init_prefetch = oq.prefetch(src, sizeof(float) * count); | ||
|
||
oq.submit([&](handler &cgh) { | ||
cgh.depends_on(init_prefetch); | ||
cgh.single_task<class double_dest4>([=]() { | ||
for (int i = 0; i < count; i++) | ||
dest[i] = 4 * src[i]; | ||
}); | ||
}); | ||
oq.wait_and_throw(); | ||
|
||
for (int i = 0; i < count; i++) { | ||
assert(dest[i] == i * 4); | ||
} | ||
} | ||
} |