#include "ompi_config.h" #include #include #include "support.h" #include "opal/include/constants.h" #include "opal/threads/threads.h" #include "opal/threads/condition.h" #include "opal/include/sys/atomic.h" #if !OMPI_HAVE_THREAD_SUPPORT /* If we don't have thread support, there's no point in running this test */ int main(int argc, char *argv[]) { printf("OMPI was compiled without thread support -- skipping this test\n"); return 77; } #else /* Only have the body of this test if we have thread support */ opal_mutex_t mutex; opal_condition_t thr1_cond; opal_condition_t thr2_cond; static volatile int thr1_count = 0; static volatile int thr2_count = 0; #define TEST_COUNT 1000000 static void* thr1_run(opal_object_t* obj) { int i; clock_t c1, c2; opal_mutex_lock(&mutex); c1 = clock(); for(i=0; it_run = thr1_run; thr2->t_run = thr2_run; rc = opal_thread_start(thr1); test_verify_int(OPAL_SUCCESS, rc); rc = opal_thread_start(thr2); test_verify_int(OPAL_SUCCESS, rc); rc = opal_thread_join(thr1, NULL); test_verify_int(OPAL_SUCCESS, rc); test_verify_int(TEST_COUNT, thr1_count); rc = opal_thread_join(thr2, NULL); test_verify_int(OPAL_SUCCESS, rc); test_verify_int(TEST_COUNT, thr2_count); return test_finalize(); } #endif /* OMPI_HAVE_THREAD_SUPPORT */