check transfer  0.1
Check data transfer for SDAccell OpenCL application
check_cnt_m2.cl
Go to the documentation of this file.
1 
2 #define BUFFER_SIZE 1024
3 #define LOOP_SIZE 1024
4 
5 static bool check_data64( ulong data_i, ulong expect );
6 
7 static void check_data( __global ulong8 *pStatus, uint size );
8 
9 static void read_input(__global ulong8 *in, uint size);
10 
11 pipe ulong8 pipe_input __attribute__((xcl_reqd_pipe_depth(512)));
12 
13 
14 __kernel
15 __attribute__ ((reqd_work_group_size(1,1,1)))
16 void check_read_input(
17  __global ulong8 *src,
18  const uint size
19  )
20 {
21  read_input(src, size);
22 }
23 
24 
25 __kernel
26 __attribute__ ((reqd_work_group_size(1,1,1)))
27 void check_cnt_m2a(
28  __global uint16 *pStatus,
29  const uint size
30  )
31 {
32  check_data( pStatus, size );
33 
34 }
35 
36 //__kernel
37 //__attribute__ ((reqd_work_group_size(1,1,1)))
38 //__attribute__ ((xcl_dataflow))
39 //void check_cnt_m2b(
40 // __global ulong8 *src,
41 // __global uint16 *pStatus,
42 // const ulong8 expect,
43 // const uint size
44 // )
45 //{
46 //
47 // read_input(src, size);
48 // check_data( pStatus, expect, size );
49 //
50 //}
51 
52 
53 void read_input(__global ulong8 *in, uint size)
54 {
55  __attribute__((xcl_pipeline_loop))
56  for (int ii = 0 ; ii < size ; ii++)
57  {
58  write_pipe_block( pipe_input, &in[ii] );
59  }
60 }
61 
62 
63 //__attribute__ ((xcl_dataflow))
64 static void check_data( __global ulong8 *pStatus, uint size )
65 {
66 
67  uint flagError=0;
68  uint blockRd;
69  uint blockOk;
70  uint blockError;
71 
72 
73  ulong8 temp0, temp1;
74 
75  ulong8 checkStatus;
76 
77  bool flag0=0;
78  bool flag1=0;
79  bool flag2=0;
80  bool flag3=0;
81  bool flag4=0;
82  bool flag5=0;
83  bool flag6=0;
84  bool flag7=0;
85 
86  bool word_error;
87  uint cnt_error=0;
88  ulong8 addConst;
89 
90  //__global ulong8 *pStatusUlong = (ulong8*)pStatus;
91 
92  checkStatus = pStatus[0];
93 
94  temp1 = pStatus[1];
95  addConst = pStatus[2];
96 
97  blockRd = checkStatus.s0 >> 32;
98  blockOk = checkStatus.s1 & 0xFFFFFFFF;
99  blockError = checkStatus.s1 >> 32;
100  //printf( "krnl - %.4x %d %d %d \n", checkStatus.s0, blockRd, blockOk, blockError );
101 
102 
103 
104 // printf( "krnl: input0=%p\n", input0 );
105 // printf( "krnl: pStatus=%p\n", pStatus);
106 // printf( "krnl: size=%d\n", size);
107 //
108 // //for( int ii=0; ii<8; ii++ )
109 // printf( "krnl: expect(%X)= %lX\n", 0, temp1.s0 );
110 // printf( "krnl: expect(%X)= %lX\n", 1, temp1.s1 );
111 // printf( "krnl: expect(%X)= %lX\n", 2, temp1.s2 );
112 // printf( "krnl: expect(%X)= %lX\n", 3, temp1.s3 );
113 // printf( "krnl: expect(%X)= %lX\n", 4, temp1.s4 );
114 // printf( "krnl: expect(%X)= %lX\n", 5, temp1.s5 );
115 // printf( "krnl: expect(%X)= %lX\n", 6, temp1.s6 );
116 // printf( "krnl: expect(%X)= %lX\n", 7, temp1.s7 );
117 
118 
119  __attribute__((xcl_pipeline_loop))
120  for ( int ii=0; ii<size; ii++)
121  {
122 
123  //word_error=0;
124  read_pipe_block( pipe_input, &temp0 );
125 
126  {
127  flag0 |= check_data64( temp0.s0, temp1.s0 );
128  flag1 |= check_data64( temp0.s1, temp1.s1 );
129  flag2 |= check_data64( temp0.s2, temp1.s2 );
130  flag3 |= check_data64( temp0.s3, temp1.s3 );
131  flag4 |= check_data64( temp0.s4, temp1.s4 );
132  flag5 |= check_data64( temp0.s5, temp1.s5 );
133  flag6 |= check_data64( temp0.s6, temp1.s6 );
134  flag7 |= check_data64( temp0.s7, temp1.s7 );
135  }
136 
137 // if( flag0 || flag1 || flag2 || flag3 || flag4 || flag5 || flag6 || flag7 )
138 // {
139 // flagError=1;
140 // word_error=1;
141 // cnt_error++;
142 //
143 // }
144 
145 
146 // if( word_error && cnt_error<4 )
147 // {
148 // printf( "0: %.4X %.4X %.4X %.4X %.4X %.4X %.4X %.4X ii=%d\n",
149 // temp0.s0,
150 // temp0.s1,
151 // temp0.s2,
152 // temp0.s3,
153 // temp0.s4,
154 // temp0.s5,
155 // temp0.s6,
156 // temp0.s7,
157 // ii
158 // );
159 //
160 // printf( "1: %.4X %.4X %.4X %.4X %.4X %.4X %.4X %.4X %d\n\n",
161 // temp1.s0,
162 // temp1.s1,
163 // temp1.s2,
164 // temp1.s3,
165 // temp1.s4,
166 // temp1.s5,
167 // temp1.s6,
168 // temp1.s7,
169 // word_error
170 //
171 // );
172 // }
173 
174  temp1.s0 +=addConst.s0;
175  temp1.s1 +=addConst.s1;
176  temp1.s2 +=addConst.s2;
177  temp1.s3 +=addConst.s3;
178  temp1.s4 +=addConst.s4;
179  temp1.s5 +=addConst.s5;
180  temp1.s6 +=addConst.s6;
181  temp1.s7 +=addConst.s7;
182 
183  }
184 
185  if( flag0 || flag1 || flag2 || flag3 || flag4 || flag5 || flag6 || flag7 )
186  {
187  flagError=1;
188  }
189 
190 
191  if( flagError )
192  blockError++;
193  else
194  blockOk++;
195 
196  blockRd++;
197  checkStatus.s0 = ((ulong)blockRd)<<32 | 0xAA55;
198  checkStatus.s1 = ((ulong)blockError)<<32 | blockOk;
199 
200  pStatus[0] = checkStatus;
201  pStatus[1] = temp1;
202 
203  //printf( "krnl - %.4x %d %d %d - Ok\n", checkStatus.s0, blockRd, blockOk, blockError );
204 }
205 
206 
207 __attribute__((xcl_pipeline_loop))
208 static bool check_data64( ulong data_i, ulong expect )
209 {
210  bool ret;
211 
212  if( data_i==expect )
213  ret=0;
214  else
215  ret=1;
216 
217  return ret;
218 }