Skip to content

[SYCL] Fix post-commit failure #3532

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 2 commits into from
Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions sycl/source/detail/persistent_device_code_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ void PersistentDeviceCodeCache::putItemToDisc(
*/
std::vector<std::vector<char>> PersistentDeviceCodeCache::getItemFromDisc(
const device &Device, const RTDeviceBinaryImage &Img,
const SerializedObj &SpecConsts, const std::string &BuildOptionsString,
RT::PiProgram &NativePrg) {
const SerializedObj &SpecConsts, const std::string &BuildOptionsString) {

if (!isImageCached(Img))
return {};
Expand Down
3 changes: 1 addition & 2 deletions sycl/source/detail/persistent_device_code_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ class PersistentDeviceCodeCache {
static std::vector<std::vector<char>>
getItemFromDisc(const device &Device, const RTDeviceBinaryImage &Img,
const SerializedObj &SpecConsts,
const std::string &BuildOptionsString,
RT::PiProgram &NativePrg);
const std::string &BuildOptionsString);

/* Stores build program in persisten cache
*/
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ RT::PiProgram ProgramManager::getBuiltPIProgram(OSModuleHandle M,
RT::PiProgram NativePrg;

auto BinProg = PersistentDeviceCodeCache::getItemFromDisc(
Device, Img, SpecConsts, CompileOpts + LinkOpts, NativePrg);
Device, Img, SpecConsts, CompileOpts + LinkOpts);
if (BinProg.size()) {
// TODO: Build for multiple devices once supported by program manager
NativePrg = createBinaryProgram(ContextImpl, Device,
Expand Down
38 changes: 19 additions & 19 deletions sycl/unittests/kernel-and-program/PersistentDeviceCodeCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class PersistenDeviceCodeCache : public ::testing::Test {
Dev, Img,
sycl::vector_class<unsigned char>(
{'S', 'p', 'e', 'c', 'C', 'o', 'n', 's', 't', ProgramID}),
BuildOptions, NativeProg);
BuildOptions);
for (int i = 0; i < Res.size(); ++i) {
for (int j = 0; j < Res[i].size(); ++j) {
assert(Res[i][j] == i &&
Expand Down Expand Up @@ -187,8 +187,8 @@ TEST_F(PersistenDeviceCodeCache, CorruptedCacheFiles) {
NativeProg);
assert(!llvm::sys::fs::remove(ItemDir + "/0.bin") &&
"Failed to remove binary file");
auto Res = detail::PersistentDeviceCodeCache::getItemFromDisc(
Dev, Img, {}, BuildOptions, NativeProg);
auto Res = detail::PersistentDeviceCodeCache::getItemFromDisc(Dev, Img, {},
BuildOptions);
assert(Res.size() == 0 && "Item with missed binary file was read");
llvm::sys::fs::remove_directories(ItemDir);

Expand All @@ -197,8 +197,8 @@ TEST_F(PersistenDeviceCodeCache, CorruptedCacheFiles) {
NativeProg);
assert(!llvm::sys::fs::remove(ItemDir + "/0.src") &&
"Failed to remove source file");
Res = detail::PersistentDeviceCodeCache::getItemFromDisc(
Dev, Img, {}, BuildOptions, NativeProg);
Res = detail::PersistentDeviceCodeCache::getItemFromDisc(Dev, Img, {},
BuildOptions);
assert(Res.size() == 0 && "Item with missed source file was read");
llvm::sys::fs::remove_directories(ItemDir);

Expand All @@ -213,8 +213,8 @@ TEST_F(PersistenDeviceCodeCache, CorruptedCacheFiles) {
FileStream << 2 << 12 << "123456789012" << 23 << "1234";
FileStream.close();
assert((!FileStream.fail()) && "Failed to create trancated binary file");
Res = detail::PersistentDeviceCodeCache::getItemFromDisc(
Dev, Img, {}, BuildOptions, NativeProg);
Res = detail::PersistentDeviceCodeCache::getItemFromDisc(Dev, Img, {},
BuildOptions);
assert(Res.size() == 0 && "Item with corrupted binary file was read");

llvm::sys::fs::remove_directories(ItemDir);
Expand All @@ -226,8 +226,8 @@ TEST_F(PersistenDeviceCodeCache, CorruptedCacheFiles) {
std::ofstream FileStream(ItemDir + "/0.src",
std::ofstream::out | std::ofstream::trunc);
}
Res = detail::PersistentDeviceCodeCache::getItemFromDisc(
Dev, Img, {}, BuildOptions, NativeProg);
Res = detail::PersistentDeviceCodeCache::getItemFromDisc(Dev, Img, {},
BuildOptions);
assert(Res.size() == 0 && "Item with corrupted binary file was read");
llvm::sys::fs::remove_directories(ItemDir);
}
Expand Down Expand Up @@ -256,8 +256,8 @@ TEST_F(PersistenDeviceCodeCache, LockFile) {
{ std::ofstream File{LockFile}; }

// Cache item is locked, cache miss happens on read
auto Res = detail::PersistentDeviceCodeCache::getItemFromDisc(
Dev, Img, {}, BuildOptions, NativeProg);
auto Res = detail::PersistentDeviceCodeCache::getItemFromDisc(Dev, Img, {},
BuildOptions);
assert(Res.size() == 0 && "Locked item was read");

// Cache item is locked - new cache item to be created
Expand All @@ -267,14 +267,14 @@ TEST_F(PersistenDeviceCodeCache, LockFile) {

// Second cache item is locked, cache miss happens on read
{ std::ofstream File{ItemDir + "/1.lock"}; }
Res = detail::PersistentDeviceCodeCache::getItemFromDisc(
Dev, Img, {}, BuildOptions, NativeProg);
Res = detail::PersistentDeviceCodeCache::getItemFromDisc(Dev, Img, {},
BuildOptions);
assert(Res.size() == 0 && "Locked item was read");

// First cache item was unlocked and successfully read
std::remove(LockFile.c_str());
Res = detail::PersistentDeviceCodeCache::getItemFromDisc(
Dev, Img, {}, BuildOptions, NativeProg);
Res = detail::PersistentDeviceCodeCache::getItemFromDisc(Dev, Img, {},
BuildOptions);
for (int i = 0; i < Res.size(); ++i) {
for (int j = 0; j < Res[i].size(); ++j) {
assert(Res[i][j] == i && "Corrupted image loaded from persistent cache");
Expand Down Expand Up @@ -305,17 +305,17 @@ TEST_F(PersistenDeviceCodeCache, AccessDeniedForCacheDir) {
assert(llvm::sys::fs::exists(ItemDir + "/1.bin") && "No file created");

llvm::sys::fs::setPermissions(ItemDir + "/1.bin", llvm::sys::fs::no_perms);
auto Res = detail::PersistentDeviceCodeCache::getItemFromDisc(
Dev, Img, {}, BuildOptions, NativeProg);
auto Res = detail::PersistentDeviceCodeCache::getItemFromDisc(Dev, Img, {},
BuildOptions);

// No image to be read due to lack of permissions fro source file
assert(Res.size() == 0);

llvm::sys::fs::setPermissions(ItemDir + "/0.bin", llvm::sys::fs::all_perms);
llvm::sys::fs::setPermissions(ItemDir + "/1.bin", llvm::sys::fs::all_perms);

Res = detail::PersistentDeviceCodeCache::getItemFromDisc(
Dev, Img, {}, BuildOptions, NativeProg);
Res = detail::PersistentDeviceCodeCache::getItemFromDisc(Dev, Img, {},
BuildOptions);
// Image should be successfully read
for (int i = 0; i < Res.size(); ++i) {
for (int j = 0; j < Res[i].size(); ++j) {
Expand Down