diff options
author | Junyan He <junyan.he@intel.com> | 2016-04-07 15:04:56 +0800 |
---|---|---|
committer | Junyan He <junyan.he@intel.com> | 2016-04-07 15:04:56 +0800 |
commit | d94e9af7947504aefc0117ff13965ae2123db47b (patch) | |
tree | 8358a85cbc7f98e80a1a50e70f1089906e82ed5d | |
parent | ec81a026ed62ebd427daeae4ac723517e0a59916 (diff) |
user cb
-rw-r--r-- | backend/src/driver/cl_gen_driver.hpp | 2 | ||||
-rw-r--r-- | backend/src/driver/cl_gen_event.cpp | 34 | ||||
-rw-r--r-- | include/cl_event.h | 12 | ||||
-rw-r--r-- | libclapi/cl_event.c | 10 | ||||
-rw-r--r-- | libclapi/cl_mem.c | 10 |
5 files changed, 63 insertions, 5 deletions
diff --git a/backend/src/driver/cl_gen_driver.hpp b/backend/src/driver/cl_gen_driver.hpp index b377b82d..689d74e6 100644 --- a/backend/src/driver/cl_gen_driver.hpp +++ b/backend/src/driver/cl_gen_driver.hpp @@ -252,7 +252,7 @@ struct GenGPUCommandQueue { bool inExec; list<GenGPUWorkItem*> workItems; cl_uint cookie; - bool enqueueWorkItem(GenGPUWorkItem* item, bool withLock); + bool enqueueWorkItem(GenGPUWorkItem* item, bool withLock = false); void userEventChange(void); void waitOnEvent(GenGPUWorkItem* item); GenGPUCommandQueue(dri_bufmgr *bufmgr, drm_intel_context *ctx); diff --git a/backend/src/driver/cl_gen_event.cpp b/backend/src/driver/cl_gen_event.cpp new file mode 100644 index 00000000..09233654 --- /dev/null +++ b/backend/src/driver/cl_gen_event.cpp @@ -0,0 +1,34 @@ +/* + * 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/>. + * + */ + +#ifdef __cplusplus +extern "C" { // for the C header files +#endif /* __cplusplus */ +#include <unistd.h> +#include <string.h> +#include "cl_gen_driver.h" +#include "cl_event.h" +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#include "cl_gen_driver.hpp" +#include "sys/assert.hpp" +#include "sys/alloc.hpp" + + + diff --git a/include/cl_event.h b/include/cl_event.h index 3298bf5c..ffbebf93 100644 --- a/include/cl_event.h +++ b/include/cl_event.h @@ -23,6 +23,15 @@ #include "CL/cl.h" typedef void (CL_CALLBACK *cl_event_notify)(cl_event event, cl_int event_command_exec_status, void *user_data); +typedef struct _cl_event_user_cb { + cl_int status; /* The execution status */ + cl_bool executed; /* Indicat the callback function been called or not */ + cl_event_notify pfn_notify; /* Callback function */ + void* user_data; /* Callback user data */ + struct _cl_event_user_cb* next; /* Next event callback in list */ +} _cl_event_user_cb; + +typedef struct _cl_event_user_cb* cl_event_user_cb; typedef struct _cl_event { uint64_t magic; /* To identify it as a sampler object */ @@ -32,8 +41,7 @@ typedef struct _cl_event { cl_command_queue queue; /* The command queue associated with event, NULL for usr event */ cl_command_type type; /* The command type associated with event */ cl_int status; /* The execution status */ - cl_event_notify pfn_notify; /* User set callback. */ - void* user_data; /* The user data */ + cl_event_user_cb user_cb; /* User set callback. */ cl_bool user_event; /* User create event. */ cl_ulong timestamp[4]; /* The time stamps for profiling. */ cl_event* wait_events; /* The events we are waiting for. */ diff --git a/libclapi/cl_event.c b/libclapi/cl_event.c index 2ead849e..164a8271 100644 --- a/libclapi/cl_event.c +++ b/libclapi/cl_event.c @@ -90,6 +90,16 @@ static void cl_event_delete(cl_event e) } cl_free(e->wait_events); } + + if (e->user_cb) { + cl_event_user_cb cb = NULL; + while (e->user_cb) { + cb = e->user_cb; + e->user_cb = cb->next; + cl_free(cb); + } + } + cl_free(e); } diff --git a/libclapi/cl_mem.c b/libclapi/cl_mem.c index 9585541f..7596a06e 100644 --- a/libclapi/cl_mem.c +++ b/libclapi/cl_mem.c @@ -187,8 +187,14 @@ static void cl_mem_delete(cl_mem mem) if (mem->mapped_ptr) cl_free(mem->mapped_ptr); - if (mem->dstr_cb) - cl_free(mem->dstr_cb); + if (mem->dstr_cb) { + cl_mem_dstr_cb *cb = NULL; + while (mem->dstr_cb) { + cb = mem->dstr_cb; + mem->dstr_cb = cb->next; + cl_free(cb); + } + } if (mem->ctx->device_num > 1) { cl_free(mem->pdata); |