From: Dongju Chae Date: Tue, 26 Nov 2019 11:07:28 +0000 (+0900) Subject: [FIX/RUN_SYNC] Fix the timing issue due to early inference completion X-Git-Tag: accepted/tizen/unified/20220103.130045~564 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6960a555a726197a20c5c591824be0c1499539de;p=platform%2Fadaptation%2Fnpu%2Ftrix-engine.git [FIX/RUN_SYNC] Fix the timing issue due to early inference completion This commit fixes the timing issue caused when `run_sync()`'s inference is finished too early. This patch introduces an extra variable to check whether the callback is called or not. Signed-off-by: Dongju Chae --- diff --git a/src/core/ip/plugin-comm-ip.c b/src/core/ip/plugin-comm-ip.c index d7e8eb1..bcd3e66 100644 --- a/src/core/ip/plugin-comm-ip.c +++ b/src/core/ip/plugin-comm-ip.c @@ -943,6 +943,7 @@ out: typedef struct { npu_device *npu_dev; output_buffer *user_output; + bool handled; } sync_cb_data; /** @@ -969,6 +970,7 @@ static void sync_callback (output_buffer *output, uint64_t sequence, if (err < 0) { logerr (TAG, "Error setting output buffer, errno: %d\n", err); } + cb_data->handled = true; /** wake the sync process up, if any */ DEVICE_WAKEUP(); @@ -997,6 +999,7 @@ int runNPU_sync(npudev_h dev, uint32_t modelid, const input_buffers *input, sync_cb_data cb_data = { .npu_dev = dev, .user_output = output, + .handled = false, }; npu_dev = dev; @@ -1015,7 +1018,8 @@ int runNPU_sync(npudev_h dev, uint32_t modelid, const input_buffers *input, /** wait until the internal callback is finished */ DEVICE_LOCK(); - DEVICE_WAIT(); + if (!cb_data.handled) + DEVICE_WAIT(); DEVICE_UNLOCK(); return 0;