ytgui / temp

0 stars 0 forks source link

SYCL #46

Closed ytgui closed 5 years ago

ytgui commented 5 years ago

https://www.khronos.org/sycl/ https://github.com/intel/llvm/blob/sycl/sycl/doc/GetStartedWithSYCLCompiler.md https://www.khronos.org/assets/uploads/apis/2015-sycl-page3.jpg https://www.codeplay.com/portal/sycl-tutorial-1-the-vector-addition https://www.khronos.org/news/press/khronos-releases-sycl-1.2-final-specification-c-single-source-heterogeneous https://www.khronos.org/news/press/khronos-releases-opencl-2.2-provisional-spec-opencl-c-kernel-language

ytgui commented 5 years ago

SYCL

Abstract

#include <vector>
#include <iostream>

#include <sycl/execution_policy>
#include <experimental/algorithm>
#include <sycl/helpers/sycl_buffers.hpp>

using namespace std::experimental::parallel;
using namespace sycl::helpers;

int main() {
  constexpr size_t array_size = 1024*512;
  std::array<cl::sycl::cl_int, array_size> a;
  std::iota(begin(a),end(a),0);

  {
    cl::sycl::buffer<int> b(a.data(), cl::sycl::range<1>(a.size()));
    cl::sycl::queue q;
    sycl::sycl_execution_policy<class Mul> sycl_policy(q);
    transform(sycl_policy, begin(b), end(b), begin(b),
              [](int x) { return x*2; });
  }
}