From b3356cca1a94d3b6badc473121b01787262f39c3 Mon Sep 17 00:00:00 2001 From: Andreas Beckmann Date: Fri, 26 Nov 2021 14:02:56 +0100 Subject: [PATCH] [PATCH 72/90] pthread: add return code to pthread_scheduler_init() Gbp-Pq: Name 0072-pthread-add-return-code-to-pthread_scheduler_init.patch --- .../devices/pthread/pocl-pthread_scheduler.h | 2 +- lib/CL/devices/pthread/pthread.c | 21 +++++++++++++------ lib/CL/devices/pthread/pthread_scheduler.c | 3 ++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/CL/devices/pthread/pocl-pthread_scheduler.h b/lib/CL/devices/pthread/pocl-pthread_scheduler.h index e96980b..d56709d 100644 --- a/lib/CL/devices/pthread/pocl-pthread_scheduler.h +++ b/lib/CL/devices/pthread/pocl-pthread_scheduler.h @@ -36,7 +36,7 @@ typedef struct pool_thread_data thread_data; /* Initializes scheduler. Must be called before any kernel enqueue */ -void pthread_scheduler_init (cl_device_id device); +cl_int pthread_scheduler_init (cl_device_id device); void pthread_scheduler_uninit (); diff --git a/lib/CL/devices/pthread/pthread.c b/lib/CL/devices/pthread/pthread.c index 444d7dc..e66d76e 100644 --- a/lib/CL/devices/pthread/pthread.c +++ b/lib/CL/devices/pthread/pthread.c @@ -208,14 +208,19 @@ pocl_pthread_init (unsigned j, cl_device_id device, const char* parameters) device->num_partition_types = 0; device->partition_type = NULL; + cl_int ret = CL_SUCCESS; if (!scheduler_initialized) { - scheduler_initialized = 1; pocl_init_dlhandle_cache(); pocl_init_kernel_run_command_manager(); - pthread_scheduler_init (device); + ret = pthread_scheduler_init (device); + if (ret == CL_SUCCESS) + { + scheduler_initialized = 1; + } } - return CL_SUCCESS; + + return ret; } cl_int @@ -246,13 +251,17 @@ pocl_pthread_reinit (unsigned j, cl_device_id device) d->current_kernel = NULL; device->data = d; + cl_int ret = CL_SUCCESS; if (!scheduler_initialized) { - pthread_scheduler_init (device); - scheduler_initialized = 1; + ret = pthread_scheduler_init (device); + if (ret == CL_SUCCESS) + { + scheduler_initialized = 1; + } } - return CL_SUCCESS; + return ret; } void diff --git a/lib/CL/devices/pthread/pthread_scheduler.c b/lib/CL/devices/pthread/pthread_scheduler.c index d3a8958..d57f7c9 100644 --- a/lib/CL/devices/pthread/pthread_scheduler.c +++ b/lib/CL/devices/pthread/pthread_scheduler.c @@ -81,7 +81,7 @@ typedef struct scheduler_data_ static scheduler_data scheduler; -void +cl_int pthread_scheduler_init (cl_device_id device) { unsigned i; @@ -114,6 +114,7 @@ pthread_scheduler_init (cl_device_id device) (void *)&scheduler.thread_pool[i])); } + return CL_SUCCESS; } void -- 2.30.2