@@ -24,20 +24,24 @@ namespace bc = boost::compute;
2424
2525BOOST_AUTO_TEST_CASE (construct_from_devices)
2626{
27- std::vector<bc::device> all_devices;
27+ std::vector<std::vector< bc::device> > all_devices;
2828
2929 const std::vector<bc::platform> &platforms = bc::system::platforms ();
3030 for (size_t i = 0 ; i < platforms.size (); i++){
3131 const bc::platform &platform = platforms[i];
32+
3233 std::vector<bc::device> platform_devices = platform.devices ();
34+ std::vector<cl_context_properties*> properties (platform_devices.size (), 0 );
3335
3436 // create a distributed context for devices in current platform
35- bc::distributed::context ctx (platform_devices);
37+ bc::distributed::context ctx1 (platform_devices);
38+ bc::distributed::context ctx2 (platform_devices, properties);
3639
3740 // check context count
38- BOOST_CHECK_EQUAL (ctx.size (), platform.device_count ());
41+ BOOST_CHECK_EQUAL (ctx1.size (), platform_devices.size ());
42+ BOOST_CHECK_EQUAL (ctx2.size (), platform_devices.size ());
3943
40- all_devices.insert (all_devices. end (), platform_devices. begin (), platform_devices. end () );
44+ all_devices.push_back ( platform_devices);
4145 }
4246
4347 // create a distributed context for devices in current platform
@@ -58,14 +62,25 @@ BOOST_AUTO_TEST_CASE(construct_from_contexts)
5862 bc::context ctx (platform.devices ());
5963 contexts.push_back (ctx);
6064 }
61- bc::distributed::context ctx (contexts);
6265
63- BOOST_CHECK_EQUAL (ctx.size (), contexts.size ());
66+ bc::distributed::context ctx1 (contexts);
67+ bc::distributed::context ctx2 (contexts.begin (), contexts.end ());
68+
69+ BOOST_CHECK_EQUAL (ctx1.size (), contexts.size ());
70+ BOOST_CHECK_EQUAL (ctx2.size (), contexts.size ());
6471 for (size_t i = 0 ; i < contexts.size (); i++) {
65- BOOST_CHECK_EQUAL (ctx.get (i), contexts[i]);
72+ BOOST_CHECK_EQUAL (ctx1.get (i), contexts[i]);
73+ BOOST_CHECK_EQUAL (ctx2.get (i), contexts[i]);
6674 }
6775}
6876
77+ BOOST_AUTO_TEST_CASE (construct_from_context)
78+ {
79+ bc::distributed::context ctx (context);
80+ BOOST_CHECK_EQUAL (ctx.size (), 1 );
81+ BOOST_CHECK_EQUAL (ctx.get (0 ), context);
82+ }
83+
6984BOOST_AUTO_TEST_CASE (copy_ctor)
7085{
7186 std::vector<bc::context> contexts;
@@ -137,33 +152,4 @@ BOOST_AUTO_TEST_CASE(get_context)
137152 }
138153}
139154
140- // BOOST_AUTO_TEST_CASE(test)
141- // {
142- // bc::platform platform = Context::queue.get_context().get_device().platform();
143- // // create a context for containing all devices in the platform
144- // bc::context ctx(platform.devices());
145- //
146- // for(size_t i = 0; i < platform.devices().size(); i++)
147- // {
148- // std::cout << platform.devices()[i].name() << std::endl;
149- // }
150- //
151- // bc::vector<bc::int_> vec(64, ctx);
152- //
153- // bc::command_queue q0(ctx, platform.devices()[0]);
154- // bc::command_queue q1(ctx, platform.devices()[1]);
155- //
156- // bc::fill(vec.begin(), vec.begin() + 32, bc::int_(4), q0);
157- // q0.finish();
158- // bc::fill(vec.begin() + 32, vec.end(), bc::int_(3), q1);
159- // q1.finish();
160- //
161- // bc::fill(vec.begin(), vec.end(), bc::int_(5), q1);
162- // q0.finish();
163- //
164- // // for(size_t i = 0; i < vec.size(); i++) {
165- // // std::cout << vec[i] << std::endl;
166- // // }
167- // }
168-
169155BOOST_AUTO_TEST_SUITE_END ()
0 commit comments