1
1
#include < ODLA/odla.h>
2
2
#include < stdlib.h>
3
3
#include < string.h>
4
+ #include < sys/syscall.h>
4
5
#include < sys/time.h>
6
+ #include < unistd.h>
5
7
#include < vodh_common.h>
6
8
7
9
#include < atomic>
14
16
#include < thread>
15
17
#include < vector>
16
18
19
+ #define gettid () syscall(SYS_gettid)
17
20
#define MAX_INPUT_TENSOR 256
18
21
#define MAX_OUTPUT_TENSOR 256
19
22
@@ -206,9 +209,9 @@ odla_status odla_AllocateDevice(const odla_vendor vendor,
206
209
odla_device* device) {
207
210
// Init, query and open vvodh devices
208
211
#ifdef DEBUG
209
- std::cout << " [vODLA] INFO: Start initializing vodh device.\n " ;
212
+ pid_t tid = gettid ();
213
+ std::cout << " [vODLA] INFO: thread " << tid << " allocate device\n " ;
210
214
#endif
211
-
212
215
// create vODLA device
213
216
odla_device dev = new _odla_device ();
214
217
if (dev == NULL ) {
@@ -371,6 +374,10 @@ odla_status odla_AllocateDevice(const odla_vendor vendor,
371
374
372
375
odla_status odla_DestroyDevice (odla_device device) {
373
376
// allocate device failed
377
+ #ifdef DEBUG
378
+ pid_t tid = gettid ();
379
+ std::cout << " [vODLA] INFO: thread " << tid << " destroy device\n " ;
380
+ #endif
374
381
if (device == NULL ) {
375
382
std::cout << " [vODLA] ERROR: NULL device, nothing to destroy.\n " ;
376
383
return ODLA_FAILURE;
@@ -445,6 +452,8 @@ odla_status odla_BindToArgument(odla_value value, const odla_void* data_ptr,
445
452
446
453
auto idx = reinterpret_cast <std::uintptr_t >(value);
447
454
#ifdef DEBUG
455
+ pid_t tid = gettid ();
456
+ std::cout << " [vODLA] DEBUG: thread " << tid << " bind argument\n " ;
448
457
std::cout << " [vODLA] DEBUG: Binding input idx: " << idx << " \n " ;
449
458
#endif
450
459
if (idx >= MAX_INPUT_TENSOR) {
@@ -469,6 +478,8 @@ odla_status odla_BindToOutput(odla_value value, odla_void* data_ptr,
469
478
470
479
auto idx = reinterpret_cast <std::uintptr_t >(value);
471
480
#ifdef DEBUG
481
+ pid_t tid = gettid ();
482
+ std::cout << " [vODLA] DEBUG: thread " << tid << " bind output\n " ;
472
483
std::cout << " [vODLA] DEBUG: Binding output idx: " << idx << " \n " ;
473
484
#endif
474
485
if (idx >= MAX_OUTPUT_TENSOR) {
@@ -486,8 +497,9 @@ odla_status odla_BindToOutput(odla_value value, odla_void* data_ptr,
486
497
487
498
odla_status odla_CreateContext (odla_context* context) {
488
499
#ifdef DEBUG
489
- std::cout << " [vODLA] DEBUG: odla_CreateContext thread "
490
- << std::this_thread::get_id () << " handler " << g_dev->vodh_hd
500
+ pid_t tid = gettid ();
501
+ std::cout << " [vODLA] DEBUG: thread " << tid << " create context\n " ;
502
+ std::cout << " [vODLA] DEBUG: odla_CreateContext handler " << g_dev->vodh_hd
491
503
<< " dev_list ptr " << &(g_dev->vodh_dev_list [0 ]) << " ctx "
492
504
<< context << " , *ctx " << *context << std::endl;
493
505
#endif
@@ -510,9 +522,9 @@ odla_status odla_CreateContext(odla_context* context) {
510
522
511
523
odla_status odla_DestroyContext (odla_context context) {
512
524
#ifdef DEBUG
513
- std::cout << " [vODLA] DEBUG: odla_DestroyContext thread "
514
- << std::this_thread::get_id () << " context " << context
515
- << std::endl;
525
+ pid_t tid = gettid ();
526
+ std::cout << " [vODLA] DEBUG: odla_DestroyContext thread " << tid
527
+ << " context " << context << std::endl;
516
528
#endif
517
529
vodh_ret ret = vodh_destroy_context (
518
530
g_dev->vodh_hd , &(g_dev->vodh_dev_list [0 ]), context->vodla_context_ );
@@ -889,8 +901,9 @@ odla_status odla_ExecuteComputation(odla_computation comp, odla_context context,
889
901
.output = NULL };
890
902
891
903
#ifdef DEBUG
892
- std::cout << " [vODLA] DEBUG: odla_ExecuteComputation thread "
893
- << std::this_thread::get_id () << " use opt addr " << &vodh_infer_opt
904
+ pid_t tid = gettid ();
905
+ std::cout << " [vODLA] DEBUG: tid " << tid
906
+ << " odla_ExecuteComputation use opt addr " << &vodh_infer_opt
894
907
<< " \n res addr " << &vodh_infer_res << std::endl;
895
908
#endif
896
909
@@ -944,8 +957,10 @@ odla_status odla_ExecuteComputation(odla_computation comp, odla_context context,
944
957
vodh_infer_opt.model .use_file = 1 ; // use file path instead of DMA
945
958
vodh_infer_opt.context = context->vodla_context_ ;
946
959
strcpy (vodh_infer_opt.model .weight_file , comp->wtFile .c_str ());
947
- std::cout << " [vODLA] INFO: start remote inference...\n " ;
948
-
960
+ #ifdef DEBUG
961
+ std::cout << " [vODLA] INFO: thread " << tid
962
+ << " start remote inference...\n " ;
963
+ #endif
949
964
#ifdef TIMING
950
965
std::cout << " [vODLA] INFO: loop " << LOOP_CNT << " times.\n " ;
951
966
0 commit comments