| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 | /* * This file is part of the StarPU Handbook. * Copyright (C) 2009--2011  Universit@'e de Bordeaux * Copyright (C) 2010, 2011, 2012, 2013, 2014  Centre National de la Recherche Scientifique * Copyright (C) 2011, 2012 Institut National de Recherche en Informatique et Automatique * See the file version.doxy for copying conditions. *//*! \defgroup API_Threads Threads\brief This section describes the thread facilities providedby StarPU. The thread function are either implemented on top of thepthread library or the Simgrid library when the simulated performancemode is enabled (\ref SimGridSupport).\def STARPU_PTHREAD_CREATE_ON\ingroup API_ThreadsThis macro calls the function starpu_pthread_create_on() and aborts on error.\def STARPU_PTHREAD_CREATE\ingroup API_ThreadsThis macro calls the function starpu_pthread_create() and aborts on error.\def STARPU_PTHREAD_MUTEX_INIT\ingroup API_ThreadsThis macro calls the function starpu_pthread_mutex_init() and abortson error.\def STARPU_PTHREAD_MUTEX_DESTROY\ingroup API_ThreadsThis macro calls the function starpu_pthread_mutex_destroy() andaborts on error.\def STARPU_PTHREAD_MUTEX_LOCK\ingroup API_ThreadsThis macro calls the function starpu_pthread_mutex_lock() and abortson error.\def STARPU_PTHREAD_MUTEX_UNLOCK\ingroup API_ThreadsThis macro calls the function starpu_pthread_mutex_unlock() and abortson error.\def STARPU_PTHREAD_KEY_CREATE\ingroup API_ThreadsThis macro calls the function starpu_pthread_key_create() and abortson error.\def STARPU_PTHREAD_KEY_DELETE\ingroup API_ThreadsThis macro calls the function starpu_pthread_key_delete() and abortson error.\def STARPU_PTHREAD_SETSPECIFIC\ingroup API_ThreadsThis macro calls the function starpu_pthread_setspecific() and abortson error.\def STARPU_PTHREAD_GETSPECIFIC\ingroup API_ThreadsThis macro calls the function starpu_pthread_getspecific() and abortson error.\def STARPU_PTHREAD_RWLOCK_INIT\ingroup API_ThreadsThis macro calls the function starpu_pthread_rwlock_init() and abortson error.\def STARPU_PTHREAD_RWLOCK_RDLOCK\ingroup API_ThreadsThis macro calls the function starpu_pthread_rwlock_rdlock() andaborts on error.\def STARPU_PTHREAD_RWLOCK_WRLOCK\ingroup API_ThreadsThis macro calls the function starpu_pthread_rwlock_wrlock() andaborts on error.\def STARPU_PTHREAD_RWLOCK_UNLOCK\ingroup API_ThreadsThis macro calls the function starpu_pthread_rwlock_unlock() andaborts on error.\def STARPU_PTHREAD_RWLOCK_DESTROY\ingroup API_ThreadsThis macro calls the function starpu_pthread_rwlock_destroy() andaborts on error.\def STARPU_PTHREAD_COND_INIT\ingroup API_ThreadsThis macro calls the function starpu_pthread_cond_init() and aborts on error.\def STARPU_PTHREAD_COND_DESTROY\ingroup API_ThreadsThis macro calls the function starpu_pthread_cond_destroy() and abortson error.\def STARPU_PTHREAD_COND_SIGNAL\ingroup API_ThreadsThis macro calls the function starpu_pthread_cond_signal() and abortson error.\def STARPU_PTHREAD_COND_BROADCAST\ingroup API_ThreadsThis macro calls the function starpu_pthread_cond_broadcast() andaborts on error.\def STARPU_PTHREAD_COND_WAIT\ingroup API_ThreadsThis macro calls the function starpu_pthread_cond_wait() and aborts on error.\def STARPU_PTHREAD_BARRIER_INIT\ingroup API_ThreadsThis macro calls the function starpu_pthread_barrier_init() and abortson error.\def STARPU_PTHREAD_BARRIER_DESTROY\ingroup API_ThreadsThis macro calls the function starpu_pthread_barrier_destroy() andaborts on error.\def STARPU_PTHREAD_BARRIER_WAIT\ingroup API_ThreadsThis macro calls the function starpu_pthread_barrier_wait() and abortson error.\fn int starpu_pthread_create_on(char *name, starpu_pthread_t *thread, const starpu_pthread_attr_t *attr, void *(*start_routine) (void *), void *arg, int where)\ingroup API_Threads\fn int starpu_pthread_create(starpu_pthread_t *thread, const starpu_pthread_attr_t *attr, void *(*start_routine) (void *), void *arg)\ingroup API_ThreadsThis function starts a new thread in the calling process.  The newthread starts execution by invoking \p start_routine; \p arg is passedas the sole argument of \p start_routine.\fn int starpu_pthread_join(starpu_pthread_t thread, void **retval)\ingroup API_ThreadsThis function waits for the thread specified by \p thread toterminate.  If that thread has already terminated, then the functionreturns immediately. The thread specified by \p thread must bejoinable.\fn int starpu_pthread_exit(void *retval)\ingroup API_ThreadsThis function terminates the calling thread and returns a value via\p retval that (if the thread is joinable) is available to another threadin the same process that calls starpu_pthread_join().\fn int starpu_pthread_attr_init(starpu_pthread_attr_t *attr)\ingroup API_ThreadsThis function initializes the thread attributes object pointed to by\p attr with default attribute values.It does not do anything when the simulated performance mode is enabled(\ref SimGridSupport).\fn int starpu_pthread_attr_destroy(starpu_pthread_attr_t *attr)\ingroup API_ThreadsThis function destroys a thread attributes object which is no longerrequired. Destroying a thread attributes object has no effect onthreads that were created using that object.It does not do anything when the simulated performance mode is enabled(\ref SimGridSupport).\fn int starpu_pthread_attr_setdetachstate(starpu_pthread_attr_t *attr, int detachstate)\ingroup API_ThreadsThis function sets the detach state attribute of the thread attributesobject referred to by \p attr to the value specified in \pdetachstate.  The detach state attribute determines whether a threadcreated using the thread attributes object \p attr will be created ina joinable or a detached state.It does not do anything when the simulated performance mode is enabled(\ref SimGridSupport).\fn int starpu_pthread_mutex_init(starpu_pthread_mutex_t *mutex, const starpu_pthread_mutexattr_t *mutexattr)\ingroup API_ThreadsThis function initializes the mutex object pointed to by \p mutexaccording to the mutex attributes specified in \p mutexattr.  If \pmutexattr is NULL, default attributes are used instead.\fn int starpu_pthread_mutex_destroy(starpu_pthread_mutex_t *mutex)\ingroup API_ThreadsThis function destroys a mutex object, freeing the resources it mighthold. The mutex must be unlocked on entrance.\fn int starpu_pthread_mutex_lock(starpu_pthread_mutex_t *mutex)\ingroup API_ThreadsThis function locks the given mutex. If the mutex is currentlyunlocked, it becomes locked and owned by the calling thread, and thefunction returns immediately. If the mutex is already locked byanother thread, the function suspends the calling thread until themutex is unlocked.This function also produces trace when the configure option \refenable-fxt-lock "--enable-fxt-lock" is enabled.\fn int starpu_pthread_mutex_unlock(starpu_pthread_mutex_t *mutex)\ingroup API_ThreadsThis function unlocks the given mutex. The mutex is assumed to belocked and owned by the calling thread on entrance tostarpu_pthread_mutex_unlock().This function also produces trace when the configure option \refenable-fxt-lock "--enable-fxt-lock" is enabled.\fn int starpu_pthread_mutex_trylock(starpu_pthread_mutex_t *mutex)\ingroup API_ThreadsThis function behaves identically to starpu_pthread_mutex_lock(),except that it does not block the calling thread if the mutex isalready locked by another thread (or by the calling thread in the caseof a ``fast''  mutex). Instead, the function returns immediately withthe error code EBUSY.This function also produces trace when the configure option \refenable-fxt-lock "--enable-fxt-lock" is enabled.\typedef STARPU_PTHREAD_MUTEX_INITIALIZER\ingroup API_ThreadsThis macro initializes the mutex given in parameter.\fn int starpu_pthread_mutexattr_gettype(const starpu_pthread_mutexattr_t *attr, int *type)\ingroup API_Threadstodo\fn int starpu_pthread_mutexattr_settype(starpu_pthread_mutexattr_t *attr, int type)\ingroup API_Threadstodo\fn int starpu_pthread_mutexattr_destroy(starpu_pthread_mutexattr_t *attr)\ingroup API_Threadstodo\fn int starpu_pthread_mutexattr_init(starpu_pthread_mutexattr_t *attr)\ingroup API_Threadstodo\fn int starpu_pthread_key_create(starpu_pthread_key_t *key, void (*destr_function) (void *))\ingroup API_ThreadsThis function allocates a new TSD key. The key is stored in thelocation pointed to by \p key.\fn int starpu_pthread_key_delete(starpu_pthread_key_t key)\ingroup API_ThreadsThis function deallocates a TSD key. It does not check whethernon-NULL values are associated with that key in the currentlyexecuting threads, nor call the destructor function associated withthe key.\fn int starpu_pthread_setspecific(starpu_pthread_key_t key, const void *pointer)\ingroup API_ThreadsThis function changes the value associated with \p key in the callingthread, storing the given \p pointer instead.\fn  *starpu_pthread_getspecific(starpu_pthread_key_t key)\ingroup API_ThreadsThis function returns the value associated with \p key on success, andNULL on error.\typedef STARPU_PTHREAD_COND_INITIALIZER\ingroup API_ThreadsThis macro initializes the condition variable given in parameter.\fn starpu_pthread_cond_init(starpu_pthread_cond_t *cond, starpu_pthread_condattr_t *cond_attr)\ingroup API_ThreadsThis function initializes the condition variable \p cond, using thecondition attributes specified in \p cond_attr, or default attributesif \p cond_attr is NULL.\fn starpu_pthread_cond_signal(starpu_pthread_cond_t *cond)\ingroup API_ThreadsThis function restarts one of the threads that are waiting on thecondition variable \p cond. If no threads are waiting on \p cond,nothing happens. If several threads are waiting on \p cond, exactlyone is restarted, but it not specified which.\fn starpu_pthread_cond_broadcast(starpu_pthread_cond_t *cond)\ingroup API_ThreadsThis function restarts all the threads that are waiting on thecondition variable \p cond. Nothing happens if no threads are waiting on cond.\fn starpu_pthread_cond_wait(starpu_pthread_cond_t *cond, starpu_pthread_mutex_t *mutex)\ingroup API_ThreadsThis function atomically unlocks the mutex (as perstarpu_pthread_mutex_unlock()) and waits for the condition variable \p condto be signaled. The thread execution is suspended and does not consumeany CPU time until the condition variable is signaled. The mutex mustbe locked by the calling thread on entrance tostarpu_pthread_cond_wait(). Before returning to the calling thread, thefunction re-acquires mutex (as per starpu_pthread_mutex_lock()).This function also produces trace when the configure option \refenable-fxt-lock "--enable-fxt-lock" is enabled.\fn starpu_pthread_cond_timedwait(starpu_pthread_cond_t *cond, starpu_pthread_mutex_t *mutex, const struct timespec *abstime)\ingroup API_ThreadsThis function atomically unlocks \p mutex and waits on \p cond, asstarpu_pthread_cond_wait() does, but it also bounds the duration ofthe wait.\fn starpu_pthread_cond_destroy(starpu_pthread_cond_t *cond)\ingroup API_ThreadsThis function destroys a condition variable, freeing the resources itmight hold. No threads must be waiting on the condition variable onentrance to the function.\fn starpu_pthread_rwlock_init(starpu_pthread_rwlock_t *rwlock, const starpu_pthread_rwlockattr_t *attr)\ingroup API_ThreadsThis function is the same as starpu_pthread_mutex_init().\fn starpu_pthread_rwlock_destroy(starpu_pthread_rwlock_t *rwlock)\ingroup API_ThreadsThis function is the same as starpu_pthread_mutex_destroy().\fn starpu_pthread_rwlock_rdlock(starpu_pthread_rwlock_t *rwlock)\ingroup API_ThreadsThis function is the same as starpu_pthread_mutex_lock().\fn int starpu_pthread_rwlock_tryrdlock(starpu_pthread_rwlock_t *rwlock)\ingroup API_Threadstodo\fn starpu_pthread_rwlock_wrlock(starpu_pthread_rwlock_t *rwlock)\ingroup API_ThreadsThis function is the same as starpu_pthread_mutex_lock().\fn int starpu_pthread_rwlock_trywrlock(starpu_pthread_rwlock_t *rwlock)\ingroup API_Threadstodo\fn starpu_pthread_rwlock_unlock(starpu_pthread_rwlock_t *rwlock)\ingroup API_ThreadsThis function is the same as starpu_pthread_mutex_unlock().\fn int starpu_pthread_barrier_init(starpu_pthread_barrier_t *barrier, const starpu_pthread_barrierattr_t *attr, unsigned count)\ingroup API_Threadstodo\fn int starpu_pthread_barrier_destroy(starpu_pthread_barrier_t *barrier)\ingroup API_Threadstodo\fn int starpu_pthread_barrier_wait(starpu_pthread_barrier_t *barrier)\ingroup API_Threadstodo\fn int starpu_pthread_spin_init(starpu_pthread_spinlock_t *lock, int pshared)\ingroup API_Threadstodo\fn int starpu_pthread_spin_destroy(starpu_pthread_spinlock_t *lock)\ingroup API_Threadstodo\fn int starpu_pthread_spin_lock(starpu_pthread_spinlock_t *lock)\ingroup API_Threadstodo\fn int starpu_pthread_spin_trylock(starpu_pthread_spinlock_t *lock)\ingroup API_Threadstodo\fn int starpu_pthread_spin_unlock(starpu_pthread_spinlock_t *lock)\ingroup API_Threadstodo*/
 |