DPC++
krisrak
25.8K views
Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
DPC++ Playground
Write any DPC++ code and run
Test any DPC++ code
Resources
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <CL/sycl.hpp>
using namespace sycl;
static const int N = 4;
int main(){
queue q;
std::cout << "Device: " << q.get_device().get_info<info::device::name>() << std::endl;
int *data = malloc_shared<int>(N, q);
for(int i=0; i<N; i++) data[i] = i;
q.parallel_for(range<1>(N), [=] (id<1> i){
data[i] *= 5;
}).wait();
for(int i=0; i<N; i++) std::cout << data[i] << std::endl;
free(data, q);
return 0;
}
Enter to Rename, Shift+Enter to Preview