[Beignet] [PATCH 8/9 newRT] Move event profiling exec time function to gen dir
junyan.he at inbox.com
junyan.he at inbox.com
Sat Apr 1 09:43:33 UTC 2017
From: Junyan He <junyan.he at intel.com>
Signed-off-by: Junyan He <junyan.he at intel.com>
---
src/CMakeLists.txt | 1 +
src/cl_event.c | 52 ++---------------------------------
src/gen/cl_event_gen.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 77 insertions(+), 50 deletions(-)
create mode 100644 src/gen/cl_event_gen.c
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 33b2e8d..05c5302 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -111,6 +111,7 @@ set(OPENCL_SRC
gen/cl_mem_gen.c
gen/cl_image_gen.c
gen/cl_compiler_gen.c
+ gen/cl_event_gen.c
performance.c)
if (X11_FOUND)
diff --git a/src/cl_event.c b/src/cl_event.c
index 6b018ee..cdc47fd 100644
--- a/src/cl_event.c
+++ b/src/cl_event.c
@@ -24,56 +24,8 @@
#include <stdio.h>
// TODO: Need to move it to some device related file later.
-static void
-cl_event_update_timestamp_gen(cl_event event, cl_int status)
-{
- cl_ulong ts = 0;
-
- if ((event->exec_data.type == EnqueueCopyBufferRect) ||
- (event->exec_data.type == EnqueueCopyBuffer) ||
- (event->exec_data.type == EnqueueCopyImage) ||
- (event->exec_data.type == EnqueueCopyBufferToImage) ||
- (event->exec_data.type == EnqueueCopyImageToBuffer) ||
- (event->exec_data.type == EnqueueNDRangeKernel) ||
- (event->exec_data.type == EnqueueFillBuffer) ||
- (event->exec_data.type == EnqueueFillImage)) {
-
- if (status == CL_QUEUED || status == CL_SUBMITTED) {
- cl_gpgpu_event_get_gpu_cur_timestamp(event->queue->ctx->drv, &ts);
-
- if (ts == CL_EVENT_INVALID_TIMESTAMP)
- ts++;
- event->timestamp[CL_QUEUED - status] = ts;
- return;
- } else if (status == CL_RUNNING) {
- assert(event->exec_data.gpgpu);
- return; // Wait for the event complete and get run and complete then.
- } else {
- assert(event->exec_data.gpgpu);
- cl_gpgpu_event_get_exec_timestamp(event->exec_data.gpgpu, 0, &ts);
- if (ts == CL_EVENT_INVALID_TIMESTAMP)
- ts++;
- event->timestamp[2] = ts;
- cl_gpgpu_event_get_exec_timestamp(event->exec_data.gpgpu, 1, &ts);
- if (ts == CL_EVENT_INVALID_TIMESTAMP)
- ts++;
- event->timestamp[3] = ts;
-
- /* Set the submit time the same as running time if it is later. */
- if (event->timestamp[1] > event->timestamp[2] ||
- event->timestamp[2] - event->timestamp[1] > 0x0FFFFFFFFFF /*Overflowed */)
- event->timestamp[1] = event->timestamp[2];
-
- return;
- }
- } else {
- cl_gpgpu_event_get_gpu_cur_timestamp(event->queue->ctx->drv, &ts);
- if (ts == CL_EVENT_INVALID_TIMESTAMP)
- ts++;
- event->timestamp[CL_QUEUED - status] = ts;
- return;
- }
-}
+extern void
+cl_event_update_timestamp_gen(cl_event event, cl_int status);
LOCAL void
cl_event_update_timestamp(cl_event event, cl_int state)
diff --git a/src/gen/cl_event_gen.c b/src/gen/cl_event_gen.c
new file mode 100644
index 0000000..aeefb29
--- /dev/null
+++ b/src/gen/cl_event_gen.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "cl_gen.h"
+
+struct gen_gpgpu;
+extern void gen_gpgpu_event_get_exec_timestamp(struct gen_gpgpu *gpgpu, int index, uint64_t *ret_ts);
+extern void gen_gpgpu_event_get_gpu_cur_timestamp(struct gen_gpgpu *gpgpu, uint64_t *ret_ts);
+
+LOCAL void
+cl_event_update_timestamp_gen(cl_event event, cl_int status)
+{
+ cl_ulong ts = 0;
+
+ if ((event->exec_data.type == EnqueueCopyBufferRect) ||
+ (event->exec_data.type == EnqueueCopyBuffer) ||
+ (event->exec_data.type == EnqueueCopyImage) ||
+ (event->exec_data.type == EnqueueCopyBufferToImage) ||
+ (event->exec_data.type == EnqueueCopyImageToBuffer) ||
+ (event->exec_data.type == EnqueueNDRangeKernel) ||
+ (event->exec_data.type == EnqueueFillBuffer) ||
+ (event->exec_data.type == EnqueueFillImage)) {
+
+ if (status == CL_QUEUED || status == CL_SUBMITTED) {
+ gen_gpgpu_event_get_gpu_cur_timestamp(event->exec_data.gpgpu, &ts);
+
+ if (ts == CL_EVENT_INVALID_TIMESTAMP)
+ ts++;
+ event->timestamp[CL_QUEUED - status] = ts;
+ return;
+ } else if (status == CL_RUNNING) {
+ assert(event->exec_data.gpgpu);
+ return; // Wait for the event complete and get run and complete then.
+ } else {
+ assert(event->exec_data.gpgpu);
+ gen_gpgpu_event_get_exec_timestamp(event->exec_data.gpgpu, 0, &ts);
+ if (ts == CL_EVENT_INVALID_TIMESTAMP)
+ ts++;
+ event->timestamp[2] = ts;
+ gen_gpgpu_event_get_exec_timestamp(event->exec_data.gpgpu, 1, &ts);
+ if (ts == CL_EVENT_INVALID_TIMESTAMP)
+ ts++;
+ event->timestamp[3] = ts;
+
+ /* Set the submit time the same as running time if it is later. */
+ if (event->timestamp[1] > event->timestamp[2] ||
+ event->timestamp[2] - event->timestamp[1] > 0x0FFFFFFFFFF /*Overflowed */)
+ event->timestamp[1] = event->timestamp[2];
+
+ return;
+ }
+ } else {
+ gen_gpgpu_event_get_gpu_cur_timestamp(event->exec_data.gpgpu, &ts);
+ if (ts == CL_EVENT_INVALID_TIMESTAMP)
+ ts++;
+ event->timestamp[CL_QUEUED - status] = ts;
+ return;
+ }
+}
--
2.7.4
More information about the Beignet
mailing list