}
else
{
- int r = pthread_cond_wait (cq_cond, &cq->pocl_lock);
- assert (r == 0);
+ PTHREAD_CHECK (pthread_cond_wait (cq_cond, &cq->pocl_lock));
}
}
return;
* user threads waiting on the same command queue
* in pthread_scheduler_wait_cq(). */
pthread_cond_t *cq_cond = (pthread_cond_t *)cq->data;
- int r = pthread_cond_broadcast (cq_cond);
- assert (r == 0);
+ PTHREAD_CHECK (pthread_cond_broadcast (cq_cond));
}
void
pocl_pthread_notify_event_finished (cl_event event)
{
struct event_data *e_d = event->data;
- pthread_cond_broadcast (&e_d->event_cond);
+ PTHREAD_CHECK (pthread_cond_broadcast (&e_d->event_cond));
}
void
e_d = malloc(sizeof(struct event_data));
assert(e_d);
- pthread_cond_init(&e_d->event_cond, NULL);
+ PTHREAD_CHECK (pthread_cond_init (&e_d->event_cond, NULL));
event->data = (void *) e_d;
}
}
POCL_LOCK_OBJ (event);
while (event->status > CL_COMPLETE)
{
- pthread_cond_wait(&e_d->event_cond, &event->pocl_lock);
+ PTHREAD_CHECK (pthread_cond_wait (&e_d->event_cond, &event->pocl_lock));
}
POCL_UNLOCK_OBJ (event);
}
queue->data
= pocl_aligned_malloc (HOST_CPU_CACHELINE_SIZE, sizeof (pthread_cond_t));
pthread_cond_t *cond = (pthread_cond_t *)queue->data;
- int r = pthread_cond_init (cond, NULL);
- assert (r == 0);
+ PTHREAD_CHECK (pthread_cond_init (cond, NULL));
return CL_SUCCESS;
}
pocl_pthread_free_queue (cl_device_id device, cl_command_queue queue)
{
pthread_cond_t *cond = (pthread_cond_t *)queue->data;
- int r = pthread_cond_destroy (cond);
- assert (r == 0);
+ PTHREAD_CHECK (pthread_cond_destroy (cond));
POCL_MEM_FREE (queue->data);
return CL_SUCCESS;
}
size_t num_worker_threads = device->max_compute_units;
POCL_FAST_INIT (scheduler.wq_lock_fast);
- pthread_cond_init (&(scheduler.wake_pool), NULL);
+ PTHREAD_CHECK (pthread_cond_init (&(scheduler.wake_pool), NULL));
scheduler.thread_pool = pocl_aligned_malloc (
HOST_CPU_CACHELINE_SIZE,
for (i = 0; i < num_worker_threads; ++i)
{
scheduler.thread_pool[i].index = i;
- pthread_create (&scheduler.thread_pool[i].thread, NULL,
- pocl_pthread_driver_thread,
- (void*)&scheduler.thread_pool[i]);
+ PTHREAD_CHECK (pthread_create (&scheduler.thread_pool[i].thread, NULL,
+ pocl_pthread_driver_thread,
+ (void *)&scheduler.thread_pool[i]));
}
}
POCL_FAST_LOCK (scheduler.wq_lock_fast);
scheduler.thread_pool_shutdown_requested = 1;
- pthread_cond_broadcast (&scheduler.wake_pool);
+ PTHREAD_CHECK (pthread_cond_broadcast (&scheduler.wake_pool));
POCL_FAST_UNLOCK (scheduler.wq_lock_fast);
for (i = 0; i < scheduler.num_threads; ++i)
{
- pthread_join (scheduler.thread_pool[i].thread, NULL);
+ PTHREAD_CHECK (pthread_join (scheduler.thread_pool[i].thread, NULL));
}
pocl_aligned_free (scheduler.thread_pool);
POCL_FAST_DESTROY (scheduler.wq_lock_fast);
- pthread_cond_destroy (&scheduler.wake_pool);
+ PTHREAD_CHECK (pthread_cond_destroy (&scheduler.wake_pool));
scheduler.thread_pool_shutdown_requested = 0;
}
{
POCL_FAST_LOCK (scheduler.wq_lock_fast);
DL_APPEND (scheduler.work_queue, cmd);
- pthread_cond_broadcast (&scheduler.wake_pool);
+ PTHREAD_CHECK (pthread_cond_broadcast (&scheduler.wake_pool));
POCL_FAST_UNLOCK (scheduler.wq_lock_fast);
}
{
POCL_FAST_LOCK (scheduler.wq_lock_fast);
DL_APPEND (scheduler.kernel_queue, run_cmd);
- pthread_cond_broadcast (&scheduler.wake_pool);
+ PTHREAD_CHECK (pthread_cond_broadcast (&scheduler.wake_pool));
POCL_FAST_UNLOCK (scheduler.wq_lock_fast);
}
/* if neither a command nor a kernel was available, sleep */
if ((cmd == NULL) && (run_cmd == NULL) && (do_exit == 0))
{
- pthread_cond_wait (&scheduler.wake_pool, &scheduler.wq_lock_fast);
+ PTHREAD_CHECK (
+ pthread_cond_wait (&scheduler.wake_pool, &scheduler.wq_lock_fast));
goto RETRY;
}
cpu_set_t set;
CPU_ZERO (&set);
CPU_SET (td->index, &set);
- pthread_setaffinity_np (td->thread, sizeof (cpu_set_t), &set);
+ PTHREAD_CHECK (
+ pthread_setaffinity_np (td->thread, sizeof (cpu_set_t), &set));
}
#endif
{
LL_DELETE (kernel_pool, k);
memset (k, 0, sizeof(kernel_run_command));
- pthread_mutex_init(&k->lock, NULL);
+ PTHREAD_CHECK (pthread_mutex_init (&k->lock, NULL));
POCL_UNLOCK (kernel_pool_lock);
return k;
}
POCL_UNLOCK (kernel_pool_lock);
k = (kernel_run_command*)calloc (1, sizeof (kernel_run_command));
- pthread_mutex_init (&k->lock, NULL);
+ PTHREAD_CHECK (pthread_mutex_init (&k->lock, NULL));
return k;
}
void free_kernel_run_command (kernel_run_command *k)
{
POCL_LOCK (kernel_pool_lock);
- pthread_mutex_destroy (&k->lock);
+ PTHREAD_CHECK (pthread_mutex_destroy (&k->lock));
LL_PREPEND (kernel_pool, k);
POCL_UNLOCK (kernel_pool_lock);
}