@@ -32,6 +32,8 @@ unsigned s_rounds = 128;
32
32
unsigned m_rounds = 32 ;
33
33
unsigned device_index = 0 ;
34
34
unsigned threads = 2 ;
35
+ unsigned vf_cnt;
36
+ bool vf_test = false ;
35
37
std::vector<unsigned > exec_list;
36
38
std::string dpu = " nop" ;
37
39
@@ -58,6 +60,8 @@ usage(const std::string& prog)
58
60
std::cout << " \t " << " -i" << " : specify device index (0 for non-sriov or VF0, 1, 2, 3 for VFs)\n " ;
59
61
std::cout << " \t " << " -t" << " : n thread to be created in thread test (default 2)\n " ;
60
62
std::cout << " \t " << " -e" << " : specify tests to add to thread test (default vadd) [-e test1 -e test2 ...]\n " ;
63
+ std::cout << " \t " << " -v" << " : apply each thread to corresponding vf, max 4\n " ;
64
+ std::cout << " \t " << " -l" << " : use xclbin flow if available\n " ;
61
65
std::cout << " \t " << " -h" << " : print this help message\n\n " ;
62
66
std::cout << " \t " << " Example Usage: ./xrt_test <# for stress test> -s 20 -d vadd -x vadd\n " ;
63
67
std::cout << " \t " << " Run stress test with Vadd kernel and xclbin for 20 rounds\n " ;
@@ -1026,6 +1030,7 @@ void
1026
1030
TEST_xrt_threads (int device_index, arg_type& arg)
1027
1031
{
1028
1032
std::vector<std::thread> m_threads;
1033
+ std::vector<bool > m_failed (threads, false );
1029
1034
1030
1035
if (exec_list.empty ())
1031
1036
exec_list.insert (exec_list.begin (), threads, 0 );
@@ -1034,16 +1039,42 @@ TEST_xrt_threads(int device_index, arg_type& arg)
1034
1039
else
1035
1040
threads = exec_list.size (); // if more tests than threads, increase threads to run all tests
1036
1041
1037
- for (int i = 0 ; i < threads; i++) {
1038
- m_threads.push_back (std::thread ([&, i](){
1039
- std::cout << " Thread " << i << " started" << std::endl;
1040
- test_list[exec_list[i]].func (device_index, test_list[exec_list[i]].arg );
1041
- })
1042
- );
1042
+ if (vf_test) {
1043
+ for (int i = 0 ; i < threads; i++) {
1044
+ m_threads.push_back (std::thread ([&, i](){
1045
+ std::cout << " Thread " << i << " started" << std::endl;
1046
+ try {
1047
+ test_list[exec_list[i]].func (i % vf_cnt, test_list[exec_list[i]].arg );
1048
+ } catch (const std::exception& ex) {
1049
+ m_failed[i] = true ;
1050
+ std::cerr << " Thread " << i << " failed: " << ex.what () << std::endl;
1051
+ }
1052
+ })
1053
+ );
1054
+ }
1055
+ }
1056
+ else {
1057
+ for (int i = 0 ; i < threads; i++) {
1058
+ m_threads.push_back (std::thread ([&, i](){
1059
+ std::cout << " Thread " << i << " started" << std::endl;
1060
+ try {
1061
+ test_list[exec_list[i]].func (device_index, test_list[exec_list[i]].arg );
1062
+ } catch (const std::exception& ex) {
1063
+ m_failed[i] = true ;
1064
+ std::cerr << " Thread " << i << " failed: " << ex.what () << std::endl;
1065
+ }
1066
+ })
1067
+ );
1068
+ }
1043
1069
}
1044
1070
1045
1071
for (int i = 0 ; i < threads; i++)
1046
- m_threads[i].join ();
1072
+ m_threads[i].join ();
1073
+
1074
+ for (int i = 0 ; i < threads; i++) {
1075
+ if (m_failed[i])
1076
+ throw std::runtime_error (" At least one thread has failed" );
1077
+ }
1047
1078
1048
1079
}
1049
1080
@@ -1108,7 +1139,7 @@ main(int argc, char **argv)
1108
1139
1109
1140
try {
1110
1141
int option, val;
1111
- while ((option = getopt (argc, argv, " :c:s:m:x:d:i:t:e:lh" )) != -1 ) {
1142
+ while ((option = getopt (argc, argv, " :c:s:m:x:d:i:t:e:v: lh" )) != -1 ) {
1112
1143
switch (option) {
1113
1144
case ' c' : {
1114
1145
val = std::stoi (optarg);
@@ -1169,10 +1200,21 @@ main(int argc, char **argv)
1169
1200
return 1 ;
1170
1201
}
1171
1202
}
1172
- case ' l' :
1173
- std::cout << " swtiching to xclbin flow" << std::endl;
1174
- elf_flow = false ;
1203
+ case ' l' : {
1204
+ std::cout << " swtiching to xclbin flow" << std::endl;
1205
+ elf_flow = false ;
1175
1206
break ;
1207
+ }
1208
+ case ' v' : {
1209
+ val = std::stoi (optarg);
1210
+ if (val > 4 || val < 1 ) {
1211
+ std::cout << " VF count is between 1-4" << std::endl;
1212
+ return 1 ;
1213
+ }
1214
+ vf_cnt = val;
1215
+ vf_test = true ;
1216
+ break ;
1217
+ }
1176
1218
case ' h' :
1177
1219
usage (program);
1178
1220
return 0 ;
0 commit comments