1 #include <assert.h> 2 3 #define ASSIGN_SX(N) \ 4 s##N.a1 = 1; \ 5 s##N.a2 = 2; \ 6 s##N.a3 = 3; \ 7 s##N.a4 = 4; \ 8 s##N.a5 = 5; \ 9 s##N.a6 = 6; \ 10 s##N.a7 = 7; \ 11 s##N.a8 = 8; \ 12 s##N.a9 = 9; \ 13 s##N.a10 = 10; 14 15 #define ASSERT_SX(N) \ 16 assert (s##N.a1 == 1); \ 17 assert (s##N.a2 == 2); \ 18 assert (s##N.a3 == 3); \ 19 assert (s##N.a4 == 4); \ 20 assert (s##N.a5 == 5); \ 21 assert (s##N.a6 == 6); \ 22 assert (s##N.a7 == 7); \ 23 assert (s##N.a8 == 8); \ 24 assert (s##N.a9 == 9); \ 25 assert (s##N.a10 == 10); 26 27 struct S1 28 { 29 unsigned a : 10; 30 unsigned b : 20; 31 }; 32 33 struct S2 34 { 35 unsigned a1 : 10; 36 unsigned a2 : 10; 37 unsigned a3 : 10; 38 unsigned a4 : 10; 39 unsigned a5 : 10; 40 unsigned a6 : 10; 41 unsigned a7 : 10; 42 unsigned a8 : 10; 43 unsigned a9 : 10; 44 unsigned a10 : 10; 45 }; 46 47 struct S3 48 { 49 unsigned a1 : 10; 50 unsigned a2 : 9; 51 unsigned a3 : 8; 52 unsigned a4 : 7; 53 unsigned a5 : 6; 54 unsigned a6 : 5; 55 unsigned a7 : 6; 56 unsigned a8 : 7; 57 unsigned a9 : 8; 58 unsigned a10 : 9; 59 }; 60 61 struct S4 62 { 63 unsigned a1 : 10; 64 int a2 : 9; 65 unsigned a3 : 8; 66 int a4 : 7; 67 unsigned a5 : 6; 68 int a6 : 5; 69 unsigned a7 : 6; 70 int a8 : 7; 71 unsigned a9 : 8; 72 int a10 : 9; 73 }; 74 75 struct S5 76 { 77 unsigned a1 : 31; 78 int a2 : 9; 79 unsigned a3 : 17; 80 int a4 : 7; 81 unsigned a5 : 6; 82 int a6 : 5; 83 unsigned long a7 : 55; 84 int a8 : 7; 85 unsigned a9 : 8; 86 int a10 : 9; 87 }; 88 89 int main()90main () 91 { 92 struct S1 s1; 93 94 #pragma omp target map(to: s1) 95 { 96 s1.a = 2; 97 s1.b = 3; 98 } 99 100 assert (s1.a == 2); 101 assert (s1.b == 3); 102 103 struct S2 s2; 104 105 #pragma omp target map(to: s2) 106 { 107 ASSIGN_SX (2) 108 } 109 110 ASSERT_SX (2) 111 112 struct S3 s3; 113 114 #pragma omp target map(to: s3) 115 { 116 ASSIGN_SX (3) 117 } 118 119 ASSERT_SX (3) 120 121 struct S4 s4; 122 123 #pragma omp target map(to: s4) 124 { 125 ASSIGN_SX (4) 126 } 127 128 ASSERT_SX (4) 129 130 struct S4 s5; 131 132 s5.a1 = 0; 133 s5.a2 = 1; 134 s5.a3 = 2; 135 s5.a4 = 3; 136 s5.a5 = 4; 137 s5.a6 = 5; 138 s5.a7 = 6; 139 s5.a8 = 7; 140 s5.a9 = 8; 141 s5.a10 = 9; 142 143 #pragma omp target map(to: s5) 144 { 145 s5.a1++; 146 s5.a2++; 147 s5.a3++; 148 s5.a4++; 149 s5.a5++; 150 s5.a6++; 151 s5.a7++; 152 s5.a8++; 153 s5.a9++; 154 s5.a10++; 155 } 156 157 ASSERT_SX (5) 158 159 return 0; 160 } 161