Skip to content

Commit 30ddaa4

Browse files
authored
print thread id in vODLA Adapter (#875)
* Update version * Print thread id in vODLA Adapter. * Moved getpid to DEBUG mode because system call is expensive.
1 parent 3be81f0 commit 30ddaa4

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
cmake_minimum_required(VERSION 3.14.5)
1818

1919
set(PROJECT_NAME "HALO_STABLE_SDK_2.3.1" HOMEPAGE_URL "https://github.com/alibaba/heterogeneity-aware-lowering-and-optimization")
20-
set(PROJECT_VERSION "0.7.6")
20+
set(PROJECT_VERSION "0.7.7")
2121

2222
project(${PROJECT_NAME} VERSION ${PROJECT_VERSION} LANGUAGES C CXX ASM)
2323

ODLA/platforms/vodla/vODLA.cpp

+26-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include <ODLA/odla.h>
22
#include <stdlib.h>
33
#include <string.h>
4+
#include <sys/syscall.h>
45
#include <sys/time.h>
6+
#include <unistd.h>
57
#include <vodh_common.h>
68

79
#include <atomic>
@@ -14,6 +16,7 @@
1416
#include <thread>
1517
#include <vector>
1618

19+
#define gettid() syscall(SYS_gettid)
1720
#define MAX_INPUT_TENSOR 256
1821
#define MAX_OUTPUT_TENSOR 256
1922

@@ -206,9 +209,9 @@ odla_status odla_AllocateDevice(const odla_vendor vendor,
206209
odla_device* device) {
207210
// Init, query and open vvodh devices
208211
#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";
210214
#endif
211-
212215
// create vODLA device
213216
odla_device dev = new _odla_device();
214217
if (dev == NULL) {
@@ -371,6 +374,10 @@ odla_status odla_AllocateDevice(const odla_vendor vendor,
371374

372375
odla_status odla_DestroyDevice(odla_device device) {
373376
// allocate device failed
377+
#ifdef DEBUG
378+
pid_t tid = gettid();
379+
std::cout << "[vODLA] INFO: thread " << tid << " destroy device\n";
380+
#endif
374381
if (device == NULL) {
375382
std::cout << "[vODLA] ERROR: NULL device, nothing to destroy.\n";
376383
return ODLA_FAILURE;
@@ -445,6 +452,8 @@ odla_status odla_BindToArgument(odla_value value, const odla_void* data_ptr,
445452

446453
auto idx = reinterpret_cast<std::uintptr_t>(value);
447454
#ifdef DEBUG
455+
pid_t tid = gettid();
456+
std::cout << "[vODLA] DEBUG: thread " << tid << " bind argument\n";
448457
std::cout << "[vODLA] DEBUG: Binding input idx: " << idx << "\n";
449458
#endif
450459
if (idx >= MAX_INPUT_TENSOR) {
@@ -469,6 +478,8 @@ odla_status odla_BindToOutput(odla_value value, odla_void* data_ptr,
469478

470479
auto idx = reinterpret_cast<std::uintptr_t>(value);
471480
#ifdef DEBUG
481+
pid_t tid = gettid();
482+
std::cout << "[vODLA] DEBUG: thread " << tid << " bind output\n";
472483
std::cout << "[vODLA] DEBUG: Binding output idx: " << idx << "\n";
473484
#endif
474485
if (idx >= MAX_OUTPUT_TENSOR) {
@@ -486,8 +497,9 @@ odla_status odla_BindToOutput(odla_value value, odla_void* data_ptr,
486497

487498
odla_status odla_CreateContext(odla_context* context) {
488499
#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
491503
<< " dev_list ptr " << &(g_dev->vodh_dev_list[0]) << " ctx "
492504
<< context << ", *ctx " << *context << std::endl;
493505
#endif
@@ -510,9 +522,9 @@ odla_status odla_CreateContext(odla_context* context) {
510522

511523
odla_status odla_DestroyContext(odla_context context) {
512524
#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;
516528
#endif
517529
vodh_ret ret = vodh_destroy_context(
518530
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,
889901
.output = NULL};
890902

891903
#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
894907
<< "\nres addr " << &vodh_infer_res << std::endl;
895908
#endif
896909

@@ -944,8 +957,10 @@ odla_status odla_ExecuteComputation(odla_computation comp, odla_context context,
944957
vodh_infer_opt.model.use_file = 1; // use file path instead of DMA
945958
vodh_infer_opt.context = context->vodla_context_;
946959
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
949964
#ifdef TIMING
950965
std::cout << "[vODLA] INFO: loop " << LOOP_CNT << " times.\n";
951966

tests/driver/test_driver.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919

2020
// RUN: %halo_compiler -version 2>&1 | FileCheck %s
2121

22-
// CHECK: Version: 0.7.6
22+
// CHECK: Version: 0.7.7
2323
// CHECK: HALO Repo:{{.*}} Rev:

0 commit comments

Comments
 (0)