1 #include "ompi_config.h"
6 #include "opal/constants.h"
7 #include "opal/threads/threads.h"
8 #include "opal/sys/atomic.h"
11 #if !OMPI_HAVE_THREAD_SUPPORT
13 /* If we don't have thread support, there's no point in running this
16 int main(int argc
, char *argv
[])
18 printf("OMPI was compiled without thread support -- skipping this test\n");
24 /* Only have the body of this test if we have thread support */
26 static volatile int count
= 0;
29 static void* thr1_run(opal_object_t
* obj
)
31 opal_atomic_add(&count
, 1);
35 static void* thr2_run(opal_object_t
* obj
)
37 opal_atomic_add(&count
, 2);
41 int main(int argc
, char** argv
)
47 test_init("opal_thread_t");
49 OBJ_CONSTRUCT(&thr1
, opal_thread_t
);
50 OBJ_CONSTRUCT(&thr2
, opal_thread_t
);
52 thr1
.t_run
= thr1_run
;
53 thr2
.t_run
= thr2_run
;
55 rc
= opal_thread_start(&thr1
);
56 test_verify_int(OPAL_SUCCESS
, rc
);
58 rc
= opal_thread_start(&thr2
);
59 test_verify_int(OPAL_SUCCESS
, rc
);
61 rc
= opal_thread_join(&thr1
, NULL
);
62 test_verify_int(OPAL_SUCCESS
, rc
);
64 rc
= opal_thread_join(&thr2
, NULL
);
65 test_verify_int(OPAL_SUCCESS
, rc
);
67 test_verify_int(3, count
);
68 return test_finalize();
71 #endif /* OMPI_HAVE_THREAD_SUPPORT */