-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Specialization constants: fix scope, allow redefinition and AOT. #1633
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
6 commits
Select commit
Hold shift + click to select a range
d54a65e
[SYCL] Specialization constants: fix scope, allow redifinition and AOT.
kbobrovs cba353c
[SQUASH] Exculde invalid exec paths leading to flushSpecConstants, fi…
kbobrovs d0a6846
[SQUASH] Disable CPU SC redefine test due to old CI CPU RT.
kbobrovs aed25f2
Update sycl/source/detail/program_manager/program_manager.hpp
kbobrovs bc7001d
Update sycl/source/detail/program_impl.cpp
kbobrovs 11df804
Address review comments. Disable tests properly.
kbobrovs 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//==----- device_binary_image.hpp --- SYCL device binary image abstraction -==// | ||
// | ||
// 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/os_util.hpp> | ||
#include <CL/sycl/detail/pi.hpp> | ||
|
||
#include <memory> | ||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
namespace detail { | ||
|
||
// SYCL RT wrapper over PI binary image. | ||
class RTDeviceBinaryImage : public pi::DeviceBinaryImage { | ||
public: | ||
RTDeviceBinaryImage(OSModuleHandle ModuleHandle) | ||
: pi::DeviceBinaryImage(), ModuleHandle(ModuleHandle) {} | ||
RTDeviceBinaryImage(pi_device_binary Bin, OSModuleHandle ModuleHandle) | ||
: pi::DeviceBinaryImage(Bin), ModuleHandle(ModuleHandle) {} | ||
OSModuleHandle getOSModuleHandle() const { return ModuleHandle; } | ||
|
||
~RTDeviceBinaryImage() override {} | ||
|
||
bool supportsSpecConstants() const { | ||
return getFormat() == PI_DEVICE_BINARY_TYPE_SPIRV; | ||
} | ||
|
||
const pi_device_binary_struct &getRawData() const { return *get(); } | ||
|
||
void print() const override { | ||
pi::DeviceBinaryImage::print(); | ||
std::cerr << " OSModuleHandle=" << ModuleHandle << "\n"; | ||
} | ||
|
||
protected: | ||
OSModuleHandle ModuleHandle; | ||
}; | ||
|
||
// Dynamically allocated device binary image, which de-allocates its binary | ||
// data in destructor. | ||
class DynRTDeviceBinaryImage : public RTDeviceBinaryImage { | ||
public: | ||
DynRTDeviceBinaryImage(std::unique_ptr<char[]> &&DataPtr, size_t DataSize, | ||
OSModuleHandle M); | ||
~DynRTDeviceBinaryImage() override; | ||
|
||
void print() const override { | ||
RTDeviceBinaryImage::print(); | ||
std::cerr << " DYNAMICALLY CREATED\n"; | ||
} | ||
|
||
protected: | ||
std::unique_ptr<char[]> Data; | ||
}; | ||
|
||
} // 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
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,40 @@ | ||
//==----- device_binary_image.cpp --- SYCL device binary image abstraction -==// | ||
// | ||
// 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/detail/pi.hpp> | ||
|
||
#include <memory> | ||
|
||
#include <CL/sycl/detail/device_binary_image.hpp> | ||
|
||
using namespace sycl::detail; | ||
|
||
DynRTDeviceBinaryImage::DynRTDeviceBinaryImage( | ||
std::unique_ptr<char[]> &&DataPtr, size_t DataSize, OSModuleHandle M) | ||
: RTDeviceBinaryImage(M) { | ||
Data = std::move(DataPtr); | ||
Bin = new pi_device_binary_struct(); | ||
Bin->Version = PI_DEVICE_BINARY_VERSION; | ||
Bin->Kind = PI_DEVICE_BINARY_OFFLOAD_KIND_SYCL; | ||
Bin->DeviceTargetSpec = PI_DEVICE_BINARY_TARGET_UNKNOWN; | ||
Bin->CompileOptions = ""; | ||
Bin->LinkOptions = ""; | ||
Bin->ManifestStart = nullptr; | ||
Bin->ManifestEnd = nullptr; | ||
Bin->BinaryStart = reinterpret_cast<unsigned char *>(Data.get()); | ||
Bin->BinaryEnd = Bin->BinaryStart + DataSize; | ||
Bin->EntriesBegin = nullptr; | ||
Bin->EntriesEnd = nullptr; | ||
Bin->Format = pi::getBinaryImageFormat(Bin->BinaryStart, DataSize); | ||
init(Bin); | ||
} | ||
|
||
DynRTDeviceBinaryImage::~DynRTDeviceBinaryImage() { | ||
delete Bin; | ||
Bin = nullptr; | ||
} |
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
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.
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.
Suggest moving functionality of this function to program_manager.cpp:991 to avoid dealing with RTDeviceBeinaryImage outside of program_manager.
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.
What is the problem with dealing with RTDeviceBeinaryImage outside of program_manager?
Or do you mean incurred dependence on program_manager.h everywhere RTDeviceBeinaryImage is used? That can be fixed by extracting BinaryImage infra into a separate header.
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.
I think it would be nice if program_manager abstracts away low level image details from other parts of the SYCL.
Is there any reason for this function to be a method of program class?
This comment doesn't block PR approval.
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.
Spec constants are now bound to a program_impl, this is the main reason. But I agree that it is better keep as few inter-dependencies as possible. Anyway, upcoming modules implementation will require significant refactoring in this area - let's revisit this design question as a part of modules design, not to refactor twice. Do you agree?
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.
Ok.