* make OMPI_THREAD_{op} a complete no-op if there are no threads. The
compiler couldn't know that ompi_have_threads() would always be false, so it was still running the tests. This saves about .04 microseconds on the critical path, according to Tim. Reviewed by George This commit was SVN r5275.
Этот коммит содержится в:
родитель
3f32a7b888
Коммит
d9f97b128a
@ -174,12 +174,13 @@ static inline bool ompi_set_using_threads(bool have)
|
||||
*/
|
||||
#define OMPI_THREAD_LOCK(mutex) \
|
||||
do { \
|
||||
if (ompi_using_threads()) { \
|
||||
if (OMPI_HAVE_THREAD_SUPPORT && ompi_using_threads()) { \
|
||||
ompi_mutex_lock(mutex); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
|
||||
/**
|
||||
* Unlock a mutex if ompi_using_threads() says that multiple threads
|
||||
* may be active in the process.
|
||||
*
|
||||
@ -194,12 +195,11 @@ static inline bool ompi_set_using_threads(bool have)
|
||||
*/
|
||||
#define OMPI_THREAD_UNLOCK(mutex) \
|
||||
do { \
|
||||
if (ompi_using_threads()) { \
|
||||
if (OMPI_HAVE_THREAD_SUPPORT && ompi_using_threads()) { \
|
||||
ompi_mutex_unlock(mutex); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
* Lock a mutex if ompi_using_threads() says that multiple threads may
|
||||
* be active in the process for the duration of the specified action.
|
||||
@ -217,7 +217,7 @@ static inline bool ompi_set_using_threads(bool have)
|
||||
*/
|
||||
#define OMPI_THREAD_SCOPED_LOCK(mutex, action) \
|
||||
do { \
|
||||
if(ompi_using_threads()) { \
|
||||
if(OMPI_HAVE_THREAD_SUPPORT && ompi_using_threads()) { \
|
||||
ompi_mutex_lock(mutex); \
|
||||
(action); \
|
||||
ompi_mutex_unlock(mutex); \
|
||||
@ -226,17 +226,18 @@ static inline bool ompi_set_using_threads(bool have)
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
* Use an atomic operation for increment/decrement if ompi_using_threads()
|
||||
* indicates that threads are in use by the application or library.
|
||||
*/
|
||||
|
||||
#define OMPI_THREAD_ADD32(x,y) \
|
||||
(ompi_using_threads() ? ompi_atomic_add_32(x,y) : (*x += y))
|
||||
((OMPI_HAVE_THREAD_SUPPORT && ompi_using_threads()) ? \
|
||||
ompi_atomic_add_32(x,y) : (*x += y))
|
||||
|
||||
#define OMPI_THREAD_ADD64(x,y) \
|
||||
(ompi_using_threads() ? ompi_atomic_add_32(x,y) : (*x += y))
|
||||
((OMPI_HAVE_THREAD_SUPPORT && ompi_using_threads()) ? \
|
||||
ompi_atomic_add_32(x,y) : (*x += y))
|
||||
|
||||
/**
|
||||
* Always locks a mutex (never compile- or run-time removed)
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user