-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Don't throw exceptions from destructors #1378
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
romanovvlad
merged 2 commits into
intel:sycl
from
KarachunIvan:private/ivankara/command_status
Mar 31, 2020
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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,50 @@ | ||
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -I %sycl_source_dir %s -o %t.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
#include <CL/sycl.hpp> | ||
#include <array> | ||
|
||
using namespace cl::sycl; | ||
|
||
constexpr access::mode sycl_read = access::mode::read; | ||
constexpr access::mode sycl_write = access::mode::write; | ||
|
||
constexpr unsigned MAX_WG_SIZE = 4; | ||
constexpr unsigned SIZE = 5; | ||
using ArrayType = std::array<unsigned, SIZE>; | ||
|
||
class kernelCompute; | ||
|
||
// Return 'true' if an exception was thrown. | ||
bool run_kernel(const unsigned wg_size) { | ||
ArrayType index; | ||
const unsigned N = index.size(); | ||
{ | ||
buffer<cl_uint, 1> bufferIdx(index.data(), N); | ||
queue deviceQueue; | ||
try { | ||
deviceQueue.submit([&](handler &cgh) { | ||
auto accessorIdx = bufferIdx.get_access<sycl_read>(cgh); | ||
cgh.parallel_for<class kernelCompute>( | ||
nd_range<1>(range<1>(N), range<1>(wg_size)), | ||
[=](nd_item<1> ID) [[cl::reqd_work_group_size(1, 1, MAX_WG_SIZE)]] { | ||
(void)accessorIdx[ID.get_global_id(0)]; | ||
}); | ||
}); | ||
} catch (nd_range_error &err) { | ||
return true; | ||
} catch (...) { | ||
assert(!"Unknown exception was thrown"); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
int main() { | ||
bool success_exception = run_kernel(MAX_WG_SIZE); | ||
assert(!success_exception && | ||
"Unexpected exception was thrown for success call"); | ||
bool fail_exception = run_kernel(SIZE); | ||
assert(fail_exception && "No exception was thrown"); | ||
|
||
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
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,61 @@ | ||
//==----------- FailedCommands.cpp ---- Scheduler unit tests ---------------==// | ||
// | ||
// 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 "SchedulerTest.hpp" | ||
|
||
#include <CL/cl.h> | ||
#include <CL/sycl.hpp> | ||
#include <detail/scheduler/scheduler.hpp> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
using namespace cl::sycl; | ||
|
||
class MockCommand : public detail::Command { | ||
public: | ||
MockCommand(detail::QueueImplPtr Queue) | ||
: Command(detail::Command::ALLOCA, Queue) {} | ||
void printDot(std::ostream &Stream) const override {} | ||
void emitInstrumentationData() override {} | ||
cl_int enqueueImp() override { return CL_SUCCESS; } | ||
}; | ||
|
||
class MockScheduler : public detail::Scheduler { | ||
public: | ||
static bool enqueueCommand(detail::Command *Cmd, | ||
detail::EnqueueResultT &EnqueueResult, | ||
detail::BlockingT Blocking) { | ||
return GraphProcessor::enqueueCommand(Cmd, EnqueueResult, Blocking); | ||
} | ||
}; | ||
|
||
TEST_F(SchedulerTest, FailedDependency) { | ||
detail::Requirement MockReq(/*Offset*/ {0, 0, 0}, /*AccessRange*/ {1, 1, 1}, | ||
/*MemoryRange*/ {1, 1, 1}, | ||
access::mode::read_write, /*SYCLMemObjT*/ nullptr, | ||
/*Dims*/ 1, /*ElementSize*/ 1); | ||
MockCommand MDep(detail::getSyclObjImpl(MQueue)); | ||
MockCommand MUser(detail::getSyclObjImpl(MQueue)); | ||
MDep.addUser(&MUser); | ||
MUser.addDep(detail::DepDesc{&MDep, &MockReq, nullptr}); | ||
MUser.MEnqueueStatus = detail::EnqueueResultT::SyclEnqueueReady; | ||
MDep.MEnqueueStatus = detail::EnqueueResultT::SyclEnqueueFailed; | ||
|
||
detail::EnqueueResultT Res; | ||
bool Enqueued = | ||
MockScheduler::enqueueCommand(&MUser, Res, detail::NON_BLOCKING); | ||
|
||
ASSERT_FALSE(Enqueued) << "Enqueue process must fail\n"; | ||
ASSERT_EQ(Res.MCmd, &MDep) << "Wrong failed command\n"; | ||
ASSERT_EQ(Res.MResult, detail::EnqueueResultT::SyclEnqueueFailed) | ||
<< "Enqueue process must fail\n"; | ||
ASSERT_EQ(MUser.MEnqueueStatus, detail::EnqueueResultT::SyclEnqueueReady) | ||
<< "MUser shouldn't be marked as failed\n"; | ||
ASSERT_EQ(MDep.MEnqueueStatus, detail::EnqueueResultT::SyclEnqueueFailed) | ||
<< "MDep should be marked as failed\n"; | ||
} |
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.