MCPcopy Create free account
hub / github.com/boostorg/compute / main

Function main

example/copy_data.cpp:20–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18namespace compute = boost::compute;
19
20int 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//]

Callers

nothing calls this directly

Calls 3

copyFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected