check transfer  0.1
Check data transfer for SDAccell OpenCL application
Functions | Variables
main.cpp File Reference
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <assert.h>
#include "ipc.h"
#include "exceptinfo.h"
#include "table_engine_console.h"
#include "tf_checktransferout.h"
#include "tf_checktransferin.h"
#include "tf_device.h"
#include "parse_cmd.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 Start point for host application. More...
 
void signal_handler (int signo)
 

Variables

static volatile int exit_flag = 0
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Start point for host application.

Parameters
argcNumber of arguments argv Pointer of argumnts

Arguments:

main():

-mode <mode> : 1 - check input, 2 - check output, 3 - check input and output -table <flag_show> : 1 - show table, 0 - do not show table -time <time> : execution time [s],

TF_Device:

-file       <path>          : fullpath for xclbin, default "../binary_container_1.xclbin"

TF_CheckTransferIn & TF_CheckTransferOut:

-size       <n>             : size block of kilobytes, default 64
-metric <n>             : 0 - binary:  1MB=2^10=1024*1024=1048576 bytes,

Definition at line 54 of file main.cpp.

References TableEngine::CreateTable(), exit_flag, TableEngine::GetConsolePos(), GetFromCommnadLine(), TF_Test::GetResult(), _except_info_t::info, IPC_delay(), IPC_getch(), IPC_getTickCount(), IPC_kbhit(), TF_Test::isComplete(), TF_Test::Prepare(), TableEngine::SetConsolePos(), signal_handler(), TF_Test::Start(), TF_Test::StepMainThread(), TF_Test::StepTable(), and TF_Test::Stop().

55 {
56  int X = 0;
57  int Y = 0;
58  int tableMode;
59  int timeMode;
60  long testStartTime;
61  int testMode; // 1 - input, 2 - output, 3 - input and output
62 
63  const char *headers[] = {
64  "TIME", "BLOCK_WR", "BLOCK_RD", "BLOCK_OK", "BLOCK_ERROR", "SPD_CURRENT", "SPD_AVR",
65  };
66 
67  TableEngine *pTable = new TableEngineConsole();
68 
69 
70 
71  tableMode = GetFromCommnadLine( argc, argv, "-table", 0 );
72  timeMode = GetFromCommnadLine( argc, argv, "-time", 10 );
73  testMode = GetFromCommnadLine( argc, argv, "-mode", 2 );
74 
75 
76  if( tableMode )
77  pTable->CreateTable(headers, sizeof(headers)/sizeof(headers[0]), 0);
78 
79  printf( "\n\n\n\n"); //FIXME - it is need for output under table
80 
81  signal(SIGINT, signal_handler);
82 
83  TF_Device device( argc, argv );
84 
85  TF_Test *pTest[2];
86  int testCnt=0;
87 
88  try {
89 
90  if( testMode & 2 )
91  {
92  TF_CheckTransferOut *pTestOut = new TF_CheckTransferOut( pTable, &device, argc, argv );
93  pTest[testCnt++]=pTestOut;
94  }
95 
96  if( testMode & 1 )
97  {
98  TF_CheckTransferIn *pTestIn = new TF_CheckTransferIn( pTable, &device, argc, argv );
99  pTest[testCnt++]=pTestIn;
100  }
101 
102 #if 0 // parallel executing prepare functions
103  for( int ii=0; ; ii++)
104  {
105  int flagExit=1;
106  for( int jj=0; jj<testCnt; jj++)
107  {
108  flagExit &=pTest[jj]->Prepare(ii);
109  }
110  if( flagExit )
111  break;
112  }
113 #else // sequence executing prepare functions
114 
115 
116  for( int jj=0; jj<testCnt; jj++)
117  {
118  int flagExit=1;
119  for( int ii=0; ; ii++)
120  {
121  flagExit=pTest[jj]->Prepare(ii);
122  if( flagExit )
123  break;
124  }
125  }
126 #endif
127 
128  if( tableMode )
129  pTable->GetConsolePos(X,Y);
130 
131  for( int jj=0; jj<testCnt; jj++ )
132  {
133  pTest[jj]->Start();
134  IPC_delay(100); // FIXME
135 
136  }
137 
138 #if defined(IS_STEP_MAIN_THREAD)
139  IPC_TIMEVAL start_time;
140  IPC_TIMEVAL curr_time;
141 #endif
142 
143 
144  testStartTime = IPC_getTickCount();
145 
146  int count = 0;
147  while(1) {
148 #if defined(IS_STEP_MAIN_THREAD)
149  IPC_getTime(&start_time);
150 
151  for(;;) {
152  for( int jj=0; jj<testCnt; jj++ )
153  {
154  pTest[jj]->StepMainThread();
155  }
156  IPC_getTime(&curr_time);
157  if(IPC_getDiffTime(&start_time, &curr_time) > 100) {
158  break;
159  }
160  IPC_delay(10);
161  }
162 #else
163  IPC_delay(100);
164 #endif
165 
166  long currentTime = IPC_getTickCount();
167  if( timeMode>0 )
168  {
169  if( (currentTime - testStartTime) >= timeMode*1000 )
170  exit_flag=2;
171  }
172 
173  if( exit_flag )
174  {
175  for( int jj=0; jj<testCnt; jj++ )
176  {
177  pTest[jj]->Stop();
178  }
179  }
180 
181  int flagExit=1;
182  for( int jj=0; jj<testCnt; jj++ )
183  {
184  flagExit &= pTest[jj]->isComplete();
185  }
186 
187  if( flagExit )
188  break;
189 
190 
191  if( tableMode )
192  {
193  for( int jj=0; jj<testCnt; jj++ )
194  {
195  pTest[jj]->StepTable();
196  }
197  }
198 
199  ++count;
200 
201  if( IPC_kbhit() )
202  {
203  // \todo - don't work
204  int key = IPC_getch();
205  if( 27==key )
206  break;
207  }
208  }
209 
210  if( tableMode )
211  pTable->SetConsolePos(X, Y+1);
212 
213 
214  for( int jj=0; jj<testCnt; jj++ )
215  {
216  pTest[jj]->GetResult();
217  }
218 
219  for( int jj=0; jj<testCnt; jj++ )
220  {
221  delete pTest[jj]; pTest[jj]=NULL;
222  }
223 
224  } catch(except_info_t& err) {
225  printf( "\n\n\n\n \n%s\n", err.info.c_str());
226  } catch( ... ) {
227  printf( "Unknown error in application!\n");
228  }
229 
230  delete pTable;
231 
232  return 0;
233 }
virtual void Start()=0
Start of test.
virtual int Prepare(int cnt)=0
Prepare test.
virtual void StepMainThread()
Don&#39;t use. Reserve for future.
Definition: tf_test.h:61
virtual void GetConsolePos(int &X, int &Y)=0
virtual void Stop()
Stop of test.
Definition: tf_test.h:46
Base class for testing device.
Definition: tf_test.h:16
std::string info
Definition: exceptinfo.h:8
int IPC_kbhit(void)
Definition: ipc.cpp:55
virtual void GetResult()
Show result of test.
Definition: tf_test.h:65
void IPC_delay(int ms)
Definition: ipc.cpp:16
long IPC_getTickCount()
Definition: ipc.cpp:66
static volatile int exit_flag
Definition: main.cpp:19
int GetFromCommnadLine(int argc, char **argv, const char *name, int defValue)
Get integer value from command line.
Definition: parse_cmd.cpp:29
check data transfer from host to device
virtual void StepTable()
Show table.
Definition: tf_test.h:58
virtual int CreateTable(const char *pColumnName[], unsigned nCount, unsigned isTStudio)=0
virtual void SetConsolePos(int X, int Y)=0
common data for OpenCL device
Definition: tf_device.h:17
void signal_handler(int signo)
Definition: main.cpp:21
check data transfer from device to host
int IPC_getch(void)
Definition: ipc.cpp:26
virtual int isComplete()
Return 1 when test is complete.
Definition: tf_test.h:49

◆ signal_handler()

void signal_handler ( int  signo)

Definition at line 21 of file main.cpp.

References exit_flag.

Referenced by main().

22 {
23  exit_flag = 1;
24 }
static volatile int exit_flag
Definition: main.cpp:19

Variable Documentation

◆ exit_flag

volatile int exit_flag = 0
static

Definition at line 19 of file main.cpp.

Referenced by main(), and signal_handler().