Merge branch 'release-4-5-patches' of git@git.gromacs.org:gromacs into release-4...
[gromacs/rigid-bodies.git] / include / thread_mpi.h
blobab38d4fccbae3cccd5098e2f57d5945f3fe784fa
1 /*
2 This source code file is part of thread_mpi.
3 Written by Sander Pronk, Erik Lindahl, and possibly others.
5 Copyright (c) 2009, Sander Pronk, Erik Lindahl.
6 All rights reserved.
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10 1) Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 2) Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15 3) Neither the name of the copyright holders nor the
16 names of its contributors may be used to endorse or promote products
17 derived from this software without specific prior written permission.
19 THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY
20 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY
23 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 If you want to redistribute modifications, please consider that
31 scientific software is very special. Version control is crucial -
32 bugs must be traceable. We will be happy to consider code for
33 inclusion in the official distribution, but derived work should not
34 be called official thread_mpi. Details are found in the README & COPYING
35 files.
38 /*
39 thread_mpi is a cross-platform threading library for applications in
40 high-performance computing. It supports:
42 - Cross-platform thread primitives (thread creation, mutexes, spinlocks,
43 barriers, thread-local storage, etc.).
44 - Cross-platform atomic operations (compare-and-swap, add-return, etc) for
45 safe lock-free synchronization.
46 - An implementation of (currently, much of) MPI, either as a drop-in
47 replacement, or for use in conjunction with a networked MPI
48 implementation.
49 - Shared-memory allocation and memory management (planned, as of now).
50 - Basic lock-free data structures (planned, as of now).
52 Because it can be used as a drop-in replacement for MPI, existing codes
53 using MPI can start using thread_mpi without major changes in the
54 source code, assuming -- and this is a big assumption -- that the code
55 is thread-safe.
57 Alternatively, networked MPI calls can be used in conjunction with
58 thread_mpi calls (simply by using
59 "#include <thread_mpi.h>"
60 instead of
61 "#include <tmpi.h>"
62 and pre-fixing all thread_mpi MPI-like calls with tMPI instead of MPI.
64 The availability of both MPI calls and shared-memory constructs makes it
65 possible to transition (relatively) seamlessly from an MPI-style code
66 to code that's optimal on multicore CPUs.
68 Although MPI-style message passing isn't neccesarily optimal for
69 performance on shared-memory systems, the MPI communicator concept and
70 its emphasis on collective operations makes sense even when computing on
71 one machine with multiple cores. The communicator forms the basis for
72 the shared-memory allocation and lock-free data structure implementations
73 in thread_mpi.
75 Although usable as a stand-alone library, thread_mpi is designed to
76 be incorporated in the code tree, eliminating any external build
77 requirements. The BSD-style license that this library is distributed
78 with reflects this.
80 The atomic operations (such as compare-and-swap) are supported on:
81 - gcc on x86, x86_64, PowerPC and Itanium.
82 - Intel compilers on x86, x86_64 and Itanium.
83 - xlc on PowerPC.
84 - (partial) HP/UX compilers on Itanium.
87 /** \file
89 * \brief Convenience header file for non-MPI compatibility.
91 * This file includes the tMPI header file thread_mpi/tmpi.h, as well
92 * as thread_mpi/threads.h and thread_mpi/atomic.h header files. If you'd
93 * like to use the components individually, include the relevant header
94 * files directly.
97 #include "thread_mpi/atomic.h"
98 #include "thread_mpi/threads.h"
99 #include "thread_mpi/barrier.h"
100 #include "thread_mpi/event.h"
101 #include "thread_mpi/lock.h"
102 #include "thread_mpi/tmpi.h"
103 #include "thread_mpi/collective.h"
104 #include "thread_mpi/hwinfo.h"