Skip to content

Commit afd31c9

Browse files
committed
Merge branch 'Enable_non_blocking_DAG_run' of https://github.com/RedisAI/RedisAI into Enable_non_blocking_DAG_run
2 parents aadb79c + d559588 commit afd31c9

File tree

16 files changed

+497
-613
lines changed

16 files changed

+497
-613
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ ENDIF()
2424
#----------------------------------------------------------------------------------------------
2525

2626
SET(CMAKE_CC_COMMON_FLAGS "-fPIC")
27+
IF (USE_PROFILE)
28+
SET(CMAKE_CC_COMMON_FLAGS "${CMAKE_CC_COMMON_FLAGS} -g -ggdb -fno-omit-frame-pointer")
29+
ENDIF()
2730

2831
IF (USE_COVERAGE)
2932
IF (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")

opt/Makefile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ make fetch # download and prepare dependant artifacts
3333
make build # compile and link
3434
DEBUG=1 # build for debugging
3535
COV=1 # build for coverage analysis (implies DEBUG=1)
36+
PROFILE=1 # enable profiling compile flags (and debug symbols) for release type.
37+
# You can consider this as build type release with debug symbols and -fno-omit-frame-pointer
3638
VARIANT=name # build variant `name`
3739
WHY=1 # explain CMake decisions (into /tmp/cmake.why)
3840
make clean # remove build artifacts
@@ -63,10 +65,11 @@ make docker # build docker image
6365
make docker-gpu-test # run GPU tests
6466

6567
fetch and build options:
66-
WITH_TF=0 # SKip TensofFlow
67-
WITH_TFLITE=0 # SKip TensofFlowLite
68-
WITH_PT=0 # Skip PyTorch
69-
WITH_ORT=0 # SKip ONNXRuntime
68+
WITH_TF=0 # SKip TensofFlow
69+
WITH_TFLITE=0 # SKip TensofFlowLite
70+
WITH_PT=0 # Skip PyTorch
71+
WITH_ORT=0 # SKip ONNXRuntime
72+
WITH_UNIT_TESTS=0 # SKip unit tests
7073

7174
device selection options (fetch, build, and test):
7275
CPU=1 # build for CPU
@@ -115,10 +118,17 @@ else
115118
USE_COVERAGE=off
116119
endif
117120

121+
ifeq ($(PROFILE),1)
122+
USE_PROFILE=on
123+
else
124+
USE_PROFILE=off
125+
endif
126+
118127
CMAKE_FLAGS += \
119128
-DDEPS_PATH=$(abspath $(DEPS_DIR)) \
120129
-DINSTALL_PATH=$(abspath $(INSTALL_DIR)) \
121130
-DUSE_COVERAGE=$(USE_COVERAGE) \
131+
-DUSE_PROFILE=$(USE_PROFILE) \
122132
-DREDISAI_GIT_SHA=\"$(GIT_SHA)\" \
123133
-DDEVICE=$(DEVICE)
124134

@@ -138,6 +148,10 @@ ifeq ($(WITH_ORT),0)
138148
CMAKE_FLAGS += -DBUILD_ORT=off
139149
endif
140150

151+
ifeq ($(WITH_UNIT_TESTS),0)
152+
CMAKE_FLAGS += -DPACKAGE_UNIT_TESTS=off
153+
endif
154+
141155
include $(MK)/defs
142156

143157
#----------------------------------------------------------------------------------------------

src/backends/onnxruntime.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define REDISMODULE_MAIN
12
#include <cuda_provider_factory.h>
23
#include "backends/onnxruntime.h"
34
#include "backends/util.h"

src/backends/tensorflow.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define REDISMODULE_MAIN
12
#include "backends/tensorflow.h"
23
#include "backends/util.h"
34
#include "tensor.h"

src/backends/tflite.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define REDISMODULE_MAIN
12
#include "backends/tflite.h"
23
#include "backends/util.h"
34
#include "tensor.h"

src/backends/torch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define REDISMODULE_MAIN
12
#include "backends/torch.h"
23
#include "backends/util.h"
34
#include "tensor.h"

src/background_workers.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ void *RedisAI_Run_ThreadMain(void *arg) {
175175
if (timedOut == 1) {
176176
queueEvict(run_queue_info->run_queue, item);
177177

178-
RedisAI_RunInfo *orig = rinfo->orig_copy;
178+
RedisAI_RunInfo *orig = rinfo->orig_copy;
179179
long long dagRefCount = RAI_DagRunInfoFreeShallowCopy(rinfo);
180180
if (dagRefCount == 0) {
181181
RedisAI_OnFinishCtx finish_ctx = (RedisAI_RunInfo *)orig;
182-
orig->OnFinish(finish_ctx, orig->private_data);
182+
orig->OnFinish(finish_ctx, orig->private_data);
183183
}
184184

185185
queueItem *evicted_item = item;
@@ -414,11 +414,11 @@ void *RedisAI_Run_ThreadMain(void *arg) {
414414
// If there was an error and the reference count for the dag
415415
// has gone to zero and the client is still around, we unblock
416416
if (dagError) {
417-
RedisAI_RunInfo *orig = rinfo->orig_copy;
417+
RedisAI_RunInfo *orig = rinfo->orig_copy;
418418
long long dagRefCount = RAI_DagRunInfoFreeShallowCopy(rinfo);
419419
if (dagRefCount == 0) {
420420
RedisAI_OnFinishCtx finish_ctx = (RedisAI_RunInfo *)orig;
421-
orig->OnFinish(finish_ctx, orig->private_data);
421+
orig->OnFinish(finish_ctx, orig->private_data);
422422
}
423423
} else {
424424
rinfo->dagDeviceCompleteOpCount += 1;
@@ -435,10 +435,10 @@ void *RedisAI_Run_ThreadMain(void *arg) {
435435
int dag_complete_after_run = RedisAI_DagComplete(batch_rinfo[0]);
436436

437437
long long dagRefCount = -1;
438-
RedisAI_RunInfo *orig;
438+
RedisAI_RunInfo *orig;
439439
if (device_complete == 1 || device_complete_after_run == 1) {
440-
RedisAI_RunInfo *evicted_rinfo = (RedisAI_RunInfo *)(evicted_items[0]->value);
441-
orig = evicted_rinfo->orig_copy;
440+
RedisAI_RunInfo *evicted_rinfo = (RedisAI_RunInfo *)(evicted_items[0]->value);
441+
orig = evicted_rinfo->orig_copy;
442442
// We decrease and get the reference count for the DAG.
443443
dagRefCount = RAI_DagRunInfoFreeShallowCopy(evicted_rinfo);
444444
}

src/background_workers.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
*
1010
*/
1111

12-
#if defined(__linux__)
13-
#define _GNU_SOURCE
14-
#endif
15-
1612
#ifndef SRC_BACKGROUND_WORKERS_H_
1713
#define SRC_BACKGROUND_WORKERS_H_
1814

15+
#if defined(__linux__) && !defined(_GNU_SOURCE)
16+
#define _GNU_SOURCE
17+
#endif
18+
1919
#include <pthread.h>
2020

2121
#include "config.h"

src/redisai.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define REDISMODULE_MAIN
12
#include "redismodule.h"
23
#include "tensor.h"
34

0 commit comments

Comments
 (0)