Skip to content

Commit 27d3a95

Browse files
committedOct 19, 2016
global buffer sample
1 parent 127504b commit 27d3a95

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
 

‎global_var/global_buffer.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <cstdio>
2+
#include <hc.hpp>
3+
4+
//#define GLOBAL_VAR_BUG 1
5+
6+
#ifdef GLOBAL_VAR_BUG
7+
__attribute__((hc))
8+
#else
9+
__attribute__((address_space(1)))
10+
#endif
11+
char buffer[1024*1024*32];
12+
13+
14+
int main() {
15+
parallel_for_each(hc::extent<1>(1), [=](hc::index<1> i) [[hc]] {
16+
if (i[0]==0) {
17+
const char* helloWorld = "Hello World!";
18+
for (int j = 0; j <= 12; j++)
19+
buffer[j] = helloWorld[j];
20+
}
21+
}).wait();
22+
23+
}

0 commit comments

Comments
 (0)
Please sign in to comment.