diff options
author | Yang Rong <rong.r.yang@intel.com> | 2013-10-28 14:02:17 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@linux.intel.com> | 2013-10-29 10:35:36 +0800 |
commit | f1ccd59f67ce21a0337d44b79927b176e89e2911 (patch) | |
tree | 29faf3d950e4b136a53e8dd1779b7d5ed79f8487 | |
parent | 7e582e7ecf7369b9424a0924ad2444da03cb704d (diff) |
Re-build the program when build option changed.
Signed-off-by: Yang Rong <rong.r.yang@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Reviewed-by: "Song, Ruiling" <ruiling.song@intel.com>
-rw-r--r-- | src/cl_program.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/cl_program.c b/src/cl_program.c index 7ae8e8a6..ad6e098f 100644 --- a/src/cl_program.c +++ b/src/cl_program.c @@ -1,4 +1,4 @@ -/* +/* * Copyright © 2012 Intel Corporation * * This library is free software; you can redistribute it and/or @@ -301,13 +301,26 @@ cl_program_build(cl_program p, const char *options) int copyed = 0; if (options) { - if(p->build_opts) { - cl_free(p->build_opts); - p->build_opts = NULL; + if(p->build_opts && strcmp(options, p->build_opts) != 0) { + p->source_type = p->source ? FROM_SOURCE : p->binary ? FROM_BINARY : FROM_LLVM; + + if(p->build_opts) { + cl_free(p->build_opts); + p->build_opts = NULL; + } + } else if(p->build_opts == NULL) { + p->source_type = p->source ? FROM_SOURCE : p->binary ? FROM_BINARY : FROM_LLVM; + + TRY_ALLOC (p->build_opts, cl_calloc(strlen(options) + 1, sizeof(char))); + memcpy(p->build_opts, options, strlen(options)); } + } + + if (options == NULL && p->build_opts) { + p->source_type = p->source ? FROM_SOURCE : p->binary ? FROM_BINARY : FROM_LLVM; - TRY_ALLOC (p->build_opts, cl_calloc(strlen(options) + 1, sizeof(char))); - memcpy(p->build_opts, options, strlen(options)); + cl_free(p->build_opts); + p->build_opts = NULL; } if (p->source_type == FROM_SOURCE) { @@ -397,7 +410,7 @@ cl_program_create_kernels_in_program(cl_program p, cl_kernel* ker) for (i = 0; i < p->ker_n; ++i) { TRY_ALLOC_NO_ERR(ker[i], cl_kernel_dup(p->ker[i])); } - + return CL_SUCCESS; error: |