Skip to content

Instantly share code, notes, and snippets.

@ddemidov
Last active February 19, 2016 12:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddemidov/ff022cca11c7715ec1b7 to your computer and use it in GitHub Desktop.
Save ddemidov/ff022cca11c7715ec1b7 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <boost/compute.hpp>
#define VEXCL_BACKEND_COMPUTE
#include <vexcl/vexcl.hpp>
namespace compute = boost::compute;
int main() {
compute::command_queue bcq = compute::system::default_queue();
// Use boost.compute queue to allocate vexcl vectors:
vex::vector<int> x({bcq}, 16);
x = vex::element_index();
std::cout << "x = " << x << std::endl;
// Wrap boost.compute vectors into vexcl vectors (no data is copied):
compute::vector<int> bcv(16, bcq.get_context());
vex::vector<int> y({bcq}, bcv.get_buffer());
y = x * 2;
std::cout << "bcv = [ ";
for(int v : bcv) std::cout << v << " ";
std::cout << "]" << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment