| 18 | namespace compute = boost::compute; |
| 19 | |
| 20 | int main() |
| 21 | { |
| 22 | // get default device and setup context |
| 23 | compute::device device = compute::system::default_device(); |
| 24 | compute::context context(device); |
| 25 | compute::command_queue queue(context, device); |
| 26 | |
| 27 | // create data array on host |
| 28 | int host_data[] = { 1, 3, 5, 7, 9 }; |
| 29 | |
| 30 | // create vector on device |
| 31 | compute::vector<int> device_vector(5, context); |
| 32 | |
| 33 | // copy from host to device |
| 34 | compute::copy( |
| 35 | host_data, host_data + 5, device_vector.begin(), queue |
| 36 | ); |
| 37 | |
| 38 | // create vector on host |
| 39 | std::vector<int> host_vector(5); |
| 40 | |
| 41 | // copy data back to host |
| 42 | compute::copy( |
| 43 | device_vector.begin(), device_vector.end(), host_vector.begin(), queue |
| 44 | ); |
| 45 | |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | //] |