utests: fix multithread queue chaos

Submitted by Pan Xiuli on Nov. 3, 2015, 3:29 a.m.

Details

Message ID 1446521366-10571-1-git-send-email-xiuli.pan@intel.com
State New
Headers show
Series "utests: fix multithread queue chaos" ( rev: 1 ) in Beignet

Not browsing as part of any series.

Commit Message

Pan Xiuli Nov. 3, 2015, 3:29 a.m.
Utest profiling exec create a new queue
and replace the global shared queue for
no use. It will result in some strange
segmeng fault.
Fix by removing the replacment of the
global queue.

Signed-off-by: Pan Xiuli <xiuli.pan@intel.com>
---
 utests/profiling_exec.cpp | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/utests/profiling_exec.cpp b/utests/profiling_exec.cpp
index 4232772..437a628 100644
--- a/utests/profiling_exec.cpp
+++ b/utests/profiling_exec.cpp
@@ -45,7 +45,6 @@  static void profiling_exec(void)
     const size_t n = 512;
     cl_int status = CL_SUCCESS;
     cl_command_queue profiling_queue = NULL;
-    cl_command_queue tmp_queue = NULL;
     float* cpu_src = (float *)malloc(n*sizeof(float));
     float* cpu_dst = (float *)malloc(n*sizeof(float));
     cl_event exec_event;
@@ -56,10 +55,6 @@  static void profiling_exec(void)
     profiling_queue = clCreateCommandQueue(ctx, device, CL_QUEUE_PROFILING_ENABLE, &status);
     OCL_ASSERT(status == CL_SUCCESS);
 
-    /* save the default queue. */
-    tmp_queue = queue;
-    queue = profiling_queue;
-
     OCL_CREATE_KERNEL("compiler_fabs");
 
     OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(float), NULL);
@@ -77,7 +72,7 @@  static void profiling_exec(void)
     cpu_exec(n, cpu_src, cpu_dst);
 
     // Run the kernel on GPU
-    OCL_CALL(clEnqueueNDRangeKernel, queue, kernel, 1, NULL, globals, locals, 0, NULL, &exec_event);
+    OCL_CALL(clEnqueueNDRangeKernel, profiling_queue, kernel, 1, NULL, globals, locals, 0, NULL, &exec_event);
     OCL_CALL(clWaitForEvents, 1, &exec_event);
 
     OCL_CALL(clGetEventProfilingInfo, exec_event, CL_PROFILING_COMMAND_QUEUED, sizeof(cl_ulong), &time_queue, NULL);
@@ -94,7 +89,6 @@  static void profiling_exec(void)
 	OCL_ASSERT(((float *)buf_data[1])[i] == cpu_dst[i]);
     OCL_UNMAP_BUFFER(1);
 
-    queue = tmp_queue;
     clReleaseCommandQueue(profiling_queue);
     free(cpu_dst);
     free(cpu_src);

Comments

LGTM

Thanks!
Ruiling

> -----Original Message-----

> From: Beignet [mailto:beignet-bounces@lists.freedesktop.org] On Behalf Of

> Pan Xiuli

> Sent: Tuesday, November 3, 2015 11:29 AM

> To: beignet@lists.freedesktop.org

> Cc: Pan, Xiuli

> Subject: [Beignet] [PATCH] utests: fix multithread queue chaos

> 

> Utest profiling exec create a new queue

> and replace the global shared queue for

> no use. It will result in some strange

> segmeng fault.

> Fix by removing the replacment of the

> global queue.

> 

> Signed-off-by: Pan Xiuli <xiuli.pan@intel.com>

> ---

>  utests/profiling_exec.cpp | 8 +-------

>  1 file changed, 1 insertion(+), 7 deletions(-)

> 

> diff --git a/utests/profiling_exec.cpp b/utests/profiling_exec.cpp

> index 4232772..437a628 100644

> --- a/utests/profiling_exec.cpp

> +++ b/utests/profiling_exec.cpp

> @@ -45,7 +45,6 @@ static void profiling_exec(void)

>      const size_t n = 512;

>      cl_int status = CL_SUCCESS;

>      cl_command_queue profiling_queue = NULL;

> -    cl_command_queue tmp_queue = NULL;

>      float* cpu_src = (float *)malloc(n*sizeof(float));

>      float* cpu_dst = (float *)malloc(n*sizeof(float));

>      cl_event exec_event;

> @@ -56,10 +55,6 @@ static void profiling_exec(void)

>      profiling_queue = clCreateCommandQueue(ctx, device,

> CL_QUEUE_PROFILING_ENABLE, &status);

>      OCL_ASSERT(status == CL_SUCCESS);

> 

> -    /* save the default queue. */

> -    tmp_queue = queue;

> -    queue = profiling_queue;

> -

>      OCL_CREATE_KERNEL("compiler_fabs");

> 

>      OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(float), NULL);

> @@ -77,7 +72,7 @@ static void profiling_exec(void)

>      cpu_exec(n, cpu_src, cpu_dst);

> 

>      // Run the kernel on GPU

> -    OCL_CALL(clEnqueueNDRangeKernel, queue, kernel, 1, NULL, globals, locals,

> 0, NULL, &exec_event);

> +    OCL_CALL(clEnqueueNDRangeKernel, profiling_queue, kernel, 1, NULL,

> globals, locals, 0, NULL, &exec_event);

>      OCL_CALL(clWaitForEvents, 1, &exec_event);

> 

>      OCL_CALL(clGetEventProfilingInfo, exec_event,

> CL_PROFILING_COMMAND_QUEUED, sizeof(cl_ulong), &time_queue, NULL);

> @@ -94,7 +89,6 @@ static void profiling_exec(void)

>  	OCL_ASSERT(((float *)buf_data[1])[i] == cpu_dst[i]);

>      OCL_UNMAP_BUFFER(1);

> 

> -    queue = tmp_queue;

>      clReleaseCommandQueue(profiling_queue);

>      free(cpu_dst);

>      free(cpu_src);

> --

> 2.1.4

> 

> _______________________________________________

> Beignet mailing list

> Beignet@lists.freedesktop.org

> http://lists.freedesktop.org/mailman/listinfo/beignet