Permalink
Browse files

Improve ethread atomics

The ethread atomics API now also provide double word size atomics.
Double word size atomics are implemented using native atomic
instructions on x86 (when the cmpxchg8b instruction is available)
and on x86_64 (when the cmpxchg16b instruction is available). On
other hardware where 32-bit atomics or word size atomics are
available, an optimized fallback is used; otherwise, a spinlock,
or a mutex based fallback is used.

The ethread library now performs runtime tests for presence of
hardware features, such as for example SSE2 instructions, instead
of requiring this to be determined at compile time.

There are now functions implementing each atomic operation with the
following implied memory barrier semantics: none, read, write,
acquire, release, and full. Some of the operation-barrier
combinations aren't especially useful. But instead of filtering
useful ones out, and potentially miss a useful one, we implement
them all.

A much smaller set of functionality for native atomics are required
to be implemented than before. More or less only cmpxchg and a
membar macro are required to be implemented for each atomic size.
Other functions will automatically be constructed from these. It is,
of course, often wise to implement more that this if possible from a
performance perspective.
  • Loading branch information...
1 parent 4a5a758 commit 7f19af0423934f85c74ccb75546e5e3a6b6d10e8 @rickard-green rickard-green committed Jan 2, 2011
Showing with 19,442 additions and 3,039 deletions.
  1. +1 −7 INSTALL.md
  2. +1 −5 configure.in
  3. +250 −184 erts/aclocal.m4
  4. +64 −0 erts/emulator/beam/erl_bif_info.c
  5. +3 −3 erts/emulator/beam/erl_process_lock.h
  6. +498 −508 erts/emulator/beam/erl_smp.h
  7. +613 −348 erts/emulator/beam/erl_threads.h
  8. +8,562 −444 erts/include/internal/ethr_atomics.h
  9. +5 −1 erts/include/internal/ethr_internal.h
  10. +17 −13 erts/include/internal/ethr_mutex.h
  11. +98 −77 erts/include/internal/ethr_optimized_fallbacks.h
  12. +89 −73 erts/include/internal/ethread.h
  13. +107 −11 erts/include/internal/ethread_header_config.h.in
  14. +86 −165 erts/include/internal/gcc/ethr_atomic.h
  15. +115 −0 erts/include/internal/gcc/ethr_dw_atomic.h
  16. +73 −0 erts/include/internal/gcc/ethr_membar.h
  17. +14 −6 erts/include/internal/gcc/ethread.h
  18. +151 −183 erts/include/internal/i386/atomic.h
  19. +278 −0 erts/include/internal/i386/ethr_dw_atomic.h
  20. +114 −0 erts/include/internal/i386/ethr_membar.h
  21. +3 −5 erts/include/internal/i386/ethread.h
  22. +4 −1 erts/include/internal/i386/rwlock.h
  23. +17 −10 erts/include/internal/i386/spinlock.h
  24. +125 −173 erts/include/internal/libatomic_ops/ethr_atomic.h
  25. +75 −0 erts/include/internal/libatomic_ops/ethr_membar.h
  26. +13 −1 erts/include/internal/libatomic_ops/ethread.h
  27. +102 −46 erts/include/internal/ppc32/atomic.h
  28. +63 −0 erts/include/internal/ppc32/ethr_membar.h
  29. +1 −4 erts/include/internal/ppc32/ethread.h
  30. +9 −6 erts/include/internal/ppc32/rwlock.h
  31. +6 −4 erts/include/internal/ppc32/spinlock.h
  32. +3 −5 erts/include/internal/pthread/ethr_event.h
  33. +30 −164 erts/include/internal/sparc32/atomic.h
  34. +115 −0 erts/include/internal/sparc32/ethr_membar.h
  35. +2 −5 erts/include/internal/sparc32/ethread.h
  36. +10 −7 erts/include/internal/sparc32/rwlock.h
  37. +7 −4 erts/include/internal/sparc32/spinlock.h
  38. +38 −98 erts/include/internal/tile/atomic.h
  39. +35 −0 erts/include/internal/tile/ethr_membar.h
  40. +2 −3 erts/include/internal/tile/ethread.h
  41. +330 −265 erts/include/internal/win/ethr_atomic.h
  42. +154 −0 erts/include/internal/win/ethr_dw_atomic.h
  43. +8 −8 erts/include/internal/win/ethr_event.h
  44. +145 −0 erts/include/internal/win/ethr_membar.h
  45. +3 −1 erts/include/internal/win/ethread.h
  46. +8 −6 erts/lib_src/Makefile.in
  47. +4,116 −163 erts/lib_src/common/ethr_atomics.c
  48. +78 −5 erts/lib_src/common/ethr_aux.c
  49. +3 −2 erts/lib_src/common/ethr_mutex.c
  50. +31 −0 erts/lib_src/pthread/ethr_x86_sse2_asm.c
  51. +101 −1 erts/lib_src/pthread/ethread.c
  52. +2,186 −0 erts/lib_src/utils/make_atomics_api
  53. +7 −15 erts/lib_src/win/ethr_event.c
  54. +21 −1 erts/lib_src/win/ethread.c
  55. +27 −5 erts/test/ethread_SUITE.erl
  56. +425 −3 erts/test/ethread_SUITE_data/ethread_tests.c
View
@@ -273,12 +273,6 @@ Some of the available `configure` options are:
* `--with-ssl=PATH` - Specify location of OpenSSL include and lib
* `--{with,without}-ssl` - OpenSSL (without implies that the `crypto`,
`ssh`, and `ssl` won't be built)
-* `--enable-ethread-pre-pentium4-compatibility` - Enable compatibility with
- x86 processors before pentium 4 (back to 486) in the ethread library. If
- not passed the ethread library (part of the runtime system) will use
- instructions that first appeared on the pentium 4 processor when building
- for x86. This option will be automatically enabled if required on the
- build machine.
* `--with-libatomic_ops=PATH` - Use the `libatomic_ops` library for atomic
memory accesses. If `configure` should inform you about no native atomic
implementation available, you typically want to try using the
@@ -726,7 +720,7 @@ Copyright and License
%CopyrightBegin%
-Copyright Ericsson AB 1998-2010. All Rights Reserved.
+Copyright Ericsson AB 1998-2011. All Rights Reserved.
The contents of this file are subject to the Erlang Public License,
Version 1.1, (the "License"); you may not use this file except in
View
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
dnl %CopyrightBegin%
dnl
-dnl Copyright Ericsson AB 1998-2010. All Rights Reserved.
+dnl Copyright Ericsson AB 1998-2011. All Rights Reserved.
dnl
dnl The contents of this file are subject to the Erlang Public License,
dnl Version 1.1, (the "License"); you may not use this file except in
@@ -306,10 +306,6 @@ AS_HELP_STRING([--enable-m32-build],
esac
],enable_m32_build=no)
-AC_ARG_ENABLE(ethread-pre-pentium4-compatibility,
- AS_HELP_STRING([--enable-ethread-pre-pentium4-compatibility],
- [enable compatibility with x86 processors before pentium 4 (back to 486) in the ethread library]))
-
AC_ARG_WITH(libatomic_ops,
AS_HELP_STRING([--with-libatomic_ops=PATH],
[specify and prefer usage of libatomic_ops in the ethread library]))
Oops, something went wrong.

0 comments on commit 7f19af0

Please sign in to comment.