This PR allows user to attach their own OpenCL context via default_context(context* = 0), with such benefits as described in #827. It adheres to default_context() behavior defined in boost/compute/system.hpp :
The default context is created once on the first time this function is called. Calling this function multiple times will always result in the same context object being returned.
Now user can either let Boost.Compute decide which context to initialize with:
Test result of repeatedly attaching user context concurrently will correctly return only one unique context. See test_user_context_thread_safety.cpp:
$ ctest -C Release -R \w*user_default_context_thread_safety --repeat-until-fail 512
1/1 Test #16:
Start 16: core.user_default_context_thread_safety
core.user_default_context_thread_safety ... Passed 0.06 sec
# … repeat 512 times
100% tests passed, 0 tests failed out of 1
Total Test time (real) = 31.65 sec
Tests passed with the following flags:
BOOST_COMPUTE_THREAD_SAFE=ON, BOOST_COMPUTE_USE_CPP11=ON
BOOST_COMPUTE_THREAD_SAFE=ON, BOOST_COMPUTE_USE_CPP11=OFF
This PR allows user to attach their own OpenCL context via
default_context(context* = 0)
, with such benefits as described in #827. It adheres todefault_context()
behavior defined in boost/compute/system.hpp :Now user can either let Boost.Compute decide which context to initialize with:
Or attach their own context:
Test result of repeatedly attaching user context concurrently will correctly return only one unique context. See
test_user_context_thread_safety.cpp
:Tests passed with the following flags: BOOST_COMPUTE_THREAD_SAFE=ON, BOOST_COMPUTE_USE_CPP11=ON BOOST_COMPUTE_THREAD_SAFE=ON, BOOST_COMPUTE_USE_CPP11=OFF