Three-in-one commit:
- Compositor now is threaded
Enable it with the Scene buttons "Threads". This will handle over nodes to
individual threads to be calculated. However, if nodes depend on others
they have to wait. The current system only threads per entire node, not for
calculating results in parts.
I've reshuffled the node execution code to evaluate 'changed' events, and
prepare the entire tree to become simply parsed for open jobs with a call
to node = getExecutableNode()
By default, even without 'thread' option active, all node execution is
done within a separate thread.
Also fixed issues in yesterdays commit for 'event based' calculations, it
didn't do animated images, or execute (on rendering) the correct nodes
when you don't have Render-Result nodes included.
- Added generic Thread support in blenlib/ module
The renderer and the node system now both use same code for controlling the
threads. This has been moved to a new C file in blenlib/intern/threads.c.
Check this c file for an extensive doc and example how to use it.
The current implementation for Compositing allows unlimited amount of
threads. For rendering it is still tied to two threads, although it is
pretty easy to extend to 4 already. People with giant amounts of cpus can
poke me once for tests. :)
- Bugfix in creating group nodes
Group node definitions demand a clear separation of 'internal sockets' and
'external sockets'. The first are sockets being linked internally, the latter
are sockets exposed as sockets for the group itself.
When sockets were linked both internal and external, Blender crashed. It is
solved now by removing the external link(s).
2006-01-29 11:36:33 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Three-in-one commit:
- Compositor now is threaded
Enable it with the Scene buttons "Threads". This will handle over nodes to
individual threads to be calculated. However, if nodes depend on others
they have to wait. The current system only threads per entire node, not for
calculating results in parts.
I've reshuffled the node execution code to evaluate 'changed' events, and
prepare the entire tree to become simply parsed for open jobs with a call
to node = getExecutableNode()
By default, even without 'thread' option active, all node execution is
done within a separate thread.
Also fixed issues in yesterdays commit for 'event based' calculations, it
didn't do animated images, or execute (on rendering) the correct nodes
when you don't have Render-Result nodes included.
- Added generic Thread support in blenlib/ module
The renderer and the node system now both use same code for controlling the
threads. This has been moved to a new C file in blenlib/intern/threads.c.
Check this c file for an extensive doc and example how to use it.
The current implementation for Compositing allows unlimited amount of
threads. For rendering it is still tied to two threads, although it is
pretty easy to extend to 4 already. People with giant amounts of cpus can
poke me once for tests. :)
- Bugfix in creating group nodes
Group node definitions demand a clear separation of 'internal sockets' and
'external sockets'. The first are sockets being linked internally, the latter
are sockets exposed as sockets for the group itself.
When sockets were linked both internal and external, Blender crashed. It is
solved now by removing the external link(s).
2006-01-29 11:36:33 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2006 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BLI_THREADS_H
|
|
|
|
#define BLI_THREADS_H
|
|
|
|
|
2011-02-18 13:58:08 +00:00
|
|
|
/** \file BLI_threads.h
|
|
|
|
* \ingroup bli
|
|
|
|
*/
|
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
#include <pthread.h>
|
2006-03-13 11:01:17 +00:00
|
|
|
|
2006-11-29 17:01:09 +00:00
|
|
|
/* for tables, button in UI, etc */
|
2010-01-28 19:18:35 +00:00
|
|
|
#define BLENDER_MAX_THREADS 64
|
2006-11-29 17:01:09 +00:00
|
|
|
|
|
|
|
struct ListBase;
|
2009-09-30 18:18:32 +00:00
|
|
|
|
|
|
|
/* Threading API */
|
|
|
|
|
2010-04-13 12:51:03 +00:00
|
|
|
/*this is run once at startup*/
|
|
|
|
void BLI_threadapi_init(void);
|
|
|
|
|
2006-11-29 17:01:09 +00:00
|
|
|
void BLI_init_threads (struct ListBase *threadbase, void *(*do_thread)(void *), int tot);
|
|
|
|
int BLI_available_threads(struct ListBase *threadbase);
|
|
|
|
int BLI_available_thread_index(struct ListBase *threadbase);
|
|
|
|
void BLI_insert_thread (struct ListBase *threadbase, void *callerdata);
|
|
|
|
void BLI_remove_thread (struct ListBase *threadbase, void *callerdata);
|
2008-08-14 23:48:52 +00:00
|
|
|
void BLI_remove_thread_index(struct ListBase *threadbase, int index);
|
2008-09-25 20:29:15 +00:00
|
|
|
void BLI_remove_threads(struct ListBase *threadbase);
|
2006-11-29 17:01:09 +00:00
|
|
|
void BLI_end_threads (struct ListBase *threadbase);
|
2010-04-13 12:51:03 +00:00
|
|
|
int BLI_thread_is_main(void);
|
2006-02-11 15:55:00 +00:00
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
/* System Information */
|
|
|
|
|
|
|
|
int BLI_system_thread_count(void); /* gets the number of threads the system can make use of */
|
|
|
|
|
|
|
|
/* Global Mutex Locks
|
|
|
|
*
|
|
|
|
* One custom lock available now. can be extended. */
|
|
|
|
|
|
|
|
#define LOCK_IMAGE 0
|
|
|
|
#define LOCK_PREVIEW 1
|
2010-03-16 16:58:45 +00:00
|
|
|
#define LOCK_VIEWER 2
|
|
|
|
#define LOCK_CUSTOM1 3
|
2010-04-25 10:49:13 +00:00
|
|
|
#define LOCK_RCACHE 4
|
|
|
|
#define LOCK_OPENGL 5
|
2011-10-31 17:00:59 +00:00
|
|
|
#define LOCK_NODES 6
|
2009-09-30 18:18:32 +00:00
|
|
|
|
|
|
|
void BLI_lock_thread(int type);
|
|
|
|
void BLI_unlock_thread(int type);
|
|
|
|
|
|
|
|
/* Mutex Lock */
|
|
|
|
|
|
|
|
typedef pthread_mutex_t ThreadMutex;
|
2010-04-25 10:49:13 +00:00
|
|
|
#define BLI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
2009-09-30 18:18:32 +00:00
|
|
|
|
|
|
|
void BLI_mutex_init(ThreadMutex *mutex);
|
|
|
|
void BLI_mutex_lock(ThreadMutex *mutex);
|
|
|
|
void BLI_mutex_unlock(ThreadMutex *mutex);
|
|
|
|
void BLI_mutex_end(ThreadMutex *mutex);
|
2006-02-11 15:55:00 +00:00
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
/* Read/Write Mutex Lock */
|
2008-08-16 22:47:33 +00:00
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
#define THREAD_LOCK_READ 1
|
|
|
|
#define THREAD_LOCK_WRITE 2
|
2009-06-08 10:00:14 +00:00
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
typedef pthread_rwlock_t ThreadRWMutex;
|
|
|
|
|
|
|
|
void BLI_rw_mutex_init(ThreadRWMutex *mutex);
|
|
|
|
void BLI_rw_mutex_lock(ThreadRWMutex *mutex, int mode);
|
|
|
|
void BLI_rw_mutex_unlock(ThreadRWMutex *mutex);
|
|
|
|
void BLI_rw_mutex_end(ThreadRWMutex *mutex);
|
|
|
|
|
|
|
|
/* ThreadedWorker
|
|
|
|
*
|
|
|
|
* A simple tool for dispatching work to a limited number of threads
|
|
|
|
* in a transparent fashion from the caller's perspective. */
|
2008-08-16 22:47:33 +00:00
|
|
|
|
|
|
|
struct ThreadedWorker;
|
|
|
|
|
|
|
|
/* Create a new worker supporting tot parallel threads.
|
|
|
|
* When new work in inserted and all threads are busy, sleep(sleep_time) before checking again
|
|
|
|
*/
|
|
|
|
struct ThreadedWorker *BLI_create_worker(void *(*do_thread)(void *), int tot, int sleep_time);
|
|
|
|
|
|
|
|
/* join all working threads */
|
|
|
|
void BLI_end_worker(struct ThreadedWorker *worker);
|
|
|
|
|
|
|
|
/* also ends all working threads */
|
|
|
|
void BLI_destroy_worker(struct ThreadedWorker *worker);
|
|
|
|
|
|
|
|
/* Spawns a new work thread if possible, sleeps until one is available otherwise
|
|
|
|
* NOTE: inserting work is NOT thread safe, so make sure it is only done from one thread */
|
|
|
|
void BLI_insert_work(struct ThreadedWorker *worker, void *param);
|
|
|
|
|
2010-01-22 11:06:57 +00:00
|
|
|
/* ThreadWorkQueue
|
|
|
|
*
|
|
|
|
* Thread-safe work queue to push work/pointers between threads. */
|
|
|
|
|
|
|
|
typedef struct ThreadQueue ThreadQueue;
|
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
ThreadQueue *BLI_thread_queue_init(void);
|
2010-01-22 11:06:57 +00:00
|
|
|
void BLI_thread_queue_free(ThreadQueue *queue);
|
|
|
|
|
|
|
|
void BLI_thread_queue_push(ThreadQueue *queue, void *work);
|
|
|
|
void *BLI_thread_queue_pop(ThreadQueue *queue);
|
|
|
|
void *BLI_thread_queue_pop_timeout(ThreadQueue *queue, int ms);
|
|
|
|
int BLI_thread_queue_size(ThreadQueue *queue);
|
|
|
|
|
|
|
|
void BLI_thread_queue_nowait(ThreadQueue *queue);
|
2008-08-16 22:47:33 +00:00
|
|
|
|
Three-in-one commit:
- Compositor now is threaded
Enable it with the Scene buttons "Threads". This will handle over nodes to
individual threads to be calculated. However, if nodes depend on others
they have to wait. The current system only threads per entire node, not for
calculating results in parts.
I've reshuffled the node execution code to evaluate 'changed' events, and
prepare the entire tree to become simply parsed for open jobs with a call
to node = getExecutableNode()
By default, even without 'thread' option active, all node execution is
done within a separate thread.
Also fixed issues in yesterdays commit for 'event based' calculations, it
didn't do animated images, or execute (on rendering) the correct nodes
when you don't have Render-Result nodes included.
- Added generic Thread support in blenlib/ module
The renderer and the node system now both use same code for controlling the
threads. This has been moved to a new C file in blenlib/intern/threads.c.
Check this c file for an extensive doc and example how to use it.
The current implementation for Compositing allows unlimited amount of
threads. For rendering it is still tied to two threads, although it is
pretty easy to extend to 4 already. People with giant amounts of cpus can
poke me once for tests. :)
- Bugfix in creating group nodes
Group node definitions demand a clear separation of 'internal sockets' and
'external sockets'. The first are sockets being linked internally, the latter
are sockets exposed as sockets for the group itself.
When sockets were linked both internal and external, Blender crashed. It is
solved now by removing the external link(s).
2006-01-29 11:36:33 +00:00
|
|
|
#endif
|
|
|
|
|