this example demonstrates how to print the values in a vector
| 20 | |
| 21 | // this example demonstrates how to print the values in a vector |
| 22 | int main() |
| 23 | { |
| 24 | // get default device and setup context |
| 25 | compute::device gpu = compute::system::default_device(); |
| 26 | compute::context context(gpu); |
| 27 | compute::command_queue queue(context, gpu); |
| 28 | std::cout << "device: " << gpu.name() << std::endl; |
| 29 | |
| 30 | // create vector on the device and fill with the sequence 1..10 |
| 31 | compute::vector<int> vector(10, context); |
| 32 | compute::iota(vector.begin(), vector.end(), 1, queue); |
| 33 | |
| 34 | //[print_vector_example |
| 35 | std::cout << "vector: [ "; |
| 36 | boost::compute::copy( |
| 37 | vector.begin(), vector.end(), |
| 38 | std::ostream_iterator<int>(std::cout, ", "), |
| 39 | queue |
| 40 | ); |
| 41 | std::cout << "]" << std::endl; |
| 42 | //] |
| 43 | |
| 44 | return 0; |
| 45 | } |