File tree Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -87,10 +87,8 @@ platform::get_backend_info() const {
8787
8888#undef __SYCL_PARAM_TRAITS_SPEC
8989
90- context platform::khr_get_default_context () const {
91- if (!detail::SYCLConfig<detail::SYCL_ENABLE_DEFAULT_CONTEXTS>::get ())
92- throw std::runtime_error (" SYCL default contexts are not enabled" );
93-
90+ namespace detail {
91+ context get_default_context () {
9492 // Keeping the default context for platforms in the global cache to avoid
9593 // shared_ptr based circular dependency between platform and context classes
9694 std::unordered_map<detail::PlatformImplPtr, detail::ContextImplPtr>
@@ -108,9 +106,17 @@ context platform::khr_get_default_context() const {
108106
109107 return detail::createSyclObjFromImpl<context>(It->second );
110108}
109+ } // namespace detail
110+
111+ context platform::khr_get_default_context () const {
112+ return detail::get_default_context ();
113+ }
111114
112115context platform::ext_oneapi_get_default_context () const {
113- return khr_get_default_context ();
116+ if (!detail::SYCLConfig<detail::SYCL_ENABLE_DEFAULT_CONTEXTS>::get ())
117+ throw std::runtime_error (" SYCL default contexts are not enabled" );
118+
119+ return detail::get_default_context ();
114120}
115121
116122std::vector<device> platform::ext_oneapi_get_composite_devices () const {
Original file line number Diff line number Diff line change @@ -54,16 +54,6 @@ void test_default_context_disabled() {
5454
5555 ASSERT_TRUE (catchException)
5656 << " ext_oneapi_get_default_context did not throw an exception" ;
57-
58- catchException = false ;
59- try {
60- (void )Plt.khr_get_default_context ();
61- } catch (const std::exception &) {
62- catchException = true ;
63- }
64-
65- ASSERT_TRUE (catchException)
66- << " khr_get_default_context did not throw an exception" ;
6757}
6858
6959TEST (DefaultContextTest, DefaultContextTest) {
You can’t perform that action at this time.
0 commit comments