-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Store stream offset in flush buffer's memory #2767
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
againull
merged 14 commits into
intel:sycl
from
mlychkov:private/mlychkov/share_stream_offset_between_copies
Dec 2, 2020
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
acaf8c9
[SYCL] Store stream offset in flush buffer's memory
mlychkov 086d3ab
Fix offset reading from buffer
mlychkov 29eba59
Flush only when something is written into buffer
mlychkov 4d21d33
Fix stream LIT test
mlychkov c423a4e
Separate stream buffer sync LIT test
mlychkov bc599c6
Correct maximum statement size check
mlychkov b478e9a
Move flush buffer initialization on device into __init
mlychkov 79d8403
Improve fix by applying new review remarks
mlychkov 4521a09
Another portion of applied remarks
mlychkov 7f0702c
Fix LIT test
mlychkov de0ac8f
Fix LIT test on windows
mlychkov cd71a1c
Fix typo
mlychkov 5d948a2
Rewrite stream init dependence LIT test as unit test
mlychkov 6c9c642
Apply remarks to unit test
mlychkov 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,55 @@ | ||
//==-- scheduler_helpers.cpp - SYCL Scheduler helper functions --*- C++ -*-===// | ||
// | ||
// 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/queue.hpp> | ||
#include <detail/queue_impl.hpp> | ||
#include <detail/scheduler/scheduler.hpp> | ||
#include <detail/scheduler/scheduler_helpers.hpp> | ||
#include <detail/stream_impl.hpp> | ||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
namespace detail { | ||
|
||
void initStream(StreamImplPtr Stream, QueueImplPtr Queue) { | ||
Scheduler::StreamBuffers *StrBufs{}; | ||
|
||
{ | ||
std::lock_guard<std::recursive_mutex> lock( | ||
Scheduler::getInstance().StreamBuffersPoolMutex); | ||
|
||
auto StreamBuf = | ||
Scheduler::getInstance().StreamBuffersPool.find(Stream.get()); | ||
assert((StreamBuf != Scheduler::getInstance().StreamBuffersPool.end()) && | ||
"Stream is unexpectedly not found in pool."); | ||
|
||
StrBufs = StreamBuf->second; | ||
} | ||
|
||
assert(StrBufs && "No buffers for a stream."); | ||
|
||
// Real size of full flush buffer is saved only in buffer_impl field of | ||
// FlushBuf object. | ||
size_t FlushBufSize = getSyclObjImpl(StrBufs->FlushBuf)->get_count(); | ||
|
||
auto Q = createSyclObjFromImpl<queue>(Queue); | ||
Q.submit([&](handler &cgh) { | ||
auto FlushBufAcc = | ||
StrBufs->FlushBuf.get_access<access::mode::discard_write, | ||
access::target::host_buffer>( | ||
cgh, range<1>(FlushBufSize), id<1>(0)); | ||
cgh.codeplay_host_task([=] { | ||
char *FlushBufPtr = FlushBufAcc.get_pointer(); | ||
std::memset(FlushBufPtr, 0, FlushBufAcc.get_size()); | ||
}); | ||
}); | ||
} | ||
|
||
} // namespace detail | ||
} // namespace sycl | ||
} // __SYCL_INLINE_NAMESPACE(cl) |
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,29 @@ | ||
//==---------- scheduler_helpers.hpp - SYCL standard header file -----------==// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
#include <CL/sycl/detail/defines_elementary.hpp> | ||
|
||
#include <memory> | ||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
namespace detail { | ||
|
||
class stream_impl; | ||
class queue_impl; | ||
|
||
using StreamImplPtr = std::shared_ptr<detail::stream_impl>; | ||
using QueueImplPtr = std::shared_ptr<detail::queue_impl>; | ||
|
||
void initStream(StreamImplPtr Stream, QueueImplPtr Queue); | ||
|
||
} // namespace detail | ||
} // namespace sycl | ||
} // __SYCL_INLINE_NAMESPACE(cl) |
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
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
39 changes: 39 additions & 0 deletions
39
sycl/test/on-device/basic_tests/stream/stream_copies_buffer_sync.cpp
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,39 @@ | ||
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out | FileCheck %s | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER | ||
// RUN: %GPU_RUN_ON_LINUX_PLACEHOLDER %t.out %GPU_CHECK_ON_LINUX_PLACEHOLDER | ||
// RUN: %ACC_RUN_PLACEHOLDER %t.out %ACC_CHECK_PLACEHOLDER | ||
|
||
#include <CL/sycl.hpp> | ||
|
||
using namespace cl::sycl; | ||
|
||
void dev_func(stream out) { out << "dev_func print\n"; } | ||
|
||
int main() { | ||
{ | ||
queue Queue; | ||
|
||
mlychkov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Queue.submit([&](handler &cgh) { | ||
stream stream1(1024, 160, cgh); | ||
cgh.parallel_for<class test_dev_func_stream>( | ||
nd_range<1>(range<1>(1), range<1>(1)), [=](sycl::nd_item<1> it) { | ||
stream1 << "stream1 print 1\n"; | ||
dev_func(stream1); | ||
sycl::stream stream2 = stream1; | ||
stream1 << "stream1 print 2" << sycl::endl; | ||
stream2 << "stream2 print 1\n"; | ||
stream1 << "stream1 print 3\n"; | ||
stream2 << sycl::flush; | ||
}); | ||
}); | ||
Queue.wait(); | ||
// CHECK: stream1 print 1 | ||
// CHECK-NEXT: dev_func print | ||
// CHECK-NEXT: stream1 print 2 | ||
// CHECK-NEXT: stream2 print 1 | ||
// CHECK-NEXT: stream1 print 3 | ||
} | ||
|
||
return 0; | ||
} |
27 changes: 27 additions & 0 deletions
27
sycl/test/on-device/basic_tests/stream/stream_max_stmt_exceed.cpp
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,27 @@ | ||
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out | FileCheck %s | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER | ||
// RUN: %GPU_RUN_ON_LINUX_PLACEHOLDER %t.out %GPU_CHECK_ON_LINUX_PLACEHOLDER | ||
// RUN: %ACC_RUN_PLACEHOLDER %t.out %ACC_CHECK_PLACEHOLDER | ||
|
||
#include <CL/sycl.hpp> | ||
|
||
#include <cassert> | ||
|
||
using namespace cl; | ||
|
||
int main() { | ||
sycl::queue Queue; | ||
try { | ||
Queue.submit([&](sycl::handler &cgh) { | ||
sycl::stream Out(100, 65536, cgh); | ||
cgh.single_task<class test_max_stmt_exceed>( | ||
[=]() { Out << "Hello world!" << sycl::endl; }); | ||
}); | ||
Queue.wait(); | ||
} catch (sycl::exception &ExpectedException) { | ||
// CHECK: Maximum statement size exceeds limit of 65535 bytes | ||
std::cout << ExpectedException.what() << std::endl; | ||
} | ||
return 0; | ||
} |
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
Oops, something went wrong.
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.