From 24fa075b5c0d54f2035a2ff510a82aa19187eda4 Mon Sep 17 00:00:00 2001 From: Rickard Green Date: Mon, 5 Jan 2015 11:04:34 +0100 Subject: Improve ethread atomics based on GCC builtins * Use of __atomic builtins when available. * Improved configure test that checks for missing memory barrier in __sync_synchronize(). The old approach was to verify known working gcc versions and check gcc version at compile time. Besides not being very safe, the old approach often unnecessarily caused usage of the very expensive workaround. * Introduced (no overhead) workaround for missing clobber in __sync_synchronize() when using buggy LLVM implementation of __sync_synchronize(). * Implement native memory barriers for ARM processors supporting the DMB instruction. * Use of volatile store on Alpha as atomic set operation if no __atomic_store_n() is available (already used on x86/x86_64 Sparc V9, PowerPC, and MIPS). Fallback used when not using volatile store is typically very expensive. * Use volatile load on Alpha and ARM as atomic read operation if no __atomic_load_n() is available (already used on x86/x86_64 Sparc V9, PowerPC, and MIPS). Fallback when not using volatile load is typically very expensive. --- HOWTO/INSTALL.md | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'HOWTO') diff --git a/HOWTO/INSTALL.md b/HOWTO/INSTALL.md index 53b1b8cd8a..7efea77d4c 100644 --- a/HOWTO/INSTALL.md +++ b/HOWTO/INSTALL.md @@ -417,22 +417,33 @@ important when building Erlang/OTP. By default the VM will refuse to build if native atomic memory operations are not available. Erlang/OTP itself provides implementations of native atomic memory operations -that can be used when compiling with a `gcc` compatible compiler on 32-bit -and 64-bit x86, 32-bit and 64-bit SPARC V9, and 32-bit PowerPC. When compiling -with a `gcc` compatible compiler on other architectures, the VM may be able to -make use of native atomic operations using the `__sync_*` primitives, but this -should only be used as a last resort since this wont give you optimal -performance. When compiling on Windows using a MicroSoft Visual C++ compiler -native atomic memory operations are provided by Windows APIs. - -You are recommended to use the native atomic implementation provided by -Erlang/OTP, or the API provided by Windows. If these do not provide native -atomics on your platform, you are recommended to build and install -[libatomic_ops][] before building Erlang/OTP. The `libatomic_ops` library -provides native atomic memory operations for a variety of platforms and -compilers. When building Erlang/OTP you need to inform the build system of -where the `libatomic_ops` library is installed using the -`--with-libatomic_ops=PATH` configure switch. +that can be used when compiling with a `gcc` compatible compiler for 32/64-bit +x86, 32/64-bit SPARC V9, 32-bit PowerPC, or 32-bit Tile. When compiling with +a `gcc` compatible compiler for other architectures, the VM may be able to make +use of native atomic operations using the `__atomic_*` builtins (may be +available when using a `gcc` of at least version 4.7) and/or using the +`__sync_*` builtins (may be available when using a `gcc` of at least version +4.1). If only the `gcc`'s `__sync_*` builtins are available, the performance +will suffer. Such a configuration should only be used as a last resort. When +compiling on Windows using a MicroSoft Visual C++ compiler native atomic +memory operations are provided by Windows APIs. + +Native atomic implementation in the order preferred: +1. The implementation provided by Erlang/OTP. +2. The API provided by Windows. +3. The implementation based on the `gcc` `__atomic_*` builtins. +4. If none of the above are available for your architecture/compiler, you + are recommended to build and install [libatomic_ops][] before building + Erlang/OTP. The `libatomic_ops` library provides native atomic memory + operations for a variety of architectures and compilers. When building + Erlang/OTP you need to inform the build system of where the + `libatomic_ops` library is installed using the + `--with-libatomic_ops=PATH` `configure` switch. +5. As a last resort, the implementation solely based on the `gcc` + `__sync_*` builtins. This will however cause lots of expensive and + unnecessary memory barrier instructions to be issued. That is, + performance will suffer. The `configure` script will warn at the end + of its execution if it cannot find any other alternative than this. ### Building ### @@ -849,7 +860,7 @@ Copyright and License %CopyrightBegin% -Copyright Ericsson AB 1998-2014. All Rights Reserved. +Copyright Ericsson AB 1998-2015. 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 -- cgit v1.2.3