We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5840cbf commit 127504bCopy full SHA for 127504b
global_var/global_var_simple.cpp
@@ -0,0 +1,38 @@
1
+#include <cstdio>
2
+#include <hc.hpp>
3
+
4
+//#define GLOBAL_VAR_BUG 1
5
6
+#ifdef GLOBAL_VAR_BUG
7
+__attribute__((hc)) int foo[1] = { 1234 };
8
+#else
9
+__attribute__((address_space(1))) int foo[1] = { 1234 };
10
+#endif
11
12
+#define N 1
13
14
+template<typename T>
15
+int test_global_var() {
16
+ hc::array_view<T,1> a0(N);
17
+ hc::parallel_for_each(a0.get_extent(),[=] (hc::index<1> i) [[hc]] {
18
+ if (i[0] == 0) {
19
+ foo[i[0]]++;
20
+ a0[i] = (T)foo[i[0]];
21
+ }
22
+ }).wait();
23
+ return (int)a0[0];
24
+}
25
26
27
+int main() {
28
+ int n0 = test_global_var<float>();
29
+ int n1 = test_global_var<double>();
30
31
+ int errors = 0;
32
+ if (n0!=1235)
33
+ errors++;
34
+ if (n1!=1236)
35
36
37
+ return errors;
38
0 commit comments