#include <stdio.h>
+#include "visibility.h"
#include "atomic.h"
};
+/** Thread setaffinity support status enumeration */
+enum tMPI_Thread_setaffinity_support
+{
+ TMPI_SETAFFINITY_SUPPORT_NO = 0, /*!< Setting thread affinity not
+ supported */
+ TMPI_SETAFFINITY_SUPPORT_YES = 1 /*!< Setting thread affinity supported */
+};
+
+
+
+
/** handle a fatal error.
\param file source code file name of error.
\param line source code line number of error.
\param message format string for error message.
*/
+TMPI_EXPORT
void tMPI_Fatal_error(const char *file, int line, const char *message, ...);
/** Convenience macro for the first two arguments to tMPI_Fatal_error(). */
#define TMPI_FARGS __FILE__,__LINE__
*
* \return 1 if threads are supported, 0 if not.
*/
+TMPI_EXPORT
enum tMPI_Thread_support tMPI_Thread_support(void);
If this number cannot be determined for the current architecture,
0 is returned.
*/
+TMPI_EXPORT
int tMPI_Thread_get_hw_number(void);
*
* \return Status - 0 on success, or an error code.
*/
+TMPI_EXPORT
int tMPI_Thread_create(tMPI_Thread_t *thread,
void* (*start_routine)(void *),
void* arg);
-/** Create a new thread with processor affinity
- *
- * The new thread will call start_routine() with the argument arg.
- *
- * The new thread will have processor affinity assigned in a
- * round-robin way, starting at processor 1. The first thread to call
- * this function will be assigned to processor 0.
- *
- * This means that this funtion should ONLY be called when starting a
- * thread on each processor: in any other case, this will lead to
- * imbalances because processors 0 and 1 will be oversubscribed.
- *
- * Please be careful not to change arg after calling this function.
- *
- * \param[out] thread Pointer to thread ID
- * \param[in] start_routine The function to call in the new thread
- * \param[in] arg Argument to call with
- *
- * \return Status - 0 on success, or an error code.
- */
-int tMPI_Thread_create_aff(tMPI_Thread_t *thread,
- void *(*start_routine)(void *),
- void *arg);
-
-
*
* \return 0 if the join went ok, or a non-zero error code.
*/
+TMPI_EXPORT
int tMPI_Thread_join(tMPI_Thread_t thread, void **value_ptr);
* join them can read this value if they try.
* \return
*/
+TMPI_EXPORT
void tMPI_Thread_exit(void *value_ptr);
* \param thread Handle to thread we want to see dead.
* \return 0 or a non-zero error message.
*/
+TMPI_EXPORT
int tMPI_Thread_cancel(tMPI_Thread_t thread);
* example assign thread affinities to any thread.
*
* \return A thread ID of the calling thread */
+TMPI_EXPORT
tMPI_Thread_t tMPI_Thread_self(void);
* \param[in] t2 Thread ID 2
* \return non-zero if the thread structs refer to the same thread,
0 if the threads are different*/
+TMPI_EXPORT
int tMPI_Thread_equal(tMPI_Thread_t t1, tMPI_Thread_t t2);
+/** Check whether this platform supports setting of thread affinity
+ *
+ * This function returns TMPI_SETAFFINITY_SUPPORT_YES if setting thread
+ * affinity is supported by the platform, and TMPI_SETAFFINITY_SUPPORT_NO
+ * if not. If this function returns 0, the function
+ * tMPI_Thread_setaffinity_single will simply return 0 itself, effectively
+ * ignoring the request.
+ *
+ * \return TMPI_SETAFFINITY_SUPPORT_YES if setting affinity is supported,
+ TMPI_SETAFFINITY_SUPPORT_NO otherwise */
+TMPI_EXPORT
+enum tMPI_Thread_setaffinity_support tMPI_Thread_setaffinity_support(void);
+
+
/** Set thread affinity to a single core
*
* This function sets the thread affinity of a thread to a a specific
* by tMPI_Thread_get_hw_number().
*
* \param[in] thread Thread ID of the thread to set affinity for
- * \param[in] nr Processor number to set affinity to */
+ * \param[in] nr Processor number to set affinity to
+ * \return zero on success, non-zero on error */
+TMPI_EXPORT
int tMPI_Thread_setaffinity_single(tMPI_Thread_t thread, unsigned int nr);
* \param mtx Pointer to a mutex opaque type.
* \return 0 or an error code.
*/
+TMPI_EXPORT
int tMPI_Thread_mutex_init(tMPI_Thread_mutex_t *mtx);
* \param mtx Pointer to a mutex variable to get rid of.
* \return 0 or a non-zero error code.
*/
+TMPI_EXPORT
int tMPI_Thread_mutex_destroy(tMPI_Thread_mutex_t *mtx);
* \param mtx Pointer to the mutex to lock
* \return 0 or a non-zero error code.
*/
+TMPI_EXPORT
int tMPI_Thread_mutex_lock(tMPI_Thread_mutex_t *mtx);
* \param mtx Pointer to the mutex to try and lock
* \return 0 or a non-zero return error code.
*/
+TMPI_EXPORT
int tMPI_Thread_mutex_trylock(tMPI_Thread_mutex_t *mtx);
* \param mtx Pointer to the mutex to release
* \return 0 or a non-zero error code.
*/
+TMPI_EXPORT
int tMPI_Thread_mutex_unlock(tMPI_Thread_mutex_t *mtx);
* \return status - 0 on sucess or a standard error code.
*
*/
+TMPI_EXPORT
int tMPI_Thread_key_create(tMPI_Thread_key_t *key, void (*destructor)(void *));
* \param key Opaque key type to destroy
* \return 0 or a non-zero error message.
*/
+TMPI_EXPORT
int tMPI_Thread_key_delete(tMPI_Thread_key_t key);
* \param key Thread-specific-storage handle.
* \return Pointer-to-void, the value of the data in this thread.
*/
+TMPI_EXPORT
void * tMPI_Thread_getspecific(tMPI_Thread_key_t key);
* \param value What to set the data to (pointer-to-void).
* \return 0 or a non-zero error message.
*/
+TMPI_EXPORT
int tMPI_Thread_setspecific(tMPI_Thread_key_t key, void *value);
* \param init_routine Function to call exactly once
* \return 0 or a non-zero error message.
*/
+TMPI_EXPORT
int tMPI_Thread_once(tMPI_Thread_once_t *once_data,
void (*init_routine)(void));
* \param cond Pointer to previously allocated condition variable
* \return 0 or a non-zero error message.
*/
+TMPI_EXPORT
int tMPI_Thread_cond_init(tMPI_Thread_cond_t *cond);
* \param cond Pointer to condition variable.
* \return 0 or a non-zero error message.
*/
+TMPI_EXPORT
int tMPI_Thread_cond_destroy(tMPI_Thread_cond_t *cond);
*
* \return 0 or a non-zero error message.
*/
+TMPI_EXPORT
int tMPI_Thread_cond_wait(tMPI_Thread_cond_t *cond,
tMPI_Thread_mutex_t *mtx);
*
* \return 0 or a non-zero error message.
*/
+TMPI_EXPORT
int tMPI_Thread_cond_signal(tMPI_Thread_cond_t *cond);
*
* \return 0 or a non-zero error message.
*/
+TMPI_EXPORT
int tMPI_Thread_cond_broadcast(tMPI_Thread_cond_t *cond);
* will be released after \a count calls to
* tMPI_Thread_barrier_wait().
*/
+TMPI_EXPORT
int tMPI_Thread_barrier_init(tMPI_Thread_barrier_t *barrier, int count);
* \param barrier Pointer to previously
* initialized barrier.
*/
+TMPI_EXPORT
int tMPI_Thread_barrier_destroy(tMPI_Thread_barrier_t *barrier);
*
* \return The last thread returns -1, all the others 0.
*/
+TMPI_EXPORT
int tMPI_Thread_barrier_wait(tMPI_Thread_barrier_t *barrier);
/*! \} */