static void print_testdevice_info(hpx::opencl::device & cldevice, std::size_t device_id, std::size_t num_devices){ // Test whether get_device_info works std::string version = cldevice.get_device_info<CL_DEVICE_VERSION>().get(); // Test whether version is a valid OpenCL version string std::string versionstring = std::string("OpenCL "); HPX_TEST(0 == version.compare(0, versionstring.length(), versionstring)); // Write Info Code hpx::cout << "Device ID: " << device_id << " / " << num_devices << hpx::endl; hpx::cout << "Device GID: " << cldevice.get_gid() << hpx::endl; hpx::cout << "Version: " << version << hpx::endl; hpx::cout << "Name: " << cldevice.get_device_info<CL_DEVICE_NAME>().get() << hpx::endl; hpx::cout << "Vendor: " << cldevice.get_device_info<CL_DEVICE_VENDOR>().get() << hpx::endl; hpx::cout << "Profile: " << cldevice.get_device_info<CL_DEVICE_PROFILE>().get() << hpx::endl; // Test for valid device client HPX_TEST(cldevice.get_gid()); }
static void cl_test( hpx::opencl::device local_device, hpx::opencl::device cldevice ){ hpx::opencl::lcos::event<void> event(cldevice.get_gid()); register_event(cldevice, event.get_event_id()); hpx::shared_future<void> sfut = event.get_future(); std::vector<hpx::shared_future<void>> vsfut1; vsfut1.push_back( sfut ); std::vector<hpx::shared_future<void>> vsfut2; vsfut2.push_back( sfut ); vsfut2.push_back( sfut ); test_client t; HPX_TEST_EQ( 5300, t.func(5, 3 ).get() ); HPX_TEST_EQ( 5301, t.func(5, 3, sfut ).get() ); HPX_TEST_EQ( 5302, t.func(5, 3, sfut, sfut ).get() ); HPX_TEST_EQ( 5301, t.func(5, 3, vsfut1 ).get() ); HPX_TEST_EQ( 5302, t.func(5, 3, vsfut2 ).get() ); HPX_TEST_EQ( 5302, t.func(5, 3, vsfut1, vsfut1 ).get() ); HPX_TEST_EQ( 5303, t.func(5, 3, vsfut1, vsfut2 ).get() ); HPX_TEST_EQ( 5303, t.func(5, 3, vsfut2, vsfut1 ).get() ); HPX_TEST_EQ( 5304, t.func(5, 3, vsfut2, vsfut2 ).get() ); HPX_TEST_EQ( 5304, t.func(5, 3, sfut, sfut, vsfut2 ).get() ); HPX_TEST_EQ( 5304, t.func(5, 3, sfut, vsfut2, sfut ).get() ); HPX_TEST_EQ( 5304, t.func(5, 3, vsfut2, sfut, sfut ).get() ); HPX_TEST_EQ( 5305, t.func(5, 3, sfut, vsfut2, vsfut2 ).get() ); HPX_TEST_EQ( 5305, t.func(5, 3, vsfut2, sfut, vsfut2 ).get() ); HPX_TEST_EQ( 5305, t.func(5, 3, vsfut2, vsfut2, sfut ).get() ); };
static void register_event(hpx::opencl::device cldevice, const hpx::naming::id_type & event_id) { boost::shared_ptr<hpx::opencl::server::device> parent_device = hpx::get_ptr<hpx::opencl::server::device> (cldevice.get_gid()).get(); // create a fake event cl_int err; cl_event event_cl = clCreateUserEvent ( parent_device->get_context(), &err); cl_ensure(err, "clEnqueueWriteBuffer()"); err = clSetUserEventStatus(event_cl, CL_COMPLETE); cl_ensure(err, "clSetUserEventStatus()"); parent_device->register_event(event_id, event_cl); }