* Update ASM tests to do more thread testing (which should help find bugs)
* Update cmpset test to call memory barrier when needed before checking the results * remove unneeded sync from cmpset_32 on Power PC This commit was SVN r5420.
Этот коммит содержится в:
родитель
0a77b54535
Коммит
63bd314a0b
@ -26,7 +26,6 @@ START_FUNC(ompi_atomic_cmpset_32)
|
|||||||
bne- REFLSYM(2)
|
bne- REFLSYM(2)
|
||||||
stwcx. r5, 0, r3
|
stwcx. r5, 0, r3
|
||||||
bne- REFLSYM(1)
|
bne- REFLSYM(1)
|
||||||
sync
|
|
||||||
LSYM(2)
|
LSYM(2)
|
||||||
xor r3,r0,r4
|
xor r3,r0,r4
|
||||||
subfic r2,r3,0
|
subfic r2,r3,0
|
||||||
|
@ -26,7 +26,6 @@ START_FUNC(ompi_atomic_cmpset_32)
|
|||||||
bne- REFLSYM(2)
|
bne- REFLSYM(2)
|
||||||
stwcx. r5, 0, r3
|
stwcx. r5, 0, r3
|
||||||
bne- REFLSYM(1)
|
bne- REFLSYM(1)
|
||||||
sync
|
|
||||||
LSYM(2)
|
LSYM(2)
|
||||||
cmpw cr7,r0,r4
|
cmpw cr7,r0,r4
|
||||||
mfcr r3
|
mfcr r3
|
||||||
|
@ -132,7 +132,6 @@ static inline int ompi_atomic_cmpset_32(volatile int32_t *addr,
|
|||||||
" bne- 2f \n\t"
|
" bne- 2f \n\t"
|
||||||
" stwcx. %4, 0, %2 \n\t"
|
" stwcx. %4, 0, %2 \n\t"
|
||||||
" bne- 1b \n\t"
|
" bne- 1b \n\t"
|
||||||
SMP_SYNC
|
|
||||||
"2:"
|
"2:"
|
||||||
: "=&r" (ret), "=m" (*addr)
|
: "=&r" (ret), "=m" (*addr)
|
||||||
: "r" (addr), "r" (oldval), "r" (newval), "m" (*addr)
|
: "r" (addr), "r" (oldval), "r" (newval), "m" (*addr)
|
||||||
|
@ -16,29 +16,23 @@
|
|||||||
|
|
||||||
include $(top_srcdir)/config/Makefile.options
|
include $(top_srcdir)/config/Makefile.options
|
||||||
|
|
||||||
noinst_HEADERS = atomic_test.h
|
TESTS_ENVIRONMENT = $(SHELL) run_tests
|
||||||
|
|
||||||
check_PROGRAMS = \
|
check_PROGRAMS = \
|
||||||
atomic_barrier \
|
atomic_barrier \
|
||||||
atomic_barrier_noinline \
|
atomic_barrier_noinline \
|
||||||
atomic_spinlock_serial \
|
atomic_spinlock \
|
||||||
atomic_spinlock_serial_noinline \
|
atomic_spinlock_noinline \
|
||||||
atomic_spinlock_2 \
|
atomic_math \
|
||||||
atomic_spinlock_2_noinline \
|
atomic_math_noinline \
|
||||||
atomic_spinlock_5 \
|
atomic_cmpset \
|
||||||
atomic_spinlock_5_noinline \
|
atomic_cmpset_noinline
|
||||||
atomic_spinlock_8 \
|
|
||||||
atomic_spinlock_8_noinline \
|
|
||||||
atomic_cmpset_32_serial \
|
|
||||||
atomic_cmpset_32_serial_noinline \
|
|
||||||
atomic_cmpset_64_serial \
|
|
||||||
atomic_cmpset_64_serial_noinline \
|
|
||||||
atomic-test \
|
|
||||||
atomic-test_noinline
|
|
||||||
|
|
||||||
TESTS = \
|
TESTS = \
|
||||||
$(check_PROGRAMS)
|
$(check_PROGRAMS)
|
||||||
|
|
||||||
|
EXTRA_DIST = run_tests
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
atomic_barrier_SOURCES = atomic_barrier.c
|
atomic_barrier_SOURCES = atomic_barrier.c
|
||||||
@ -52,96 +46,42 @@ atomic_barrier_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM
|
|||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
atomic_spinlock_serial_SOURCES = \
|
atomic_spinlock_SOURCES = atomic_spinlock.c
|
||||||
atomic_spinlock_serial.c \
|
atomic_spinlock_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
||||||
atomic_spinlock.c
|
|
||||||
atomic_spinlock_serial_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
|
||||||
|
|
||||||
atomic_spinlock_serial_noinline.c:
|
|
||||||
ln -s $(top_srcdir)/test/asm/atomic_spinlock_serial.c atomic_spinlock_serial_noinline.c
|
|
||||||
atomic_spinlock_serial_noinline_SOURCES = \
|
|
||||||
atomic_spinlock_serial_noinline.c \
|
|
||||||
atomic_spinlock.c
|
|
||||||
atomic_spinlock_serial_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM
|
|
||||||
atomic_spinlock_serial_noinline_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
|
||||||
|
|
||||||
atomic_spinlock_2_SOURCES = \
|
|
||||||
atomic_spinlock_2.c \
|
|
||||||
atomic_spinlock.c
|
|
||||||
atomic_spinlock_2_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
|
||||||
|
|
||||||
atomic_spinlock_2_noinline.c:
|
|
||||||
ln -s $(top_srcdir)/test/asm/atomic_spinlock_2.c atomic_spinlock_2_noinline.c
|
|
||||||
atomic_spinlock_2_noinline_SOURCES = \
|
|
||||||
atomic_spinlock_2_noinline.c \
|
|
||||||
atomic_spinlock.c
|
|
||||||
atomic_spinlock_2_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM
|
|
||||||
atomic_spinlock_2_noinline_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
|
||||||
|
|
||||||
atomic_spinlock_5_SOURCES = \
|
|
||||||
atomic_spinlock_5.c \
|
|
||||||
atomic_spinlock.c
|
|
||||||
atomic_spinlock_5_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
|
||||||
|
|
||||||
atomic_spinlock_5_noinline.c:
|
|
||||||
ln -s $(top_srcdir)/test/asm/atomic_spinlock_5.c atomic_spinlock_5_noinline.c
|
|
||||||
atomic_spinlock_5_noinline_SOURCES = \
|
|
||||||
atomic_spinlock_5_noinline.c \
|
|
||||||
atomic_spinlock.c
|
|
||||||
atomic_spinlock_5_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM
|
|
||||||
atomic_spinlock_5_noinline_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
|
||||||
|
|
||||||
atomic_spinlock_8_SOURCES = \
|
|
||||||
atomic_spinlock_8.c \
|
|
||||||
atomic_spinlock.c
|
|
||||||
atomic_spinlock_8_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
|
||||||
|
|
||||||
atomic_spinlock_8_noinline.c:
|
|
||||||
ln -s $(top_srcdir)/test/asm/atomic_spinlock_8.c atomic_spinlock_8_noinline.c
|
|
||||||
atomic_spinlock_8_noinline_SOURCES = \
|
|
||||||
atomic_spinlock_8_noinline.c \
|
|
||||||
atomic_spinlock.c
|
|
||||||
atomic_spinlock_8_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM
|
|
||||||
atomic_spinlock_8_noinline_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
|
||||||
|
|
||||||
|
atomic_spinlock_noinline.c:
|
||||||
|
ln -s $(top_srcdir)/test/asm/atomic_spinlock.c atomic_spinlock_noinline.c
|
||||||
|
atomic_spinlock_noinline_SOURCES = atomic_spinlock_noinline.c
|
||||||
|
atomic_spinlock_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM
|
||||||
|
atomic_spinlock_noinline_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
atomic_cmpset_32_serial_SOURCES = atomic_cmpset_32_serial.c
|
atomic_math_SOURCES = atomic_math.c
|
||||||
atomic_cmpset_32_serial_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
atomic_math_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
||||||
|
|
||||||
atomic_cmpset_32_serial_noinline.c:
|
atomic_math_noinline.c:
|
||||||
ln -s $(top_srcdir)/test/asm/atomic_cmpset_32_serial.c atomic_cmpset_32_serial_noinline.c
|
ln -s $(top_srcdir)/test/asm/atomic_math.c atomic_math_noinline.c
|
||||||
atomic_cmpset_32_serial_noinline_SOURCES = atomic_cmpset_32_serial_noinline.c
|
atomic_math_noinline_SOURCES = atomic_math_noinline.c
|
||||||
atomic_cmpset_32_serial_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM
|
atomic_math_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM
|
||||||
atomic_cmpset_32_serial_noinline_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
atomic_math_noinline_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
atomic_cmpset_64_serial_SOURCES = atomic_cmpset_64_serial.c
|
atomic_cmpset_SOURCES = atomic_cmpset.c
|
||||||
atomic_cmpset_64_serial_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
atomic_cmpset_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
||||||
|
|
||||||
atomic_cmpset_64_serial_noinline.c:
|
atomic_cmpset_noinline.c:
|
||||||
ln -s $(top_srcdir)/test/asm/atomic_cmpset_64_serial.c atomic_cmpset_64_serial_noinline.c
|
ln -s $(top_srcdir)/test/asm/atomic_cmpset.c atomic_cmpset_noinline.c
|
||||||
atomic_cmpset_64_serial_noinline_SOURCES = atomic_cmpset_64_serial_noinline.c
|
atomic_cmpset_noinline_SOURCES = atomic_cmpset_noinline.c
|
||||||
atomic_cmpset_64_serial_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM
|
atomic_cmpset_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM
|
||||||
atomic_cmpset_64_serial_noinline_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
atomic_cmpset_noinline_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
atomic_test_SOURCES = atomic-test.c
|
|
||||||
atomic_test_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
|
||||||
|
|
||||||
atomic-test_noinline.c:
|
|
||||||
ln -s $(top_srcdir)/test/asm/atomic-test.c atomic-test_noinline.c
|
|
||||||
atomic_test_noinline_SOURCES = atomic-test_noinline.c
|
|
||||||
atomic_test_serial_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM
|
|
||||||
atomic_test_noinline_LDADD = $(top_builddir)/src/asm/libasm.la $(libs)
|
|
||||||
|
|
||||||
|
|
||||||
clean-local:
|
clean-local:
|
||||||
rm -f atomic_barrier_noinline.c atomic-test_noinline.c \
|
rm -f atomic_barrier_noinline.c \
|
||||||
atomic_cmpset_32_serial_noinline.c \
|
atomic_spinlock_noinline.c \
|
||||||
atomic_cmpset_64_serial_noinline.c atomic_spinlock_2_noinline.c \
|
atomic_math_noinline.c \
|
||||||
atomic_spinlock_5_noinline.c atomic_spinlock_8_noinline.c \
|
atomic_cmpset_noinline.c
|
||||||
atomic_spinlock_serial_noinline.c
|
|
||||||
|
@ -17,14 +17,13 @@
|
|||||||
#undef OMPI_BUILDING
|
#undef OMPI_BUILDING
|
||||||
#include "ompi_config.h"
|
#include "ompi_config.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "include/sys/atomic.h"
|
#include "include/sys/atomic.h"
|
||||||
#include "atomic_test.h"
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
#if OMPI_HAVE_ATOMIC_MEM_BARRIER
|
||||||
|
|
||||||
/* there really isn't a great way to test that the barriers
|
/* there really isn't a great way to test that the barriers
|
||||||
actually barrier, but at least make sure they don't kill the
|
actually barrier, but at least make sure they don't kill the
|
||||||
machine.*/
|
machine.*/
|
||||||
@ -34,5 +33,8 @@ main(int argc, char *argv[])
|
|||||||
ompi_atomic_wmb();
|
ompi_atomic_wmb();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
return 77;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,10 @@
|
|||||||
#undef OMPI_BUILDING
|
#undef OMPI_BUILDING
|
||||||
#include "ompi_config.h"
|
#include "ompi_config.h"
|
||||||
|
|
||||||
|
#undef NDEBUG
|
||||||
|
#define DEBUG
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <getopt.h>
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
#ifdef HAVE_PTHREAD_H
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
@ -31,11 +33,9 @@
|
|||||||
|
|
||||||
|
|
||||||
/* default options */
|
/* default options */
|
||||||
|
|
||||||
int nreps = 100;
|
int nreps = 100;
|
||||||
int nthreads = 2;
|
int nthreads = 2;
|
||||||
int enable_verbose = 0;
|
int enable_verbose = 0;
|
||||||
int enable_64_bit_tests = 0;
|
|
||||||
|
|
||||||
volatile int32_t vol32;
|
volatile int32_t vol32;
|
||||||
int32_t val32;
|
int32_t val32;
|
||||||
@ -59,79 +59,12 @@ void *oldptr;
|
|||||||
void *newptr;
|
void *newptr;
|
||||||
|
|
||||||
|
|
||||||
static void help(void)
|
#if OMPI_HAVE_POSIX_THREADS
|
||||||
{
|
|
||||||
printf("Usage: threadtest [flags]\n"
|
|
||||||
"\n"
|
|
||||||
" Flags may be any of\n"
|
|
||||||
#if OMPI_HAVE_ATOMIC_MATH_64
|
|
||||||
" -l do 64-bit tests\n"
|
|
||||||
#endif
|
|
||||||
" -r NREPS number of repetitions\n"
|
|
||||||
" -t NTRHEADS number of threads\n"
|
|
||||||
" -v verbose output\n"
|
|
||||||
" -h print this info\n" "\n"
|
|
||||||
" Numbers may be postfixed with 'k' or 'm'\n\n");
|
|
||||||
|
|
||||||
#ifndef OMPI_HAVE_ATOMIC_MATH_64
|
|
||||||
printf(" 64-bit tests are not enabled in this build of the tests\n\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void usage(void)
|
|
||||||
{
|
|
||||||
fprintf(stderr,
|
|
||||||
"Usage: threadtest [flags]\n" " threadtest -h\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void verbose(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
if (enable_verbose) {
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vfprintf(stderr, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int str2size(char *str)
|
|
||||||
{
|
|
||||||
int size;
|
|
||||||
char mod[32];
|
|
||||||
|
|
||||||
switch (sscanf(str, "%d%1[mMkK]", &size, mod)) {
|
|
||||||
case 1:
|
|
||||||
return (size);
|
|
||||||
case 2:
|
|
||||||
switch (*mod) {
|
|
||||||
case 'm':
|
|
||||||
case 'M':
|
|
||||||
return (size << 20);
|
|
||||||
case 'k':
|
|
||||||
case 'K':
|
|
||||||
return (size << 10);
|
|
||||||
default:
|
|
||||||
return (size);
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void *thread_main(void *arg)
|
static void *thread_main(void *arg)
|
||||||
{
|
{
|
||||||
int rank = (int) (unsigned long) arg;
|
int rank = (int) (unsigned long) arg;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
verbose("thread-%d: Hello\n", rank);
|
|
||||||
|
|
||||||
/* thread tests */
|
/* thread tests */
|
||||||
|
|
||||||
for (i = 0; i < nreps; i++) {
|
for (i = 0; i < nreps; i++) {
|
||||||
@ -146,54 +79,22 @@ static void *thread_main(void *arg)
|
|||||||
|
|
||||||
return (void *) (unsigned long) (rank + 1000);
|
return (void *) (unsigned long) (rank + 1000);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int c;
|
|
||||||
#if OMPI_HAVE_POSIX_THREADS
|
#if OMPI_HAVE_POSIX_THREADS
|
||||||
int tid;
|
int tid;
|
||||||
pthread_t *th;
|
pthread_t *th;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* option processing */
|
if (argc != 2) {
|
||||||
|
printf("*** Incorrect number of arguments. Skipping test\n");
|
||||||
while ((c = getopt(argc, argv, "hlr:t:v")) != -1) {
|
return 77;
|
||||||
switch (c) {
|
|
||||||
case 'h':
|
|
||||||
help();
|
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
#if OMPI_HAVE_ATOMIC_MATH_64
|
|
||||||
enable_64_bit_tests = 1;
|
|
||||||
#else
|
|
||||||
usage();
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
if ((nreps = str2size(optarg)) <= 0) {
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
if ((nthreads = str2size(optarg)) <= 0) {
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
enable_verbose = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (optind != argc) {
|
|
||||||
usage();
|
|
||||||
}
|
}
|
||||||
|
nthreads = atoi(argv[1]);
|
||||||
|
|
||||||
verbose("main: %s\n", argv[0]);
|
|
||||||
verbose("main: nthreads = %d\n", nthreads);
|
|
||||||
verbose("main: nreps = %d\n", nreps);
|
|
||||||
|
|
||||||
/* first test single-threaded functionality */
|
/* first test single-threaded functionality */
|
||||||
|
|
||||||
@ -201,10 +102,12 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
vol32 = 42, old32 = 42, new32 = 50;
|
vol32 = 42, old32 = 42, new32 = 50;
|
||||||
assert(ompi_atomic_cmpset_32(&vol32, old32, new32) == 1);
|
assert(ompi_atomic_cmpset_32(&vol32, old32, new32) == 1);
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert(vol32 == new32);
|
assert(vol32 == new32);
|
||||||
|
|
||||||
vol32 = 42, old32 = 420, new32 = 50;
|
vol32 = 42, old32 = 420, new32 = 50;
|
||||||
assert(ompi_atomic_cmpset_32(&vol32, old32, new32) == 0);
|
assert(ompi_atomic_cmpset_32(&vol32, old32, new32) == 0);
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert(vol32 == 42);
|
assert(vol32 == 42);
|
||||||
|
|
||||||
vol32 = 42, old32 = 42, new32 = 50;
|
vol32 = 42, old32 = 42, new32 = 50;
|
||||||
@ -217,51 +120,55 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
vol32 = 42, old32 = 42, new32 = 50;
|
vol32 = 42, old32 = 42, new32 = 50;
|
||||||
assert(ompi_atomic_cmpset_rel_32(&vol32, old32, new32) == 1);
|
assert(ompi_atomic_cmpset_rel_32(&vol32, old32, new32) == 1);
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert(vol32 == new32);
|
assert(vol32 == new32);
|
||||||
|
|
||||||
vol32 = 42, old32 = 420, new32 = 50;
|
vol32 = 42, old32 = 420, new32 = 50;
|
||||||
assert(ompi_atomic_cmpset_rel_32(&vol32, old32, new32) == 0);
|
assert(ompi_atomic_cmpset_rel_32(&vol32, old32, new32) == 0);
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert(vol32 == 42);
|
assert(vol32 == 42);
|
||||||
|
|
||||||
/* -- cmpset 64-bit tests -- */
|
/* -- cmpset 64-bit tests -- */
|
||||||
|
|
||||||
#if OMPI_HAVE_ATOMIC_MATH_64
|
#if OMPI_HAVE_ATOMIC_MATH_64
|
||||||
if (enable_64_bit_tests) {
|
vol64 = 42, old64 = 42, new64 = 50;
|
||||||
verbose("64 bit serial tests\n");
|
assert(1 == ompi_atomic_cmpset_64(&vol64, old64, new64));
|
||||||
vol64 = 42, old64 = 42, new64 = 50;
|
ompi_atomic_rmb();
|
||||||
assert(1 == ompi_atomic_cmpset_64(&vol64, old64, new64));
|
assert(new64 == vol64);
|
||||||
assert(new64 == vol64);
|
|
||||||
|
|
||||||
verbose("64 bit serial test 2\n");
|
vol64 = 42, old64 = 420, new64 = 50;
|
||||||
vol64 = 42, old64 = 420, new64 = 50;
|
assert(ompi_atomic_cmpset_64(&vol64, old64, new64) == 0);
|
||||||
assert(ompi_atomic_cmpset_64(&vol64, old64, new64) == 0);
|
ompi_atomic_rmb();
|
||||||
assert(vol64 == 42);
|
assert(vol64 == 42);
|
||||||
|
|
||||||
vol64 = 42, old64 = 42, new64 = 50;
|
vol64 = 42, old64 = 42, new64 = 50;
|
||||||
assert(ompi_atomic_cmpset_acq_64(&vol64, old64, new64) == 1);
|
assert(ompi_atomic_cmpset_acq_64(&vol64, old64, new64) == 1);
|
||||||
assert(vol64 == new64);
|
assert(vol64 == new64);
|
||||||
|
|
||||||
vol64 = 42, old64 = 420, new64 = 50;
|
vol64 = 42, old64 = 420, new64 = 50;
|
||||||
assert(ompi_atomic_cmpset_acq_64(&vol64, old64, new64) == 0);
|
assert(ompi_atomic_cmpset_acq_64(&vol64, old64, new64) == 0);
|
||||||
assert(vol64 == 42);
|
assert(vol64 == 42);
|
||||||
|
|
||||||
vol64 = 42, old64 = 42, new64 = 50;
|
vol64 = 42, old64 = 42, new64 = 50;
|
||||||
assert(ompi_atomic_cmpset_rel_64(&vol64, old64, new64) == 1);
|
assert(ompi_atomic_cmpset_rel_64(&vol64, old64, new64) == 1);
|
||||||
assert(vol64 == new64);
|
ompi_atomic_rmb();
|
||||||
|
assert(vol64 == new64);
|
||||||
|
|
||||||
vol64 = 42, old64 = 420, new64 = 50;
|
vol64 = 42, old64 = 420, new64 = 50;
|
||||||
assert(ompi_atomic_cmpset_rel_64(&vol64, old64, new64) == 0);
|
assert(ompi_atomic_cmpset_rel_64(&vol64, old64, new64) == 0);
|
||||||
assert(vol64 == 42);
|
ompi_atomic_rmb();
|
||||||
}
|
assert(vol64 == 42);
|
||||||
#endif
|
#endif
|
||||||
/* -- cmpset int tests -- */
|
/* -- cmpset int tests -- */
|
||||||
|
|
||||||
volint = 42, oldint = 42, newint = 50;
|
volint = 42, oldint = 42, newint = 50;
|
||||||
assert(ompi_atomic_cmpset(&volint, oldint, newint) == 1);
|
assert(ompi_atomic_cmpset(&volint, oldint, newint) == 1);
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert(volint ==newint);
|
assert(volint ==newint);
|
||||||
|
|
||||||
volint = 42, oldint = 420, newint = 50;
|
volint = 42, oldint = 420, newint = 50;
|
||||||
assert(ompi_atomic_cmpset(&volint, oldint, newint) == 0);
|
assert(ompi_atomic_cmpset(&volint, oldint, newint) == 0);
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert(volint == 42);
|
assert(volint == 42);
|
||||||
|
|
||||||
volint = 42, oldint = 42, newint = 50;
|
volint = 42, oldint = 42, newint = 50;
|
||||||
@ -274,10 +181,12 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
volint = 42, oldint = 42, newint = 50;
|
volint = 42, oldint = 42, newint = 50;
|
||||||
assert(ompi_atomic_cmpset_rel(&volint, oldint, newint) == 1);
|
assert(ompi_atomic_cmpset_rel(&volint, oldint, newint) == 1);
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert(volint == newint);
|
assert(volint == newint);
|
||||||
|
|
||||||
volint = 42, oldint = 420, newint = 50;
|
volint = 42, oldint = 420, newint = 50;
|
||||||
assert(ompi_atomic_cmpset_rel(&volint, oldint, newint) == 0);
|
assert(ompi_atomic_cmpset_rel(&volint, oldint, newint) == 0);
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert(volint == 42);
|
assert(volint == 42);
|
||||||
|
|
||||||
|
|
||||||
@ -285,10 +194,12 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
volptr = (void *) 42, oldptr = (void *) 42, newptr = (void *) 50;
|
volptr = (void *) 42, oldptr = (void *) 42, newptr = (void *) 50;
|
||||||
assert(ompi_atomic_cmpset_ptr(&volptr, oldptr, newptr) == 1);
|
assert(ompi_atomic_cmpset_ptr(&volptr, oldptr, newptr) == 1);
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert(volptr == newptr);
|
assert(volptr == newptr);
|
||||||
|
|
||||||
volptr = (void *) 42, oldptr = (void *) 420, newptr = (void *) 50;
|
volptr = (void *) 42, oldptr = (void *) 420, newptr = (void *) 50;
|
||||||
assert(ompi_atomic_cmpset_ptr(&volptr, oldptr, newptr) == 0);
|
assert(ompi_atomic_cmpset_ptr(&volptr, oldptr, newptr) == 0);
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert(volptr == (void *) 42);
|
assert(volptr == (void *) 42);
|
||||||
|
|
||||||
volptr = (void *) 42, oldptr = (void *) 42, newptr = (void *) 50;
|
volptr = (void *) 42, oldptr = (void *) 42, newptr = (void *) 50;
|
||||||
@ -301,30 +212,33 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
volptr = (void *) 42, oldptr = (void *) 42, newptr = (void *) 50;
|
volptr = (void *) 42, oldptr = (void *) 42, newptr = (void *) 50;
|
||||||
assert(ompi_atomic_cmpset_rel_ptr(&volptr, oldptr, newptr) == 1);
|
assert(ompi_atomic_cmpset_rel_ptr(&volptr, oldptr, newptr) == 1);
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert(volptr == newptr);
|
assert(volptr == newptr);
|
||||||
|
|
||||||
volptr = (void *) 42, oldptr = (void *) 420, newptr = (void *) 50;
|
volptr = (void *) 42, oldptr = (void *) 420, newptr = (void *) 50;
|
||||||
assert(ompi_atomic_cmpset_rel_ptr(&volptr, oldptr, newptr) == 0);
|
assert(ompi_atomic_cmpset_rel_ptr(&volptr, oldptr, newptr) == 0);
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert(volptr == (void *) 42);
|
assert(volptr == (void *) 42);
|
||||||
|
|
||||||
/* -- add_32 tests -- */
|
/* -- add_32 tests -- */
|
||||||
|
|
||||||
val32 = 42;
|
val32 = 42;
|
||||||
assert(ompi_atomic_add_32(&val32, 5) == (42 + 5));
|
assert(ompi_atomic_add_32(&val32, 5) == (42 + 5));
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert((42 + 5) == val32);
|
assert((42 + 5) == val32);
|
||||||
|
|
||||||
/* -- add_64 tests -- */
|
/* -- add_64 tests -- */
|
||||||
#if OMPI_HAVE_ATOMIC_MATH_64
|
#if OMPI_HAVE_ATOMIC_MATH_64
|
||||||
if (enable_64_bit_tests) {
|
val64 = 42;
|
||||||
val64 = 42;
|
assert(ompi_atomic_add_64(&val64, 5) == (42 + 5));
|
||||||
assert(ompi_atomic_add_64(&val64, 5) == (42 + 5));
|
ompi_atomic_rmb();
|
||||||
assert((42 + 5) == val64);
|
assert((42 + 5) == val64);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
/* -- add_int tests -- */
|
/* -- add_int tests -- */
|
||||||
|
|
||||||
valint = 42;
|
valint = 42;
|
||||||
ompi_atomic_add(&valint, 5);
|
ompi_atomic_add(&valint, 5);
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert((42 + 5) == valint);
|
assert((42 + 5) == valint);
|
||||||
|
|
||||||
|
|
||||||
@ -359,16 +273,16 @@ int main(int argc, char *argv[])
|
|||||||
perror("pthread_join");
|
perror("pthread_join");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
verbose("main: thread %d returned %d\n", tid, (int) (unsigned long) thread_return);
|
|
||||||
}
|
}
|
||||||
free(th);
|
free(th);
|
||||||
|
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert((5 * nthreads * nreps) == val32);
|
assert((5 * nthreads * nreps) == val32);
|
||||||
#if OMPI_HAVE_ATOMIC_MATH_64
|
#if OMPI_HAVE_ATOMIC_MATH_64
|
||||||
if (enable_64_bit_tests) {
|
ompi_atomic_rmb();
|
||||||
assert((5 * nthreads * nreps) == val64);
|
assert((5 * nthreads * nreps) == val64);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
ompi_atomic_rmb();
|
||||||
assert((5 * nthreads * nreps) == valint);
|
assert((5 * nthreads * nreps) == valint);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
||||||
* All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
||||||
* All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
||||||
* University of Stuttgart. All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
||||||
* All rights reserved.
|
|
||||||
* $COPYRIGHT$
|
|
||||||
*
|
|
||||||
* Additional copyrights may follow
|
|
||||||
*
|
|
||||||
* $HEADER$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#undef OMPI_BUILDING
|
|
||||||
#include "ompi_config.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "include/sys/atomic.h"
|
|
||||||
|
|
||||||
volatile int32_t vol32;
|
|
||||||
int32_t val32;
|
|
||||||
int32_t old32;
|
|
||||||
int32_t new32;
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
#if ! OMPI_HAVE_ATOMIC_CMPSET_32
|
|
||||||
return 77;
|
|
||||||
#else
|
|
||||||
|
|
||||||
vol32 = 42, old32 = 42, new32 = 50;
|
|
||||||
assert(ompi_atomic_cmpset_32(&vol32, old32, new32) == 1);
|
|
||||||
assert(vol32 == new32);
|
|
||||||
|
|
||||||
vol32 = 42, old32 = 420, new32 = 50;
|
|
||||||
assert(ompi_atomic_cmpset_32(&vol32, old32, new32) == 0);
|
|
||||||
assert(vol32 == 42);
|
|
||||||
|
|
||||||
vol32 = 42, old32 = 42, new32 = 50;
|
|
||||||
assert(ompi_atomic_cmpset_acq_32(&vol32, old32, new32) == 1);
|
|
||||||
assert(vol32 == new32);
|
|
||||||
|
|
||||||
vol32 = 42, old32 = 420, new32 = 50;
|
|
||||||
assert(ompi_atomic_cmpset_acq_32(&vol32, old32, new32) == 0);
|
|
||||||
assert(vol32 == 42);
|
|
||||||
|
|
||||||
vol32 = 42, old32 = 42, new32 = 50;
|
|
||||||
assert(ompi_atomic_cmpset_rel_32(&vol32, old32, new32) == 1);
|
|
||||||
assert(vol32 == new32);
|
|
||||||
|
|
||||||
vol32 = 42, old32 = 420, new32 = 50;
|
|
||||||
assert(ompi_atomic_cmpset_rel_32(&vol32, old32, new32) == 0);
|
|
||||||
assert(vol32 == 42);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
||||||
* All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
||||||
* All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
||||||
* University of Stuttgart. All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
||||||
* All rights reserved.
|
|
||||||
* $COPYRIGHT$
|
|
||||||
*
|
|
||||||
* Additional copyrights may follow
|
|
||||||
*
|
|
||||||
* $HEADER$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#undef OMPI_BUILDING
|
|
||||||
#include "ompi_config.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "include/sys/atomic.h"
|
|
||||||
|
|
||||||
#if OMPI_HAVE_ATOMIC_MATH_64
|
|
||||||
volatile int64_t vol64;
|
|
||||||
int64_t val64;
|
|
||||||
int64_t old64;
|
|
||||||
int64_t new64;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
#if OMPI_HAVE_ATOMIC_MATH_64
|
|
||||||
vol64 = 42, old64 = 42, new64 = 50;
|
|
||||||
assert(1 == ompi_atomic_cmpset_64(&vol64, old64, new64));
|
|
||||||
assert(new64 == vol64);
|
|
||||||
|
|
||||||
vol64 = 42, old64 = 420, new64 = 50;
|
|
||||||
assert(ompi_atomic_cmpset_64(&vol64, old64, new64) == 0);
|
|
||||||
assert(vol64 == 42);
|
|
||||||
|
|
||||||
vol64 = 42, old64 = 42, new64 = 50;
|
|
||||||
assert(ompi_atomic_cmpset_acq_64(&vol64, old64, new64) == 1);
|
|
||||||
assert(vol64 == new64);
|
|
||||||
|
|
||||||
vol64 = 42, old64 = 420, new64 = 50;
|
|
||||||
assert(ompi_atomic_cmpset_acq_64(&vol64, old64, new64) == 0);
|
|
||||||
assert(vol64 == 42);
|
|
||||||
|
|
||||||
vol64 = 42, old64 = 42, new64 = 50;
|
|
||||||
assert(ompi_atomic_cmpset_rel_64(&vol64, old64, new64) == 1);
|
|
||||||
assert(vol64 == new64);
|
|
||||||
|
|
||||||
vol64 = 42, old64 = 420, new64 = 50;
|
|
||||||
assert(ompi_atomic_cmpset_rel_64(&vol64, old64, new64) == 0);
|
|
||||||
assert(vol64 == 42);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
#else
|
|
||||||
return 77;
|
|
||||||
#endif
|
|
||||||
}
|
|
131
test/asm/atomic_math.c
Обычный файл
131
test/asm/atomic_math.c
Обычный файл
@ -0,0 +1,131 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
||||||
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
||||||
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||||
|
* University of Stuttgart. All rights reserved.
|
||||||
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
|
* All rights reserved.
|
||||||
|
* $COPYRIGHT$
|
||||||
|
*
|
||||||
|
* Additional copyrights may follow
|
||||||
|
*
|
||||||
|
* $HEADER$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#undef OMPI_BUILDING
|
||||||
|
#include "ompi_config.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_PTHREAD_H
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "include/sys/atomic.h"
|
||||||
|
|
||||||
|
#define TEST_REPS 500
|
||||||
|
|
||||||
|
int32_t val32 = 0;
|
||||||
|
#if OMPI_HAVE_ATOMIC_MATH_64
|
||||||
|
int64_t val64 = 0;
|
||||||
|
#endif
|
||||||
|
int valint = 0;
|
||||||
|
|
||||||
|
|
||||||
|
static void* atomic_math_test(void* arg)
|
||||||
|
{
|
||||||
|
int count = (int) (unsigned long) arg;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0 ; i < count ; ++i) {
|
||||||
|
ompi_atomic_add_32(&val32, 5);
|
||||||
|
#if OMPI_HAVE_ATOMIC_MATH_64
|
||||||
|
ompi_atomic_add_64(&val64, 6);
|
||||||
|
#endif
|
||||||
|
ompi_atomic_add(&valint, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
atomic_math_test_th(int count, int thr_count)
|
||||||
|
{
|
||||||
|
#if OMPI_HAVE_POSIX_THREADS
|
||||||
|
pthread_t *th;
|
||||||
|
int tid, ret = 0;
|
||||||
|
|
||||||
|
th = (pthread_t *) malloc(thr_count * sizeof(pthread_t));
|
||||||
|
if (!th) { perror("malloc"); exit(EXIT_FAILURE); }
|
||||||
|
|
||||||
|
for (tid = 0; tid < thr_count; tid++) {
|
||||||
|
if (pthread_create(&th[tid], NULL, atomic_math_test, (void*) count) != 0) {
|
||||||
|
perror("pthread_create");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -- wait for the thread set to finish -- */
|
||||||
|
for (tid = 0; tid < thr_count; tid++) {
|
||||||
|
void *thread_return;
|
||||||
|
|
||||||
|
if (pthread_join(th[tid], &thread_return) != 0) {
|
||||||
|
perror("pthread_join");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(th);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
#else
|
||||||
|
if (thr_count == 1) {
|
||||||
|
atomic_math_test((void*) count);
|
||||||
|
} else {
|
||||||
|
return 77;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int ret = 77;
|
||||||
|
int num_threads = 1;
|
||||||
|
|
||||||
|
if (argc != 2) {
|
||||||
|
printf("*** Incorrect number of arguments. Skipping test\n");
|
||||||
|
return 77;
|
||||||
|
}
|
||||||
|
num_threads = atoi(argv[1]);
|
||||||
|
|
||||||
|
ret = atomic_math_test_th(TEST_REPS, num_threads);
|
||||||
|
if (ret == 77) return ret;
|
||||||
|
ompi_atomic_mb();
|
||||||
|
if (val32 != TEST_REPS * num_threads * 5) {
|
||||||
|
printf("ompi_atomic_add32 failed. Expected %d, got %d.\n",
|
||||||
|
TEST_REPS * num_threads * 5, val32);
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
#if OMPI_HAVE_ATOMIC_MATH_64
|
||||||
|
if (val64 != TEST_REPS * num_threads * 6) {
|
||||||
|
printf("ompi_atomic_add32 failed. Expected %d, got %d.\n",
|
||||||
|
TEST_REPS * num_threads * 6, val64);
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
printf(" * skipping 64 bit tests\n");
|
||||||
|
#endif
|
||||||
|
if (valint != TEST_REPS * num_threads * 4) {
|
||||||
|
printf("ompi_atomic_add32 failed. Expected %d, got %d.\n",
|
||||||
|
TEST_REPS * num_threads * 4, valint);
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
@ -17,7 +17,6 @@
|
|||||||
#undef OMPI_BUILDING
|
#undef OMPI_BUILDING
|
||||||
#include "ompi_config.h"
|
#include "ompi_config.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
#ifdef HAVE_PTHREAD_H
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
@ -25,7 +24,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "include/sys/atomic.h"
|
#include "include/sys/atomic.h"
|
||||||
#include "atomic_test.h"
|
|
||||||
|
#define TEST_REPS 500
|
||||||
|
|
||||||
int atomic_verbose = 0;
|
int atomic_verbose = 0;
|
||||||
|
|
||||||
@ -109,3 +109,23 @@ atomic_spinlock_test(ompi_lock_t *lock, int count, int id)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int ret = 77;
|
||||||
|
ompi_lock_t lock;
|
||||||
|
int num_threads = 1;
|
||||||
|
|
||||||
|
if (argc != 2) {
|
||||||
|
printf("*** Incorrect number of arguments. Skipping test\n");
|
||||||
|
return 77;
|
||||||
|
}
|
||||||
|
num_threads = atoi(argv[1]);
|
||||||
|
|
||||||
|
ompi_atomic_init(&lock, OMPI_ATOMIC_UNLOCKED);
|
||||||
|
ret = atomic_spinlock_test_th(&lock, TEST_REPS, 0, num_threads);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
||||||
* All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
||||||
* All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
||||||
* University of Stuttgart. All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
||||||
* All rights reserved.
|
|
||||||
* $COPYRIGHT$
|
|
||||||
*
|
|
||||||
* Additional copyrights may follow
|
|
||||||
*
|
|
||||||
* $HEADER$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#undef OMPI_BUILDING
|
|
||||||
#include "ompi_config.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "include/sys/atomic.h"
|
|
||||||
#include "atomic_test.h"
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int ret = 77;
|
|
||||||
ompi_lock_t lock;
|
|
||||||
|
|
||||||
ompi_atomic_init(&lock, OMPI_ATOMIC_UNLOCKED);
|
|
||||||
ret = atomic_spinlock_test_th(&lock, TEST_REPS, 0, 2);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
||||||
* All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
||||||
* All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
||||||
* University of Stuttgart. All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
||||||
* All rights reserved.
|
|
||||||
* $COPYRIGHT$
|
|
||||||
*
|
|
||||||
* Additional copyrights may follow
|
|
||||||
*
|
|
||||||
* $HEADER$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#undef OMPI_BUILDING
|
|
||||||
#include "ompi_config.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "include/sys/atomic.h"
|
|
||||||
#include "atomic_test.h"
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int ret = 77;
|
|
||||||
ompi_lock_t lock;
|
|
||||||
|
|
||||||
ompi_atomic_init(&lock, OMPI_ATOMIC_UNLOCKED);
|
|
||||||
ret = atomic_spinlock_test_th(&lock, TEST_REPS, 0, 5);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
||||||
* All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
||||||
* All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
||||||
* University of Stuttgart. All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
||||||
* All rights reserved.
|
|
||||||
* $COPYRIGHT$
|
|
||||||
*
|
|
||||||
* Additional copyrights may follow
|
|
||||||
*
|
|
||||||
* $HEADER$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#undef OMPI_BUILDING
|
|
||||||
#include "ompi_config.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "include/sys/atomic.h"
|
|
||||||
#include "atomic_test.h"
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int ret = 77;
|
|
||||||
ompi_lock_t lock;
|
|
||||||
|
|
||||||
ompi_atomic_init(&lock, OMPI_ATOMIC_UNLOCKED);
|
|
||||||
ret = atomic_spinlock_test_th(&lock, TEST_REPS, 0, 8);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
||||||
* All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
||||||
* All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
||||||
* University of Stuttgart. All rights reserved.
|
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
||||||
* All rights reserved.
|
|
||||||
* $COPYRIGHT$
|
|
||||||
*
|
|
||||||
* Additional copyrights may follow
|
|
||||||
*
|
|
||||||
* $HEADER$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ATOMIC_TEST_H_
|
|
||||||
#define ATOMIC_TEST_H_
|
|
||||||
|
|
||||||
extern int atomic_verbose;
|
|
||||||
|
|
||||||
#define TEST_REPS 100
|
|
||||||
|
|
||||||
int atomic_spinlock_test(ompi_lock_t *lock, int count, int id);
|
|
||||||
int atomic_spinlock_test_th(ompi_lock_t *lock, int count,
|
|
||||||
int id, int thr_count);
|
|
||||||
|
|
||||||
#endif
|
|
27
test/asm/run_tests
Обычный файл
27
test/asm/run_tests
Обычный файл
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
retval=-1
|
||||||
|
|
||||||
|
progname="`basename $*`"
|
||||||
|
echo "--> Testing $progname"
|
||||||
|
|
||||||
|
for threads in 1 2 4 5 8 ; do
|
||||||
|
$* $threads
|
||||||
|
result=$?
|
||||||
|
if test "$result" = "0" ; then
|
||||||
|
echo " - $threads threads: Passed"
|
||||||
|
if test "$retval" = "-1" ; then
|
||||||
|
retval=0
|
||||||
|
fi
|
||||||
|
elif test "$result" = "77" ; then
|
||||||
|
echo " - $threads threads: Skipped"
|
||||||
|
if test "$retval" = "-1" ; then
|
||||||
|
retval=77
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo " - $threads threads: Failed"
|
||||||
|
retval="$result"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit $retval
|
Загрузка…
x
Ссылка в новой задаче
Block a user