Skip to content

Commit

Permalink
opencl: fix for #11066
Browse files Browse the repository at this point in the history
  • Loading branch information
upegelow authored and johannes hanika committed Jul 4, 2016
1 parent 02d06ee commit e388057
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/common/darktable.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ int dt_init(int argc, char *argv[], const int init_gui, lua_State *L)

#ifdef HAVE_OPENCL
gboolean exclude_opencl = FALSE;
gboolean print_statistics = strcmp(argv[0], "darktable-cltest");
#endif

#ifdef USE_LUA
Expand Down Expand Up @@ -897,7 +898,7 @@ int dt_init(int argc, char *argv[], const int init_gui, lua_State *L)

darktable.opencl = (dt_opencl_t *)calloc(1, sizeof(dt_opencl_t));
#ifdef HAVE_OPENCL
dt_opencl_init(darktable.opencl, exclude_opencl);
dt_opencl_init(darktable.opencl, exclude_opencl, print_statistics);
#endif

darktable.blendop = (dt_blendop_t *)calloc(1, sizeof(dt_blendop_t));
Expand Down
8 changes: 6 additions & 2 deletions src/common/opencl.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ static void dt_opencl_priority_parse(dt_opencl_t *cl, char *configstr, int *prio
/** parse a complete priority string */
static void dt_opencl_priorities_parse(dt_opencl_t *cl, const char *configstr);

void dt_opencl_init(dt_opencl_t *cl, const gboolean exclude_opencl)
void dt_opencl_init(dt_opencl_t *cl, const gboolean exclude_opencl, const gboolean print_statistics)
{
char *str;
dt_pthread_mutex_init(&cl->lock, NULL);
cl->inited = 0;
cl->enabled = 0;
cl->stopped = 0;
cl->error_count = 0;
cl->print_statistics = print_statistics;

// work-around to fix a bug in some AMD OpenCL compilers, which would fail parsing certain numerical
// constants if locale is different from "C".
Expand Down Expand Up @@ -624,7 +625,7 @@ void dt_opencl_cleanup(dt_opencl_t *cl)
if(cl->dev[i].program_used[k]) (cl->dlocl->symbols->dt_clReleaseProgram)(cl->dev[i].program[k]);
(cl->dlocl->symbols->dt_clReleaseCommandQueue)(cl->dev[i].cmd_queue);
(cl->dlocl->symbols->dt_clReleaseContext)(cl->dev[i].context);
if(cl->use_events)
if(cl->print_statistics && cl->use_events)
{
if(cl->dev[i].totalevents)
{
Expand All @@ -637,6 +638,9 @@ void dt_opencl_cleanup(dt_opencl_t *cl)
dt_print(DT_DEBUG_OPENCL, "[opencl_summary_statistics] device '%s': NOT utilized\n",
cl->dev[i].name);
}
}
if(cl->use_events)
{
dt_opencl_events_reset(i);

free(cl->dev[i].eventlist);
Expand Down
5 changes: 3 additions & 2 deletions src/common/opencl.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ typedef struct dt_opencl_t
int use_events;
int async_pixelpipe;
int number_event_handles;
int print_statistics;
int synch_cache;
int micro_nap;
int enabled;
Expand All @@ -134,7 +135,7 @@ typedef struct dt_opencl_t
} dt_opencl_t;

/** inits the opencl subsystem. */
void dt_opencl_init(dt_opencl_t *cl, const gboolean exclude_opencl);
void dt_opencl_init(dt_opencl_t *cl, const gboolean exclude_opencl, const gboolean print_statistics);

/** cleans up the opencl subsystem. */
void dt_opencl_cleanup(dt_opencl_t *cl);
Expand Down Expand Up @@ -316,7 +317,7 @@ typedef struct dt_opencl_t
int stopped;
int error_count;
} dt_opencl_t;
static inline void dt_opencl_init(dt_opencl_t *cl, const int argc, char *argv[])
static inline void dt_opencl_init(dt_opencl_t *cl, const gboolean exclude_opencl, const gboolean print_statistics)
{
cl->inited = 0;
cl->enabled = 0;
Expand Down

0 comments on commit e388057

Please sign in to comment.