1
1

adding common test support routines and reporting

This commit was SVN r1982.
Этот коммит содержится в:
Laura Casswell 2004-08-09 21:25:05 +00:00
родитель 33c1952c79
Коммит ec8b5d1d16
2 изменённых файлов: 31 добавлений и 5 удалений

Просмотреть файл

@ -11,5 +11,12 @@ noinst_PROGRAMS = \
atomic_SOURCES = atomic.c atomic_SOURCES = atomic.c
atomic_LDADD = \ atomic_LDADD = \
$(top_builddir)/src/util/output.lo \
$(top_builddir)/src/class/ompi_object.lo \
$(top_builddir)/src/util/malloc.lo \
$(top_builddir)/src/threads/mutex.lo \
$(top_builddir)/src/threads/mutex_pthread.lo \
$(top_builddir)/src/threads/mutex_spinlock.lo \
$(top_builddir)/src/util/libutil.la \
$(top_builddir)/test/support/libsupport.la $(top_builddir)/test/support/libsupport.la
atomic_DEPENDENCIES = $(ompi_bitmap_LDADD) atomic_DEPENDENCIES = $(atomic_LDADD)

Просмотреть файл

@ -7,7 +7,7 @@
#include "support.h" #include "support.h"
#include "atomic.h" #include "include/atomic.h"
/* default options */ /* default options */
@ -21,10 +21,12 @@ uint32_t val32;
uint32_t old32; uint32_t old32;
uint32_t new32; uint32_t new32;
#ifdef ENABLE_64_BIT
volatile uint64_t vol64; volatile uint64_t vol64;
uint64_t val64; uint64_t val64;
uint64_t old64; uint64_t old64;
uint64_t new64; uint64_t new64;
#endif
volatile int volint; volatile int volint;
int valint; int valint;
@ -41,13 +43,19 @@ static void help(void)
printf("Usage: threadtest [flags]\n" printf("Usage: threadtest [flags]\n"
"\n" "\n"
" Flags may be any of\n" " Flags may be any of\n"
#ifdef ENABLE_64_BIT
" -l do 64-bit tests\n" " -l do 64-bit tests\n"
#endif
" -r NREPS number of repetitions\n" " -r NREPS number of repetitions\n"
" -t NTRHEADS number of threads\n" " -t NTRHEADS number of threads\n"
" -v verbose output\n" " -v verbose output\n"
" -h print this info\n" "\n" " -h print this info\n" "\n"
" Numbers may be postfixed with 'k' or 'm'\n\n"); " Numbers may be postfixed with 'k' or 'm'\n\n");
#ifndef ENABLE_64_BIT
printf(" 64-bit tests are not enabled in this build of the tests\n\n");
#endif
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -107,9 +115,11 @@ void *thread_main(void *arg)
for (i = 0; i < nreps; i++) { for (i = 0; i < nreps; i++) {
ompi_atomic_add_32(&val32, 5); ompi_atomic_add_32(&val32, 5);
#ifdef ENABLE_64_BIT
if (enable_64_bit_tests) { if (enable_64_bit_tests) {
ompi_atomic_add_64(&val64, 5); ompi_atomic_add_64(&val64, 5);
} }
#endif
ompi_atomic_add_int(&valint, 5); ompi_atomic_add_int(&valint, 5);
} }
@ -133,7 +143,11 @@ int main(int argc, char *argv[])
help(); help();
break; break;
case 'l': case 'l':
#ifdef ENABLE_64_BIT
enable_64_bit_tests = 1; enable_64_bit_tests = 1;
#else
usage();
#endif
break; break;
case 'r': case 'r':
if ((nreps = str2size(optarg)) <= 0) { if ((nreps = str2size(optarg)) <= 0) {
@ -190,6 +204,7 @@ int main(int argc, char *argv[])
/* -- cmpset 64-bit tests -- */ /* -- cmpset 64-bit tests -- */
#ifdef ENABLE_64_BIT
if (enable_64_bit_tests) { if (enable_64_bit_tests) {
vol64 = 42, old64 = 42, new64 = 50; vol64 = 42, old64 = 42, new64 = 50;
test_verify("atomic", ompi_atomic_cmpset_64(&vol64, old64, new64) == 1); test_verify("atomic", ompi_atomic_cmpset_64(&vol64, old64, new64) == 1);
@ -215,7 +230,7 @@ int main(int argc, char *argv[])
test_verify("atomic", ompi_atomic_cmpset_rel_64(&vol64, old64, new64) == 0); test_verify("atomic", ompi_atomic_cmpset_rel_64(&vol64, old64, new64) == 0);
test_verify("atomic", vol64 == 42); test_verify("atomic", vol64 == 42);
} }
#endif
/* -- cmpset int tests -- */ /* -- cmpset int tests -- */
volint = 42, oldint = 42, newint = 50; volint = 42, oldint = 42, newint = 50;
@ -276,13 +291,13 @@ int main(int argc, char *argv[])
test_verify("atomic", (42 + 5) == val32); test_verify("atomic", (42 + 5) == val32);
/* -- add_64 tests -- */ /* -- add_64 tests -- */
#ifdef ENABLE_64_BIT
if (enable_64_bit_tests) { if (enable_64_bit_tests) {
val64 = 42; val64 = 42;
test_verify("atomic", ompi_atomic_add_64(&val64, 5) == (42 + 5)); test_verify("atomic", ompi_atomic_add_64(&val64, 5) == (42 + 5));
test_verify("atomic", (42 + 5) == val64); test_verify("atomic", (42 + 5) == val64);
} }
#endif
/* -- add_int tests -- */ /* -- add_int tests -- */
valint = 42; valint = 42;
@ -293,7 +308,9 @@ int main(int argc, char *argv[])
/* threaded tests */ /* threaded tests */
val32 = 0; val32 = 0;
#ifdef ENABLE_64_BIT
val64 = 0ul; val64 = 0ul;
#endif
valint = 0; valint = 0;
/* -- create the thread set -- */ /* -- create the thread set -- */
@ -324,9 +341,11 @@ int main(int argc, char *argv[])
free(th); free(th);
test_verify("atomic", val32 == (5 * nthreads * nreps)); test_verify("atomic", val32 == (5 * nthreads * nreps));
#ifdef ENABLE_64_BIT
if (enable_64_bit_tests) { if (enable_64_bit_tests) {
test_verify("atomic", val64 == (5 * nthreads * nreps)); test_verify("atomic", val64 == (5 * nthreads * nreps));
} }
#endif
test_verify("atomic", valint == (5 * nthreads * nreps)); test_verify("atomic", valint == (5 * nthreads * nreps));
return test_finalize(); return test_finalize();