-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Store stream buffers in the scheduler #2416
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
Changes from 1 commit
9941a6c
cd8a698
a0bf820
4708e96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -715,6 +715,38 @@ class Scheduler { | |
|
||
friend class Command; | ||
friend class DispatchHostTask; | ||
|
||
class StreamBuffers { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's all public. Why is it class then? Suggest switching to struct here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, switched to structure |
||
public: | ||
StreamBuffers(size_t StreamBufferSize, size_t FlushBufferSize) | ||
// Initialize stream buffer with zeros, this is needed for two reasons: | ||
// 1. We don't need to care about end of line when printing out | ||
// streamed data. | ||
// 2. Offset is properly initialized. | ||
: Data(StreamBufferSize, 0), | ||
Buf(Data.data(), range<1>(StreamBufferSize), | ||
{property::buffer::use_host_ptr()}), | ||
FlushBuf(range<1>(FlushBufferSize)) {} | ||
|
||
// Vector on the host side which is used to initialize the stream | ||
// buffer | ||
std::vector<char> Data; | ||
|
||
// Stream buffer | ||
buffer<char, 1> Buf; | ||
|
||
// Global flush buffer | ||
buffer<char, 1> FlushBuf; | ||
}; | ||
|
||
friend class stream_impl; | ||
|
||
// Protects stream buffers pool | ||
std::mutex StreamBuffersPoolMutex; | ||
std::map<stream_impl *, StreamBuffers> StreamBuffersPool; | ||
|
||
// Allocate buffers in the pool for a provided stream | ||
void allocateStreamBuffers(stream_impl *, size_t, size_t); | ||
}; | ||
|
||
} // namespace detail | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
// RUN: env SYCL_PI_TRACE=2 %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER | ||
// RUN: env SYCL_PI_TRACE=2 %GPU_RUN_PLACEHOLDER %t.out %GPU_CHECK_PLACEHOLDER | ||
// RUN: env SYCL_PI_TRACE=2 %ACC_RUN_PLACEHOLDER %t.out %ACC_CHECK_PLACEHOLDER | ||
|
||
//==----------------------- release_resources_test.cpp ---------------------==// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this part isn't needed here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
|
||
// Check that buffer used by a stream object is released. | ||
|
||
#include <CL/sycl.hpp> | ||
|
||
using namespace cl::sycl; | ||
|
||
int main() { | ||
{ | ||
queue Queue; | ||
|
||
// CHECK:---> piMemRelease | ||
Queue.submit([&](handler &CGH) { | ||
stream Out(1024, 80, CGH); | ||
CGH.parallel_for<class test_cleanup1>( | ||
range<1>(2), [=](id<1> i) { Out << "Hello, World!" << endl; }); | ||
}); | ||
Queue.wait(); | ||
} | ||
|
||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need at least some info on this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added info in the style of this file