[Beignet] [PATCH 3/4] Re-build the program when build option changed.

Song, Ruiling ruiling.song at intel.com
Tue Oct 29 02:15:05 CET 2013


One comment inline.

-----Original Message-----
From: beignet-bounces+ruiling.song=intel.com at lists.freedesktop.org [mailto:beignet-bounces+ruiling.song=intel.com at lists.freedesktop.org] On Behalf Of Yang Rong
Sent: Monday, October 28, 2013 2:02 PM
To: beignet at lists.freedesktop.org
Cc: Yang, Rong R
Subject: [Beignet] [PATCH 3/4] Re-build the program when build option changed.


Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
 src/cl_program.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/cl_program.c b/src/cl_program.c index 7ae8e8a..ad6e098 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;
+      }
[ruiling] do we need to save options to p->build_opts here as new options come? If it is needed, I suggest merge this if/ elseif together, so there is less duplicate code.
+    } 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:
--
1.8.1.2

_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list