Skip to content

Commit 35ead92

Browse files
committed
Add one_context() method to distributed context and queue
1 parent c43ceb8 commit 35ead92

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

include/boost/compute/distributed/command_queue.hpp

+7
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ class command_queue
181181
return m_queues[n].get_context();
182182
}
183183

184+
/// Returns true if all device command queues are in the same OpenCL
185+
/// context.
186+
bool one_context() const
187+
{
188+
return m_context.one_context();
189+
}
190+
184191
/// Returns nth context from command queue's distributed context.
185192
::boost::compute::device get_device(size_t n) const
186193
{

include/boost/compute/distributed/context.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ class context
147147
return m_contexts[n];
148148
}
149149

150+
/// Returns true if all contexts are in fact the same OpenCL context.
151+
bool one_context() const
152+
{
153+
bool one_context = false;
154+
for(size_t i = 0; i < m_contexts.size(); i++) {
155+
one_context == one_context && (m_contexts[0] == m_contexts[i]);
156+
}
157+
return one_context;
158+
}
159+
150160
/// Returns information about nth context.
151161
template<class T>
152162
T get_info(size_t n, cl_context_info info) const

0 commit comments

Comments
 (0)